diff --git a/.vscode/settings.json b/.vscode/settings.json index f782196d..373c9928 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -16,5 +16,6 @@ "**/pxt_modules/**": true }, "tslint.enable": true, - "tslint.rulesDirectory": "node_modules/tslint-microsoft-contrib" + "tslint.rulesDirectory": "node_modules/tslint-microsoft-contrib", + "typescript.tsdk": "./node_modules/typescript/lib" } \ No newline at end of file diff --git a/docfiles/apptracking.html b/docfiles/apptracking.html index 159aa331..9517ea8a 100644 --- a/docfiles/apptracking.html +++ b/docfiles/apptracking.html @@ -2,5 +2,5 @@ (function(e,b){if(!b.__SV){var a,f,i,g;window.mixpanel=b;b._i=[];b.init=function(a,e,d){function f(b,h){var a=h.split(".");2==a.length&&(b=b[a[0]],h=a[1]);b[h]=function(){b.push([h].concat(Array.prototype.slice.call(arguments,0)))}}var c=b;"undefined"!==typeof d?c=b[d]=[]:d="mixpanel";c.people=c.people||[];c.toString=function(b){var a="mixpanel";"mixpanel"!==d&&(a+="."+d);b||(a+=" (stub)");return a};c.people.toString=function(){return c.toString(1)+".people (stub)"};i="disable time_event track track_pageview track_links track_forms register register_once alias unregister identify name_tag set_config reset people.set people.set_once people.increment people.append people.union people.track_charge people.clear_charges people.delete_user".split(" "); for(g=0;g diff --git a/docfiles/tracking.html b/docfiles/tracking.html index 548da3a0..cb37031e 100644 --- a/docfiles/tracking.html +++ b/docfiles/tracking.html @@ -2,5 +2,5 @@ (function(e,b){if(!b.__SV){var a,f,i,g;window.mixpanel=b;b._i=[];b.init=function(a,e,d){function f(b,h){var a=h.split(".");2==a.length&&(b=b[a[0]],h=a[1]);b[h]=function(){b.push([h].concat(Array.prototype.slice.call(arguments,0)))}}var c=b;"undefined"!==typeof d?c=b[d]=[]:d="mixpanel";c.people=c.people||[];c.toString=function(b){var a="mixpanel";"mixpanel"!==d&&(a+="."+d);b||(a+=" (stub)");return a};c.people.toString=function(){return c.toString(1)+".people (stub)"};i="disable time_event track track_pageview track_links track_forms register register_once alias unregister identify name_tag set_config reset people.set people.set_once people.increment people.append people.union people.track_charge people.clear_charges people.delete_user".split(" "); for(g=0;g diff --git a/docs/reference.md b/docs/reference.md index ef289ef6..4482a39b 100644 --- a/docs/reference.md +++ b/docs/reference.md @@ -10,6 +10,10 @@ input.onButtonPressed(Button.A, () => { music.playTone(0, 0); led.plot(0, 0); radio.sendNumber(0); +``` +## Advanced + +```namespaces game.addScore(1); images.createImage(` . . . . . @@ -24,7 +28,8 @@ control.inBackground(() => { }); ``` -## Advanced + +## Bluetooth ```namespaces devices.tellCameraTo(MesCameraEvent.TakePhoto); diff --git a/libs/core/input.cpp b/libs/core/input.cpp index 3d8637ba..5e6a7f11 100644 --- a/libs/core/input.cpp +++ b/libs/core/input.cpp @@ -143,7 +143,6 @@ namespace input { */ //% help=input/on-pin-pressed weight=83 //% blockId=device_pin_event block="on pin %NAME|pressed" icon="\uf094" - //% advanced=true void onPinPressed(TouchPin name, Action body) { auto pin = getPin((int)name); if (!pin) return; @@ -173,7 +172,7 @@ namespace input { /** * Get the button state (pressed or not) for ``A`` and ``B``. */ - //% help=input/button-is-pressed weight=57 + //% help=input/button-is-pressed weight=60 //% block="button|%NAME|is pressed" //% blockId=device_get_button2 //% icon="\uf192" blockGap=8 @@ -192,15 +191,48 @@ namespace input { * Get the pin state (pressed or not). Requires to hold the ground to close the circuit. * @param name pin used to detect the touch */ - //% help=input/pin-is-pressed weight=56 + //% help=input/pin-is-pressed weight=58 //% blockId="device_pin_is_pressed" block="pin %NAME|is pressed" icon="\uf094" //% blockGap=8 - //% advanced=true bool pinIsPressed(TouchPin name) { auto pin = getPin((int)name); return pin && pin->isTouched(); } + int getAccelerationStrength() { + double x = uBit.accelerometer.getX(); + double y = uBit.accelerometer.getY(); + double z = uBit.accelerometer.getZ(); + return (int)sqrt(x*x+y*y+z*z); + } + + /** + * Get the acceleration value in milli-gravitys (when the board is laying flat with the screen up, x=0, y=0 and z=-1024) + * @param dimension TODO + */ + //% help=input/acceleration weight=58 icon="\uf135" + //% blockId=device_acceleration block="acceleration (mg)|%NAME" blockGap=8 + //% parts="accelerometer" + int acceleration(Dimension dimension) { + switch (dimension) { + case Dimension::X: return uBit.accelerometer.getX(); + case Dimension::Y: return uBit.accelerometer.getY(); + case Dimension::Z: return uBit.accelerometer.getZ(); + case Dimension::Strength: return getAccelerationStrength(); + } + return 0; + } + + /** + * Reads the light level applied to the LED screen in a range from ``0`` (dark) to ``255`` bright. + */ + //% help=input/light-level weight=57 + //% blockId=device_get_light_level block="light level" blockGap=8 icon="\uf185" + //% parts="ledmatrix" + int lightLevel() { + return uBit.display.readLightLevel(); + } + /** * Get the current compass heading in degrees. */ @@ -224,48 +256,13 @@ namespace input { return uBit.thermometer.getTemperature(); } - int getAccelerationStrength() { - double x = uBit.accelerometer.getX(); - double y = uBit.accelerometer.getY(); - double z = uBit.accelerometer.getZ(); - return (int)sqrt(x*x+y*y+z*z); - } - - /** - * Get the acceleration value in milli-gravitys (when the board is laying flat with the screen up, x=0, y=0 and z=-1024) - * @param dimension TODO - */ - //% help=input/acceleration weight=54 icon="\uf135" - //% blockId=device_acceleration block="acceleration (mg)|%NAME" blockGap=8 - //% parts="accelerometer" - int acceleration(Dimension dimension) { - switch (dimension) { - case Dimension::X: return uBit.accelerometer.getX(); - case Dimension::Y: return uBit.accelerometer.getY(); - case Dimension::Z: return uBit.accelerometer.getZ(); - case Dimension::Strength: return getAccelerationStrength(); - } - return 0; - } - - - /** - * Reads the light level applied to the LED screen in a range from ``0`` (dark) to ``255`` bright. - */ - //% help=input/light-level weight=53 - //% blockId=device_get_light_level block="light level" blockGap=8 icon="\uf185" - //% parts="ledmatrix" - int lightLevel() { - return uBit.display.readLightLevel(); - } - /** * The pitch or roll of the device, rotation along the ``x-axis`` or ``y-axis``, in degrees. * @param kind TODO */ //% help=input/rotation weight=52 //% blockId=device_get_rotation block="rotation (°)|%NAME" blockGap=8 icon="\uf197" - //% parts="accelerometer" + //% parts="accelerometer" advanced=true int rotation(Rotation kind) { switch (kind) { case Rotation::Pitch: return uBit.accelerometer.getPitch(); diff --git a/libs/core/shims.d.ts b/libs/core/shims.d.ts index 82dd5acd..c649e7de 100644 --- a/libs/core/shims.d.ts +++ b/libs/core/shims.d.ts @@ -239,8 +239,7 @@ declare namespace input { * @param body the code to run when the pin is pressed */ //% help=input/on-pin-pressed weight=83 - //% blockId=device_pin_event block="on pin %NAME|pressed" icon="\uf094" - //% advanced=true shim=input::onPinPressed + //% blockId=device_pin_event block="on pin %NAME|pressed" icon="\uf094" shim=input::onPinPressed function onPinPressed(name: TouchPin, body: () => void): void; /** @@ -256,7 +255,7 @@ declare namespace input { /** * Get the button state (pressed or not) for ``A`` and ``B``. */ - //% help=input/button-is-pressed weight=57 + //% help=input/button-is-pressed weight=60 //% block="button|%NAME|is pressed" //% blockId=device_get_button2 //% icon="\uf192" blockGap=8 @@ -267,12 +266,28 @@ declare namespace input { * Get the pin state (pressed or not). Requires to hold the ground to close the circuit. * @param name pin used to detect the touch */ - //% help=input/pin-is-pressed weight=56 + //% help=input/pin-is-pressed weight=58 //% blockId="device_pin_is_pressed" block="pin %NAME|is pressed" icon="\uf094" - //% blockGap=8 - //% advanced=true shim=input::pinIsPressed + //% blockGap=8 shim=input::pinIsPressed function pinIsPressed(name: TouchPin): boolean; + /** + * Get the acceleration value in milli-gravitys (when the board is laying flat with the screen up, x=0, y=0 and z=-1024) + * @param dimension TODO + */ + //% help=input/acceleration weight=58 icon="\uf135" + //% blockId=device_acceleration block="acceleration (mg)|%NAME" blockGap=8 + //% parts="accelerometer" shim=input::acceleration + function acceleration(dimension: Dimension): number; + + /** + * Reads the light level applied to the LED screen in a range from ``0`` (dark) to ``255`` bright. + */ + //% help=input/light-level weight=57 + //% blockId=device_get_light_level block="light level" blockGap=8 icon="\uf185" + //% parts="ledmatrix" shim=input::lightLevel + function lightLevel(): number; + /** * Get the current compass heading in degrees. */ @@ -291,30 +306,13 @@ declare namespace input { //% parts="thermometer" shim=input::temperature function temperature(): number; - /** - * Get the acceleration value in milli-gravitys (when the board is laying flat with the screen up, x=0, y=0 and z=-1024) - * @param dimension TODO - */ - //% help=input/acceleration weight=54 icon="\uf135" - //% blockId=device_acceleration block="acceleration (mg)|%NAME" blockGap=8 - //% parts="accelerometer" shim=input::acceleration - function acceleration(dimension: Dimension): number; - - /** - * Reads the light level applied to the LED screen in a range from ``0`` (dark) to ``255`` bright. - */ - //% help=input/light-level weight=53 - //% blockId=device_get_light_level block="light level" blockGap=8 icon="\uf185" - //% parts="ledmatrix" shim=input::lightLevel - function lightLevel(): number; - /** * The pitch or roll of the device, rotation along the ``x-axis`` or ``y-axis``, in degrees. * @param kind TODO */ //% help=input/rotation weight=52 //% blockId=device_get_rotation block="rotation (°)|%NAME" blockGap=8 icon="\uf197" - //% parts="accelerometer" shim=input::rotation + //% parts="accelerometer" advanced=true shim=input::rotation function rotation(kind: Rotation): number; /** diff --git a/libs/radio/radio.cpp b/libs/radio/radio.cpp index ab783592..a67980cb 100644 --- a/libs/radio/radio.cpp +++ b/libs/radio/radio.cpp @@ -210,7 +210,7 @@ namespace radio { * @ param id the group id between ``0`` and ``255``, 1 eg */ //% help=radio/set-group - //% weight=10 blockGap=8 + //% weight=10 blockGap=8 advanced=true //% blockId=radio_set_group block="radio set group %ID" void setGroup(int id) { if (radioEnable() != MICROBIT_OK) return; @@ -232,6 +232,7 @@ namespace radio { /** * Set the radio to transmit the serial number in each message. + * @param transmit value indicating if the serial number is transmitted, eg: true */ //% help=radio/set-transmit-serial-number //% weight=8 blockGap=8 diff --git a/libs/radio/shims.d.ts b/libs/radio/shims.d.ts index c2952d94..f483c2d7 100644 --- a/libs/radio/shims.d.ts +++ b/libs/radio/shims.d.ts @@ -89,7 +89,7 @@ declare namespace radio { * @ param id the group id between ``0`` and ``255``, 1 eg */ //% help=radio/set-group - //% weight=10 blockGap=8 + //% weight=10 blockGap=8 advanced=true //% blockId=radio_set_group block="radio set group %ID" shim=radio::setGroup function setGroup(id: number): void; @@ -105,6 +105,7 @@ declare namespace radio { /** * Set the radio to transmit the serial number in each message. + * @param transmit value indicating if the serial number is transmitted, eg: true */ //% help=radio/set-transmit-serial-number //% weight=8 blockGap=8