Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make brushless button actually change ebb config #133

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,16 @@ export async function startServer (port: number, hardware: Hardware = 'v3', com:
res.status(200).end();
})

app.post("/change-hardware", (req, res) => {
if (ebb?.hardware === 'brushless') {
ebb.hardware = 'v3';
} else if (ebb?.hardware === 'v3') {
ebb.hardware = 'brushless';
}
// fixme: change planning.ts : Device
res.status(200).end();
})

function broadcast(msg: any) {
clients.forEach((ws) => {
try {
Expand Down
14 changes: 9 additions & 5 deletions src/ui.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,11 @@ function HardwareOptions({ state }: { state: State }) {
<input
type="checkbox"
checked={state.planOptions.hardware === 'brushless'}
onChange={(e) => setHardware(e.target.checked ? 'brushless' : 'v3')}
onChange={(e) => {
// fixme combine if possible
setHardware(e.target.checked ? 'brushless' : 'v3');
fetch("/change-hardware", { method: "POST" });
}}
/>
brushless
</label>
Expand Down Expand Up @@ -630,7 +634,7 @@ function PlanStatistics({plan}: {plan: Plan}) {

function TimeLeft({plan, progress, currentMotionStartedTime, paused}: {
plan: Plan;
progress: number | null;
progress: number | null;
currentMotionStartedTime: Date | null;
paused: boolean;
}) {
Expand Down Expand Up @@ -1216,9 +1220,9 @@ function Root() {
<div className="section-header">plot</div>
<div className="section-body section-body__plot">
<PlanStatistics plan={plan} />
<TimeLeft
plan={plan}
progress={state.progress}
<TimeLeft
plan={plan}
progress={state.progress}
currentMotionStartedTime={currentMotionStartedTime}
paused={state.paused}
/>
Expand Down