diff --git a/cmds/cmds.ts b/cmds/cmds.ts index c862c7a6..be21defb 100644 --- a/cmds/cmds.ts +++ b/cmds/cmds.ts @@ -13,20 +13,20 @@ export function deployCoreAsync(res: ts.pxtc.CompileResult) { return getBitDrivesAsync() .then(drives => { if (drives.length == 0) { - let msg = "cannot find any drives to deploy to"; - console.log(msg); - return Promise.reject(new Error(msg)); + console.log("cannot find any drives to deploy to"); + return Promise.resolve(0); } - console.log(`copy ${ts.pxtc.BINARY_HEX} to ` + drives.join(", ")) + console.log(`copy ${ts.pxtc.BINARY_HEX} to ` + drives.join(", ")); - return Promise.map(drives, d => - writeFileAsync(d + ts.pxtc.BINARY_HEX, res.outfiles[ts.pxtc.BINARY_HEX]) - .then(() => { - console.log("wrote hex file to " + d) - })) - }) - .then(() => { }) + let writeHexFile = (filename: string) => { + return writeFileAsync(filename + ts.pxtc.BINARY_HEX, res.outfiles[ts.pxtc.BINARY_HEX]) + .then(() => console.log("wrote hex file to " + filename)); + }; + + return Promise.map(drives, d => writeHexFile(d)) + .then(() => drives.length); + }); } function getBitDrivesAsync(): Promise { diff --git a/docs/device/crocodile-clips.md b/docs/device/crocodile-clips.md index f9a90413..04070a35 100644 --- a/docs/device/crocodile-clips.md +++ b/docs/device/crocodile-clips.md @@ -1,11 +1,40 @@ # crocodile clips -The large holes at the bottom of the board are designed to attach alligator/crocodile clips. -Register an event that will execute whenever the user attaches one side of the crocodile clip to the `GND` pin, then connects and disconnects the unattached side of the crocodile clip to pin `0`, `1`, or `2`. +The large holes at the bottom of the board are designed to attach alligator/crocodile clips +to create electrical circuit with other components. -### Example: on pin pressed with random numbers +# ~hint -This example displays a random number every time the crocodile clip holds `GND` then connects and disconnects the `P0` pin. Each time the crocodile clip is firmly connected and disconnected from pin `P0`, the micro:bit will return a random Number between 0 and the parameter limit +**No crocodile clips!?!?!** Use wires or Aluminium foil! [Read more...](/device/foil-circuits) + +# ~ + + +## Connecting Crocodile Clips + +The hole for ``P0`` and ``GND`` allow to grab the board on the side which makes for a great grip. + +![](/static/mb/device/croc-clips/crocclipsclamped.jpg) + +Pass one jaw in the hole and grab the side of the board with the other jaw. + +![](/static/mb/device/croc-clips/sideclamp.jpg) + +For the center holes, ``P1`` and ``P2``, you can also grab the bottom of the board but they are a bit harder to grip. + +You can also grip the board between the jaws. In which case, you will want to make sure to avoid overlapping the jaws +with the other pins as it will create short-circuit in the board. + +![](/static/mb/device/croc-clips/badclamp.jpg) + +Adding a little tape helps keeping the crocodile clips in place. + +![](/static/mb/device/croc-clips/frontclamp.jpg) + +## Example: on pin pressed with random numbers + +This example displays a random number every time the crocodile clip holds `GND` then connects and disconnects the `P0` pin. +Each time the crocodile clip is firmly connected and disconnected from pin `P0`, the micro:bit will return a random Number between 0 and the parameter limit. ```blocks input.onPinPressed(TouchPin.P0, () => { @@ -13,11 +42,6 @@ input.onPinPressed(TouchPin.P0, () => { }) ``` -### Connecting Crocodile Clips - -![](/static/mb/crocodile-clips-2.jpg) - -### See also - -[micro:bit pins](/device/pins), [pin is pressed](/reference/input/pin-is-pressed), [analog read pin](/reference/pins/analog-read-pin), [analog write pin](/reference/pins/analog-write-pin), [digital read pin](/reference/pins/digital-read-pin), [digital write pin](/reference/pins/digital-write-pin) +## See also +[micro:bit pins](/device/pins) diff --git a/docs/device/error-codes.md b/docs/device/error-codes.md index 16e823c7..0de6c4fe 100644 --- a/docs/device/error-codes.md +++ b/docs/device/error-codes.md @@ -1,7 +1,5 @@ # Error codes -The micro:bit error codes - Your micro:bit may encounter a situation that prevents it from running your code. When this happens, a frowny face will appear on your micro:bit screen (see picture) followed by an error number. Below is a list of error numbers and what they mean: diff --git a/docs/device/foil-circuits.md b/docs/device/foil-circuits.md new file mode 100644 index 00000000..609c1ce9 --- /dev/null +++ b/docs/device/foil-circuits.md @@ -0,0 +1,52 @@ +# foil circuits + +The large holes at the bottom of the board are designed to attach alligator/crocodile clips +to create electrical circuit with other components. + +If you do not have crocodile clips at hand, dyou can use wires or even Aluminium foil to acheive the same result. +We will show you how to connect the micro:bit to headphones using Alumunium foil and tape. + +https://youtu.be/mhXYyPuvpz0 + +### Materials + +* micro:bit and battery pack (you can also power it via USB) +* a small piece of cardboard +* Aluminium foil +* tape + +### Assembly instructions + +Tape the micro:bit and battery pack to the card board. Make sure to remove the batteries while you are building your circuit. + +![](/static/mb/device/croc-clips/microbitattached.jpg) + +Cut the thinest strip of foil possible and roll it into a cable. You can also try to fold, whatever works for you. +Build two of those wires. + +![](/static/mb/device/croc-clips/foilcut.jpg) + +Place the foil wire on the ``GND`` pin and attach with a piece of tape. Press hard to get the best connection between +the foil and the pin board. Make sure the foil is not overlapping with the other pins! + +![](/static/mb/device/croc-clips/groundconnected.jpg) + +Place the second wire on the ``P0`` pin the same way. Make sure the wire does not overlap with the other pins! + +![](/static/mb/device/croc-clips/microbitconnect.jpg) + +Tape the headphone jack connector to the cardboard and roll the wire coming from ``GND`` around the metal base. +Make sure the wire does not touch the other metal rings on the jack. + +![](/static/mb/device/croc-clips/jackground.jpg) + +Tape the second wire on the head of the jack connector. + +![](/static/mb/device/croc-clips/jackconnect.jpg) + +![](/static/mb/device/croc-clips/foilcircuit.jpg) + + +## See also + +[micro:bit pins](/device/pins) diff --git a/docs/projects/flashing-heart.md b/docs/projects/flashing-heart.md index 82335207..42068cf1 100644 --- a/docs/projects/flashing-heart.md +++ b/docs/projects/flashing-heart.md @@ -7,11 +7,12 @@ ```sim basic.forever(() => { basic.showLeds(` -. # . # . -# # # # # -# # # # # -. # # # . -. . # . .`); + . # . # . + # # # # # + # # # # # + . # # # . + . . # . .` + ); basic.pause(500); basic.clearScreen(); basic.pause(500); @@ -29,11 +30,12 @@ Use [show leds](/reference/basic/show-leds) and make your code look like this: ```blocks basic.showLeds(` -. # . # . -# # # # # -# # # # # -. # # # . -. . # . .`); + . # . # . + # # # # # + # # # # # + . # # # . + . . # . .` + ); ``` ## Step 2 @@ -42,11 +44,11 @@ Add a [pause](/reference/basic/pause) to wait and [clear screen](/reference/basi ```blocks basic.showLeds(` -. # . # . -# # # # # -# # # # # -. # # # . -. . # . .`); + . # . # . + # # # # # + # # # # # + . # # # . + . . # . .`); basic.pause(500); basic.clearScreen(); ``` @@ -58,11 +60,12 @@ Put a [forever loop](/reference/basic/forever) around it. ```blocks basic.forever(() => { basic.showLeds(` -. # . # . -# # # # # -# # # # # -. # # # . -. . # . .`); + . # . # . + # # # # # + # # # # # + . # # # . + . . # . .` + ); basic.pause(500); basic.clearScreen(); }) @@ -75,11 +78,12 @@ Add a [pause](/reference/basic/pause) to wait after clearing the screen. ```blocks basic.forever(() => { basic.showLeds(` -. # . # . -# # # # # -# # # # # -. # # # . -. . # . .`); + . # . # . + # # # # # + # # # # # + . # # # . + . . # . .` + ); basic.pause(500); basic.clearScreen(); basic.pause(500); @@ -94,20 +98,22 @@ Add a second image of a broken heart. ```blocks basic.forever(() => { basic.showLeds(` -. # . # . -# # # # # -# # # # # -. # # # . -. . # . .`); + . # . # . + # # # # # + # # # # # + . # # # . + . . # . .` + ); basic.pause(500); basic.clearScreen(); basic.pause(500); basic.showLeds(` -. # . # . -# . # # # -# . . . # -. # # # . -. . # . .`); + . # . # . + # . # # # + # . . . # + . # # # . + . . # . .` + ); basic.pause(500); basic.clearScreen(); basic.pause(500); diff --git a/docs/projects/hack-your-headphones.md b/docs/projects/hack-your-headphones.md index 32eeebae..1d5bef04 100644 --- a/docs/projects/hack-your-headphones.md +++ b/docs/projects/hack-your-headphones.md @@ -24,6 +24,12 @@ Build your own music player micro:bit from headphones. * [Connect your headphone](/projects/hack-your-headphone/making) * [Play sounds!]() +# ~hint + +**No crocodile clips!?!?!** Use wires or Aluminium foil! [Read more...](/device/foil-circuits) + +# ~ + ### ~button /projects/hack-your-headphones/making Let's get started! diff --git a/docs/projects/hack-your-headphones/making.md b/docs/projects/hack-your-headphones/making.md index a2dfc05a..8148e0d8 100644 --- a/docs/projects/hack-your-headphones/making.md +++ b/docs/projects/hack-your-headphones/making.md @@ -6,6 +6,12 @@ Did you know you could attach your headhpones to the micro:bit to generate sound ### ~ +# ~hint + +**No crocodile clips!?!?!** Use wires or Aluminium foil! [Read more...](/device/foil-circuits) + +# ~ + ### Step 1 ![](/static/mb/lessons/banana-keyboard-1.png) diff --git a/docs/projects/smiley-buttons.md b/docs/projects/smiley-buttons.md index 7adf4279..afda51f2 100644 --- a/docs/projects/smiley-buttons.md +++ b/docs/projects/smiley-buttons.md @@ -10,11 +10,12 @@ Use [show leds](/reference/basic/show-leds) to make a smiley face: ```blocks basic.showLeds(` -. # . # . -. # . # . -. . . . . -# . . . # -. # # # .`); + . # . # . + . # . # . + . . . . . + # . . . # + . # # # .` + ); ``` ## Step 2 @@ -24,18 +25,20 @@ frowny face inside it: ```blocks basic.showLeds(` -. # . # . -. # . # . -. . . . . -# . . . # -. # # # .`); -input.onButtonPressed(Button.A, () => { - basic.showLeds(` . # . # . . # . # . . . . . . - . # # # . - # . . . #`); + # . . . # + . # # # .` + ); +input.onButtonPressed(Button.A, () => { + basic.showLeds(` + . # . # . + . # . # . + . . . . . + . # # # . + # . . . #` + ); }); ``` @@ -45,25 +48,28 @@ Now add blocks so that when [button B is pressed](/reference/input/button-is-pre ```blocks basic.showLeds(` -. # . # . -. # . # . -. . . . . -# . . . # -. # # # .`); -input.onButtonPressed(Button.A, () => { - basic.showLeds(` - . # . # . - . # . # . - . . . . . - . # # # . - # . . . #`); -}); -input.onButtonPressed(Button.B, () => { - basic.showLeds(` . # . # . . # . # . . . . . . # . . . # - . # # # .`); + . # # # .` + ); +input.onButtonPressed(Button.A, () => { + basic.showLeds(` + . # . # . + . # . # . + . . . . . + . # # # . + # . . . #` + ); +}); +input.onButtonPressed(Button.B, () => { + basic.showLeds(` + . # . # . + . # . # . + . . . . . + # . . . # + . # # # .` + ); }); ``` diff --git a/docs/static/mb/device/croc-clips/badclamp.jpg b/docs/static/mb/device/croc-clips/badclamp.jpg new file mode 100644 index 00000000..315d4efe Binary files /dev/null and b/docs/static/mb/device/croc-clips/badclamp.jpg differ diff --git a/docs/static/mb/device/croc-clips/crocclipsclamped.jpg b/docs/static/mb/device/croc-clips/crocclipsclamped.jpg new file mode 100644 index 00000000..97c0a42a Binary files /dev/null and b/docs/static/mb/device/croc-clips/crocclipsclamped.jpg differ diff --git a/docs/static/mb/device/croc-clips/foilcircuit.jpg b/docs/static/mb/device/croc-clips/foilcircuit.jpg new file mode 100644 index 00000000..a2f8a1af Binary files /dev/null and b/docs/static/mb/device/croc-clips/foilcircuit.jpg differ diff --git a/docs/static/mb/device/croc-clips/foilcut.jpg b/docs/static/mb/device/croc-clips/foilcut.jpg new file mode 100644 index 00000000..ea6dc2f0 Binary files /dev/null and b/docs/static/mb/device/croc-clips/foilcut.jpg differ diff --git a/docs/static/mb/device/croc-clips/frontclamp.jpg b/docs/static/mb/device/croc-clips/frontclamp.jpg new file mode 100644 index 00000000..eca31b20 Binary files /dev/null and b/docs/static/mb/device/croc-clips/frontclamp.jpg differ diff --git a/docs/static/mb/device/croc-clips/groundconnected.jpg b/docs/static/mb/device/croc-clips/groundconnected.jpg new file mode 100644 index 00000000..43f64c9a Binary files /dev/null and b/docs/static/mb/device/croc-clips/groundconnected.jpg differ diff --git a/docs/static/mb/device/croc-clips/jackconnect.jpg b/docs/static/mb/device/croc-clips/jackconnect.jpg new file mode 100644 index 00000000..ac84336b Binary files /dev/null and b/docs/static/mb/device/croc-clips/jackconnect.jpg differ diff --git a/docs/static/mb/device/croc-clips/jackground.jpg b/docs/static/mb/device/croc-clips/jackground.jpg new file mode 100644 index 00000000..b791178b Binary files /dev/null and b/docs/static/mb/device/croc-clips/jackground.jpg differ diff --git a/docs/static/mb/device/croc-clips/microbitattached.jpg b/docs/static/mb/device/croc-clips/microbitattached.jpg new file mode 100644 index 00000000..35c88ecf Binary files /dev/null and b/docs/static/mb/device/croc-clips/microbitattached.jpg differ diff --git a/docs/static/mb/device/croc-clips/microbitconnect.jpg b/docs/static/mb/device/croc-clips/microbitconnect.jpg new file mode 100644 index 00000000..5c7532df Binary files /dev/null and b/docs/static/mb/device/croc-clips/microbitconnect.jpg differ diff --git a/docs/static/mb/device/croc-clips/sideclamp.jpg b/docs/static/mb/device/croc-clips/sideclamp.jpg new file mode 100644 index 00000000..24db12cc Binary files /dev/null and b/docs/static/mb/device/croc-clips/sideclamp.jpg differ diff --git a/libs/bluetooth/_locales/microbit-bluetooth-jsdoc-strings.json b/libs/bluetooth/_locales/bluetooth-jsdoc-strings.json similarity index 100% rename from libs/bluetooth/_locales/microbit-bluetooth-jsdoc-strings.json rename to libs/bluetooth/_locales/bluetooth-jsdoc-strings.json diff --git a/libs/bluetooth/_locales/microbit-bluetooth-strings.json b/libs/bluetooth/_locales/bluetooth-strings.json similarity index 100% rename from libs/bluetooth/_locales/microbit-bluetooth-strings.json rename to libs/bluetooth/_locales/bluetooth-strings.json diff --git a/libs/core/_locales/ar/microbit-strings.json b/libs/core/_locales/ar/core-strings.json similarity index 100% rename from libs/core/_locales/ar/microbit-strings.json rename to libs/core/_locales/ar/core-strings.json diff --git a/libs/core/_locales/microbit-jsdoc-strings.json b/libs/core/_locales/core-jsdoc-strings.json similarity index 100% rename from libs/core/_locales/microbit-jsdoc-strings.json rename to libs/core/_locales/core-jsdoc-strings.json diff --git a/libs/core/_locales/microbit-strings.json b/libs/core/_locales/core-strings.json similarity index 100% rename from libs/core/_locales/microbit-strings.json rename to libs/core/_locales/core-strings.json diff --git a/libs/core/_locales/de/microbit-strings.json b/libs/core/_locales/de/core-strings.json similarity index 100% rename from libs/core/_locales/de/microbit-strings.json rename to libs/core/_locales/de/core-strings.json diff --git a/libs/core/_locales/es-ES/microbit-strings.json b/libs/core/_locales/es-ES/core-strings.json similarity index 100% rename from libs/core/_locales/es-ES/microbit-strings.json rename to libs/core/_locales/es-ES/core-strings.json diff --git a/libs/core/_locales/fr/microbit-jsdoc-strings.json b/libs/core/_locales/fr/core-jsdoc-strings.json similarity index 100% rename from libs/core/_locales/fr/microbit-jsdoc-strings.json rename to libs/core/_locales/fr/core-jsdoc-strings.json diff --git a/libs/core/_locales/ja/microbit-strings.json b/libs/core/_locales/ja/core-jsdoc-strings.json similarity index 100% rename from libs/core/_locales/ja/microbit-strings.json rename to libs/core/_locales/ja/core-jsdoc-strings.json diff --git a/libs/core/_locales/ja/core-strings.json b/libs/core/_locales/ja/core-strings.json new file mode 100644 index 00000000..ddd6ab34 --- /dev/null +++ b/libs/core/_locales/ja/core-strings.json @@ -0,0 +1,80 @@ +{ + "Math.randomBoolean|block": "pick random true or false", + "Math|block": "Math", + "String.fromCharCode|block": "text from char code %code", + "String|block": "String", + "basic.clearScreen|block": "clear screen", + "basic.forever|block": "forever", + "basic.pause|block": "pause (ms) %pause", + "basic.showLeds|block": "show leds", + "basic.showNumber|block": "show|number %number", + "basic.showString|block": "show|string %text", + "basic|block": "basic", + "control.inBackground|block": "run in background", + "control.reset|block": "reset", + "control.waitMicros|block": "wait (µs)%micros", + "control|block": "control", + "game.addScore|block": "change score by|%points", + "game.gameOver|block": "game over", + "game.score|block": "score", + "game.startCountdown|block": "start countdown|(ms) %duration", + "game|block": "game", + "images.createBigImage|block": "create big image", + "images.createImage|block": "create image", + "images|block": "images", + "input.acceleration|block": "acceleration (mg)|%NAME", + "input.buttonIsPressed|block": "button|%NAME|is pressed", + "input.compassHeading|block": "compass heading (°)", + "input.lightLevel|block": "light level", + "input.magneticForce|block": "magnetic force (µT)|%NAME", + "input.onButtonPressed|block": "on button|%NAME|pressed", + "input.onGesture|block": "on |%NAME", + "input.onPinPressed|block": "on pin %NAME|pressed", + "input.onPinReleased|block": "on pin %NAME|released", + "input.pinIsPressed|block": "pin %NAME|is pressed", + "input.rotation|block": "rotation (°)|%NAME", + "input.runningTime|block": "running time (ms)", + "input.setAccelerometerRange|block": "set accelerometer|range %range", + "input.temperature|block": "temperature (°C)", + "input|block": "input", + "led.brightness|block": "brightness", + "led.plotBarGraph|block": "plot bar graph of %value |up to %high", + "led.plot|block": "plot|x %x|y %y", + "led.point|block": "point|x %x|y %y", + "led.setBrightness|block": "set brightness %value", + "led.stopAnimation|block": "stop animation", + "led.toggle|block": "toggle|x %x|y %y", + "led.unplot|block": "unplot|x %x|y %y", + "led|block": "led", + "music.beat|block": "%fraction|beat", + "music.changeTempoBy|block": "change tempo by (bpm)|%value", + "music.noteFrequency|block": "%note", + "music.playTone|block": "play|tone %note=device_note|for %duration=device_beat", + "music.rest|block": "rest(ms)|%duration=device_beat", + "music.ringTone|block": "ring tone (Hz)|%note=device_note", + "music.setTempo|block": "set tempo to (bpm)|%value", + "music.tempo|block": "tempo (bpm)", + "music|block": "music", + "pins.analogReadPin|block": "analog read|pin %name", + "pins.analogSetPeriod|block": "analog set period|pin %pin|to (µs)%micros", + "pins.analogWritePin|block": "analog write|pin %name|to %value", + "pins.digitalReadPin|block": "digital read|pin %name", + "pins.digitalWritePin|block": "digital write|pin %name|to %value", + "pins.i2cReadNumber|block": "i2c read number|at address %address|of format %format=i2c_sizeof", + "pins.i2cWriteNumber|block": "i2c write number|at address %address|with value %value|of format %format=i2c_sizeof", + "pins.map|block": "map %value|from low %fromLow|from high %fromHigh|to low %toLow|to high %toHigh", + "pins.onPulsed|block": "on|pin %pin|pulsed %pulse", + "pins.pulseDuration|block": "pulse duration (µs)", + "pins.servoSetPulse|block": "servo set pulse|pin %value|to (µs) %micros", + "pins.servoWritePin|block": "servo write|pin %name|to %value", + "pins.setPull|block": "set pull|pin %pin|to %pull", + "pins.spiWrite|block": "spi write %value", + "pins|block": "pins", + "serial.readLine|block": "serial read line", + "serial.redirect|block": "serial redirect to|TX %tx|RX %rx|at baud rate %rate", + "serial.writeLine|block": "serial|write line %text", + "serial.writeNumber|block": "serial|write number %value", + "serial.writeString|block": "serial write string %text", + "serial.writeValue|block": "serial|write value %name|= %value", + "serial|block": "serial" +} \ No newline at end of file diff --git a/libs/core/pxt.json b/libs/core/pxt.json index 395e146f..7f123c70 100644 --- a/libs/core/pxt.json +++ b/libs/core/pxt.json @@ -33,7 +33,9 @@ "parts/speaker.svg", "parts/headphone.svg", "parts/dcmotor.svg", - "_locales/fr/microbit-jsdoc-strings.json" + "_locales/ja/core-jsdoc-strings.json", + "_locales/ja/core-strings.json", + "_locales/fr/core-jsdoc-strings.json" ], "public": true, "dependencies": {}, diff --git a/libs/devices/_locales/microbit-devices-jsdoc-strings.json b/libs/devices/_locales/devices-jsdoc-strings.json similarity index 100% rename from libs/devices/_locales/microbit-devices-jsdoc-strings.json rename to libs/devices/_locales/devices-jsdoc-strings.json diff --git a/libs/devices/_locales/microbit-devices-strings.json b/libs/devices/_locales/devices-strings.json similarity index 100% rename from libs/devices/_locales/microbit-devices-strings.json rename to libs/devices/_locales/devices-strings.json diff --git a/libs/radio/_locales/microbit-radio-jsdoc-strings.json b/libs/radio/_locales/radio-jsdoc-strings.json similarity index 100% rename from libs/radio/_locales/microbit-radio-jsdoc-strings.json rename to libs/radio/_locales/radio-jsdoc-strings.json diff --git a/libs/radio/_locales/microbit-radio-strings.json b/libs/radio/_locales/radio-strings.json similarity index 100% rename from libs/radio/_locales/microbit-radio-strings.json rename to libs/radio/_locales/radio-strings.json