From 298a37e576edab37e2885632338d22087bb57540 Mon Sep 17 00:00:00 2001 From: gingemonster Date: Wed, 20 Jul 2016 06:14:18 +0100 Subject: [PATCH 01/31] updated setPull help annotation At some point Im guessing the help file has been renamed and its current url is https://codethemicrobit.com/reference/pins/set-pull. This change to the annotation of setPull removes the word "digital" so that the link should work again --- libs/microbit/pins.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/microbit/pins.cpp b/libs/microbit/pins.cpp index 0589aa7c..88c31ab1 100644 --- a/libs/microbit/pins.cpp +++ b/libs/microbit/pins.cpp @@ -229,7 +229,7 @@ namespace pins { * @param name pin to set the pull mode on * @param pull one of the mbed pull configurations: PullUp, PullDown, PullNone */ - //% help=pins/digital-set-pull weight=3 + //% help=pins/set-pull weight=3 //% blockId=device_set_pull block="set pull|pin %pin|to %pull" void setPull(DigitalPin name, PinPullMode pull) { PinMode m = pull == PinPullMode::PullDown From 943c2e7716c984382f86d0cb656c4dd5d5f7f63c Mon Sep 17 00:00:00 2001 From: gingemonster Date: Wed, 20 Jul 2016 06:21:15 +0100 Subject: [PATCH 02/31] Fixing help annotation on serial.redirect Code currently points to help at https://codethemicrobit.com/reference/serial/redirect but the working url is https://codethemicrobit.com/reference/serial/redirect-to so fixed the help annotation --- libs/microbit/serial.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/microbit/serial.cpp b/libs/microbit/serial.cpp index e08e0b99..47f9dda0 100644 --- a/libs/microbit/serial.cpp +++ b/libs/microbit/serial.cpp @@ -61,11 +61,11 @@ namespace serial { * @param baud the new baud rate. eg: 115200 */ //% weight=10 - //% help=serial/redirect + //% help=serial/redirect-to //% blockId=serial_redirect block="serial redirect to|TX %tx|RX %rx|at baud rate %rate" //% blockExternalInputs=1 void redirect(SerialPin tx, SerialPin rx, BaudRate rate) { uBit.serial.redirect((PinName)tx, (PinName)rx); uBit.serial.baud((int)rate); } -} \ No newline at end of file +} From c805d67cf626eb76b024303724ff3fa89c2992e8 Mon Sep 17 00:00:00 2001 From: gingemonster Date: Wed, 20 Jul 2016 06:29:44 +0100 Subject: [PATCH 03/31] fixing help for pins.pulseDuration Help document at https://codethemicrobit.com/reference/pins/pulse-duration doesnt match the help annotation in the code so this fixes it --- libs/microbit/pins.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/microbit/pins.cpp b/libs/microbit/pins.cpp index 0589aa7c..a262018d 100644 --- a/libs/microbit/pins.cpp +++ b/libs/microbit/pins.cpp @@ -159,7 +159,7 @@ namespace pins { /** * Gets the duration of the last pulse in micro-seconds. This function should be called from a ``onPulsed`` handler. */ - //% help=pins/pulse-micros + //% help=pins/pulse-duration //% blockId=pins_pulse_duration block="pulse duration (µs)" //% weight=21 int pulseDuration() { From 20ac14fdf66b7cf30fd1fa21393ee7072bbfe25e Mon Sep 17 00:00:00 2001 From: gingemonster Date: Wed, 20 Jul 2016 10:44:32 +0100 Subject: [PATCH 04/31] fixing more help documentation links set-accelerometer-range was wrong so fixing reference to help doc --- libs/microbit/input.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/microbit/input.cpp b/libs/microbit/input.cpp index efdbc312..c5f54569 100644 --- a/libs/microbit/input.cpp +++ b/libs/microbit/input.cpp @@ -284,7 +284,7 @@ namespace input { * Sets the accelerometer sample range in gravities. * @param range a value describe the maximum strengh of acceleration measured */ - //% help=input/set-accelerator-range + //% help=input/set-accelerometer-range //% blockId=device_set_accelerometer_range block="set accelerometer|range %range" icon="\uf135" //% weight=5 void setAccelerometerRange(AcceleratorRange range) { From 3f66870688f0ce002e3eecca4a604ebbe4b8e2fc Mon Sep 17 00:00:00 2001 From: Ron Hale-Evans Date: Wed, 20 Jul 2016 16:25:09 -0700 Subject: [PATCH 05/31] Getting started with Control --- docs/reference/control/device-name.md | 4 ++-- docs/reference/control/device-serial-number.md | 4 ++-- docs/reference/control/event-timestamp.md | 4 ++-- docs/reference/control/event-value.md | 4 ++-- docs/reference/control/on-event.md | 4 ++-- docs/reference/control/raise-event.md | 4 ++-- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/docs/reference/control/device-name.md b/docs/reference/control/device-name.md index 5c210b4d..46594ba9 100644 --- a/docs/reference/control/device-name.md +++ b/docs/reference/control/device-name.md @@ -1,6 +1,6 @@ -# Do Something +# Device Name -Do something. +Gets a friendly name for the device derived from the its serial number. ```sig diff --git a/docs/reference/control/device-serial-number.md b/docs/reference/control/device-serial-number.md index 5c210b4d..13c2e1a7 100644 --- a/docs/reference/control/device-serial-number.md +++ b/docs/reference/control/device-serial-number.md @@ -1,6 +1,6 @@ -# Do Something +# Device Serial Number -Do something. +Derive a unique, consistent serial number of this device from internal data. ```sig diff --git a/docs/reference/control/event-timestamp.md b/docs/reference/control/event-timestamp.md index 5c210b4d..5a68fc94 100644 --- a/docs/reference/control/event-timestamp.md +++ b/docs/reference/control/event-timestamp.md @@ -1,6 +1,6 @@ -# Do Something +# Event Timestamp -Do something. +Get the timestamp of the last event executed on the bus ```sig diff --git a/docs/reference/control/event-value.md b/docs/reference/control/event-value.md index 5c210b4d..28078c39 100644 --- a/docs/reference/control/event-value.md +++ b/docs/reference/control/event-value.md @@ -1,6 +1,6 @@ -# Do Something +# Event Value -Do something. +Get the value of the last event executed on the bus. ```sig diff --git a/docs/reference/control/on-event.md b/docs/reference/control/on-event.md index 5c210b4d..610233c2 100644 --- a/docs/reference/control/on-event.md +++ b/docs/reference/control/on-event.md @@ -1,6 +1,6 @@ -# Do Something +# On Event -Do something. +Raise an event in the event bus. ```sig diff --git a/docs/reference/control/raise-event.md b/docs/reference/control/raise-event.md index 5c210b4d..010b2e8a 100644 --- a/docs/reference/control/raise-event.md +++ b/docs/reference/control/raise-event.md @@ -1,6 +1,6 @@ -# Do Something +# Raise Event -Do something. +Raise an event in the event bus. ```sig From 3c8027425a42c243f33e1e413bbad8bc74c4b08d Mon Sep 17 00:00:00 2001 From: Michal Moskal Date: Thu, 21 Jul 2016 09:54:53 +0100 Subject: [PATCH 06/31] Fix order of arguments for memset() --- libs/microbit-radio/radio.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/microbit-radio/radio.cpp b/libs/microbit-radio/radio.cpp index e41d6d9c..a93a047a 100644 --- a/libs/microbit-radio/radio.cpp +++ b/libs/microbit-radio/radio.cpp @@ -69,7 +69,7 @@ namespace radio { uint32_t sn = transmitSerialNumber ? microbit_serial_number() : 0; uint8_t buf[32]; uint32_t* buf32 = (uint32_t*)buf; - memset(buf, 32, 0); + memset(buf, 0, 32); buf32[0] = value; // 4 bytes: value buf32[1] = t; // 4 bytes: running time buf32[2] = sn; // 4 bytes: serial number From 43e4d06fd9717383e479ef5ac2377270d44a8a15 Mon Sep 17 00:00:00 2001 From: Michal Moskal Date: Thu, 21 Jul 2016 16:08:22 +0100 Subject: [PATCH 07/31] Add tests (for pxt testdir) --- tests/base/main.ts | 1 + tests/base/pxt.json | 13 +++++++++++++ tests/hello.ts | 1 + 3 files changed, 15 insertions(+) create mode 100644 tests/base/main.ts create mode 100644 tests/base/pxt.json create mode 100644 tests/hello.ts diff --git a/tests/base/main.ts b/tests/base/main.ts new file mode 100644 index 00000000..94cbb82d --- /dev/null +++ b/tests/base/main.ts @@ -0,0 +1 @@ +// empty - not testing anything here diff --git a/tests/base/pxt.json b/tests/base/pxt.json new file mode 100644 index 00000000..db9ff13a --- /dev/null +++ b/tests/base/pxt.json @@ -0,0 +1,13 @@ +{ + "name": "base-test", + "description": "Base package for tests", + "files": [ + "main.ts" + ], + "public": true, + "dependencies": { + "microbit": "*", + "microbit-radio": "*" + }, + "installedVersion": "file:." +} diff --git a/tests/hello.ts b/tests/hello.ts new file mode 100644 index 00000000..522e9d88 --- /dev/null +++ b/tests/hello.ts @@ -0,0 +1 @@ +basic.showString("Hello world!") From a29e06abce8b73f66e01baac60bbc5eebf97c09e Mon Sep 17 00:00:00 2001 From: Peli de Halleux Date: Thu, 21 Jul 2016 11:06:02 -0700 Subject: [PATCH 08/31] removing dangling file --- docs/reference/game/misc.txt | 54 ------------------------------------ 1 file changed, 54 deletions(-) delete mode 100644 docs/reference/game/misc.txt diff --git a/docs/reference/game/misc.txt b/docs/reference/game/misc.txt deleted file mode 100644 index e32154ef..00000000 --- a/docs/reference/game/misc.txt +++ /dev/null @@ -1,54 +0,0 @@ - -### Score - -When a player achieves a goal, you can increase the game score - -* add score points to the current score - -``` -export function addScore(points: number) -``` - -* get the current score value - -``` -export function score() : number -``` - - -### Score - -When a player achieves a goal, you can increase the game score - -* add score points to the current score - -``` -export function addScore(points: number) -``` - -* set the current score to a particular value. - -``` -export function setScore(value: number) -``` - -* get the current score value - -``` -export function score() : number - - - -``` - -### Countdown - -If your game has a time limit, you can start a countdown in which case `game->current time` returns the remaining time. - -* start a countdown with the maximum duration of the game in milliseconds. - -``` -export function startCountdown(ms: number) -``` - - From c55716e148c46d6597abf6b9f875303038218a78 Mon Sep 17 00:00:00 2001 From: Ron Hale-Evans Date: Thu, 21 Jul 2016 13:29:59 -0700 Subject: [PATCH 09/31] Control pages now link to Lancaster --- docs/reference/control/device-name.md | 27 ++-------------- .../reference/control/device-serial-number.md | 28 ++-------------- docs/reference/control/event-source-id.md | 32 +++---------------- docs/reference/control/event-timestamp.md | 28 ++-------------- docs/reference/control/event-value-id.md | 30 +++-------------- docs/reference/control/event-value.md | 26 ++------------- docs/reference/control/on-event.md | 27 ++-------------- docs/reference/control/raise-event.md | 28 ++-------------- 8 files changed, 28 insertions(+), 198 deletions(-) diff --git a/docs/reference/control/device-name.md b/docs/reference/control/device-name.md index 46594ba9..566b0e07 100644 --- a/docs/reference/control/device-name.md +++ b/docs/reference/control/device-name.md @@ -3,30 +3,9 @@ Gets a friendly name for the device derived from the its serial number. ```sig - +control.deviceName(); ``` -### Parameters - -* ``a``: -* ``b``: -* ``c``: - -### Returns - - - -### Example - -The following example / This program does something. - -```blocks - -``` - -### See also - -[bar bas](/reference/foo/bar-bas), -[bar bas](/reference/foo/bar-bas), -[bar bas](/reference/foo/bar-bas) +**This is an advanced API.** For more information, see the +[micro:bit runtime messageBus documentation](https://lancaster-university.github.io/microbit-docs/ubit/messageBus/). diff --git a/docs/reference/control/device-serial-number.md b/docs/reference/control/device-serial-number.md index 13c2e1a7..abb4dd20 100644 --- a/docs/reference/control/device-serial-number.md +++ b/docs/reference/control/device-serial-number.md @@ -3,30 +3,8 @@ Derive a unique, consistent serial number of this device from internal data. ```sig - +control.deviceSerialNumber(); ``` -### Parameters - -* ``a``: -* ``b``: -* ``c``: - -### Returns - - - -### Example - -The following example / This program does something. - -```blocks - -``` - -### See also - -[bar bas](/reference/foo/bar-bas), -[bar bas](/reference/foo/bar-bas), -[bar bas](/reference/foo/bar-bas) - +**This is an advanced API.** For more information, see the +[micro:bit runtime messageBus documentation](https://lancaster-university.github.io/microbit-docs/ubit/messageBus/). diff --git a/docs/reference/control/event-source-id.md b/docs/reference/control/event-source-id.md index 5c210b4d..af44ba9d 100644 --- a/docs/reference/control/event-source-id.md +++ b/docs/reference/control/event-source-id.md @@ -1,32 +1,10 @@ -# Do Something +# Event Source ID -Do something. +Return a code representing the origin of the event on the bus (button, pin, radio, and so on). ```sig - +control.eventSourceId(EventBusSource.MICROBIT_ID_BUTTON_A); ``` -### Parameters - -* ``a``: -* ``b``: -* ``c``: - -### Returns - - - -### Example - -The following example / This program does something. - -```blocks - -``` - -### See also - -[bar bas](/reference/foo/bar-bas), -[bar bas](/reference/foo/bar-bas), -[bar bas](/reference/foo/bar-bas) - +**This is an advanced API.** For more information, see the +[micro:bit runtime messageBus documentation](https://lancaster-university.github.io/microbit-docs/ubit/messageBus/) diff --git a/docs/reference/control/event-timestamp.md b/docs/reference/control/event-timestamp.md index 5a68fc94..5129b9ad 100644 --- a/docs/reference/control/event-timestamp.md +++ b/docs/reference/control/event-timestamp.md @@ -3,30 +3,8 @@ Get the timestamp of the last event executed on the bus ```sig - +control.eventTimestamp(); ``` -### Parameters - -* ``a``: -* ``b``: -* ``c``: - -### Returns - - - -### Example - -The following example / This program does something. - -```blocks - -``` - -### See also - -[bar bas](/reference/foo/bar-bas), -[bar bas](/reference/foo/bar-bas), -[bar bas](/reference/foo/bar-bas) - +**This is an advanced API.** For more information, see the +[micro:bit runtime messageBus documentation](https://lancaster-university.github.io/microbit-docs/ubit/messageBus/). diff --git a/docs/reference/control/event-value-id.md b/docs/reference/control/event-value-id.md index 5c210b4d..8153a7f0 100644 --- a/docs/reference/control/event-value-id.md +++ b/docs/reference/control/event-value-id.md @@ -1,32 +1,12 @@ -# Do Something +# Event Value ID -Do something. +Return a code representing the type of the event (button click, device gesture, and so on). ```sig - +control.eventValueId(EventBusValue.MICROBIT_EVT_ANY); ``` -### Parameters -* ``a``: -* ``b``: -* ``c``: - -### Returns - - - -### Example - -The following example / This program does something. - -```blocks - -``` - -### See also - -[bar bas](/reference/foo/bar-bas), -[bar bas](/reference/foo/bar-bas), -[bar bas](/reference/foo/bar-bas) +**This is an advanced API.** For more information, see the +[micro:bit runtime messageBus documentation](https://lancaster-university.github.io/microbit-docs/ubit/messageBus/). diff --git a/docs/reference/control/event-value.md b/docs/reference/control/event-value.md index 28078c39..46b60081 100644 --- a/docs/reference/control/event-value.md +++ b/docs/reference/control/event-value.md @@ -3,30 +3,10 @@ Get the value of the last event executed on the bus. ```sig - +control.eventValue(); ``` -### Parameters -* ``a``: -* ``b``: -* ``c``: - -### Returns - - - -### Example - -The following example / This program does something. - -```blocks - -``` - -### See also - -[bar bas](/reference/foo/bar-bas), -[bar bas](/reference/foo/bar-bas), -[bar bas](/reference/foo/bar-bas) +**This is an advanced API.** For more information, see the +[micro:bit runtime messageBus documentation](https://lancaster-university.github.io/microbit-docs/ubit/messageBus/). diff --git a/docs/reference/control/on-event.md b/docs/reference/control/on-event.md index 610233c2..a95dd5d8 100644 --- a/docs/reference/control/on-event.md +++ b/docs/reference/control/on-event.md @@ -3,30 +3,9 @@ Raise an event in the event bus. ```sig - +control.onEvent(control.eventSourceId(EventBusSource.MICROBIT_ID_BUTTON_A), control.eventValueId(EventBusValue.MICROBIT_EVT_ANY), () => { }); ``` -### Parameters - -* ``a``: -* ``b``: -* ``c``: - -### Returns - - - -### Example - -The following example / This program does something. - -```blocks - -``` - -### See also - -[bar bas](/reference/foo/bar-bas), -[bar bas](/reference/foo/bar-bas), -[bar bas](/reference/foo/bar-bas) +**This is an advanced API.** For more information, see the +[micro:bit runtime messageBus documentation](https://lancaster-university.github.io/microbit-docs/ubit/messageBus/). diff --git a/docs/reference/control/raise-event.md b/docs/reference/control/raise-event.md index 010b2e8a..f9a8a50c 100644 --- a/docs/reference/control/raise-event.md +++ b/docs/reference/control/raise-event.md @@ -3,30 +3,8 @@ Raise an event in the event bus. ```sig - +control.raiseEvent(control.eventSourceId(EventBusSource.MICROBIT_ID_BUTTON_A), control.eventValueId(EventBusValue.MICROBIT_EVT_ANY)); ``` -### Parameters - -* ``a``: -* ``b``: -* ``c``: - -### Returns - - - -### Example - -The following example / This program does something. - -```blocks - -``` - -### See also - -[bar bas](/reference/foo/bar-bas), -[bar bas](/reference/foo/bar-bas), -[bar bas](/reference/foo/bar-bas) - +**This is an advanced API.** For more information, see the +[micro:bit runtime messageBus documentation](https://lancaster-university.github.io/microbit-docs/ubit/messageBus/) From 63913c21820adee21102ed86a135ea5af00529fb Mon Sep 17 00:00:00 2001 From: Peli de Halleux Date: Thu, 21 Jul 2016 13:46:22 -0700 Subject: [PATCH 10/31] updated getting-started intro --- docs/getting-started.md | 7 ++----- libs/microbit/shims.d.ts | 8 ++++---- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/docs/getting-started.md b/docs/getting-started.md index f00cd502..dab6bddf 100644 --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -2,16 +2,13 @@ ## ~avatar -Are you ready to build cool micro:bit programs? - Here are some challenges for you. Arrange the blocks in the editor to make real programs that work! ## ~ -Use the **Basic** drawer in the editor (to the left) -to drag out and arrange three blocks (two `show leds` and one `forever` block) -to create this program: +Use the **Basic** drawer in the editor +to drag out and arrange three blocks to create this program: ```blocks basic.forever(() => { diff --git a/libs/microbit/shims.d.ts b/libs/microbit/shims.d.ts index 87ca31d1..c600e641 100644 --- a/libs/microbit/shims.d.ts +++ b/libs/microbit/shims.d.ts @@ -301,7 +301,7 @@ declare namespace input { * Sets the accelerometer sample range in gravities. * @param range a value describe the maximum strengh of acceleration measured */ - //% help=input/set-accelerator-range + //% help=input/set-accelerometer-range //% blockId=device_set_accelerometer_range block="set accelerometer|range %range" icon="\uf135" //% weight=5 shim=input::setAccelerometerRange function setAccelerometerRange(range: AcceleratorRange): void; @@ -497,7 +497,7 @@ declare namespace pins { /** * Gets the duration of the last pulse in micro-seconds. This function should be called from a ``onPulsed`` handler. */ - //% help=pins/pulse-micros + //% help=pins/pulse-duration //% blockId=pins_pulse_duration block="pulse duration (µs)" //% weight=21 shim=pins::pulseDuration function pulseDuration(): number; @@ -540,7 +540,7 @@ declare namespace pins { * @param name pin to set the pull mode on * @param pull one of the mbed pull configurations: PullUp, PullDown, PullNone */ - //% help=pins/digital-set-pull weight=3 + //% help=pins/set-pull weight=3 //% blockId=device_set_pull block="set pull|pin %pin|to %pull" shim=pins::setPull function setPull(name: DigitalPin, pull: PinPullMode): void; @@ -592,7 +592,7 @@ declare namespace serial { * @param baud the new baud rate. eg: 115200 */ //% weight=10 - //% help=serial/redirect + //% help=serial/redirect-to //% blockId=serial_redirect block="serial redirect to|TX %tx|RX %rx|at baud rate %rate" //% blockExternalInputs=1 shim=serial::redirect function redirect(tx: SerialPin, rx: SerialPin, rate: BaudRate): void; From 8e749659645696e03d94510b08db1b8f5898feb9 Mon Sep 17 00:00:00 2001 From: Peli de Halleux Date: Thu, 21 Jul 2016 14:22:30 -0700 Subject: [PATCH 11/31] remove experiemental translations --- libs/microbit/pxt.json | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/libs/microbit/pxt.json b/libs/microbit/pxt.json index d45a0a08..7fa62df8 100644 --- a/libs/microbit/pxt.json +++ b/libs/microbit/pxt.json @@ -26,12 +26,7 @@ "pins.ts", "serial.cpp", "serial.ts", - "buffer.cpp", - "_locales/ar/microbit-strings.json", - "_locales/de/microbit-strings.json", - "_locales/es-ES/microbit-strings.json", - "_locales/fr/microbit-strings.json", - "_locales/ja/microbit-strings.json" + "buffer.cpp" ], "public": true, "dependencies": {}, From 05098252ed2eee8fcdc8ef60d16ba41f2ffdd757 Mon Sep 17 00:00:00 2001 From: Peli de Halleux Date: Thu, 21 Jul 2016 15:32:59 -0700 Subject: [PATCH 12/31] slightly more impressive about example --- docs/about.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/about.md b/docs/about.md index d5d8242b..99839f62 100644 --- a/docs/about.md +++ b/docs/about.md @@ -38,7 +38,9 @@ Learn about the [hardware components](/device) of the micro:bit to make the most You can program the micro:bit using [Blocks](/blocks) or [JavaScript](/javascript), via the [micro:bit APIs](/reference): ```blocks -basic.showString("Hi!"); +input.onButtonPressed(Button.A, () => { + basic.showString("Hi!"); +}) ``` ## Compile and Flash: Your Program! From a51a14022ab6e29870eac0ef0e2289d48a6ca899 Mon Sep 17 00:00:00 2001 From: Jonathan Protzenko Date: Thu, 21 Jul 2016 16:25:20 -0700 Subject: [PATCH 13/31] Update analog-pitch.md --- docs/reference/pins/analog-pitch.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/reference/pins/analog-pitch.md b/docs/reference/pins/analog-pitch.md index b229875c..d42308b9 100644 --- a/docs/reference/pins/analog-pitch.md +++ b/docs/reference/pins/analog-pitch.md @@ -1,6 +1,6 @@ # Analog Pitch -Emits a Pulse With Modulation (PWM) signal to the current pitch [pin](/device/pins). Use [analog set pitch pin](/reference/pins/analog-set-pitch-pin) to set the pitch pin. +Emits a Pulse With Modulation (PWM) signal to the current pitch [pin](/device/pins). Use [analog set pitch pin](/reference/pins/analog-set-pitch-pin) to set the current pitch pin. ```sig pins.analogPitch(440, 300) From ead4d32446c564a0245aeb55a47d3302439065ee Mon Sep 17 00:00:00 2001 From: Jonathan Protzenko Date: Thu, 21 Jul 2016 16:36:33 -0700 Subject: [PATCH 14/31] Update analog-read-pin.md --- docs/reference/pins/analog-read-pin.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/docs/reference/pins/analog-read-pin.md b/docs/reference/pins/analog-read-pin.md index c9b87526..35ded767 100644 --- a/docs/reference/pins/analog-read-pin.md +++ b/docs/reference/pins/analog-read-pin.md @@ -28,9 +28,7 @@ basic.forever(() => { #### ~hint -If you are using **analog read pin** with another micro:bit -running **analog write pin**, it is a good idea to check -**analog read pin** many times and then take an average. +If you are using **analog read pin** with another micro:bit running **analog write pin**, then things can get tricky. Remember that the micro:bit that runs **analog set pin** writes 0's and 1's at a very high frequency to achieve an average of the desired value. Sadly, if you try to read that average from another micro:bit, then the micro:bit will either read 0 or 1023. You could try to read a higher number of values (e.g. a million) in a loop, then computer then average. Alternatively, you can plug in a capacitor in-between the two micro:bits. #### ~ From 7dcd770508927a1812162cee5de93420506512e8 Mon Sep 17 00:00:00 2001 From: Michal Moskal Date: Fri, 22 Jul 2016 11:32:57 +0100 Subject: [PATCH 15/31] Cache sources for testconv in travis --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 08b12ffb..af38511e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,4 +14,5 @@ cache: directories: - node_modules - built/cache + - libs/hello/built/cache From 5123a962d9012e9e14ec9eed459613785626b745 Mon Sep 17 00:00:00 2001 From: Michal Moskal Date: Fri, 22 Jul 2016 11:39:39 +0100 Subject: [PATCH 16/31] Bump pxt-core to 0.2.196 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ad22fb76..aaefed11 100644 --- a/package.json +++ b/package.json @@ -29,6 +29,6 @@ "typescript": "^1.8.7" }, "dependencies": { - "pxt-core": "0.2.194" + "pxt-core": "0.2.196" } } From aa380baf1cd34a72f78dd142d8d1a8f9079cfed2 Mon Sep 17 00:00:00 2001 From: Michal Moskal Date: Fri, 22 Jul 2016 11:39:39 +0100 Subject: [PATCH 17/31] 0.2.187 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index aaefed11..e734c60d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "pxt-microbit", - "version": "0.2.186", + "version": "0.2.187", "description": "BBC micro:bit target for PXT", "keywords": [ "JavaScript", From 004d34b5df64bda48a77b3857fdc8433d7817aa8 Mon Sep 17 00:00:00 2001 From: Michal Moskal Date: Fri, 22 Jul 2016 11:57:15 +0100 Subject: [PATCH 18/31] Bump pxt-core to 0.2.197 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index e734c60d..f9339ae0 100644 --- a/package.json +++ b/package.json @@ -29,6 +29,6 @@ "typescript": "^1.8.7" }, "dependencies": { - "pxt-core": "0.2.196" + "pxt-core": "0.2.197" } } From ed07f0baad261f19fb8cd08523bb8e3f6d0fee30 Mon Sep 17 00:00:00 2001 From: Michal Moskal Date: Fri, 22 Jul 2016 11:57:15 +0100 Subject: [PATCH 19/31] 0.2.188 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index f9339ae0..74584ab8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "pxt-microbit", - "version": "0.2.187", + "version": "0.2.188", "description": "BBC micro:bit target for PXT", "keywords": [ "JavaScript", From 0b4dd534ab7a6c2c007769a53f92fd3a82343047 Mon Sep 17 00:00:00 2001 From: Michal Moskal Date: Fri, 22 Jul 2016 12:12:20 +0100 Subject: [PATCH 20/31] Bump pxt-core to 0.2.199 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 74584ab8..f3cc1ffa 100644 --- a/package.json +++ b/package.json @@ -29,6 +29,6 @@ "typescript": "^1.8.7" }, "dependencies": { - "pxt-core": "0.2.197" + "pxt-core": "0.2.199" } } From 6e4a71b2f4f4cd63ff962c337c0ec18899ca9aa5 Mon Sep 17 00:00:00 2001 From: Michal Moskal Date: Fri, 22 Jul 2016 12:12:21 +0100 Subject: [PATCH 21/31] 0.2.189 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index f3cc1ffa..a80ec85c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "pxt-microbit", - "version": "0.2.188", + "version": "0.2.189", "description": "BBC micro:bit target for PXT", "keywords": [ "JavaScript", From d0357137868c4f495fd5782643829d5b063d32f4 Mon Sep 17 00:00:00 2001 From: Michal Moskal Date: Fri, 22 Jul 2016 12:26:13 +0100 Subject: [PATCH 22/31] Bump pxt-core to 0.2.200 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index a80ec85c..ba66161d 100644 --- a/package.json +++ b/package.json @@ -29,6 +29,6 @@ "typescript": "^1.8.7" }, "dependencies": { - "pxt-core": "0.2.199" + "pxt-core": "0.2.200" } } From 3e37b0380802c77e49d2b16b75addf50e2d63f5c Mon Sep 17 00:00:00 2001 From: Michal Moskal Date: Fri, 22 Jul 2016 12:26:13 +0100 Subject: [PATCH 23/31] 0.2.190 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ba66161d..4014b12b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "pxt-microbit", - "version": "0.2.189", + "version": "0.2.190", "description": "BBC micro:bit target for PXT", "keywords": [ "JavaScript", From a5d5836ea209fff3eca93526b30aeed530fbbfec Mon Sep 17 00:00:00 2001 From: Michal Moskal Date: Fri, 22 Jul 2016 15:18:38 +0100 Subject: [PATCH 24/31] Add some tests converted from TD --- .gitignore | 3 +- tests/hat-game.ts | 232 +++++++++++++++++++++++++++++++++++++++ tests/meteorite.ts | 155 ++++++++++++++++++++++++++ tests/pac-man-runaway.ts | 230 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 619 insertions(+), 1 deletion(-) create mode 100644 tests/hat-game.ts create mode 100644 tests/meteorite.ts create mode 100644 tests/pac-man-runaway.ts diff --git a/.gitignore b/.gitignore index a380d480..fb7912e2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ node_modules yotta_modules yotta_targets +pxt_modules built typings tmp @@ -18,4 +19,4 @@ clients/**/obj/** *.tgz *.db *.suo -*.log \ No newline at end of file +*.log diff --git a/tests/hat-game.ts b/tests/hat-game.ts new file mode 100644 index 00000000..1f1b3e79 --- /dev/null +++ b/tests/hat-game.ts @@ -0,0 +1,232 @@ +let correctBall: number +let ballRevealing: boolean +let cupSelect: string +let index: number +let score: number +let level: number +let swapSpeed: number + +initializeGame() +input.onButtonPressed(Button.A, () => { + if (ballRevealing) { + index = index + 1 + if (index > 2) { + index = 0 + } + basic.showString(cupSelect[index], 150) + } +}) +input.onButtonPressed(Button.B, () => { + if (ballRevealing) { + ballRevealing = false + if (correctBall == index) { + score = score + level + images.createImage(` + . . . . . + . . . . # + . . . # . + # . # . . + . # . . . + `).showImage(0) + basic.pause(1000) + basic.showString("+".concat(level.toString()), 150) + basic.pause(1000) + } else { + images.createImage(` + # . . . # + . # . # . + . . # . . + . # . # . + # . . . # + `).showImage(0) + basic.pause(1000) + basic.clearScreen() + revealBall(correctBall) + basic.pause(1000) + } + } + level = level + 1 + if (level == 4) { + basic.showString("FINAL SCORE:", 75) + basic.showNumber(score, 150) + } else { + playLevel(level) + } +}) +playLevel(1) + +function revealBall(p: number) { + let xCoordinate = 2 * p + for (let j = 0; j < 3; j++) { + led.plot(j * 2, 2) + } + for (let i = 0; i < 3; i++) { + led.unplot(xCoordinate, 2) + led.plot(xCoordinate, 1) + basic.pause(100) + led.unplot(xCoordinate, 1) + led.plot(xCoordinate, 0) + basic.pause(200) + led.unplot(xCoordinate, 0) + led.plot(xCoordinate, 1) + basic.pause(100) + led.unplot(xCoordinate, 1) + led.plot(xCoordinate, 2) + basic.pause(75) + } + basic.pause(1000) +} + +function initializeGame() { + ballRevealing = false + level = 1 + score = 0 + cupSelect = "LMR" +} + +function swapCups(cup_1: number, cup_2: number, pauseDifficulty: number) { + let cup_1X = 2 * cup_1 + let cup_2X = 2 * cup_2 + let cupXAverage = (cup_1X + cup_2X) / 2 + led.unplot(cup_1X, 2) + led.unplot(cup_2X, 2) + led.plot(cup_1X, 3) + led.plot(cup_2X, 1) + basic.pause(pauseDifficulty) + led.unplot(cup_1X, 3) + led.unplot(cup_2X, 1) + led.plot(cup_1X, 4) + led.plot(cup_2X, 0) + basic.pause(pauseDifficulty) + led.unplot(cup_1X, 4) + led.unplot(cup_2X, 0) + if (cupXAverage == 2) { + led.plot((cupXAverage + cup_1X) / 2, 4) + led.plot((cupXAverage + cup_2X) / 2, 0) + basic.pause(pauseDifficulty) + led.unplot((cupXAverage + cup_1X) / 2, 4) + led.unplot((cupXAverage + cup_2X) / 2, 0) + } + led.plot(cupXAverage, 4) + led.plot(cupXAverage, 0) + basic.pause(pauseDifficulty) + led.unplot(cupXAverage, 4) + led.unplot(cupXAverage, 0) + if (cupXAverage == 2) { + led.plot((cupXAverage + cup_2X) / 2, 4) + led.plot((cupXAverage + cup_1X) / 2, 0) + basic.pause(pauseDifficulty) + led.unplot((cupXAverage + cup_2X) / 2, 4) + led.unplot((cupXAverage + cup_1X) / 2, 0) + } + led.plot(cup_2X, 4) + led.plot(cup_1X, 0) + basic.pause(pauseDifficulty) + led.unplot(cup_2X, 4) + led.unplot(cup_1X, 0) + led.plot(cup_2X, 3) + led.plot(cup_1X, 1) + basic.pause(pauseDifficulty) + led.unplot(cup_2X, 3) + led.unplot(cup_1X, 1) + led.plot(cup_2X, 2) + led.plot(cup_1X, 2) + basic.pause(pauseDifficulty) + if (correctBall == cup_1) { + correctBall = cup_2 + } else if (correctBall == cup_2) { + correctBall = cup_1 + } +} + +function swapFake(cup_1: number, cup_2: number, pauseDifficulty: number) { + let cup_1X = 2 * cup_1 + let cup_2X = 2 * cup_2 + let cupXAverage = (cup_1X + cup_2X) / 2 + led.unplot(cup_1X, 2) + led.unplot(cup_2X, 2) + led.plot(cup_1X, 3) + led.plot(cup_2X, 1) + basic.pause(pauseDifficulty) + led.unplot(cup_1X, 3) + led.unplot(cup_2X, 1) + led.plot(cup_1X, 4) + led.plot(cup_2X, 0) + basic.pause(pauseDifficulty) + led.unplot(cup_1X, 4) + led.unplot(cup_2X, 0) + if (cupXAverage == 2) { + led.plot((cupXAverage + cup_1X) / 2, 4) + led.plot((cupXAverage + cup_2X) / 2, 0) + basic.pause(pauseDifficulty) + led.unplot((cupXAverage + cup_1X) / 2, 4) + led.unplot((cupXAverage + cup_2X) / 2, 0) + } + led.plot(cupXAverage, 4) + led.plot(cupXAverage, 0) + basic.pause(pauseDifficulty) + led.unplot(cupXAverage, 4) + led.unplot(cupXAverage, 0) + if (cupXAverage == 2) { + led.plot((cupXAverage + cup_1X) / 2, 4) + led.plot((cupXAverage + cup_2X) / 2, 0) + basic.pause(pauseDifficulty) + led.unplot((cupXAverage + cup_1X) / 2, 4) + led.unplot((cupXAverage + cup_2X) / 2, 0) + } + led.plot(cup_1X, 4) + led.plot(cup_2X, 0) + basic.pause(pauseDifficulty) + led.unplot(cup_1X, 4) + led.unplot(cup_2X, 0) + led.plot(cup_1X, 3) + led.plot(cup_2X, 1) + basic.pause(pauseDifficulty) + led.unplot(cup_1X, 3) + led.unplot(cup_2X, 1) + led.plot(cup_1X, 2) + led.plot(cup_2X, 2) + basic.pause(pauseDifficulty) +} + +function playLevel(level1: number) { + basic.showNumber(level, 150) + basic.pause(3000) + basic.clearScreen() + for (let i = 0; i < 3; i++) { + led.plot(2 * i, 2) + } + basic.pause(1000) + correctBall = Math.random(3) + revealBall(correctBall) + basic.pause(1000) + let swaps = 5 + 10 * level1 + if (level1 == 1) { + swapSpeed = 80 + } else if (level1 == 2) { + swapSpeed = 40 + } else { + swapSpeed = 20 + } + for (let i1 = 0; i1 < swaps; i1++) { + let swapType = Math.random(3) + let not = Math.random(3) + if (swapType < 2) { + let swapOrientation = Math.random(2) + if (swapOrientation == 0) { + swapCups((not + 1) % 3, (not + 2) % 3, swapSpeed) + } else { + swapCups((not + 2) % 3, (not + 1) % 3, swapSpeed) + } + } else { + let swapOrientation1 = Math.random(2) + if (swapOrientation1 == 0) { + swapFake((not + 1) % 3, (not + 2) % 3, swapSpeed) + } else { + swapFake((not + 2) % 3, (not + 1) % 3, swapSpeed) + } + } + } + index = -1 + ballRevealing = true +} diff --git a/tests/meteorite.ts b/tests/meteorite.ts new file mode 100644 index 00000000..a877ab1b --- /dev/null +++ b/tests/meteorite.ts @@ -0,0 +1,155 @@ +let oneX: number +let oneY: number +let twoX: number +let twoY: number +let pause: number +let meteoriteOneX: number +let meteoriteOneY: number +let meteoriteTwoX: number +let meteoriteTwoY: number +let counter: number + +basic.pause(2000) +oneX = 0 +oneY = 4 +twoX = 1 +twoY = 4 +counter = 0 +pause = 700 +led.plot(oneX, oneY) +led.plot(twoX, twoY) +input.onButtonPressed(Button.A, () => { + if (oneX > 0) { + led.unplot(oneX, oneY) + led.unplot(twoX, twoY) + oneX = oneX - 1 + twoX = twoX - 1 + led.plot(oneX, oneY) + led.plot(twoX, twoY) + } +}) +input.onButtonPressed(Button.B, () => { + if (twoX < 4) { + led.unplot(oneX, oneY) + led.unplot(twoX, twoY) + oneX = oneX + 1 + twoX = twoX + 1 + led.plot(oneX, oneY) + led.plot(twoX, twoY) + } +}) +meteoriteOneX = Math.random(5) +meteoriteOneY = 0 +meteoriteTwoX = Math.random(5) +meteoriteTwoY = -3 +basic.pause(1000) +for (let i = 0; i < 3; i++) { + led.plot(meteoriteTwoX, meteoriteTwoY) + led.plot(meteoriteOneX, meteoriteOneY) + basic.pause(pause) + led.unplot(meteoriteTwoX, meteoriteTwoY) + led.unplot(meteoriteOneX, meteoriteOneY) + meteoriteOneY = meteoriteOneY + 1 + meteoriteTwoY = meteoriteTwoY + 1 +} +basic.forever(() => { + for (let i1 = 0; i1 < 3; i1++) { + led.plot(meteoriteTwoX, meteoriteTwoY) + led.plot(meteoriteOneX, meteoriteOneY) + basic.pause(pause) + led.unplot(meteoriteOneX, meteoriteOneY) + led.unplot(meteoriteTwoX, meteoriteTwoY) + meteoriteOneY = meteoriteOneY + 1 + meteoriteTwoY = meteoriteTwoY + 1 + if (meteoriteOneY == 4) { + if (meteoriteOneX == oneX) { + for (let j = 0; j < 10; j++) { + led.plotAll() + basic.pause(200) + basic.clearScreen() + basic.pause(200) + } + basic.showNumber(counter, 150) + basic.pause(10000) + } else if (meteoriteOneX == twoX) { + for (let j1 = 0; j1 < 10; j1++) { + led.plotAll() + basic.pause(200) + basic.clearScreen() + basic.pause(200) + } + basic.showNumber(counter, 150) + basic.pause(10000) + } + } + } + while (Math.abs(meteoriteTwoX - meteoriteOneX) < 1) { + meteoriteOneX = Math.random(5) + } + meteoriteOneY = 0 + counter = counter + 1 + if (counter == 3) { + pause = pause - 250 + } else if (counter == 8) { + pause = pause - 100 + } else if (counter == 12) { + pause = pause - 100 + } else if (counter == 20) { + pause = pause - 100 + } else if (counter == 30) { + pause = pause - 70 + } + if (counter == 40) { + pause = pause - 70 + } + for (let i2 = 0; i2 < 3; i2++) { + led.plot(meteoriteOneX, meteoriteOneY) + led.plot(meteoriteTwoX, meteoriteTwoY) + basic.pause(pause) + led.unplot(meteoriteOneX, meteoriteOneY) + led.unplot(meteoriteTwoX, meteoriteTwoY) + meteoriteOneY = meteoriteOneY + 1 + meteoriteTwoY = meteoriteTwoY + 1 + if (meteoriteTwoY == 4) { + if (meteoriteTwoX == oneX) { + for (let j2 = 0; j2 < 10; j2++) { + led.plotAll() + basic.pause(200) + basic.clearScreen() + basic.pause(200) + } + basic.showNumber(counter, 150) + basic.pause(10000) + } else if (meteoriteTwoX == twoX) { + for (let j3 = 0; j3 < 10; j3++) { + led.plotAll() + basic.pause(200) + basic.clearScreen() + basic.pause(200) + } + basic.showNumber(counter, 150) + basic.pause(10000) + } + } + } + + meteoriteTwoX = Math.random(5) + while (Math.abs(meteoriteTwoX - meteoriteOneX) < 1) { + meteoriteTwoX = Math.random(5) + } + meteoriteTwoY = 0 + counter = counter + 1 + if (counter == 3) { + pause = pause - 250 + } else if (counter == 8) { + pause = pause - 100 + } else if (counter == 12) { + pause = pause - 100 + } else if (counter == 20) { + pause = pause - 100 + } else if (counter == 30) { + pause = pause - 70 + } else if (counter == 40) { + pause = pause - 70 + } +}) diff --git a/tests/pac-man-runaway.ts b/tests/pac-man-runaway.ts new file mode 100644 index 00000000..be805bff --- /dev/null +++ b/tests/pac-man-runaway.ts @@ -0,0 +1,230 @@ +let levelTime: number +let person: Entity +let monsters: Entity[] +let totalMonsters: number +let playing: boolean +let gameSuspended: boolean +let busyPos: Point[] + +class Entity { + public x: number + public y: number + public dirX: number + public dirY: number + public hitHorizontalWall(): boolean { + return this.y == 0 && this.dirY == -1 || this.y == 4 && this.dirY == 1 + } + + public hitVerticalWall(): boolean { + return this.x == 0 && this.dirX == -1 || this.x == 4 && this.dirX == 1 + } + + public possHorizontalDir(): number { + if (this.x == 0) { + return 1 + } else if (this.x == 4) { + return - 1 + } else { + return Math.random(2) * 2 - 1 + } + } + + public possVerticalDir(): number { + if (this.y == 0) { + return 1 + } else if (this.y == 4) { + return - 1 + } else { + return Math.random(2) * 2 - 1 + } + } + + public collidesX(p2: Entity): boolean { + return this.y == p2.y && this.y + this.dirY == p2.y + p2.dirY && (this.x + this.dirX == p2.x || this.x + this.dirX == p2.x + p2.dirX || p2.x + p2.dirX == this.x) + } + + public collidesY(p2: Entity): boolean { + return this.x == p2.x && this.x + this.dirX == p2.x + p2.dirX && (this.y + this.dirY == p2.y || this.y + this.dirY == p2.y + p2.dirY || p2.y + p2.dirY == this.y) + } + + public move1() { + this.x = this.x + this.dirX + this.y = this.y + this.dirY + } + + public towardsX(p2: Entity): number { + return Math.sign(p2.x - this.x) + } + + public towardsY(p2: Entity): number { + return Math.sign(p2.y - this.y) + } + + public plot() { + led.plot(this.x, this.y) + } + + public blink() { + led.plot(this.x, this.y) + basic.pause(125) + led.unplot(this.x, this.y) + basic.pause(125) + led.plot(this.x, this.y) + } + +} + +class Point { + public x: number + public y: number +} + +initializeState() +redraw() +basic.pause(1000) +basic.forever(() => { + levelTime = levelTime + 12 + basic.pause(12) + if (!playing) { + levelTime = 0 + playing = true + } + if (levelTime >= 5000) { + gameSuspended = true + game.levelUp() + levelUp() + levelTime = 0 + resetState() + redraw() + basic.pause(1000) + gameSuspended = false + } +}) +basic.forever(() => { + if (!gameSuspended) { + logic() + redraw() + basic.pause(500) + } +}) +input.onButtonPressed(Button.A, () => { + let temp = Math.abs(person.dirX) * (-1) + person.dirX = Math.abs(person.dirY) * (-1) + person.dirY = temp +}) +input.onButtonPressed(Button.B, () => { + let temp1 = Math.abs(person.dirX) + person.dirX = Math.abs(person.dirY) + person.dirY = temp1 +}) + +function redraw() { + basic.clearScreen() + person.plot() + for (let i = 0; i < totalMonsters; i++) { + monsters[i].blink() + } +} + +function initializeState() { + person = new Entity() + playing = false + busyPos = ([] as Point[]) + let busyPos1 = new Point() + busyPos1.x = 1 + busyPos1.y = 1 + let busyPos2 = new Point() + busyPos2.x = 1 + busyPos2.y = 3 + let busyPos3 = new Point() + busyPos3.x = 3 + busyPos3.y = 1 + busyPos.push(busyPos1) + busyPos.push(busyPos2) + busyPos.push(busyPos3) + monsters = ([] as Entity[]) + addMonster() + resetState() +} + +function logic() { + if (person.hitHorizontalWall()) { + person.dirY = 0 + person.dirX = person.possHorizontalDir() + } + if (person.hitVerticalWall()) { + person.dirX = 0 + person.dirY = person.possVerticalDir() + } + let lost = false + for (let i = 0; i < totalMonsters; i++) { + let m = monsters[i] + m.dirX = m.towardsX(person) + m.dirY = m.towardsY(person) + if (m.dirX != 0 && m.dirY != 0) { + let x = Math.random(2) + if (x == 1) { + m.dirX = 0 + } else { + m.dirY = 0 + } + } + if (person.collidesX(m) || person.collidesY(m)) { + lost = true + } + } + if (!lost) { + moveAll() + } else { + loseLife() + } +} + +function loseLife() { + moveAll() + basic.pause(500) + basic.showLeds(` + . # . # . + . . # . . + . . . . . + . # # # . + # . . . # + `, 400) + basic.pause(1000) + basic.clearScreen() + game.removeLife(1) + playing = false + resetState() +} + +function moveAll() { + person.move1() + for (let i = 0; i < totalMonsters; i++) { + monsters[i].move1() + } +} + +function addMonster() { + let m = new Entity() + monsters.push(m) + totalMonsters = totalMonsters + 1 +} + +function levelUp() { + addMonster() +} + +function resetState() { + levelTime = 0 + game.setLife(5) + person.x = 4 + person.y = 4 + person.dirX = -1 + person.dirY = 0 + for (let i = 0; i < totalMonsters; i++) { + let busy = busyPos[i] + let m = monsters[i] + m.x = (busy.x + Math.random(3)) - 1 + m.y = (busy.y + Math.random(3)) - 1 + } +} From 7b352b3a58a4a0c134fb478b5a092790df7b0806 Mon Sep 17 00:00:00 2001 From: Michal Moskal Date: Fri, 22 Jul 2016 15:21:16 +0100 Subject: [PATCH 25/31] Use pre-cached TD scripts for testing --- .travis.yml | 2 +- testconv.json | 670 -------------------------------------------------- 2 files changed, 1 insertion(+), 671 deletions(-) delete mode 100644 testconv.json diff --git a/.travis.yml b/.travis.yml index af38511e..d48e1fc2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,7 +5,7 @@ script: - "node node_modules/pxt-core/built/pxt.js travis" - "(cd libs/lang-test0; node ../../node_modules/pxt-core/built/pxt.js run)" - "node node_modules/pxt-core/built/pxt.js uploaddoc" - - "(cd libs/hello; node ../../node_modules/pxt-core/built/pxt.js testconv ../../testconv.json)" + - "(cd libs/hello; node ../../node_modules/pxt-core/built/pxt.js testconv https://az851932.vo.msecnd.net/files/td-converter-tests-v0.json)" sudo: false notifications: email: diff --git a/testconv.json b/testconv.json deleted file mode 100644 index c80cba75..00000000 --- a/testconv.json +++ /dev/null @@ -1,670 +0,0 @@ -{ - "apiUrl": "https://www.microbit.co.uk/api/", - "fakeids": [ - "zzltaj", - "zzpgxf", - "rhisri", - "zztzyk" - ], - "ids": [ - "balcxr", - "bambkh", - "bbfxnw", - "bbtlly", - "bbvscl", - "bbxapr", - "bcbxtu", - "bchtnm", - "bcpnpx", - "bcredt", - "bdbwuy", - "bdddfl", - "bedihg", - "behvrp", - "bevhll", - "bezbat", - "bfrafy", - "bfvuez", - "bgqdmi", - "bguxyx", - "bhbzvc", - "bhhzvr", - "bhollk", - "biczhe", - "bieoqj", - "biwfto", - "bjayrk", - "bjcbpf", - "bjcdte", - "bjomis", - "bjqlzz", - "bkaofs", - "bkbsfh", - "bkxbji", - "blbhmr", - "blkuau", - "bllhdc", - "blougi", - "blpvxv", - "bmevma", - "bmlwtk", - "bmmayl", - "bncsjd", - "bnlfif", - "bnsfch", - "bnucdu", - "bolvvm", - "bouhxx", - "bpbvyx", - "bpmeio", - "bpqvtv", - "bptlwr", - "bqceny", - "bqgsnm", - "bqkwia", - "bqvoqy", - "bqyoyn", - "brlcdr", - "bsmmsp", - "bsncre", - "bstaqt", - "butypx", - "buuzga", - "bvnciu", - "bwbuga", - "bwhttb", - "bwkezu", - "bxswvm", - "bynkeb", - "bypanj", - "bywqzx", - "byzegt", - "bzaaya", - "bzrusu", - "bzwbps", - "dalzjm", - "damymx", - "dbdpxx", - "dcapfd", - "dceikq", - "ddikkz", - "ddjpss", - "ddtadz", - "ddxbjj", - "dfkuyn", - "dfmpxf", - "dfypdn", - "dhabye", - "dhbioa", - "dieoiu", - "diuhli", - "djchkz", - "djohvc", - "djztxc", - "dkqbyq", - "dkvxwr", - "dmbcwi", - "dmekmj", - "dmghho", - "dnmrlu", - "dnnzgd", - "dooboj", - "dosuna", - "dqgnhz", - "dqqfgv", - "dqwrsw", - "drmbxg", - "drrrty", - "dscjnc", - "dsvguv", - "dtemsf", - "dtmmmc", - "dundpx", - "dushve", - "duupgd", - "dvgzyq", - "dvnoer", - "dwcxtn", - "dwtoyp", - "dxdfbw", - "dxqdqw", - "dxroxs", - "dxvgvs", - "dycuzj", - "dyhnkt", - "dyxejk", - "dzlocb", - "dzlogl", - "fadekj", - "faffgr", - "fapznm", - "fbgdog", - "fbpnng", - "fbyrog", - "fcfoox", - "fcicvk", - "fcjlto", - "fcvwvj", - "fdjhpo", - "fdtayy", - "fdyxvx", - "fegzbd", - "felusd", - "fethzd", - "ffcqby", - "ffjeei", - "ffjuuz", - "fflxnx", - "ffpyfa", - "fhcyyx", - "fhoonu", - "fitucj", - "fitvxu", - "fjdnmb", - "fjhnpw", - "fjlzrt", - "fjwknw", - "fkgprd", - "fklpld", - "fllghh", - "flqpgb", - "fmdsdi", - "fmdzgg", - "fnimjx", - "fnjmfx", - "fnscgh", - "fomwmz", - "fpelnl", - "fpngwv", - "fpqusd", - "fpuclv", - "fpvrwv", - "fqmgsu", - "fqsbhp", - "fqsrdu", - "frlxvd", - "froxsb", - "frqqnm", - "ftcrip", - "ftrzta", - "fubsaf", - "fvgogo", - "fvgxfz", - "fvkluo", - "fvsfrv", - "fwkjkj", - "fxxsgy", - "fyazlp", - "fypaix", - "fzcoly", - "fzidej", - "hatpaz", - "haxiza", - "hbfvlb", - "hbklfv", - "hbwlkf", - "hcmpdm", - "hdnlmx", - "hetmho", - "hfklxz", - "hfkvpg", - "hfmkbt", - "hftxjx", - "hfunev", - "hgepqq", - "hivbxk", - "hjesfm", - "hklazc", - "hkncxl", - "hkrfni", - "hlenxc", - "hlhipg", - "hlhvoe", - "hlwdwo", - "hnljdp", - "howggk", - "hpjppy", - "hptebp", - "hpupwc", - "hqdpet", - "hqhclr", - "hqheal", - "hqoqjh", - "hqpuxt", - "hrnitd", - "hrooif", - "hsuiag", - "hsxmox", - "humerf", - "huqcpc", - "huydje", - "hwetsq", - "hxuwlt", - "hzcxdp", - "hzpfge", - "hzpkma", - "jaeeve", - "jcmkmq", - "jcojot", - "jcvdvp", - "jdcils", - "jddumo", - "jdsqxr", - "jerwei", - "jfwcov", - "jgdknu", - "jgjijp", - "jgofmw", - "jhjauh", - "jhrjvj", - "jhseak", - "jiyhsk", - "jiyoeq", - "jjumac", - "jkppnc", - "jkxyeh", - "jkymhg", - "jlatje", - "jlbxjm", - "jlmzps", - "jmmgyn", - "jmshop", - "jnengo", - "jnhcat", - "jnvrkr", - "jnxdok", - "jociyw", - "joryiq", - "jpbfze", - "jpcrcj", - "jrfuqz", - "jrfwyh", - "jrpbtk", - "jrwkyz", - "jrxhxe", - "jsxvju", - "jszrpp", - "jtbdng", - "jtglrx", - "jtodxy", - "julzbh", - "juqrkb", - "jvstzh", - "jwckaz", - "jwplaw", - "jwskcb", - "jxgcel", - "jxjryw", - "jxmrht", - "jxqobc", - "jzenhj", - "jzwxbr", - "jzzbqg", - "laanun", - "lagxjo", - "lamnpb", - "lapexp", - "lazmuu", - "lbeyfh", - "lbhuwc", - "lcdeuk", - "lchqfb", - "lcpmnp", - "ldgoae", - "lecrpo", - "lfpidi", - "lfrpst", - "lgsrwm", - "lhjcvy", - "licgsp", - "likrcp", - "ljauxo", - "ljkskx", - "llsepx", - "llxcdk", - "lmvoxp", - "lniybn", - "loafab", - "loehfe", - "lpnzct", - "lqwdio", - "lqxnnj", - "lracic", - "lrwotp", - "lryglt", - "lsikdy", - "ltchng", - "ltsbpa", - "lucaof", - "lvahkk", - "lvvdne", - "lwtsxc", - "lxleej", - "lxwstg", - "lxwwtd", - "lzndlk", - "lzosmg", - "lzsseg", - "naevvc", - "nawmtp", - "nbomql", - "nbuuii", - "nbwine", - "ndayhb", - "ndikwg", - "ndlikc", - "ndljim", - "ndooqj", - "ndqgow", - "nfjrxg", - "nfmunh", - "nghraa", - "nhpyof", - "nhtyzy", - "nikzhg", - "nitcfc", - "njfeff", - "njvcbs", - "njynsd", - "nkdbmy", - "nlyuwy", - "nmbxkh", - "nmdfik", - "nmuhlk", - "noftar", - "noikvz", - "novevx", - "noxyjg", - "noyovd", - "npkjbk", - "nqdtvd", - "nqgyno", - "nqxloa", - "nrjdzu", - "nsaumh", - "nsegbi", - "ntfmsx", - "ntsvek", - "nujrlc", - "nvogiv", - "nvrqzl", - "nvtfbc", - "nvymrn", - "nwowql", - "nwxlij", - "nxhnvy", - "nxpwae", - "nynwto", - "nytwlb", - "nyuakq", - "nzrgyf", - "nzrwza", - "nzzcea", - "pbsolq", - "pbtnpf", - "pcdvqu", - "pchzqo", - "pdmxpl", - "pdnntw", - "pdsghq", - "pewcsa", - "pflxxj", - "pfutwa", - "pgvoic", - "phehbm", - "phgmqm", - "phhkfi", - "phjonu", - "phvurr", - "piaksu", - "pijsrg", - "piubiw", - "pjsmac", - "pjxdoj", - "pjzfgn", - "pkmwkn", - "pkntkb", - "pkquey", - "pmxlhz", - "pnvgvr", - "pooqwk", - "ppslyh", - "ppxsux", - "prglvf", - "probjd", - "psmgrz", - "psptyd", - "psqjon", - "pughxs", - "puhetz", - "pujfoc", - "purkko", - "puthiz", - "pvjilh", - "pvqrgm", - "pvzmhz", - "pxebwk", - "pxizap", - "pxyovu", - "pymfqh", - "pzmjbx", - "pzucty", - "rannhh", - "rbnvdq", - "rccfvy", - "rceosh", - "rcobok", - "rdamey", - "rdhndz", - "rdpdll", - "rdzfjv", - "redkby", - "reqjzm", - "revjgd", - "rfihyn", - "rfzukz", - "rgtmoz", - "rheeoa", - "rheyiw", - "rilbti", - "rilexn", - "riotng", - "riqiss", - "riupfo", - "rjglqu", - "rjthvx", - "rjvjwq", - "rlporb", - "rmazpa", - "rmyvbb", - "rnkxav", - "rnvzdo", - "ropkaf", - "rozudg", - "rrvdls", - "rsdjun", - "rudelg", - "rugwft", - "rupbjr", - "rvjwiu", - "rvqkwq", - "rwdqcz", - "rwjnfq", - "rxdqqf", - "rxnztr", - "rxugmm", - "rydpvf", - "ryftuq", - "rygikf", - "ryvkkx", - "rzmnrf", - "tbehov", - "tcaulx", - "tcrfuz", - "tcvaou", - "tdfxfg", - "tdkwue", - "tfrbqz", - "tgbxuq", - "tglsyl", - "tgorrv", - "theruf", - "thhvzq", - "thncnj", - "tiircu", - "tjdpzj", - "tjliry", - "tjpwmu", - "tjqgba", - "tkhgfo", - "tkxbfr", - "tmkbao", - "tmnhhx", - "tnripk", - "tnudiw", - "tnuuwe", - "tnvnko", - "toqcgf", - "tpdiyw", - "tqeddl", - "tqhpqp", - "tqwach", - "trkitt", - "trkrrh", - "tsdmft", - "ttvzqd", - "ttxeud", - "tujsjf", - "tvbjyi", - "tvkqoe", - "twrsnj", - "txkmpg", - "txouzs", - "txszvu", - "txwbbf", - "tzqydt", - "vaszak", - "vaymbt", - "vbcdot", - "vbtmwf", - "vcijrw", - "vcoevo", - "vcrvjm", - "vcudrv", - "vczceh", - "vfcwwr", - "vftxlg", - "vfusfw", - "vgovse", - "vgvkok", - "vgxdxq", - "vhhygu", - "vioniz", - "vipnog", - "vjkwgj", - "vjmnkh", - "vkhabg", - "vkhiga", - "vkybzm", - "vlrsar", - "vmhvfa", - "vndxor", - "vodekh", - "vopucc", - "vovivd", - "vpnspf", - "vpslsg", - "vreifv", - "vrikcc", - "vrxpod", - "vsbzms", - "vslnue", - "vsrguv", - "vsyfym", - "vtfund", - "vtviqj", - "vtzfzy", - "vuwzmu", - "vwkpiw", - "vwlohb", - "vwnjqy", - "vwtwos", - "vxjfnm", - "vyewot", - "vyhvrg", - "vzmvvw", - "vzniie", - "vzrycv", - "vztdyx", - "xascqb", - "xaurjv", - "xcenyy", - "xczuut", - "xdvawd", - "xdwebc", - "xdxlsd", - "xfdrwr", - "xfrysj", - "xfytns", - "xhgnmw", - "xhjkvj", - "xjngae", - "xjuzjz", - "xkrsfl", - "xlfmnd", - "xltsru", - "xmcivt", - "xmlisq", - "xmzztb", - "xndixq", - "xnhxka", - "xnurqq", - "xolqgf", - "xoojpa", - "xoulbi", - "xoygfg", - "xpekdp", - "xpiqbj", - "xrqriw", - "xrsohj", - "xrvzyi", - "xsvwgh", - "xtrrnu", - "xtsmne", - "xuxlra", - "xvjcdf", - "xvmxti", - "xvpkiq", - "xxuosa", - "xymixn", - "xzcsqr", - "xzlzgl", - "zaidka", - "zbiznd", - "zbqfmt", - "zdfkcr", - "zdntvf", - "zdwmwu", - "zehjio", - "zelzkd", - "zewaak", - "zgozuh", - "zifrtl", - "ziqeez", - "zldufm", - "zlfusn", - "zmrcwu", - "zoyilz", - "zqlcxg", - "zqotda", - "zswztj", - "zszuqa", - "zwkhxx", - "zwpewj", - "zytfqg", - "zywows", - "zzltaj", - "zzpgxf", - "zztzyk" - ] -} From ada956064208bddc3b084debf8f7e353c14d3cb6 Mon Sep 17 00:00:00 2001 From: Michal Moskal Date: Fri, 22 Jul 2016 15:22:49 +0100 Subject: [PATCH 26/31] Bump pxt-core to 0.2.201 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 4014b12b..4776bb71 100644 --- a/package.json +++ b/package.json @@ -29,6 +29,6 @@ "typescript": "^1.8.7" }, "dependencies": { - "pxt-core": "0.2.200" + "pxt-core": "0.2.201" } } From 579eb29ce3ad2f8a3f8b3894f8dfc73ffc73f5d6 Mon Sep 17 00:00:00 2001 From: Michal Moskal Date: Fri, 22 Jul 2016 15:22:50 +0100 Subject: [PATCH 27/31] 0.2.191 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 4776bb71..55f4c8e6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "pxt-microbit", - "version": "0.2.190", + "version": "0.2.191", "description": "BBC micro:bit target for PXT", "keywords": [ "JavaScript", From e2d1b8a55c632a6f2f0df92dae5b1ae77fb23864 Mon Sep 17 00:00:00 2001 From: Michal Moskal Date: Fri, 22 Jul 2016 17:06:56 +0100 Subject: [PATCH 28/31] Run tests --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index d48e1fc2..cc2e4e19 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,6 +4,7 @@ node_js: script: - "node node_modules/pxt-core/built/pxt.js travis" - "(cd libs/lang-test0; node ../../node_modules/pxt-core/built/pxt.js run)" + - "node node_modules/pxt-core/built/pxt.js testdir tests" - "node node_modules/pxt-core/built/pxt.js uploaddoc" - "(cd libs/hello; node ../../node_modules/pxt-core/built/pxt.js testconv https://az851932.vo.msecnd.net/files/td-converter-tests-v0.json)" sudo: false From 47efcfb41f1f804e38a3b67e297caf398985f61e Mon Sep 17 00:00:00 2001 From: Michal Moskal Date: Fri, 22 Jul 2016 17:07:29 +0100 Subject: [PATCH 29/31] Bump pxt-core to 0.2.202 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 55f4c8e6..1dbf9271 100644 --- a/package.json +++ b/package.json @@ -29,6 +29,6 @@ "typescript": "^1.8.7" }, "dependencies": { - "pxt-core": "0.2.201" + "pxt-core": "0.2.202" } } From 329baaf9a4eff725e0013304cd93de10015dd007 Mon Sep 17 00:00:00 2001 From: Michal Moskal Date: Fri, 22 Jul 2016 17:07:29 +0100 Subject: [PATCH 30/31] 0.2.192 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 1dbf9271..ba429665 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "pxt-microbit", - "version": "0.2.191", + "version": "0.2.192", "description": "BBC micro:bit target for PXT", "keywords": [ "JavaScript", From d7f22bc8e6f4e6191ba52cd76a567a94c82f6e94 Mon Sep 17 00:00:00 2001 From: Peli de Halleux Date: Mon, 25 Jul 2016 11:33:14 -0700 Subject: [PATCH 31/31] fix broken link --- docs/projects.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/projects.md b/docs/projects.md index b41155ed..31c427eb 100644 --- a/docs/projects.md +++ b/docs/projects.md @@ -14,7 +14,7 @@ Here are some cool projects that you can build with your micro:bit! "imageUrl": "/static/mb/projects/a2-buttons.png" },{ "name": "Love Meter", - "url":"/projects/lover-meter", + "url":"/projects/love-meter", "imageUrl":"/static/mb/projects/a3-pins.png" },{ "name": "Rock Paper Scissors",