From 62b6b8e9eb71651411876cf08ef213cf1e6c7e78 Mon Sep 17 00:00:00 2001 From: Ron Hale-Evans Date: Tue, 14 Jun 2016 12:12:26 -0700 Subject: [PATCH 01/11] Second pass. Clarify API's functionality. --- docs/reference/led/brightness.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/reference/led/brightness.md b/docs/reference/led/brightness.md index f6e2e4e1..c4f175c8 100644 --- a/docs/reference/led/brightness.md +++ b/docs/reference/led/brightness.md @@ -1,6 +1,6 @@ # Brightness -Find how bright the [LED screen](/device/screen) is. +Find how bright the [LED screen](/device/screen) is _when it is turned on_. ```sig led.brightness(); @@ -8,11 +8,11 @@ led.brightness(); ### Returns -* a [Number](/reference/types/number) that means how bright the screen is, from `0` (darkest) to `255` (brightest). For example, the number `127` means the screen is halfway bright. +* a [number](/reference/types/number) that means how bright the screen is when it is turned on, from `0` (darkest) to `255` (brightest). For example, the number `127` means the screen is halfway bright when it is turned on. ### Example: highest brightness -This program makes the screen completely bright if it is not that way already: +This program makes the screen completely bright when it is turned on (if it is not that way already): ```blocks if (led.brightness() < 255) { From 764505d2ca6f9b82844200a11aea8816bd73f545 Mon Sep 17 00:00:00 2001 From: Ron Hale-Evans Date: Tue, 14 Jun 2016 12:51:21 -0700 Subject: [PATCH 02/11] Rewrite in simple language. Improve code examples. --- docs/reference/led/brightness.md | 14 ++++++++++++++ docs/reference/led/set-brightness.md | 11 +++++++---- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/docs/reference/led/brightness.md b/docs/reference/led/brightness.md index c4f175c8..1772fead 100644 --- a/docs/reference/led/brightness.md +++ b/docs/reference/led/brightness.md @@ -20,6 +20,20 @@ if (led.brightness() < 255) { } ``` + +### Example: change brightness + +This program makes the screen brightness 100% (255). Then it turns on +the center LED (`2, 2`), waits for one second and then sets the screen +brightness to 50% (128): + +```blocks +led.setBrightness(255) +led.plot(2, 2) +basic.pause(1000) +led.setBrightness(led.brightness() / 2) +``` + ### See also [set brightness](/reference/led/set-brightness), [fade in](/reference/led/fade-in), [fade out](/reference/led/fade-out) diff --git a/docs/reference/led/set-brightness.md b/docs/reference/led/set-brightness.md index b9262723..3525ff83 100644 --- a/docs/reference/led/set-brightness.md +++ b/docs/reference/led/set-brightness.md @@ -1,6 +1,7 @@ # Set Brightness -Sets the brightness of the [LED screen](/device/screen). +Make the [LED screen](/device/screen) as bright as you say when it is +turned on. ```sig led.setBrightness(121) @@ -8,17 +9,19 @@ led.setBrightness(121) ### Parameters -* value : [Number](/reference/types/number) - the brightness of the LED screen expressed as a number between 0 and 255 +* a [number](/reference/types/number) that means how bright the screen is when it is turned on, from `0` (darkest) to `255` (brightest). For example, the number `127` means the screen is halfway bright when it is turned on. ### Example: change brightness -The following example sets the screen brightness to 100% (255), turns on LED `2, 2`, waits for a second and then sets the screen brightness to 50% (127): +This program makes the screen brightness 100% (255). Then it turns on +the center LED (`2, 2`), waits for one second, and then sets the screen +brightness to 50% (128): ```blocks led.setBrightness(255) led.plot(2, 2) basic.pause(1000) -led.setBrightness(127) +led.setBrightness(led.brightness() / 2) ``` ### See also From bb20c1780b687d08eaa542cd77d61fd9c37e9a8b Mon Sep 17 00:00:00 2001 From: Peli de Halleux Date: Tue, 14 Jun 2016 13:17:20 -0700 Subject: [PATCH 03/11] Add Bluetooth LED service. fix for #111 --- libs/microbit-bluetooth/bluetooth.cpp | 15 ++++++++++++--- libs/microbit-bluetooth/shims.d.ts | 13 ++++++++++--- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/libs/microbit-bluetooth/bluetooth.cpp b/libs/microbit-bluetooth/bluetooth.cpp index 1eed2f05..ef53a82d 100644 --- a/libs/microbit-bluetooth/bluetooth.cpp +++ b/libs/microbit-bluetooth/bluetooth.cpp @@ -2,14 +2,23 @@ #include "MESEvents.h" using namespace pxt; -//% color=#0082FB weight=2 +//% color=#0082FB weight=20 namespace bluetooth { /** * Starts the Bluetooth IO pin service */ - //% help=bluetooth/io-pin-service - //% blockId=bluetooth-io-pin-service block="bluetooth io pin service" + //% help=bluetooth/start-io-pin-service + //% blockId=bluetooth_start_io_pin_service block="bluetooth io pin service" void startIOPinService() { new MicroBitIOPinService(*uBit.ble, uBit.io); } + + /** + * Starts the Bluetooth LED service + */ + //% help=bluetooth/start-led-service + //% blockId=bluetooth_start_led_service block="bluetooth led service" + void startLEDService() { + new MicroBitLEDService(*uBit.ble, uBit.display); + } } diff --git a/libs/microbit-bluetooth/shims.d.ts b/libs/microbit-bluetooth/shims.d.ts index 09260a0f..e6202248 100644 --- a/libs/microbit-bluetooth/shims.d.ts +++ b/libs/microbit-bluetooth/shims.d.ts @@ -2,15 +2,22 @@ - //% color=#0082FB weight=2 + //% color=#0082FB weight=20 declare namespace bluetooth { /** * Starts the Bluetooth IO pin service */ - //% help=bluetooth/io-pin-service - //% blockId=bluetooth-io-pin-service block="bluetooth io pin service" shim=bluetooth::startIOPinService + //% help=bluetooth/start-io-pin-service + //% blockId=bluetooth_start_io_pin_service block="bluetooth io pin service" shim=bluetooth::startIOPinService function startIOPinService(): void; + + /** + * Starts the Bluetooth LED service + */ + //% help=bluetooth/start-led-service + //% blockId=bluetooth_start_led_service block="bluetooth led service" shim=bluetooth::startLEDService + function startLEDService(): void; } // Auto-generated. Do not edit. Really. From 23eefb28d2b7c9748c2708014c0a8e09496817bd Mon Sep 17 00:00:00 2001 From: Peli de Halleux Date: Tue, 14 Jun 2016 13:24:55 -0700 Subject: [PATCH 04/11] support for starting the temperature service #113 --- libs/microbit-bluetooth/bluetooth.cpp | 9 +++++++++ libs/microbit-bluetooth/shims.d.ts | 7 +++++++ sim/libmbit.ts | 12 ++++++++++++ 3 files changed, 28 insertions(+) diff --git a/libs/microbit-bluetooth/bluetooth.cpp b/libs/microbit-bluetooth/bluetooth.cpp index ef53a82d..594e5727 100644 --- a/libs/microbit-bluetooth/bluetooth.cpp +++ b/libs/microbit-bluetooth/bluetooth.cpp @@ -21,4 +21,13 @@ namespace bluetooth { void startLEDService() { new MicroBitLEDService(*uBit.ble, uBit.display); } + + /** + * Starts the temperature service + */ + //% help=bluetooth/start-temperature-service + //% blockId=bluetooth_start_temperature_service block="bluetooth temperature service" + void startTemperatureService() { + new MicroBitTemperatureService(*uBit.ble, uBit.thermometer); + } } diff --git a/libs/microbit-bluetooth/shims.d.ts b/libs/microbit-bluetooth/shims.d.ts index e6202248..5e04fdea 100644 --- a/libs/microbit-bluetooth/shims.d.ts +++ b/libs/microbit-bluetooth/shims.d.ts @@ -18,6 +18,13 @@ declare namespace bluetooth { //% help=bluetooth/start-led-service //% blockId=bluetooth_start_led_service block="bluetooth led service" shim=bluetooth::startLEDService function startLEDService(): void; + + /** + * Starts the temperature service + */ + //% help=bluetooth/start-led-service + //% blockId=bluetooth_start_temperature_service block="bluetooth temperature service" shim=bluetooth::startTemperatureService + function startTemperatureService(): void; } // Auto-generated. Do not edit. Really. diff --git a/sim/libmbit.ts b/sim/libmbit.ts index 52dc76dc..4a386ceb 100644 --- a/sim/libmbit.ts +++ b/sim/libmbit.ts @@ -614,6 +614,18 @@ namespace pxsim.pins { } +namespace pxsim.bluetooth { + export function startIOPinService(): void { + // TODO + } + export function startLEDService(): void { + // TODO + } + export function startTemperatureService(): void { + // TODO + } +} + namespace pxsim.images { export function createImage(img: Image) { return img } export function createBigImage(img: Image) { return img } From 7a2c4f00567f1c59c3e17d29e57d51153d91130c Mon Sep 17 00:00:00 2001 From: Peli de Halleux Date: Tue, 14 Jun 2016 13:27:21 -0700 Subject: [PATCH 05/11] updated shims --- libs/microbit-bluetooth/shims.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/microbit-bluetooth/shims.d.ts b/libs/microbit-bluetooth/shims.d.ts index 5e04fdea..d96b38f8 100644 --- a/libs/microbit-bluetooth/shims.d.ts +++ b/libs/microbit-bluetooth/shims.d.ts @@ -22,7 +22,7 @@ declare namespace bluetooth { /** * Starts the temperature service */ - //% help=bluetooth/start-led-service + //% help=bluetooth/start-temperature-service //% blockId=bluetooth_start_temperature_service block="bluetooth temperature service" shim=bluetooth::startTemperatureService function startTemperatureService(): void; } From c1a6c1c66af95615da714a065a41f981ba68dab0 Mon Sep 17 00:00:00 2001 From: Peli de Halleux Date: Tue, 14 Jun 2016 13:39:24 -0700 Subject: [PATCH 06/11] support for magnetometer service. fix for #112 --- libs/microbit-bluetooth/bluetooth.cpp | 9 +++++++++ libs/microbit-bluetooth/shims.d.ts | 7 +++++++ sim/libmbit.ts | 3 +++ 3 files changed, 19 insertions(+) diff --git a/libs/microbit-bluetooth/bluetooth.cpp b/libs/microbit-bluetooth/bluetooth.cpp index 594e5727..1bb5bdbd 100644 --- a/libs/microbit-bluetooth/bluetooth.cpp +++ b/libs/microbit-bluetooth/bluetooth.cpp @@ -30,4 +30,13 @@ namespace bluetooth { void startTemperatureService() { new MicroBitTemperatureService(*uBit.ble, uBit.thermometer); } + + /** + * Starts the magnetometer service + */ + //% help=bluetooth/start-magnetometer-service + //% blockId=bluetooth_start_magnetometer_service block="bluetooth magnetometer service" + void startMagnetometerService() { + new MicroBitMagnetometerService(*uBit.ble, uBit.compass); + } } diff --git a/libs/microbit-bluetooth/shims.d.ts b/libs/microbit-bluetooth/shims.d.ts index d96b38f8..37fc827c 100644 --- a/libs/microbit-bluetooth/shims.d.ts +++ b/libs/microbit-bluetooth/shims.d.ts @@ -25,6 +25,13 @@ declare namespace bluetooth { //% help=bluetooth/start-temperature-service //% blockId=bluetooth_start_temperature_service block="bluetooth temperature service" shim=bluetooth::startTemperatureService function startTemperatureService(): void; + + /** + * Starts the magnetometer service + */ + //% help=bluetooth/start-magnetometer-service + //% blockId=bluetooth_start_magnetometer_service block="bluetooth magnetometer service" shim=bluetooth::startMagnetometerService + function startMagnetometerService(): void; } // Auto-generated. Do not edit. Really. diff --git a/sim/libmbit.ts b/sim/libmbit.ts index 4a386ceb..0b59481c 100644 --- a/sim/libmbit.ts +++ b/sim/libmbit.ts @@ -624,6 +624,9 @@ namespace pxsim.bluetooth { export function startTemperatureService(): void { // TODO } + export function startMagnetometerService(): void { + // TODO + } } namespace pxsim.images { From 918d2f1a3a5286942eb2fd0d073d067292a26b0d Mon Sep 17 00:00:00 2001 From: Peli de Halleux Date: Tue, 14 Jun 2016 13:47:18 -0700 Subject: [PATCH 07/11] support for bluetooth accelerometer service. fix for #105 --- libs/microbit-bluetooth/bluetooth.cpp | 17 +++++++++++++---- libs/microbit-bluetooth/shims.d.ts | 15 +++++++++++---- sim/libmbit.ts | 3 +++ 3 files changed, 27 insertions(+), 8 deletions(-) diff --git a/libs/microbit-bluetooth/bluetooth.cpp b/libs/microbit-bluetooth/bluetooth.cpp index 1bb5bdbd..2f1f759a 100644 --- a/libs/microbit-bluetooth/bluetooth.cpp +++ b/libs/microbit-bluetooth/bluetooth.cpp @@ -8,7 +8,7 @@ namespace bluetooth { * Starts the Bluetooth IO pin service */ //% help=bluetooth/start-io-pin-service - //% blockId=bluetooth_start_io_pin_service block="bluetooth io pin service" + //% blockId=bluetooth_start_io_pin_service block="bluetooth io pin service" blockGap=8 void startIOPinService() { new MicroBitIOPinService(*uBit.ble, uBit.io); } @@ -17,7 +17,7 @@ namespace bluetooth { * Starts the Bluetooth LED service */ //% help=bluetooth/start-led-service - //% blockId=bluetooth_start_led_service block="bluetooth led service" + //% blockId=bluetooth_start_led_service block="bluetooth led service" blockGap=8 void startLEDService() { new MicroBitLEDService(*uBit.ble, uBit.display); } @@ -26,7 +26,7 @@ namespace bluetooth { * Starts the temperature service */ //% help=bluetooth/start-temperature-service - //% blockId=bluetooth_start_temperature_service block="bluetooth temperature service" + //% blockId=bluetooth_start_temperature_service block="bluetooth temperature service" blockGap=8 void startTemperatureService() { new MicroBitTemperatureService(*uBit.ble, uBit.thermometer); } @@ -35,8 +35,17 @@ namespace bluetooth { * Starts the magnetometer service */ //% help=bluetooth/start-magnetometer-service - //% blockId=bluetooth_start_magnetometer_service block="bluetooth magnetometer service" + //% blockId=bluetooth_start_magnetometer_service block="bluetooth magnetometer service" blockGap=8 void startMagnetometerService() { new MicroBitMagnetometerService(*uBit.ble, uBit.compass); } + + /** + * Starts the accelerometer service + */ + //% help=bluetooth/start-accelerometer-service + //% blockId=bluetooth_start_accelerometer_service block="bluetooth accelerometer service" blockGap=8 + void startAccelerometerService() { + new MicroBitAccelerometerService(*uBit.ble, uBit.accelerometer); + } } diff --git a/libs/microbit-bluetooth/shims.d.ts b/libs/microbit-bluetooth/shims.d.ts index 37fc827c..4979fbed 100644 --- a/libs/microbit-bluetooth/shims.d.ts +++ b/libs/microbit-bluetooth/shims.d.ts @@ -9,29 +9,36 @@ declare namespace bluetooth { * Starts the Bluetooth IO pin service */ //% help=bluetooth/start-io-pin-service - //% blockId=bluetooth_start_io_pin_service block="bluetooth io pin service" shim=bluetooth::startIOPinService + //% blockId=bluetooth_start_io_pin_service block="bluetooth io pin service" blockGap=8 shim=bluetooth::startIOPinService function startIOPinService(): void; /** * Starts the Bluetooth LED service */ //% help=bluetooth/start-led-service - //% blockId=bluetooth_start_led_service block="bluetooth led service" shim=bluetooth::startLEDService + //% blockId=bluetooth_start_led_service block="bluetooth led service" blockGap=8 shim=bluetooth::startLEDService function startLEDService(): void; /** * Starts the temperature service */ //% help=bluetooth/start-temperature-service - //% blockId=bluetooth_start_temperature_service block="bluetooth temperature service" shim=bluetooth::startTemperatureService + //% blockId=bluetooth_start_temperature_service block="bluetooth temperature service" blockGap=8 shim=bluetooth::startTemperatureService function startTemperatureService(): void; /** * Starts the magnetometer service */ //% help=bluetooth/start-magnetometer-service - //% blockId=bluetooth_start_magnetometer_service block="bluetooth magnetometer service" shim=bluetooth::startMagnetometerService + //% blockId=bluetooth_start_magnetometer_service block="bluetooth magnetometer service" blockGap=8 shim=bluetooth::startMagnetometerService function startMagnetometerService(): void; + + /** + * Starts the accelerometer service + */ + //% help=bluetooth/start-accelerometer-service + //% blockId=bluetooth_start_accelerometer_service block="bluetooth accelerometer service" blockGap=8 shim=bluetooth::startAccelerometerService + function startAccelerometerService(): void; } // Auto-generated. Do not edit. Really. diff --git a/sim/libmbit.ts b/sim/libmbit.ts index 0b59481c..0e5ec72f 100644 --- a/sim/libmbit.ts +++ b/sim/libmbit.ts @@ -627,6 +627,9 @@ namespace pxsim.bluetooth { export function startMagnetometerService(): void { // TODO } + export function startAccelerometerService(): void { + // TODO + } } namespace pxsim.images { From cf0372aeaa5f00c9b3ce9b31a209d999389810b5 Mon Sep 17 00:00:00 2001 From: Peli de Halleux Date: Tue, 14 Jun 2016 13:53:05 -0700 Subject: [PATCH 08/11] adding bluetooth button service. fix for #106 --- libs/microbit-bluetooth/bluetooth.cpp | 9 +++++++++ libs/microbit-bluetooth/shims.d.ts | 7 +++++++ sim/libmbit.ts | 3 +++ 3 files changed, 19 insertions(+) diff --git a/libs/microbit-bluetooth/bluetooth.cpp b/libs/microbit-bluetooth/bluetooth.cpp index 2f1f759a..7e6f63d9 100644 --- a/libs/microbit-bluetooth/bluetooth.cpp +++ b/libs/microbit-bluetooth/bluetooth.cpp @@ -48,4 +48,13 @@ namespace bluetooth { void startAccelerometerService() { new MicroBitAccelerometerService(*uBit.ble, uBit.accelerometer); } + + /** + * Starts the button service + */ + //% help=bluetooth/start-button-service + //% blockId=bluetooth_start_button_service block="bluetooth button service" blockGap=8 + void startButtonService() { + new MicroBitButtonService(*uBit.ble); + } } diff --git a/libs/microbit-bluetooth/shims.d.ts b/libs/microbit-bluetooth/shims.d.ts index 4979fbed..85393c00 100644 --- a/libs/microbit-bluetooth/shims.d.ts +++ b/libs/microbit-bluetooth/shims.d.ts @@ -39,6 +39,13 @@ declare namespace bluetooth { //% help=bluetooth/start-accelerometer-service //% blockId=bluetooth_start_accelerometer_service block="bluetooth accelerometer service" blockGap=8 shim=bluetooth::startAccelerometerService function startAccelerometerService(): void; + + /** + * Starts the button service + */ + //% help=bluetooth/start-button-service + //% blockId=bluetooth_start_button_service block="bluetooth button service" blockGap=8 shim=bluetooth::startButtonService + function startButtonService(): void; } // Auto-generated. Do not edit. Really. diff --git a/sim/libmbit.ts b/sim/libmbit.ts index 0e5ec72f..1e9a7a92 100644 --- a/sim/libmbit.ts +++ b/sim/libmbit.ts @@ -630,6 +630,9 @@ namespace pxsim.bluetooth { export function startAccelerometerService(): void { // TODO } + export function startButtonService(): void { + // TODO + } } namespace pxsim.images { From 4a537b1ce83a8a0edd40a71d9512b31de30bb8c6 Mon Sep 17 00:00:00 2001 From: Peli de Halleux Date: Tue, 14 Jun 2016 13:57:27 -0700 Subject: [PATCH 09/11] updated bluetooth library --- libs/microbit-bluetooth/pxt.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/microbit-bluetooth/pxt.json b/libs/microbit-bluetooth/pxt.json index 6d2ead02..7fab9c9d 100644 --- a/libs/microbit-bluetooth/pxt.json +++ b/libs/microbit-bluetooth/pxt.json @@ -20,5 +20,5 @@ } } }, - "installedVersion": "bpcjjs" + "installedVersion": "vzlhfd" } From 0a722b2196c1843d7a56dc1108bea9d9c9a7080b Mon Sep 17 00:00:00 2001 From: Peli de Halleux Date: Tue, 14 Jun 2016 13:57:46 -0700 Subject: [PATCH 10/11] 0.2.161 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 7498b001..20683d04 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "pxt-microbit", - "version": "0.2.160", + "version": "0.2.161", "description": "BBC micro:bit target for PXT", "keywords": [ "JavaScript", From 20c7a16524e58804594fd4d8e7044ee6fd5b9c3c Mon Sep 17 00:00:00 2001 From: Ron Hale-Evans Date: Tue, 14 Jun 2016 14:01:00 -0700 Subject: [PATCH 11/11] Used Dimension.X in sample instead of string --- docs/reference/input/magnetic-force.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/reference/input/magnetic-force.md b/docs/reference/input/magnetic-force.md index 89da6474..b795311d 100644 --- a/docs/reference/input/magnetic-force.md +++ b/docs/reference/input/magnetic-force.md @@ -29,7 +29,7 @@ the magnetic force is stronger, and dimmer when it is weaker. ```blocks led.plot(2, 2) basic.forever(() => { - let f = input.magneticForce("x") + let f = input.magneticForce(Dimension.X) led.setBrightness(f / 2000) }) ```