firmware: add multi-step dialog

This commit is contained in:
David Lechner
2022-07-20 12:32:17 -05:00
parent b70777178c
commit 85deb42f76
42 changed files with 1119 additions and 327 deletions
+30
View File
@@ -0,0 +1,30 @@
// SPDX-License-Identifier: MIT
// Copyright (c) 2022 The Pybricks Authors
import { Radio, RadioGroup } from '@blueprintjs/core';
import React from 'react';
import { Hub } from '.';
type HubPickerProps = {
hubType: Hub;
onChange: (hubType: Hub) => void;
};
export const HubPicker: React.VoidFunctionComponent<HubPickerProps> = ({
hubType,
onChange,
}) => {
return (
<RadioGroup
selectedValue={hubType}
onChange={(e) => onChange(e.currentTarget.value as Hub)}
>
<Radio value={Hub.Move}>BOOST Move Hub</Radio>
<Radio value={Hub.City}>City Hub</Radio>
<Radio value={Hub.Technic}>Technic Hub</Radio>
<Radio value={Hub.Prime}>SPIKE Prime Hub</Radio>
<Radio value={Hub.Essential}>SPIKE Essential Hub</Radio>
<Radio value={Hub.Inventor}>MINDSTORMS Robot Inventor Hub</Radio>
</RadioGroup>
);
};
+59
View File
@@ -0,0 +1,59 @@
// SPDX-License-Identifier: MIT
// Copyright (c) 2022 The Pybricks Authors
/** Supported hub types. */
export enum Hub {
/** BOOST Move hub */
Move = 'movehub',
/** City hub */
City = 'cityhub',
/** Technic hub */
Technic = 'technichub',
/** MINDSTORMS Robot Inventor hub */
Inventor = 'inventorhub',
/** SPIKE Prime hub */
Prime = 'primehub',
/** SPIKE Essential hub */
Essential = 'essentialhub',
}
/**
* Tests if hub has a USB port.
*/
export function hubHasUSB(hub: Hub): boolean {
switch (hub) {
case Hub.Prime:
case Hub.Essential:
case Hub.Inventor:
return true;
default:
return false;
}
}
/**
* Tests if hub has a Bluetooth button.
*/
export function hubHasBluetoothButton(hub: Hub): boolean {
switch (hub) {
case Hub.Prime:
case Hub.Inventor:
return true;
default:
return false;
}
}
/**
* Tests if hub has external flash memory.
*/
export function hubHasExternalFlash(hub: Hub): boolean {
switch (hub) {
case Hub.Prime:
case Hub.Essential:
case Hub.Inventor:
return true;
default:
return false;
}
}