Enable the slider for a number of apis. (#367)

This commit is contained in:
Sam El-Husseini 2017-03-03 23:39:42 -08:00 committed by GitHub
parent df95a6441b
commit 87f1580061
8 changed files with 29 additions and 10 deletions

View File

@ -19,6 +19,7 @@ namespace led {
//% help=led/plot weight=78 //% help=led/plot weight=78
//% blockId=device_plot block="plot|x %x|y %y" blockGap=8 //% blockId=device_plot block="plot|x %x|y %y" blockGap=8
//% parts="ledmatrix" //% parts="ledmatrix"
//% x.min=0 x.max=4 y.min=0 y.max=4
void plot(int x, int y) { void plot(int x, int y) {
uBit.display.image.setPixelValue(x, y, 1); uBit.display.image.setPixelValue(x, y, 1);
} }
@ -31,6 +32,7 @@ namespace led {
//% help=led/unplot weight=77 //% help=led/unplot weight=77
//% blockId=device_unplot block="unplot|x %x|y %y" blockGap=8 //% blockId=device_unplot block="unplot|x %x|y %y" blockGap=8
//% parts="ledmatrix" //% parts="ledmatrix"
//% x.min=0 x.max=4 y.min=0 y.max=4
void unplot(int x, int y) { void unplot(int x, int y) {
uBit.display.image.setPixelValue(x, y, 0); uBit.display.image.setPixelValue(x, y, 0);
} }
@ -43,6 +45,7 @@ namespace led {
//% help=led/point weight=76 //% help=led/point weight=76
//% blockId=device_point block="point|x %x|y %y" //% blockId=device_point block="point|x %x|y %y"
//% parts="ledmatrix" //% parts="ledmatrix"
//% x.min=0 x.max=4 y.min=0 y.max=4
bool point(int x, int y) { bool point(int x, int y) {
int pix = uBit.display.image.getPixelValue(x, y); int pix = uBit.display.image.getPixelValue(x, y);
return pix > 0; return pix > 0;
@ -67,6 +70,7 @@ namespace led {
//% blockId=device_set_brightness block="set brightness %value" //% blockId=device_set_brightness block="set brightness %value"
//% parts="ledmatrix" //% parts="ledmatrix"
//% advanced=true //% advanced=true
//% value.min=0 value.max=255
void setBrightness(int value) { void setBrightness(int value) {
uBit.display.setBrightness(value); uBit.display.setBrightness(value);
} }

View File

@ -55,6 +55,7 @@
//% help=led/toggle weight=77 //% help=led/toggle weight=77
//% blockId=device_led_toggle block="toggle|x %x|y %y" icon="\uf204" blockGap=8 //% blockId=device_led_toggle block="toggle|x %x|y %y" icon="\uf204" blockGap=8
//% parts="ledmatrix" //% parts="ledmatrix"
//% x.min=0 x.max=4 y.min=0 y.max=4
export function toggle(x: number, y: number): void { export function toggle(x: number, y: number): void {
if (led.point(x, y)) { if (led.point(x, y)) {
led.unplot(x, y); led.unplot(x, y);

View File

@ -247,6 +247,7 @@ namespace music {
*/ */
//% help=music/set-tempo weight=38 //% help=music/set-tempo weight=38
//% blockId=device_set_tempo block="set tempo to (bpm)|%value" //% blockId=device_set_tempo block="set tempo to (bpm)|%value"
//% bpm.min=4 bpm.max=400
export function setTempo(bpm: number): void { export function setTempo(bpm: number): void {
init(); init();
if (bpm > 0) { if (bpm > 0) {

View File

@ -144,6 +144,7 @@ namespace pins {
*/ */
//% help=pins/digital-write-pin weight=29 //% help=pins/digital-write-pin weight=29
//% blockId=device_set_digital_pin block="digital write|pin %name|to %value" //% blockId=device_set_digital_pin block="digital write|pin %name|to %value"
//% value.min=0 value.max=1
void digitalWritePin(DigitalPin name, int value) { void digitalWritePin(DigitalPin name, int value) {
PINOP(setDigitalValue(value)); PINOP(setDigitalValue(value));
} }
@ -243,6 +244,7 @@ namespace pins {
//% help=pins/servo-write-pin weight=20 //% help=pins/servo-write-pin weight=20
//% blockId=device_set_servo_pin block="servo write|pin %name|to %value" blockGap=8 //% blockId=device_set_servo_pin block="servo write|pin %name|to %value" blockGap=8
//% parts=microservo trackArgs=0 //% parts=microservo trackArgs=0
//% value.min=0 value.max=180
void servoWritePin(AnalogPin name, int value) { void servoWritePin(AnalogPin name, int value) {
PINOP(setServoValue(value)); PINOP(setServoValue(value));
} }

18
libs/core/shims.d.ts vendored
View File

@ -440,7 +440,8 @@ declare namespace led {
*/ */
//% help=led/plot weight=78 //% help=led/plot weight=78
//% blockId=device_plot block="plot|x %x|y %y" blockGap=8 //% 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; function plot(x: number, y: number): void;
/** /**
@ -450,7 +451,8 @@ declare namespace led {
*/ */
//% help=led/unplot weight=77 //% help=led/unplot weight=77
//% blockId=device_unplot block="unplot|x %x|y %y" blockGap=8 //% 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; function unplot(x: number, y: number): void;
/** /**
@ -460,7 +462,8 @@ declare namespace led {
*/ */
//% help=led/point weight=76 //% help=led/point weight=76
//% blockId=device_point block="point|x %x|y %y" //% 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; function point(x: number, y: number): boolean;
/** /**
@ -479,7 +482,8 @@ declare namespace led {
//% help=led/set-brightness weight=59 //% help=led/set-brightness weight=59
//% blockId=device_set_brightness block="set brightness %value" //% blockId=device_set_brightness block="set brightness %value"
//% parts="ledmatrix" //% parts="ledmatrix"
//% advanced=true shim=led::setBrightness //% advanced=true
//% value.min=0 value.max=255 shim=led::setBrightness
function setBrightness(value: number): void; function setBrightness(value: number): void;
/** /**
@ -529,7 +533,8 @@ declare namespace pins {
* @param value value to set on the pin, 1 eg,0 * @param value value to set on the pin, 1 eg,0
*/ */
//% help=pins/digital-write-pin weight=29 //% 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; function digitalWritePin(name: DigitalPin, value: number): void;
/** /**
@ -593,7 +598,8 @@ declare namespace pins {
*/ */
//% help=pins/servo-write-pin weight=20 //% help=pins/servo-write-pin weight=20
//% blockId=device_set_servo_pin block="servo write|pin %name|to %value" blockGap=8 //% 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; function servoWritePin(name: AnalogPin, value: number): void;
/** /**

View File

@ -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": "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|name": "the field name (max 12 characters), eg: \"name\"",
"radio.sendValue|param|value": "the numberic value", "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": "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.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.", "radio.setTransmitSerialNumber": "Set the radio to transmit the serial number in each message.",

View File

@ -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. * 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 //% help=radio/set-group
//% weight=10 blockGap=8 //% weight=10 blockGap=8
//% blockId=radio_set_group block="radio set group %ID" //% blockId=radio_set_group block="radio set group %ID"
//% id.min=0 id.max=255
void setGroup(int id) { void setGroup(int id) {
if (radioEnable() != MICROBIT_OK) return; if (radioEnable() != MICROBIT_OK) return;
uBit.radio.setGroup(id); uBit.radio.setGroup(id);
@ -331,6 +332,7 @@ namespace radio {
//% help=radio/set-transmit-power //% help=radio/set-transmit-power
//% weight=9 blockGap=8 //% weight=9 blockGap=8
//% blockId=radio_set_transmit_power block="radio set transmit power %power" //% blockId=radio_set_transmit_power block="radio set transmit power %power"
//% power.min=0 power.max=7
//% advanced=true //% advanced=true
void setTransmitPower(int power) { void setTransmitPower(int power) {
if (radioEnable() != MICROBIT_OK) return; if (radioEnable() != MICROBIT_OK) return;

View File

@ -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. * 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 //% help=radio/set-group
//% weight=10 blockGap=8 //% 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; function setGroup(id: number): void;
/** /**
@ -109,6 +110,7 @@ declare namespace radio {
//% help=radio/set-transmit-power //% help=radio/set-transmit-power
//% weight=9 blockGap=8 //% weight=9 blockGap=8
//% blockId=radio_set_transmit_power block="radio set transmit power %power" //% blockId=radio_set_transmit_power block="radio set transmit power %power"
//% power.min=0 power.max=7
//% advanced=true shim=radio::setTransmitPower //% advanced=true shim=radio::setTransmitPower
function setTransmitPower(power: number): void; function setTransmitPower(power: number): void;