From 0ccddf9fe8fa5ca5ed1a15a474f2768f9f23631a Mon Sep 17 00:00:00 2001 From: Michal Moskal Date: Tue, 29 Mar 2016 17:11:17 -0700 Subject: [PATCH 01/12] Start on direct CPP migration --- libs/cpp-test/hello.ts | 6 +-- libs/cpp-test/support.cpp | 8 ++- libs/microbit/{basic.ts => basic.cpp} | 77 +++++++++++++++++++++------ libs/microbit/control.cpp | 30 +++++++++++ libs/microbit/control.ts | 47 ++++++---------- libs/microbit/kind.json | 3 +- 6 files changed, 118 insertions(+), 53 deletions(-) rename libs/microbit/{basic.ts => basic.cpp} (54%) create mode 100644 libs/microbit/control.cpp diff --git a/libs/cpp-test/hello.ts b/libs/cpp-test/hello.ts index 6f4776d1..4b8b9240 100644 --- a/libs/cpp-test/hello.ts +++ b/libs/cpp-test/hello.ts @@ -1,7 +1,3 @@ -//% shim=foo::bar -function test() { -} - basic.plotLeds(` # # . # # . . # . . @@ -10,4 +6,4 @@ basic.plotLeds(` . # # # . `); basic.pause(300); -test(); +foo.bar(); diff --git a/libs/cpp-test/support.cpp b/libs/cpp-test/support.cpp index 1474159a..89d523f9 100644 --- a/libs/cpp-test/support.cpp +++ b/libs/cpp-test/support.cpp @@ -1,6 +1,10 @@ +#include "BitVM.h" +#include "MicroBitTouchDevelop.h" + namespace foo { - GLUE void bar() + //% + void bar() { - micro_bit::scrollNumber(108108, 50); + touch_develop::micro_bit::scrollNumber(108108, 50); } } diff --git a/libs/microbit/basic.ts b/libs/microbit/basic.cpp similarity index 54% rename from libs/microbit/basic.ts rename to libs/microbit/basic.cpp index 5c94e097..f2b999a4 100644 --- a/libs/microbit/basic.ts +++ b/libs/microbit/basic.cpp @@ -1,3 +1,8 @@ +#include "BitVM.h" + + +typedef uint32_t ImageLiteral; + /** * Provides access to basic micro:bit functionality. */ @@ -10,10 +15,19 @@ namespace basic { */ //% help=basic/show-number //% weight=96 - //% shim=micro_bit::scrollNumber //% blockId=device_show_number block="show|number %number" blockGap=8 icon="\uf1ec" //% async - export function showNumber(value: number, interval: number = 150): void { } + void showNumber(int value, int interval = 150) { + if (interval < 0) + return; + + ManagedString t(value); + if (value < 0 || value >= 10) { + uBit.display.scroll(t, interval); + } else { + uBit.display.print(t.charAt(0), interval * 5); + } + } /** * Draws an image on the LED screen. @@ -22,11 +36,12 @@ namespace basic { */ //% help=basic/show-leds //% weight=95 blockGap=8 - //% shim=micro_bit::showLeds //% imageLiteral=1 async //% blockId=device_show_leds //% block="show leds" icon="\uf00a" - export function showLeds(leds: string, interval: number = 400): void { } + void showLeds(ImageLiteral leds, int interval = 400) { + uBit.display.print(MicroBitImage(getbytes(leds)), 0, 0, 0, delay); + } /** * Display text on the display, one character at a time. If the string fits on the screen (i.e. is one letter), does not scroll. @@ -35,19 +50,32 @@ namespace basic { */ //% help=basic/show-string //% weight=87 blockGap=8 - //% shim=micro_bit::scrollString async //% block="show|string %text" icon="\uf031" //% async //% blockId=device_print_message - export function showString(text: string, interval: number = 150): void { } + void showString(StringData *text, int interval = 150) { + if (interval < 0) + return; + ManagedString s(text); + int l = s.length(); + if (l == 0) { + uBit.display.clear(); + uBit.sleep(interval * 5); + } else if (l > 1) { + uBit.display.scroll(s, interval); + } else { + uBit.display.print(s.charAt(0), interval * 5); + } + } /** * Turn off all LEDs */ //% help=basic/clear-screen weight=79 - //% shim=micro_bit::clearScreen //% blockId=device_clear_display block="clear screen" icon="\uf12d" - export function clearScreen(): void { } + void clearScreen() { + uBit.display.image.clear(); + } /** * Shows a sequence of LED screens as an animation. @@ -55,29 +83,48 @@ namespace basic { * @param interval TODO */ //% help=basic/show-animation shim=micro_bit::showAnimation imageLiteral=1 async - export function showAnimation(leds: string, interval: number = 400): void { } + void showAnimation(ImageLiteral leds, int interval = 400) { + uBit.display.animate(MicroBitImage(getbytes(leds)), interval, 5, 0); + } /** * Draws an image on the LED screen. * @param leds TODO */ - //% help=basic/plot-leds weight=80 shim=micro_bit::plotLeds imageLiteral=1 - export function plotLeds(leds: string): void { } + //% help=basic/plot-leds weight=80 shim=micro_bit::plotLeds + void plotLeds(ImageLiteral leds) { + MicroBitImage i(getbytes(leds)); + uBit.display.print(i, 0, 0, 0, 0); + } + + void forever_stub(void *a) { + while (true) { + action::run((Action)a); + micro_bit::pause(20); + } + } /** * Repeats the code forever in the background. On each iteration, allows other codes to run. * @param body TODO */ //% help=basic/forever weight=55 blockGap=8 - //% blockId=device_forever block="forever" icon="\uf01e" shim=micro_bit::forever - export function forever(body: () => void): void { } + //% blockId=device_forever block="forever" icon="\uf01e" + void forever(Action a) { + if (a != 0) { + incr(a); + create_fiber(forever_stub, (void*)a); + } + } /** * Pause for the specified time in milliseconds * @param ms how long to pause for, eg: 100, 200, 500, 1000, 2000 */ //% help=basic/pause weight=54 - //% shim=micro_bit::pause async block="pause (ms) %pause" + //% async block="pause (ms) %pause" //% blockId=device_pause icon="\uf110" - export function pause(ms: number): void { } + void pause(int ms) { + uBit.sleep(ms); + } } diff --git a/libs/microbit/control.cpp b/libs/microbit/control.cpp new file mode 100644 index 00000000..167f3820 --- /dev/null +++ b/libs/microbit/control.cpp @@ -0,0 +1,30 @@ +#include "BitVM.h" + +namespace control { + void fiberDone(void *a) + { + decr((Action)a); + release_fiber(); + } + + /** + * Schedules code that run in the background. + */ + //% help=control/in-background + //% blockId="control_in_background" block="run in background" blockGap=8 + void inBackground(Action a) { + if (a != 0) { + incr(a); + create_fiber((void(*)(void*))action::run, (void*)a, fiberDone); + } + } + + /** + * Resets the BBC micro:bit. + */ + //% weight=30 async help=control/reset + //% blockId="control_reset" block="reset" + void reset() { + uBit.reset(); + } +} diff --git a/libs/microbit/control.ts b/libs/microbit/control.ts index a1d358d1..f8112492 100644 --- a/libs/microbit/control.ts +++ b/libs/microbit/control.ts @@ -192,27 +192,29 @@ enum EventBusValue { //% weight=1 color="#333333" namespace control { - /** - * Schedules code that run in the background. - */ - //% help=control/in-background shim=micro_bit::runInBackground - //% blockId="control_in_background" block="run in background" blockGap=8 - export function inBackground(body: Action): void { } /** - * Resets the BBC micro:bit. + * Returns the value of a C++ runtime constant */ - //% weight=30 shim=uBit.reset async help=control/reset - //% blockId="control_reset" block="reset" - export function reset(): void { } + //% weight=19 weight=19 blockId="control_event_source" block="%id" + export function eventSource(id: EventBusSource) : number { + return id; + } + /** + * Returns the value of a C++ runtime constant + */ + //% weight=19 weight=19 blockId="control_event_value" block="%id" + export function eventValue(id: EventBusValue) : number { + return id; + } /** * Raises an event in the event bus. - @param src ID of the MicroBit Component that generated the event e.g. MICROBIT_ID_BUTTON_A. - @param value Component specific code indicating the cause of the event. - @param mode optional definition of how the event should be processed after construction (default is CREATE_AND_QUEUE). - */ - // shim=micro_bit::busRaiseEvent + * @param src ID of the MicroBit Component that generated the event e.g. MICROBIT_ID_BUTTON_A. + * @param value Component specific code indicating the cause of the event. + * @param mode optional definition of how the event should be processed after construction (default is CREATE_AND_QUEUE). + */ + //% shim=micro_bit::busRaiseEvent //% weight=21 blockGap=12 blockId="control_raise_event" block="raise event|from source %src=control_event_source|with value %value=control_event_value" blockExternalInputs=1 export function raiseEvent(src: number, value: number, mode: EventCreationMode = EventCreationMode.CreateAndQueue): void { } @@ -223,19 +225,4 @@ namespace control { //% weight=20 blockGap=8 blockId="control_on_event" block="on event|from %src=control_event_source|with value %value=control_event_value" //% blockExternalInputs=1 blockStatement=1 export function onEvent(src: number, value: number, handler: Action): void { } - - /** - * Returns the value of a C++ runtime constant - */ - //% weight=19 shimw=TD_ID weight=19 blockId="control_event_source" block="%id" - export function eventSource(id: EventBusSource) : number { - return 0; - } - /** - * Returns the value of a C++ runtime constant - */ - //% weight=19 shimw=TD_ID weight=19 blockId="control_event_value" block="%id" - export function eventValue(id: EventBusValue) : number { - return 0; - } } diff --git a/libs/microbit/kind.json b/libs/microbit/kind.json index 6cd6bc30..6f827ac1 100644 --- a/libs/microbit/kind.json +++ b/libs/microbit/kind.json @@ -7,9 +7,10 @@ "core.d.ts", "mbit.ts", "images.ts", - "basic.ts", + "basic.cpp", "input.ts", "control.ts", + "control.cpp", "game.ts", "led.ts", "music.ts", From 45aa7809344427e2902327da1d5bc8c37316a629 Mon Sep 17 00:00:00 2001 From: Michal Moskal Date: Tue, 29 Mar 2016 17:56:01 -0700 Subject: [PATCH 02/12] C++ fixes --- libs/cpp-test/hello.ts | 3 ++- libs/microbit/basic.cpp | 6 ++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/libs/cpp-test/hello.ts b/libs/cpp-test/hello.ts index 4b8b9240..2153f128 100644 --- a/libs/cpp-test/hello.ts +++ b/libs/cpp-test/hello.ts @@ -6,4 +6,5 @@ basic.plotLeds(` . # # # . `); basic.pause(300); -foo.bar(); +basic.showString("Hello"); +// foo.bar(); diff --git a/libs/microbit/basic.cpp b/libs/microbit/basic.cpp index f2b999a4..719465a8 100644 --- a/libs/microbit/basic.cpp +++ b/libs/microbit/basic.cpp @@ -1,8 +1,6 @@ #include "BitVM.h" -typedef uint32_t ImageLiteral; - /** * Provides access to basic micro:bit functionality. */ @@ -40,7 +38,7 @@ namespace basic { //% blockId=device_show_leds //% block="show leds" icon="\uf00a" void showLeds(ImageLiteral leds, int interval = 400) { - uBit.display.print(MicroBitImage(getbytes(leds)), 0, 0, 0, delay); + uBit.display.print(MicroBitImage(getbytes(leds)), 0, 0, 0, interval); } /** @@ -100,7 +98,7 @@ namespace basic { void forever_stub(void *a) { while (true) { action::run((Action)a); - micro_bit::pause(20); + uBit.sleep(20); } } From 61dd0075b2a3c9817debab95c219c2a088027e45 Mon Sep 17 00:00:00 2001 From: Michal Moskal Date: Tue, 29 Mar 2016 19:13:46 -0700 Subject: [PATCH 03/12] Fix build --- libs/microbit/control.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/microbit/control.ts b/libs/microbit/control.ts index f8112492..6017ad6f 100644 --- a/libs/microbit/control.ts +++ b/libs/microbit/control.ts @@ -214,7 +214,7 @@ namespace control { * @param value Component specific code indicating the cause of the event. * @param mode optional definition of how the event should be processed after construction (default is CREATE_AND_QUEUE). */ - //% shim=micro_bit::busRaiseEvent + // shim=micro_bit::busRaiseEvent //% weight=21 blockGap=12 blockId="control_raise_event" block="raise event|from source %src=control_event_source|with value %value=control_event_value" blockExternalInputs=1 export function raiseEvent(src: number, value: number, mode: EventCreationMode = EventCreationMode.CreateAndQueue): void { } From 1e77491b16030b8c01d909711caf804a6b2186b9 Mon Sep 17 00:00:00 2001 From: Michael Elliot Braun Date: Wed, 30 Mar 2016 15:11:05 -0700 Subject: [PATCH 04/12] updated lessons --- .../js => }/lessons/catch-the-egg-game.md | 42 ----- .../lessons/catch-the-egg-game/challenges.md | 29 ++-- .../catch-the-egg-game/quiz-answers.md | 27 ++-- .../lessons/catch-the-egg-game/quiz.md | 6 +- docs/lessons/compass/quiz-answers.md | 3 + docs/lessons/counter/quiz-answers.md | 12 +- docs/lessons/counter/quiz.md | 12 +- docs/lessons/digi-yoyo/quiz-answers.md | 5 +- docs/lessons/magic-logo/activity.md | 3 +- docs/lessons/magic-logo/challenges.md | 6 +- docs/lessons/magic-logo/quiz-answers.md | 2 +- .../rotation-animation/quiz-answers.md | 42 +++-- docs/lessons/rotation-animation/quiz.md | 26 ++- docs/lessons/smiley/activity.md | 4 +- docs/lessons/smiley/challenges.md | 14 +- docs/lessons/snowflake-fall/activity.md | 2 +- docs/lessons/snowflake-fall/challenges.md | 58 +++++-- docs/lessons/snowflake-fall/quiz-answers.md | 39 ++++- docs/lessons/spinner/activity.md | 84 +++++++++- docs/lessons/spinner/challenges.md | 151 +++++++++++++++++- docs/lessons/zoomer/quiz-answers.md | 6 +- docs/reference/js/lessons/catch-the-egg.md | 8 - 22 files changed, 422 insertions(+), 159 deletions(-) rename docs/{reference/js => }/lessons/catch-the-egg-game.md (60%) rename docs/{reference/js => }/lessons/catch-the-egg-game/challenges.md (87%) rename docs/{reference/js => }/lessons/catch-the-egg-game/quiz-answers.md (75%) rename docs/{reference/js => }/lessons/catch-the-egg-game/quiz.md (85%) delete mode 100644 docs/reference/js/lessons/catch-the-egg.md diff --git a/docs/reference/js/lessons/catch-the-egg-game.md b/docs/lessons/catch-the-egg-game.md similarity index 60% rename from docs/reference/js/lessons/catch-the-egg-game.md rename to docs/lessons/catch-the-egg-game.md index fb7a00e5..c0162f4b 100644 --- a/docs/reference/js/lessons/catch-the-egg-game.md +++ b/docs/lessons/catch-the-egg-game.md @@ -10,15 +10,10 @@ Variables ## Quick Links -* [tutorial](/microbit/lessons/catch-the-egg-game/tutorial) * [quiz](/microbit/lessons/catch-the-egg-game/quiz) * [quiz answers](/microbit/lessons/catch-the-egg-game/quiz-answers) * [challenges](/microbit/lessons/catch-the-egg-game/challenges) -## Class - -Year 7 - ## Prior learning/place of lesson in scheme of work Learn how to create a catch the egg game game with **plot**, `led->plot` , **unplot**, `led->unplot`, and **acceleration** `input -> acceleration` to turn on and off LED lights on the LED screen. We will be learning how to create a catch the egg game app using global variables, forever loop, local variable, input acceleration, math min, math max, math random, math mod, if (conditionals), game library as well as simple commands, such as led plot, led unplot, and pause. @@ -52,40 +47,3 @@ Learn how to create a catch the egg game game with **plot**, `led->plot` , **unp * learn how to return the modulus * learn how to show a number of the BBC micro:bit screen * learn how to pause your code for the specified number of milliseconds - -## Progression Pathways / Computational Thinking Framework - -#### Algorithms - -* Designs solutions (algorithms) that use repetition and two-way selection, ie if, then and else.(AL) -* Uses logical reasoning to predict outputs, showing an awareness of inputs (AL) -* Recognises that different solutions exist for the same problem (AL) (AB) Understands that iteration is the repetition of a process such as a loop (AL) -* Represents solutions using a structured notation (AL) (AB) - -#### Programming & Development - -* Creates programs that implement algorithms to achieve given goals (AL) -* Declares and assigns variables(AB) -* Understands the difference between, and appropriately uses if and if, then and else statements(AL) -* Uses a variable and relational operators within a loop to govern termination (AL) (GE) -* Has practical experience of a high-level textual language, including using standard libraries when programming(AB) (AL) -* Uses a range of operators and expressions e.g. Boolean, and applies them in the context of program control. (AL) -* Selects the appropriate data types(AL) (AB - -Computational Thinking Concept: AB = Abstraction; DE = Decomposition; AL = Algorithmic Thinking; EV = Evaluation; GE = Generalisation - -## Activity - -* time: 20 min. -* [tutorial](/microbit/lessons/catch-the-egg-game/tutorial) -* [quiz](/microbit/lessons/catch-the-egg-game/quiz) - -## Extended Activity - -* time: 20 min. -* [challenges](/microbit/lessons/catch-the-egg-game/challenges) - -## Homework - -* Extended Activity: [challenges](/microbit/lessons/catch-the-egg-game/challenges) - diff --git a/docs/reference/js/lessons/catch-the-egg-game/challenges.md b/docs/lessons/catch-the-egg-game/challenges.md similarity index 87% rename from docs/reference/js/lessons/catch-the-egg-game/challenges.md rename to docs/lessons/catch-the-egg-game/challenges.md index 29aa3fba..72fc8b7a 100644 --- a/docs/reference/js/lessons/catch-the-egg-game/challenges.md +++ b/docs/lessons/catch-the-egg-game/challenges.md @@ -4,13 +4,9 @@ Coding challenges for catch the egg game. ## Before we get started -Complete the following guided tutorial: +Your starting code should look like this: -* [tutorial](/microbit/lessons/catch-the-egg-game/tutorial) - -At the end of the tutorial, click `keep editing`. Your code should look like this: - -``` +```blocks let basketX = 2 let eggX = 2 let eggY = 0 @@ -20,7 +16,7 @@ basic.forever(() => { eggY = eggY + 1 led.plot(eggX, eggY) basic.pause(300) - let accX = input.acceleration("x") + let accX = input.acceleration(Dimension.X) basketX = 2 + Math.min(2, Math.max(-2, accX / 200)) led.plot(basketX, 4) if (eggY > 4) { @@ -49,7 +45,7 @@ Now that we know when an egg is caught, we can keep track of the score! We need ### ~ -``` +```blocks let basketX1 = 2 let eggX1 = 2 let eggY1 = 0 @@ -59,8 +55,8 @@ basic.forever(() => { eggY1 = eggY1 + 1 led.plot(eggX1, eggY1) basic.pause(300) - let accX1 = input.acceleration("x") - basketX1 = 2 + Math.min(2, Math.max(-2, accX1 / 200)) + let accX = input.acceleration(Dimension.X) + basketX1 = 2 + Math.min(2, Math.max(-2, accX / 200)) led.plot(basketX1, 4) if (eggY1 > 4) { eggY1 = -1 @@ -87,7 +83,7 @@ Catching eggs gets easier with practice so let's make the eggs fall faster every ### ~ -``` +```blocks let basketX2 = 2 let eggX2 = 2 let eggY2 = 0 @@ -98,7 +94,7 @@ basic.forever(() => { eggY2 = eggY2 + 1 led.plot(eggX2, eggY2) basic.pause(300) - let accX2 = input.acceleration("x") + let accX2 = input.acceleration(Dimension.X) basketX2 = 2 + Math.min(2, Math.max(-2, accX2 / 200)) led.plot(basketX2, 4) if (eggY2 > 4) { @@ -108,7 +104,7 @@ basic.forever(() => { if (eggY2 == 4) { if (basketX2 == eggX2) { game.addScore(1) - if (math.mod(game.score(), 5) == 0) { + if (game.score() %5 == 0) { } } else { game.removeLife(1) @@ -126,7 +122,7 @@ basic.forever(() => { Let's make the egg fall faster by decreasing the amount of time it pauses in each position by decreasing **falling pause** by `25` every 5 catches. Now, instead of pausing for 300 milliseconds we can pause for the value of **falling pause**. -``` +```blocks let basketX3 = 2 let eggX3 = 2 let eggY3 = 0 @@ -137,7 +133,7 @@ basic.forever(() => { eggY3 = eggY3 + 1 led.plot(eggX3, eggY3) basic.pause(300) - let accX3 = input.acceleration("x") + let accX3 = input.acceleration(Dimension.X) basketX3 = 2 + Math.min(2, Math.max(-2, accX3 / 200)) led.plot(basketX3, 4) if (eggY3 > 4) { @@ -147,7 +143,7 @@ basic.forever(() => { if (eggY3 == 4) { if (basketX3 == eggX3) { game.addScore(1) - if (math.mod(game.score(), 5) == 0) { + if (game.score()% 5 == 0) { fallingPause1 = fallingPause1 - 25 // *** } } else { @@ -156,6 +152,7 @@ basic.forever(() => { } basic.pause(fallingPause1) // *** }) + ``` Fantastic! Your game is now ready to show off. diff --git a/docs/reference/js/lessons/catch-the-egg-game/quiz-answers.md b/docs/lessons/catch-the-egg-game/quiz-answers.md similarity index 75% rename from docs/reference/js/lessons/catch-the-egg-game/quiz-answers.md rename to docs/lessons/catch-the-egg-game/quiz-answers.md index 38da8ba0..7af3169d 100644 --- a/docs/reference/js/lessons/catch-the-egg-game/quiz-answers.md +++ b/docs/lessons/catch-the-egg-game/quiz-answers.md @@ -22,7 +22,10 @@ Answer the questions while completing the tutorial. Pay attention to the dialogu
-``` +```blocks +let basketX = 2 +let eggX = 2 +let eggY = 0 led.plot(eggX, eggY) led.plot(basketX, 4) ``` @@ -31,28 +34,22 @@ led.plot(basketX, 4)
-``` +```blocks +let basketX = 2 +let eggX = 2 +let eggY = 0 led.unplot(eggX, eggY) eggY = eggY + 1 led.plot(eggX, eggY) ``` -## 4. Write the code that calculates 'basket x' given the variable 'acc x'. +## 4. . Write the code that resets the egg after it has fallen past the bottom of the BBC micro:bit.
-``` -let accX = input.acceleration("x") -basketX = 2 + Math.min(2, Math.max(-2, accX / 200)) -``` - -Note: the first line of code in this answer is optional. - -## 5. Write the code that resets the egg after it has fallen past the bottom of the BBC micro:bit. - -
- -``` +```blocks +let eggX = 2 +let eggY = 0 if (eggY > 4) { eggY = -1 eggX = Math.random(5) diff --git a/docs/reference/js/lessons/catch-the-egg-game/quiz.md b/docs/lessons/catch-the-egg-game/quiz.md similarity index 85% rename from docs/reference/js/lessons/catch-the-egg-game/quiz.md rename to docs/lessons/catch-the-egg-game/quiz.md index 28125f26..339c4fbf 100644 --- a/docs/reference/js/lessons/catch-the-egg-game/quiz.md +++ b/docs/lessons/catch-the-egg-game/quiz.md @@ -24,11 +24,7 @@ Answer the questions while completing the tutorial. Pay attention to the dialogu
-## 4. Write the code that calculates 'basket x' given the variable 'acc x'. - -
- -## 5. Write the code that resets the egg after it has fallen past the bottom of the BBC micro:bit. +## 4. Write the code that resets the egg after it has fallen past the bottom of the BBC micro:bit.
diff --git a/docs/lessons/compass/quiz-answers.md b/docs/lessons/compass/quiz-answers.md index 1bfa3303..489251e1 100644 --- a/docs/lessons/compass/quiz-answers.md +++ b/docs/lessons/compass/quiz-answers.md @@ -26,6 +26,7 @@ let degrees = input.compassHeading() ```blocks +let degrees = input.compassHeading() if (degrees < 45) { basic.showString("N", 150) } @@ -35,6 +36,7 @@ if (degrees < 45) { ```blocks +let degrees = input.compassHeading() if (degrees < 135) { basic.showString("E", 150) } @@ -44,6 +46,7 @@ if (degrees < 135) { ```blocks +let degrees = input.compassHeading() if (degrees < 225) { basic.showString("S", 150) } diff --git a/docs/lessons/counter/quiz-answers.md b/docs/lessons/counter/quiz-answers.md index 154cd9bf..2f494d36 100644 --- a/docs/lessons/counter/quiz-answers.md +++ b/docs/lessons/counter/quiz-answers.md @@ -23,10 +23,10 @@ We create a **variable**, `count` to keep track of the current count. The number ## 3. Draw which LEDs are ON after running this code and pressing button "A" once. Explain you chose to draw that number ```blocks -let count_ = 0 +let counts = 0 input.onButtonPressed(Button.A, () => { - count_ = count_ + 1 - basic.showNumber(count, 150) + counts = counts + 1 + basic.showNumber(counts, 150) }) ``` @@ -39,10 +39,10 @@ We are only pressing on button pressed once. So the number to display on the mic ## 4. Draw which LEDs are ON after running this code and pressing button "A" three times. Explain you chose to draw that number ```blocks -count_ = 0 +let counting= 0 input.onButtonPressed(Button.A, () => { - count_ = count_ + 1 - basic.showNumber(count_, 100) + counting = counting + 1 + basic.showNumber(counting, 100) }) ``` diff --git a/docs/lessons/counter/quiz.md b/docs/lessons/counter/quiz.md index 2fb8f3e6..bd8f9d4b 100644 --- a/docs/lessons/counter/quiz.md +++ b/docs/lessons/counter/quiz.md @@ -27,10 +27,10 @@ let count = 0 ## 3. Draw which LEDs are ON after running this code and pressing button "A" once. Explain you chose to draw that number ```blocks -let count_ = 0 +let counts = 0 input.onButtonPressed(Button.A, () => { - count_ = count_ + 1 - basic.showNumber(count_, 100) + counts = counts + 1 + basic.showNumber(counts, 150) }) ``` @@ -41,10 +41,10 @@ input.onButtonPressed(Button.A, () => { ## 4. Draw which LEDs are ON after running this code and pressing button "A" three times. Explain you chose to draw that number ```blocks -count_ = 0 +let counting= 0 input.onButtonPressed(Button.A, () => { - count_ = count_ + 1 - basic.showNumber(count_, 100) + counting = counting + 1 + basic.showNumber(counting, 100) }) ``` diff --git a/docs/lessons/digi-yoyo/quiz-answers.md b/docs/lessons/digi-yoyo/quiz-answers.md index 7df40bf9..4a281b20 100644 --- a/docs/lessons/digi-yoyo/quiz-answers.md +++ b/docs/lessons/digi-yoyo/quiz-answers.md @@ -16,7 +16,7 @@ A loop that repeats code while a condition is true.
-``` +```blocks let count = 0 ``` @@ -26,7 +26,8 @@ let count = 0
-``` +```blocks +let count = 0 while (count < 5) { count = count + 1 } diff --git a/docs/lessons/magic-logo/activity.md b/docs/lessons/magic-logo/activity.md index 96f0f6ec..603e4f88 100644 --- a/docs/lessons/magic-logo/activity.md +++ b/docs/lessons/magic-logo/activity.md @@ -22,7 +22,7 @@ When the micro:bit goes logo up, the code nested under the `on logo up` function ```blocks input.onLogoUp(() => { - basic.showAnimation(` + basic.showLeds(` . . # . . . # # # . # # # # # @@ -31,6 +31,7 @@ input.onLogoUp(() => { `) }) + ``` Run your code and try to turn around the micro:bit to see the **logo up** event in action! diff --git a/docs/lessons/magic-logo/challenges.md b/docs/lessons/magic-logo/challenges.md index 864ac13a..6ce04b0e 100644 --- a/docs/lessons/magic-logo/challenges.md +++ b/docs/lessons/magic-logo/challenges.md @@ -8,7 +8,7 @@ Complete the [magic logo](/microbit/lessons/magic-logo/activity) activity and yo ```blocks input.onLogoUp(() => { - basic.showAnimation(` + basic.showLeds(` . . # . . . # # # . # # # # # @@ -28,7 +28,7 @@ How about when the logo is down? We should display an arrow pointing downward! ```blocks input.onLogoUp(() => { - basic.showAnimation(` + basic.showLeds(` . . # . . . # # # . # # # # # @@ -37,7 +37,7 @@ input.onLogoUp(() => { `) }) input.onLogoDown(() => { - basic.showAnimation(` + basic.showLeds(` . . # . . . . # . . # # # # # diff --git a/docs/lessons/magic-logo/quiz-answers.md b/docs/lessons/magic-logo/quiz-answers.md index 4aac9fa7..0a087f5e 100644 --- a/docs/lessons/magic-logo/quiz-answers.md +++ b/docs/lessons/magic-logo/quiz-answers.md @@ -44,7 +44,7 @@ input.onLogoUp(() => { ```blocks input.onLogoDown(() => { - basic.plotImage(` + basic.showLeds(` . . # . . . . # . . # # # # # diff --git a/docs/lessons/rotation-animation/quiz-answers.md b/docs/lessons/rotation-animation/quiz-answers.md index 51fc2f41..38d86043 100644 --- a/docs/lessons/rotation-animation/quiz-answers.md +++ b/docs/lessons/rotation-animation/quiz-answers.md @@ -4,34 +4,50 @@ Learn how to create a rotating image with a while loop. #image #loop #while #do This is the answer key for the [rotation animation quiz](/microbit/lessons/rotation-animation/quiz). -## 1. What is a "global variable"? +## 1. What is a " variable"? -Answers may vary. A global variable is a place where you can store data so that you can use it later in your code. +Answers may vary. A variable is a place where you can store data so that you can use it later in your code. -## 2. Consider the following directions +## 2. Write the code to create a ** variable** called `foo` that stores a boolean and initialize it to **false**. -Write the code to create a **global variable** called `foo` that stores a boolean and initialize it to **false**. -``` -rotating = true + +```blocks +let rotating = true; ``` -## 3. Consider the following code +## 3. Explain what this line of code does. -``` +```blocks +let rotating = true; while (rotating) { + basic.showLeds(` + . . . . . + . . . . . + . . # . . + . . . . . + . . . . . + `) + basic.showLeds(` + . . . . . + . . . . . + . . . . . + . . . . . + . . . . . + `) } + ``` -Explain what this line of code does. +
-It is a **while** loop that will be executed only if the **global variable** called `rotating` is **true**. +It is a **while** loop that will be executed only if the ** variable** called `rotating` is **true**. -## 4. Consider the following code +## 4. If the rectangle below represents the BBC micro:bit, shade the areas that will be displayed. Explain why that particular area is shaded. -``` +```blocks basic.showAnimation(` # . . . . . . # . . . . . . # . . . . . . # . . . . . # . . . . . # . . . . . . @@ -41,7 +57,7 @@ basic.showAnimation(` `, 400) ``` -If the rectangle below represents the BBC micro:bit, shade the areas that will be displayed. Explain why that particular area is shaded. + ![](/static/mb/lessons/rotation-animation-0.png) diff --git a/docs/lessons/rotation-animation/quiz.md b/docs/lessons/rotation-animation/quiz.md index 35f47452..b9505fab 100644 --- a/docs/lessons/rotation-animation/quiz.md +++ b/docs/lessons/rotation-animation/quiz.md @@ -10,26 +10,42 @@ Use this activity document to guide your work in the [rotation animation tutoria Answer the questions while completing the tutorial. Pay attention to the dialogues! -## 1. What is a "global variable"? +## 1. What is a " variable"?
-## 2. Write the code to create a global variable called foo that stores a boolean and initialize it to false. +## 2. Write the code to create a variable called foo that stores a boolean and initialize it to false.
-## 3. Explain why you use a while loop with a global variable +## 3. Explain why you use a while loop with a variable -``` +```blocks +let rotating = true; while (rotating) { + basic.showLeds(` + . . . . . + . . . . . + . . # . . + . . . . . + . . . . . + `) + basic.showLeds(` + . . . . . + . . . . . + . . . . . + . . . . . + . . . . . + `) } + ```
## 4. Draw the areas on the micro:bits to illustrate the code below. Explain why you chose to draw in those areas. -``` +```blocks basic.showAnimation(` # . . . . . . # . . . . . . # . . . . . . # . . . . . # . . . . . # . . . . . . diff --git a/docs/lessons/smiley/activity.md b/docs/lessons/smiley/activity.md index 2777881c..87b7b1a9 100644 --- a/docs/lessons/smiley/activity.md +++ b/docs/lessons/smiley/activity.md @@ -13,14 +13,14 @@ Welcome! This tutorial will help you make a smiley face blink. Let's get started Create an animation with an image displaying a smiley face and the next image with no LEDs lit up. This will make it look like the smiley face is blinking as the display switches between images. ```blocks -basic.showAnimation(` +basic.showLeds(` . # . # . . # . # . . . . . . # . . . # . # # # . `) -basic.showAnimation(` +basic.showLeds(` . . . . . . . . . . . . . . . diff --git a/docs/lessons/smiley/challenges.md b/docs/lessons/smiley/challenges.md index f875843f..171de366 100644 --- a/docs/lessons/smiley/challenges.md +++ b/docs/lessons/smiley/challenges.md @@ -8,14 +8,14 @@ Complete the [smiley activity](/microbit/lessons/smiley/activity) and your code ```blocks -basic.showAnimation(` +basic.showLeds(` . # . # . . # . # . . . . . . # . . . # . # # # . `) -basic.showAnimation(` +basic.showLeds(` . . . . . . . . . . . . . . . @@ -33,14 +33,14 @@ Let's make add code that will run when button A is pressed! ```blocks -basic.showAnimation(` +basic.showLeds(` . # . # . . # . # . . . . . . # . . . # . # # # . `) -basic.showAnimation(` +basic.showLeds(` . . . . . . . . . . . . . . . @@ -59,14 +59,14 @@ input.onButtonPressed(Button.A, () => { Now, we want to show a frowny face when this button is pressed. Let's show the LEDs. ```blocks -basic.showAnimation(` +basic.showLeds(` . # . # . . # . # . . . . . . # . . . # . # # # . `) -basic.showAnimation(` +basic.showLeds(` . . . . . . . . . . . . . . . @@ -74,7 +74,7 @@ basic.showAnimation(` . . . . . `) input.onButtonPressed(Button.A, () => { - basic.showAnimation(` + basic.showLeds(` . # . # . . # . # . . . . . . diff --git a/docs/lessons/snowflake-fall/activity.md b/docs/lessons/snowflake-fall/activity.md index f9065309..04d6d8d9 100644 --- a/docs/lessons/snowflake-fall/activity.md +++ b/docs/lessons/snowflake-fall/activity.md @@ -51,7 +51,7 @@ basic.forever(() => { . . # . . `) }) -```blocks +``` Run your code in the simulator or download it to your BBC micro:bit to see what happens! diff --git a/docs/lessons/snowflake-fall/challenges.md b/docs/lessons/snowflake-fall/challenges.md index 26f80a46..00d057cb 100644 --- a/docs/lessons/snowflake-fall/challenges.md +++ b/docs/lessons/snowflake-fall/challenges.md @@ -6,25 +6,59 @@ Coding challenges for snowflake fall. Complete the [snowflake fall](/microbit/lessons/snowflake-fall/activity) activity and your code will look like this: -![](/static/mb/blocks/lessons/snowflake-fall-1.jpg) +```blocks +basic.forever(() => { + basic.showLeds(` + . . . . . + . . # . . + . # # # . + . . # . . + . . . . . + `) + basic.showLeds(` + . . # . . + . # . # . + # . . . # + . # . # . + . . # . . + `) +}) +``` ### Challenge 1 ### @video td/videos/snowflake-fall-1 -Let's begin creating our falling effect by adding another snowflake with `show LEDs` that displays a different snowflake pattern after the first one. We need 2 frames in the new animation that display both the first and the second snowflake images. - -![](/static/mb/blocks/lessons/snowflake-fall-2.jpg) - -* Run your program to see the cool animation. - -### Challenge 2 - -### @video td/videos/snowflake-fall-2 - To finalize our snowflake fall, let's add a different snowflake pattern. -![](/static/mb/blocks/lessons/snowflake-fall-3.jpg) +```blocks + +basic.forever(() => { + basic.showLeds(` + . . . . . + . . # . . + . # # # . + . . # . . + . . . . . + `) + basic.showLeds(` + . . # . . + . # . # . + # . . . # + . # . # . + . . # . . + `) + basic.showLeds(` + . # . # . + # # # # # + . # . # . + # # # # # + . # . # . + `) +}) + +``` + * Run your program and see if it works. diff --git a/docs/lessons/snowflake-fall/quiz-answers.md b/docs/lessons/snowflake-fall/quiz-answers.md index 3cb3855e..e1c82bd6 100644 --- a/docs/lessons/snowflake-fall/quiz-answers.md +++ b/docs/lessons/snowflake-fall/quiz-answers.md @@ -28,7 +28,24 @@ basic.forever(() => { ![](/static/mb/lessons/snowflake-fall-0.png) -![](/static/mb/blocks/lessons/snowflake-fall-5.png) +```blocks +basic.forever(() => { + basic.showLeds(` + . . . . . + . . # . . + . # # # . + . . # . . + . . . . . + `); + basic.showLeds(` + . . . . . + . . . . . + . . . . . + . . . . . + . . . . . + `) +}); +``` ## 4. Write the code for a forever loop and show LEDS for these images! @@ -36,5 +53,21 @@ basic.forever(() => { ![](/static/mb/lessons/snowflake-fall-2.png) -![](/static/mb/blocks/lessons/snowflake-fall-6.png) - +```blocks +basic.forever(() => { + basic.showLeds(` + . . . . . + . . # . . + . # # # . + . . # . . + . . . . . + `); + basic.showLeds(` + # # # # # + # # . # # + # . # . # + # # . # # + # # # # # + `) +}); +``` \ No newline at end of file diff --git a/docs/lessons/spinner/activity.md b/docs/lessons/spinner/activity.md index f1f9aaec..6cd85a86 100644 --- a/docs/lessons/spinner/activity.md +++ b/docs/lessons/spinner/activity.md @@ -12,19 +12,95 @@ Welcome! This guided tutorial will teach how to program a script that randomly p Let's begin by adding an `on shake` condition to know when the micro:bit is shaken. -![](/static/mb/blocks/lessons/spinner-0.jpg) +```blocks +input.onGesture(Gesture.Shake, () => { + +}) +``` Now let's randomly generate a number from 0 to 3 so that we can randomly display an arrow in a given direction. -![](/static/mb/blocks/lessons/spinner-1.jpg) +```blocks +input.onGesture(Gesture.Shake, () => { + let randomArrow = Math.random(4) + if (randomArrow = 3) { + basic.showLeds(` + . . # . . + . # # # . + # # # # # + . . # . . + . . # . . + `) + } +}) +``` + + Now let's handle each of the cases by displaying the appropriate arrow. (Let's display an up arrow if `random arrow` is 0. -![](/static/mb/blocks/lessons/spinner-2.jpg) +```blocks +input.onGesture(Gesture.Shake, () => { + let randomArrow = Math.random(4) + if (randomArrow = 3) { + basic.showLeds(` + . . # . . + . # # # . + # # # # # + . . # . . + . . # . . + `) + } + if (randomArrow = 2) { + basic.showLeds(` + . . # . . + . . # . . + # # # # # + . # # # . + . . # . . + `) + } +}) +``` + Now let's handle the rest of the cases for `random arrow`. -![](/static/mb/blocks/lessons/spinner-3.jpg) + +```blocks +input.onGesture(Gesture.Shake, () => { + let randomArrow = Math.random(4) + if (randomArrow = 3) { + basic.showLeds(` + . . # . . + . # # # . + # # # # # + . . # . . + . . # . . + `) + } + if (randomArrow = 2) { + basic.showLeds(` + . . # . . + . . # . . + # # # # # + . # # # . + . . # . . + `) + } + if (randomArrow = 1) { + basic.showLeds(` + . . # . . + . # # . . + # # # # # + . # # . . + . . # . . + `) + + } +}) +``` + ### ~avatar avatar diff --git a/docs/lessons/spinner/challenges.md b/docs/lessons/spinner/challenges.md index 6b468fc7..81aee108 100644 --- a/docs/lessons/spinner/challenges.md +++ b/docs/lessons/spinner/challenges.md @@ -6,21 +6,164 @@ Create an arrow that randomly points to a player. Complete the following [guided tutorial](/microbit/lessons/spinner/activity), your code should look like this: -![](/static/mb/blocks/lessons/spinner-3.jpg) +```blocks +input.onGesture(Gesture.Shake, () => { + let randomArrow = Math.random(4) + if (randomArrow = 3) { + basic.showLeds(` + . . # . . + . # # # . + # # # # # + . . # . . + . . # . . + `) + } + if (randomArrow = 2) { + basic.showLeds(` + . . # . . + . . # . . + # # # # # + . # # # . + . . # . . + `) + } + if (randomArrow = 1) { + basic.showLeds(` + . . # . . + . # # . . + # # # # # + . # # . . + . . # . . + `) + + } +}) +``` ### Challenge 1 Modify the random number generator so that it can include new arrows we will create in the next challenge. -![](/static/mb/blocks/lessons/spinner-4.jpg) +```blocks +input.onGesture(Gesture.Shake, () => { + let randomArrow = Math.random(8) + if (randomArrow = 3) { + basic.showLeds(` + . . # . . + . # # # . + # # # # # + . . # . . + . . # . . + `) + } + if (randomArrow = 2) { + basic.showLeds(` + . . # . . + . . # . . + # # # # # + . # # # . + . . # . . + `) + } + if (randomArrow = 1) { + basic.showLeds(` + . . # . . + . # # . . + # # # # # + . # # . . + . . # . . + `) + + } +}) +``` + + * Do **not** run the code yet because it will not work until you have conditions for every random number. ### Challenge 2 -Let's add four more arrows that point diagonally. +Let's add more arrows that point diagonally. + + +```blocks +input.onGesture(Gesture.Shake, () => { + let randomArrow = Math.random(8) + if (randomArrow = 7) { + basic.showLeds(` + . . # . . + . # # # . + # # # # # + . . # . . + . . # . . + `) + } + if (randomArrow = 6) { + basic.showLeds(` + . . # . . + . . # . . + # # # # # + . # # # . + . . # . . + `) + } + if (randomArrow = 5) { + basic.showLeds(` + . . # . . + . # # . . + # # # # # + . # # . . + . . # . . + `) + + } + if (randomArrow = 4) { + basic.showLeds(` + . . # . . + . . . # . + # # # # # + . . . # . + . . # . . + `) + + } + + if (randomArrow = 3) { + basic.showLeds(` + # # # # # + # # # # . + # # # # . + # . . # . + . . . . # + `) + + } + if (randomArrow = 2) { + basic.showLeds(` + # # # # # + # # # # # + . . # # # + . # . # # + # . . . # + `) + + } + if (randomArrow = 1) { + basic.showLeds(` + # . . . # + # # . # . + # # # . . + # # # # . + # # # # # + `) + + } + +}) + +``` -![](/static/mb/blocks/lessons/spinner-5.jpg) * Run your code to see if it works as expected diff --git a/docs/lessons/zoomer/quiz-answers.md b/docs/lessons/zoomer/quiz-answers.md index fb6995ac..d9e24e1c 100644 --- a/docs/lessons/zoomer/quiz-answers.md +++ b/docs/lessons/zoomer/quiz-answers.md @@ -14,7 +14,7 @@ Write the line of code to measure the acceleration and then store in it a variab
-``` +```blocks let accX_ = input.acceleration("x") ``` @@ -26,9 +26,9 @@ After storing the acceleration in a variable, write the code to show acceleratio
-``` +```blocks let accX = input.acceleration("x") -basic.showNumber(accX_, 150) +basic.showNumber(accX, 150) ``` Note: make sure the same variable name ("acc x" in this case) is the same in both lines of code.. diff --git a/docs/reference/js/lessons/catch-the-egg.md b/docs/reference/js/lessons/catch-the-egg.md deleted file mode 100644 index 6b0a9d84..00000000 --- a/docs/reference/js/lessons/catch-the-egg.md +++ /dev/null @@ -1,8 +0,0 @@ -# catch the egg - -Programming a game of 'catch the egg' using the accelerometer in Touch Develop #docs #functions #var - -Programming a game of 'catch the egg' using the accelerometer - -* [tutorial](/microbit/lessons/catch-the-egg-game/tutorial) -* [challenges](/microbit/lessons/catch-the-egg/challenges) From b76b32a825416ccaf12c3d2dc4a669f4d4cc0c5d Mon Sep 17 00:00:00 2001 From: Michal Moskal Date: Wed, 30 Mar 2016 15:53:00 -0700 Subject: [PATCH 05/12] Move C++ sim stuff to proper namespace --- libs/hello/kind.json | 2 +- sim/libmbit.ts | 291 ++++++++++++++++++++++--------------------- 2 files changed, 147 insertions(+), 146 deletions(-) diff --git a/libs/hello/kind.json b/libs/hello/kind.json index d7f7e7c1..468413e1 100644 --- a/libs/hello/kind.json +++ b/libs/hello/kind.json @@ -6,6 +6,6 @@ ], "public": true, "dependencies": { - "core": "file:../microbit" + "microbit": "file:../microbit" } } diff --git a/sim/libmbit.ts b/sim/libmbit.ts index 17cf2181..ab2cb9b5 100644 --- a/sim/libmbit.ts +++ b/sim/libmbit.ts @@ -88,78 +88,6 @@ namespace ks.rt.micro_bit { throw new Error("PANIC " + code) } - /* basic */ - export function showDigit(v: number) { - if (!quiet) - console.log("DIGIT:", v) - plotLeds(createImageFromString(v.toString()[0])); - } - - export function clearScreen() { - board().image.clear(); - runtime.queueDisplayUpdate() - } - - export function showLeds(leds: micro_bit.Image, delay: number): void { - showAnimation(leds, delay); - } - - function scrollImage(leds: micro_bit.Image, interval: number, stride: number): void { - let cb = getResume() - let off = stride > 0 ? 0 : leds.width - 1; - let display = board().image; - - board().animationQ.enqueue({ - interval: interval, - frame: () => { - if (off >= leds.width || off < 0) return false; - stride > 0 ? display.shiftLeft(stride) : display.shiftRight(-stride); - let c = Math.min(stride, leds.width - off); - leds.copyTo(off, c, display, 5 - stride) - off += stride; - return true; - }, - whenDone: cb - }) - } - - export function showAnimation(leds: micro_bit.Image, interval: number = 400): void { - scrollImage(leds, interval, 5); - } - - export function scrollNumber(x: number, interval: number) { - if (interval < 0) return; - - let leds = createImageFromString(x.toString()); - if (x < 0 || x >= 10) scrollImage(leds, interval, 1); - else showLeds(leds, interval * 5); - } - - export function scrollString(s: string, interval: number) { - if (interval < 0) return; - if (s.length == 0) { - clearScreen(); - pause(interval * 5); - } else { - let leds = createImageFromString(s); - if (s.length == 1) showLeds(leds, interval * 5) - else scrollImage(leds, interval, 1); - } - } - - export function forever(a: RefAction) { - function loop() { - runtime.runFiberAsync(a) - .then(() => Promise.delay(20)) - .then(loop) - .done() - } - incr(a) - loop() - } - - export var pause = thread.pause; - /* leds */ export function plot(x: number, y: number) { board().image.set(x, y, 255); @@ -198,20 +126,17 @@ namespace ks.rt.micro_bit { runtime.queueDisplayUpdate() } - /* control */ - export var runInBackground = thread.runInBackground; - /* serial */ export function serialSendString(s: string) { board().writeSerial(s); } - - export function serialReadString() : string { + + export function serialReadString(): string { return board().readSerial(); } /* input */ - export function onButtonPressed(button : number, handler: RefAction) : void { + export function onButtonPressed(button: number, handler: RefAction): void { let ens = enums(); let b = board(); if (button == ens.MICROBIT_ID_BUTTON_AB && !board().usesButtonAB) { @@ -220,7 +145,7 @@ namespace ks.rt.micro_bit { } b.bus.listen(button, ens.MICROBIT_BUTTON_EVT_CLICK, handler); } - + export function isButtonPressed(button: number): boolean { let ens = enums(); let b = board(); @@ -233,19 +158,19 @@ namespace ks.rt.micro_bit { if (button == ens.MICROBIT_ID_BUTTON_B) return bts[1].pressed; return bts[2].pressed || (bts[0].pressed && bts[1].pressed); } - + export function onGesture(gesture: number, handler: RefAction) { let ens = enums(); let b = board(); b.accelerometer.activate(); - + if (gesture == 11 && !b.useShake) { // SAKE b.useShake = true; runtime.queueDisplayUpdate(); } b.bus.listen(ens.MICROBIT_ID_GESTURE, gesture, handler); } - + export function onPinPressed(pin: Pin, handler: RefAction) { pin.isTouched(); onButtonPressed(pin.id, handler); @@ -283,7 +208,7 @@ namespace ks.rt.micro_bit { } return b.heading; } - + export function temperature(): number { var b = board(); if (!b.usesTemperature) { @@ -292,7 +217,7 @@ namespace ks.rt.micro_bit { } return b.temperature; } - + export function getAcceleration(dimension: number): number { let b = board(); let acc = b.accelerometer; @@ -304,8 +229,8 @@ namespace ks.rt.micro_bit { default: return Math.floor(Math.sqrt(acc.instantaneousAccelerationSquared())); } } - - export function setAccelerometerRange(range : number) { + + export function setAccelerometerRange(range: number) { let b = board(); b.accelerometer.setSampleRange(range); } @@ -327,76 +252,76 @@ namespace ks.rt.micro_bit { export function getCurrentTime(): number { return runtime.runningTime(); } - + /* pins */ - export function digitalReadPin(pin : Pin) : number { + export function digitalReadPin(pin: Pin): number { pin.mode = PinMode.Digital | PinMode.Input; return pin.value > 100 ? 1 : 0; } - - export function digitalWritePin(pin : Pin, value: number) { + + export function digitalWritePin(pin: Pin, value: number) { pin.mode = PinMode.Digital | PinMode.Output; pin.value = value > 0 ? 1023 : 0; runtime.queueDisplayUpdate(); } - export function analogReadPin(pin : Pin) : number { + export function analogReadPin(pin: Pin): number { pin.mode = PinMode.Analog | PinMode.Input; return pin.value || 0; } - - export function analogWritePin(pin : Pin, value: number) { + + export function analogWritePin(pin: Pin, value: number) { pin.mode = PinMode.Analog | PinMode.Output; pin.value = value ? 1 : 0; runtime.queueDisplayUpdate(); } - - export function setAnalogPeriodUs(pin: Pin, micros:number) { + + export function setAnalogPeriodUs(pin: Pin, micros: number) { pin.mode = PinMode.Analog | PinMode.Output; pin.period = micros; runtime.queueDisplayUpdate(); } - + export function servoWritePin(pin: Pin, value: number) { setAnalogPeriodUs(pin, 20000); // TODO } - - export function servoSetPulse(pin: Pin, micros:number) { + + export function servoSetPulse(pin: Pin, micros: number) { } - + module AudioContextManager { - var _context : any; // AudioContext - var _vco : any; //OscillatorNode; + var _context: any; // AudioContext + var _vco: any; //OscillatorNode; var _vca: any; // GainNode; - - function context() : any { + + function context(): any { if (!_context) _context = freshContext(); return _context; } - - function freshContext() : any { + + function freshContext(): any { (window).AudioContext = (window).AudioContext || (window).webkitAudioContext; if ((window).AudioContext) { try { // this call my crash. // SyntaxError: audio resources unavailable for AudioContext construction - return new (window).AudioContext(); - } catch(e) {} - } + return new (window).AudioContext(); + } catch (e) { } + } return undefined; } - + export function stop() { if (_vca) _vca.gain.value = 0; } - - export function tone(frequency: number, gain: number) { - if (frequency <= 0) return; + + export function tone(frequency: number, gain: number) { + if (frequency <= 0) return; var ctx = context(); if (!ctx) return; - - gain = Math.max(0, Math.min(1, gain)); + + gain = Math.max(0, Math.min(1, gain)); if (!_vco) { try { _vco = ctx.createOscillator(); @@ -405,89 +330,165 @@ namespace ks.rt.micro_bit { _vca.connect(ctx.destination); _vca.gain.value = gain; _vco.start(0); - } catch(e) { + } catch (e) { _vco = undefined; _vca = undefined; return; } } - + _vco.frequency.value = frequency; _vca.gain.value = gain; } } - + export function enablePitch(pin: Pin) { board().pins.filter(p => !!p).forEach(p => p.pitch = false); pin.pitch = true; } - + export function pitch(frequency: number, ms: number) { // update analog output let pin = board().pins.filter(pin => !!pin && pin.pitch)[0] || board().pins[0]; pin.mode = PinMode.Analog | PinMode.Output; if (frequency <= 0) { - pin.value = 0; - pin.period = 0; + pin.value = 0; + pin.period = 0; } else { pin.value = 512; - pin.period = 1000000/frequency; + pin.period = 1000000 / frequency; } runtime.queueDisplayUpdate(); - + let cb = getResume(); AudioContextManager.tone(frequency, 1); if (ms <= 0) cb(); else { setTimeout(() => { - AudioContextManager.stop(); - pin.value = 0; - pin.period = 0; + AudioContextManager.stop(); + pin.value = 0; + pin.period = 0; pin.mode = PinMode.Unused; runtime.queueDisplayUpdate(); - cb() + cb() }, ms); } } - - + + /* radio */ - export function broadcastMessage(msg: number) : void { + export function broadcastMessage(msg: number): void { board().radio.broadcast(msg); } - - export function onBroadcastMessageReceived(msg: number, handler: RefAction) : void { + + export function onBroadcastMessageReceived(msg: number, handler: RefAction): void { let ens = enums() board().bus.listen(ens.MES_BROADCAST_GENERAL_ID, msg, handler); } - - export function setGroup(id : number) : void { + + export function setGroup(id: number): void { board().radio.setGroup(id); } - - export function setTransmitPower(power: number) : void { - board().radio.setTransmitPower(power); + + export function setTransmitPower(power: number): void { + board().radio.setTransmitPower(power); } - export function datagramSendNumbers(value0 : number, value1: number, value2: number, value3: number) : void { + export function datagramSendNumbers(value0: number, value1: number, value2: number, value3: number): void { board().radio.datagram.send([value0, value1, value2, value3]); } - - export function datagramReceiveNumber() : number { + + export function datagramReceiveNumber(): number { return board().radio.datagram.recv().data[0]; } - - export function datagramGetNumber(index : number) : number { + + export function datagramGetNumber(index: number): number { return board().radio.datagram.lastReceived.data[index] || 0; } - - export function datagramGetRSSI() : number { + + export function datagramGetRSSI(): number { return board().radio.datagram.lastReceived.rssi; } - - export function onDatagramReceived(handler: RefAction) : void { + + export function onDatagramReceived(handler: RefAction): void { let ens = enums(); board().bus.listen(ens.MICROBIT_ID_RADIO, ens.MICROBIT_RADIO_EVT_DATAGRAM, handler); } } +namespace ks.rt.basic { + var board = micro_bit.board; + + export var pause = thread.pause; + + export function showNumber(x: number, interval: number) { + if (interval < 0) return; + + let leds = micro_bit.createImageFromString(x.toString()); + if (x < 0 || x >= 10) scrollImage(leds, interval, 1); + else showLeds(leds, interval * 5); + } + + export function showString(s: string, interval: number) { + if (interval < 0) return; + if (s.length == 0) { + clearScreen(); + pause(interval * 5); + } else { + let leds = micro_bit.createImageFromString(s); + if (s.length == 1) showLeds(leds, interval * 5) + else scrollImage(leds, interval, 1); + } + } + + export function showLeds(leds: micro_bit.Image, delay: number): void { + showAnimation(leds, delay); + } + + export function clearScreen() { + board().image.clear(); + runtime.queueDisplayUpdate() + } + + function scrollImage(leds: micro_bit.Image, interval: number, stride: number): void { + let cb = getResume() + let off = stride > 0 ? 0 : leds.width - 1; + let display = board().image; + + board().animationQ.enqueue({ + interval: interval, + frame: () => { + if (off >= leds.width || off < 0) return false; + stride > 0 ? display.shiftLeft(stride) : display.shiftRight(-stride); + let c = Math.min(stride, leds.width - off); + leds.copyTo(off, c, display, 5 - stride) + off += stride; + return true; + }, + whenDone: cb + }) + } + + export function showAnimation(leds: micro_bit.Image, interval: number = 400): void { + scrollImage(leds, interval, 5); + } + + export function forever(a: RefAction) { + function loop() { + runtime.runFiberAsync(a) + .then(() => Promise.delay(20)) + .then(loop) + .done() + } + incr(a) + loop() + } +} + +namespace ks.rt.control { + export var inBackground = thread.runInBackground; + + export function reset() { + U.userError("reset not implemented in simulator yet") + } +} From a14585d36fa41c9520a131cd26c29e8f9b49ab93 Mon Sep 17 00:00:00 2001 From: Michael Elliot Braun Date: Wed, 30 Mar 2016 15:54:19 -0700 Subject: [PATCH 06/12] updating lessons --- docs/lessons/counter.md | 2 ++ docs/lessons/die-roll.md | 3 ++- docs/lessons/digi-yoyo.md | 10 ++------- docs/lessons/digi-yoyo/activity.md | 1 - docs/lessons/digi-yoyo/challenges.md | 4 +++- docs/lessons/guess-the-number.md | 2 ++ docs/lessons/guess-the-number/quiz-answers.md | 2 +- docs/lessons/looper.md | 3 +++ docs/lessons/magic-8.md | 3 ++- docs/lessons/magic-8/quiz-answers.md | 3 ++- docs/lessons/magic-8/quiz.md | 2 +- docs/lessons/magic-logo.md | 2 ++ docs/lessons/night-light.md | 2 ++ docs/lessons/night-light/quiz-answers.md | 22 ++++++++++++++----- docs/lessons/rotation-animation.md | 15 +++++-------- docs/lessons/rotation-animation/challenges.md | 17 ++++++-------- docs/lessons/spinner.md | 2 ++ docs/lessons/strobe-light.md | 2 ++ docs/lessons/strobe-light/activity.md | 9 +++++++- docs/lessons/truth-or-dare.md | 2 ++ 20 files changed, 67 insertions(+), 41 deletions(-) diff --git a/docs/lessons/counter.md b/docs/lessons/counter.md index 921c8aa0..09ad7590 100644 --- a/docs/lessons/counter.md +++ b/docs/lessons/counter.md @@ -12,6 +12,8 @@ Variables * [activity](/microbit/lessons/counter/activity) * [challenges](/microbit/lessons/counter/challenges) +* [quiz](/microbit/lessons/counter/quiz) +* [quiz answers](/microbit/lessons/counter/quiz-answers) ## Prior learning/place of lesson in scheme of work diff --git a/docs/lessons/die-roll.md b/docs/lessons/die-roll.md index 673f306a..54329cb9 100644 --- a/docs/lessons/die-roll.md +++ b/docs/lessons/die-roll.md @@ -12,7 +12,8 @@ If (Conditionals) * [activity](/microbit/lessons/die-roll/activity) * [challenges](/microbit/lessons/die-roll/challenges) - +* [quiz](/microbit/lessons/die-roll/quiz) +* [quiz answers](/microbit/lessons/die-roll/quiz-answers) ## Prior learning/place of lesson in scheme of work diff --git a/docs/lessons/digi-yoyo.md b/docs/lessons/digi-yoyo.md index c0eae3c2..98e70b14 100644 --- a/docs/lessons/digi-yoyo.md +++ b/docs/lessons/digi-yoyo.md @@ -12,6 +12,8 @@ While Loop * [activity](/microbit/lessons/digi-yoyo/activity) * [challenges](/microbit/lessons/digi-yoyo/challenges) +* [quiz](/microbit/lessons/digi-yoyo/quiz) +* [quiz answers](/microbit/lessons/digi-yoyo/quiz-answers) ## Prior learning/place of lesson in scheme of work @@ -20,20 +22,12 @@ Learn how to creating a **while loop**, `while condition do` to repeat code whil ## Documentation ```docs - let x = 0 - basic.showNumber(0) - - while (true) { basic.pause(20) } - - - - ``` ## Objectives diff --git a/docs/lessons/digi-yoyo/activity.md b/docs/lessons/digi-yoyo/activity.md index bd6bfa71..da9c8dbf 100644 --- a/docs/lessons/digi-yoyo/activity.md +++ b/docs/lessons/digi-yoyo/activity.md @@ -18,7 +18,6 @@ let count = 0 Add a while loop that will loop over and over until the variable `count` equals 10. -![](/static/mb/blocks/lessons/digi-yoyo-1.jpg) ```blocks let count = 0 diff --git a/docs/lessons/digi-yoyo/challenges.md b/docs/lessons/digi-yoyo/challenges.md index 42b1afaa..24dee263 100644 --- a/docs/lessons/digi-yoyo/challenges.md +++ b/docs/lessons/digi-yoyo/challenges.md @@ -69,5 +69,7 @@ Now, we need `count` to decrease by one after the micro:bit has displayed the va We can do this by adding this line: ```blocks -let count = count + (count - 1); +let count = 0; +count = count + (count - 1); + ``` diff --git a/docs/lessons/guess-the-number.md b/docs/lessons/guess-the-number.md index 727a3bb4..d1457195 100644 --- a/docs/lessons/guess-the-number.md +++ b/docs/lessons/guess-the-number.md @@ -12,6 +12,8 @@ Math - Pick Random * [activity](/microbit/lessons/guess-the-number/activity) * [challenges](/microbit/lessons/guess-the-number/challenges) +* [quiz](/microbit/lessons/guess-the-number/quiz) +* [quiz answers](/microbit/lessons/guess-the-number/quiz-answers) ## Prior learning/place of lesson in scheme of work diff --git a/docs/lessons/guess-the-number/quiz-answers.md b/docs/lessons/guess-the-number/quiz-answers.md index a32d39ed..c4984252 100644 --- a/docs/lessons/guess-the-number/quiz-answers.md +++ b/docs/lessons/guess-the-number/quiz-answers.md @@ -31,7 +31,7 @@ let randomNumber = Math.random(10) If the rectangle below represents the BBC micro:bit, shade the areas that will be displayed. Explain why that particular area is shaded. ```blocks -randomNumber = Math.random(10) +let randomNumber = Math.random(10) ``` diff --git a/docs/lessons/looper.md b/docs/lessons/looper.md index 8dc06ac6..75f01bb3 100644 --- a/docs/lessons/looper.md +++ b/docs/lessons/looper.md @@ -12,6 +12,9 @@ For Loop * [activity](/microbit/lessons/looper/activity) * [challenges](/microbit/lessons/looper/challenges) +* [quiz](/microbit/lessons/looper/quiz) +* [quiz answers](/microbit/lessons/looper/quiz-answers) + ## Class diff --git a/docs/lessons/magic-8.md b/docs/lessons/magic-8.md index 9330a5ea..856b4ddf 100644 --- a/docs/lessons/magic-8.md +++ b/docs/lessons/magic-8.md @@ -10,6 +10,8 @@ If (Conditionals) * [activity](/microbit/lessons/magic-8/activity) * [challenges](/microbit/lessons/magic-8/challenges) +* [quiz](/microbit/lessons/magic-8/quiz) +* [quiz answers](/microbit/lessons/magic-8/quiz-answers) ## Prior learning/place of lesson in scheme of work @@ -28,7 +30,6 @@ input.onGesture(Gesture.Shake, () => { basic.showNumber(7) basic.clearScreen() basic.showString("Hello!") - ``` ## Objectives diff --git a/docs/lessons/magic-8/quiz-answers.md b/docs/lessons/magic-8/quiz-answers.md index 60628125..9acfa619 100644 --- a/docs/lessons/magic-8/quiz-answers.md +++ b/docs/lessons/magic-8/quiz-answers.md @@ -25,12 +25,13 @@ let x = Math.random(3) ## 3. Write the 'if statement' to check if ``x`` is equal to 2. Inside the 'if statement', display the string "Yes". ```blocks +let x = Math.random(3) if (x == 2) { basic.showString("Yes", 150) } ``` -## 3. Write the 'if statement' to check if ``x`` is equal to 1. Inside the 'if statement', display the string "No." +## 4. Write the 'if statement' to check if ``x`` is equal to 1. Inside the 'if statement', display the string "No." ```blocks let x = Math.random(3) diff --git a/docs/lessons/magic-8/quiz.md b/docs/lessons/magic-8/quiz.md index 317adce7..ed2cd13a 100644 --- a/docs/lessons/magic-8/quiz.md +++ b/docs/lessons/magic-8/quiz.md @@ -22,7 +22,7 @@ Answer the questions while completing the tutorial. Pay attention to the dialogu
-## 3. Write the 'if statement' to check if ``x`` is equal to 1. Inside the 'if statement', display the string "No." +## 4. Write the 'if statement' to check if ``x`` is equal to 1. Inside the 'if statement', display the string "No."
diff --git a/docs/lessons/magic-logo.md b/docs/lessons/magic-logo.md index c36d453b..ff659cab 100644 --- a/docs/lessons/magic-logo.md +++ b/docs/lessons/magic-logo.md @@ -12,6 +12,8 @@ On Logo Up * [activity](/microbit/lessons/magic-logo/activity) * [challenges](/microbit/lessons/magic-logo/challenges) +* [quiz](/microbit/lessons/magic-logo/challenges) +* [quiz answers](/microbit/lessons/magic-logo/challenges) ## Prior learning/place of lesson in scheme of work diff --git a/docs/lessons/night-light.md b/docs/lessons/night-light.md index 53816d77..b7e65054 100644 --- a/docs/lessons/night-light.md +++ b/docs/lessons/night-light.md @@ -12,6 +12,8 @@ Set Brightness * [activity](/microbit/lessons/night-light/activity) * [challenges](/microbit/lessons/night-light/challenges) +* [quiz](/microbit/lessons/night-light/quiz) +* [quiz answers](/microbit/lessons/night-light/quiz-answers) ## Prior learning/place of lesson in scheme of work diff --git a/docs/lessons/night-light/quiz-answers.md b/docs/lessons/night-light/quiz-answers.md index 2396e758..14df5f9a 100644 --- a/docs/lessons/night-light/quiz-answers.md +++ b/docs/lessons/night-light/quiz-answers.md @@ -16,9 +16,15 @@ If the rectangle above represents the BBC micro:bit, write the code to set all t
-``` +```blocks led.setBrightness(255) -led.plotAll() +basic.showLeds(` + # # # # # + # # # # # + # # # # # + # # # # # + # # # # # + `) ``` ## 3. Consider the following image @@ -29,9 +35,15 @@ If the rectangle above represents the BBC micro:bit, write the code to set the s
-``` +```blocks led.setBrightness(128) -led.plotAll() +basic.showLeds(` + # # # # # + # # # # # + # # # # # + # # # # # + # # # # # + `) ``` ## 4. Consider the following image @@ -40,7 +52,7 @@ led.plotAll() If the rectangle above represents the BBC micro:bit, write the code to turn off all the LEDs. -``` +```blocks led.setBrightness(0) ``` diff --git a/docs/lessons/rotation-animation.md b/docs/lessons/rotation-animation.md index 1c2665f6..9f77f5f6 100644 --- a/docs/lessons/rotation-animation.md +++ b/docs/lessons/rotation-animation.md @@ -10,10 +10,8 @@ While Loop * [activity](/microbit/lessons/rotation-animation/activity) * [challenges](/microbit/lessons/rotation-animation/challenges) - -## Class - -Year 7 +* [quiz](/microbit/lessons/rotation-animation/quiz) +* [quiz answers](/microbit/lessons/rotation-animation/quiz-answers) ## Prior learning/place of lesson in scheme of work @@ -38,17 +36,14 @@ while (true) { basic.pause(20) } - - - ``` ## Objectives -* learn how to create a global variable for a place where you can store data, accessible across functions, and in nested code blocks -* learn how to set or change the value of a global variable +* learn how to create a variable for a place where you can store data, accessible across functions, and in nested code blocks +* learn how to set or change the value of a variable * learn how to repeat code while a condition is true -* learn how to declare a global boolean variable to determine which code will execute next +* learn how to declare a boolean variable to determine which code will execute next * learn how to run code when an input button is pressed * learn how to show a series of image frames on the LED screen * learn how to pause your code for the specified number of milliseconds diff --git a/docs/lessons/rotation-animation/challenges.md b/docs/lessons/rotation-animation/challenges.md index 14bb9d82..b58cbc3f 100644 --- a/docs/lessons/rotation-animation/challenges.md +++ b/docs/lessons/rotation-animation/challenges.md @@ -54,9 +54,6 @@ Now let's add to this by creating a condition for on button pressed `A` before t ```blocks let rotating = true; -input.onButtonPressed(Button.A, () => { - serial.writeLine("hello") -}) while (rotating) { serial.writeLine("loop") basic.showLeds(` @@ -88,8 +85,9 @@ while (rotating) { . . . . . `) } - - +input.onButtonPressed(Button.A, () => { + serial.writeLine("hello") +}) ``` @@ -101,10 +99,6 @@ Now that we have the on button pressed condition, let's make the animation stop ```blocks let rotating = true; -input.onButtonPressed(Button.A, () => { - serial.writeLine("hello") - rotating = false -}) while (rotating) { serial.writeLine("loop") basic.showLeds(` @@ -136,7 +130,10 @@ while (rotating) { . . . . . `) } - +input.onButtonPressed(Button.A, () => { + serial.writeLine("hello") + rotating = false +}) ``` diff --git a/docs/lessons/spinner.md b/docs/lessons/spinner.md index 29b54c64..360162f2 100644 --- a/docs/lessons/spinner.md +++ b/docs/lessons/spinner.md @@ -12,6 +12,8 @@ If (Conditionals) * [activity](/microbit/lessons/spinner/activity) * [challenges](/microbit/lessons/spinner/challenges) +* [quiz](/microbit/lessons/spinner/quiz) +* [quiz answers](/microbit/lessons/spinner/quiz-answers) ## Prior learning/place of lesson in scheme of work diff --git a/docs/lessons/strobe-light.md b/docs/lessons/strobe-light.md index f22e84bb..57092d62 100644 --- a/docs/lessons/strobe-light.md +++ b/docs/lessons/strobe-light.md @@ -12,6 +12,8 @@ For Loop * [activity](/microbit/lessons/strobe-light/activity) * [challenges](/microbit/lessons/strobe-light/challenges) +* [quiz](/microbit/lessons/strobe-light/quiz) +* [quiz answers](/microbit/lessons/strobe-light/quiz-answers) ## Documentation diff --git a/docs/lessons/strobe-light/activity.md b/docs/lessons/strobe-light/activity.md index 8ff62a3a..80ed82ba 100644 --- a/docs/lessons/strobe-light/activity.md +++ b/docs/lessons/strobe-light/activity.md @@ -45,7 +45,14 @@ for (let i = 0; i < 5; i++) { The pause will add a delay between lighting each LED. -![](/static/mb/blocks/lessons/strobe-light-3.jpg) +```blocks +for (let i = 0; i < 5; i++) { + for (let j = 0; j < 5; j++) { + led.plot(i, j) + basic.pause(200) + } +} +``` ### ~avatar avatar diff --git a/docs/lessons/truth-or-dare.md b/docs/lessons/truth-or-dare.md index 73bf9877..32fe19d8 100644 --- a/docs/lessons/truth-or-dare.md +++ b/docs/lessons/truth-or-dare.md @@ -12,6 +12,8 @@ If (Conditionals) * [activity](/microbit/lessons/truth-or-dare/activity) * [challenges](/microbit/lessons/truth-or-dare/challenges) +* [quiz](/microbit/lessons/truth-or-dare/quiz) +* [quiz answers](/microbit/lessons/truth-or-dare/quiz-answers) ## Prior learning/place of lesson in scheme of work From ba6c9f9d9270a5f19edc8163f93e30ccf199892e Mon Sep 17 00:00:00 2001 From: Michael Elliot Braun Date: Wed, 30 Mar 2016 16:10:27 -0700 Subject: [PATCH 07/12] updating lesson links --- docs/lessons/catch-the-egg-game/quiz.md | 4 +- docs/lessons/compass.md | 3 +- docs/lessons/compass/activity.md | 6 +-- docs/lessons/compass/challenges.md | 6 +-- docs/lessons/die-roll/quiz.md | 2 +- docs/lessons/digi-yoyo/quiz.md | 2 +- docs/lessons/glowing-pendulum/quiz.md | 2 +- docs/lessons/guess-the-number/quiz.md | 2 +- docs/lessons/looper/quiz.md | 2 +- docs/lessons/magic-8/quiz.md | 2 +- docs/lessons/night-light/quiz.md | 2 +- docs/lessons/rock-paper-scissors/quiz.md | 2 +- .../rotation-animation/quiz-answers.md | 36 ++++++++++++++---- docs/lessons/rotation-animation/quiz.md | 38 +++++++++++++++---- docs/lessons/spinner/quiz.md | 2 +- docs/lessons/strobe-light/quiz.md | 2 +- docs/lessons/truth-or-dare/quiz.md | 2 +- docs/lessons/zoomer.md | 4 +- docs/lessons/zoomer/quiz.md | 2 +- 19 files changed, 83 insertions(+), 38 deletions(-) diff --git a/docs/lessons/catch-the-egg-game/quiz.md b/docs/lessons/catch-the-egg-game/quiz.md index 339c4fbf..35a087f2 100644 --- a/docs/lessons/catch-the-egg-game/quiz.md +++ b/docs/lessons/catch-the-egg-game/quiz.md @@ -6,11 +6,11 @@ Programming a game of catch the egg using the accelerometer. ## Directions -Use this activity document to guide your work in the [catch the egg tutorial](/microbit/lessons/catch-the-egg-game/tutorial) +Use this activity document to guide your work in the [catch the egg challenges](/microbit/lessons/catch-the-egg-game/challenges) Answer the questions while completing the tutorial. Pay attention to the dialogues! -## 1. Write the data type for the global variables 'basket' and 'egg'. +## 1. Write the data type for the variables 'basket' and 'egg'.
diff --git a/docs/lessons/compass.md b/docs/lessons/compass.md index b2827ced..9d368f66 100644 --- a/docs/lessons/compass.md +++ b/docs/lessons/compass.md @@ -12,7 +12,8 @@ If (Conditionals) * [activity](/microbit/lessons/compass/activity) * [challenges](/microbit/lessons/compass/challenges) - +* [quiz](/microbit/lessons/compass/quiz) +* [quiz answers](/microbit/lessons/compass/quiz-answers) ## Prior learning/place of lesson in scheme of work diff --git a/docs/lessons/compass/activity.md b/docs/lessons/compass/activity.md index 943ef8f6..c4031140 100644 --- a/docs/lessons/compass/activity.md +++ b/docs/lessons/compass/activity.md @@ -41,7 +41,7 @@ If `degrees` is less than 135, the micro:bit is mostly pointing East. Display `E ```blocks - let degrees = null; + let degrees = 0; basic.forever(() => { degrees = input.compassHeading(); if (degrees < 45) { @@ -57,7 +57,7 @@ If `degrees` is less than 225, the micro:bit is mostly pointing South. Display ` ```blocks - let degrees = null; + let degrees = 0; basic.forever(() => { degrees = input.compassHeading(); if (degrees < 45) { @@ -76,7 +76,7 @@ basic.forever(() => { If none of these conditions returned true, then the micro:bit must be pointing West. Display `W` on the micro:bit. ```blocks - let degrees = null; + let degrees = 0; basic.forever(() => { degrees = input.compassHeading(); if (degrees < 45) { diff --git a/docs/lessons/compass/challenges.md b/docs/lessons/compass/challenges.md index b61fc71b..4603b7b9 100644 --- a/docs/lessons/compass/challenges.md +++ b/docs/lessons/compass/challenges.md @@ -7,7 +7,7 @@ Display the direction that the micro:bit is facing using the compass Complete the following [guided tutorial](/microbit/lessons/compass/activity), your code should look like this: ```blocks - let degrees = null; + let degrees = 0; basic.forever(() => { degrees = input.compassHeading(); if (degrees < 45) { @@ -30,7 +30,7 @@ basic.forever(() => { Instead of displaying `N` when the BBC micro:bit is pointing North, display a star to indicate the north star. ```blocks - let degrees = null; + let degrees = 0; basic.forever(() => { degrees = input.compassHeading(); if (degrees < 45) { @@ -61,7 +61,7 @@ basic.forever(() => { Instead of displaying just `N`, `W`, `S`, or `E`, display the full word. ```blocks - let degrees = null; + let degrees = 0; basic.forever(() => { degrees = input.compassHeading(); if (degrees < 45) { diff --git a/docs/lessons/die-roll/quiz.md b/docs/lessons/die-roll/quiz.md index 2592c6a2..e97e7364 100644 --- a/docs/lessons/die-roll/quiz.md +++ b/docs/lessons/die-roll/quiz.md @@ -6,7 +6,7 @@ Create a die when the BBC micro:bit is shaken ## Directions -Use this activity document to guide your work in the [die roll tutorial](/microbit/lessons/die-roll/tutorial). +Use this activity document to guide your work in the [die roll tutorial](/microbit/lessons/die-roll/activity). Answer the questions while completing the tutorial. Pay attention to the dialogues! diff --git a/docs/lessons/digi-yoyo/quiz.md b/docs/lessons/digi-yoyo/quiz.md index de9aecf2..0f97309c 100644 --- a/docs/lessons/digi-yoyo/quiz.md +++ b/docs/lessons/digi-yoyo/quiz.md @@ -6,7 +6,7 @@ Create a counter with a while loop ## Directions -Use this activity document to guide your work in the [digi yoyo tutorial](/microbit/lessons/digi-yoyo/tutorial) +Use this activity document to guide your work in the [digi yoyo tutorial](/microbit/lessons/digi-yoyo/activity) Answer the questions while completing the tutorial. Pay attention to the dialogues! diff --git a/docs/lessons/glowing-pendulum/quiz.md b/docs/lessons/glowing-pendulum/quiz.md index f2dc9a7d..2ca42dff 100644 --- a/docs/lessons/glowing-pendulum/quiz.md +++ b/docs/lessons/glowing-pendulum/quiz.md @@ -6,7 +6,7 @@ construct a pendulum that glows using acceleration #LED #number #math #accelerat ## Directions -Use this activity document to guide your work in the [glowing pendulum tutorial](/microbit/lessons/glowing-pendulum/tutorial) +Use this activity document to guide your work in the [glowing pendulum tutorial](/microbit/lessons/glowing-pendulum/activity) Answer the questions while completing the tutorial. Pay attention to the dialogues! diff --git a/docs/lessons/guess-the-number/quiz.md b/docs/lessons/guess-the-number/quiz.md index b7511109..aed4df30 100644 --- a/docs/lessons/guess-the-number/quiz.md +++ b/docs/lessons/guess-the-number/quiz.md @@ -6,7 +6,7 @@ Learn how to generate a random number on the micro:bit. #math #random #docs ## Directions -Use this activity document to guide your work in the [guess the number tutorial](/microbit/lessons/guess-the-number/tutorial). +Use this activity document to guide your work in the [guess the number tutorial](/microbit/lessons/guess-the-number/activity). Answer the questions while completing the tutorial. Pay attention to the dialogues! diff --git a/docs/lessons/looper/quiz.md b/docs/lessons/looper/quiz.md index 8cbe593e..a6ed1adf 100644 --- a/docs/lessons/looper/quiz.md +++ b/docs/lessons/looper/quiz.md @@ -6,7 +6,7 @@ Learn how to create a series of numbers with a for loop. #LED #screen #plot #doc ## Directions -Use this activity document to guide your work in the [looper tutorial](/microbit/lessons/looper/tutorial) +Use this activity document to guide your work in the [looper tutorial](/microbit/lessons/looper/activity) Answer the questions while completing the tutorial. Pay attention to the dialogues! diff --git a/docs/lessons/magic-8/quiz.md b/docs/lessons/magic-8/quiz.md index ed2cd13a..3244d112 100644 --- a/docs/lessons/magic-8/quiz.md +++ b/docs/lessons/magic-8/quiz.md @@ -6,7 +6,7 @@ create a magic 8 ball on the BBC micro:bit #math #random #docs ## Directions -Use this activity document to guide your work in the [magic 8 tutorial](/microbit/lessons/magic-8/tutorial). +Use this activity document to guide your work in the [magic 8 tutorial](/microbit/lessons/magic-8/activity). Answer the questions while completing the tutorial. Pay attention to the dialogues! diff --git a/docs/lessons/night-light/quiz.md b/docs/lessons/night-light/quiz.md index 0c6ce527..c4d15768 100644 --- a/docs/lessons/night-light/quiz.md +++ b/docs/lessons/night-light/quiz.md @@ -6,7 +6,7 @@ change the brightness of the BBC micro:bit #LED #image #brightness #fade #docs ## Directions -Use this activity document to guide your work in the [night light tutorial](/microbit/lessons/night-light/tutorial) +Use this activity document to guide your work in the [night light tutorial](/microbit/lessons/night-light/activity) Answer the questions while completing the tutorial. Pay attention to the dialogues! diff --git a/docs/lessons/rock-paper-scissors/quiz.md b/docs/lessons/rock-paper-scissors/quiz.md index 2841da06..0703ef85 100644 --- a/docs/lessons/rock-paper-scissors/quiz.md +++ b/docs/lessons/rock-paper-scissors/quiz.md @@ -6,7 +6,7 @@ shift an image horizontally across the display with offset #offset #screen #var ## Directions -Use this activity document to guide your work in the [rock paper scissors tutorial](/microbit/lessons/rock-paper-scissors/tutorial). +Use this activity document to guide your work in the [rock paper scissors tutorial](/microbit/lessons/rock-paper-scissors/activity). Answer the questions while completing the tutorial. Pay attention to the dialogues! diff --git a/docs/lessons/rotation-animation/quiz-answers.md b/docs/lessons/rotation-animation/quiz-answers.md index 38d86043..a8abae77 100644 --- a/docs/lessons/rotation-animation/quiz-answers.md +++ b/docs/lessons/rotation-animation/quiz-answers.md @@ -48,13 +48,35 @@ It is a **while** loop that will be executed only if the ** variable** called `r ## 4. If the rectangle below represents the BBC micro:bit, shade the areas that will be displayed. Explain why that particular area is shaded. ```blocks -basic.showAnimation(` -# . . . . . . # . . . . . . # . . . . . -. # . . . . . # . . . . . # . . . . . . -. . # . . . . # . . . . # . . # # # # # -. . . # . . . # . . . # . . . . . . . . -. . . . # . . # . . # . . . . . . . . . -`, 400) +basic.showLeds(` + . . # . . + . . # . . + . . # . . + . . # . . + . . # . . + `) +basic.showLeds(` + . . . . . + . . . . . + # # # # # + . . . . . + . . . . . + `) +basic.showLeds(` + . . . . # + . . . # . + . . # . . + . # . . . + # . . . . + `) +basic.showLeds(` + . . . . # + . . . # . + . . # . . + . # . . . + # . . . . + `) + ``` diff --git a/docs/lessons/rotation-animation/quiz.md b/docs/lessons/rotation-animation/quiz.md index b9505fab..7991c5cb 100644 --- a/docs/lessons/rotation-animation/quiz.md +++ b/docs/lessons/rotation-animation/quiz.md @@ -6,7 +6,7 @@ Learn how to create a rotating image with a while loop. #image #loop #while #do ## Directions -Use this activity document to guide your work in the [rotation animation tutorial](/microbit/lessons/rotation-animation/tutorial). +Use this activity document to guide your work in the [rotation animation tutorial](/microbit/lessons/rotation-animation/activity). Answer the questions while completing the tutorial. Pay attention to the dialogues! @@ -46,13 +46,35 @@ while (rotating) { ## 4. Draw the areas on the micro:bits to illustrate the code below. Explain why you chose to draw in those areas. ```blocks -basic.showAnimation(` -# . . . . . . # . . . . . . # . . . . . -. # . . . . . # . . . . . # . . . . . . -. . # . . . . # . . . . # . . # # # # # -. . . # . . . # . . . # . . . . . . . . -. . . . # . . # . . # . . . . . . . . . -`, 400) +basic.showLeds(` + . . # . . + . . # . . + . . # . . + . . # . . + . . # . . + `) +basic.showLeds(` + . . . . . + . . . . . + # # # # # + . . . . . + . . . . . + `) +basic.showLeds(` + . . . . # + . . . # . + . . # . . + . # . . . + # . . . . + `) +basic.showLeds(` + . . . . # + . . . # . + . . # . . + . # . . . + # . . . . + `) + ``` ![](/static/mb/lessons/looper-2.png) diff --git a/docs/lessons/spinner/quiz.md b/docs/lessons/spinner/quiz.md index 9f5d2768..a11e71b9 100644 --- a/docs/lessons/spinner/quiz.md +++ b/docs/lessons/spinner/quiz.md @@ -6,7 +6,7 @@ a spin the BBC micro:bit game with the input on shake #math #random #docs #shake ## Directions -Use this activity document to guide your work in the [spinner tutorial](/microbit/lessons/spinner/tutorial). +Use this activity document to guide your work in the [spinner tutorial](/microbit/lessons/spinner/activity). Answer the questions while completing the tutorial. Pay attention to the dialogues! diff --git a/docs/lessons/strobe-light/quiz.md b/docs/lessons/strobe-light/quiz.md index 90c82b35..30f58564 100644 --- a/docs/lessons/strobe-light/quiz.md +++ b/docs/lessons/strobe-light/quiz.md @@ -6,7 +6,7 @@ Learn how to create a blinking LED script with a for loop. #LED #screen #plot #d ## Directions -Use this activity document to guide your work in the [strobe light tutorial](/microbit/lessons/strobe-light/tutorial) +Use this activity document to guide your work in the [strobe light tutorial](/microbit/lessons/strobe-light/activity) Answer the questions while completing the tutorial. Pay attention to the dialogues! diff --git a/docs/lessons/truth-or-dare/quiz.md b/docs/lessons/truth-or-dare/quiz.md index c7e783d1..66fee197 100644 --- a/docs/lessons/truth-or-dare/quiz.md +++ b/docs/lessons/truth-or-dare/quiz.md @@ -6,7 +6,7 @@ a multi-player game that forces each player to reveal a secret or something funn ## Directions -Use this activity document to guide your work in the [truth or dare tutorial](/microbit/lessons/truth-or-dare/tutorial). +Use this activity document to guide your work in the [truth or dare tutorial](/microbit/lessons/truth-or-dare/activity). Answer the questions while completing the tutorial. Pay attention to the dialogues! diff --git a/docs/lessons/zoomer.md b/docs/lessons/zoomer.md index fada8b35..81765572 100644 --- a/docs/lessons/zoomer.md +++ b/docs/lessons/zoomer.md @@ -12,6 +12,8 @@ Acceleration * [activity](/microbit/lessons/zoomer/activity) * [challenges](/microbit/lessons/zoomer/challenges) +* [quiz](/microbit/lessons/zoomer/quiz) +* [quiz answers](/microbit/lessons/zoomer/quiz-answers) ## Prior learning/place of lesson in scheme of work @@ -21,12 +23,10 @@ Learn how to get the **acceleration**, `acceleration` in one of three specified ```docs basic.forever(() => { - }) let x = 0 input.acceleration(Dimension.X) if (true) { - } input.buttonIsPressed(Button.A) basic.showNumber(0) diff --git a/docs/lessons/zoomer/quiz.md b/docs/lessons/zoomer/quiz.md index 3a9f293b..a7ab18a2 100644 --- a/docs/lessons/zoomer/quiz.md +++ b/docs/lessons/zoomer/quiz.md @@ -6,7 +6,7 @@ Measure the acceleration on the micro:bit in the "z" direction #LED #number #mat ## Directions -Use this activity document to guide your work in the [zoomer tutorial](/microbit/lessons/zoomer/tutorial) +Use this activity document to guide your work in the [zoomer tutorial](/microbit/lessons/zoomer/activity) Answer the questions while completing the tutorial. Pay attention to the dialogues! From b83a8458547751f15741229fab3852523080e8f9 Mon Sep 17 00:00:00 2001 From: Michael Elliot Braun Date: Wed, 30 Mar 2016 16:25:19 -0700 Subject: [PATCH 08/12] updated lessons --- docs/lessons/classic-beatbox.md | 39 ------------------- docs/lessons/glowing-pendulum.md | 6 +-- docs/lessons/glowing-pendulum/quiz-answers.md | 11 ++++-- docs/lessons/glowing-pendulum/quiz.md | 2 +- docs/lessons/hack-your-headphones.md | 4 -- .../js => }/lessons/ornament-chain.md | 6 +-- docs/lessons/telegraph.md | 4 -- 7 files changed, 11 insertions(+), 61 deletions(-) rename docs/{reference/js => }/lessons/ornament-chain.md (95%) diff --git a/docs/lessons/classic-beatbox.md b/docs/lessons/classic-beatbox.md index 245242f1..6f5b2e32 100644 --- a/docs/lessons/classic-beatbox.md +++ b/docs/lessons/classic-beatbox.md @@ -11,9 +11,7 @@ Music * [activity](/microbit/lessons/classic-beatbox/activity) * [challenges](/microbit/lessons/classic-beatbox/challenges) -## Class -Year 7 ## Prior learning/place of lesson in scheme of work @@ -23,40 +21,3 @@ Learn how to make a beatbox music player using pins P1 and P2. We will be learni * learn how to code music on the BBC micro:bit -## Progression Pathways / Computational Thinking Framework - -#### Algorithms - -* Uses diagrams to express solutions.(AB) -* Represents solutions using a structured notation (AL) (AB) - -#### Programming & Development - -* Creates programs that implement algorithms to achieve given goals (AL) -* Selects the appropriate data types(AL) (AB - -#### Communication Networks - -* Demonstrates responsible use of technologies and online services, and knows a range of ways to report concerns Understands how search engines rank search results (AL) - -#### Information Technology - -* Collects, organizes, and presents data and information in digital content (AB) -* Makes appropriate improvements to solutions based on feedback received, and can comment on the success of the solution (EV) - -Computational Thinking Concept: AB = Abstraction; DE = Decomposition; AL = Algorithmic Thinking; EV = Evaluation; GE = Generalisation - -## Activity - -* time: 20 min. -* [activity](/microbit/lessons/classic-beatbox/activity) - -## Extended Activity - -* time: 20 min. -* [challenges](/microbit/lessons/classic-beatbox/challenges) - -## Homework - -* Extended Activity: [challenges](/microbit/lessons/classic-beatbox/challenges) - diff --git a/docs/lessons/glowing-pendulum.md b/docs/lessons/glowing-pendulum.md index b35c253a..b1c522e6 100644 --- a/docs/lessons/glowing-pendulum.md +++ b/docs/lessons/glowing-pendulum.md @@ -10,10 +10,8 @@ Acceleration * [activity](/microbit/lessons/glowing-pendulum/activity) * [challenges](/microbit/lessons/glowing-pendulum/challenges) - -## Class - -Year 7 +* [quiz](/microbit/lessons/glowing-pendulum/quiz) +* [quiz answers](/microbit/lessons/glowing-pendulum/quiz-answers) ## Prior learning/place of lesson in scheme of work diff --git a/docs/lessons/glowing-pendulum/quiz-answers.md b/docs/lessons/glowing-pendulum/quiz-answers.md index 479fb667..e5b980f6 100644 --- a/docs/lessons/glowing-pendulum/quiz-answers.md +++ b/docs/lessons/glowing-pendulum/quiz-answers.md @@ -29,16 +29,19 @@ let acceleration = input.acceleration("y")
```blocks -let acceleration = math.abs(acceleration) +let acceleration = input.acceleration(Dimension.X) +let accelerationAbsolute = Math.abs(acceleration) ``` -## 4. Write the code that uses the acceleration value from question #3 to set the brightness on the BBC micro:bit. +## 4. Write the code to use the acceleration value from question 3 to set the brightness on the BBC micro:bit.
```blocks -let acceleration = acceleration / 4 -led.setBrightness(acceleration) +let accelerationX = input.acceleration(Dimension.X) +let accelerationAbsolute = Math.abs(accelerationX) +let accelerationDivided = accelerationX / 4 +led.setBrightness(accelerationX) ``` ## 5. Write the code that tuns all the LEDs on (as the image displays below) diff --git a/docs/lessons/glowing-pendulum/quiz.md b/docs/lessons/glowing-pendulum/quiz.md index 2ca42dff..f911ff4d 100644 --- a/docs/lessons/glowing-pendulum/quiz.md +++ b/docs/lessons/glowing-pendulum/quiz.md @@ -22,7 +22,7 @@ Answer the questions while completing the tutorial. Pay attention to the dialogu
-## 4. Write the code that uses the acceleration value from question #3 to set the brightness on the BBC micro:bit. +## 4. Write the code to include acceleration value question 3 to set the brightness on the BBC micro:bit.
diff --git a/docs/lessons/hack-your-headphones.md b/docs/lessons/hack-your-headphones.md index 90297fdf..9fe850ac 100644 --- a/docs/lessons/hack-your-headphones.md +++ b/docs/lessons/hack-your-headphones.md @@ -10,10 +10,6 @@ Hack your headphone * [activity](/microbit/lessons/hack-your-headphones/activity) -## Class - -Year 7 - ## Prior learning/place of lesson in scheme of work Learn how to convert your BBC micro:bit into a music player using pins P0 and GND, headphones (or speakers), as well as crocodile clips (or spring clips). diff --git a/docs/reference/js/lessons/ornament-chain.md b/docs/lessons/ornament-chain.md similarity index 95% rename from docs/reference/js/lessons/ornament-chain.md rename to docs/lessons/ornament-chain.md index 0b008445..20f3f416 100644 --- a/docs/reference/js/lessons/ornament-chain.md +++ b/docs/lessons/ornament-chain.md @@ -4,16 +4,12 @@ display beautiful images on the BBC micro:bit #var #pause #docs ## Topic -Telegraph +Network devices ## Quick Links * [activity](/microbit/lessons/ornament-chain/activity) -## Class - -Year 7 - ## Prior learning/place of lesson in scheme of work Learn how to convert your BBC micro:bit into a telegraph using a second BBC micro:bit as well as pin P1, P2, 3V, GND, and crocodile clips (or spring clips). The connect BBC micro:bit uses pins P1, P2, 3V, GND. diff --git a/docs/lessons/telegraph.md b/docs/lessons/telegraph.md index adcd5537..5149f03f 100644 --- a/docs/lessons/telegraph.md +++ b/docs/lessons/telegraph.md @@ -10,10 +10,6 @@ Telegraph * [activity](/microbit/lessons/telegraph/activity) -## Class - -Year 7 - ## Prior learning/place of lesson in scheme of work Learn how to convert your BBC micro:bit into a telegraph using a second BBC micro:bit as well as pin P1, P2, 3V, GND, and crocodile clips (or spring clips). The connect BBC micro:bit uses pins P1, P2, 3V, GND. From 03d7799afcb8fadd60c8e81dda40c1d143ef7d9f Mon Sep 17 00:00:00 2001 From: Michal Moskal Date: Wed, 30 Mar 2016 16:27:54 -0700 Subject: [PATCH 09/12] Switching to 0.2 - with the new C++ architecture --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 08e00661..0c61fcde 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "kindscript-microbit", - "version": "0.0.17", + "version": "0.2.0", "description": "BBC micro:bit target for KindScript", "keywords": [ "JavaScript", From bbb153305a27102430aea4a2c0b382aee8527fbf Mon Sep 17 00:00:00 2001 From: Michal Moskal Date: Wed, 30 Mar 2016 16:29:51 -0700 Subject: [PATCH 10/12] Bump kindscript to 0.2.1 --- package.json | 66 ++++++++++++++++++++++++++-------------------------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/package.json b/package.json index 0c61fcde..fe696162 100644 --- a/package.json +++ b/package.json @@ -1,35 +1,35 @@ { - "name": "kindscript-microbit", - "version": "0.2.0", - "description": "BBC micro:bit target for KindScript", - "keywords": [ - "JavaScript", - "education", - "microbit" - ], - "repository": { - "type": "git", - "url": "git+https://github.com/Microsoft/kindscript-microbit.git" - }, - "author": "", - "license": "MIT", - "homepage": "https://github.com/Microsoft/kindscript-microbit#readme", - "files": [ - "README.md", - "kindtarget.json", - "kindtheme.json", - "built/*.js", - "built/*.json", - "built/*.d.ts", - "sim/public", - "docs/*.md", - "docs/*/*.md", - "docs/*/*/*.md" - ], - "devDependencies": { - "typescript": "^1.8.7" - }, - "dependencies": { - "kindscript": "0.1.123" - } + "name": "kindscript-microbit", + "version": "0.2.0", + "description": "BBC micro:bit target for KindScript", + "keywords": [ + "JavaScript", + "education", + "microbit" + ], + "repository": { + "type": "git", + "url": "git+https://github.com/Microsoft/kindscript-microbit.git" + }, + "author": "", + "license": "MIT", + "homepage": "https://github.com/Microsoft/kindscript-microbit#readme", + "files": [ + "README.md", + "kindtarget.json", + "kindtheme.json", + "built/*.js", + "built/*.json", + "built/*.d.ts", + "sim/public", + "docs/*.md", + "docs/*/*.md", + "docs/*/*/*.md" + ], + "devDependencies": { + "typescript": "^1.8.7" + }, + "dependencies": { + "kindscript": "0.2.1" + } } From ac5800246279a9f004adc6504328407d249ffcce Mon Sep 17 00:00:00 2001 From: Michal Moskal Date: Wed, 30 Mar 2016 16:29:52 -0700 Subject: [PATCH 11/12] 0.2.1 --- package.json | 66 ++++++++++++++++++++++++++-------------------------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/package.json b/package.json index fe696162..c0c56a2f 100644 --- a/package.json +++ b/package.json @@ -1,35 +1,35 @@ { - "name": "kindscript-microbit", - "version": "0.2.0", - "description": "BBC micro:bit target for KindScript", - "keywords": [ - "JavaScript", - "education", - "microbit" - ], - "repository": { - "type": "git", - "url": "git+https://github.com/Microsoft/kindscript-microbit.git" - }, - "author": "", - "license": "MIT", - "homepage": "https://github.com/Microsoft/kindscript-microbit#readme", - "files": [ - "README.md", - "kindtarget.json", - "kindtheme.json", - "built/*.js", - "built/*.json", - "built/*.d.ts", - "sim/public", - "docs/*.md", - "docs/*/*.md", - "docs/*/*/*.md" - ], - "devDependencies": { - "typescript": "^1.8.7" - }, - "dependencies": { - "kindscript": "0.2.1" - } + "name": "kindscript-microbit", + "version": "0.2.1", + "description": "BBC micro:bit target for KindScript", + "keywords": [ + "JavaScript", + "education", + "microbit" + ], + "repository": { + "type": "git", + "url": "git+https://github.com/Microsoft/kindscript-microbit.git" + }, + "author": "", + "license": "MIT", + "homepage": "https://github.com/Microsoft/kindscript-microbit#readme", + "files": [ + "README.md", + "kindtarget.json", + "kindtheme.json", + "built/*.js", + "built/*.json", + "built/*.d.ts", + "sim/public", + "docs/*.md", + "docs/*/*.md", + "docs/*/*/*.md" + ], + "devDependencies": { + "typescript": "^1.8.7" + }, + "dependencies": { + "kindscript": "0.2.1" + } } From 545fff44d0dcd620cfb8c8edfb7e9a28115fa5a2 Mon Sep 17 00:00:00 2001 From: Michael Elliot Braun Date: Wed, 30 Mar 2016 16:32:16 -0700 Subject: [PATCH 12/12] updated static lesson page --- docs/lessons.md | 3 +-- docs/lessons/catch-the-egg-game.md | 4 ++-- .../{challenges.md => activity.md} | 12 ++---------- docs/lessons/catch-the-egg-game/quiz.md | 2 +- 4 files changed, 6 insertions(+), 15 deletions(-) rename docs/lessons/catch-the-egg-game/{challenges.md => activity.md} (97%) diff --git a/docs/lessons.md b/docs/lessons.md index 0aa418d3..55ba1f2a 100644 --- a/docs/lessons.md +++ b/docs/lessons.md @@ -57,12 +57,11 @@ Overview of lessons for the BBC micro:bit. * [Hack your Headphones](/microbit/lessons/hack-your-headphones), create music on the BBC micro:bit by hacking your headphones * [Banana Keyboard](/microbit/lessons/banana-keyboard), create music with fruits * [Telegraph](/microbit/lessons/telegraph), play the telegraph game between two BBC micro:bits -* [Ornament Chain](/microbit/lessons/ornament-chain), play the ornament chain game between two BBC micro:bits ## Advanced * [Hero](/microbit/lessons/hero), reconstruct the classic arcade game pac man with the BBC micro:bit - +* [Catch the Egg](/microbit/lessons/catch-the-egg-game), reconstruct the classic game of Catch the Egg with the BBC micro:bit ### ~ ### @section full diff --git a/docs/lessons/catch-the-egg-game.md b/docs/lessons/catch-the-egg-game.md index c0162f4b..86e32b06 100644 --- a/docs/lessons/catch-the-egg-game.md +++ b/docs/lessons/catch-the-egg-game.md @@ -10,9 +10,9 @@ Variables ## Quick Links +* [activity](/microbit/lessons/catch-the-egg-game/activity) * [quiz](/microbit/lessons/catch-the-egg-game/quiz) * [quiz answers](/microbit/lessons/catch-the-egg-game/quiz-answers) -* [challenges](/microbit/lessons/catch-the-egg-game/challenges) ## Prior learning/place of lesson in scheme of work @@ -35,7 +35,7 @@ Learn how to create a catch the egg game game with **plot**, `led->plot` , **unp ## Objectives -* learn how to create a global variable as a place where you can store data so that you can use it later in your code, accessible across functions and in nested code blocks +* learn how to create a variable as a place where you can store data so that you can use it later in your code, accessible across functions and in nested code blocks * learn how to repeat code in the background forever * learn how to turn off a LED light on the LED screen * learn how to turn on a LED light on the LED screen diff --git a/docs/lessons/catch-the-egg-game/challenges.md b/docs/lessons/catch-the-egg-game/activity.md similarity index 97% rename from docs/lessons/catch-the-egg-game/challenges.md rename to docs/lessons/catch-the-egg-game/activity.md index 72fc8b7a..ddf37fe6 100644 --- a/docs/lessons/catch-the-egg-game/challenges.md +++ b/docs/lessons/catch-the-egg-game/activity.md @@ -31,14 +31,6 @@ basic.forever(() => { ### Challenge 1 -Let's start by adding the **game** library. - -### ~ - -### ~avatar avatar improvised - -### Challenge 2 - Let's use an **IF** statement to detect if the egg and the basket are lined up. Now that we know when an egg is caught, we can keep track of the score! We need to use the `add score` function built into the game library to add `1` point for every egg that is caught. However, let's not forget to `remove life` if an egg falls off the display before it's caught! @@ -77,7 +69,7 @@ basic.forever(() => { ### ~avatar avatar encourage -### Challenge 3 +### Challenge 2 Catching eggs gets easier with practice so let's make the eggs fall faster every 5 catches. We can do this by tracking how long the egg pauses in each position while falling with a global variable called **falling pause**. Let's create this variable and set it to `300` initially. Don't forget to also create a condition that will be true every 5 catches. @@ -116,7 +108,7 @@ basic.forever(() => { ### ~avatar avatar surprised -### Challenge 4 +### Challenge 3 ### @video td/videos/catch-the-egg-game-4 diff --git a/docs/lessons/catch-the-egg-game/quiz.md b/docs/lessons/catch-the-egg-game/quiz.md index 35a087f2..6965c32a 100644 --- a/docs/lessons/catch-the-egg-game/quiz.md +++ b/docs/lessons/catch-the-egg-game/quiz.md @@ -6,7 +6,7 @@ Programming a game of catch the egg using the accelerometer. ## Directions -Use this activity document to guide your work in the [catch the egg challenges](/microbit/lessons/catch-the-egg-game/challenges) +Use this activity document to guide your work in the [catch the egg challenges](/microbit/lessons/catch-the-egg-game/activity) Answer the questions while completing the tutorial. Pay attention to the dialogues!