Compare commits
11 Commits
Author | SHA1 | Date | |
---|---|---|---|
6455da6adb | |||
4e88ba4ef2 | |||
0c7d49256d | |||
c2883d00ee | |||
7da483f258 | |||
6cbc6a53b2 | |||
5e23bc96ca | |||
4169663a8b | |||
4795c58e97 | |||
8fb96934ca | |||
cd91504c1f |
1
.gitignore
vendored
1
.gitignore
vendored
@ -6,6 +6,7 @@ temp
|
||||
projects
|
||||
win10/app/bin
|
||||
win10/app/bld
|
||||
win10/*.opendb
|
||||
|
||||
*.user
|
||||
*.sw?
|
||||
|
@ -33,7 +33,7 @@ basic.showString(s)
|
||||
|
||||
### Lessons
|
||||
|
||||
[answering machine](/lessons/answering-machine), [rock paper scissors](/lessons/rock-paper-scissors), [love meter](/lessons/love-meter), [digital pet](/lessons/digital-pet)
|
||||
[answering machine](/lessons/answering-machine), [rock paper scissors](/lessons/rock-paper-scissors), [love meter](/lessons/love-meter)
|
||||
|
||||
### See also
|
||||
|
||||
|
@ -19,5 +19,4 @@ devices.onGamepadButton(MesDpadButtonInfo.ADown, () => {})
|
||||
|
||||
### See Also
|
||||
|
||||
[tell remote control to](/reference/devices/tell-remote-control-to), [raise alert to](/reference/devices/raise-alert-to), [on notified](/reference/devices/on-notified), [signal strength](/reference/devices/signal-strength), [on signal strength changed](/reference/devices/on-signal-strength-changed)
|
||||
|
||||
[tell remote control to](/reference/devices/tell-remote-control-to), [raise alert to](/reference/devices/raise-alert-to), [signal strength](/reference/devices/signal-strength), [on signal strength changed](/reference/devices/on-signal-strength-changed)
|
||||
|
@ -14,7 +14,7 @@ The set of supported events will depend on the remote device and the BBC micro:b
|
||||
|
||||

|
||||
|
||||
### KindScript
|
||||
### JavaScript
|
||||
|
||||
```
|
||||
export function tellCameraTo(event: string)
|
||||
|
@ -10,7 +10,7 @@ The functions in the antenna namespace allow the BBC micro:bit to communicate wi
|
||||
|
||||

|
||||
|
||||
### KindScript
|
||||
### JavaScript
|
||||
|
||||
```
|
||||
export function tellMicrophoneTo(event: string)
|
||||
|
@ -14,7 +14,7 @@ The set of supported events will depend on the remote device and the BBC micro:b
|
||||
|
||||

|
||||
|
||||
### KindScript
|
||||
### JavaScript
|
||||
|
||||
```
|
||||
export function tellRemoteControlTo(event: string)
|
||||
|
@ -1,16 +1,12 @@
|
||||
# Change
|
||||
|
||||
The game library
|
||||
|
||||
### Change
|
||||
|
||||
Sprite will change the x position by this number
|
||||
|
||||
## Block Editor
|
||||
### Block Editor
|
||||
|
||||

|
||||
|
||||
## KindScript
|
||||
### JavaScript
|
||||
|
||||
Sprite will change the x position by this number
|
||||
|
||||
|
@ -4,7 +4,7 @@ The clear function for images.
|
||||
|
||||
Turn off all the pixels in an [Image](/reference/images/image).
|
||||
|
||||
### KindScript
|
||||
### JavaScript
|
||||
|
||||
```
|
||||
export function clear(img: micro_bit.Image)
|
||||
|
@ -55,5 +55,5 @@ export function startCountdown(ms: number)
|
||||
|
||||
### Lessons
|
||||
|
||||
[bop it](/lessons/bop-it) | [game of chance](/lessons/game-of-chance) | [game counter](/lessons/game-counter)
|
||||
[game of chance](/lessons/game-of-chance), [game counter](/lessons/game-counter)
|
||||
|
||||
|
@ -4,7 +4,7 @@ The pixel function.
|
||||
|
||||
Get the state of a pixel in an [Image](/reference/images/image).
|
||||
|
||||
### KindScript
|
||||
### JavaScript
|
||||
|
||||
```
|
||||
export function pixel(_this: micro_bit.Image, x: number, y: number) : boolean
|
||||
|
@ -4,7 +4,7 @@ The plot frame function.
|
||||
|
||||
Display an [Image](/reference/images/image) on the BBC micro:bit's [LED screen](/device/screen)
|
||||
|
||||
### KindScript
|
||||
### JavaScript
|
||||
|
||||
```
|
||||
export function plotFrame(_this: micro_bit.Image, index: number)
|
||||
|
@ -4,7 +4,7 @@ The plot image function.
|
||||
|
||||
Display an [Image](/reference/images/image) on the BBC micro:bit's [LED screen](/device/screen)
|
||||
|
||||
### KindScript
|
||||
### JavaScript
|
||||
|
||||
```
|
||||
export function plotImage(_this: micro_bit.Image, xOffset: number)
|
||||
|
@ -8,7 +8,7 @@ Scrolls the frames within an [Image](/reference/images/image) on the [LED screen
|
||||
|
||||

|
||||
|
||||
### KindScript
|
||||
### JavaScript
|
||||
|
||||
```
|
||||
export function scrollImage(_this: micro_bit.Image, xOffsetPerStep: number, interval: number)
|
||||
|
@ -4,7 +4,7 @@ The set pixel function. #set pixel.
|
||||
|
||||
Set the on/off state of pixel in an [Image](/reference/images/image).
|
||||
|
||||
### KindScript
|
||||
### JavaScript
|
||||
|
||||
```
|
||||
export function setPixel(_this: micro_bit.Image, x: number, y: number, value: boolean)
|
||||
|
@ -4,7 +4,7 @@ The show frame function.
|
||||
|
||||
Display an [Image](/reference/images/image) on the BBC micro:bit's [LED screen](/device/screen)
|
||||
|
||||
### KindScript
|
||||
### JavaScript
|
||||
|
||||
```
|
||||
export function showFrame(img: micro_bit.Image, frame: number)
|
||||
|
@ -4,12 +4,6 @@ The show image function.
|
||||
|
||||
Show an [Image](/reference/images/image) on the [LED screen](/device/screen), followed by a 400ms pause.
|
||||
|
||||
### Block Editor
|
||||
|
||||

|
||||
|
||||
### KindScript
|
||||
|
||||
```
|
||||
export function showImage(_this: micro_bit.Image, xOffset: number)
|
||||
```
|
||||
@ -20,7 +14,7 @@ export function showImage(_this: micro_bit.Image, xOffset: number)
|
||||
|
||||
### Create image and show image
|
||||
|
||||
Use the [image editor](/reference/images/image) to create images using the [create image](/reference/image/create-image) function, and then use `show image` like this:
|
||||
Use the [image editor](/reference/images/image) to create images using the [create image](/reference/images/create-image) function, and then use `show image` like this:
|
||||
|
||||
```
|
||||
let img = images.createImage(`
|
||||
|
@ -4,10 +4,8 @@ The width function.
|
||||
|
||||
Get the width of an [Image](/reference/images/image) in columns.
|
||||
|
||||
### KindScript
|
||||
|
||||
```
|
||||
export function width(_this: micro_bit.Image) : number
|
||||
```sig
|
||||
images.createImage().width();
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
@ -45,5 +45,5 @@ basic.forever(() => {
|
||||
|
||||
### See also
|
||||
|
||||
[compass-heading](/input/compass-heading), [lightlevel](/input/lightlevel)
|
||||
[compass-heading](/reference/input/compass-heading), [lightlevel](/reference/input/lightlevel)
|
||||
|
||||
|
@ -37,5 +37,5 @@ basic.forever(() => {
|
||||
|
||||
### See also
|
||||
|
||||
[on button pressed](/input/on-button-pressed), [if](/reference/logic/if), [forever](/basic/forever)
|
||||
[on button pressed](/reference/input/on-button-pressed), [if](/reference/logic/if), [forever](/reference/basic/forever)
|
||||
|
||||
|
@ -26,5 +26,5 @@ basic.forever(() => {
|
||||
|
||||
### See also
|
||||
|
||||
[acceleration](/reference/input/acceleration), [compass-heading](/input/compass-heading)
|
||||
[acceleration](/reference/input/acceleration), [compass-heading](/reference/input/compass-heading)
|
||||
|
||||
|
@ -28,5 +28,5 @@ basic.forever(() => {
|
||||
|
||||
### See also
|
||||
|
||||
[compass heading](/input/compass-heading)
|
||||
[compass heading](/reference/input/compass-heading)
|
||||
|
||||
|
@ -28,5 +28,5 @@ input.onPinPressed(TouchPin.P0, () => {
|
||||
|
||||
### See also
|
||||
|
||||
[BBC micro:bit pins](/device/pins), [pin is pressed](/input/pin-is-pressed), [analog read pin](/pins/analog-read-pin), [analog write pin](/pins/analog-write-pin), [digital read pin](/pins/digital-read-pin), [digital write pin](/pins/digital-write-pin)
|
||||
[BBC micro:bit pins](/device/pins), [pin is pressed](/reference/input/pin-is-pressed), [analog read pin](/reference/pins/analog-read-pin), [analog write pin](/reference/pins/analog-write-pin), [digital read pin](/reference/pins/digital-read-pin), [digital write pin](/reference/pins/digital-write-pin)
|
||||
|
||||
|
@ -32,5 +32,5 @@ basic.forever(() => {
|
||||
|
||||
### See also
|
||||
|
||||
[BBC micro:bit pins](/device/pins), [on pin pressed](/input/on-pin-pressed), [analog read pin](/reference/pins/analog-read-pin), [analog write pin](/reference/pins/analog-write-pin), [digital read pin](/reference/pins/digital-read-pin), [digital write pin](/reference/pins/digital-write-pin)
|
||||
[BBC micro:bit pins](/device/pins), [on pin pressed](/reference/input/on-pin-pressed), [analog read pin](/reference/pins/analog-read-pin), [analog write pin](/reference/pins/analog-write-pin), [digital read pin](/reference/pins/digital-read-pin), [digital write pin](/reference/pins/digital-write-pin)
|
||||
|
||||
|
@ -2,8 +2,6 @@
|
||||
|
||||
Display an [Image](/reference/images/image) on the BBC micro:bit's [LED screen](/device/screen). NOTE: `basic -> plot image` has been replaced by `basic -> show leds`.
|
||||
|
||||
### KindScript syntax
|
||||
|
||||
```sig
|
||||
basic.plotLeds(`
|
||||
. . . . .
|
||||
|
@ -24,5 +24,5 @@ for (let k = 0; k < 4; k++) {
|
||||
|
||||
### See also
|
||||
|
||||
[while](/reference/loops/while), [if](/blocks/if)
|
||||
[while](/reference/loops/while), [if](/reference/logic/if)
|
||||
|
||||
|
@ -39,5 +39,5 @@ The following example uses a while loop to make a diagonal line on the LED scree
|
||||
|
||||
### See also
|
||||
|
||||
[on button pressed](/reference/input/on-button-pressed), [for](/reference/loops/for), [if](/blocks/if), [forever](/reference/basic/forever)
|
||||
[on button pressed](/reference/input/on-button-pressed), [for](/reference/loops/for), [if](/reference/logic/if), [forever](/reference/basic/forever)
|
||||
|
||||
|
@ -31,5 +31,5 @@ radio.onDataReceived(() => {
|
||||
|
||||
### See also
|
||||
|
||||
[receive number](/reference/radio/receive-number), [send number](/radio/send-number), [set group](/reference/radio/set-group)
|
||||
[receive number](/reference/radio/receive-number), [send number](/reference/radio/send-number), [set group](/reference/radio/set-group)
|
||||
|
||||
|
@ -30,5 +30,5 @@ radio.onDataReceived(() => {
|
||||
|
||||
### See also
|
||||
|
||||
[receive number](/input/receive-number), [on data received](/reference/radio/on-data-received)
|
||||
[receive number](/reference/input/receive-number), [on data received](/reference/radio/on-data-received)
|
||||
|
||||
|
@ -32,7 +32,7 @@ The next six blocks represent comparison operators that yield a Boolean value. M
|
||||
42 >= 0;
|
||||
```
|
||||
|
||||
Boolean values and operators are often used with an [if](/blocks/if) or [while](/reference/loops/while) statement to determine which code will execute next. For example:
|
||||
Boolean values and operators are often used with an [if](/reference/logic/if) or [while](/reference/loops/while) statement to determine which code will execute next. For example:
|
||||
|
||||
### Functions that return a Boolean
|
||||
|
||||
@ -104,5 +104,5 @@ See the documentation on [Numbers](/reference/types/number) for more information
|
||||
|
||||
### See also
|
||||
|
||||
[if](/blocks/if), [while](/reference/loops/while), [number](/reference/types/number)
|
||||
[if](/reference/logic/if), [while](/reference/loops/while), [number](/reference/types/number)
|
||||
|
||||
|
@ -20,7 +20,7 @@ The following arithmetic operators work on numbers and return a [Number](/refere
|
||||
* subtraction: `1 - 3 `
|
||||
* multiplication: `3 * 2`
|
||||
* integer division: `7 / 3`
|
||||
* modulo is available through the [math library](/blocks/math)
|
||||
* modulo is available through the [math library](/reference/math)
|
||||
|
||||
### Relational operators
|
||||
|
||||
@ -47,7 +47,7 @@ Some functions return a number, which you can store in a variable. For example t
|
||||
|
||||
### Math functions
|
||||
|
||||
The [math library](/blocks/math) includes math related functions. In the [Block Editor](/blocks/editor), click `math` on the Code Keyboard to see the math functions. For example, the `absolute` function returns the returns the absolute value of input parameter `x`:
|
||||
The [math library](/reference/math) includes math related functions. In the [Block Editor](/blocks/editor), click `math` on the Code Keyboard to see the math functions. For example, the `absolute` function returns the returns the absolute value of input parameter `x`:
|
||||
|
||||

|
||||
|
||||
@ -57,5 +57,5 @@ The [math library](/blocks/math) includes math related functions. In the [Block
|
||||
|
||||
### See also
|
||||
|
||||
[math library](/blocks/math), [var](/reference/variables/var), [Boolean](/reference/types/boolean), [show number](/reference/basic/show-number)
|
||||
[math library](/reference/math), [var](/reference/variables/var), [Boolean](/reference/types/boolean), [show number](/reference/basic/show-number)
|
||||
|
||||
|
@ -28,7 +28,7 @@ let num1 = 42
|
||||
````
|
||||
### Notes
|
||||
|
||||
* You can use the assignment operator with variables of each of the supported [types](/blocks/types).
|
||||
* You can use the assignment operator with variables of each of the supported [types](/reference/types).
|
||||
|
||||
### Lessons
|
||||
|
||||
@ -36,5 +36,5 @@ let num1 = 42
|
||||
|
||||
### See also
|
||||
|
||||
[variable](/reference/variables/var), [types](/blocks/types)
|
||||
[variable](/reference/variables/var), [types](/reference/types)
|
||||
|
||||
|
@ -32,9 +32,9 @@ basic.showNumber(x);
|
||||
|
||||
### Notes
|
||||
|
||||
* You can use the assignment operator with variables of each of the supported [types](/blocks/types).
|
||||
* You can use the assignment operator with variables of each of the supported [types](/reference/types).
|
||||
|
||||
### See also
|
||||
|
||||
[variable](/reference/variables/var), [types](/blocks/types)
|
||||
[variable](/reference/variables/var), [types](/reference/types)
|
||||
|
||||
|
@ -13,7 +13,10 @@ namespace radio {
|
||||
|
||||
int radioEnable() {
|
||||
int r = uBit.radio.enable();
|
||||
if (r != MICROBIT_OK) return r;
|
||||
if (r != MICROBIT_OK) {
|
||||
uBit.panic(43);
|
||||
return r;
|
||||
}
|
||||
if (!radioEnabled) {
|
||||
uBit.radio.setGroup(pxt::programHash());
|
||||
radioEnabled = true;
|
||||
|
@ -151,7 +151,7 @@ namespace control {
|
||||
* Raises an event in the event bus.
|
||||
*/
|
||||
//% weight=20 blockGap=8 blockId="control_on_event" block="on event|from %src=control_event_source|with value %value=control_event_value"
|
||||
//% blockExternalInputs=1 blockStatement=1
|
||||
//% blockExternalInputs=1
|
||||
void onEvent(int src, int value, Action handler) {
|
||||
registerWithDal(src, value, handler);
|
||||
}
|
||||
|
2
libs/microbit/enums.d.ts
vendored
2
libs/microbit/enums.d.ts
vendored
@ -281,5 +281,7 @@ declare namespace serial {
|
||||
Int32BE = 10,
|
||||
// UInt32,
|
||||
}
|
||||
declare namespace storage {
|
||||
}
|
||||
|
||||
// Auto-generated. Do not edit. Really.
|
||||
|
@ -26,7 +26,8 @@
|
||||
"pins.ts",
|
||||
"serial.cpp",
|
||||
"serial.ts",
|
||||
"buffer.cpp"
|
||||
"buffer.cpp",
|
||||
"storage.cpp"
|
||||
],
|
||||
"public": true,
|
||||
"dependencies": {},
|
||||
|
@ -7,7 +7,7 @@ namespace serial {
|
||||
* Prints a line of text to the serial
|
||||
* @param value to send over serial
|
||||
*/
|
||||
//% help=/reference/serial/write-line
|
||||
//% help=/serial/write-line
|
||||
//% blockId=serial_writeline block="serial|write %text"
|
||||
export function writeLine(text: string): void {
|
||||
writeString(text);
|
||||
@ -27,6 +27,7 @@ namespace serial {
|
||||
* @param value to write
|
||||
*/
|
||||
//% weight=80
|
||||
//% help=/serial/write-value
|
||||
//% blockId=serial_writevalue block="serial|write %name|= %value"
|
||||
export function writeValue(name: string, value: number): void {
|
||||
writeString(name);
|
||||
|
35
libs/microbit/shims.d.ts
vendored
35
libs/microbit/shims.d.ts
vendored
@ -340,7 +340,7 @@ declare namespace control {
|
||||
* Raises an event in the event bus.
|
||||
*/
|
||||
//% weight=20 blockGap=8 blockId="control_on_event" block="on event|from %src=control_event_source|with value %value=control_event_value"
|
||||
//% blockExternalInputs=1 blockStatement=1 shim=control::onEvent
|
||||
//% blockExternalInputs=1 shim=control::onEvent
|
||||
function onEvent(src: number, value: number, handler: () => void): void;
|
||||
}
|
||||
|
||||
@ -585,4 +585,37 @@ declare interface Buffer {
|
||||
write(dstOffset: number, src: Buffer): void;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This allows reading and writing of small blocks of data to FLASH memory.
|
||||
*/
|
||||
//% weight=10 color=#cc6600
|
||||
declare namespace storage {
|
||||
|
||||
/**
|
||||
* Writes the key and buffer pair into FLASH. This operation is rather costly as all the key/value pairs
|
||||
* have to be rewritten as well.
|
||||
*/
|
||||
//% shim=storage::putBuffer
|
||||
function putBuffer(key: string, buffer: Buffer): void;
|
||||
|
||||
/**
|
||||
* Gets the buffer at the given key if any. If no key is available, empty buffer is returned.
|
||||
*/
|
||||
//% shim=storage::getBuffer
|
||||
function getBuffer(key: string): Buffer;
|
||||
|
||||
/**
|
||||
* Removes an entry identified by the key.
|
||||
*/
|
||||
//% shim=storage::remove
|
||||
function remove(key: string): void;
|
||||
|
||||
/**
|
||||
* The number of entries in the key value store
|
||||
*/
|
||||
//% shim=storage::size
|
||||
function size(): number;
|
||||
}
|
||||
|
||||
// Auto-generated. Do not edit. Really.
|
||||
|
43
libs/microbit/storage.cpp
Normal file
43
libs/microbit/storage.cpp
Normal file
@ -0,0 +1,43 @@
|
||||
#include "ksbit.h"
|
||||
|
||||
/**
|
||||
* This allows reading and writing of small blocks of data to FLASH memory.
|
||||
*/
|
||||
//% weight=10 color=#cc6600
|
||||
namespace storage {
|
||||
/**
|
||||
* Writes the key and buffer pair into FLASH. This operation is rather costly as all the key/value pairs
|
||||
* have to be rewritten as well.
|
||||
*/
|
||||
//%
|
||||
void putBuffer(StringData* key, Buffer buffer) {
|
||||
uBit.storage.put(ManagedString(key), ManagedBuffer(buffer).getBytes());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the buffer at the given key if any. If no key is available, empty buffer is returned.
|
||||
*/
|
||||
//%
|
||||
Buffer getBuffer(StringData* key) {
|
||||
KeyValuePair* pv = uBit.storage.get(ManagedString(key));
|
||||
if (pv == NULL) return ManagedBuffer().leakData();
|
||||
|
||||
return ManagedBuffer(pv->value, sizeof(pv->value)).leakData();
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes an entry identified by the key.
|
||||
*/
|
||||
//%
|
||||
void remove(StringData * key) {
|
||||
uBit.storage.remove(ManagedString(key));
|
||||
}
|
||||
|
||||
/**
|
||||
* The number of entries in the key value store
|
||||
*/
|
||||
//%
|
||||
int size() {
|
||||
return uBit.storage.size();
|
||||
}
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "pxt-microbit",
|
||||
"version": "0.2.77",
|
||||
"version": "0.2.78",
|
||||
"description": "BBC micro:bit target for PXT",
|
||||
"keywords": [
|
||||
"JavaScript",
|
||||
@ -29,6 +29,6 @@
|
||||
"typescript": "^1.8.7"
|
||||
},
|
||||
"dependencies": {
|
||||
"pxt-core": "0.2.81"
|
||||
"pxt-core": "0.2.82"
|
||||
}
|
||||
}
|
||||
|
@ -201,7 +201,7 @@ namespace pxsim.basic {
|
||||
else ImageMethods.scrollImage(createImageFromString(s + ' '), interval, 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export function showLeds(leds: Image, delay: number): void {
|
||||
showAnimation(leds, delay);
|
||||
}
|
||||
@ -250,7 +250,7 @@ namespace pxsim.input {
|
||||
b.usesButtonAB = true;
|
||||
runtime.queueDisplayUpdate();
|
||||
}
|
||||
b.bus.listen(button, DAL.MICROBIT_BUTTON_EVT_CLICK, handler);
|
||||
pxt.registerWithDal(button, DAL.MICROBIT_BUTTON_EVT_CLICK, handler);
|
||||
}
|
||||
|
||||
export function buttonIsPressed(button: number): boolean {
|
||||
@ -273,7 +273,7 @@ namespace pxsim.input {
|
||||
b.useShake = true;
|
||||
runtime.queueDisplayUpdate();
|
||||
}
|
||||
b.bus.listen(DAL.MICROBIT_ID_GESTURE, gesture, handler);
|
||||
pxt.registerWithDal(DAL.MICROBIT_ID_GESTURE, gesture, handler);
|
||||
}
|
||||
|
||||
export function onPinPressed(pinId: number, handler: RefAction) {
|
||||
@ -424,7 +424,7 @@ namespace pxsim.radio {
|
||||
}
|
||||
|
||||
export function onBroadcastMessageReceived(msg: number, handler: RefAction): void {
|
||||
board().bus.listen(DAL.MES_BROADCAST_GENERAL_ID, msg, handler);
|
||||
pxt.registerWithDal(DAL.MES_BROADCAST_GENERAL_ID, msg, handler);
|
||||
}
|
||||
|
||||
export function setGroup(id: number): void {
|
||||
@ -452,7 +452,7 @@ namespace pxsim.radio {
|
||||
}
|
||||
|
||||
export function onDataReceived(handler: RefAction): void {
|
||||
board().bus.listen(DAL.MICROBIT_ID_RADIO, DAL.MICROBIT_RADIO_EVT_DATAGRAM, handler);
|
||||
pxt.registerWithDal(DAL.MICROBIT_ID_RADIO, DAL.MICROBIT_RADIO_EVT_DATAGRAM, handler);
|
||||
}
|
||||
}
|
||||
|
||||
@ -564,6 +564,34 @@ namespace pxsim.ImageMethods {
|
||||
runtime.queueDisplayUpdate()
|
||||
}
|
||||
|
||||
export function height(leds: Image) : number {
|
||||
if (!leds) panic(PanicCode.MICROBIT_NULL_DEREFERENCE);
|
||||
return Image.height;
|
||||
}
|
||||
|
||||
export function width(leds: Image) : number {
|
||||
if (!leds) panic(PanicCode.MICROBIT_NULL_DEREFERENCE);
|
||||
return leds.width;
|
||||
}
|
||||
|
||||
export function plotFrame(leds: Image, frame: number) {
|
||||
ImageMethods.plotImage(leds, frame * Image.height);
|
||||
}
|
||||
|
||||
export function showFrame(leds: Image, frame: number) {
|
||||
ImageMethods.showImage(leds, frame * Image.height);
|
||||
}
|
||||
|
||||
export function pixel(leds: Image, x: number, y: number) : number {
|
||||
if (!leds) panic(PanicCode.MICROBIT_NULL_DEREFERENCE);
|
||||
return leds.get(x,y);
|
||||
}
|
||||
|
||||
export function setPixel(leds: Image, x: number, y: number, v:number) {
|
||||
if (!leds) panic(PanicCode.MICROBIT_NULL_DEREFERENCE);
|
||||
leds.set(x,y,v);
|
||||
}
|
||||
|
||||
export function clear(leds: Image) {
|
||||
if (!leds) panic(PanicCode.MICROBIT_NULL_DEREFERENCE);
|
||||
|
||||
|
@ -611,6 +611,7 @@ namespace pxsim {
|
||||
}
|
||||
|
||||
export class Image {
|
||||
public static height: number = 5;
|
||||
public width: number;
|
||||
public data: number[];
|
||||
constructor(width: number, data: number[]) {
|
||||
|
Reference in New Issue
Block a user