Remove td, remove field matrix, update radio blocks. Revert image literal changes.

This commit is contained in:
Sam El-Husseini
2018-05-09 10:56:48 -07:00
parent dc5ec79708
commit 8957bf0647
14 changed files with 150 additions and 367 deletions

View File

@ -230,7 +230,7 @@
"basic.pause|block": "pause (ms) %pause",
"basic.showArrow|block": "show arrow %i=device_arrow",
"basic.showIcon|block": "show icon %i",
"basic.showLeds|block": "show leds| %leds",
"basic.showLeds|block": "show leds",
"basic.showNumber|block": "show|number %number",
"basic.showString|block": "show|string %text",
"basic|block": "basic",
@ -266,8 +266,8 @@
"game|block": "game",
"images.arrowImage|block": "arrow image %i=device_arrow",
"images.arrowNumber|block": "%arrow",
"images.createBigImage|block": "create big image| %leds",
"images.createImage|block": "create image| %leds",
"images.createBigImage|block": "create big image",
"images.createImage|block": "create image",
"images.iconImage|block": "icon image %i",
"images|block": "images",
"input.acceleration|block": "acceleration (mg)|%NAME",

View File

@ -34,13 +34,10 @@ namespace basic {
*/
//% help=basic/show-leds
//% weight=95 blockGap=8
//% imageLiteral=0 async
//% leds.fieldEditor="matrix"
//% leds.fieldOptions.onParentBlock=true
//% leds.fieldOptions.decompileLiterals=true
//% imageLiteral=1 async
//% blockId=device_show_leds
//% block="show leds| %leds" icon="\uf00a"
//% parts="ledmatrix" blockExternalInputs=1
//% block="show leds" icon="\uf00a"
//% parts="ledmatrix"
void showLeds(ImageLiteral leds, int interval = 400) {
uBit.display.print(MicroBitImage(imageBytes(leds)), 0, 0, 0, interval);
}
@ -87,10 +84,7 @@ namespace basic {
* @param leds pattern of LEDs to turn on/off
* @param interval time in milliseconds between each redraw
*/
//% help=basic/show-animation imageLiteral=0 async
//% leds.fieldEditor="matrix"
//% leds.fieldOptions.onParentBlock=true
//% leds.fieldOptions.decompileLiterals=true
//% help=basic/show-animation imageLiteral=1 async
//% parts="ledmatrix"
void showAnimation(ImageLiteral leds, int interval = 400) {
uBit.display.animate(MicroBitImage(imageBytes(leds)), interval, 5, 0, 0);
@ -137,4 +131,4 @@ namespace basic {
void pause(int ms) {
fiber_sleep(ms);
}
}
}

View File

@ -10,11 +10,8 @@ namespace images {
* Creates an image that fits on the LED screen.
*/
//% weight=75 help=images/create-image
//% blockId=device_build_image block="create image| %leds"
//% leds.fieldEditor="matrix"
//% leds.fieldOptions.onParentBlock=true
//% leds.fieldOptions.decompileLiterals=true
//% parts="ledmatrix" imageLiteral=0 blockExternalInput=1
//% blockId=device_build_image block="create image"
//% parts="ledmatrix"
Image createImage(ImageLiteral leds) {
return MicroBitImage(imageBytes(leds)).clone().leakData();
}
@ -23,11 +20,7 @@ namespace images {
* Creates an image with 2 frames.
*/
//% weight=74 help=images/create-big-image
//% leds.fieldEditor="matrix"
//% leds.fieldOptions.onParentBlock=true
//% leds.fieldOptions.decompileLiterals=true
//% blockId=device_build_big_image block="create big image| %leds"
//% imageLiteral=0 blockExternalInput=1
//% blockId=device_build_big_image block="create big image" imageLiteral=2
//% parts="ledmatrix"
Image createBigImage(ImageLiteral leds) {
return createImage(leds);
@ -160,4 +153,4 @@ namespace ImageMethods {
void showFrame(Image i, int frame, int interval = 400) {
showImage(i, frame * 5, interval);
}
}
}

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

@ -12,22 +12,15 @@ declare namespace images {
* Creates an image that fits on the LED screen.
*/
//% weight=75 help=images/create-image
//% blockId=device_build_image block="create image| %leds"
//% leds.fieldEditor="matrix"
//% leds.fieldOptions.onParentBlock=true
//% leds.fieldOptions.decompileLiterals=true
//% parts="ledmatrix" imageLiteral=0 blockExternalInput=1 shim=images::createImage
//% blockId=device_build_image block="create image"
//% parts="ledmatrix" imageLiteral=1 shim=images::createImage
function createImage(leds: string): Image;
/**
* Creates an image with 2 frames.
*/
//% weight=74 help=images/create-big-image
//% leds.fieldEditor="matrix"
//% leds.fieldOptions.onParentBlock=true
//% leds.fieldOptions.decompileLiterals=true
//% blockId=device_build_big_image block="create big image| %leds"
//% imageLiteral=0 blockExternalInput=1
//% blockId=device_build_big_image block="create big image" imageLiteral=2
//% parts="ledmatrix" shim=images::createBigImage
function createBigImage(leds: string): Image;
}
@ -154,13 +147,10 @@ declare namespace basic {
*/
//% help=basic/show-leds
//% weight=95 blockGap=8
//% imageLiteral=0 async
//% leds.fieldEditor="matrix"
//% leds.fieldOptions.onParentBlock=true
//% leds.fieldOptions.decompileLiterals=true
//% imageLiteral=1 async
//% blockId=device_show_leds
//% block="show leds| %leds" icon="\uf00a"
//% parts="ledmatrix" blockExternalInputs=1 interval.defl=400 shim=basic::showLeds
//% block="show leds" icon="\uf00a"
//% parts="ledmatrix" interval.defl=400 shim=basic::showLeds
function showLeds(leds: string, interval?: int32): void;
/**
@ -190,10 +180,7 @@ declare namespace basic {
* @param leds pattern of LEDs to turn on/off
* @param interval time in milliseconds between each redraw
*/
//% help=basic/show-animation imageLiteral=0 async
//% leds.fieldEditor="matrix"
//% leds.fieldOptions.onParentBlock=true
//% leds.fieldOptions.decompileLiterals=true
//% help=basic/show-animation imageLiteral=1 async
//% parts="ledmatrix" interval.defl=400 shim=basic::showAnimation
function showAnimation(leds: string, interval?: int32): void;

View File

@ -6,7 +6,9 @@
"radio.Packet.serial": "The serial number of the sender of the packet or 0 if the sender did not sent their serial number.",
"radio.Packet.signal": "The received signal strength indicator (RSSI) of the packet.",
"radio.Packet.time": "The system time of the sender of the packet at the time the packet was sent.",
"radio.onDataPacketReceived": "Registers code to run when the radio receives a packet. Also takes the\nreceived packet from the radio queue.",
"radio.onReceivedNumber": "Registers code to run when the radio receives a packet. Also takes the\nreceived packet from the radio queue.",
"radio.onReceivedString": "Registers code to run when the radio receives a packet. Also takes the\nreceived packet from the radio queue.",
"radio.onReceivedValue": "Registers code to run when the radio receives a packet. Also takes the\nreceived packet from the radio queue.",
"radio.receivedBuffer": "Returns the buffer payload from the last packet taken from the radio queue\n(via ``receiveNumber``, ``receiveString``, etc) or the empty string if that\npacket did not contain a string.",
"radio.receivedNumber": "Returns the number payload from the last packet taken from the radio queue\n(via ``receiveNumber``, ``receiveString``, etc) or 0 if that packet did not\ncontain a number.",
"radio.receivedSerial": "Returns the serial number of the sender micro:bit from the last packet taken\nfrom the radio queue (via ``receiveNumber``, ``receiveString``, etc) or 0 if\nthat packet did not send a serial number.",

View File

@ -1,5 +1,7 @@
{
"radio.onDataPacketReceived|block": "on radio received",
"radio.onReceivedNumber|block": "on radio received number",
"radio.onReceivedString|block": "on radio received string",
"radio.onReceivedValue|block": "on radio received",
"radio.sendNumber|block": "radio send number %value",
"radio.sendString|block": "radio send string %msg",
"radio.sendValue|block": "radio send|value %name|= %value",

View File

@ -37,7 +37,7 @@ namespace radio {
* Registers code to run when the radio receives a packet. Also takes the
* received packet from the radio queue.
*/
//% help=radio/on-data-packet-received
//% help=radio/on-data-packet-received deprecated=true
//% mutate=objectdestructuring
//% mutateText=Packet
//% mutateDefaults="receivedNumber;receivedString:name,receivedNumber:value;receivedString"
@ -55,4 +55,60 @@ namespace radio {
cb(packet)
});
}
/**
* Registers code to run when the radio receives a packet. Also takes the
* received packet from the radio queue.
*/
//% help=radio/on-radio-received-number
//% blockId=radio_on_number block="on radio received number" blockGap=8
export function onReceivedNumber(cb: (num: number, time?: number, serial?: number, signal?: number) => void) {
onDataReceived(() => {
receiveNumber();
const packet = new Packet();
packet.receivedNumber = receivedNumber();
packet.time = receivedTime();
packet.serial = receivedSerial();
packet.signal = receivedSignalStrength();
cb(packet.receivedNumber, packet.time, packet.serial, packet.signal);
});
}
/**
* Registers code to run when the radio receives a packet. Also takes the
* received packet from the radio queue.
*/
//% help=radio/on-radio-received-string
//% blockId=radio_on_string block="on radio received string" blockGap=8
export function onReceivedString(cb: (received: string, time?: number, serial?: number, signal?: number) => void) {
onDataReceived(() => {
receiveNumber();
const packet = new Packet();
packet.time = receivedTime();
packet.serial = receivedSerial();
packet.signal = receivedSignalStrength();
packet.receivedString = receivedString();
cb(packet.receivedString, packet.time, packet.serial, packet.signal);
});
}
/**
* Registers code to run when the radio receives a packet. Also takes the
* received packet from the radio queue.
*/
//% help=radio/on-radio-received-value
//% blockId=radio_on_value block="on radio received" blockGap=8
export function onReceivedValue(cb: (packet: Packet) => void) {
onDataReceived(() => {
receiveNumber();
const packet = new Packet();
packet.receivedNumber = receivedNumber();
packet.time = receivedTime();
packet.serial = receivedSerial();
packet.signal = receivedSignalStrength();
packet.receivedString = receivedString();
cb(packet)
});
}
}