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

Official CLUE release #339

Merged
merged 55 commits into from
Apr 18, 2020
Merged
Show file tree
Hide file tree
Changes from 36 commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
9ddfcc6
Update Package.json for latest typescript version
xnkevinnguyen Apr 12, 2020
df63c2d
Refactor code to use latest typescript syntax
xnkevinnguyen Apr 12, 2020
b5b5d49
Remove onMouseLeave from simulator
xnkevinnguyen Apr 12, 2020
acacf3a
Modify CSS for slider area
xnkevinnguyen Apr 12, 2020
d784817
Use generic slider to remove accelerometer
xnkevinnguyen Apr 12, 2020
1b3ada1
Refactor sensor for microbit & clue
xnkevinnguyen Apr 12, 2020
0113331
Remove non-generic sliders
xnkevinnguyen Apr 12, 2020
c165972
Update tests
xnkevinnguyen Apr 12, 2020
3b2b052
Format
xnkevinnguyen Apr 13, 2020
416c63c
Lint code
xnkevinnguyen Apr 13, 2020
d86ae2f
Merge branch 'users/t-xunguy/typescript' into users/t-xunguy/slider-r…
xnkevinnguyen Apr 13, 2020
0f4d6c1
Format & lint
xnkevinnguyen Apr 13, 2020
9f4265c
Get the latest HTML even if it already exists
xnkevinnguyen Apr 13, 2020
466bb4f
Merge pull request #323 from microsoft/users/t-xunguy/render-fix
xnkevinnguyen Apr 13, 2020
96aacb9
Bug Fix for different values of Pressure on Python and React-side (#322)
vandyliu Apr 13, 2020
80900f3
Merge branch 'dev' into users/t-xunguy/typescript
xnkevinnguyen Apr 13, 2020
52c3350
CLUE unimplemented properties print correctly (#324)
vandyliu Apr 13, 2020
fa4daa6
Merge branch 'dev' into users/t-xunguy/typescript
xnkevinnguyen Apr 13, 2020
4840ad6
added troubleshooting help for using python3 in linux (#326)
andreamah Apr 13, 2020
72bfc75
Merge branch 'dev' into users/t-xunguy/typescript
xnkevinnguyen Apr 13, 2020
3546119
Merge pull request #325 from microsoft/users/t-xunguy/typescript
xnkevinnguyen Apr 14, 2020
824b141
Clue Bug Fixes (#327)
andreamah Apr 14, 2020
eaf91ba
Merge remote-tracking branch 'origin/dev' into users/t-xunguy/slider-…
xnkevinnguyen Apr 14, 2020
55094af
Refactoring state of CPX to use constants (#328)
vandyliu Apr 14, 2020
d2d47e3
Merge branch 'dev' into users/t-xunguy/slider-refactor
xnkevinnguyen Apr 14, 2020
5eca6b4
Fixed debugger bug for white leds and red led (#330)
vandyliu Apr 15, 2020
19738cd
Merge branch 'dev' into users/t-xunguy/slider-refactor
xnkevinnguyen Apr 15, 2020
3b5fced
Merge pull request #329 from microsoft/users/t-xunguy/slider-refactor
xnkevinnguyen Apr 15, 2020
9a0c839
moved tarball files to clue dir
andreamah Apr 16, 2020
ead1572
first commit
vandyliu Apr 16, 2020
b431f56
resolved merge conflict for dev
andreamah Apr 16, 2020
daa4466
Merge pull request #335 from microsoft/users/t-anmah/tarball-bug-fix
andreamah Apr 17, 2020
958230d
Fix the switch
xnkevinnguyen Apr 17, 2020
3753cc1
Getting Started Improvements (#331)
vandyliu Apr 17, 2020
b4312b7
Merge branch 'dev' into users/t-xunguy/switch-fix
xnkevinnguyen Apr 17, 2020
8ad93f6
made setup changes for python3 call
andreamah Apr 17, 2020
5d88fc5
Merge pull request #337 from microsoft/users/t-xunguy/switch-fix
xnkevinnguyen Apr 17, 2020
e39f77f
Remove preview mode for CLUE (#336)
vandyliu Apr 17, 2020
d701e8d
dependency fixes
andreamah Apr 17, 2020
8ee166a
formatting
andreamah Apr 17, 2020
acdd305
Merge branch 'dev' into users/t-anmah/unix-nopythonpath-fix
andreamah Apr 17, 2020
ef77c01
pr feedback
andreamah Apr 17, 2020
dc8ed95
fixed version too low issue
andreamah Apr 17, 2020
7cfa0b9
Merge pull request #338 from microsoft/users/t-anmah/unix-nopythonpat…
xnkevinnguyen Apr 17, 2020
3952fff
bypassed terminal print
andreamah Apr 18, 2020
d5badb6
Remove preview draft commit
xnkevinnguyen Apr 18, 2020
90a92fa
Merge branch 'dev' into users/t-vali/unimplemented-fns
andreamah Apr 18, 2020
b9e1f17
Remove any preview mode info in ReadMe
xnkevinnguyen Apr 18, 2020
77f0a26
Add link for deploy to clue
xnkevinnguyen Apr 18, 2020
63dfa98
formatting
andreamah Apr 18, 2020
cd4b40f
changed variable name
andreamah Apr 18, 2020
08a4d1e
updated release note
andreamah Apr 18, 2020
5072861
Merge pull request #341 from microsoft/users/t-vali/unimplemented-fns
xnkevinnguyen Apr 18, 2020
a7ea944
Merge branch 'dev' into users/t-xunguy/release-notes-readme
xnkevinnguyen Apr 18, 2020
f090660
Merge pull request #340 from microsoft/users/t-xunguy/release-notes-r…
xnkevinnguyen Apr 18, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@ A `ThirdPartyNotices.txt` file is provided in the extension's source code listin
- If you try to deploy to the CPX while it's plugged in but you still get an error saying it cannot find the board, make sure your device is formatted correctly and that its name matches `CIRCUITPY`.
- If you can't get the Simulator communication working while debugging, try to open your `Settings` and check the port used under `"Device Simulator Express: Debugger Server Port"`. You can either change it (usually ports above 5000 should work) or try to free it, then start debugging again.
- When you are using the serial monitor, if you get some unusual error messages, unplug the device and reload the VS Code windows.
- If you're using Ubuntu and having some problems with setting up the environment, try reviewing [this article's](https://www.digitalocean.com/community/tutorials/how-to-install-python-3-and-set-up-a-local-programming-environment-on-ubuntu-16-04) "Step 1" section on how to set up Python 3 on Ubuntu 16.04. Then, ensure that you've run `sudo apt-get install -y python3-venv` to allow for virtual environment creation.

## License

Expand Down
Binary file not shown.
3 changes: 1 addition & 2 deletions locales/en/package.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,5 @@
"deviceSimulatorExpressExtension.configuration.title": "Device Simulator Express configuration",
"deviceSimulatorExpressExtension.configuration.properties.configEnvOnChange": "When you change the Python interpreter, the Device Simulator Express will automatically configure itself for the required dependencies.",
"deviceSimulatorExpressExtension.configuration.properties.debuggerPort": "The port the Server will listen on for communication with the debugger.",
"deviceSimulatorExpressExtension.configuration.properties.dependencyChecker": "Whether or not to ask if we can download dependencies. If unchecked, the extension will default to never download dependencies, except when automatically creating a virtual environment in the extension files.",
"deviceSimulatorExpressExtension.configuration.properties.previewMode": "Enable this to test out and play with the new Adafruit CLUE simulator!"
"deviceSimulatorExpressExtension.configuration.properties.dependencyChecker": "Whether or not to ask if we can download dependencies. If unchecked, the extension will default to never download dependencies, except when automatically creating a virtual environment in the extension files."
}
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 1 addition & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -144,12 +144,6 @@
"default": 5577,
"description": "%deviceSimulatorExpressExtension.configuration.properties.debuggerPort%",
"scope": "resource"
},
"deviceSimulatorExpress.previewMode": {
"type": "boolean",
"default": false,
"description": "%deviceSimulatorExpressExtension.configuration.properties.previewMode%",
"scope": "resource"
}
}
},
Expand Down Expand Up @@ -286,7 +280,7 @@
"tslint-microsoft-contrib": "^6.1.0",
"tslint-react": "^3.6.0",
"tslint-react-hooks": "^2.0.0",
"typescript": "^3.3.1",
"typescript": "^3.8.3",
"typescript-react-intl": "^0.4.0",
"version-from-git": "^1.1.1",
"vsce": "^1.47.0",
Expand Down
3 changes: 1 addition & 2 deletions package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,5 @@
"deviceSimulatorExpressExtension.configuration.title": "Device Simulator Express configuration",
"deviceSimulatorExpressExtension.configuration.properties.configEnvOnChange": "When you change the Python interpreter, the Device Simulator Express will automatically configure itself for the required dependencies.",
"deviceSimulatorExpressExtension.configuration.properties.debuggerPort": "The port the Server will listen on for communication with the debugger.",
"deviceSimulatorExpressExtension.configuration.properties.dependencyChecker": "Whether or not to ask for dependency downloads. If unchecked, the extension will default to never download dependencies, except when automatically creating a virtual environment in the extension files.",
"deviceSimulatorExpressExtension.configuration.properties.previewMode": "Enable this to test out and play with the new Adafruit CLUE simulator!"
"deviceSimulatorExpressExtension.configuration.properties.dependencyChecker": "Whether or not to ask for dependency downloads. If unchecked, the extension will default to never download dependencies, except when automatically creating a virtual environment in the extension files."
}
53 changes: 41 additions & 12 deletions src/adafruit_circuitplayground/constants.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,25 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.


class EXPRESS_STATE:
BUTTON_A = "button_a"
BUTTON_B = "button_b"
ACCELERATION = "acceleration"
BRIGHTNESS = "brightness"
PIXELS = "pixels"
RED_LED = "red_led"
SWITCH = "switch"
TEMPERATURE = "temperature"
LIGHT = "light"
MOTION_X = "motion_x"
MOTION_Y = "motion_y"
MOTION_Z = "motion_z"
TOUCH = "touch"
SHAKE = "shake"
DETECT_TAPS = "detect_taps"


ASSIGN_PIXEL_TYPE_ERROR = (
"The pixel color value type should be tuple, list or hexadecimal."
)
Expand Down Expand Up @@ -32,18 +51,28 @@
TIME_DELAY = 0.03


EVENTS_BUTTON_PRESS = ["button_a", "button_b", "switch"]
EVENTS_SENSOR_CHANGED = ["temperature", "light", "motion_x", "motion_y", "motion_z"]
EVENTS_BUTTON_PRESS = [
EXPRESS_STATE.BUTTON_A,
EXPRESS_STATE.BUTTON_B,
EXPRESS_STATE.SWITCH,
]
EVENTS_SENSOR_CHANGED = [
EXPRESS_STATE.TEMPERATURE,
EXPRESS_STATE.LIGHT,
EXPRESS_STATE.MOTION_X,
EXPRESS_STATE.MOTION_Y,
EXPRESS_STATE.MOTION_Z,
]

ALL_EXPECTED_INPUT_EVENTS = [
"button_a",
"button_b",
"switch",
"temperature",
"light",
"shake",
"motion_x",
"motion_y",
"motion_z",
"touch",
EXPRESS_STATE.BUTTON_A,
EXPRESS_STATE.BUTTON_B,
EXPRESS_STATE.SWITCH,
EXPRESS_STATE.TEMPERATURE,
EXPRESS_STATE.LIGHT,
EXPRESS_STATE.SHAKE,
EXPRESS_STATE.MOTION_X,
EXPRESS_STATE.MOTION_Y,
EXPRESS_STATE.MOTION_Z,
EXPRESS_STATE.TOUCH,
]
80 changes: 41 additions & 39 deletions src/adafruit_circuitplayground/express.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,67 +14,69 @@
from collections import namedtuple
import common

Acceleration = namedtuple("acceleration", ["x", "y", "z"])
Acceleration = namedtuple(CONSTANTS.EXPRESS_STATE.ACCELERATION, ["x", "y", "z"])


class Express:
def __init__(self):
# State in the Python process
self.__state = {
"brightness": 1.0,
"button_a": False,
"button_b": False,
"pixels": [
(0, 0, 0),
(0, 0, 0),
(0, 0, 0),
(0, 0, 0),
(0, 0, 0),
(0, 0, 0),
(0, 0, 0),
(0, 0, 0),
(0, 0, 0),
(0, 0, 0),
],
"red_led": False,
"switch": False,
"temperature": 0,
"light": 0,
"motion_x": 0,
"motion_y": 0,
"motion_z": 0,
"touch": [False] * 7,
"shake": False,
}
self.__state = {}
self.__state[CONSTANTS.EXPRESS_STATE.BRIGHTNESS] = 1.0
self.__state[CONSTANTS.EXPRESS_STATE.BUTTON_A] = False
self.__state[CONSTANTS.EXPRESS_STATE.BUTTON_B] = False
self.__state[CONSTANTS.EXPRESS_STATE.PIXELS] = [
(0, 0, 0),
(0, 0, 0),
(0, 0, 0),
(0, 0, 0),
(0, 0, 0),
(0, 0, 0),
(0, 0, 0),
(0, 0, 0),
(0, 0, 0),
(0, 0, 0),
]
self.__state[CONSTANTS.EXPRESS_STATE.RED_LED] = False
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
self.__state[CONSTANTS.EXPRESS_STATE.MOTION_Y] = 0
self.__state[CONSTANTS.EXPRESS_STATE.MOTION_Z] = 0
self.__state[CONSTANTS.EXPRESS_STATE.TOUCH] = [False] * 7
self.__state[CONSTANTS.EXPRESS_STATE.SHAKE] = False
self.__state[CONSTANTS.EXPRESS_STATE.DETECT_TAPS] = 0
self.pixels = Pixel(self.__state)

@property
def acceleration(self):
telemetry_py.send_telemetry(TelemetryEvent.CPX_API_ACCELERATION)
return Acceleration(
self.__state["motion_x"], self.__state["motion_y"], self.__state["motion_z"]
self.__state[CONSTANTS.EXPRESS_STATE.MOTION_X],
self.__state[CONSTANTS.EXPRESS_STATE.MOTION_Y],
self.__state[CONSTANTS.EXPRESS_STATE.MOTION_Z],
)

@property
def button_a(self):
telemetry_py.send_telemetry(TelemetryEvent.CPX_API_BUTTON_A)
return self.__state["button_a"]
return self.__state[CONSTANTS.EXPRESS_STATE.BUTTON_A]

@property
def button_b(self):
telemetry_py.send_telemetry(TelemetryEvent.CPX_API_BUTTON_B)
return self.__state["button_b"]
return self.__state[CONSTANTS.EXPRESS_STATE.BUTTON_B]

@property
def detect_taps(self):
telemetry_py.send_telemetry(TelemetryEvent.CPX_API_DETECT_TAPS)
return self.__state["detect_taps"]
return self.__state[CONSTANTS.EXPRESS_STATE.DETECT_TAPS]

@detect_taps.setter
def detect_taps(self, value):
telemetry_py.send_telemetry(TelemetryEvent.CPX_API_DETECT_TAPS)
value_int = int(value)
self.__state["detect_taps"] = (
self.__state[CONSTANTS.EXPRESS_STATE.DETECT_TAPS] = (
value_int if (value_int == 1 or value_int == 2) else 1
)

Expand All @@ -88,28 +90,28 @@ def tapped(self):
@property
def red_led(self):
telemetry_py.send_telemetry(TelemetryEvent.CPX_API_RED_LED)
return self.__state["red_led"]
return self.__state[CONSTANTS.EXPRESS_STATE.RED_LED]

@red_led.setter
def red_led(self, value):
telemetry_py.send_telemetry(TelemetryEvent.CPX_API_RED_LED)
self.__state["red_led"] = bool(value)
self.__state[CONSTANTS.EXPRESS_STATE.RED_LED] = bool(value)
self.__show()

@property
def switch(self):
telemetry_py.send_telemetry(TelemetryEvent.CPX_API_SWITCH)
return self.__state["switch"]
return self.__state[CONSTANTS.EXPRESS_STATE.SWITCH]

@property
def temperature(self):
telemetry_py.send_telemetry(TelemetryEvent.CPX_API_TEMPERATURE)
return self.__state["temperature"]
return self.__state[CONSTANTS.EXPRESS_STATE.TEMPERATURE]

@property
def light(self):
telemetry_py.send_telemetry(TelemetryEvent.CPX_API_LIGHT)
return self.__state["light"]
return self.__state[CONSTANTS.EXPRESS_STATE.LIGHT]

def __show(self):
if utils.debug_mode:
Expand All @@ -121,7 +123,7 @@ def __show(self):

def __touch(self, i):
telemetry_py.send_telemetry(TelemetryEvent.CPX_API_TOUCH)
return self.__state["touch"][i - 1]
return self.__state[CONSTANTS.EXPRESS_STATE.TOUCH][i - 1]

@property
def touch_A1(self):
Expand Down Expand Up @@ -160,7 +162,7 @@ def adjust_touch_threshold(self, adjustment):

def shake(self, shake_threshold=30):
telemetry_py.send_telemetry(TelemetryEvent.CPX_API_SHAKE)
return self.__state["shake"]
return self.__state[CONSTANTS.EXPRESS_STATE.SHAKE]

def play_file(self, file_name):
telemetry_py.send_telemetry(TelemetryEvent.CPX_API_PLAY_FILE)
Expand Down
24 changes: 14 additions & 10 deletions src/adafruit_circuitplayground/pixel.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def __getitem__(self, index):
if not self.__valid_index(index):
raise IndexError(CONSTANTS.INDEX_ERROR)
telemetry_py.send_telemetry(TelemetryEvent.CPX_API_PIXELS)
return self.__state["pixels"][index]
return self.__state[CONSTANTS.EXPRESS_STATE.PIXELS][index]

def __setitem__(self, index, val):
telemetry_py.send_telemetry(TelemetryEvent.CPX_API_PIXELS)
Expand All @@ -46,11 +46,13 @@ def __setitem__(self, index, val):
else:
if not self.__valid_index(index):
raise IndexError(CONSTANTS.INDEX_ERROR)
self.__state["pixels"][index] = self.__extract_pixel_value(val, is_slice)
self.__state[CONSTANTS.EXPRESS_STATE.PIXELS][
index
] = self.__extract_pixel_value(val, is_slice)
self.__show_if_auto_write()

def __iter__(self):
yield from self.__state["pixels"]
yield from self.__state[CONSTANTS.EXPRESS_STATE.PIXELS]

def __enter__(self):
return self
Expand All @@ -59,18 +61,20 @@ def __repr__(self):
return "[" + ", ".join([str(x) for x in self]) + "]"

def __len__(self):
return len(self.__state["pixels"])
return len(self.__state[CONSTANTS.EXPRESS_STATE.PIXELS])

def __valid_index(self, index):
return (
type(index) is int
and index >= -len(self.__state["pixels"])
and index < len(self.__state["pixels"])
and index >= -len(self.__state[CONSTANTS.EXPRESS_STATE.PIXELS])
and index < len(self.__state[CONSTANTS.EXPRESS_STATE.PIXELS])
)

def fill(self, val):
for index in range(len(self.__state["pixels"])):
self.__state["pixels"][index] = self.__extract_pixel_value(val)
for index in range(len(self.__state[CONSTANTS.EXPRESS_STATE.PIXELS])):
self.__state[CONSTANTS.EXPRESS_STATE.PIXELS][
index
] = self.__extract_pixel_value(val)
self.__show_if_auto_write()

def __extract_pixel_value(self, val, is_slice=False):
Expand Down Expand Up @@ -113,14 +117,14 @@ def __valid_rgb_value(self, pixValue):
@property
def brightness(self):
telemetry_py.send_telemetry(TelemetryEvent.CPX_API_BRIGHTNESS)
return self.__state["brightness"]
return self.__state[CONSTANTS.EXPRESS_STATE.BRIGHTNESS]

@brightness.setter
def brightness(self, brightness):
if not self.__valid_brightness(brightness):
raise ValueError(CONSTANTS.BRIGHTNESS_RANGE_ERROR)
telemetry_py.send_telemetry(TelemetryEvent.CPX_API_BRIGHTNESS)
self.__state["brightness"] = brightness
self.__state[CONSTANTS.EXPRESS_STATE.BRIGHTNESS] = brightness
self.__show_if_auto_write()

def __valid_brightness(self, brightness):
Expand Down
Loading