Skip to content

Commit 1b3ada1

Browse files
committed
Refactor sensor for microbit & clue
1 parent d784817 commit 1b3ada1

4 files changed

Lines changed: 25 additions & 5 deletions

File tree

src/view/components/toolbar/SensorModalUtils.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ export const CPX_TOOLBAR_ICON_ID = {
6565
};
6666

6767
export const MICROBIT_TOOLBAR_ICON_ID = {
68-
TEMPERATURE: "toolbar-temperature-sensor",
68+
TEMPERATURE: "toolbar-microbit-temperature-sensor",
6969
LIGHT: "toolbar-microbit-light-sensor",
7070
ACCELEROMETER: "toolbar-accelerometer-sensor",
7171
LEDS: "toolbar-microbit-led",
@@ -309,6 +309,7 @@ export const LABEL_TO_MODAL_CONTENT_CONSTRUCTOR = new Map([
309309
MICROBIT_TOOLBAR_ICON_ID.ACCELEROMETER,
310310
MICROBIT_MODAL.ACCELEROMETER_CONTENT,
311311
],
312+
[MICROBIT_TOOLBAR_ICON_ID.TEMPERATURE, MICROBIT_MODAL.TEMPERATURE_CONTENT],
312313
[MICROBIT_TOOLBAR_ICON_ID.LIGHT, MICROBIT_MODAL.LIGHT_CONTENT],
313314
[MICROBIT_TOOLBAR_ICON_ID.COMPASS, MICROBIT_MODAL.COMPASS_CONTENT],
314315
[MICROBIT_TOOLBAR_ICON_ID.LEDS, MICROBIT_MODAL.LED_CONTENT],

src/view/components/toolbar/clue/ClueModalContent.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,15 @@ export const TEMPERATURE_CONTENT = (
1212
onUpdateValue: (sensor: SENSOR_LIST, value: number) => void,
1313
sensorValues: { [key: string]: number }
1414
): IModalContent => {
15+
const temperatureSensorValues = {
16+
T: sensorValues[SENSOR_LIST.TEMPERATURE]
17+
}
1518
return {
1619
components: [
17-
<TemperatureSensorBar
18-
onUpdateSensor={onUpdateValue}
19-
value={sensorValues[SENSOR_LIST.TEMPERATURE]}
20+
<GenericSliderComponent
21+
onUpdateValue={onUpdateValue}
22+
axisValues={temperatureSensorValues}
23+
axisProperties={SENSOR_PROPERTIES.TEMPERATURE_SENSOR_PROPERTIES}
2024
/>,
2125
],
2226
descriptionText: "toolbar-clue-temperature-sensor.description",

src/view/components/toolbar/clue/ClueSensorProperties.tsx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,4 +181,19 @@ export const MOTION_SENSOR_PROPERTIES: ISensorProps = {
181181
MOTION_SLIDER_PROPS_Z,
182182
],
183183
unitLabel: "m/s2",
184+
};
185+
186+
const TEMPERATURE_SLIDER_PROPS: ISliderProps = {
187+
axisLabel: "T",
188+
maxLabel: "Hot",
189+
maxValue: 125,
190+
minLabel: "Cold",
191+
minValue: -55,
192+
type: SENSOR_LIST.TEMPERATURE,
193+
};
194+
195+
export const TEMPERATURE_SENSOR_PROPERTIES: ISensorProps = {
196+
LABEL: "Temperature sensor",
197+
sliderProps: [TEMPERATURE_SLIDER_PROPS],
198+
unitLabel: "°C",
184199
};

src/view/components/toolbar/microbit/MicrobitSensorProperties.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export const MOTION_SENSOR_PROPERTIES: ISensorProps = {
5555
};
5656

5757
const TEMPERATURE_SLIDER_PROPS: ISliderProps = {
58-
axisLabel: " ",
58+
axisLabel: "T",
5959
maxLabel: "Hot",
6060
maxValue: 125,
6161
minLabel: "Cold",

0 commit comments

Comments
 (0)