Enable the slider for a number of apis. (#367)
This commit is contained in:
parent
df95a6441b
commit
87f1580061
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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) {
|
||||
|
@ -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));
|
||||
}
|
||||
|
18
libs/core/shims.d.ts
vendored
18
libs/core/shims.d.ts
vendored
@ -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;
|
||||
|
||||
/**
|
||||
|
@ -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.",
|
||||
|
@ -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;
|
||||
|
6
libs/radio/shims.d.ts
vendored
6
libs/radio/shims.d.ts
vendored
@ -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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user