From 87f1580061e72e0f223ad5226bad4a7fd1c85f37 Mon Sep 17 00:00:00 2001 From: Sam El-Husseini Date: Fri, 3 Mar 2017 23:39:42 -0800 Subject: [PATCH] Enable the slider for a number of apis. (#367) --- libs/core/led.cpp | 4 ++++ libs/core/led.ts | 1 + libs/core/music.ts | 1 + libs/core/pins.cpp | 2 ++ libs/core/shims.d.ts | 18 ++++++++++++------ libs/radio/_locales/radio-jsdoc-strings.json | 3 ++- libs/radio/radio.cpp | 4 +++- libs/radio/shims.d.ts | 6 ++++-- 8 files changed, 29 insertions(+), 10 deletions(-) diff --git a/libs/core/led.cpp b/libs/core/led.cpp index b02c0c15..740d9d85 100644 --- a/libs/core/led.cpp +++ b/libs/core/led.cpp @@ -19,6 +19,7 @@ namespace led { //% help=led/plot weight=78 //% blockId=device_plot block="plot|x %x|y %y" blockGap=8 //% parts="ledmatrix" + //% x.min=0 x.max=4 y.min=0 y.max=4 void plot(int x, int y) { uBit.display.image.setPixelValue(x, y, 1); } @@ -31,6 +32,7 @@ namespace led { //% help=led/unplot weight=77 //% blockId=device_unplot block="unplot|x %x|y %y" blockGap=8 //% parts="ledmatrix" + //% x.min=0 x.max=4 y.min=0 y.max=4 void unplot(int x, int y) { uBit.display.image.setPixelValue(x, y, 0); } @@ -43,6 +45,7 @@ namespace led { //% help=led/point weight=76 //% blockId=device_point block="point|x %x|y %y" //% parts="ledmatrix" + //% x.min=0 x.max=4 y.min=0 y.max=4 bool point(int x, int y) { int pix = uBit.display.image.getPixelValue(x, y); return pix > 0; @@ -67,6 +70,7 @@ namespace led { //% blockId=device_set_brightness block="set brightness %value" //% parts="ledmatrix" //% advanced=true + //% value.min=0 value.max=255 void setBrightness(int value) { uBit.display.setBrightness(value); } diff --git a/libs/core/led.ts b/libs/core/led.ts index a8a55eee..0423f91e 100644 --- a/libs/core/led.ts +++ b/libs/core/led.ts @@ -55,6 +55,7 @@ //% help=led/toggle weight=77 //% blockId=device_led_toggle block="toggle|x %x|y %y" icon="\uf204" blockGap=8 //% parts="ledmatrix" + //% x.min=0 x.max=4 y.min=0 y.max=4 export function toggle(x: number, y: number): void { if (led.point(x, y)) { led.unplot(x, y); diff --git a/libs/core/music.ts b/libs/core/music.ts index 492fcb77..5282f4f0 100644 --- a/libs/core/music.ts +++ b/libs/core/music.ts @@ -247,6 +247,7 @@ namespace music { */ //% help=music/set-tempo weight=38 //% blockId=device_set_tempo block="set tempo to (bpm)|%value" + //% bpm.min=4 bpm.max=400 export function setTempo(bpm: number): void { init(); if (bpm > 0) { diff --git a/libs/core/pins.cpp b/libs/core/pins.cpp index bfc5263c..6c2d3bb3 100644 --- a/libs/core/pins.cpp +++ b/libs/core/pins.cpp @@ -144,6 +144,7 @@ namespace pins { */ //% help=pins/digital-write-pin weight=29 //% blockId=device_set_digital_pin block="digital write|pin %name|to %value" + //% value.min=0 value.max=1 void digitalWritePin(DigitalPin name, int value) { PINOP(setDigitalValue(value)); } @@ -243,6 +244,7 @@ namespace pins { //% help=pins/servo-write-pin weight=20 //% blockId=device_set_servo_pin block="servo write|pin %name|to %value" blockGap=8 //% parts=microservo trackArgs=0 + //% value.min=0 value.max=180 void servoWritePin(AnalogPin name, int value) { PINOP(setServoValue(value)); } diff --git a/libs/core/shims.d.ts b/libs/core/shims.d.ts index 0f42a14c..83430904 100644 --- a/libs/core/shims.d.ts +++ b/libs/core/shims.d.ts @@ -440,7 +440,8 @@ declare namespace led { */ //% help=led/plot weight=78 //% blockId=device_plot block="plot|x %x|y %y" blockGap=8 - //% parts="ledmatrix" shim=led::plot + //% parts="ledmatrix" + //% x.min=0 x.max=4 y.min=0 y.max=4 shim=led::plot function plot(x: number, y: number): void; /** @@ -450,7 +451,8 @@ declare namespace led { */ //% help=led/unplot weight=77 //% blockId=device_unplot block="unplot|x %x|y %y" blockGap=8 - //% parts="ledmatrix" shim=led::unplot + //% parts="ledmatrix" + //% x.min=0 x.max=4 y.min=0 y.max=4 shim=led::unplot function unplot(x: number, y: number): void; /** @@ -460,7 +462,8 @@ declare namespace led { */ //% help=led/point weight=76 //% blockId=device_point block="point|x %x|y %y" - //% parts="ledmatrix" shim=led::point + //% parts="ledmatrix" + //% x.min=0 x.max=4 y.min=0 y.max=4 shim=led::point function point(x: number, y: number): boolean; /** @@ -479,7 +482,8 @@ declare namespace led { //% help=led/set-brightness weight=59 //% blockId=device_set_brightness block="set brightness %value" //% parts="ledmatrix" - //% advanced=true shim=led::setBrightness + //% advanced=true + //% value.min=0 value.max=255 shim=led::setBrightness function setBrightness(value: number): void; /** @@ -529,7 +533,8 @@ declare namespace pins { * @param value value to set on the pin, 1 eg,0 */ //% help=pins/digital-write-pin weight=29 - //% blockId=device_set_digital_pin block="digital write|pin %name|to %value" shim=pins::digitalWritePin + //% blockId=device_set_digital_pin block="digital write|pin %name|to %value" + //% value.min=0 value.max=1 shim=pins::digitalWritePin function digitalWritePin(name: DigitalPin, value: number): void; /** @@ -593,7 +598,8 @@ declare namespace pins { */ //% help=pins/servo-write-pin weight=20 //% blockId=device_set_servo_pin block="servo write|pin %name|to %value" blockGap=8 - //% parts=microservo trackArgs=0 shim=pins::servoWritePin + //% parts=microservo trackArgs=0 + //% value.min=0 value.max=180 shim=pins::servoWritePin function servoWritePin(name: AnalogPin, value: number): void; /** diff --git a/libs/radio/_locales/radio-jsdoc-strings.json b/libs/radio/_locales/radio-jsdoc-strings.json index f80bb225..34b37e9e 100644 --- a/libs/radio/_locales/radio-jsdoc-strings.json +++ b/libs/radio/_locales/radio-jsdoc-strings.json @@ -14,7 +14,8 @@ "radio.sendValue": "Broadcasts a name / value pair along with the device serial number\nand running time to any connected micro:bit in the group.", "radio.sendValue|param|name": "the field name (max 12 characters), eg: \"name\"", "radio.sendValue|param|value": "the numberic value", - "radio.setGroup": "Sets the group id for radio communications. A micro:bit can only listen to one group ID at any time.\n@ param id the group id between ``0`` and ``255``, 1 eg", + "radio.setGroup": "Sets the group id for radio communications. A micro:bit can only listen to one group ID at any time.", + "radio.setGroup|param|id": "the group id between ``0`` and ``255``, eg: 1", "radio.setTransmitPower": "Change the output power level of the transmitter to the given value.", "radio.setTransmitPower|param|power": "a value in the range 0..7, where 0 is the lowest power and 7 is the highest. eg: 7", "radio.setTransmitSerialNumber": "Set the radio to transmit the serial number in each message.", diff --git a/libs/radio/radio.cpp b/libs/radio/radio.cpp index bcf094b8..59684a27 100644 --- a/libs/radio/radio.cpp +++ b/libs/radio/radio.cpp @@ -314,11 +314,12 @@ namespace radio { /** * Sets the group id for radio communications. A micro:bit can only listen to one group ID at any time. - * @ param id the group id between ``0`` and ``255``, 1 eg + * @param id the group id between ``0`` and ``255``, eg: 1 */ //% help=radio/set-group //% weight=10 blockGap=8 //% blockId=radio_set_group block="radio set group %ID" + //% id.min=0 id.max=255 void setGroup(int id) { if (radioEnable() != MICROBIT_OK) return; uBit.radio.setGroup(id); @@ -331,6 +332,7 @@ namespace radio { //% help=radio/set-transmit-power //% weight=9 blockGap=8 //% blockId=radio_set_transmit_power block="radio set transmit power %power" + //% power.min=0 power.max=7 //% advanced=true void setTransmitPower(int power) { if (radioEnable() != MICROBIT_OK) return; diff --git a/libs/radio/shims.d.ts b/libs/radio/shims.d.ts index b7c84a5a..af208987 100644 --- a/libs/radio/shims.d.ts +++ b/libs/radio/shims.d.ts @@ -95,11 +95,12 @@ declare namespace radio { /** * Sets the group id for radio communications. A micro:bit can only listen to one group ID at any time. - * @ param id the group id between ``0`` and ``255``, 1 eg + * @param id the group id between ``0`` and ``255``, eg: 1 */ //% help=radio/set-group //% weight=10 blockGap=8 - //% blockId=radio_set_group block="radio set group %ID" shim=radio::setGroup + //% blockId=radio_set_group block="radio set group %ID" + //% id.min=0 id.max=255 shim=radio::setGroup function setGroup(id: number): void; /** @@ -109,6 +110,7 @@ declare namespace radio { //% help=radio/set-transmit-power //% weight=9 blockGap=8 //% blockId=radio_set_transmit_power block="radio set transmit power %power" + //% power.min=0 power.max=7 //% advanced=true shim=radio::setTransmitPower function setTransmitPower(power: number): void;