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
//% 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);
}

View File

@ -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);

View File

@ -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) {

View File

@ -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
View File

@ -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;
/**