mirror of
https://github.com/pybricks/pybricks-code.git
synced 2026-09-14 10:35:11 +00:00
firmware: add multi-step dialog
This commit is contained in:
@@ -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>
|
||||
);
|
||||
};
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user