From 609567d3c8e5a88823e248f14a7970da125f2d1c Mon Sep 17 00:00:00 2001 From: xnkevinnguyen Date: Mon, 20 Apr 2020 08:55:36 -0700 Subject: [PATCH 01/16] Add precision to input slider --- src/view/components/cpx/Cpx.tsx | 2 +- .../toolbar/GenericSliderComponent.tsx | 1 + src/view/components/toolbar/InputSlider.tsx | 12 +++++++++--- .../toolbar/clue/ClueSensorProperties.tsx | 17 +++++++++++++++++ .../toolbar/cpx/CpxSensorProperties.tsx | 7 ++++++- .../microbit/MicrobitSensorProperties.tsx | 5 +++++ src/view/viewUtils.tsx | 1 + 7 files changed, 40 insertions(+), 5 deletions(-) diff --git a/src/view/components/cpx/Cpx.tsx b/src/view/components/cpx/Cpx.tsx index d91728fba..a28343b28 100644 --- a/src/view/components/cpx/Cpx.tsx +++ b/src/view/components/cpx/Cpx.tsx @@ -11,7 +11,7 @@ import Simulator from "./CpxSimulator"; // Component grouping the functionality for circuit playground express const DEFAULT_STATE = { sensors: { - [SENSOR_LIST.TEMPERATURE]: 0, + [SENSOR_LIST.TEMPERATURE]: 0.0, [SENSOR_LIST.LIGHT]: 0, [SENSOR_LIST.MOTION_X]: 0, [SENSOR_LIST.MOTION_Y]: 0, diff --git a/src/view/components/toolbar/GenericSliderComponent.tsx b/src/view/components/toolbar/GenericSliderComponent.tsx index 48e2ec091..273896621 100644 --- a/src/view/components/toolbar/GenericSliderComponent.tsx +++ b/src/view/components/toolbar/GenericSliderComponent.tsx @@ -29,6 +29,7 @@ export const GenericSliderComponent: React.FC = props => { value={ props.axisValues[sliderProperties.axisLabel] } + step={sliderProperties.step} />
diff --git a/src/view/components/toolbar/InputSlider.tsx b/src/view/components/toolbar/InputSlider.tsx index d98e118cc..b4c0a167a 100644 --- a/src/view/components/toolbar/InputSlider.tsx +++ b/src/view/components/toolbar/InputSlider.tsx @@ -21,6 +21,7 @@ class InputSlider extends React.Component { render() { const isInputDisabled = this.context === VIEW_STATE.PAUSE; + const nbDecimals = this.props.step.toString().split(".")[1].length || 0; return (
{this.props.axisLabel} @@ -31,8 +32,9 @@ class InputSlider extends React.Component { onInput={this.handleOnChange} defaultValue={this.props.minValue.toLocaleString()} pattern={`^-?[0-9]{0,${ - this.props.maxValue.toString().length - }}$`} + (this.props.maxValue / this.props.step).toString() + .length + }}[.]{0,${nbDecimals > 0 ? 1 : 0}}[0-9]{0,${nbDecimals}}$`} onKeyUp={this.handleOnChange} aria-label={`${this.props.type} sensor input ${this.props.axisLabel}`} /> @@ -56,6 +58,7 @@ class InputSlider extends React.Component { aria-label={`${this.props.type} sensor`} defaultValue={this.props.minValue.toLocaleString()} disabled={isInputDisabled} + step={this.props.step} /> {this.props.minLabel} @@ -100,7 +103,8 @@ class InputSlider extends React.Component { }; private validateRange = (valueString: string) => { - let valueInt = parseInt(valueString, 10); + let valueInt = parseFloat(valueString); + console.log(`original value ${valueString}`); if (valueInt < this.props.minValue) { valueInt = this.props.minValue; this.setState({ value: valueInt }); @@ -108,6 +112,8 @@ class InputSlider extends React.Component { valueInt = this.props.maxValue; this.setState({ value: valueInt }); } + console.log(`updated value ${valueInt}`); + return valueInt; }; } diff --git a/src/view/components/toolbar/clue/ClueSensorProperties.tsx b/src/view/components/toolbar/clue/ClueSensorProperties.tsx index 2e2b9975a..e3293a493 100644 --- a/src/view/components/toolbar/clue/ClueSensorProperties.tsx +++ b/src/view/components/toolbar/clue/ClueSensorProperties.tsx @@ -8,6 +8,7 @@ const CLUE_SLIDER_R: ISliderProps = { minLabel: "Min", minValue: 0, type: SENSOR_LIST.LIGHT_R, + step: 1, }; const CLUE_SLIDER_G: ISliderProps = { @@ -17,6 +18,7 @@ const CLUE_SLIDER_G: ISliderProps = { minLabel: "Min", minValue: 0, type: SENSOR_LIST.LIGHT_G, + step: 1, }; const CLUE_SLIDER_B: ISliderProps = { @@ -26,6 +28,7 @@ const CLUE_SLIDER_B: ISliderProps = { minLabel: "Min", minValue: 0, type: SENSOR_LIST.LIGHT_B, + step: 1, }; const CLUE_SLIDER_C: ISliderProps = { axisLabel: "C", @@ -34,6 +37,7 @@ const CLUE_SLIDER_C: ISliderProps = { minLabel: "Min", minValue: 0, type: SENSOR_LIST.LIGHT_C, + step: 1, }; export const CLUE_LIGHT_PROPERTIES: ISensorProps = { @@ -50,6 +54,7 @@ const CLUE_MAGNET_X: ISliderProps = { maxValue: 1000, minValue: -1000, type: SENSOR_LIST.MAGNET_X, + step: 1, }; const CLUE_MAGNET_Y: ISliderProps = { axisLabel: "Y", @@ -58,6 +63,7 @@ const CLUE_MAGNET_Y: ISliderProps = { maxValue: 1000, minValue: -1000, type: SENSOR_LIST.MAGNET_Y, + step: 1, }; const CLUE_MAGNET_Z: ISliderProps = { axisLabel: "Z", @@ -66,6 +72,7 @@ const CLUE_MAGNET_Z: ISliderProps = { maxValue: 1000, minValue: -1000, type: SENSOR_LIST.MAGNET_Z, + step: 1, }; export const CLUE_MAGNET_PROPERTIES: ISensorProps = { @@ -80,6 +87,7 @@ const CLUE_GYRO_X: ISliderProps = { maxValue: 1000, minValue: -1000, type: SENSOR_LIST.GYRO_X, + step: 1, }; const CLUE_GYRO_Y: ISliderProps = { axisLabel: "Y", @@ -88,6 +96,7 @@ const CLUE_GYRO_Y: ISliderProps = { maxValue: 1000, minValue: -1000, type: SENSOR_LIST.GYRO_Y, + step: 1, }; const CLUE_GYRO_Z: ISliderProps = { axisLabel: "Z", @@ -96,6 +105,7 @@ const CLUE_GYRO_Z: ISliderProps = { maxValue: 1000, minValue: -1000, type: SENSOR_LIST.GYRO_Z, + step: 1, }; export const CLUE_GYRO_PROPERTIES: ISensorProps = { @@ -114,6 +124,7 @@ export const CLUE_HUMIDITY_PROPERTIES: ISensorProps = { minLabel: "Min", minValue: 0, type: SENSOR_LIST.HUMIDITY, + step: 1, }, ], unitLabel: "%", @@ -128,6 +139,7 @@ export const CLUE__PROXIMITY_PROPERTIES: ISensorProps = { minLabel: "Min", minValue: 0, type: SENSOR_LIST.PROXIMITY, + step: 1, }, ], unitLabel: "", @@ -142,6 +154,7 @@ export const CLUE_PRESSURE_PROPERTIES: ISensorProps = { minLabel: "Min", minValue: 800, type: SENSOR_LIST.PRESSURE, + step: 1, }, ], unitLabel: "hPa", @@ -153,6 +166,7 @@ const MOTION_SLIDER_PROPS_X: ISliderProps = { minLabel: "Left", minValue: -1023, type: SENSOR_LIST.MOTION_X, + step: 1, }; const MOTION_SLIDER_PROPS_Y: ISliderProps = { @@ -162,6 +176,7 @@ const MOTION_SLIDER_PROPS_Y: ISliderProps = { minLabel: "Back", minValue: -1023, type: SENSOR_LIST.MOTION_Y, + step: 1, }; const MOTION_SLIDER_PROPS_Z: ISliderProps = { @@ -171,6 +186,7 @@ const MOTION_SLIDER_PROPS_Z: ISliderProps = { minLabel: "Up", minValue: -1023, type: SENSOR_LIST.MOTION_Z, + step: 1, }; export const MOTION_SENSOR_PROPERTIES: ISensorProps = { @@ -190,6 +206,7 @@ const TEMPERATURE_SLIDER_PROPS: ISliderProps = { minLabel: "Cold", minValue: -55, type: SENSOR_LIST.TEMPERATURE, + step: 1, }; export const TEMPERATURE_SENSOR_PROPERTIES: ISensorProps = { diff --git a/src/view/components/toolbar/cpx/CpxSensorProperties.tsx b/src/view/components/toolbar/cpx/CpxSensorProperties.tsx index 6a5a9990a..f91f91469 100644 --- a/src/view/components/toolbar/cpx/CpxSensorProperties.tsx +++ b/src/view/components/toolbar/cpx/CpxSensorProperties.tsx @@ -2,12 +2,13 @@ import { SENSOR_LIST } from "../../../constants"; import { ISensorProps, ISliderProps } from "../../../viewUtils"; const LIGHT_SLIDER_PROPS: ISliderProps = { - maxValue: 255, + maxValue: 320, minValue: 0, minLabel: "Dark", maxLabel: "Bright", type: "light", axisLabel: "L", + step: 1, }; export const LIGHT_SENSOR_PROPERTIES: ISensorProps = { @@ -23,6 +24,7 @@ const TEMPERATURE_SLIDER_PROPS: ISliderProps = { minLabel: "Cold", minValue: -55, type: SENSOR_LIST.TEMPERATURE, + step: 0.1, }; export const TEMPERATURE_SENSOR_PROPERTIES: ISensorProps = { LABEL: "Temperature sensor", @@ -37,6 +39,7 @@ const MOTION_SLIDER_PROPS_X: ISliderProps = { minLabel: "Left", minValue: -78, type: SENSOR_LIST.MOTION_X, + step: 1, }; const MOTION_SLIDER_PROPS_Y: ISliderProps = { axisLabel: "Y", @@ -45,6 +48,7 @@ const MOTION_SLIDER_PROPS_Y: ISliderProps = { minLabel: "Back", minValue: -78, type: SENSOR_LIST.MOTION_Y, + step: 1, }; const MOTION_SLIDER_PROPS_Z: ISliderProps = { axisLabel: "Z", @@ -53,6 +57,7 @@ const MOTION_SLIDER_PROPS_Z: ISliderProps = { minLabel: "Up", minValue: -78, type: SENSOR_LIST.MOTION_Z, + step: 1, }; export const MOTION_SENSOR_PROPERTIES: ISensorProps = { diff --git a/src/view/components/toolbar/microbit/MicrobitSensorProperties.tsx b/src/view/components/toolbar/microbit/MicrobitSensorProperties.tsx index 42470ce44..c32b00477 100644 --- a/src/view/components/toolbar/microbit/MicrobitSensorProperties.tsx +++ b/src/view/components/toolbar/microbit/MicrobitSensorProperties.tsx @@ -8,6 +8,7 @@ const LIGHT_SLIDER_PROPS: ISliderProps = { maxLabel: "Bright", type: "light", axisLabel: "L", + step: 1, }; export const LIGHT_SENSOR_PROPERTIES: ISensorProps = { @@ -23,6 +24,7 @@ const MOTION_SLIDER_PROPS_X: ISliderProps = { minLabel: "Left", minValue: -1023, type: SENSOR_LIST.MOTION_X, + step: 1, }; const MOTION_SLIDER_PROPS_Y: ISliderProps = { @@ -32,6 +34,7 @@ const MOTION_SLIDER_PROPS_Y: ISliderProps = { minLabel: "Back", minValue: -1023, type: SENSOR_LIST.MOTION_Y, + step: 1, }; const MOTION_SLIDER_PROPS_Z: ISliderProps = { @@ -41,6 +44,7 @@ const MOTION_SLIDER_PROPS_Z: ISliderProps = { minLabel: "Up", minValue: -1023, type: SENSOR_LIST.MOTION_Z, + step: 1, }; export const MOTION_SENSOR_PROPERTIES: ISensorProps = { @@ -60,6 +64,7 @@ const TEMPERATURE_SLIDER_PROPS: ISliderProps = { minLabel: "Cold", minValue: -55, type: SENSOR_LIST.TEMPERATURE, + step: 1, }; export const TEMPERATURE_SENSOR_PROPERTIES: ISensorProps = { diff --git a/src/view/viewUtils.tsx b/src/view/viewUtils.tsx index cc12abd59..1335d039f 100644 --- a/src/view/viewUtils.tsx +++ b/src/view/viewUtils.tsx @@ -11,6 +11,7 @@ export interface ISliderProps { axisLabel: string; value?: number; onUpdateValue?: (sensor: SENSOR_LIST, value: number) => void; + step: number; } export interface ISensorButtonProps { From b0c72ac370c574ed151b4f24c5c055c03cb102f4 Mon Sep 17 00:00:00 2001 From: xnkevinnguyen Date: Mon, 20 Apr 2020 09:07:27 -0700 Subject: [PATCH 02/16] Fix inverse switch --- src/adafruit_circuitplayground/express.py | 2 +- src/view/components/cpx/CpxImage.tsx | 2 +- src/view/components/cpx/CpxSimulator.tsx | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/adafruit_circuitplayground/express.py b/src/adafruit_circuitplayground/express.py index 7f2857508..84fa68c7e 100644 --- a/src/adafruit_circuitplayground/express.py +++ b/src/adafruit_circuitplayground/express.py @@ -37,7 +37,7 @@ def __init__(self): (0, 0, 0), ] self.__state[CONSTANTS.EXPRESS_STATE.RED_LED] = False - self.__state[CONSTANTS.EXPRESS_STATE.SWITCH] = False + self.__state[CONSTANTS.EXPRESS_STATE.SWITCH] = True self.__state[CONSTANTS.EXPRESS_STATE.TEMPERATURE] = 0 self.__state[CONSTANTS.EXPRESS_STATE.LIGHT] = 0 self.__state[CONSTANTS.EXPRESS_STATE.MOTION_X] = 0 diff --git a/src/view/components/cpx/CpxImage.tsx b/src/view/components/cpx/CpxImage.tsx index 7163b67c3..48aef4e64 100644 --- a/src/view/components/cpx/CpxImage.tsx +++ b/src/view/components/cpx/CpxImage.tsx @@ -380,7 +380,7 @@ export const updateSwitch = (switchState: boolean): void => { if (switchElement && switchInner) { svg.addClass(switchInner, "sim-slide-switch-inner"); - if (switchState) { + if (!switchState) { svg.addClass(switchInner, "on"); switchInner.setAttribute("transform", "translate(-5,0)"); } else { diff --git a/src/view/components/cpx/CpxSimulator.tsx b/src/view/components/cpx/CpxSimulator.tsx index b0d77f441..2a0ee0c11 100644 --- a/src/view/components/cpx/CpxSimulator.tsx +++ b/src/view/components/cpx/CpxSimulator.tsx @@ -49,7 +49,7 @@ const DEFAULT_CPX_STATE: ICpxState = { [0, 0, 0], ], red_led: false, - switch: false, + switch: true, touch: [false, false, false, false, false, false, false], shake: false, }; From 32ec778bfebfed9b8f113a1a2aaf06cb171975ec Mon Sep 17 00:00:00 2001 From: xnkevinnguyen Date: Mon, 20 Apr 2020 09:25:09 -0700 Subject: [PATCH 03/16] Refactor --- src/view/components/cpx/Cpx.tsx | 2 +- src/view/components/toolbar/InputSlider.tsx | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/src/view/components/cpx/Cpx.tsx b/src/view/components/cpx/Cpx.tsx index a28343b28..d91728fba 100644 --- a/src/view/components/cpx/Cpx.tsx +++ b/src/view/components/cpx/Cpx.tsx @@ -11,7 +11,7 @@ import Simulator from "./CpxSimulator"; // Component grouping the functionality for circuit playground express const DEFAULT_STATE = { sensors: { - [SENSOR_LIST.TEMPERATURE]: 0.0, + [SENSOR_LIST.TEMPERATURE]: 0, [SENSOR_LIST.LIGHT]: 0, [SENSOR_LIST.MOTION_X]: 0, [SENSOR_LIST.MOTION_Y]: 0, diff --git a/src/view/components/toolbar/InputSlider.tsx b/src/view/components/toolbar/InputSlider.tsx index b4c0a167a..c88479a78 100644 --- a/src/view/components/toolbar/InputSlider.tsx +++ b/src/view/components/toolbar/InputSlider.tsx @@ -104,7 +104,6 @@ class InputSlider extends React.Component { private validateRange = (valueString: string) => { let valueInt = parseFloat(valueString); - console.log(`original value ${valueString}`); if (valueInt < this.props.minValue) { valueInt = this.props.minValue; this.setState({ value: valueInt }); @@ -112,8 +111,6 @@ class InputSlider extends React.Component { valueInt = this.props.maxValue; this.setState({ value: valueInt }); } - console.log(`updated value ${valueInt}`); - return valueInt; }; } From 80bc804a8e2b3a6a355c8194a4fc538b0f33d7b0 Mon Sep 17 00:00:00 2001 From: xnkevinnguyen Date: Mon, 20 Apr 2020 09:28:26 -0700 Subject: [PATCH 04/16] Switch default is false --- src/adafruit_circuitplayground/express.py | 2 +- src/view/components/cpx/CpxSimulator.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/adafruit_circuitplayground/express.py b/src/adafruit_circuitplayground/express.py index 84fa68c7e..7f2857508 100644 --- a/src/adafruit_circuitplayground/express.py +++ b/src/adafruit_circuitplayground/express.py @@ -37,7 +37,7 @@ def __init__(self): (0, 0, 0), ] self.__state[CONSTANTS.EXPRESS_STATE.RED_LED] = False - self.__state[CONSTANTS.EXPRESS_STATE.SWITCH] = True + self.__state[CONSTANTS.EXPRESS_STATE.SWITCH] = False self.__state[CONSTANTS.EXPRESS_STATE.TEMPERATURE] = 0 self.__state[CONSTANTS.EXPRESS_STATE.LIGHT] = 0 self.__state[CONSTANTS.EXPRESS_STATE.MOTION_X] = 0 diff --git a/src/view/components/cpx/CpxSimulator.tsx b/src/view/components/cpx/CpxSimulator.tsx index 2a0ee0c11..b0d77f441 100644 --- a/src/view/components/cpx/CpxSimulator.tsx +++ b/src/view/components/cpx/CpxSimulator.tsx @@ -49,7 +49,7 @@ const DEFAULT_CPX_STATE: ICpxState = { [0, 0, 0], ], red_led: false, - switch: true, + switch: false, touch: [false, false, false, false, false, false, false], shake: false, }; From 08b35cf379ab7cbace3441af9fc94f5ddbeb78b5 Mon Sep 17 00:00:00 2001 From: xnkevinnguyen Date: Mon, 20 Apr 2020 15:43:25 -0700 Subject: [PATCH 05/16] Modify precision value for cpx and clue --- src/view/components/toolbar/InputSlider.tsx | 4 ++- .../toolbar/clue/ClueSensorProperties.tsx | 30 +++++++++---------- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/src/view/components/toolbar/InputSlider.tsx b/src/view/components/toolbar/InputSlider.tsx index c88479a78..9d163aca3 100644 --- a/src/view/components/toolbar/InputSlider.tsx +++ b/src/view/components/toolbar/InputSlider.tsx @@ -21,7 +21,9 @@ class InputSlider extends React.Component { render() { const isInputDisabled = this.context === VIEW_STATE.PAUSE; - const nbDecimals = this.props.step.toString().split(".")[1].length || 0; + + const nbDecimals = + this.props.step.toString().split(".")[1]?.length || 0; return (
{this.props.axisLabel} diff --git a/src/view/components/toolbar/clue/ClueSensorProperties.tsx b/src/view/components/toolbar/clue/ClueSensorProperties.tsx index e3293a493..e1f124557 100644 --- a/src/view/components/toolbar/clue/ClueSensorProperties.tsx +++ b/src/view/components/toolbar/clue/ClueSensorProperties.tsx @@ -4,7 +4,7 @@ import { ISensorProps, ISliderProps } from "../../../viewUtils"; const CLUE_SLIDER_R: ISliderProps = { axisLabel: "R", maxLabel: "Max", - maxValue: 255, + maxValue: 65535, minLabel: "Min", minValue: 0, type: SENSOR_LIST.LIGHT_R, @@ -14,7 +14,7 @@ const CLUE_SLIDER_R: ISliderProps = { const CLUE_SLIDER_G: ISliderProps = { axisLabel: "G", maxLabel: "Max", - maxValue: 255, + maxValue: 65535, minLabel: "Min", minValue: 0, type: SENSOR_LIST.LIGHT_G, @@ -24,7 +24,7 @@ const CLUE_SLIDER_G: ISliderProps = { const CLUE_SLIDER_B: ISliderProps = { axisLabel: "B", maxLabel: "Max", - maxValue: 255, + maxValue: 65535, minLabel: "Min", minValue: 0, type: SENSOR_LIST.LIGHT_B, @@ -54,7 +54,7 @@ const CLUE_MAGNET_X: ISliderProps = { maxValue: 1000, minValue: -1000, type: SENSOR_LIST.MAGNET_X, - step: 1, + step: 0.1, }; const CLUE_MAGNET_Y: ISliderProps = { axisLabel: "Y", @@ -63,7 +63,7 @@ const CLUE_MAGNET_Y: ISliderProps = { maxValue: 1000, minValue: -1000, type: SENSOR_LIST.MAGNET_Y, - step: 1, + step: 0.1, }; const CLUE_MAGNET_Z: ISliderProps = { axisLabel: "Z", @@ -72,7 +72,7 @@ const CLUE_MAGNET_Z: ISliderProps = { maxValue: 1000, minValue: -1000, type: SENSOR_LIST.MAGNET_Z, - step: 1, + step: 0.1, }; export const CLUE_MAGNET_PROPERTIES: ISensorProps = { @@ -87,7 +87,7 @@ const CLUE_GYRO_X: ISliderProps = { maxValue: 1000, minValue: -1000, type: SENSOR_LIST.GYRO_X, - step: 1, + step: 0.1, }; const CLUE_GYRO_Y: ISliderProps = { axisLabel: "Y", @@ -96,7 +96,7 @@ const CLUE_GYRO_Y: ISliderProps = { maxValue: 1000, minValue: -1000, type: SENSOR_LIST.GYRO_Y, - step: 1, + step: 0.1, }; const CLUE_GYRO_Z: ISliderProps = { axisLabel: "Z", @@ -105,7 +105,7 @@ const CLUE_GYRO_Z: ISliderProps = { maxValue: 1000, minValue: -1000, type: SENSOR_LIST.GYRO_Z, - step: 1, + step: 0.1, }; export const CLUE_GYRO_PROPERTIES: ISensorProps = { @@ -124,7 +124,7 @@ export const CLUE_HUMIDITY_PROPERTIES: ISensorProps = { minLabel: "Min", minValue: 0, type: SENSOR_LIST.HUMIDITY, - step: 1, + step: 0.1, }, ], unitLabel: "%", @@ -154,7 +154,7 @@ export const CLUE_PRESSURE_PROPERTIES: ISensorProps = { minLabel: "Min", minValue: 800, type: SENSOR_LIST.PRESSURE, - step: 1, + step: 0.1, }, ], unitLabel: "hPa", @@ -166,7 +166,7 @@ const MOTION_SLIDER_PROPS_X: ISliderProps = { minLabel: "Left", minValue: -1023, type: SENSOR_LIST.MOTION_X, - step: 1, + step: 0.1, }; const MOTION_SLIDER_PROPS_Y: ISliderProps = { @@ -176,7 +176,7 @@ const MOTION_SLIDER_PROPS_Y: ISliderProps = { minLabel: "Back", minValue: -1023, type: SENSOR_LIST.MOTION_Y, - step: 1, + step: 0.1, }; const MOTION_SLIDER_PROPS_Z: ISliderProps = { @@ -186,7 +186,7 @@ const MOTION_SLIDER_PROPS_Z: ISliderProps = { minLabel: "Up", minValue: -1023, type: SENSOR_LIST.MOTION_Z, - step: 1, + step: 0.1, }; export const MOTION_SENSOR_PROPERTIES: ISensorProps = { @@ -206,7 +206,7 @@ const TEMPERATURE_SLIDER_PROPS: ISliderProps = { minLabel: "Cold", minValue: -55, type: SENSOR_LIST.TEMPERATURE, - step: 1, + step: 0.1, }; export const TEMPERATURE_SENSOR_PROPERTIES: ISensorProps = { From 48f817ba69f9cbbcbb5657d9397f17bd3a14d8ec Mon Sep 17 00:00:00 2001 From: Vandy Liu <33995460+vandyliu@users.noreply.github.com> Date: Mon, 20 Apr 2020 15:58:57 -0700 Subject: [PATCH 06/16] Table of Contents for README (#349) --- README.md | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index f54889b18..0da43101b 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,32 @@ Make without limit! Device Simulator Express, a Microsoft Garage project, allows result when you plug in your actual microcontroller. Curious about the output of the device, the serial monitor allows you to observe the device output. -## Devices we support: +## Table of Contents + - [Devices we support](#devices-we-support) + - [Prerequisites](#prerequisites) + - [Adafruit Circuit Playground Express (CPX) Simulator](#adafruit-circuit-playground-express-cpx-simulator) + - [Features](#features) + - [Useful Links](#useful-links) + - [Keyboard Shortcuts](#keyboard-shortcuts) + - [BBC micro:bit Simulator](#bbc-microbit-simulator) + - [Features](#features-1) + - [Useful Links](#useful-links-1) + - [Keyboard Shortcuts](#keyboard-shortcuts-1) + - [Adafruit CLUE Simulator](#adafruit-clue-simulator) + - [Features](#features-2) + - [Useful Links](#useful-links-2) + - [Keyboard Shortcuts](#keyboard-shortcuts-2) + - [How to use](#how-to-use) + - [Commands](#commands) + - [Contribute](#contribute) + - [Provide feedback](#provide-feedback) + - [Privacy and Telemetry Notice](#privacy-and-telemetry-notice) + - [Third Party Notice](#third-party-notice) + - [Troubleshooting Tips](#troubleshooting-tips) + - [License](#license) + - [Notes](#notes) + +## Devices we support - [**Adafruit Circuit Playground Express (CPX)**](#adafruit-circuit-playground-express-cpx-simulator) From f6d61221d234915bd5bf66efb7c36860c2c81359 Mon Sep 17 00:00:00 2001 From: Andrea Mah <31675041+andreamah@users.noreply.github.com> Date: Mon, 20 Apr 2020 16:48:44 -0700 Subject: [PATCH 07/16] Slideshow Backwards/Forwards Bug Fix (#350) * slideshow nav fixed --- src/clue/adafruit_slideshow.py | 56 ++++++++++++++++++++++------------ 1 file changed, 37 insertions(+), 19 deletions(-) diff --git a/src/clue/adafruit_slideshow.py b/src/clue/adafruit_slideshow.py index 7e5cecd2c..aa1fb6b65 100644 --- a/src/clue/adafruit_slideshow.py +++ b/src/clue/adafruit_slideshow.py @@ -5,7 +5,6 @@ from io import BytesIO from base_circuitpython import base_cp_constants as CONSTANTS import time -import collections from random import shuffle import common import board @@ -165,6 +164,7 @@ def __init__( self._order = order self._curr_img = "" + self._current_image_index = None # load images into main queue self.__load_images() @@ -219,41 +219,57 @@ def update(self): def __get_next_img(self): - # handle empty queue - if not len(self.pic_queue): - if self.loop: - self.__load_images() + if self.direction == PlayBackDirection.FORWARD: + if self._current_image_index == None: + self._current_image_index = 0 else: - return "" + self._current_image_index += 1 + + if self._current_image_index >= len(self.dir_imgs): + + if self.loop: + self._current_image_index = 0 + self.__load_images() + else: + self._current_image_index = len(self.dir_imgs) - 10 + return "" - if self.direction == PlayBackDirection.FORWARD: - return self.pic_queue.popleft() else: - return self.pic_queue.pop() + if self._current_image_index == None: + self._current_image_index = len(self.dir_imgs) - 1 + else: + self._current_image_index -= 1 + + if self._current_image_index < 0: + if self.loop: + self._current_image_index = len(self.dir_imgs) - 1 + self.__load_images() + else: + self._current_image_index = 0 + return "" + + img = self.dir_imgs[self._current_image_index] + return img def __load_images(self): - dir_imgs = [] + self.dir_imgs = [] for d in self.dirs: try: new_path = os.path.join(self.folder, d) # only add bmp imgs - if os.path.splitext(new_path)[1] == CONSTANTS.BMP_IMG_ENDING: - dir_imgs.append(new_path) + if os.path.splitext(new_path)[-1] == CONSTANTS.BMP_IMG_ENDING: + self.dir_imgs.append(new_path) except Image.UnidentifiedImageError as e: continue - if not len(dir_imgs): + if not len(self.dir_imgs): raise RuntimeError(CONSTANTS.NO_VALID_IMGS_ERR) if self._order == PlayBackOrder.RANDOM: - shuffle(dir_imgs) + shuffle(self.dir_imgs) else: - dir_imgs.sort() - - # convert list to queue - # (must be list beforehand for potential randomization) - self.pic_queue = collections.deque(dir_imgs) + self.dir_imgs.sort() def __advance_with_fade(self): if board.DISPLAY.active_group != self: @@ -265,6 +281,7 @@ def __advance_with_fade(self): while not advance_sucessful: new_path = self.__get_next_img() if new_path == "": + self._img_start = time.monotonic() return False try: @@ -323,6 +340,7 @@ def __advance_no_fade(self): while not advance_sucessful: new_path = self.__get_next_img() if new_path == "": + self._img_start = time.monotonic() return False try: From a2e6c53d0538c16db8e16bf81a9462effe932dc1 Mon Sep 17 00:00:00 2001 From: Andrea Mah <31675041+andreamah@users.noreply.github.com> Date: Tue, 21 Apr 2020 09:53:39 -0700 Subject: [PATCH 08/16] Fixed print() statements for CLUE display in debug mode (#351) * fixed debug_user_code.py to capture print statements * added starting and ending print statements --- src/debug_user_code.py | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/debug_user_code.py b/src/debug_user_code.py index 7e534f479..8be4792fb 100644 --- a/src/debug_user_code.py +++ b/src/debug_user_code.py @@ -32,9 +32,15 @@ # Insert absolute path to Circuitpython libraries for CLUE into sys.path sys.path.insert(0, os.path.join(abs_path_to_parent_dir, CONSTANTS.CIRCUITPYTHON)) +# get board so we can get terminal handle +import board + # This import must happen after the sys.path is modified from common import debugger_communication_client +# get handle to terminal for clue +curr_terminal = board.DISPLAY.terminal + ## Execute User Code ## # Get user's code path @@ -56,12 +62,26 @@ utils.abs_path_to_user_file = abs_path_to_code_file utils.debug_mode = True +# overriding print function so that it shows on clue terminal +def print_decorator(func): + global curr_terminal + + def wrapped_func(*args, **kwargs): + curr_terminal.add_str_to_terminal("".join(str(e) for e in args)) + return func(*args, **kwargs) + + return wrapped_func + + +print = print_decorator(print) + # Execute the user's code file with open(abs_path_to_code_file, encoding="utf8") as user_code_file: + curr_terminal.add_str_to_terminal(CONSTANTS.CODE_START_MSG_CLUE) user_code = user_code_file.read() try: codeObj = compile(user_code, abs_path_to_code_file, CONSTANTS.EXEC_COMMAND) - exec(codeObj, {}) + exec(codeObj, {"print": print}) sys.stdout.flush() except Exception as e: exc_type, exc_value, exc_traceback = sys.exc_info() @@ -71,3 +91,5 @@ for frameIndex in range(2, len(stackTrace) - 1): errorMessage += "\t" + str(stackTrace[frameIndex]) print(e, errorMessage, file=sys.stderr, flush=True) + curr_terminal.add_str_to_terminal(CONSTANTS.CODE_FINISHED_MSG_CLUE) + board.DISPLAY.show(None) From 6ab91070053c1a5348c39dc7dbb28d2ab4989fc3 Mon Sep 17 00:00:00 2001 From: andreamah Date: Tue, 21 Apr 2020 10:22:13 -0700 Subject: [PATCH 09/16] new release note apr 21 --- src/latest_release_note.ts | 57 +++++++++++++++++++++++--------------- 1 file changed, 35 insertions(+), 22 deletions(-) diff --git a/src/latest_release_note.ts b/src/latest_release_note.ts index 65547e1aa..88c55bc4e 100644 --- a/src/latest_release_note.ts +++ b/src/latest_release_note.ts @@ -1,26 +1,39 @@ // TODO: find a better way of loading html into a string -export const LATEST_RELEASE_NOTE = `

Device Simulator Express Release Notes 📝(April 20, 2020)

-

-

We're back with a full release for the Adafruit CLUE 🐍🔍.

+export const LATEST_RELEASE_NOTE = `

Device Simulator Express Release Notes

+

Device Simulator Express, a Microsoft Garage project, allows you to code microcontrollers without the hardware on hand! You can program your Adafruit Circuit Playground Express (CPX), your BBC micro:bit or the Adafruit CLUE!

+
+ LIGHTGESTUREPROXIMITY +
+ +

📝(April 21, 2020)

+ +

Changes:

+
    +
  • Increased precision for certain sensors on the CLUE and CPX.
  • +
+

Fixes:

+
    +
  • Fixed bugs within the CLUE slideshow library and debugger.
  • +
-
- LIGHTGESTUREPROXIMITY -
-

-

Changes:

-
    -
  • The Adafruit CLUE is enabled by default.
  • -
  • The "Getting Started" page now includes some guidance on the debugger.
  • -
-

Fixes:

-
    -
  • Implemented fix for the switch on the CPX.
  • -
  • The CLUE debugger's LEDs can now correctly show on the UI.
  • -
  • The dependency installation process is fixed, and users without Git installed can now run setup.
  • -
+

📝(April 20, 2020)

+

+

We're back with a full release for the Adafruit CLUE 🐍🔍.

+

+

Changes:

+
    +
  • The Adafruit CLUE is enabled by default.
  • +
  • The "Getting Started" page now includes some guidance on the debugger.
  • +
+

Fixes:

+
    +
  • Implemented fix for the switch on the CPX.
  • +
  • The CLUE debugger's LEDs can now correctly show on the UI.
  • +
  • The dependency installation process is fixed, and users without Git installed can now run setup.
  • +
-

+

-

PS: You can read about the DSX team in the article here!

-

Create something wonderful ✨🙌,
-       - The Device Simulator Express Team

`; +

PS: You can read about the DSX team in the article here!

+

Create something wonderful ✨🙌,
+       - The Device Simulator Express Team

`; From 082d57f7591af7a4c9a6cd3ed680f51a9cf4a568 Mon Sep 17 00:00:00 2001 From: andreamah Date: Tue, 21 Apr 2020 10:38:52 -0700 Subject: [PATCH 10/16] added a few fixes --- src/latest_release_note.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/latest_release_note.ts b/src/latest_release_note.ts index 88c55bc4e..3d9971054 100644 --- a/src/latest_release_note.ts +++ b/src/latest_release_note.ts @@ -1,11 +1,11 @@ // TODO: find a better way of loading html into a string -export const LATEST_RELEASE_NOTE = `

Device Simulator Express Release Notes

+export const LATEST_RELEASE_NOTE = `

Device Simulator Express Release Notes 🤖

Device Simulator Express, a Microsoft Garage project, allows you to code microcontrollers without the hardware on hand! You can program your Adafruit Circuit Playground Express (CPX), your BBC micro:bit or the Adafruit CLUE!

LIGHTGESTUREPROXIMITY
-

📝(April 21, 2020)

+

📝 April 21, 2020

Changes:

    @@ -16,7 +16,7 @@ export const LATEST_RELEASE_NOTE = `

    Device Simulator Express Release Notes <
  • Fixed bugs within the CLUE slideshow library and debugger.
-

📝(April 20, 2020)

+

📝 April 20, 2020

We're back with a full release for the Adafruit CLUE 🐍🔍.

From d246992cc1ef8b1e7e17c1cc28cdff4b4bafc7bd Mon Sep 17 00:00:00 2001 From: xnkevinnguyen Date: Tue, 21 Apr 2020 15:36:21 -0700 Subject: [PATCH 11/16] Add filter for clue message --- src/debuggerCommunicationServer.ts | 19 ++++++++++++------- src/extension.ts | 2 +- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/debuggerCommunicationServer.ts b/src/debuggerCommunicationServer.ts index 86a4aeef2..0fa4a65cc 100644 --- a/src/debuggerCommunicationServer.ts +++ b/src/debuggerCommunicationServer.ts @@ -5,6 +5,7 @@ import * as http from "http"; import * as socketio from "socket.io"; import { WebviewPanel } from "vscode"; import { SERVER_INFO } from "./constants"; +import { DeviceSelectionService } from "./service/deviceSelectionService"; export const DEBUGGER_MESSAGES = { EMITTER: { @@ -24,14 +25,14 @@ export class DebuggerCommunicationServer { private serverHttp: http.Server; private serverIo: socketio.Server; private simulatorWebview: WebviewPanel | undefined; - private currentActiveDevice; + private deviceSelectionService: DeviceSelectionService; private isPendingResponse = false; private pendingCallbacks: Function[] = []; constructor( webviewPanel: WebviewPanel | undefined, port = SERVER_INFO.DEFAULT_SERVER_PORT, - currentActiveDevice: string + deviceSelectionService: DeviceSelectionService ) { this.port = port; this.serverHttp = new http.Server(); @@ -42,7 +43,7 @@ export class DebuggerCommunicationServer { this.initEventsHandlers(); console.info(`Server running on port ${this.port}`); - this.currentActiveDevice = currentActiveDevice; + this.deviceSelectionService = deviceSelectionService; } // send the message to start closing the connection @@ -119,12 +120,16 @@ export class DebuggerCommunicationServer { try { const messageToWebview = JSON.parse(data); if (messageToWebview.type === "state") { - console.log(`State recieved: ${messageToWebview.data}`); - if (this.simulatorWebview) { + const messageState = JSON.parse(messageToWebview.data); + if ( + this.simulatorWebview && + messageState.device_name === + this.deviceSelectionService.getCurrentActiveDevice() + ) { this.simulatorWebview.webview.postMessage({ - active_device: this.currentActiveDevice, + active_device: this.deviceSelectionService.getCurrentActiveDevice(), command: "set-state", - state: JSON.parse(messageToWebview.data), + state: messageState, }); } } diff --git a/src/extension.ts b/src/extension.ts index b733129f0..74e2bf1bf 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -947,7 +947,7 @@ export async function activate(context: vscode.ExtensionContext) { new DebuggerCommunicationServer( currentPanel, utils.getServerPortConfig(), - deviceSelectionService.getCurrentActiveDevice() + deviceSelectionService ) ); From 9f2bfdf5852d5871f6299c1137585b23f4ac8364 Mon Sep 17 00:00:00 2001 From: andreamah Date: Tue, 21 Apr 2020 15:39:37 -0700 Subject: [PATCH 12/16] changed release date from today to tomorrow --- src/latest_release_note.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/latest_release_note.ts b/src/latest_release_note.ts index 3d9971054..8d4a980cd 100644 --- a/src/latest_release_note.ts +++ b/src/latest_release_note.ts @@ -5,7 +5,7 @@ export const LATEST_RELEASE_NOTE = `

Device Simulator Express Release Notes LIGHTGESTUREPROXIMITY

-

📝 April 21, 2020

+

📝 April 22, 2020

Changes:

    From a69db06599c2a19392e3ed907c681c0e14268e1c Mon Sep 17 00:00:00 2001 From: xnkevinnguyen Date: Tue, 21 Apr 2020 15:52:03 -0700 Subject: [PATCH 13/16] Modify C for color sensor --- src/view/components/toolbar/clue/ClueSensorProperties.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/view/components/toolbar/clue/ClueSensorProperties.tsx b/src/view/components/toolbar/clue/ClueSensorProperties.tsx index e1f124557..ccb8d8e1b 100644 --- a/src/view/components/toolbar/clue/ClueSensorProperties.tsx +++ b/src/view/components/toolbar/clue/ClueSensorProperties.tsx @@ -33,7 +33,7 @@ const CLUE_SLIDER_B: ISliderProps = { const CLUE_SLIDER_C: ISliderProps = { axisLabel: "C", maxLabel: "Max", - maxValue: 255, + maxValue: 65535, minLabel: "Min", minValue: 0, type: SENSOR_LIST.LIGHT_C, From cd340ea0f3d2a3f937d9c642b030701a76a8f2f7 Mon Sep 17 00:00:00 2001 From: xnkevinnguyen Date: Tue, 21 Apr 2020 16:06:59 -0700 Subject: [PATCH 14/16] Update tooltips --- .../clue/__snapshots__/Clue.spec.tsx.snap | 21 ------------- .../cpx/__snapshots__/Cpx.spec.tsx.snap | 30 ------------------- .../__snapshots__/Microbit.spec.tsx.snap | 21 ------------- .../__snapshots__/Toolbar.spec.tsx.snap | 3 -- .../device/__snapshots__/Device.spec.tsx.snap | 21 ------------- src/view/svgs/toolbar_svg.tsx | 14 --------- src/view/translations/en.json | 2 ++ 7 files changed, 2 insertions(+), 110 deletions(-) diff --git a/src/view/components/clue/__snapshots__/Clue.spec.tsx.snap b/src/view/components/clue/__snapshots__/Clue.spec.tsx.snap index 40de21d57..dce8f43ff 100644 --- a/src/view/components/clue/__snapshots__/Clue.spec.tsx.snap +++ b/src/view/components/clue/__snapshots__/Clue.spec.tsx.snap @@ -1248,9 +1248,6 @@ Array [ xmlns="http://www.w3.org/2000/svg" xmlnsXlink="http://www.w3.org/1999/xlink" > - - Push Button - Created with Sketch. @@ -1315,9 +1312,6 @@ Array [ xmlns="http://www.w3.org/2000/svg" xmlnsXlink="http://www.w3.org/1999/xlink" > - - neon_pixel - Created with Sketch. @@ -1418,9 +1412,6 @@ Array [ xmlns="http://www.w3.org/2000/svg" xmlnsXlink="http://www.w3.org/1999/xlink" > - - Temperature Sensor - - - Light sensor - - - GPIO - Created with Sketch. @@ -2109,9 +2094,6 @@ Array [ xmlns="http://www.w3.org/2000/svg" xmlnsXlink="http://www.w3.org/1999/xlink" > - - Sound Sensor - Created with Sketch. @@ -2185,9 +2167,6 @@ Array [ xmlns="http://www.w3.org/2000/svg" xmlnsXlink="http://www.w3.org/1999/xlink" > - - Speaker - Created with Sketch. diff --git a/src/view/components/cpx/__snapshots__/Cpx.spec.tsx.snap b/src/view/components/cpx/__snapshots__/Cpx.spec.tsx.snap index 3a41b60f6..960f9b501 100644 --- a/src/view/components/cpx/__snapshots__/Cpx.spec.tsx.snap +++ b/src/view/components/cpx/__snapshots__/Cpx.spec.tsx.snap @@ -3968,9 +3968,6 @@ Array [ xmlns="http://www.w3.org/2000/svg" xmlnsXlink="http://www.w3.org/1999/xlink" > - - Switch - Created with Sketch. @@ -4035,9 +4032,6 @@ Array [ xmlns="http://www.w3.org/2000/svg" xmlnsXlink="http://www.w3.org/1999/xlink" > - - Push Button - Created with Sketch. @@ -4102,9 +4096,6 @@ Array [ xmlns="http://www.w3.org/2000/svg" xmlnsXlink="http://www.w3.org/1999/xlink" > - - Red LED - Created with Sketch. @@ -4167,9 +4158,6 @@ Array [ xmlns="http://www.w3.org/2000/svg" xmlnsXlink="http://www.w3.org/1999/xlink" > - - Sound Sensor - Created with Sketch. @@ -4243,9 +4231,6 @@ Array [ xmlns="http://www.w3.org/2000/svg" xmlnsXlink="http://www.w3.org/1999/xlink" > - - Temperature Sensor - - - Light sensor - - - neon_pixel - Created with Sketch. @@ -4480,9 +4459,6 @@ Array [ xmlns="http://www.w3.org/2000/svg" xmlnsXlink="http://www.w3.org/1999/xlink" > - - Speaker - Created with Sketch. @@ -4602,9 +4578,6 @@ Array [ xmlns="http://www.w3.org/2000/svg" xmlnsXlink="http://www.w3.org/1999/xlink" > - - IR - Created with Sketch. @@ -4662,9 +4635,6 @@ Array [ xmlns="http://www.w3.org/2000/svg" xmlnsXlink="http://www.w3.org/1999/xlink" > - - GPIO - Created with Sketch. diff --git a/src/view/components/microbit/__snapshots__/Microbit.spec.tsx.snap b/src/view/components/microbit/__snapshots__/Microbit.spec.tsx.snap index 1ab115851..9e167bbca 100644 --- a/src/view/components/microbit/__snapshots__/Microbit.spec.tsx.snap +++ b/src/view/components/microbit/__snapshots__/Microbit.spec.tsx.snap @@ -2669,9 +2669,6 @@ Array [ xmlns="http://www.w3.org/2000/svg" xmlnsXlink="http://www.w3.org/1999/xlink" > - - Push Button - Created with Sketch. @@ -2736,9 +2733,6 @@ Array [ xmlns="http://www.w3.org/2000/svg" xmlnsXlink="http://www.w3.org/1999/xlink" > - - Red LED - Created with Sketch. @@ -2801,9 +2795,6 @@ Array [ xmlns="http://www.w3.org/2000/svg" xmlnsXlink="http://www.w3.org/1999/xlink" > - - Temperature Sensor - - - Light sensor - - - GPIO - Created with Sketch. @@ -3164,9 +3149,6 @@ Array [ xmlns="http://www.w3.org/2000/svg" xmlnsXlink="http://www.w3.org/1999/xlink" > - - Speaker - Created with Sketch. @@ -3224,9 +3206,6 @@ Array [ xmlns="http://www.w3.org/2000/svg" xmlnsXlink="http://www.w3.org/1999/xlink" > - - Bluetooth and Radio - - - Light sensor - - - Push Button - Created with Sketch. @@ -2738,9 +2735,6 @@ exports[`Device component should render correctly 1`] = ` xmlns="http://www.w3.org/2000/svg" xmlnsXlink="http://www.w3.org/1999/xlink" > - - Red LED - Created with Sketch. @@ -2803,9 +2797,6 @@ exports[`Device component should render correctly 1`] = ` xmlns="http://www.w3.org/2000/svg" xmlnsXlink="http://www.w3.org/1999/xlink" > - - Temperature Sensor - - - Light sensor - - - GPIO - Created with Sketch. @@ -3166,9 +3151,6 @@ exports[`Device component should render correctly 1`] = ` xmlns="http://www.w3.org/2000/svg" xmlnsXlink="http://www.w3.org/1999/xlink" > - - Speaker - Created with Sketch. @@ -3226,9 +3208,6 @@ exports[`Device component should render correctly 1`] = ` xmlns="http://www.w3.org/2000/svg" xmlnsXlink="http://www.w3.org/1999/xlink" > - - Bluetooth and Radio - - GPIO Created with Sketch. - IR Created with Sketch. - {TOOLBAR_ICON_LABEL.LIGHT} - - neon_pixel Created with Sketch. - {TOOLBAR_ICON_LABEL.PUSH_BUTTON} Created with Sketch. - {TOOLBAR_ICON_LABEL.RED_LED} Created with Sketch. - {TOOLBAR_ICON_LABEL.SWITCH} Created with Sketch. - {TOOLBAR_ICON_LABEL.SOUND} Created with Sketch. - {TOOLBAR_ICON_LABEL.SPEAKER} Created with Sketch. - {TOOLBAR_ICON_LABEL.TEMPERATURE} - - {TOOLBAR_ICON_LABEL.WIRELESS} - Date: Tue, 21 Apr 2020 16:33:45 -0700 Subject: [PATCH 15/16] Fixed Import Error on Linux (#357) * fixed import error in linux --- src/base_circuitpython/displayio/group.py | 2 +- src/base_circuitpython/displayio/test/test_group.py | 8 ++++---- src/debug_user_code.py | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/base_circuitpython/displayio/group.py b/src/base_circuitpython/displayio/group.py index c5dccf90a..5acc1f2a8 100644 --- a/src/base_circuitpython/displayio/group.py +++ b/src/base_circuitpython/displayio/group.py @@ -3,7 +3,7 @@ from PIL import Image import adafruit_display_text -from .tile_grid import TileGrid +from displayio.tile_grid import TileGrid from . import constants as CONSTANTS import common diff --git a/src/base_circuitpython/displayio/test/test_group.py b/src/base_circuitpython/displayio/test/test_group.py index 4d943ffc8..3e4b3601e 100644 --- a/src/base_circuitpython/displayio/test/test_group.py +++ b/src/base_circuitpython/displayio/test/test_group.py @@ -7,10 +7,10 @@ from common import utils -from ..tile_grid import TileGrid -from ..group import Group -from ..palette import Palette -from ..bitmap import Bitmap +from displayio.tile_grid import TileGrid +from displayio.group import Group +from displayio.palette import Palette +from displayio.bitmap import Bitmap from .. import constants as CONSTANTS from PIL import Image diff --git a/src/debug_user_code.py b/src/debug_user_code.py index 8be4792fb..a1ad6cb16 100644 --- a/src/debug_user_code.py +++ b/src/debug_user_code.py @@ -32,12 +32,12 @@ # Insert absolute path to Circuitpython libraries for CLUE into sys.path sys.path.insert(0, os.path.join(abs_path_to_parent_dir, CONSTANTS.CIRCUITPYTHON)) -# get board so we can get terminal handle -import board - # This import must happen after the sys.path is modified from common import debugger_communication_client +# get board so we can get terminal handle +import board + # get handle to terminal for clue curr_terminal = board.DISPLAY.terminal From cd0944130b9fe4f280c6f1ebf4ca2299dcfbb76f Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 21 Apr 2020 16:35:05 -0700 Subject: [PATCH 16/16] remove node from prereqs in readme --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 0da43101b..5fd02e91c 100644 --- a/README.md +++ b/README.md @@ -61,7 +61,6 @@ The following dependencies are required to install before launching Device Simul You will be prompted to install the Python dependencies during the first use. - _**[Visual Studio Code](https://code.visualstudio.com/)**_ -- _**[Node](https://nodejs.org/en/download/)**_ - _**[Python 3.7+](https://www.python.org/downloads/)**_: Make sure you've added Python and pip to your PATH in your environment variables. (1) - _**[Python VS Code extension](https://marketplace.visualstudio.com/items?itemName=ms-python.python)**_: This will be installed automatically from the marketplace when you install Device Simulator Express.