Compare commits

...

20 Commits

Author SHA1 Message Date
79ead74af4 0.7.23 2017-01-10 10:31:04 -08:00
0f8ff95b72 Bump pxt-core to 0.8.13 2017-01-10 10:30:58 -08:00
05028c4527 Serial events (#337)
* added "serial->on data received"

* updated info

* updated docs

* added readline to read entire buffer

* lazy initialize of serial buffers

* init async on event

* updated docs
2017-01-10 10:26:44 -08:00
4054da3483 0.7.22 2017-01-09 21:33:47 -08:00
7052d27d6d Bump pxt-core to 0.8.12 2017-01-09 21:33:44 -08:00
365af8d672 Merge pull request #335 from Microsoft/default
Default values for array
2017-01-09 20:35:56 -08:00
5086ca308c 0.7.21 2017-01-09 16:08:58 -08:00
c1af770afc Bump pxt-core to 0.8.11 2017-01-09 16:08:58 -08:00
e175e70d01 Merge branch 'master' into editortoolbox 2017-01-09 16:01:35 -08:00
cbc228dca3 negative scroll fix
fix for Microsoft/pxt#813
2017-01-09 14:17:19 -08:00
462127c661 Loader (#336)
* Custom microbit loader

* updated animation

* use standardized name

* moving loader support to pxt
2017-01-09 07:51:00 -08:00
487da05eca Fix for https://github.com/Microsoft/pxt/issues/1057 2017-01-09 10:58:24 +00:00
c938618d29 adding default values for beyond the array.length access 2017-01-08 19:08:09 -08:00
91321dab83 Support for default values in array. 2017-01-08 18:43:14 -08:00
0cb3d6e44e Changes accompanying the editor toolbox. 2017-01-07 17:35:54 -08:00
7a98b06424 Custom microbit loader (#334)
* Custom microbit loader

* updated animation

* use standardized name
2017-01-06 17:39:48 -08:00
69c80d3aff Add css and default icon to NPM package for Electron app (#332) 2017-01-06 16:29:48 -08:00
1d82f08668 update instructions to use inline buttons 2017-01-06 14:41:33 -08:00
4681a68ffd added avatar image 2017-01-06 09:51:19 -08:00
0a69b773de missing package annotation 2017-01-06 07:19:00 -08:00
23 changed files with 353 additions and 164 deletions

View File

@ -16,10 +16,10 @@ at a certain pace. In the code below, the user pressed button ``A`` to launch th
```blocks
input.onButtonPressed(Button.A, () => {
pins.servoWritePin(AnalogPin.P0, 0)
basic.pause(500)
pins.servoWritePin(AnalogPin.P0, 180)
basic.pause(500)
pins.servoWritePin(AnalogPin.P0, 0);
basic.pause(500);
pins.servoWritePin(AnalogPin.P0, 180);
basic.pause(500);
});
```
@ -45,4 +45,8 @@ radio.onDataPacketReceived(({receivedNumber}) => {
input.onButtonPressed(Button.A, () => {
radio.sendNumber(0)
})
```
```package
radio
```

View File

@ -7,8 +7,11 @@ serial.writeLine("");
serial.writeNumber(0);
serial.writeValue("x", 0);
serial.writeString("");
serial.readUntil(",");
serial.readLine();
serial.readString();
serial.redirect(SerialPin.P0, SerialPin.P0, BaudRate.BaudRate115200);
serial.onDataReceived(",", () => {})
```
### See Also

View File

@ -0,0 +1,29 @@
# Serial On Data Received
Registers an event to be fired when one of the delimiter is matched.
```sig
serial.onDataReceived(",", () => {})
```
### Parameters
* `delimiters` is a [string](/reference/types/string) containing any of the character to match
### Example
Read values separated by `,`:
```blocks
serial.onDataReceived(serial.delimiters(Delimiters.Comma), () => {
basic.showString(serial.readUntil(serial.delimiters(Delimiters.Comma)))
})
```
### See also
[serial](/device/serial),
[serial write line](/reference/serial/write-line),
[serial write value](/reference/serial/write-value)

View File

@ -0,0 +1,27 @@
# Serial Read String
Read the buffered serial data as a string
```sig
serial.readString();
```
### Returns
* a [string](/reference/types/string) containing input from the serial port. Empty if no data available.
### Example
The following program scrolls text on the screen as it arrives from serial.
```blocks
basic.forever(() => {
basic.showString(serial.readString());
});
```
### See also
[serial](/device/serial),
[serial write line](/reference/serial/write-line),
[serial write value](/reference/serial/write-value)

61
docs/static/avatar.svg vendored Normal file
View File

@ -0,0 +1,61 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
role="img"
aria-labelledby="title desc"
xml:space="preserve"
enable-background="new 0 0 280 32.755"
height="52.672001"
width="52.672001"
version="1.1"
id="svg2"
inkscape:version="0.91 r13725"
sodipodi:docname="logo.square.black.svg"><sodipodi:namedview
pagecolor="#ff00ff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1536"
inkscape:window-height="801"
id="namedview14"
showgrid="false"
inkscape:zoom="2.0836233"
inkscape:cx="83.390493"
inkscape:cy="16.071144"
inkscape:window-x="-8"
inkscape:window-y="-8"
inkscape:window-maximized="1"
inkscape:current-layer="svg2" /><rect
id="backgroundrect"
width="195.47368"
height="34.210526"
x="0"
y="18.461473"
class=""
style="fill:none;stroke:none" /><title
id="title"
lang="en-GB">BBC micro:bit</title><desc
id="desc"
lang="en-GB">BBC micro:bit logo</desc><metadata
id="metadata37"><rdf:rdf><cc:work
rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title /></cc:work></rdf:rdf><rdf:RDF><cc:Work
rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title>BBC micro:bit</dc:title></cc:Work></rdf:RDF></metadata><defs
id="defs35" /><path
inkscape:connector-curvature="0"
class=""
d="m 37.363,29.377 c -1.677,0 -3.035,-1.364 -3.035,-3.042 0,-1.678 1.357,-3.038 3.035,-3.038 1.684,0 3.039,1.36 3.039,3.038 0,1.678 -1.355,3.042 -3.039,3.042 M 15.052,23.3 c -1.677,0 -3.042,1.357 -3.042,3.035 0,1.678 1.363,3.042 3.042,3.042 1.674,0 3.036,-1.364 3.036,-3.042 0,-1.678 -1.363,-3.035 -3.036,-3.035 m -0.003,-5.99 22.576,0 c 4.979,0 9.027,4.047 9.027,9.027 0,4.979 -4.049,9.031 -9.027,9.031 l -22.576,0 c -4.977,0 -9.0299993,-4.053 -9.0299993,-9.031 C 6.0180007,21.357 10.072,17.31 15.049,17.31 m 22.576,24.076 c 8.299,0 15.047,-6.75 15.047,-15.049 0,-8.299 -6.748,-15.051 -15.047,-15.051 l -22.576,0 C 6.7500007,11.286 6.9250488e-7,18.038 6.9250488e-7,26.337 6.9250488e-7,34.636 6.7500007,41.386 15.049,41.386 l 22.576,0"
id="path21"
style="fill:#000000"
sodipodi:nodetypes="csssccsssccsssscccsssssc" /></svg>

After

Width:  |  Height:  |  Size: 2.8 KiB

61
docs/static/loader.svg vendored Normal file
View File

@ -0,0 +1,61 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
role="img"
aria-labelledby="title desc"
xml:space="preserve"
enable-background="new 0 0 280 32.755"
height="52.672001"
width="52.672001"
version="1.1"
id="svg2"
inkscape:version="0.91 r13725"
sodipodi:docname="logo.square.white.svg"><sodipodi:namedview
pagecolor="#ff00ff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1536"
inkscape:window-height="801"
id="namedview14"
showgrid="false"
inkscape:zoom="2.0836233"
inkscape:cx="83.390493"
inkscape:cy="16.071144"
inkscape:window-x="-8"
inkscape:window-y="-8"
inkscape:window-maximized="1"
inkscape:current-layer="svg2" /><rect
id="backgroundrect"
width="195.47368"
height="34.210526"
x="0"
y="18.461473"
class=""
style="fill:none;stroke:none" /><title
id="title"
lang="en-GB">BBC micro:bit</title><desc
id="desc"
lang="en-GB">BBC micro:bit logo</desc><metadata
id="metadata37"><rdf:rdf><cc:work
rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title /></cc:work></rdf:rdf><rdf:RDF><cc:Work
rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title>BBC micro:bit</dc:title></cc:Work></rdf:RDF></metadata><defs
id="defs35" /><path
inkscape:connector-curvature="0"
class=""
d="m 37.363,29.377 c -1.677,0 -3.035,-1.364 -3.035,-3.042 0,-1.678 1.357,-3.038 3.035,-3.038 1.684,0 3.039,1.36 3.039,3.038 0,1.678 -1.355,3.042 -3.039,3.042 M 15.052,23.3 c -1.677,0 -3.042,1.357 -3.042,3.035 0,1.678 1.363,3.042 3.042,3.042 1.674,0 3.036,-1.364 3.036,-3.042 0,-1.678 -1.363,-3.035 -3.036,-3.035 m -0.003,-5.99 22.576,0 c 4.979,0 9.027,4.047 9.027,9.027 0,4.979 -4.049,9.031 -9.027,9.031 l -22.576,0 c -4.977,0 -9.0299993,-4.053 -9.0299993,-9.031 C 6.0180007,21.357 10.072,17.31 15.049,17.31 m 22.576,24.076 c 8.299,0 15.047,-6.75 15.047,-15.049 0,-8.299 -6.748,-15.051 -15.047,-15.051 l -22.576,0 C 6.7500007,11.286 6.9250488e-7,18.038 6.9250488e-7,26.337 6.9250488e-7,34.636 6.7500007,41.386 15.049,41.386 l 22.576,0"
id="path21"
style="fill:#ffffff"
sodipodi:nodetypes="csssccsssccsssscccsssssc" /></svg>

After

Width:  |  Height:  |  Size: 2.8 KiB

View File

@ -5,15 +5,12 @@
Place blocks in the workspace to scroll text on the screen.
```blocks
basic.showString("Hi!")
basic.showString("Hello!")
```
### Step 2
Transfer your code in your @boardname@! Click the **Download** button
and follow the instructions.
ANIMATEDGIF
Click ``|Download|`` to transfer your code in your @boardname@!
### Step 3
@ -22,20 +19,18 @@ Let's make it scroll when button **A** is pressed.
```block
input.onButtonPressed(Button.A, () => {
basic.showString("Hi!")
basic.showString("Hello!")
});
```
### Step 4
Transfer your code in your @boardname@ and try pressing **A**.
ANIMATEDGIF
Click ``|Download|`` to transfer your code
and press **A** to scroll your text.
### Step 5
Place more blocks to display a smiley when button **B** is pressed.
Download your code and try it!
```block
input.onButtonPressed(Button.B, () => {
@ -52,7 +47,6 @@ input.onButtonPressed(Button.B, () => {
### Step 6
Drag more blocks to display a frownie when @boardname@ is shaken.
Download your code and try it!
```block
input.onGesture(Gesture.Shake, () => {

View File

@ -231,8 +231,10 @@
"pins.spiWrite|param|value": "Data to be sent to the SPI slave",
"serial": "Reading and writing data over a serial connection.",
"serial.delimiters": "Returns the delimiter corresponding string",
"serial.onLineReceived": "Registers an event to be fired when a line has been received",
"serial.onDataReceived": "Registers an event to be fired when one of the delimiter is matched.",
"serial.onDataReceived|param|delimiters": "the characters to match received characters against.",
"serial.readLine": "Reads a line of text from the serial port.",
"serial.readString": "Reads the buffered received data as a string",
"serial.readUntil": "Reads a line of text from the serial port and returns the buffer when the delimiter is met.",
"serial.readUntil|param|delimiter": "text delimiter that separates each text chunk",
"serial.redirect": "Dynamically configuring the serial instance to use pins other than USBTX and USBRX.",

View File

@ -171,7 +171,9 @@
"pins.spiWrite|block": "spi write %value",
"pins|block": "pins",
"serial.delimiters|block": "%del",
"serial.onDataReceived|block": "serial|on data received %delimiters=serial_delimiter_conv",
"serial.readLine|block": "serial|read line",
"serial.readString|block": "serial|read string",
"serial.readUntil|block": "serial|read until %delimiter=serial_delimiter_conv",
"serial.redirect|block": "serial|redirect to|TX %tx|RX %rx|at baud rate %rate",
"serial.writeLine|block": "serial|write line %text",

View File

@ -76,7 +76,7 @@ namespace Boolean_ {
}
//%
bool bang(bool v) { return !v; }
bool bang(int v) { return v == 0; }
}
namespace Number_ {

View File

@ -150,15 +150,9 @@ namespace pxt {
if (i < length)
{
if (data[i] != Segment::MissingValue)
{
return data[i];
}
error(ERR_MISSING_VALUE);
return 0;
}
error(ERR_OUT_OF_BOUNDS);
return 0;
return Segment::DefaultValue;
}
void Segment::set(uint32_t i, uint32_t value)
@ -223,12 +217,8 @@ namespace pxt {
{
memcpy(tmp, data, size * sizeof(uint32_t));
}
//fill the rest with missing values;
for(uint16_t i = size; i < newSize; i++)
{
tmp[i] = Segment::MissingValue;
}
//fill the rest with default value
memset(tmp + size, Segment::DefaultValue, (newSize - size) * sizeof(uint32_t));
//free older segment;
::operator delete(data);
@ -280,12 +270,11 @@ namespace pxt {
if (length > 0)
{
uint32_t value = data[length];
data[length] = Segment::MissingValue;
data[length] = Segment::DefaultValue;
--length;
return value;
}
error(ERR_OUT_OF_BOUNDS);
return 0;
return Segment::DefaultValue;
}
//this function removes an element at index i and shifts the rest of the elements to
@ -306,15 +295,14 @@ namespace pxt {
memmove(data + i, data + i + 1, (length - i - 1) * sizeof(uint32_t));
}
length--;
data[length] = Segment::MissingValue;
data[length] = Segment::DefaultValue;
#ifdef DEBUG_BUILD
printf("After Segment::remove index:%u\n", i);
this->print();
#endif
return ret;
}
error(ERR_OUT_OF_BOUNDS);
return 0;
return Segment::DefaultValue;
}
//this function inserts element value at index i by shifting the rest of the elements right.
@ -360,32 +348,13 @@ namespace pxt {
bool Segment::isValidIndex(uint32_t i)
{
if (i > length || data[i] == Segment::MissingValue)
if (i > length)
{
return false;
}
return true;
}
bool Segment::getNextValidIndex(uint32_t i, uint32_t *result)
{
while (i < length)
{
if (data[i] != Segment::MissingValue)
{
*result = i;
#ifdef DEBUG_BUILD
printf("In Segment::getNextValidIndex result=%u\n",i);
this->print();
#endif
return true;
}
i++;
}
return false;
}
void Segment::destroy()
{
#ifdef DEBUG_BUILD
@ -415,29 +384,16 @@ namespace pxt {
uint32_t RefCollection::getAt(int i)
{
if (head.isValidIndex(i))
uint32_t tmp = head.get(i);
if (isRef())
{
uint32_t tmp = head.get(i);
if (isRef())
{
incr(tmp);
}
return tmp;
}
else
{
error(ERR_OUT_OF_BOUNDS);
return 0;
incr(tmp);
}
return tmp;
}
uint32_t RefCollection::removeAt(int i)
{
if (!head.isValidIndex((uint32_t)i))
{
error(ERR_OUT_OF_BOUNDS);
return 0;
}
if (isRef())
{
decr(head.get(i));
@ -447,18 +403,11 @@ namespace pxt {
void RefCollection::insertAt(int i, uint32_t value)
{
if (i < length())
head.insert(i, value);
if (isRef())
{
head.insert(i, value);
if (isRef())
{
incr(value);
}
}
else
{
error(ERR_OUT_OF_BOUNDS);
}
incr(value);
}
}
void RefCollection::setAt(int i, uint32_t value)
@ -480,26 +429,31 @@ namespace pxt {
{
StringData *xx = (StringData*)x;
uint32_t i = start;
while(head.getNextValidIndex(start, &i))
while(head.isValidIndex(i))
{
StringData *ee = (StringData*)head.get(i);
if (xx->len == ee->len && memcmp(xx->data, ee->data, xx->len) == 0)
if (ee == xx)
{
//handles ee being null
return (int) i;
}
if (ee && xx->len == ee->len && memcmp(xx->data, ee->data, xx->len) == 0)
{
return (int)i;
}
start = i;
i++;
}
}
else
{
uint32_t i = start;
while(head.getNextValidIndex(start, &i))
while(head.isValidIndex(i))
{
if (head.get(i) == x)
{
return (int)i;
}
start = i;
i++;
}
}
@ -550,12 +504,9 @@ namespace pxt {
{
if (this->isRef())
{
uint32_t start = 0;
uint32_t i = 0;
while(head.getNextValidIndex(start, &i))
for(uint32_t i = 0; i < this->head.getLength(); i++)
{
decr(this->head.get(i));
start = i;
}
}
this->head.destroy();

View File

@ -38,7 +38,6 @@ namespace pxt {
ERR_OUT_OF_BOUNDS = 8,
ERR_REF_DELETED = 7,
ERR_SIZE = 9,
ERR_MISSING_VALUE = 10,
} ERROR;
extern const uint32_t functionsAndBytecode[];
@ -175,7 +174,7 @@ namespace pxt {
uint16_t size;
static const uint16_t MaxSize = 0xFFFF;
static const uint32_t MissingValue = 0x80000000;
static const uint32_t DefaultValue = 0x0;
static uint16_t growthFactor(uint16_t size);
void growByMin(uint16_t minSize);
@ -197,10 +196,6 @@ namespace pxt {
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
//index < length which is valid.
bool getNextValidIndex(uint32_t i, uint32_t *result);
bool isValidIndex(uint32_t i);
void destroy();

View File

@ -51,24 +51,27 @@ namespace serial {
}
/**
* Reads a line of text from the serial port.
*/
//% help=serial/read-line
//% blockId=serial_read_line block="serial|read line"
//% weight=20 blockGap=8
StringData* readLine() {
return readUntil(ManagedString("\n").leakData());
* Reads the buffered received data as a string
*/
//% blockId=serial_read_buffer block="serial|read string"
//% weight=18
StringData* readString() {
int n = uBit.serial.getRxBufferSize();
if (n == 0) return ManagedString("").leakData();
return ManagedString(uBit.serial.read(n, MicroBitSerialMode::ASYNC)).leakData();
}
/**
* Registers an event to be fired when one of the delimiter is matched
* @param delimiters the characters to match received characters against. eg:"\n"
* Registers an event to be fired when one of the delimiter is matched.
* @param delimiters the characters to match received characters against.
*/
// help=serial/on-data-received
// weight=18
//% help=serial/on-data-received
//% weight=18 blockId=serial_on_data_received block="serial|on data received %delimiters=serial_delimiter_conv"
void onDataReceived(StringData* delimiters, Action body) {
uBit.serial.eventOn(ManagedString(delimiters));
registerWithDal(MICROBIT_ID_SERIAL, MICROBIT_SERIAL_EVT_DELIM_MATCH, body);
// lazy initialization of serial buffers
uBit.serial.read(MicroBitSerialMode::ASYNC);
}
/**

View File

@ -38,20 +38,20 @@ namespace serial {
}
/**
* Registers an event to be fired when a line has been received
*/
// help=serial/on-line-received
// blockId=serial_on_line_received block="serial on line received"
// weight=21 blockGap=8
export function onLineReceived(body: Action): void {
// serial.onDataReceived("\n", body);
* Reads a line of text from the serial port.
*/
//% help=serial/read-line
//% blockId=serial_read_line block="serial|read line"
//% weight=20 blockGap=8
export function readLine(): string {
return serial.readUntil(delimiters(Delimiters.NewLine));
}
/**
* Returns the delimiter corresponding string
*/
//% blockId="serial_delimiter_conv" block="%del"
//% weight=1
//% weight=1 blockHidden=true
export function delimiters(del: Delimiters): string {
// even though it might not look like, this is more
// (memory) efficient than the C++ implementation, because the

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

@ -672,12 +672,19 @@ declare namespace serial {
function readUntil(delimiter: string): string;
/**
* Reads a line of text from the serial port.
* Reads the buffered received data as a string
*/
//% help=serial/read-line
//% blockId=serial_read_line block="serial|read line"
//% weight=20 blockGap=8 shim=serial::readLine
function readLine(): string;
//% blockId=serial_read_buffer block="serial|read string"
//% weight=18 shim=serial::readString
function readString(): string;
/**
* Registers an event to be fired when one of the delimiter is matched.
* @param delimiters the characters to match received characters against.
*/
//% help=serial/on-data-received
//% weight=18 blockId=serial_on_data_received block="serial|on data received %delimiters=serial_delimiter_conv" shim=serial::onDataReceived
function onDataReceived(delimiters: string, body: () => void): void;
/**
* Sends a piece of text through Serial connection.

View File

@ -1,6 +1,6 @@
{
"name": "pxt-microbit",
"version": "0.7.20",
"version": "0.7.23",
"description": "micro:bit target for PXT",
"keywords": [
"JavaScript",
@ -21,10 +21,12 @@
"built/*.json",
"built/*.d.ts",
"built/hexcache",
"built/web",
"sim/public",
"docs/*.md",
"docs/*/*.md",
"docs/*/*/*.md"
"docs/*/*/*.md",
"docs/static/icons/favicon.ico"
],
"main": "built/pxtrequire.js",
"typings": "built/pxtrequire.d.ts",
@ -34,6 +36,6 @@
"semantic-ui-less": "^2.2.4"
},
"dependencies": {
"pxt-core": "0.8.8"
"pxt-core": "0.8.13"
}
}

View File

@ -53,9 +53,9 @@ namespace pxsim {
}
public shiftRight(cols: number) {
for (let x = this.width - 1; x <= 0; --x)
for (let x = this.width - 1; x >= 0; --x)
for (let y = 0; y < 5; ++y)
this.set(x, y, x > cols ? this.get(x - cols, y) : 0);
this.set(x, y, x >= cols ? this.get(x - cols, y) : 0);
}
public clear(): void {
@ -195,11 +195,16 @@ namespace pxsim.ImageMethods {
board().ledMatrixState.animationQ.enqueue({
interval: interval,
frame: () => {
//TODO: support right to left.
if (off >= leds.width || off < 0) return false;
stride > 0 ? display.shiftLeft(stride) : display.shiftRight(-stride);
let c = Math.min(stride, leds.width - off);
leds.copyTo(off, c, display, 5 - stride)
if (stride > 0) {
display.shiftLeft(stride);
const c = Math.min(stride, leds.width - off);
leds.copyTo(off, c, display, 5 - stride)
} else {
display.shiftRight(-stride);
const c = Math.min(-stride, leds.width - off);
leds.copyTo(off, c, display, 0)
}
off += stride;
return true;
},

View File

@ -35,18 +35,14 @@ namespace pxsim.serial {
board().writeSerial(s);
}
export function readUntil(del: string): string {
return readString();
}
export function readString(): string {
return board().serialState.readSerial();
}
export function readLine(): string {
return board().serialState.readSerial();
}
export function readUntil(del: string): string {
return readLine();
}
export function onDataReceived(delimiters: string, handler: RefAction) {
let b = board();
b.bus.listen(DAL.MICROBIT_ID_SERIAL, DAL.MICROBIT_SERIAL_EVT_DELIM_MATCH, handler);

View File

@ -1,3 +1,56 @@
/*******************************
Site Overrides
*******************************/
.ui.loader:before {
border: none;
border-radius: 0px;
box-shadow: none;
}
.ui.loader:after {
border: none;
box-shadow: none;
border-radius: 0px;
margin: 40px auto;
background: transparent data-uri("static/loader.svg") no-repeat center center;
background-size: 100%;
-webkit-animation: loader-pxt @loaderSpeed infinite ease-in-out;
animation: loader-pxt @loaderSpeed infinite ease-in-out;
}
@-webkit-keyframes loader-pxt {
0% {
-webkit-transform: perspective(160px) rotateX(0deg) rotateY(0deg);
transform: perspective(160px) rotateX(0deg) rotateY(0deg);
opacity: 0}
15% {
-webkit-transform: perspective(160px) rotateX(0deg) rotateY(-@loaderAngle);
transform: perspective(160px) rotateX(0deg) rotateY(-@loaderAngle); }
50% {
-webkit-transform: perspective(160px) rotateX(0deg) rotateY(@loaderAngle);
transform: perspective(160px) rotateX(0deg) rotateY(@loaderAngle);
opacity: 1}
100% {
-webkit-transform: perspective(160px) rotateX(0deg) rotateY(0deg);
transform: perspective(160px) rotateX(0deg) rotateY(0deg);
opacity: 0}
}
@keyframes loader-pxt {
0% {
-webkit-transform: perspective(160px) rotateX(0deg) rotateY(0deg);
transform: perspective(160px) rotateX(0deg) rotateY(0deg);
opacity: 0}
15% {
-webkit-transform: perspective(160px) rotateX(0deg) rotateY(-10deg);
transform: perspective(160px) rotateX(0deg) rotateY(-10deg); }
50% {
-webkit-transform: perspective(160px) rotateX(0deg) rotateY(10deg);
transform: perspective(160px) rotateX(0deg) rotateY(10deg);
opacity: 1}
100% {
-webkit-transform: perspective(160px) rotateX(0deg) rotateY(0deg);
transform: perspective(160px) rotateX(0deg) rotateY(0deg);
opacity: 0}
}

View File

@ -1,3 +1,8 @@
/*******************************
User Variable Overrides
*******************************/
@loaderSpeed: 2s;
@loaderAngle: 5deg;
@large : 200px;

View File

@ -16,6 +16,7 @@
@red: #EF767A;
@pink: #F46197;
@yellow: #FDE74C;
@grey:#95a5a6;
/* Microbit.org colors */
@orange: #ff8b27;
@ -35,9 +36,6 @@
@mainMenuInvertedBackground: @blue;
@mainMenuTutorialBackground: @orange;
@mainMenuHeight: 5rem;
@mobileMenuHeight: 4.4rem;
@mainMenuBlocksJsToggleColor: @primaryColor;
@tutorialSelectedMenuColor: @blue;
@ -55,6 +53,7 @@
--------------------*/
@simulatorBackground: #FDFDFF;
@editorToolsBackground: @simulatorBackground;
@blocklySvgColor: #ecf0f1;
/*-------------------

View File

@ -12,16 +12,11 @@
Add your custom CSS here
*******************************/
.download-button {
&:extend(.ui.button all);
.ui.button.download-button {
&:extend(.purple all);
}
.download-button.download-button-full {
&:extend(.ui.inverted.purple.button all);
}
.download-button:hover {
.ui.button.download-button:hover {
&:extend(.green all);
color: black !important;
}
@ -30,12 +25,11 @@
&:extend(.ui.inverted.button all);
}
.getting-started-btn {
&:extend(.ui.button all);
.ui.button.getting-started-btn {
&:extend(.orange all);
}
#filelist {
#filelist, #editortools {
background: #fff url(https://az742082.vo.msecnd.net/pub/psopafpj) 0 0 repeat !important;
}
@ -62,12 +56,11 @@
.blocklyToolboxDiv, .monacoToolboxDiv {
background-color: white !important;
border-left: 1px solid #ecf0f1 !important;
box-shadow: 0px 0px 2px 0px rgba(0,0,0,0.12), 0px 2px 2px 0px rgba(0,0,0,0.24);
box-shadow: 0px 0px 2px 0px rgba(0,0,0,0.12), 0px 0px 2px 0px rgba(0,0,0,0.24);
}
.blocklyFlyoutBackground {
fill: #525A67 !important;
fill-opacity: 0.5 !important;
}
/* Remove shadow around blockly blocks */
@ -80,14 +73,8 @@
}
/* Blockly Toolbox Buttons */
.blocklyToolboxButtons .blocklyAddPackageButton {
&:extend(.ui.inverted.pink.button all);
&:extend(.ui.circular.button all);
}
.blocklyToolboxButtons .blocklyUndoButton {
&:extend(.ui.inverted.blue.button all);
&:extend(.ui.circular.button all);
.ui.button.blocklyAddPackageButton {
&:extend(.pink all);
}
/*******************************
@ -121,6 +108,9 @@
/* Tablet */
@media only screen and (min-width: @tabletBreakpoint) and (max-width: @largestTabletScreen) {
#filelist {
background: transparent !important;
}
}
/* Small Monitor */

View File

@ -32,7 +32,7 @@
@input : 'pxt';
@label : 'pxt';
@list : 'pxt';
@loader : 'pulsar';
@loader : 'pxt';
@rail : 'pxt';
@reveal : 'pxt';
@segment : 'pxt';