Beta v4 updates (#195)

* fix simulator

- fix buttons
- fix analog max value

* BLE Set max table size

* reset defaults

* add coding4coconut/pxt-lcd128x160-st7735s

* add coding4coconut/pxt-oled128x128-sh1107

* enable partial flashing
This commit is contained in:
Juri Wolf 2022-06-30 19:01:19 +02:00 committed by GitHub
parent 5aba020bb3
commit fa34fe5fd2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 212 additions and 42 deletions

View File

@ -268,7 +268,7 @@
"basic.showCompass|param|interval": "the amount of time (milliseconds) to show the needle. Default is 600.", "basic.showCompass|param|interval": "the amount of time (milliseconds) to show the needle. Default is 600.",
"basic.showIcon": "Draws the selected icon on the LED screen", "basic.showIcon": "Draws the selected icon on the LED screen",
"basic.showIcon|param|icon": "the predefined icon id", "basic.showIcon|param|icon": "the predefined icon id",
"basic.showIcon|param|interval": "the amount of time (milliseconds) to block the LED Matrix for showing the icon. Default is 200.", "basic.showIcon|param|interval": "the amount of time (milliseconds) to block the LED Matrix for showing the icon. Default is 600.",
"basic.showLeds": "Draws an image on the LED screen.", "basic.showLeds": "Draws an image on the LED screen.",
"basic.showLeds|param|interval": "time in milliseconds to pause after drawing", "basic.showLeds|param|interval": "time in milliseconds to pause after drawing",
"basic.showLeds|param|leds": "the pattern of LED to turn on/off", "basic.showLeds|param|leds": "the pattern of LED to turn on/off",
@ -442,9 +442,18 @@
"input.onButtonEvent|param|body": "code to run when event is raised", "input.onButtonEvent|param|body": "code to run when event is raised",
"input.onButtonEvent|param|button": "the button", "input.onButtonEvent|param|button": "the button",
"input.onButtonEvent|param|eventType": "event Type", "input.onButtonEvent|param|eventType": "event Type",
"input.onButtonPressed": "Do something when a button (A, B or both A+B) is pushed down and released again.",
"input.onButtonPressed|param|body": "code to run when event is raised",
"input.onButtonPressed|param|button": "the button that needs to be pressed",
"input.onGesture": "Do something when when a gesture is done (like shaking the micro:bit).", "input.onGesture": "Do something when when a gesture is done (like shaking the micro:bit).",
"input.onGesture|param|body": "code to run when gesture is raised", "input.onGesture|param|body": "code to run when gesture is raised",
"input.onGesture|param|gesture": "the type of gesture to track, eg: Gesture.Shake", "input.onGesture|param|gesture": "the type of gesture to track, eg: Gesture.Shake",
"input.onPinPressed": "Do something when a pin is touched and released again (while also touching the GND pin).",
"input.onPinPressed|param|body": "the code to run when the pin is pressed",
"input.onPinPressed|param|name": "the pin that needs to be pressed, eg: TouchPin.P0",
"input.onPinReleased": "Do something when a pin is released.",
"input.onPinReleased|param|body": "the code to run when the pin is released",
"input.onPinReleased|param|name": "the pin that needs to be released, eg: TouchPin.P0",
"input.onPinTouchEvent": "Do something when a pin receives an touch event (while also touching the GND pin).", "input.onPinTouchEvent": "Do something when a pin receives an touch event (while also touching the GND pin).",
"input.onPinTouchEvent|param|body": "the code to run when event is fired on pin", "input.onPinTouchEvent|param|body": "the code to run when event is fired on pin",
"input.onPinTouchEvent|param|name": "the pin, eg: TouchPin.P0", "input.onPinTouchEvent|param|name": "the pin, eg: TouchPin.P0",

View File

@ -345,7 +345,10 @@
"input.lightLevel|block": "light level", "input.lightLevel|block": "light level",
"input.magneticForce|block": "magnetic force (µT)|%NAME", "input.magneticForce|block": "magnetic force (µT)|%NAME",
"input.onButtonEvent|block": "on button %NAME| %eventType=control_button_event_value_id", "input.onButtonEvent|block": "on button %NAME| %eventType=control_button_event_value_id",
"input.onButtonPressed|block": "on button|%NAME|pressed",
"input.onGesture|block": "on |%NAME", "input.onGesture|block": "on |%NAME",
"input.onPinPressed|block": "on pin %name|pressed",
"input.onPinReleased|block": "on pin %NAME|released",
"input.onPinTouchEvent|block": "on pin %name| %eventType=control_button_event_value_id", "input.onPinTouchEvent|block": "on pin %name| %eventType=control_button_event_value_id",
"input.pinIsPressed|block": "pin %NAME|is pressed", "input.pinIsPressed|block": "pin %NAME|is pressed",
"input.rotation|block": "rotation (°)|%NAME", "input.rotation|block": "rotation (°)|%NAME",
@ -484,8 +487,10 @@
"{id:category}String": "String", "{id:category}String": "String",
"{id:category}Text": "Text", "{id:category}Text": "Text",
"{id:category}_py": "_py", "{id:category}_py": "_py",
"{id:group}Analog": "Analog",
"{id:group}Configuration": "Configuration", "{id:group}Configuration": "Configuration",
"{id:group}Control": "Control", "{id:group}Control": "Control",
"{id:group}Digital": "Digital",
"{id:group}Events": "Events", "{id:group}Events": "Events",
"{id:group}Get": "Get", "{id:group}Get": "Get",
"{id:group}LED matrix": "LED matrix", "{id:group}LED matrix": "LED matrix",
@ -493,15 +498,20 @@
"{id:group}Melody Advanced": "Melody Advanced", "{id:group}Melody Advanced": "Melody Advanced",
"{id:group}Modify": "Modify", "{id:group}Modify": "Modify",
"{id:group}Operations": "Operations", "{id:group}Operations": "Operations",
"{id:group}Pitch": "Pitch",
"{id:group}Pulse": "Pulse",
"{id:group}Put": "Put", "{id:group}Put": "Put",
"{id:group}RGB LED": "RGB LED", "{id:group}RGB LED": "RGB LED",
"{id:group}Read": "Read", "{id:group}Read": "Read",
"{id:group}Remove": "Remove", "{id:group}Remove": "Remove",
"{id:group}Sensors": "Sensors", "{id:group}Sensors": "Sensors",
"{id:group}Servo": "Servo",
"{id:group}Silence": "Silence", "{id:group}Silence": "Silence",
"{id:group}States": "States", "{id:group}States": "States",
"{id:group}System": "System", "{id:group}System": "System",
"{id:group}Tempo": "Tempo", "{id:group}Tempo": "Tempo",
"{id:group}Tone": "Tone", "{id:group}Tone": "Tone",
"{id:group}Volume": "Volume" "{id:group}Volume": "Volume",
"{id:group}i2c": "i2c",
"{id:group}spi": "spi"
} }

View File

@ -35,9 +35,9 @@ namespace basic {
//% parts="ledmatrix" //% parts="ledmatrix"
//% text.shadowOptions.toString=true //% text.shadowOptions.toString=true
//% expandableArgumentMode="toggle" //% expandableArgumentMode="toggle"
//% interval.defl=80 //% interval.defl=150
//% group="LED matrix" //% group="LED matrix"
void showString(String text, int interval = 80) { void showString(String text, int interval = 150) {
if (interval <= 0) if (interval <= 0)
interval = 1; interval = 1;
int l = text ? text->getUTF8Size() : 0; int l = text ? text->getUTF8Size() : 0;

View File

@ -52,7 +52,7 @@ namespace basic {
//% async //% async
//% parts="ledmatrix" //% parts="ledmatrix"
//% expandableArgumentMode="toggle" //% expandableArgumentMode="toggle"
//% interval.defl=80 //% interval.defl=150
//% group="LED matrix" //% group="LED matrix"
export function showNumber(value: number, interval?: number) { export function showNumber(value: number, interval?: number) {
showString(Math.roundWithPrecision(value, 2).toString(), interval); showString(Math.roundWithPrecision(value, 2).toString(), interval);

View File

@ -196,7 +196,7 @@ namespace basic {
/** /**
* Draws the selected icon on the LED screen * Draws the selected icon on the LED screen
* @param icon the predefined icon id * @param icon the predefined icon id
* @param interval the amount of time (milliseconds) to block the LED Matrix for showing the icon. Default is 200. * @param interval the amount of time (milliseconds) to block the LED Matrix for showing the icon. Default is 600.
*/ */
//% weight=90 blockGap=8 //% weight=90 blockGap=8
//% blockId=basic_show_icon //% blockId=basic_show_icon
@ -208,9 +208,9 @@ namespace basic {
//% icon.fieldOptions.width="380" //% icon.fieldOptions.width="380"
//% icon.fieldOptions.maxRows=4 //% icon.fieldOptions.maxRows=4
//% expandableArgumentMode="toggle" //% expandableArgumentMode="toggle"
//% interval.defl=200 //% interval.defl=600
//% group="LED matrix" //% group="LED matrix"
export function showIcon(icon: IconNames, interval = 200) { export function showIcon(icon: IconNames, interval = 600) {
let res = images.iconImage(icon) let res = images.iconImage(icon)
res.showImage(0, interval) res.showImage(0, interval)
} }

View File

@ -262,6 +262,57 @@ namespace input {
return false; return false;
} }
/**
* Do something when a button (A, B or both A+B) is pushed down and released again.
* @param button the button that needs to be pressed
* @param body code to run when event is raised
*/
//% help=input/on-button-pressed weight=85 blockGap=16
//% blockId=device_button_event block="on button|%NAME|pressed"
//% parts="buttonpair"
//% deprecated=true
//% group="Events"
void onButtonPressed(Button button, Action body) {
registerWithDal((int)button, MICROBIT_BUTTON_EVT_CLICK, body);
}
/**
* Do something when a pin is touched and released again (while also touching the GND pin).
* @param name the pin that needs to be pressed, eg: TouchPin.P0
* @param body the code to run when the pin is pressed
*/
//% help=input/on-pin-pressed weight=83 blockGap=16
//% blockId=device_pin_event block="on pin %name|pressed"
//% group="Events"
//% deprecated=true
void onPinPressed(TouchPin name, Action body) {
auto pin = getPin((int)name);
if (!pin) return;
// Forces the PIN to switch to makey-makey style detection.
pin->isTouched();
registerWithDal((int)name, MICROBIT_BUTTON_EVT_CLICK, body);
}
/**
* Do something when a pin is released.
* @param name the pin that needs to be released, eg: TouchPin.P0
* @param body the code to run when the pin is released
*/
//% help=input/on-pin-released weight=6 blockGap=16
//% blockId=device_pin_released block="on pin %NAME|released"
//% advanced=true
//% group="Events"
//% deprecated=true
void onPinReleased(TouchPin name, Action body) {
auto pin = getPin((int)name);
if (!pin) return;
// Forces the PIN to switch to makey-makey style detection.
pin->isTouched();
registerWithDal((int)name, MICROBIT_BUTTON_EVT_UP, body);
}
/** /**
* Get the pin state (pressed or not). Requires to hold the ground to close the circuit. * Get the pin state (pressed or not). Requires to hold the ground to close the circuit.
* @param name pin used to detect the touch, eg: TouchPin.P0 * @param name pin used to detect the touch, eg: TouchPin.P0

View File

@ -124,6 +124,7 @@ namespace pins {
//% 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.fieldEditor="gridpicker" name.fieldOptions.columns=4
//% name.fieldOptions.tooltips="false" name.fieldOptions.width="250" //% name.fieldOptions.tooltips="false" name.fieldOptions.width="250"
//% group="Digital"
int digitalReadPin(DigitalPin name) { int digitalReadPin(DigitalPin name) {
PINREAD(getDigitalValue()); PINREAD(getDigitalValue());
} }
@ -138,6 +139,7 @@ namespace pins {
//% value.min=0 value.max=1 //% value.min=0 value.max=1
//% name.fieldEditor="gridpicker" name.fieldOptions.columns=4 //% name.fieldEditor="gridpicker" name.fieldOptions.columns=4
//% name.fieldOptions.tooltips="false" name.fieldOptions.width="250" //% name.fieldOptions.tooltips="false" name.fieldOptions.width="250"
//% group="Digital"
void digitalWritePin(DigitalPin name, int value) { void digitalWritePin(DigitalPin name, int value) {
PINOP(setDigitalValue(value)); PINOP(setDigitalValue(value));
} }
@ -150,6 +152,7 @@ namespace pins {
//% 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.fieldEditor="gridpicker" name.fieldOptions.columns=4
//% name.fieldOptions.tooltips="false" name.fieldOptions.width="250" //% name.fieldOptions.tooltips="false" name.fieldOptions.width="250"
//% group="Analog"
int analogReadPin(AnalogPin name) { int analogReadPin(AnalogPin name) {
PINREAD(getAnalogValue()); PINREAD(getAnalogValue());
} }
@ -164,6 +167,7 @@ namespace pins {
//% value.min=0 value.max=1023 //% value.min=0 value.max=1023
//% name.fieldEditor="gridpicker" name.fieldOptions.columns=4 //% name.fieldEditor="gridpicker" name.fieldOptions.columns=4
//% name.fieldOptions.tooltips="false" name.fieldOptions.width="250" //% name.fieldOptions.tooltips="false" name.fieldOptions.width="250"
//% group="Analog"
void analogWritePin(AnalogPin name, int value) { void analogWritePin(AnalogPin name, int value) {
PINOP(setAnalogValue(value)); PINOP(setAnalogValue(value));
} }
@ -178,6 +182,7 @@ namespace pins {
//% 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.fieldEditor="gridpicker" pin.fieldOptions.columns=4
//% pin.fieldOptions.tooltips="false" //% pin.fieldOptions.tooltips="false"
//% group="Analog"
void analogSetPeriod(AnalogPin name, int micros) { void analogSetPeriod(AnalogPin name, int micros) {
PINOP(setAnalogPeriodUs(micros)); PINOP(setAnalogPeriodUs(micros));
} }
@ -191,6 +196,7 @@ namespace pins {
//% 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.fieldEditor="gridpicker" pin.fieldOptions.columns=4
//% pin.fieldOptions.tooltips="false" pin.fieldOptions.width="250" //% pin.fieldOptions.tooltips="false" pin.fieldOptions.width="250"
//% group="Pulse"
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;
@ -205,6 +211,7 @@ namespace pins {
//% help=pins/pulse-duration advanced=true //% help=pins/pulse-duration advanced=true
//% blockId=pins_pulse_duration block="pulse duration (µs)" //% blockId=pins_pulse_duration block="pulse duration (µs)"
//% weight=21 blockGap=8 //% weight=21 blockGap=8
//% group="Pulse"
int pulseDuration() { int pulseDuration() {
return pxt::lastEvent.timestamp; return pxt::lastEvent.timestamp;
} }
@ -220,6 +227,7 @@ namespace pins {
//% help=pins/pulse-in //% help=pins/pulse-in
//% name.fieldEditor="gridpicker" name.fieldOptions.columns=4 //% name.fieldEditor="gridpicker" name.fieldOptions.columns=4
//% name.fieldOptions.tooltips="false" name.fieldOptions.width="250" //% name.fieldOptions.tooltips="false" name.fieldOptions.width="250"
//% group="Pulse"
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;
@ -275,6 +283,7 @@ namespace pins {
//% value.min=0 value.max=180 //% value.min=0 value.max=180
//% name.fieldEditor="gridpicker" name.fieldOptions.columns=4 //% name.fieldEditor="gridpicker" name.fieldOptions.columns=4
//% name.fieldOptions.tooltips="false" name.fieldOptions.width="250" //% name.fieldOptions.tooltips="false" name.fieldOptions.width="250"
//% group="Servo"
void servoWritePin(AnalogPin name, int value) { void servoWritePin(AnalogPin name, int value) {
PINOP(setServoValue(value)); PINOP(setServoValue(value));
} }
@ -283,6 +292,7 @@ namespace pins {
* Specifies that a continuous servo is connected. * Specifies that a continuous servo is connected.
*/ */
//% //%
//% group="Servo"
void servoSetContinuous(AnalogPin name, bool value) { void servoSetContinuous(AnalogPin name, bool value) {
// handled in simulator // handled in simulator
} }
@ -296,6 +306,7 @@ namespace pins {
//% 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.fieldEditor="gridpicker" value.fieldOptions.columns=4
//% value.fieldOptions.tooltips="false" value.fieldOptions.width="250" //% value.fieldOptions.tooltips="false" value.fieldOptions.width="250"
//% group="Servo"
void servoSetPulse(AnalogPin name, int micros) { void servoSetPulse(AnalogPin name, int micros) {
fixMotorIssue(name); fixMotorIssue(name);
PINOP(setServoPulseUs(micros)); PINOP(setServoPulseUs(micros));
@ -316,6 +327,7 @@ namespace pins {
//% name.fieldEditor="gridpicker" name.fieldOptions.columns=4 //% name.fieldEditor="gridpicker" name.fieldOptions.columns=4
//% name.fieldOptions.tooltips="false" name.fieldOptions.width="250" //% name.fieldOptions.tooltips="false" name.fieldOptions.width="250"
//% blockHidden=true //% blockHidden=true
//% group="Pitch"
void analogSetPitchPin(AnalogPin name) { void analogSetPitchPin(AnalogPin name) {
pitchPin = getPin((int)name); pitchPin = getPin((int)name);
pitchPin2 = NULL; pitchPin2 = NULL;
@ -339,6 +351,7 @@ namespace pins {
//% help=pins/analog-set-pitch-volume weight=3 advanced=true //% help=pins/analog-set-pitch-volume weight=3 advanced=true
//% volume.min=0 volume.max=255 //% volume.min=0 volume.max=255
//% blockHidden=true //% blockHidden=true
//% group="Pitch"
void analogSetPitchVolume(int volume) { void analogSetPitchVolume(int volume) {
pitchVolume = max(0, min(0xff, volume)); pitchVolume = max(0, min(0xff, volume));
@ -355,6 +368,7 @@ namespace pins {
//% blockId=device_analog_pitch_volume block="analog pitch volume" //% blockId=device_analog_pitch_volume block="analog pitch volume"
//% help=pins/analog-pitch-volume weight=3 advanced=true //% help=pins/analog-pitch-volume weight=3 advanced=true
//% blockHidden=true //% blockHidden=true
//% group="Pitch"
int analogPitchVolume() { int analogPitchVolume() {
return pitchVolume; return pitchVolume;
} }
@ -367,6 +381,7 @@ namespace pins {
//% blockId=device_analog_pitch block="analog pitch %frequency|for (ms) %ms" //% blockId=device_analog_pitch block="analog pitch %frequency|for (ms) %ms"
//% help=pins/analog-pitch weight=4 async advanced=true blockGap=8 //% help=pins/analog-pitch weight=4 async advanced=true blockGap=8
//% blockHidden=true //% blockHidden=true
//% group="Pitch"
void analogPitch(int frequency, int ms) { void analogPitch(int frequency, int ms) {
// init pins if needed // init pins if needed
if (NULL == pitchPin) { if (NULL == pitchPin) {
@ -402,6 +417,7 @@ namespace pins {
//% 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.fieldEditor="gridpicker" pin.fieldOptions.columns=4
//% pin.fieldOptions.tooltips="false" pin.fieldOptions.width="250" //% pin.fieldOptions.tooltips="false" pin.fieldOptions.width="250"
//% group="Digital"
void setPull(DigitalPin name, PinPullMode pull) { void setPull(DigitalPin name, PinPullMode pull) {
#if MICROBIT_CODAL #if MICROBIT_CODAL
codal::PullMode m = pull == PinPullMode::PullDown codal::PullMode m = pull == PinPullMode::PullDown
@ -428,6 +444,7 @@ namespace pins {
//% 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.fieldEditor="gridpicker" pin.fieldOptions.columns=4
//% pin.fieldOptions.tooltips="false" pin.fieldOptions.width="250" //% pin.fieldOptions.tooltips="false" pin.fieldOptions.width="250"
//% group="Digital"
void setEvents(DigitalPin name, PinEventType type) { void setEvents(DigitalPin name, PinEventType type) {
getPin((int)name)->eventOn((int)type); getPin((int)name)->eventOn((int)type);
} }
@ -467,6 +484,7 @@ namespace pins {
* Read `size` bytes from a 7-bit I2C `address`. * Read `size` bytes from a 7-bit I2C `address`.
*/ */
//% //%
//% group="i2c"
Buffer i2cReadBuffer(int address, int size, bool repeat = false) Buffer i2cReadBuffer(int address, int size, bool repeat = false)
{ {
Buffer buf = createBuffer(size); Buffer buf = createBuffer(size);
@ -478,6 +496,7 @@ namespace pins {
* Write bytes to a 7-bit I2C `address`. * Write bytes to a 7-bit I2C `address`.
*/ */
//% //%
//% group="i2c"
int i2cWriteBuffer(int address, Buffer buf, bool repeat = false) int i2cWriteBuffer(int address, Buffer buf, bool repeat = false)
{ {
return uBit.i2c.write(address << 1, (BUFFER_TYPE)buf->data, buf->length, repeat); return uBit.i2c.write(address << 1, (BUFFER_TYPE)buf->data, buf->length, repeat);
@ -496,6 +515,7 @@ namespace pins {
*/ */
//% help=pins/spi-write weight=5 advanced=true //% help=pins/spi-write weight=5 advanced=true
//% blockId=spi_write block="spi write %value" //% blockId=spi_write block="spi write %value"
//% group="spi"
int spiWrite(int value) { int spiWrite(int value) {
auto p = allocSPI(); auto p = allocSPI();
return p->write(value); return p->write(value);
@ -507,6 +527,7 @@ namespace pins {
* @param response Data received from the SPI slave (can be null) * @param response Data received from the SPI slave (can be null)
*/ */
//% help=pins/spi-transfer argsNullable //% help=pins/spi-transfer argsNullable
//% group="spi"
void spiTransfer(Buffer command, Buffer response) { void spiTransfer(Buffer command, Buffer response) {
if (!command && !response) if (!command && !response)
target_panic(PANIC_INVALID_ARGUMENT); target_panic(PANIC_INVALID_ARGUMENT);
@ -531,6 +552,7 @@ namespace pins {
*/ */
//% help=pins/spi-frequency weight=4 advanced=true //% help=pins/spi-frequency weight=4 advanced=true
//% blockId=spi_frequency block="spi frequency %frequency" //% blockId=spi_frequency block="spi frequency %frequency"
//% group="spi"
void spiFrequency(int frequency) { void spiFrequency(int frequency) {
auto p = allocSPI(); auto p = allocSPI();
p->frequency(frequency); p->frequency(frequency);
@ -543,6 +565,7 @@ namespace pins {
*/ */
//% help=pins/spi-format weight=3 advanced=true //% help=pins/spi-format weight=3 advanced=true
//% blockId=spi_format block="spi format|bits %bits|mode %mode" //% blockId=spi_format block="spi format|bits %bits|mode %mode"
//% group="spi"
void spiFormat(int bits, int mode) { void spiFormat(int bits, int mode) {
auto p = allocSPI(); auto p = allocSPI();
p->format(bits, mode); p->format(bits, mode);
@ -566,6 +589,7 @@ namespace pins {
//% miso.fieldOptions.tooltips="false" miso.fieldOptions.width="250" //% miso.fieldOptions.tooltips="false" miso.fieldOptions.width="250"
//% sck.fieldEditor="gridpicker" sck.fieldOptions.columns=4 //% sck.fieldEditor="gridpicker" sck.fieldOptions.columns=4
//% sck.fieldOptions.tooltips="false" sck.fieldOptions.width="250" //% sck.fieldOptions.tooltips="false" sck.fieldOptions.width="250"
//% group="spi"
void spiPins(DigitalPin mosi, DigitalPin miso, DigitalPin sck) { void spiPins(DigitalPin mosi, DigitalPin miso, DigitalPin sck) {
if (NULL != spi) { if (NULL != spi) {
delete spi; delete spi;
@ -578,6 +602,7 @@ namespace pins {
* Mounts a push button on the given pin * Mounts a push button on the given pin
*/ */
//% help=pins/push-button advanced=true //% help=pins/push-button advanced=true
//% group="Digital"
void pushButton(DigitalPin pin) { void pushButton(DigitalPin pin) {
new MicroBitButton((PinName)getPin((int)(pin))->name, (int)pin, MICROBIT_BUTTON_ALL_EVENTS, PinMode::PullUp); new MicroBitButton((PinName)getPin((int)(pin))->name, (int)pin, MICROBIT_BUTTON_ALL_EVENTS, PinMode::PullUp);
} }
@ -592,6 +617,7 @@ namespace pins {
//% name.fieldOptions.tooltips="false" name.fieldOptions.width="250" //% name.fieldOptions.tooltips="false" name.fieldOptions.width="250"
//% weight=1 //% weight=1
//% blockHidden=true //% blockHidden=true
//% group="Pitch"
void setAudioPin(AnalogPin name) { void setAudioPin(AnalogPin name) {
#if MICROBIT_CODAL #if MICROBIT_CODAL
uBit.audio.setPin(*getPin((int)name)); uBit.audio.setPin(*getPin((int)name));

View File

@ -3,6 +3,8 @@
*/ */
//% color=#A80000 weight=30 icon="\uf140" //% color=#A80000 weight=30 icon="\uf140"
//% advanced=true //% advanced=true
//% groups=['Analog', 'Digital', 'Servos', 'Pulse', 'Pitch', 'i2c', 'spi']
namespace pins { namespace pins {
/** /**
* Map a number from one range to another. That is, a value of ``from low`` would get mapped to ``to low``, a value of ``from high`` to ``to high``, values in-between to values in-between, etc. * Map a number from one range to another. That is, a value of ``from low`` would get mapped to ``to low``, a value of ``from high`` to ``to high``, values in-between to values in-between, etc.
@ -14,6 +16,7 @@ namespace pins {
*/ */
//% help=pins/map weight=23 //% help=pins/map weight=23
//% blockId=pin_map block="map %value|from low %fromLow|from high %fromHigh|to low %toLow|to high %toHigh" //% blockId=pin_map block="map %value|from low %fromLow|from high %fromHigh|to low %toLow|to high %toHigh"
//% deprecated=true
export function map(value: number, fromLow: number, fromHigh: number, toLow: number, toHigh: number): number { export function map(value: number, fromLow: number, fromHigh: number, toLow: number, toHigh: number): number {
return ((value - fromLow) * (toHigh - toLow)) / (fromHigh - fromLow) + toLow; return ((value - fromLow) * (toHigh - toLow)) / (fromHigh - fromLow) + toLow;
} }
@ -23,6 +26,7 @@ namespace pins {
*/ */
//% help=pins/i2c-read-number blockGap=8 advanced=true //% help=pins/i2c-read-number blockGap=8 advanced=true
//% blockId=pins_i2c_readnumber block="i2c read number|at address %address|of format %format|repeated %repeat" weight=7 //% blockId=pins_i2c_readnumber block="i2c read number|at address %address|of format %format|repeated %repeat" weight=7
//% group="i2c"
export function i2cReadNumber(address: number, format: NumberFormat, repeated?: boolean): number { export function i2cReadNumber(address: number, format: NumberFormat, repeated?: boolean): number {
let buf = pins.i2cReadBuffer(address, pins.sizeOf(format), repeated) let buf = pins.i2cReadBuffer(address, pins.sizeOf(format), repeated)
return buf.getNumber(format, 0) return buf.getNumber(format, 0)
@ -33,6 +37,7 @@ namespace pins {
*/ */
//% help=pins/i2c-write-number blockGap=8 advanced=true //% help=pins/i2c-write-number blockGap=8 advanced=true
//% blockId=i2c_writenumber block="i2c write number|at address %address|with value %value|of format %format|repeated %repeat" weight=6 //% blockId=i2c_writenumber block="i2c write number|at address %address|with value %value|of format %format|repeated %repeat" weight=6
//% group="i2c"
export function i2cWriteNumber(address: number, value: number, format: NumberFormat, repeated?: boolean): void { export function i2cWriteNumber(address: number, value: number, format: NumberFormat, repeated?: boolean): void {
let buf = createBuffer(pins.sizeOf(format)) let buf = createBuffer(pins.sizeOf(format))
buf.setNumber(format, 0, value) buf.setNumber(format, 0, value)

View File

@ -116,6 +116,7 @@
"pairing_mode": 1, "pairing_mode": 1,
"private_addressing": 0, "private_addressing": 0,
"open": 1, "open": 1,
"partial_flashing": 1,
"security_level": null, "security_level": null,
"whitelist": 1, "whitelist": 1,
"advertising_timeout": 0, "advertising_timeout": 0,
@ -125,7 +126,7 @@
"device_info_service": 0 "device_info_service": 0
}, },
"stack_size": 1280, "stack_size": 1280,
"gatt_table_size": "0xD8", "gatt_table_size": "0x200",
"panic_on_heap_full": 0, "panic_on_heap_full": 0,
"debug": 0, "debug": 0,
"heap_debug": 0, "heap_debug": 0,
@ -139,7 +140,7 @@
"config": { "config": {
"microbit-dal": { "microbit-dal": {
"stack_size": 2048, "stack_size": 2048,
"gatt_table_size": "0x600", "gatt_table_size": "0x700",
"sram_end": "0x20008000", "sram_end": "0x20008000",
"RAM_SIZE": "\"32K\"" "RAM_SIZE": "\"32K\""
} }
@ -150,7 +151,7 @@
"config": { "config": {
"microbit-dal": { "microbit-dal": {
"stack_size": 1280, "stack_size": 1280,
"gatt_table_size": "0xD8", "gatt_table_size": "0x200",
"sram_end": "0x20004000", "sram_end": "0x20004000",
"RAM_SIZE": "\"16K\"" "RAM_SIZE": "\"16K\""
} }

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

@ -160,7 +160,7 @@ declare namespace basic {
//% text.shadowOptions.toString=true //% text.shadowOptions.toString=true
//% expandableArgumentMode="toggle" //% expandableArgumentMode="toggle"
//% //%
//% group="LED matrix" interval.defl=80 shim=basic::showString //% group="LED matrix" interval.defl=150 shim=basic::showString
function showString(text: string, interval?: int32): void; function showString(text: string, interval?: int32): void;
/** /**
@ -294,6 +294,41 @@ declare namespace input {
//% group="States" shim=input::buttonIsPressed //% group="States" shim=input::buttonIsPressed
function buttonIsPressed(button: Button): boolean; function buttonIsPressed(button: Button): boolean;
/**
* Do something when a button (A, B or both A+B) is pushed down and released again.
* @param button the button that needs to be pressed
* @param body code to run when event is raised
*/
//% help=input/on-button-pressed weight=85 blockGap=16
//% blockId=device_button_event block="on button|%NAME|pressed"
//% parts="buttonpair"
//% deprecated=true
//% group="Events" shim=input::onButtonPressed
function onButtonPressed(button: Button, body: () => void): void;
/**
* Do something when a pin is touched and released again (while also touching the GND pin).
* @param name the pin that needs to be pressed, eg: TouchPin.P0
* @param body the code to run when the pin is pressed
*/
//% help=input/on-pin-pressed weight=83 blockGap=16
//% blockId=device_pin_event block="on pin %name|pressed"
//% group="Events"
//% deprecated=true shim=input::onPinPressed
function onPinPressed(name: TouchPin, body: () => void): void;
/**
* Do something when a pin is released.
* @param name the pin that needs to be released, eg: TouchPin.P0
* @param body the code to run when the pin is released
*/
//% help=input/on-pin-released weight=6 blockGap=16
//% blockId=device_pin_released block="on pin %NAME|released"
//% advanced=true
//% group="Events"
//% deprecated=true shim=input::onPinReleased
function onPinReleased(name: TouchPin, body: () => void): void;
/** /**
* Get the pin state (pressed or not). Requires to hold the ground to close the circuit. * Get the pin state (pressed or not). Requires to hold the ground to close the circuit.
* @param name pin used to detect the touch, eg: TouchPin.P0 * @param name pin used to detect the touch, eg: TouchPin.P0
@ -783,7 +818,8 @@ declare 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.fieldEditor="gridpicker" name.fieldOptions.columns=4
//% name.fieldOptions.tooltips="false" name.fieldOptions.width="250" shim=pins::digitalReadPin //% name.fieldOptions.tooltips="false" name.fieldOptions.width="250"
//% group="Digital" shim=pins::digitalReadPin
function digitalReadPin(name: DigitalPin): int32; function digitalReadPin(name: DigitalPin): int32;
/** /**
@ -795,7 +831,8 @@ declare namespace pins {
//% 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.fieldEditor="gridpicker" name.fieldOptions.columns=4
//% name.fieldOptions.tooltips="false" name.fieldOptions.width="250" shim=pins::digitalWritePin //% name.fieldOptions.tooltips="false" name.fieldOptions.width="250"
//% group="Digital" shim=pins::digitalWritePin
function digitalWritePin(name: DigitalPin, value: int32): void; function digitalWritePin(name: DigitalPin, value: int32): void;
/** /**
@ -805,7 +842,8 @@ declare 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.fieldEditor="gridpicker" name.fieldOptions.columns=4
//% name.fieldOptions.tooltips="false" name.fieldOptions.width="250" shim=pins::analogReadPin //% name.fieldOptions.tooltips="false" name.fieldOptions.width="250"
//% group="Analog" shim=pins::analogReadPin
function analogReadPin(name: AnalogPin): int32; function analogReadPin(name: AnalogPin): int32;
/** /**
@ -817,7 +855,8 @@ declare namespace pins {
//% 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.fieldEditor="gridpicker" name.fieldOptions.columns=4
//% name.fieldOptions.tooltips="false" name.fieldOptions.width="250" shim=pins::analogWritePin //% name.fieldOptions.tooltips="false" name.fieldOptions.width="250"
//% group="Analog" shim=pins::analogWritePin
function analogWritePin(name: AnalogPin, value: int32): void; function analogWritePin(name: AnalogPin, value: int32): void;
/** /**
@ -829,7 +868,8 @@ declare 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.fieldEditor="gridpicker" pin.fieldOptions.columns=4
//% pin.fieldOptions.tooltips="false" shim=pins::analogSetPeriod //% pin.fieldOptions.tooltips="false"
//% group="Analog" shim=pins::analogSetPeriod
function analogSetPeriod(name: AnalogPin, micros: int32): void; function analogSetPeriod(name: AnalogPin, micros: int32): void;
/** /**
@ -840,7 +880,8 @@ declare namespace pins {
//% help=pins/on-pulsed weight=22 blockGap=16 advanced=true //% help=pins/on-pulsed weight=22 blockGap=16 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.fieldEditor="gridpicker" pin.fieldOptions.columns=4
//% pin.fieldOptions.tooltips="false" pin.fieldOptions.width="250" shim=pins::onPulsed //% pin.fieldOptions.tooltips="false" pin.fieldOptions.width="250"
//% group="Pulse" shim=pins::onPulsed
function onPulsed(name: DigitalPin, pulse: PulseValue, body: () => void): void; function onPulsed(name: DigitalPin, pulse: PulseValue, body: () => void): void;
/** /**
@ -848,7 +889,8 @@ declare namespace pins {
*/ */
//% help=pins/pulse-duration advanced=true //% help=pins/pulse-duration advanced=true
//% blockId=pins_pulse_duration block="pulse duration (µs)" //% blockId=pins_pulse_duration block="pulse duration (µs)"
//% weight=21 blockGap=8 shim=pins::pulseDuration //% weight=21 blockGap=8
//% group="Pulse" shim=pins::pulseDuration
function pulseDuration(): int32; function pulseDuration(): int32;
/** /**
@ -861,7 +903,8 @@ declare namespace pins {
//% weight=20 advanced=true //% weight=20 advanced=true
//% help=pins/pulse-in //% help=pins/pulse-in
//% name.fieldEditor="gridpicker" name.fieldOptions.columns=4 //% name.fieldEditor="gridpicker" name.fieldOptions.columns=4
//% name.fieldOptions.tooltips="false" name.fieldOptions.width="250" maxDuration.defl=2000000 shim=pins::pulseIn //% name.fieldOptions.tooltips="false" name.fieldOptions.width="250"
//% group="Pulse" maxDuration.defl=2000000 shim=pins::pulseIn
function pulseIn(name: DigitalPin, value: PulseValue, maxDuration?: int32): int32; function pulseIn(name: DigitalPin, value: PulseValue, maxDuration?: int32): int32;
/** /**
@ -874,13 +917,15 @@ declare namespace pins {
//% 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.fieldEditor="gridpicker" name.fieldOptions.columns=4
//% name.fieldOptions.tooltips="false" name.fieldOptions.width="250" shim=pins::servoWritePin //% name.fieldOptions.tooltips="false" name.fieldOptions.width="250"
//% group="Servo" shim=pins::servoWritePin
function servoWritePin(name: AnalogPin, value: int32): void; function servoWritePin(name: AnalogPin, value: int32): void;
/** /**
* Specifies that a continuous servo is connected. * Specifies that a continuous servo is connected.
*/ */
//% shim=pins::servoSetContinuous //%
//% group="Servo" shim=pins::servoSetContinuous
function servoSetContinuous(name: AnalogPin, value: boolean): void; function servoSetContinuous(name: AnalogPin, value: boolean): void;
/** /**
@ -891,7 +936,8 @@ declare 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.fieldEditor="gridpicker" value.fieldOptions.columns=4
//% value.fieldOptions.tooltips="false" value.fieldOptions.width="250" shim=pins::servoSetPulse //% value.fieldOptions.tooltips="false" value.fieldOptions.width="250"
//% group="Servo" shim=pins::servoSetPulse
function servoSetPulse(name: AnalogPin, micros: int32): void; function servoSetPulse(name: AnalogPin, micros: int32): void;
/** /**
@ -902,7 +948,8 @@ declare namespace pins {
//% help=pins/analog-set-pitch-pin weight=3 advanced=true //% help=pins/analog-set-pitch-pin weight=3 advanced=true
//% name.fieldEditor="gridpicker" name.fieldOptions.columns=4 //% name.fieldEditor="gridpicker" name.fieldOptions.columns=4
//% name.fieldOptions.tooltips="false" name.fieldOptions.width="250" //% name.fieldOptions.tooltips="false" name.fieldOptions.width="250"
//% blockHidden=true shim=pins::analogSetPitchPin //% blockHidden=true
//% group="Pitch" shim=pins::analogSetPitchPin
function analogSetPitchPin(name: AnalogPin): void; function analogSetPitchPin(name: AnalogPin): void;
/** /**
@ -912,7 +959,8 @@ declare namespace pins {
//% blockId=device_analog_set_pitch_volume block="analog set pitch volume $volume" //% blockId=device_analog_set_pitch_volume block="analog set pitch volume $volume"
//% help=pins/analog-set-pitch-volume weight=3 advanced=true //% help=pins/analog-set-pitch-volume weight=3 advanced=true
//% volume.min=0 volume.max=255 //% volume.min=0 volume.max=255
//% blockHidden=true shim=pins::analogSetPitchVolume //% blockHidden=true
//% group="Pitch" shim=pins::analogSetPitchVolume
function analogSetPitchVolume(volume: int32): void; function analogSetPitchVolume(volume: int32): void;
/** /**
@ -920,7 +968,8 @@ declare namespace pins {
*/ */
//% blockId=device_analog_pitch_volume block="analog pitch volume" //% blockId=device_analog_pitch_volume block="analog pitch volume"
//% help=pins/analog-pitch-volume weight=3 advanced=true //% help=pins/analog-pitch-volume weight=3 advanced=true
//% blockHidden=true shim=pins::analogPitchVolume //% blockHidden=true
//% group="Pitch" shim=pins::analogPitchVolume
function analogPitchVolume(): int32; function analogPitchVolume(): int32;
/** /**
@ -930,7 +979,8 @@ declare namespace pins {
*/ */
//% blockId=device_analog_pitch block="analog pitch %frequency|for (ms) %ms" //% blockId=device_analog_pitch block="analog pitch %frequency|for (ms) %ms"
//% help=pins/analog-pitch weight=4 async advanced=true blockGap=8 //% help=pins/analog-pitch weight=4 async advanced=true blockGap=8
//% blockHidden=true shim=pins::analogPitch //% blockHidden=true
//% group="Pitch" shim=pins::analogPitch
function analogPitch(frequency: int32, ms: int32): void; function analogPitch(frequency: int32, ms: int32): void;
/** /**
@ -941,7 +991,8 @@ declare 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.fieldEditor="gridpicker" pin.fieldOptions.columns=4
//% pin.fieldOptions.tooltips="false" pin.fieldOptions.width="250" shim=pins::setPull //% pin.fieldOptions.tooltips="false" pin.fieldOptions.width="250"
//% group="Digital" shim=pins::setPull
function setPull(name: DigitalPin, pull: PinPullMode): void; function setPull(name: DigitalPin, pull: PinPullMode): void;
/** /**
@ -953,7 +1004,8 @@ declare 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.fieldEditor="gridpicker" pin.fieldOptions.columns=4
//% pin.fieldOptions.tooltips="false" pin.fieldOptions.width="250" shim=pins::setEvents //% pin.fieldOptions.tooltips="false" pin.fieldOptions.width="250"
//% group="Digital" shim=pins::setEvents
function setEvents(name: DigitalPin, type: PinEventType): void; function setEvents(name: DigitalPin, type: PinEventType): void;
/** /**
@ -980,13 +1032,15 @@ declare namespace pins {
/** /**
* Read `size` bytes from a 7-bit I2C `address`. * Read `size` bytes from a 7-bit I2C `address`.
*/ */
//% repeat.defl=0 shim=pins::i2cReadBuffer //%
//% group="i2c" repeat.defl=0 shim=pins::i2cReadBuffer
function i2cReadBuffer(address: int32, size: int32, repeat?: boolean): Buffer; function i2cReadBuffer(address: int32, size: int32, repeat?: boolean): Buffer;
/** /**
* Write bytes to a 7-bit I2C `address`. * Write bytes to a 7-bit I2C `address`.
*/ */
//% repeat.defl=0 shim=pins::i2cWriteBuffer //%
//% group="i2c" repeat.defl=0 shim=pins::i2cWriteBuffer
function i2cWriteBuffer(address: int32, buf: Buffer, repeat?: boolean): int32; function i2cWriteBuffer(address: int32, buf: Buffer, repeat?: boolean): int32;
/** /**
@ -994,7 +1048,8 @@ declare namespace pins {
* @param value Data to be sent to the SPI slave * @param value Data to be sent to the SPI slave
*/ */
//% help=pins/spi-write weight=5 advanced=true //% help=pins/spi-write weight=5 advanced=true
//% blockId=spi_write block="spi write %value" shim=pins::spiWrite //% blockId=spi_write block="spi write %value"
//% group="spi" shim=pins::spiWrite
function spiWrite(value: int32): int32; function spiWrite(value: int32): int32;
/** /**
@ -1002,7 +1057,8 @@ declare namespace pins {
* @param command Data to be sent to the SPI slave (can be null) * @param command Data to be sent to the SPI slave (can be null)
* @param response Data received from the SPI slave (can be null) * @param response Data received from the SPI slave (can be null)
*/ */
//% help=pins/spi-transfer argsNullable shim=pins::spiTransfer //% help=pins/spi-transfer argsNullable
//% group="spi" shim=pins::spiTransfer
function spiTransfer(command: Buffer, response: Buffer): void; function spiTransfer(command: Buffer, response: Buffer): void;
/** /**
@ -1010,7 +1066,8 @@ declare namespace pins {
* @param frequency the clock frequency, eg: 1000000 * @param frequency the clock frequency, eg: 1000000
*/ */
//% help=pins/spi-frequency weight=4 advanced=true //% help=pins/spi-frequency weight=4 advanced=true
//% blockId=spi_frequency block="spi frequency %frequency" shim=pins::spiFrequency //% blockId=spi_frequency block="spi frequency %frequency"
//% group="spi" shim=pins::spiFrequency
function spiFrequency(frequency: int32): void; function spiFrequency(frequency: int32): void;
/** /**
@ -1019,7 +1076,8 @@ declare namespace pins {
* @param mode the mode, eg: 3 * @param mode the mode, eg: 3
*/ */
//% help=pins/spi-format weight=3 advanced=true //% help=pins/spi-format weight=3 advanced=true
//% blockId=spi_format block="spi format|bits %bits|mode %mode" shim=pins::spiFormat //% blockId=spi_format block="spi format|bits %bits|mode %mode"
//% group="spi" shim=pins::spiFormat
function spiFormat(bits: int32, mode: int32): void; function spiFormat(bits: int32, mode: int32): void;
/** /**
@ -1033,13 +1091,15 @@ declare namespace pins {
//% miso.fieldEditor="gridpicker" miso.fieldOptions.columns=4 //% miso.fieldEditor="gridpicker" miso.fieldOptions.columns=4
//% miso.fieldOptions.tooltips="false" miso.fieldOptions.width="250" //% miso.fieldOptions.tooltips="false" miso.fieldOptions.width="250"
//% sck.fieldEditor="gridpicker" sck.fieldOptions.columns=4 //% sck.fieldEditor="gridpicker" sck.fieldOptions.columns=4
//% sck.fieldOptions.tooltips="false" sck.fieldOptions.width="250" shim=pins::spiPins //% sck.fieldOptions.tooltips="false" sck.fieldOptions.width="250"
//% group="spi" shim=pins::spiPins
function spiPins(mosi: DigitalPin, miso: DigitalPin, sck: DigitalPin): void; function spiPins(mosi: DigitalPin, miso: DigitalPin, sck: DigitalPin): void;
/** /**
* Mounts a push button on the given pin * Mounts a push button on the given pin
*/ */
//% help=pins/push-button advanced=true shim=pins::pushButton //% help=pins/push-button advanced=true
//% group="Digital" shim=pins::pushButton
function pushButton(pin: DigitalPin): void; function pushButton(pin: DigitalPin): void;
/** /**
@ -1051,7 +1111,8 @@ declare namespace pins {
//% name.fieldEditor="gridpicker" name.fieldOptions.columns=4 //% name.fieldEditor="gridpicker" name.fieldOptions.columns=4
//% name.fieldOptions.tooltips="false" name.fieldOptions.width="250" //% name.fieldOptions.tooltips="false" name.fieldOptions.width="250"
//% weight=1 //% weight=1
//% blockHidden=true shim=pins::setAudioPin //% blockHidden=true
//% group="Pitch" shim=pins::setAudioPin
function setAudioPin(name: AnalogPin): void; function setAudioPin(name: AnalogPin): void;
} }

View File

@ -46,6 +46,6 @@
}, },
"dependencies": { "dependencies": {
"pxt-common-packages": "9.0.1", "pxt-common-packages": "9.0.1",
"pxt-core": "7.0.16" "pxt-core": "7.0.17"
} }
} }

View File

@ -1873,7 +1873,7 @@ namespace pxsim.visuals {
if (!this.board.edgeConnectorState.pins[index]) return; if (!this.board.edgeConnectorState.pins[index]) return;
let pt = this.element.createSVGPoint(); let pt = this.element.createSVGPoint();
let xpos = (index === 0 || index === 3) ? 300 : 520; let xpos = (index === 0 || index === 3) ? 300 : 520;
let vMax = (index === 0 || index === 3) ? 1 : 1032; let vMax = (index === 0 || index === 3) ? 1 : 1023;
svg.buttonEvents(pin, svg.buttonEvents(pin,
// move // move
ev => { ev => {
@ -1978,8 +1978,8 @@ namespace pxsim.visuals {
private attachABEvents() { private attachABEvents() {
const bpState = this.board.buttonPairState; const bpState = this.board.buttonPairState;
const stateButtons: Button[] = [bpState.aBtn, bpState.bBtn]; const stateButtons: Button[] = [bpState.aBtn, bpState.bBtn];
const elButtonOuters = this.buttonsOuter.slice(6, 8); const elButtonOuters = this.buttonsOuter.slice(0,2);
const elButtons = this.buttons.slice(6, 8); const elButtons = this.buttons.slice(0,2);
elButtonOuters.forEach((btn, index) => { elButtonOuters.forEach((btn, index) => {
let pressedTime: number; let pressedTime: number;
@ -2015,6 +2015,7 @@ namespace pxsim.visuals {
private attachAPlusBEvents() { private attachAPlusBEvents() {
const bpState = this.board.buttonPairState; const bpState = this.board.buttonPairState;
const stateButtons: Button[] = [bpState.aBtn, bpState.bBtn];
let pressedTime: number; let pressedTime: number;
// A+B // A+B
pointerEvents.down.forEach(evid => this.buttonsOuter[2].addEventListener(evid, ev => { pointerEvents.down.forEach(evid => this.buttonsOuter[2].addEventListener(evid, ev => {
@ -2024,6 +2025,8 @@ namespace pxsim.visuals {
svg.fill(this.buttons[0], this.props.theme.buttonDown); svg.fill(this.buttons[0], this.props.theme.buttonDown);
svg.fill(this.buttons[1], this.props.theme.buttonDown); svg.fill(this.buttons[1], this.props.theme.buttonDown);
svg.fill(this.buttons[2], this.props.theme.buttonDown); svg.fill(this.buttons[2], this.props.theme.buttonDown);
this.board.bus.queue(stateButtons[0].id, DAL.MICROBIT_BUTTON_EVT_DOWN);
this.board.bus.queue(stateButtons[1].id, DAL.MICROBIT_BUTTON_EVT_DOWN);
this.board.bus.queue(bpState.abBtn.id, DAL.MICROBIT_BUTTON_EVT_DOWN); this.board.bus.queue(bpState.abBtn.id, DAL.MICROBIT_BUTTON_EVT_DOWN);
pressedTime = runtime.runningTime() pressedTime = runtime.runningTime()
})); }));
@ -2043,6 +2046,8 @@ namespace pxsim.visuals {
svg.fill(this.buttons[1], this.props.theme.buttonUps[1]); svg.fill(this.buttons[1], this.props.theme.buttonUps[1]);
svg.fill(this.buttons[2], this.props.theme.virtualButtonUp); svg.fill(this.buttons[2], this.props.theme.virtualButtonUp);
this.board.bus.queue(stateButtons[0].id, DAL.MICROBIT_BUTTON_EVT_UP);
this.board.bus.queue(stateButtons[1].id, DAL.MICROBIT_BUTTON_EVT_UP);
this.board.bus.queue(bpState.abBtn.id, DAL.MICROBIT_BUTTON_EVT_UP); this.board.bus.queue(bpState.abBtn.id, DAL.MICROBIT_BUTTON_EVT_UP);
const currentTime = runtime.runningTime() const currentTime = runtime.runningTime()
if (currentTime - pressedTime > DAL.DEVICE_BUTTON_LONG_CLICK_TIME) if (currentTime - pressedTime > DAL.DEVICE_BUTTON_LONG_CLICK_TIME)

View File

@ -5,6 +5,8 @@
"51bit/SFC", "51bit/SFC",
"51bit/SmartTools", "51bit/SmartTools",
"51bit/dfplayermini", "51bit/dfplayermini",
"coding4coconut/pxt-lcd128x160-st7735s",
"coding4coconut/pxt-oled128x128-sh1107",
"Freenove/Makecode-Extension-Starter-Kit", "Freenove/Makecode-Extension-Starter-Kit",
"joernalraun/pxt-remember-int", "joernalraun/pxt-remember-int",
"KitronikLtd/pxt-kitronik-I2C-16-servo", "KitronikLtd/pxt-kitronik-I2C-16-servo",