diff --git a/libs/core/input.cpp b/libs/core/input.cpp index 89edd191..c45530e2 100644 --- a/libs/core/input.cpp +++ b/libs/core/input.cpp @@ -134,6 +134,7 @@ namespace input { //% help=input/on-gesture weight=84 blockGap=8 //% blockId=device_gesture_event block="on |%NAME" //% parts="accelerometer" + //% NAME.fieldEditor="gridpicker" NAME.fieldOptions.columns=4 void onGesture(Gesture gesture, Action body) { int gi = (int)gesture; if (gi == MICROBIT_ACCELEROMETER_EVT_3G && uBit.accelerometer.getRange() < 3) diff --git a/libs/core/pins.cpp b/libs/core/pins.cpp index 12942697..5027fc20 100644 --- a/libs/core/pins.cpp +++ b/libs/core/pins.cpp @@ -133,6 +133,8 @@ namespace pins { */ //% help=pins/digital-read-pin weight=30 //% 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) { PINREAD(getDigitalValue()); } @@ -145,6 +147,8 @@ 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 + //% name.fieldEditor="gridpicker" name.fieldOptions.columns=4 + //% name.fieldOptions.tooltips="false" name.fieldOptions.width="300" void digitalWritePin(DigitalPin name, int value) { PINOP(setDigitalValue(value)); } @@ -155,6 +159,8 @@ namespace pins { */ //% help=pins/analog-read-pin weight=25 //% 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) { PINREAD(getAnalogValue()); } @@ -167,6 +173,8 @@ namespace pins { //% help=pins/analog-write-pin weight=24 //% blockId=device_set_analog_pin block="analog write|pin %name|to %value" blockGap=8 //% value.min=0 value.max=1023 + //% name.fieldEditor="gridpicker" name.fieldOptions.columns=4 + //% name.fieldOptions.tooltips="false" void analogWritePin(AnalogPin name, int value) { PINOP(setAnalogValue(value)); } @@ -179,6 +187,8 @@ namespace pins { */ //% help=pins/analog-set-period weight=23 blockGap=8 //% 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) { PINOP(setAnalogPeriodUs(micros)); } @@ -190,6 +200,8 @@ namespace pins { */ //% help=pins/on-pulsed weight=22 blockGap=8 advanced=true //% 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) { MicroBitPin* pin = getPin((int)name); if (!pin) return; @@ -216,6 +228,8 @@ namespace pins { */ //% blockId="pins_pulse_in" block="pulse in (µs)|pin %name|pulsed %value" //% 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) { MicroBitPin* pin = getPin((int)name); if (!pin) return 0; @@ -246,6 +260,8 @@ namespace pins { //% blockId=device_set_servo_pin block="servo write|pin %name|to %value" blockGap=8 //% parts=microservo trackArgs=0 //% value.min=0 value.max=180 + //% name.fieldEditor="gridpicker" name.fieldOptions.columns=4 + //% name.fieldOptions.tooltips="false" void servoWritePin(AnalogPin name, int value) { PINOP(setServoValue(value)); } @@ -257,6 +273,8 @@ namespace pins { */ //% help=pins/servo-set-pulse weight=19 //% 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) { PINOP(setServoPulseUs(micros)); } @@ -270,6 +288,8 @@ namespace pins { */ //% blockId=device_analog_set_pitch_pin block="analog set pitch pin %name" //% help=pins/analog-set-pitch weight=3 advanced=true + //% name.fieldEditor="gridpicker" name.fieldOptions.columns=4 + //% name.fieldOptions.tooltips="false" void analogSetPitchPin(AnalogPin name) { pitchPin = getPin((int)name); } @@ -307,6 +327,8 @@ namespace pins { */ //% help=pins/set-pull weight=3 advanced=true //% 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) { PinMode m = pull == PinPullMode::PullDown ? PinMode::PullDown @@ -323,6 +345,8 @@ namespace pins { */ //% help=pins/set-events weight=4 advanced=true //% 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) { getPin((int)name)->eventOn((int)type); } diff --git a/libs/core/shims.d.ts b/libs/core/shims.d.ts index 0d2ddefd..059b2e08 100644 --- a/libs/core/shims.d.ts +++ b/libs/core/shims.d.ts @@ -232,7 +232,8 @@ declare namespace input { */ //% help=input/on-gesture weight=84 blockGap=8 //% 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; /** @@ -525,7 +526,9 @@ declare namespace pins { * @param name pin to read from, eg: DigitalPin.P0 */ //% 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; /** @@ -535,7 +538,9 @@ declare 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 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; /** @@ -543,7 +548,9 @@ declare namespace pins { * @param name pin to write to, eg: AnalogPin.P0 */ //% 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; /** @@ -553,7 +560,9 @@ declare namespace pins { */ //% help=pins/analog-write-pin weight=24 //% 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; /** @@ -563,7 +572,9 @@ declare namespace pins { * @param micros period in micro seconds. eg:20000 */ //% 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; /** @@ -572,7 +583,9 @@ declare namespace pins { * @param pulse the value of the pulse, eg: PulseValue.High */ //% 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; /** @@ -590,7 +603,9 @@ declare namespace pins { * @param maximum duration in micro-seconds */ //% 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; /** @@ -601,7 +616,9 @@ 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 - //% 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; /** @@ -610,7 +627,9 @@ declare namespace pins { * @param micros pulse duration in micro seconds, eg:1500 */ //% 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; /** @@ -618,7 +637,9 @@ declare namespace pins { * @param name pin to modulate pitch from */ //% 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; /** @@ -636,7 +657,9 @@ declare namespace pins { * @param pull one of the mbed pull configurations, eg: PinPullMode.PullUp */ //% 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; /** @@ -646,7 +669,9 @@ declare namespace pins { * @param type the type of events for this pin to emit, eg: PinEventType.Edge */ //% 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; /** diff --git a/package.json b/package.json index 2490dc7a..cfdb614b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "pxt-microbit", - "version": "0.12.17", + "version": "0.12.18", "description": "micro:bit target for Microsoft MakeCode (PXT)", "keywords": [ "JavaScript", @@ -38,6 +38,6 @@ "semantic-ui-less": "^2.2.4" }, "dependencies": { - "pxt-core": "0.12.79" + "pxt-core": "0.12.80" } }