This commit is contained in:
Peli de Halleux 2017-05-25 07:10:36 -07:00
commit 894b8145eb
4 changed files with 65 additions and 15 deletions

View File

@ -134,6 +134,7 @@ namespace input {
//% help=input/on-gesture weight=84 blockGap=8 //% help=input/on-gesture weight=84 blockGap=8
//% blockId=device_gesture_event block="on |%NAME" //% blockId=device_gesture_event block="on |%NAME"
//% parts="accelerometer" //% parts="accelerometer"
//% NAME.fieldEditor="gridpicker" NAME.fieldOptions.columns=4
void onGesture(Gesture gesture, Action body) { void onGesture(Gesture gesture, Action body) {
int gi = (int)gesture; int gi = (int)gesture;
if (gi == MICROBIT_ACCELEROMETER_EVT_3G && uBit.accelerometer.getRange() < 3) if (gi == MICROBIT_ACCELEROMETER_EVT_3G && uBit.accelerometer.getRange() < 3)

View File

@ -133,6 +133,8 @@ namespace pins {
*/ */
//% help=pins/digital-read-pin weight=30 //% help=pins/digital-read-pin weight=30
//% blockId=device_get_digital_pin block="digital read|pin %name" blockGap=8 //% blockId=device_get_digital_pin block="digital read|pin %name" blockGap=8
//% name.fieldEditor="gridpicker" name.fieldOptions.columns=4
//% name.fieldOptions.tooltips="false" name.fieldOptions.width="300"
int digitalReadPin(DigitalPin name) { int digitalReadPin(DigitalPin name) {
PINREAD(getDigitalValue()); PINREAD(getDigitalValue());
} }
@ -145,6 +147,8 @@ 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 //% value.min=0 value.max=1
//% name.fieldEditor="gridpicker" name.fieldOptions.columns=4
//% name.fieldOptions.tooltips="false" name.fieldOptions.width="300"
void digitalWritePin(DigitalPin name, int value) { void digitalWritePin(DigitalPin name, int value) {
PINOP(setDigitalValue(value)); PINOP(setDigitalValue(value));
} }
@ -155,6 +159,8 @@ namespace pins {
*/ */
//% help=pins/analog-read-pin weight=25 //% help=pins/analog-read-pin weight=25
//% blockId=device_get_analog_pin block="analog read|pin %name" blockGap="8" //% blockId=device_get_analog_pin block="analog read|pin %name" blockGap="8"
//% name.fieldEditor="gridpicker" name.fieldOptions.columns=4
//% name.fieldOptions.tooltips="false"
int analogReadPin(AnalogPin name) { int analogReadPin(AnalogPin name) {
PINREAD(getAnalogValue()); PINREAD(getAnalogValue());
} }
@ -167,6 +173,8 @@ namespace pins {
//% help=pins/analog-write-pin weight=24 //% help=pins/analog-write-pin weight=24
//% blockId=device_set_analog_pin block="analog write|pin %name|to %value" blockGap=8 //% blockId=device_set_analog_pin block="analog write|pin %name|to %value" blockGap=8
//% value.min=0 value.max=1023 //% value.min=0 value.max=1023
//% name.fieldEditor="gridpicker" name.fieldOptions.columns=4
//% name.fieldOptions.tooltips="false"
void analogWritePin(AnalogPin name, int value) { void analogWritePin(AnalogPin name, int value) {
PINOP(setAnalogValue(value)); PINOP(setAnalogValue(value));
} }
@ -179,6 +187,8 @@ namespace pins {
*/ */
//% help=pins/analog-set-period weight=23 blockGap=8 //% help=pins/analog-set-period weight=23 blockGap=8
//% blockId=device_set_analog_period block="analog set period|pin %pin|to (µs)%micros" //% blockId=device_set_analog_period block="analog set period|pin %pin|to (µs)%micros"
//% pin.fieldEditor="gridpicker" pin.fieldOptions.columns=4
//% pin.fieldOptions.tooltips="false"
void analogSetPeriod(AnalogPin name, int micros) { void analogSetPeriod(AnalogPin name, int micros) {
PINOP(setAnalogPeriodUs(micros)); PINOP(setAnalogPeriodUs(micros));
} }
@ -190,6 +200,8 @@ namespace pins {
*/ */
//% help=pins/on-pulsed weight=22 blockGap=8 advanced=true //% help=pins/on-pulsed weight=22 blockGap=8 advanced=true
//% blockId=pins_on_pulsed block="on|pin %pin|pulsed %pulse" //% blockId=pins_on_pulsed block="on|pin %pin|pulsed %pulse"
//% pin.fieldEditor="gridpicker" pin.fieldOptions.columns=4
//% pin.fieldOptions.tooltips="false" pin.fieldOptions.width="300"
void onPulsed(DigitalPin name, PulseValue pulse, Action body) { void onPulsed(DigitalPin name, PulseValue pulse, Action body) {
MicroBitPin* pin = getPin((int)name); MicroBitPin* pin = getPin((int)name);
if (!pin) return; if (!pin) return;
@ -216,6 +228,8 @@ namespace pins {
*/ */
//% blockId="pins_pulse_in" block="pulse in (µs)|pin %name|pulsed %value" //% blockId="pins_pulse_in" block="pulse in (µs)|pin %name|pulsed %value"
//% weight=20 advanced=true //% weight=20 advanced=true
//% name.fieldEditor="gridpicker" name.fieldOptions.columns=4
//% name.fieldOptions.tooltips="false" name.fieldOptions.width="300"
int pulseIn(DigitalPin name, PulseValue value, int maxDuration = 2000000) { int pulseIn(DigitalPin name, PulseValue value, int maxDuration = 2000000) {
MicroBitPin* pin = getPin((int)name); MicroBitPin* pin = getPin((int)name);
if (!pin) return 0; if (!pin) return 0;
@ -246,6 +260,8 @@ namespace pins {
//% 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 //% value.min=0 value.max=180
//% name.fieldEditor="gridpicker" name.fieldOptions.columns=4
//% name.fieldOptions.tooltips="false"
void servoWritePin(AnalogPin name, int value) { void servoWritePin(AnalogPin name, int value) {
PINOP(setServoValue(value)); PINOP(setServoValue(value));
} }
@ -257,6 +273,8 @@ namespace pins {
*/ */
//% help=pins/servo-set-pulse weight=19 //% help=pins/servo-set-pulse weight=19
//% blockId=device_set_servo_pulse block="servo set pulse|pin %value|to (µs) %micros" //% blockId=device_set_servo_pulse block="servo set pulse|pin %value|to (µs) %micros"
//% value.fieldEditor="gridpicker" value.fieldOptions.columns=4
//% value.fieldOptions.tooltips="false"
void servoSetPulse(AnalogPin name, int micros) { void servoSetPulse(AnalogPin name, int micros) {
PINOP(setServoPulseUs(micros)); PINOP(setServoPulseUs(micros));
} }
@ -270,6 +288,8 @@ namespace pins {
*/ */
//% blockId=device_analog_set_pitch_pin block="analog set pitch pin %name" //% blockId=device_analog_set_pitch_pin block="analog set pitch pin %name"
//% help=pins/analog-set-pitch weight=3 advanced=true //% help=pins/analog-set-pitch weight=3 advanced=true
//% name.fieldEditor="gridpicker" name.fieldOptions.columns=4
//% name.fieldOptions.tooltips="false"
void analogSetPitchPin(AnalogPin name) { void analogSetPitchPin(AnalogPin name) {
pitchPin = getPin((int)name); pitchPin = getPin((int)name);
} }
@ -307,6 +327,8 @@ namespace pins {
*/ */
//% help=pins/set-pull weight=3 advanced=true //% help=pins/set-pull weight=3 advanced=true
//% blockId=device_set_pull block="set pull|pin %pin|to %pull" //% blockId=device_set_pull block="set pull|pin %pin|to %pull"
//% pin.fieldEditor="gridpicker" pin.fieldOptions.columns=4
//% pin.fieldOptions.tooltips="false" pin.fieldOptions.width="300"
void setPull(DigitalPin name, PinPullMode pull) { void setPull(DigitalPin name, PinPullMode pull) {
PinMode m = pull == PinPullMode::PullDown PinMode m = pull == PinPullMode::PullDown
? PinMode::PullDown ? PinMode::PullDown
@ -323,6 +345,8 @@ namespace pins {
*/ */
//% help=pins/set-events weight=4 advanced=true //% help=pins/set-events weight=4 advanced=true
//% blockId=device_set_pin_events block="set pin %pin|to emit %type|events" //% blockId=device_set_pin_events block="set pin %pin|to emit %type|events"
//% pin.fieldEditor="gridpicker" pin.fieldOptions.columns=4
//% pin.fieldOptions.tooltips="false" pin.fieldOptions.width="300"
void setEvents(DigitalPin name, PinEventType type) { void setEvents(DigitalPin name, PinEventType type) {
getPin((int)name)->eventOn((int)type); getPin((int)name)->eventOn((int)type);
} }

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

@ -232,7 +232,8 @@ declare namespace input {
*/ */
//% help=input/on-gesture weight=84 blockGap=8 //% help=input/on-gesture weight=84 blockGap=8
//% blockId=device_gesture_event block="on |%NAME" //% blockId=device_gesture_event block="on |%NAME"
//% parts="accelerometer" shim=input::onGesture //% parts="accelerometer"
//% NAME.fieldEditor="gridpicker" NAME.fieldOptions.columns=4 shim=input::onGesture
function onGesture(gesture: Gesture, body: () => void): void; function onGesture(gesture: Gesture, body: () => void): void;
/** /**
@ -525,7 +526,9 @@ declare namespace pins {
* @param name pin to read from, eg: DigitalPin.P0 * @param name pin to read from, eg: DigitalPin.P0
*/ */
//% help=pins/digital-read-pin weight=30 //% help=pins/digital-read-pin weight=30
//% blockId=device_get_digital_pin block="digital read|pin %name" blockGap=8 shim=pins::digitalReadPin //% blockId=device_get_digital_pin block="digital read|pin %name" blockGap=8
//% name.fieldEditor="gridpicker" name.fieldOptions.columns=4
//% name.fieldOptions.tooltips="false" name.fieldOptions.width="300" shim=pins::digitalReadPin
function digitalReadPin(name: DigitalPin): number; function digitalReadPin(name: DigitalPin): number;
/** /**
@ -535,7 +538,9 @@ declare 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 shim=pins::digitalWritePin //% value.min=0 value.max=1
//% name.fieldEditor="gridpicker" name.fieldOptions.columns=4
//% name.fieldOptions.tooltips="false" name.fieldOptions.width="300" shim=pins::digitalWritePin
function digitalWritePin(name: DigitalPin, value: number): void; function digitalWritePin(name: DigitalPin, value: number): void;
/** /**
@ -543,7 +548,9 @@ declare namespace pins {
* @param name pin to write to, eg: AnalogPin.P0 * @param name pin to write to, eg: AnalogPin.P0
*/ */
//% help=pins/analog-read-pin weight=25 //% help=pins/analog-read-pin weight=25
//% blockId=device_get_analog_pin block="analog read|pin %name" blockGap="8" shim=pins::analogReadPin //% blockId=device_get_analog_pin block="analog read|pin %name" blockGap="8"
//% name.fieldEditor="gridpicker" name.fieldOptions.columns=4
//% name.fieldOptions.tooltips="false" shim=pins::analogReadPin
function analogReadPin(name: AnalogPin): number; function analogReadPin(name: AnalogPin): number;
/** /**
@ -553,7 +560,9 @@ declare namespace pins {
*/ */
//% help=pins/analog-write-pin weight=24 //% help=pins/analog-write-pin weight=24
//% blockId=device_set_analog_pin block="analog write|pin %name|to %value" blockGap=8 //% blockId=device_set_analog_pin block="analog write|pin %name|to %value" blockGap=8
//% value.min=0 value.max=1023 shim=pins::analogWritePin //% value.min=0 value.max=1023
//% name.fieldEditor="gridpicker" name.fieldOptions.columns=4
//% name.fieldOptions.tooltips="false" shim=pins::analogWritePin
function analogWritePin(name: AnalogPin, value: number): void; function analogWritePin(name: AnalogPin, value: number): void;
/** /**
@ -563,7 +572,9 @@ declare namespace pins {
* @param micros period in micro seconds. eg:20000 * @param micros period in micro seconds. eg:20000
*/ */
//% help=pins/analog-set-period weight=23 blockGap=8 //% help=pins/analog-set-period weight=23 blockGap=8
//% blockId=device_set_analog_period block="analog set period|pin %pin|to (µs)%micros" shim=pins::analogSetPeriod //% blockId=device_set_analog_period block="analog set period|pin %pin|to (µs)%micros"
//% pin.fieldEditor="gridpicker" pin.fieldOptions.columns=4
//% pin.fieldOptions.tooltips="false" shim=pins::analogSetPeriod
function analogSetPeriod(name: AnalogPin, micros: number): void; function analogSetPeriod(name: AnalogPin, micros: number): void;
/** /**
@ -572,7 +583,9 @@ declare namespace pins {
* @param pulse the value of the pulse, eg: PulseValue.High * @param pulse the value of the pulse, eg: PulseValue.High
*/ */
//% help=pins/on-pulsed weight=22 blockGap=8 advanced=true //% help=pins/on-pulsed weight=22 blockGap=8 advanced=true
//% blockId=pins_on_pulsed block="on|pin %pin|pulsed %pulse" shim=pins::onPulsed //% blockId=pins_on_pulsed block="on|pin %pin|pulsed %pulse"
//% pin.fieldEditor="gridpicker" pin.fieldOptions.columns=4
//% pin.fieldOptions.tooltips="false" pin.fieldOptions.width="300" shim=pins::onPulsed
function onPulsed(name: DigitalPin, pulse: PulseValue, body: () => void): void; function onPulsed(name: DigitalPin, pulse: PulseValue, body: () => void): void;
/** /**
@ -590,7 +603,9 @@ declare namespace pins {
* @param maximum duration in micro-seconds * @param maximum duration in micro-seconds
*/ */
//% blockId="pins_pulse_in" block="pulse in (µs)|pin %name|pulsed %value" //% blockId="pins_pulse_in" block="pulse in (µs)|pin %name|pulsed %value"
//% weight=20 advanced=true maxDuration.defl=2000000 shim=pins::pulseIn //% weight=20 advanced=true
//% name.fieldEditor="gridpicker" name.fieldOptions.columns=4
//% name.fieldOptions.tooltips="false" name.fieldOptions.width="300" maxDuration.defl=2000000 shim=pins::pulseIn
function pulseIn(name: DigitalPin, value: PulseValue, maxDuration?: number): number; function pulseIn(name: DigitalPin, value: PulseValue, maxDuration?: number): number;
/** /**
@ -601,7 +616,9 @@ 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 //% parts=microservo trackArgs=0
//% value.min=0 value.max=180 shim=pins::servoWritePin //% value.min=0 value.max=180
//% name.fieldEditor="gridpicker" name.fieldOptions.columns=4
//% name.fieldOptions.tooltips="false" shim=pins::servoWritePin
function servoWritePin(name: AnalogPin, value: number): void; function servoWritePin(name: AnalogPin, value: number): void;
/** /**
@ -610,7 +627,9 @@ declare namespace pins {
* @param micros pulse duration in micro seconds, eg:1500 * @param micros pulse duration in micro seconds, eg:1500
*/ */
//% help=pins/servo-set-pulse weight=19 //% help=pins/servo-set-pulse weight=19
//% blockId=device_set_servo_pulse block="servo set pulse|pin %value|to (µs) %micros" shim=pins::servoSetPulse //% blockId=device_set_servo_pulse block="servo set pulse|pin %value|to (µs) %micros"
//% value.fieldEditor="gridpicker" value.fieldOptions.columns=4
//% value.fieldOptions.tooltips="false" shim=pins::servoSetPulse
function servoSetPulse(name: AnalogPin, micros: number): void; function servoSetPulse(name: AnalogPin, micros: number): void;
/** /**
@ -618,7 +637,9 @@ declare namespace pins {
* @param name pin to modulate pitch from * @param name pin to modulate pitch from
*/ */
//% blockId=device_analog_set_pitch_pin block="analog set pitch pin %name" //% blockId=device_analog_set_pitch_pin block="analog set pitch pin %name"
//% help=pins/analog-set-pitch weight=3 advanced=true shim=pins::analogSetPitchPin //% help=pins/analog-set-pitch weight=3 advanced=true
//% name.fieldEditor="gridpicker" name.fieldOptions.columns=4
//% name.fieldOptions.tooltips="false" shim=pins::analogSetPitchPin
function analogSetPitchPin(name: AnalogPin): void; function analogSetPitchPin(name: AnalogPin): void;
/** /**
@ -636,7 +657,9 @@ declare namespace pins {
* @param pull one of the mbed pull configurations, eg: PinPullMode.PullUp * @param pull one of the mbed pull configurations, eg: PinPullMode.PullUp
*/ */
//% help=pins/set-pull weight=3 advanced=true //% help=pins/set-pull weight=3 advanced=true
//% blockId=device_set_pull block="set pull|pin %pin|to %pull" shim=pins::setPull //% blockId=device_set_pull block="set pull|pin %pin|to %pull"
//% pin.fieldEditor="gridpicker" pin.fieldOptions.columns=4
//% pin.fieldOptions.tooltips="false" pin.fieldOptions.width="300" shim=pins::setPull
function setPull(name: DigitalPin, pull: PinPullMode): void; function setPull(name: DigitalPin, pull: PinPullMode): void;
/** /**
@ -646,7 +669,9 @@ declare namespace pins {
* @param type the type of events for this pin to emit, eg: PinEventType.Edge * @param type the type of events for this pin to emit, eg: PinEventType.Edge
*/ */
//% help=pins/set-events weight=4 advanced=true //% help=pins/set-events weight=4 advanced=true
//% blockId=device_set_pin_events block="set pin %pin|to emit %type|events" shim=pins::setEvents //% blockId=device_set_pin_events block="set pin %pin|to emit %type|events"
//% pin.fieldEditor="gridpicker" pin.fieldOptions.columns=4
//% pin.fieldOptions.tooltips="false" pin.fieldOptions.width="300" shim=pins::setEvents
function setEvents(name: DigitalPin, type: PinEventType): void; function setEvents(name: DigitalPin, type: PinEventType): void;
/** /**

View File

@ -1,6 +1,6 @@
{ {
"name": "pxt-microbit", "name": "pxt-microbit",
"version": "0.12.17", "version": "0.12.18",
"description": "micro:bit target for Microsoft MakeCode (PXT)", "description": "micro:bit target for Microsoft MakeCode (PXT)",
"keywords": [ "keywords": [
"JavaScript", "JavaScript",
@ -38,6 +38,6 @@
"semantic-ui-less": "^2.2.4" "semantic-ui-less": "^2.2.4"
}, },
"dependencies": { "dependencies": {
"pxt-core": "0.12.79" "pxt-core": "0.12.80"
} }
} }