Merge branch 'master' into tutorialmode
This commit is contained in:
commit
c5128aa497
@ -18,7 +18,7 @@ Read more at https://lancaster-university.github.io/microbit-docs/ble/eddystone/
|
||||
## ~
|
||||
|
||||
```sig
|
||||
bluetooth.advertiseUrl("https://pxt.microbit.org/", true);
|
||||
bluetooth.advertiseUrl("https://pxt.microbit.org/", 7, true);
|
||||
```
|
||||
|
||||
### Parameters
|
||||
@ -30,7 +30,7 @@ bluetooth.advertiseUrl("https://pxt.microbit.org/", true);
|
||||
### Example: Broadcast a secret code
|
||||
|
||||
```blocks
|
||||
bluetooth.advertiseUrl("https://pxt.io?secret=42", true);
|
||||
bluetooth.advertiseUrl("https://pxt.io?secret=42", 7, true);
|
||||
```
|
||||
|
||||
## See Also
|
||||
|
@ -7,7 +7,7 @@ using namespace pxt;
|
||||
/**
|
||||
* Support for additional Bluetooth services.
|
||||
*/
|
||||
//% color=#0082FB weight=20
|
||||
//% color=#0082FB weight=20 icon="\uf294"
|
||||
namespace bluetooth {
|
||||
MicroBitUARTService *uart = NULL;
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* Support for additional Bluetooth services.
|
||||
*/
|
||||
//% color=#0082FB weight=20
|
||||
//% color=#0082FB weight=20 icon="\uf294"
|
||||
namespace bluetooth {
|
||||
/**
|
||||
* Writes to the Bluetooth UART service buffer. From there the data is transmitted over Bluetooth to a connected device.
|
||||
|
2
libs/bluetooth/shims.d.ts
vendored
2
libs/bluetooth/shims.d.ts
vendored
@ -4,7 +4,7 @@
|
||||
/**
|
||||
* Support for additional Bluetooth services.
|
||||
*/
|
||||
//% color=#0082FB weight=20
|
||||
//% color=#0082FB weight=20 icon="\uf294"
|
||||
declare namespace bluetooth {
|
||||
|
||||
/**
|
||||
|
@ -4,7 +4,7 @@
|
||||
/**
|
||||
* Provides access to basic micro:bit functionality.
|
||||
*/
|
||||
//% color=#0078D7 weight=100
|
||||
//% color=#0078D7 weight=100 icon="\uf00a"
|
||||
namespace basic {
|
||||
|
||||
/**
|
||||
@ -13,7 +13,7 @@ namespace basic {
|
||||
*/
|
||||
//% help=basic/show-number
|
||||
//% weight=96
|
||||
//% blockId=device_show_number block="show|number %number" blockGap=8 icon="\uf1ec"
|
||||
//% blockId=device_show_number block="show|number %number" blockGap=8
|
||||
//% async
|
||||
//% parts="ledmatrix"
|
||||
void showNumber(int value, int interval = 150) {
|
||||
@ -50,7 +50,7 @@ namespace basic {
|
||||
*/
|
||||
//% help=basic/show-string
|
||||
//% weight=87 blockGap=8
|
||||
//% block="show|string %text" icon="\uf031"
|
||||
//% block="show|string %text"
|
||||
//% async
|
||||
//% blockId=device_print_message
|
||||
//% parts="ledmatrix"
|
||||
@ -73,7 +73,7 @@ namespace basic {
|
||||
* Turn off all LEDs
|
||||
*/
|
||||
//% help=basic/clear-screen weight=79
|
||||
//% blockId=device_clear_display block="clear screen" icon="\uf12d"
|
||||
//% blockId=device_clear_display block="clear screen"
|
||||
//% parts="ledmatrix"
|
||||
void clearScreen() {
|
||||
uBit.display.image.clear();
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* Runtime and event utilities.
|
||||
*/
|
||||
//% weight=1 color="#333333"
|
||||
//% weight=1 color="#333333" icon="\uf233"
|
||||
//% advanced=true
|
||||
namespace control {
|
||||
|
||||
|
@ -153,15 +153,19 @@ namespace Array_ {
|
||||
//%
|
||||
int length(RefCollection *c) { return c->length(); }
|
||||
//%
|
||||
void setLength(RefCollection *c, int newLength) { c->setLength(newLength); }
|
||||
//%
|
||||
void push(RefCollection *c, uint32_t x) { c->push(x); }
|
||||
//%
|
||||
uint32_t pop(RefCollection *c) { return c->pop(); }
|
||||
//%
|
||||
uint32_t getAt(RefCollection *c, int x) { return c->getAt(x); }
|
||||
//%
|
||||
void removeAt(RefCollection *c, int x) { c->removeAt(x); }
|
||||
void setAt(RefCollection *c, int x, uint32_t y) { c->setAt(x, y); }
|
||||
//%
|
||||
void setAt(RefCollection *c, int x, uint32_t y) { c->setAt(x, y); }
|
||||
uint32_t removeAt(RefCollection *c, int x) { return c->removeAt(x); }
|
||||
//%
|
||||
void insertAt(RefCollection *c, int x, uint32_t value) { c->insertAt(x, value); }
|
||||
//%
|
||||
int indexOf(RefCollection *c, uint32_t x, int start) { return c->indexOf(x, start); }
|
||||
//%
|
||||
|
@ -21,7 +21,7 @@ enum LedSpriteProperty {
|
||||
/**
|
||||
* A single-LED sprite game engine
|
||||
*/
|
||||
//% color=#008272 weight=32
|
||||
//% color=#008272 weight=32 icon="\uf11b"
|
||||
//% advanced=true
|
||||
namespace game {
|
||||
let _score: number = 0;
|
||||
|
@ -3,7 +3,7 @@
|
||||
/**
|
||||
* Creation, manipulation and display of LED images.
|
||||
*/
|
||||
//% color=#5C2D91 weight=31
|
||||
//% color=#5C2D91 weight=31 icon="\uf03e"
|
||||
//% advanced=true
|
||||
namespace images {
|
||||
/**
|
||||
|
@ -112,7 +112,7 @@ enum class Gesture {
|
||||
EightG = MICROBIT_ACCELEROMETER_EVT_8G
|
||||
};
|
||||
|
||||
//% color=300 weight=99
|
||||
//% color=300 weight=99 icon="\uf192"
|
||||
namespace input {
|
||||
/**
|
||||
* Do something when a button (``A``, ``B`` or both ``A+B``) is pressed
|
||||
@ -120,7 +120,7 @@ namespace input {
|
||||
* @param body code to run when event is raised
|
||||
*/
|
||||
//% help=input/on-button-pressed weight=85 blockGap=8
|
||||
//% blockId=device_button_event block="on button|%NAME|pressed" icon="\uf192"
|
||||
//% blockId=device_button_event block="on button|%NAME|pressed"
|
||||
//% parts="buttonpair"
|
||||
void onButtonPressed(Button button, Action body) {
|
||||
registerWithDal((int)button, MICROBIT_BUTTON_EVT_CLICK, body);
|
||||
@ -132,7 +132,7 @@ namespace input {
|
||||
* @param body code to run when gesture is raised
|
||||
*/
|
||||
//% help=input/on-gesture weight=84 blockGap=8
|
||||
//% blockId=device_gesture_event block="on |%NAME" icon="\uf135"
|
||||
//% blockId=device_gesture_event block="on |%NAME"
|
||||
//% parts="accelerometer"
|
||||
void onGesture(Gesture gesture, Action body) {
|
||||
int gi = (int)gesture;
|
||||
@ -149,7 +149,7 @@ namespace input {
|
||||
* @param body the code to run when the pin is pressed
|
||||
*/
|
||||
//% help=input/on-pin-pressed weight=83
|
||||
//% blockId=device_pin_event block="on pin %name|pressed" icon="\uf094"
|
||||
//% blockId=device_pin_event block="on pin %name|pressed"
|
||||
void onPinPressed(TouchPin name, Action body) {
|
||||
auto pin = getPin((int)name);
|
||||
if (!pin) return;
|
||||
@ -165,7 +165,7 @@ namespace input {
|
||||
* @param body the code to run when the pin is released
|
||||
*/
|
||||
//% help=input/on-pin-released weight=6 blockGap=8
|
||||
//% blockId=device_pin_released block="on pin %NAME|released" icon="\uf094"
|
||||
//% blockId=device_pin_released block="on pin %NAME|released"
|
||||
//% advanced=true
|
||||
void onPinReleased(TouchPin name, Action body) {
|
||||
auto pin = getPin((int)name);
|
||||
@ -200,7 +200,7 @@ namespace input {
|
||||
* @param name pin used to detect the touch, eg: TouchPin.P0
|
||||
*/
|
||||
//% help=input/pin-is-pressed weight=58
|
||||
//% blockId="device_pin_is_pressed" block="pin %NAME|is pressed" icon="\uf094"
|
||||
//% blockId="device_pin_is_pressed" block="pin %NAME|is pressed"
|
||||
//% blockGap=8
|
||||
bool pinIsPressed(TouchPin name) {
|
||||
auto pin = getPin((int)name);
|
||||
@ -218,7 +218,7 @@ namespace input {
|
||||
* Get the acceleration value in milli-gravitys (when the board is laying flat with the screen up, x=0, y=0 and z=-1024)
|
||||
* @param dimension TODO
|
||||
*/
|
||||
//% help=input/acceleration weight=58 icon="\uf135"
|
||||
//% help=input/acceleration weight=58
|
||||
//% blockId=device_acceleration block="acceleration (mg)|%NAME" blockGap=8
|
||||
//% parts="accelerometer"
|
||||
int acceleration(Dimension dimension) {
|
||||
@ -235,7 +235,7 @@ namespace input {
|
||||
* Reads the light level applied to the LED screen in a range from ``0`` (dark) to ``255`` bright.
|
||||
*/
|
||||
//% help=input/light-level weight=57
|
||||
//% blockId=device_get_light_level block="light level" blockGap=8 icon="\uf185"
|
||||
//% blockId=device_get_light_level block="light level" blockGap=8
|
||||
//% parts="ledmatrix"
|
||||
int lightLevel() {
|
||||
return uBit.display.readLightLevel();
|
||||
@ -245,7 +245,7 @@ namespace input {
|
||||
* Get the current compass heading in degrees.
|
||||
*/
|
||||
//% help=input/compass-heading
|
||||
//% weight=56 icon="\uf14e"
|
||||
//% weight=56
|
||||
//% blockId=device_heading block="compass heading (°)" blockGap=8
|
||||
//% parts="compass"
|
||||
int compassHeading() {
|
||||
@ -256,7 +256,7 @@ namespace input {
|
||||
/**
|
||||
* Gets the temperature in Celsius degrees (°C).
|
||||
*/
|
||||
//% weight=55 icon="\uf06d"
|
||||
//% weight=55
|
||||
//% help=input/temperature
|
||||
//% blockId=device_temperature block="temperature (°C)" blockGap=8
|
||||
//% parts="thermometer"
|
||||
@ -269,7 +269,7 @@ namespace input {
|
||||
* @param kind TODO
|
||||
*/
|
||||
//% help=input/rotation weight=52
|
||||
//% blockId=device_get_rotation block="rotation (°)|%NAME" blockGap=8 icon="\uf197"
|
||||
//% blockId=device_get_rotation block="rotation (°)|%NAME" blockGap=8
|
||||
//% parts="accelerometer" advanced=true
|
||||
int rotation(Rotation kind) {
|
||||
switch (kind) {
|
||||
@ -284,7 +284,7 @@ namespace input {
|
||||
* @param dimension TODO
|
||||
*/
|
||||
//% help=input/magnetic-force weight=51
|
||||
//% blockId=device_get_magnetic_force block="magnetic force (µT)|%NAME" blockGap=8 icon="\uf076"
|
||||
//% blockId=device_get_magnetic_force block="magnetic force (µT)|%NAME" blockGap=8
|
||||
//% parts="compass"
|
||||
//% advanced=true
|
||||
int magneticForce(Dimension dimension) {
|
||||
@ -304,7 +304,7 @@ namespace input {
|
||||
* Gets the number of milliseconds elapsed since power on.
|
||||
*/
|
||||
//% help=input/running-time weight=50
|
||||
//% blockId=device_get_running_time block="running time (ms)" icon="\uf017"
|
||||
//% blockId=device_get_running_time block="running time (ms)"
|
||||
//% advanced=true
|
||||
int runningTime() {
|
||||
return system_timer_current_time();
|
||||
@ -321,7 +321,7 @@ namespace input {
|
||||
* @param range a value describe the maximum strengh of acceleration measured
|
||||
*/
|
||||
//% help=input/set-accelerometer-range
|
||||
//% blockId=device_set_accelerometer_range block="set accelerometer|range %range" icon="\uf135"
|
||||
//% blockId=device_set_accelerometer_range block="set accelerometer|range %range"
|
||||
//% weight=5
|
||||
//% parts="accelerometer"
|
||||
//% advanced=true
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* Events and data from sensors
|
||||
*/
|
||||
//% color=#B4009E weight=99
|
||||
//% color=#B4009E weight=99 icon="\uf192"
|
||||
namespace input {
|
||||
/**
|
||||
* Attaches code to run when the screen is facing up.
|
||||
|
@ -8,7 +8,7 @@ enum class DisplayMode_ {
|
||||
// TODO DISPLAY_MODE_BLACK_AND_WHITE_LIGHT_SENSE
|
||||
};
|
||||
|
||||
//% color=3 weight=35
|
||||
//% color=3 weight=35 icon="\uf205"
|
||||
namespace led {
|
||||
|
||||
/**
|
||||
@ -17,7 +17,7 @@ namespace led {
|
||||
* @param y TODO
|
||||
*/
|
||||
//% help=led/plot weight=78
|
||||
//% blockId=device_plot block="plot|x %x|y %y" icon="\uf205" blockGap=8
|
||||
//% blockId=device_plot block="plot|x %x|y %y" blockGap=8
|
||||
//% parts="ledmatrix"
|
||||
void plot(int x, int y) {
|
||||
uBit.display.image.setPixelValue(x, y, 1);
|
||||
@ -29,7 +29,7 @@ namespace led {
|
||||
* @param y TODO
|
||||
*/
|
||||
//% help=led/unplot weight=77
|
||||
//% blockId=device_unplot block="unplot|x %x|y %y" icon="\uf204" blockGap=8
|
||||
//% blockId=device_unplot block="unplot|x %x|y %y" blockGap=8
|
||||
//% parts="ledmatrix"
|
||||
void unplot(int x, int y) {
|
||||
uBit.display.image.setPixelValue(x, y, 0);
|
||||
@ -41,7 +41,7 @@ namespace led {
|
||||
* @param y TODO
|
||||
*/
|
||||
//% help=led/point weight=76
|
||||
//% blockId=device_point block="point|x %x|y %y" icon="\uf10c"
|
||||
//% blockId=device_point block="point|x %x|y %y"
|
||||
//% parts="ledmatrix"
|
||||
bool point(int x, int y) {
|
||||
int pix = uBit.display.image.getPixelValue(x, y);
|
||||
@ -52,7 +52,7 @@ namespace led {
|
||||
* Get the screen brightness from 0 (off) to 255 (full bright).
|
||||
*/
|
||||
//% help=led/brightness weight=60
|
||||
//% blockId=device_get_brightness block="brightness" icon="\uf042" blockGap=8
|
||||
//% blockId=device_get_brightness block="brightness" blockGap=8
|
||||
//% parts="ledmatrix"
|
||||
//% advanced=true
|
||||
int brightness() {
|
||||
@ -64,7 +64,7 @@ namespace led {
|
||||
* @param value the brightness value, eg:255, 127, 0
|
||||
*/
|
||||
//% help=led/set-brightness weight=59
|
||||
//% blockId=device_set_brightness block="set brightness %value" icon="\uf042"
|
||||
//% blockId=device_set_brightness block="set brightness %value"
|
||||
//% parts="ledmatrix"
|
||||
//% advanced=true
|
||||
void setBrightness(int value) {
|
||||
@ -75,7 +75,7 @@ namespace led {
|
||||
* Cancels the current animation and clears other pending animations.
|
||||
*/
|
||||
//% weight=50 help=led/stop-animation
|
||||
//% blockId=device_stop_animation block="stop animation" icon="\uf04d"
|
||||
//% blockId=device_stop_animation block="stop animation"
|
||||
//% parts="ledmatrix"
|
||||
//% advanced=true
|
||||
void stopAnimation() {
|
||||
@ -95,7 +95,7 @@ namespace led {
|
||||
/**
|
||||
* Turns on or off the display
|
||||
*/
|
||||
//% help=led/enable blockId=device_led_enable block="led enable %on" icon="\uf04d"
|
||||
//% help=led/enable blockId=device_led_enable block="led enable %on"
|
||||
//% advanced=true parts="ledmatrix"
|
||||
void enable(bool on) {
|
||||
if (on) uBit.display.enable();
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* Control of the LED screen.
|
||||
*/
|
||||
//% color=#5C2D91 weight=97
|
||||
//% color=#5C2D91 weight=97 icon="\uf205"
|
||||
namespace led {
|
||||
|
||||
// what's the current high value
|
||||
|
@ -129,7 +129,7 @@ enum BeatFraction {
|
||||
/**
|
||||
* Generation of music tones through pin ``P0``.
|
||||
*/
|
||||
//% color=#D83B01 weight=98
|
||||
//% color=#D83B01 weight=98 icon="\uf025"
|
||||
namespace music {
|
||||
let beatsPerMinute: number = 120;
|
||||
|
||||
@ -139,7 +139,7 @@ namespace music {
|
||||
* @param ms tone duration in milliseconds (ms)
|
||||
*/
|
||||
//% help=music/play-tone weight=90
|
||||
//% blockId=device_play_note block="play|tone %note=device_note|for %duration=device_beat" icon="\uf025" blockGap=8
|
||||
//% blockId=device_play_note block="play|tone %note=device_note|for %duration=device_beat" blockGap=8
|
||||
//% parts="headphone"
|
||||
export function playTone(frequency: number, ms: number): void {
|
||||
pins.analogPitch(frequency, ms);
|
||||
@ -150,7 +150,7 @@ namespace music {
|
||||
* @param frequency pitch of the tone to play in Hertz (Hz)
|
||||
*/
|
||||
//% help=music/ring-tone weight=80
|
||||
//% blockId=device_ring block="ring tone (Hz)|%note=device_note" icon="\uf025" blockGap=8
|
||||
//% blockId=device_ring block="ring tone (Hz)|%note=device_note" blockGap=8
|
||||
//% parts="headphone"
|
||||
export function ringTone(frequency: number): void {
|
||||
pins.analogPitch(frequency, 0);
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* Control currents in Pins for analog/digital signals, servos, i2c, ...
|
||||
*/
|
||||
//% color=#A80000 weight=30
|
||||
//% color=#A80000 weight=30 icon="\uf140"
|
||||
//% advanced=true
|
||||
namespace pins {
|
||||
/**
|
||||
|
@ -246,6 +246,25 @@ namespace pxt {
|
||||
return;
|
||||
}
|
||||
|
||||
void Segment::ensure(uint16_t newSize)
|
||||
{
|
||||
if (newSize < size)
|
||||
{
|
||||
return;
|
||||
}
|
||||
growByMin(newSize);
|
||||
}
|
||||
|
||||
void Segment::setLength(uint32_t newLength)
|
||||
{
|
||||
if (newLength > size)
|
||||
{
|
||||
ensure(length);
|
||||
}
|
||||
length = newLength;
|
||||
return;
|
||||
}
|
||||
|
||||
void Segment::push(uint32_t value)
|
||||
{
|
||||
this->set(length, value);
|
||||
@ -269,17 +288,64 @@ namespace pxt {
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Segment::remove(uint32_t i)
|
||||
//this function removes an element at index i and shifts the rest of the elements to
|
||||
//left to fill the gap
|
||||
uint32_t Segment::remove(uint32_t i)
|
||||
{
|
||||
#ifdef DEBUG_BUILD
|
||||
printf("In Segment::remove\n");
|
||||
printf("In Segment::remove index:%u\n", i);
|
||||
this->print();
|
||||
#endif
|
||||
if (i < length)
|
||||
{
|
||||
data[i] = Segment::MissingValue;
|
||||
//value to return
|
||||
uint32_t ret = data[i];
|
||||
if (i + 1 < length)
|
||||
{
|
||||
//Move the rest of the elements to fill in the gap.
|
||||
memmove(data + i, data + i + 1, (length - i - 1) * sizeof(uint32_t));
|
||||
}
|
||||
length--;
|
||||
data[length] = Segment::MissingValue;
|
||||
#ifdef DEBUG_BUILD
|
||||
printf("After Segment::remove index:%u\n", i);
|
||||
this->print();
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
return;
|
||||
error(ERR_OUT_OF_BOUNDS);
|
||||
return 0;
|
||||
}
|
||||
|
||||
//this function inserts element value at index i by shifting the rest of the elements right.
|
||||
void Segment::insert(uint32_t i, uint32_t value)
|
||||
{
|
||||
#ifdef DEBUG_BUILD
|
||||
printf("In Segment::insert index:%u value:%u\n", i, value);
|
||||
this->print();
|
||||
#endif
|
||||
|
||||
if (i < length)
|
||||
{
|
||||
ensure(length + 1);
|
||||
if (i + 1 < length)
|
||||
{
|
||||
//Move the rest of the elements to fill in the gap.
|
||||
memmove(data + i + 1, data + i, (length - i) * sizeof(uint32_t));
|
||||
}
|
||||
|
||||
data[i] = value;
|
||||
length++;
|
||||
}
|
||||
else
|
||||
{
|
||||
//This is insert beyond the length, just call set which will adjust the length
|
||||
set(i, value);
|
||||
}
|
||||
#ifdef DEBUG_BUILD
|
||||
printf("After Segment::insert index:%u\n", i);
|
||||
this->print();
|
||||
#endif
|
||||
}
|
||||
|
||||
void Segment::print()
|
||||
@ -365,17 +431,34 @@ namespace pxt {
|
||||
}
|
||||
}
|
||||
|
||||
void RefCollection::removeAt(int i)
|
||||
uint32_t RefCollection::removeAt(int i)
|
||||
{
|
||||
if (!head.isValidIndex((uint32_t)i))
|
||||
{
|
||||
return;
|
||||
error(ERR_OUT_OF_BOUNDS);
|
||||
return 0;
|
||||
}
|
||||
if (isRef())
|
||||
{
|
||||
decr(head.get(i));
|
||||
}
|
||||
head.remove(i);
|
||||
return head.remove(i);
|
||||
}
|
||||
|
||||
void RefCollection::insertAt(int i, uint32_t value)
|
||||
{
|
||||
if (i < length())
|
||||
{
|
||||
head.insert(i, value);
|
||||
if (isRef())
|
||||
{
|
||||
incr(value);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
error(ERR_OUT_OF_BOUNDS);
|
||||
}
|
||||
}
|
||||
|
||||
void RefCollection::setAt(int i, uint32_t value)
|
||||
|
@ -180,6 +180,7 @@ namespace pxt {
|
||||
static uint16_t growthFactor(uint16_t size);
|
||||
void growByMin(uint16_t minSize);
|
||||
void growBy(uint16_t newSize);
|
||||
void ensure(uint16_t newSize);
|
||||
|
||||
public:
|
||||
Segment() : data (nullptr), length(0), size(0) {};
|
||||
@ -188,11 +189,13 @@ namespace pxt {
|
||||
void set(uint32_t i, uint32_t value);
|
||||
|
||||
uint32_t getLength() { return length;};
|
||||
void setLength(uint32_t newLength);
|
||||
|
||||
void push(uint32_t value);
|
||||
uint32_t pop();
|
||||
|
||||
void remove(uint32_t i);
|
||||
uint32_t remove(uint32_t i);
|
||||
void insert(uint32_t i, uint32_t value);
|
||||
|
||||
//Returns true if there is a valid index greater than or equal to 'i', returns false otherwise
|
||||
//If 'i' is valid returns it in 'result', if not tries to find the next valid
|
||||
@ -225,11 +228,17 @@ namespace pxt {
|
||||
void print();
|
||||
|
||||
uint32_t length() { return head.getLength();}
|
||||
void setLength(uint32_t newLength) { head.setLength(newLength); }
|
||||
|
||||
void push(uint32_t x);
|
||||
uint32_t pop();
|
||||
uint32_t getAt(int x);
|
||||
void removeAt(int x);
|
||||
void setAt(int x, uint32_t y);
|
||||
uint32_t getAt(int i);
|
||||
void setAt(int i, uint32_t x);
|
||||
//removes the element at index i and shifts the other elements left
|
||||
uint32_t removeAt(int i);
|
||||
//inserts the element at index i and moves the other elements right.
|
||||
void insertAt(int i, uint32_t x);
|
||||
|
||||
int indexOf(uint32_t x, int start);
|
||||
int removeElement(uint32_t x);
|
||||
};
|
||||
|
@ -34,7 +34,7 @@ enum Delimiters {
|
||||
Hash = 6,
|
||||
};
|
||||
|
||||
//% weight=2 color=30
|
||||
//% weight=2 color=30 icon="\uf287"
|
||||
//% advanced=true
|
||||
namespace serial {
|
||||
// note that at least one // followed by % is needed per declaration!
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* Reading and writing data over a serial connection.
|
||||
*/
|
||||
//% weight=2 color=#002050
|
||||
//% weight=2 color=#002050 icon="\uf287"
|
||||
//% advanced=true
|
||||
namespace serial {
|
||||
/**
|
||||
|
56
libs/core/shims.d.ts
vendored
56
libs/core/shims.d.ts
vendored
@ -4,7 +4,7 @@
|
||||
/**
|
||||
* Creation, manipulation and display of LED images.
|
||||
*/
|
||||
//% color=#5C2D91 weight=31
|
||||
//% color=#5C2D91 weight=31 icon="\uf03e"
|
||||
//% advanced=true
|
||||
declare namespace images {
|
||||
|
||||
@ -126,7 +126,7 @@ declare interface Image {
|
||||
/**
|
||||
* Provides access to basic micro:bit functionality.
|
||||
*/
|
||||
//% color=#0078D7 weight=100
|
||||
//% color=#0078D7 weight=100 icon="\uf00a"
|
||||
declare namespace basic {
|
||||
|
||||
/**
|
||||
@ -135,7 +135,7 @@ declare namespace basic {
|
||||
*/
|
||||
//% help=basic/show-number
|
||||
//% weight=96
|
||||
//% blockId=device_show_number block="show|number %number" blockGap=8 icon="\uf1ec"
|
||||
//% blockId=device_show_number block="show|number %number" blockGap=8
|
||||
//% async
|
||||
//% parts="ledmatrix" interval.defl=150 shim=basic::showNumber
|
||||
function showNumber(value: number, interval?: number): void;
|
||||
@ -160,7 +160,7 @@ declare namespace basic {
|
||||
*/
|
||||
//% help=basic/show-string
|
||||
//% weight=87 blockGap=8
|
||||
//% block="show|string %text" icon="\uf031"
|
||||
//% block="show|string %text"
|
||||
//% async
|
||||
//% blockId=device_print_message
|
||||
//% parts="ledmatrix" interval.defl=150 shim=basic::showString
|
||||
@ -170,7 +170,7 @@ declare namespace basic {
|
||||
* Turn off all LEDs
|
||||
*/
|
||||
//% help=basic/clear-screen weight=79
|
||||
//% blockId=device_clear_display block="clear screen" icon="\uf12d"
|
||||
//% blockId=device_clear_display block="clear screen"
|
||||
//% parts="ledmatrix" shim=basic::clearScreen
|
||||
function clearScreen(): void;
|
||||
|
||||
@ -211,7 +211,7 @@ declare namespace basic {
|
||||
|
||||
|
||||
|
||||
//% color=300 weight=99
|
||||
//% color=300 weight=99 icon="\uf192"
|
||||
declare namespace input {
|
||||
|
||||
/**
|
||||
@ -220,7 +220,7 @@ declare namespace input {
|
||||
* @param body code to run when event is raised
|
||||
*/
|
||||
//% help=input/on-button-pressed weight=85 blockGap=8
|
||||
//% blockId=device_button_event block="on button|%NAME|pressed" icon="\uf192"
|
||||
//% blockId=device_button_event block="on button|%NAME|pressed"
|
||||
//% parts="buttonpair" shim=input::onButtonPressed
|
||||
function onButtonPressed(button: Button, body: () => void): void;
|
||||
|
||||
@ -230,7 +230,7 @@ declare namespace input {
|
||||
* @param body code to run when gesture is raised
|
||||
*/
|
||||
//% help=input/on-gesture weight=84 blockGap=8
|
||||
//% blockId=device_gesture_event block="on |%NAME" icon="\uf135"
|
||||
//% blockId=device_gesture_event block="on |%NAME"
|
||||
//% parts="accelerometer" shim=input::onGesture
|
||||
function onGesture(gesture: Gesture, body: () => void): void;
|
||||
|
||||
@ -240,7 +240,7 @@ declare namespace input {
|
||||
* @param body the code to run when the pin is pressed
|
||||
*/
|
||||
//% help=input/on-pin-pressed weight=83
|
||||
//% blockId=device_pin_event block="on pin %name|pressed" icon="\uf094" shim=input::onPinPressed
|
||||
//% blockId=device_pin_event block="on pin %name|pressed" shim=input::onPinPressed
|
||||
function onPinPressed(name: TouchPin, body: () => void): void;
|
||||
|
||||
/**
|
||||
@ -249,7 +249,7 @@ declare namespace input {
|
||||
* @param body the code to run when the pin is released
|
||||
*/
|
||||
//% help=input/on-pin-released weight=6 blockGap=8
|
||||
//% blockId=device_pin_released block="on pin %NAME|released" icon="\uf094"
|
||||
//% blockId=device_pin_released block="on pin %NAME|released"
|
||||
//% advanced=true shim=input::onPinReleased
|
||||
function onPinReleased(name: TouchPin, body: () => void): void;
|
||||
|
||||
@ -269,7 +269,7 @@ declare namespace input {
|
||||
* @param name pin used to detect the touch, eg: TouchPin.P0
|
||||
*/
|
||||
//% help=input/pin-is-pressed weight=58
|
||||
//% blockId="device_pin_is_pressed" block="pin %NAME|is pressed" icon="\uf094"
|
||||
//% blockId="device_pin_is_pressed" block="pin %NAME|is pressed"
|
||||
//% blockGap=8 shim=input::pinIsPressed
|
||||
function pinIsPressed(name: TouchPin): boolean;
|
||||
|
||||
@ -277,7 +277,7 @@ declare namespace input {
|
||||
* Get the acceleration value in milli-gravitys (when the board is laying flat with the screen up, x=0, y=0 and z=-1024)
|
||||
* @param dimension TODO
|
||||
*/
|
||||
//% help=input/acceleration weight=58 icon="\uf135"
|
||||
//% help=input/acceleration weight=58
|
||||
//% blockId=device_acceleration block="acceleration (mg)|%NAME" blockGap=8
|
||||
//% parts="accelerometer" shim=input::acceleration
|
||||
function acceleration(dimension: Dimension): number;
|
||||
@ -286,7 +286,7 @@ declare namespace input {
|
||||
* Reads the light level applied to the LED screen in a range from ``0`` (dark) to ``255`` bright.
|
||||
*/
|
||||
//% help=input/light-level weight=57
|
||||
//% blockId=device_get_light_level block="light level" blockGap=8 icon="\uf185"
|
||||
//% blockId=device_get_light_level block="light level" blockGap=8
|
||||
//% parts="ledmatrix" shim=input::lightLevel
|
||||
function lightLevel(): number;
|
||||
|
||||
@ -294,7 +294,7 @@ declare namespace input {
|
||||
* Get the current compass heading in degrees.
|
||||
*/
|
||||
//% help=input/compass-heading
|
||||
//% weight=56 icon="\uf14e"
|
||||
//% weight=56
|
||||
//% blockId=device_heading block="compass heading (°)" blockGap=8
|
||||
//% parts="compass" shim=input::compassHeading
|
||||
function compassHeading(): number;
|
||||
@ -302,7 +302,7 @@ declare namespace input {
|
||||
/**
|
||||
* Gets the temperature in Celsius degrees (°C).
|
||||
*/
|
||||
//% weight=55 icon="\uf06d"
|
||||
//% weight=55
|
||||
//% help=input/temperature
|
||||
//% blockId=device_temperature block="temperature (°C)" blockGap=8
|
||||
//% parts="thermometer" shim=input::temperature
|
||||
@ -313,7 +313,7 @@ declare namespace input {
|
||||
* @param kind TODO
|
||||
*/
|
||||
//% help=input/rotation weight=52
|
||||
//% blockId=device_get_rotation block="rotation (°)|%NAME" blockGap=8 icon="\uf197"
|
||||
//% blockId=device_get_rotation block="rotation (°)|%NAME" blockGap=8
|
||||
//% parts="accelerometer" advanced=true shim=input::rotation
|
||||
function rotation(kind: Rotation): number;
|
||||
|
||||
@ -322,7 +322,7 @@ declare namespace input {
|
||||
* @param dimension TODO
|
||||
*/
|
||||
//% help=input/magnetic-force weight=51
|
||||
//% blockId=device_get_magnetic_force block="magnetic force (µT)|%NAME" blockGap=8 icon="\uf076"
|
||||
//% blockId=device_get_magnetic_force block="magnetic force (µT)|%NAME" blockGap=8
|
||||
//% parts="compass"
|
||||
//% advanced=true shim=input::magneticForce
|
||||
function magneticForce(dimension: Dimension): number;
|
||||
@ -331,7 +331,7 @@ declare namespace input {
|
||||
* Gets the number of milliseconds elapsed since power on.
|
||||
*/
|
||||
//% help=input/running-time weight=50
|
||||
//% blockId=device_get_running_time block="running time (ms)" icon="\uf017"
|
||||
//% blockId=device_get_running_time block="running time (ms)"
|
||||
//% advanced=true shim=input::runningTime
|
||||
function runningTime(): number;
|
||||
|
||||
@ -346,7 +346,7 @@ declare namespace input {
|
||||
* @param range a value describe the maximum strengh of acceleration measured
|
||||
*/
|
||||
//% help=input/set-accelerometer-range
|
||||
//% blockId=device_set_accelerometer_range block="set accelerometer|range %range" icon="\uf135"
|
||||
//% blockId=device_set_accelerometer_range block="set accelerometer|range %range"
|
||||
//% weight=5
|
||||
//% parts="accelerometer"
|
||||
//% advanced=true shim=input::setAccelerometerRange
|
||||
@ -427,7 +427,7 @@ declare namespace control {
|
||||
|
||||
|
||||
|
||||
//% color=3 weight=35
|
||||
//% color=3 weight=35 icon="\uf205"
|
||||
declare namespace led {
|
||||
|
||||
/**
|
||||
@ -436,7 +436,7 @@ declare namespace led {
|
||||
* @param y TODO
|
||||
*/
|
||||
//% help=led/plot weight=78
|
||||
//% blockId=device_plot block="plot|x %x|y %y" icon="\uf205" blockGap=8
|
||||
//% blockId=device_plot block="plot|x %x|y %y" blockGap=8
|
||||
//% parts="ledmatrix" shim=led::plot
|
||||
function plot(x: number, y: number): void;
|
||||
|
||||
@ -446,7 +446,7 @@ declare namespace led {
|
||||
* @param y TODO
|
||||
*/
|
||||
//% help=led/unplot weight=77
|
||||
//% blockId=device_unplot block="unplot|x %x|y %y" icon="\uf204" blockGap=8
|
||||
//% blockId=device_unplot block="unplot|x %x|y %y" blockGap=8
|
||||
//% parts="ledmatrix" shim=led::unplot
|
||||
function unplot(x: number, y: number): void;
|
||||
|
||||
@ -456,7 +456,7 @@ declare namespace led {
|
||||
* @param y TODO
|
||||
*/
|
||||
//% help=led/point weight=76
|
||||
//% blockId=device_point block="point|x %x|y %y" icon="\uf10c"
|
||||
//% blockId=device_point block="point|x %x|y %y"
|
||||
//% parts="ledmatrix" shim=led::point
|
||||
function point(x: number, y: number): boolean;
|
||||
|
||||
@ -464,7 +464,7 @@ declare namespace led {
|
||||
* Get the screen brightness from 0 (off) to 255 (full bright).
|
||||
*/
|
||||
//% help=led/brightness weight=60
|
||||
//% blockId=device_get_brightness block="brightness" icon="\uf042" blockGap=8
|
||||
//% blockId=device_get_brightness block="brightness" blockGap=8
|
||||
//% parts="ledmatrix"
|
||||
//% advanced=true shim=led::brightness
|
||||
function brightness(): number;
|
||||
@ -474,7 +474,7 @@ declare namespace led {
|
||||
* @param value the brightness value, eg:255, 127, 0
|
||||
*/
|
||||
//% help=led/set-brightness weight=59
|
||||
//% blockId=device_set_brightness block="set brightness %value" icon="\uf042"
|
||||
//% blockId=device_set_brightness block="set brightness %value"
|
||||
//% parts="ledmatrix"
|
||||
//% advanced=true shim=led::setBrightness
|
||||
function setBrightness(value: number): void;
|
||||
@ -483,7 +483,7 @@ declare namespace led {
|
||||
* Cancels the current animation and clears other pending animations.
|
||||
*/
|
||||
//% weight=50 help=led/stop-animation
|
||||
//% blockId=device_stop_animation block="stop animation" icon="\uf04d"
|
||||
//% blockId=device_stop_animation block="stop animation"
|
||||
//% parts="ledmatrix"
|
||||
//% advanced=true shim=led::stopAnimation
|
||||
function stopAnimation(): void;
|
||||
@ -499,7 +499,7 @@ declare namespace led {
|
||||
/**
|
||||
* Turns on or off the display
|
||||
*/
|
||||
//% help=led/enable blockId=device_led_enable block="led enable %on" icon="\uf04d"
|
||||
//% help=led/enable blockId=device_led_enable block="led enable %on"
|
||||
//% advanced=true parts="ledmatrix" shim=led::enable
|
||||
function enable(on: boolean): void;
|
||||
|
||||
@ -658,7 +658,7 @@ declare namespace pins {
|
||||
|
||||
|
||||
|
||||
//% weight=2 color=30
|
||||
//% weight=2 color=30 icon="\uf287"
|
||||
//% advanced=true
|
||||
declare namespace serial {
|
||||
|
||||
|
@ -24,7 +24,7 @@ using namespace pxt;
|
||||
// payload: string length (9), string (10 ... 28)
|
||||
#define PACKET_TYPE_STRING 2
|
||||
|
||||
//% color=270 weight=34
|
||||
//% color=270 weight=34 icon="\uf012"
|
||||
namespace radio {
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* Communicate data using radio packets
|
||||
*/
|
||||
//% color=#E3008C weight=34
|
||||
//% color=#E3008C weight=34 icon="\uf012"
|
||||
namespace radio {
|
||||
export class Packet {
|
||||
/**
|
||||
|
2
libs/radio/shims.d.ts
vendored
2
libs/radio/shims.d.ts
vendored
@ -2,7 +2,7 @@
|
||||
|
||||
|
||||
|
||||
//% color=270 weight=34
|
||||
//% color=270 weight=34 icon="\uf012"
|
||||
declare namespace radio {
|
||||
|
||||
/**
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "pxt-microbit",
|
||||
"version": "0.7.12",
|
||||
"version": "0.7.14",
|
||||
"description": "micro:bit target for PXT",
|
||||
"keywords": [
|
||||
"JavaScript",
|
||||
@ -34,6 +34,6 @@
|
||||
"semantic-ui-less": "^2.2.4"
|
||||
},
|
||||
"dependencies": {
|
||||
"pxt-core": "0.7.13"
|
||||
"pxt-core": "0.8.3"
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user