Compare commits
25 Commits
Author | SHA1 | Date | |
---|---|---|---|
1d56be507a | |||
6504007a65 | |||
fc0526e47c | |||
cb47a6a291 | |||
6f8060a8c7 | |||
4a8897c0a4 | |||
839a26e5a7 | |||
b46802804c | |||
34d1fac337 | |||
39c41f26b1 | |||
083a192a5b | |||
76cbad0cec | |||
ed84d49667 | |||
b9d867cf4e | |||
226dfa281a | |||
cc4f6c66da | |||
49ecac6332 | |||
638e1d3c53 | |||
712bc0ada4 | |||
8437f0cf3c | |||
9641c4b5ec | |||
e29216c709 | |||
06e255eeb9 | |||
91c70e9809 | |||
8014712994 |
@ -21,7 +21,7 @@ Use pin press to switch guitar play on/off
|
|||||||
## Blocks
|
## Blocks
|
||||||
|
|
||||||
```cards
|
```cards
|
||||||
var on = false
|
let on = false
|
||||||
on;
|
on;
|
||||||
if (on) { } else {}
|
if (on) { } else {}
|
||||||
input.onPinPressed(TouchPin.P1, () => {})
|
input.onPinPressed(TouchPin.P1, () => {})
|
||||||
@ -106,7 +106,7 @@ input.onPinPressed(TouchPin.P1, () => {
|
|||||||
*Final code*
|
*Final code*
|
||||||
TODO: do we want to use `on = !on;` or be more direct in flipping the switch? `on = true; on = false;`
|
TODO: do we want to use `on = !on;` or be more direct in flipping the switch? `on = true; on = false;`
|
||||||
```blocks
|
```blocks
|
||||||
var on = false
|
let on = false
|
||||||
basic.forever(() => {
|
basic.forever(() => {
|
||||||
if (on) {
|
if (on) {
|
||||||
music.setTempo(pins.map(Math.abs(input.acceleration(Dimension.Y)),
|
music.setTempo(pins.map(Math.abs(input.acceleration(Dimension.Y)),
|
||||||
|
@ -7,6 +7,19 @@
|
|||||||
"AcceleratorRange.OneG|block": "1g",
|
"AcceleratorRange.OneG|block": "1g",
|
||||||
"AcceleratorRange.TwoG": "The accelerator measures forces up to 2 gravity",
|
"AcceleratorRange.TwoG": "The accelerator measures forces up to 2 gravity",
|
||||||
"AcceleratorRange.TwoG|block": "2g",
|
"AcceleratorRange.TwoG|block": "2g",
|
||||||
|
"AnalogPin.P11|block": "P11 (write only)",
|
||||||
|
"AnalogPin.P12|block": "P12 (write only)",
|
||||||
|
"AnalogPin.P13|block": "P13 (write only)",
|
||||||
|
"AnalogPin.P14|block": "P14 (write only)",
|
||||||
|
"AnalogPin.P15|block": "P15 (write only)",
|
||||||
|
"AnalogPin.P16|block": "P16 (write only)",
|
||||||
|
"AnalogPin.P19|block": "P19 (write only)",
|
||||||
|
"AnalogPin.P20|block": "P20 (write only)",
|
||||||
|
"AnalogPin.P5|block": "P5 (write only)",
|
||||||
|
"AnalogPin.P6|block": "P6 (write only)",
|
||||||
|
"AnalogPin.P7|block": "P5 (write only)",
|
||||||
|
"AnalogPin.P8|block": "P8 (write only)",
|
||||||
|
"AnalogPin.P9|block": "P9 (write only)",
|
||||||
"BaudRate.BaudRate115200|block": "115200",
|
"BaudRate.BaudRate115200|block": "115200",
|
||||||
"BaudRate.BaudRate9600|block": "9600",
|
"BaudRate.BaudRate9600|block": "9600",
|
||||||
"BeatFraction.Breve|block": "4",
|
"BeatFraction.Breve|block": "4",
|
||||||
@ -125,13 +138,13 @@
|
|||||||
"PulseValue.Low|block": "low",
|
"PulseValue.Low|block": "low",
|
||||||
"Rotation.Pitch|block": "pitch",
|
"Rotation.Pitch|block": "pitch",
|
||||||
"Rotation.Roll|block": "roll",
|
"Rotation.Roll|block": "roll",
|
||||||
"String.charAt|block": "char from %this|at %pos",
|
"String.charAt|block": "char from %this=text|at %pos",
|
||||||
"String.compare|block": "compare %this| to %that",
|
"String.compare|block": "compare %this=text| to %that",
|
||||||
"String.concat|block": "join %this|%other",
|
"String.concat|block": "join %this=text|%other",
|
||||||
"String.fromCharCode|block": "text from char code %code",
|
"String.fromCharCode|block": "text from char code %code",
|
||||||
"String.isEmpty|block": "%this| is empty",
|
"String.isEmpty|block": "%this=text| is empty",
|
||||||
"String.length|block": "length of %VALUE",
|
"String.length|block": "length of %VALUE",
|
||||||
"String.substr|block": "substring of %this|from %start|of length %length",
|
"String.substr|block": "substring of %this=text|from %start|of length %length",
|
||||||
"String|block": "String",
|
"String|block": "String",
|
||||||
"basic.clearScreen|block": "clear screen",
|
"basic.clearScreen|block": "clear screen",
|
||||||
"basic.forever|block": "forever",
|
"basic.forever|block": "forever",
|
||||||
|
26
libs/core/enums.d.ts
vendored
26
libs/core/enums.d.ts
vendored
@ -280,6 +280,32 @@ declare namespace led {
|
|||||||
P3 = 10, // MICROBIT_ID_IO_P3
|
P3 = 10, // MICROBIT_ID_IO_P3
|
||||||
P4 = 11, // MICROBIT_ID_IO_P4
|
P4 = 11, // MICROBIT_ID_IO_P4
|
||||||
P10 = 17, // MICROBIT_ID_IO_P10
|
P10 = 17, // MICROBIT_ID_IO_P10
|
||||||
|
//% block="P5 (write only)"
|
||||||
|
P5 = 12, // MICROBIT_ID_IO_P5
|
||||||
|
//% block="P6 (write only)"
|
||||||
|
P6 = 13, // MICROBIT_ID_IO_P6
|
||||||
|
//% block="P5 (write only)"
|
||||||
|
P7 = 14, // MICROBIT_ID_IO_P7
|
||||||
|
//% block="P8 (write only)"
|
||||||
|
P8 = 15, // MICROBIT_ID_IO_P8
|
||||||
|
//% block="P9 (write only)"
|
||||||
|
P9 = 16, // MICROBIT_ID_IO_P9
|
||||||
|
//% block="P11 (write only)"
|
||||||
|
P11 = 18, // MICROBIT_ID_IO_P11
|
||||||
|
//% block="P12 (write only)"
|
||||||
|
P12 = 19, // MICROBIT_ID_IO_P12
|
||||||
|
//% block="P13 (write only)"
|
||||||
|
P13 = 20, // MICROBIT_ID_IO_P13
|
||||||
|
//% block="P14 (write only)"
|
||||||
|
P14 = 21, // MICROBIT_ID_IO_P14
|
||||||
|
//% block="P15 (write only)"
|
||||||
|
P15 = 22, // MICROBIT_ID_IO_P15
|
||||||
|
//% block="P16 (write only)"
|
||||||
|
P16 = 23, // MICROBIT_ID_IO_P16
|
||||||
|
//% block="P19 (write only)"
|
||||||
|
P19 = 24, // MICROBIT_ID_IO_P19
|
||||||
|
//% block="P20 (write only)"
|
||||||
|
P20 = 25, // MICROBIT_ID_IO_P20
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -43,9 +43,9 @@ namespace ImageMethods {
|
|||||||
*/
|
*/
|
||||||
//% help=images/show-image weight=80 blockNamespace=images
|
//% help=images/show-image weight=80 blockNamespace=images
|
||||||
//% blockId=device_show_image_offset block="show image %sprite|at offset %offset" blockGap=8
|
//% blockId=device_show_image_offset block="show image %sprite|at offset %offset" blockGap=8
|
||||||
//% parts="ledmatrix"
|
//% parts="ledmatrix" async
|
||||||
void showImage(Image sprite, int xOffset) {
|
void showImage(Image sprite, int xOffset, int interval = 400) {
|
||||||
uBit.display.print(MicroBitImage(sprite), -xOffset, 0, 0);
|
uBit.display.print(MicroBitImage(sprite), -xOffset, 0, 0, interval);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -150,7 +150,7 @@ namespace ImageMethods {
|
|||||||
*/
|
*/
|
||||||
//% weight=70 help=images/show-frame
|
//% weight=70 help=images/show-frame
|
||||||
//% parts="ledmatrix"
|
//% parts="ledmatrix"
|
||||||
void showFrame(Image i, int frame) {
|
void showFrame(Image i, int frame, int interval = 400) {
|
||||||
showImage(i, frame * 5);
|
showImage(i, frame * 5, interval);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,6 +29,32 @@ enum class AnalogPin {
|
|||||||
P3 = MICROBIT_ID_IO_P3,
|
P3 = MICROBIT_ID_IO_P3,
|
||||||
P4 = MICROBIT_ID_IO_P4,
|
P4 = MICROBIT_ID_IO_P4,
|
||||||
P10 = MICROBIT_ID_IO_P10,
|
P10 = MICROBIT_ID_IO_P10,
|
||||||
|
//% block="P5 (write only)"
|
||||||
|
P5 = MICROBIT_ID_IO_P5,
|
||||||
|
//% block="P6 (write only)"
|
||||||
|
P6 = MICROBIT_ID_IO_P6,
|
||||||
|
//% block="P5 (write only)"
|
||||||
|
P7 = MICROBIT_ID_IO_P7,
|
||||||
|
//% block="P8 (write only)"
|
||||||
|
P8 = MICROBIT_ID_IO_P8,
|
||||||
|
//% block="P9 (write only)"
|
||||||
|
P9 = MICROBIT_ID_IO_P9,
|
||||||
|
//% block="P11 (write only)"
|
||||||
|
P11 = MICROBIT_ID_IO_P11,
|
||||||
|
//% block="P12 (write only)"
|
||||||
|
P12 = MICROBIT_ID_IO_P12,
|
||||||
|
//% block="P13 (write only)"
|
||||||
|
P13 = MICROBIT_ID_IO_P13,
|
||||||
|
//% block="P14 (write only)"
|
||||||
|
P14 = MICROBIT_ID_IO_P14,
|
||||||
|
//% block="P15 (write only)"
|
||||||
|
P15 = MICROBIT_ID_IO_P15,
|
||||||
|
//% block="P16 (write only)"
|
||||||
|
P16 = MICROBIT_ID_IO_P16,
|
||||||
|
//% block="P19 (write only)"
|
||||||
|
P19 = MICROBIT_ID_IO_P19,
|
||||||
|
//% block="P20 (write only)"
|
||||||
|
P20 = MICROBIT_ID_IO_P20
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class PulseValue {
|
enum class PulseValue {
|
||||||
|
8
libs/core/shims.d.ts
vendored
8
libs/core/shims.d.ts
vendored
@ -40,8 +40,8 @@ declare interface Image {
|
|||||||
*/
|
*/
|
||||||
//% help=images/show-image weight=80 blockNamespace=images
|
//% help=images/show-image weight=80 blockNamespace=images
|
||||||
//% blockId=device_show_image_offset block="show image %sprite|at offset %offset" blockGap=8
|
//% blockId=device_show_image_offset block="show image %sprite|at offset %offset" blockGap=8
|
||||||
//% parts="ledmatrix" shim=ImageMethods::showImage
|
//% parts="ledmatrix" async interval.defl=400 shim=ImageMethods::showImage
|
||||||
showImage(xOffset: number): void;
|
showImage(xOffset: number, interval?: number): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Draws the ``index``-th frame of the image on the screen.
|
* Draws the ``index``-th frame of the image on the screen.
|
||||||
@ -118,8 +118,8 @@ declare interface Image {
|
|||||||
* @param frame TODO
|
* @param frame TODO
|
||||||
*/
|
*/
|
||||||
//% weight=70 help=images/show-frame
|
//% weight=70 help=images/show-frame
|
||||||
//% parts="ledmatrix" shim=ImageMethods::showFrame
|
//% parts="ledmatrix" interval.defl=400 shim=ImageMethods::showFrame
|
||||||
showFrame(frame: number): void;
|
showFrame(frame: number, interval?: number): void;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "pxt-microbit",
|
"name": "pxt-microbit",
|
||||||
"version": "0.7.52",
|
"version": "0.9.1",
|
||||||
"description": "micro:bit target for PXT",
|
"description": "micro:bit target for PXT",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"JavaScript",
|
"JavaScript",
|
||||||
@ -36,6 +36,6 @@
|
|||||||
"semantic-ui-less": "^2.2.4"
|
"semantic-ui-less": "^2.2.4"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"pxt-core": "0.11.9"
|
"pxt-core": "0.11.25"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,8 +14,8 @@
|
|||||||
"cloud": {
|
"cloud": {
|
||||||
"workspace": false,
|
"workspace": false,
|
||||||
"packages": true,
|
"packages": true,
|
||||||
"sharing": false,
|
"sharing": true,
|
||||||
"publish": false,
|
"publishing": true,
|
||||||
"preferredPackages": [
|
"preferredPackages": [
|
||||||
"Microsoft/pxt-neopixel",
|
"Microsoft/pxt-neopixel",
|
||||||
"Microsoft/pxt-filesystem"
|
"Microsoft/pxt-filesystem"
|
||||||
@ -72,6 +72,7 @@
|
|||||||
"loopsBlocks": true,
|
"loopsBlocks": true,
|
||||||
"logicBlocks": true,
|
"logicBlocks": true,
|
||||||
"variablesBlocks": true,
|
"variablesBlocks": true,
|
||||||
|
"textBlocks": true,
|
||||||
"onStartColor": "#0078D7",
|
"onStartColor": "#0078D7",
|
||||||
"onStartNamespace": "basic",
|
"onStartNamespace": "basic",
|
||||||
"onStartWeight": 54
|
"onStartWeight": 54
|
||||||
|
@ -129,10 +129,11 @@ namespace pxsim.images {
|
|||||||
}
|
}
|
||||||
|
|
||||||
namespace pxsim.ImageMethods {
|
namespace pxsim.ImageMethods {
|
||||||
export function showImage(leds: Image, offset: number) {
|
export function showImage(leds: Image, offset: number, interval: number) {
|
||||||
pxtrt.nullCheck(leds)
|
pxtrt.nullCheck(leds)
|
||||||
leds.copyTo(offset, 5, board().ledMatrixState.image, 0)
|
leds.copyTo(offset, 5, board().ledMatrixState.image, 0)
|
||||||
runtime.queueDisplayUpdate()
|
runtime.queueDisplayUpdate()
|
||||||
|
basic.pause(interval);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function plotImage(leds: Image, offset: number): void {
|
export function plotImage(leds: Image, offset: number): void {
|
||||||
@ -155,8 +156,8 @@ namespace pxsim.ImageMethods {
|
|||||||
ImageMethods.plotImage(leds, frame * Image.height);
|
ImageMethods.plotImage(leds, frame * Image.height);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function showFrame(leds: Image, frame: number) {
|
export function showFrame(leds: Image, frame: number, interval: number) {
|
||||||
ImageMethods.showImage(leds, frame * Image.height);
|
ImageMethods.showImage(leds, frame * Image.height, interval);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function pixel(leds: Image, x: number, y: number): number {
|
export function pixel(leds: Image, x: number, y: number): number {
|
||||||
|
Reference in New Issue
Block a user