Skip to content
This repository was archived by the owner on Dec 23, 2021. It is now read-only.

Commit a10f3eb

Browse files
committed
Add sliders for pressure and proximity
1 parent 7eb30b6 commit a10f3eb

File tree

5 files changed

+67
-13
lines changed

5 files changed

+67
-13
lines changed

src/view/components/clue/Clue.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ const DEFAULT_STATE = {
2323
[SENSOR_LIST.MOTION_X]: 0,
2424
[SENSOR_LIST.MOTION_Y]: 0,
2525
[SENSOR_LIST.MOTION_Z]: 0,
26+
[SENSOR_LIST.HUMIDITY]: 0,
27+
[SENSOR_LIST.PRESSURE]: 0,
28+
[SENSOR_LIST.PROXIMITY]: 0,
2629
},
2730
};
2831

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

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -101,16 +101,20 @@ export const CLUE_HUMIDITY_MODAL_CONTENT = (
101101
onUpdateValue: (sensor: SENSOR_LIST, value: number) => void,
102102
sensorValues: { [key: string]: number }
103103
): IModalContent => {
104+
const humiditySensorValues = {
105+
H: sensorValues[SENSOR_LIST.HUMIDITY],
106+
};
104107
return {
105108
descriptionTitle: "toolbar-light-sensor.title",
106109
tagInput: TAG_INPUT_SVG,
107110
tagOutput: undefined,
108111
descriptionText: "toolbar-light-sensor.description",
109112
tryItDescription: "toolbar-light-sensor.tryItDescription",
110113
components: [
111-
<LightSensorBar
114+
<ThreeDimensionSlider
112115
onUpdateValue={onUpdateValue}
113-
value={sensorValues[SENSOR_LIST.LIGHT]}
116+
axisValues={humiditySensorValues}
117+
axisProperties={SENSOR_PROPERTIES.CLUE_HUMIDITY_PROPERTIES}
114118
/>,
115119
],
116120
id: "light_sensor",
@@ -139,16 +143,20 @@ export const CLUE_PROXIMITY_MODAL_CONTENT = (
139143
onUpdateValue: (sensor: SENSOR_LIST, value: number) => void,
140144
sensorValues: { [key: string]: number }
141145
): IModalContent => {
146+
const proximitySensorValues = {
147+
P: sensorValues[SENSOR_LIST.PROXIMITY],
148+
};
142149
return {
143150
descriptionTitle: "toolbar-light-sensor.title",
144151
tagInput: TAG_INPUT_SVG,
145152
tagOutput: undefined,
146153
descriptionText: "toolbar-light-sensor.description",
147154
tryItDescription: "toolbar-light-sensor.tryItDescription",
148155
components: [
149-
<LightSensorBar
156+
<ThreeDimensionSlider
150157
onUpdateValue={onUpdateValue}
151-
value={sensorValues[SENSOR_LIST.LIGHT]}
158+
axisValues={proximitySensorValues}
159+
axisProperties={SENSOR_PROPERTIES.CLUE__PROXIMITY_PROPERTIES}
152160
/>,
153161
],
154162
id: "light_sensor",
@@ -158,16 +166,20 @@ export const CLUE_PRESSURE_MODAL_CONTENT = (
158166
onUpdateValue: (sensor: SENSOR_LIST, value: number) => void,
159167
sensorValues: { [key: string]: number }
160168
): IModalContent => {
169+
const pressureSensorValues = {
170+
P: sensorValues[SENSOR_LIST.PRESSURE],
171+
};
161172
return {
162173
descriptionTitle: "toolbar-light-sensor.title",
163174
tagInput: TAG_INPUT_SVG,
164175
tagOutput: undefined,
165176
descriptionText: "toolbar-light-sensor.description",
166177
tryItDescription: "toolbar-light-sensor.tryItDescription",
167178
components: [
168-
<LightSensorBar
179+
<ThreeDimensionSlider
169180
onUpdateValue={onUpdateValue}
170-
value={sensorValues[SENSOR_LIST.LIGHT]}
181+
axisValues={pressureSensorValues}
182+
axisProperties={SENSOR_PROPERTIES.CLUE_PRESSURE_PROPERTIES}
171183
/>,
172184
],
173185
id: "light_sensor",

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

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,45 @@ export const CLUE_LIGHT_PROPERTIES: ISensorProps = {
4040
sliderProps: [CLUE_SLIDER_R, CLUE_SLIDER_G, CLUE_SLIDER_B, CLUE_SLIDER_C],
4141
unitLabel: "Lux",
4242
};
43+
export const CLUE_HUMIDITY_PROPERTIES: ISensorProps = {
44+
LABEL: "Humidity Sensor",
45+
sliderProps: [
46+
{
47+
axisLabel: "H",
48+
maxLabel: "Max",
49+
maxValue: 100,
50+
minLabel: "Min",
51+
minValue: 0,
52+
type: SENSOR_LIST.HUMIDITY,
53+
},
54+
],
55+
unitLabel: "%",
56+
};
57+
export const CLUE__PROXIMITY_PROPERTIES: ISensorProps = {
58+
LABEL: "Humidity Sensor",
59+
sliderProps: [
60+
{
61+
axisLabel: "P",
62+
maxLabel: "Max",
63+
maxValue: 100,
64+
minLabel: "Min",
65+
minValue: 0,
66+
type: SENSOR_LIST.PROXIMITY,
67+
},
68+
],
69+
unitLabel: "%",
70+
};
71+
export const CLUE_PRESSURE_PROPERTIES: ISensorProps = {
72+
LABEL: "Humidity Sensor",
73+
sliderProps: [
74+
{
75+
axisLabel: "P",
76+
maxLabel: "Max",
77+
maxValue: 100,
78+
minLabel: "Min",
79+
minValue: 0,
80+
type: SENSOR_LIST.PRESSURE,
81+
},
82+
],
83+
unitLabel: "%",
84+
};

src/view/components/toolbar/motion/threeDimensionSlider/ThreeDimensionSlider.tsx

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
11
import * as React from "react";
22
import { SENSOR_LIST } from "../../../../constants";
3-
import {
4-
ISensorProps,
5-
X_SLIDER_INDEX,
6-
Y_SLIDER_INDEX,
7-
Z_SLIDER_INDEX,
8-
ISliderProps,
9-
} from "../../../../viewUtils";
3+
import { ISensorProps, ISliderProps } from "../../../../viewUtils";
104
import InputSlider from "../../InputSlider";
115

126
interface IProps {

src/view/constants.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,9 @@ export enum SENSOR_LIST {
103103
LIGHT_G = "light_g",
104104
LIGHT_B = "light_b",
105105
LIGHT_C = "light_c",
106+
HUMIDITY = "humidity",
107+
PRESSURE = "pressure",
108+
PROXIMITY = "proximity",
106109
}
107110

108111
export const GESTURES = [

0 commit comments

Comments
 (0)