Compare commits
56 Commits
Author | SHA1 | Date | |
---|---|---|---|
472846bf3c | |||
ac4fbc850b | |||
c7054b7ee0 | |||
559a43e17b | |||
7671bc46ad | |||
b3c5f2926d | |||
28830aa905 | |||
7fbbb5e65a | |||
51ebc29887 | |||
f5d1722eae | |||
5f876d5ea9 | |||
31de8892fa | |||
0d0a68122d | |||
4ad660568e | |||
58e82a571d | |||
e629b866d5 | |||
f0ac2b7a05 | |||
e3c8db28e4 | |||
2c0e19a120 | |||
595eb788b2 | |||
2e15d22e9e | |||
57082654a9 | |||
8cbf7d38e3 | |||
a99a7325bf | |||
fa3ed9dd21 | |||
45fd40a553 | |||
5a18bea9eb | |||
d310312841 | |||
a4b93f7199 | |||
538a4b7bbf | |||
0078e7bc12 | |||
d2726133a9 | |||
00f4c9cbb3 | |||
e15da5dee1 | |||
85dda4ea84 | |||
a3ffe4e1cf | |||
90c4d4f73b | |||
6484d559d6 | |||
357436f14d | |||
85fe96b3fd | |||
cdac932c42 | |||
dcfc2a110d | |||
e9561f54c3 | |||
86f6b58d38 | |||
eee52a5c04 | |||
1a0b0eac71 | |||
5a98ae0bb8 | |||
a9eea9a618 | |||
3086c521e3 | |||
6788f79650 | |||
5900239045 | |||
248267ec2c | |||
9429075555 | |||
1fa871f2e7 | |||
04dab7df2c | |||
b6474467bc |
@ -2,6 +2,10 @@
|
|||||||
|
|
||||||
### @description Language constructs for the Block editor.
|
### @description Language constructs for the Block editor.
|
||||||
|
|
||||||
|
Blocks snap into each other to define the program that your @boardname@ will run.
|
||||||
|
Blocks can be event (buttons, shake, ...) or need to be snapped into an event to run.
|
||||||
|
The [on-start](/blocks/on-start) event runs first.
|
||||||
|
|
||||||
```namespaces
|
```namespaces
|
||||||
for (let i = 0;i<5;++i) {}
|
for (let i = 0;i<5;++i) {}
|
||||||
if (true){}
|
if (true){}
|
||||||
|
@ -16,7 +16,13 @@ input.onButtonPressed(Button.A, () => {
|
|||||||
led.setBrightness(50)
|
led.setBrightness(50)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
## What about JavaScript?
|
## What about JavaScript?
|
||||||
|
|
||||||
``on-start`` only exists in the block editor. In JavaScript, all code executes sequentially from the first line.
|
``on-start`` only exists in the block editor. In JavaScript, all code executes sequentially from the first line.
|
||||||
|
|
||||||
|
## Hey, my events moved!
|
||||||
|
|
||||||
|
When we transform the blocks into JavaScript, we always place all the event registrations (buttons, shake, ...)
|
||||||
|
before launching the ``on start`` code.
|
||||||
|
|
||||||
|
If a block from ``on start`` pauses, other registered events will have the opportunity to run as well.
|
@ -1,3 +1,3 @@
|
|||||||
{
|
{
|
||||||
"appref": "v0.6.36"
|
"appref": "v0.7.41"
|
||||||
}
|
}
|
||||||
|
@ -31,6 +31,7 @@ and press **A** to scroll your text.
|
|||||||
### Step 5
|
### Step 5
|
||||||
|
|
||||||
Place more blocks to display a smiley when button **B** is pressed.
|
Place more blocks to display a smiley when button **B** is pressed.
|
||||||
|
Use the dropdown to find ``B``!
|
||||||
|
|
||||||
```block
|
```block
|
||||||
input.onButtonPressed(Button.B, () => {
|
input.onButtonPressed(Button.B, () => {
|
||||||
@ -59,3 +60,15 @@ input.onGesture(Gesture.Shake, () => {
|
|||||||
`)
|
`)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Step 7
|
||||||
|
|
||||||
|
Drag more blocks to display a random number when pin ``P0`` is touched.
|
||||||
|
Hold your right thumb on the ``GND`` metal pin
|
||||||
|
at press the ``0`` pin with your right hand to trigger this event.
|
||||||
|
|
||||||
|
```block
|
||||||
|
input.onPinPressed(TouchPin.P0, () => {
|
||||||
|
basic.showNumber(Math.random(7))
|
||||||
|
})
|
||||||
|
```
|
@ -1,9 +1,9 @@
|
|||||||
{
|
{
|
||||||
"versions": {
|
"versions": {
|
||||||
"0": {
|
"0": {
|
||||||
"latest": "v0.6.45",
|
"latest": "v0.7.41",
|
||||||
"banned": [],
|
"banned": [],
|
||||||
"prompt": "v0.0.0"
|
"prompt": "v0.7.41"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,3 +1,4 @@
|
|||||||
<xml xmlns="http://www.w3.org/1999/xhtml">
|
<xml xmlns="http://www.w3.org/1999/xhtml">
|
||||||
<block type="pxt-on-start"></block>
|
<block type="pxt-on-start"></block>
|
||||||
|
<block type="device_forever"></block>
|
||||||
</xml>
|
</xml>
|
@ -21,7 +21,12 @@ namespace String_ {
|
|||||||
|
|
||||||
//%
|
//%
|
||||||
int compare(StringData *s, StringData *that) {
|
int compare(StringData *s, StringData *that) {
|
||||||
return strcmp(s->data, that->data);
|
int compareResult = strcmp(s->data, that->data);
|
||||||
|
if (compareResult < 0)
|
||||||
|
return -1;
|
||||||
|
else if (compareResult > 0)
|
||||||
|
return 1;
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//%
|
//%
|
||||||
|
@ -338,10 +338,10 @@ namespace pxt {
|
|||||||
|
|
||||||
void Segment::print()
|
void Segment::print()
|
||||||
{
|
{
|
||||||
printf("Segment: %x, length: %u, size: %u\n", data, (uint)length, (uint)size);
|
printf("Segment: %x, length: %u, size: %u\n", data, (uint32_t)length, (uint32_t)size);
|
||||||
for(uint i = 0; i < size; i++)
|
for(uint32_t i = 0; i < size; i++)
|
||||||
{
|
{
|
||||||
printf("%d ",(uint)data[i]);
|
printf("%d ",(uint32_t)data[i]);
|
||||||
}
|
}
|
||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "pxt-microbit",
|
"name": "pxt-microbit",
|
||||||
"version": "0.7.23",
|
"version": "0.7.43",
|
||||||
"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.8.13"
|
"pxt-core": "0.10.14"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,6 +28,7 @@
|
|||||||
"deployDrives": "(MICROBIT|MBED)",
|
"deployDrives": "(MICROBIT|MBED)",
|
||||||
"driveName": "MICROBIT",
|
"driveName": "MICROBIT",
|
||||||
"hexMimeType": "application/x-microbit-hex",
|
"hexMimeType": "application/x-microbit-hex",
|
||||||
|
"openocdScript": "source [find interface/cmsis-dap.cfg]; source [find target/nrf51.cfg]",
|
||||||
"upgrades": [
|
"upgrades": [
|
||||||
{
|
{
|
||||||
"type": "package",
|
"type": "package",
|
||||||
@ -72,7 +73,8 @@
|
|||||||
"logicBlocks": true,
|
"logicBlocks": true,
|
||||||
"variablesBlocks": true,
|
"variablesBlocks": true,
|
||||||
"onStartColor": "#0078D7",
|
"onStartColor": "#0078D7",
|
||||||
"onStartNamespace": "basic"
|
"onStartNamespace": "basic",
|
||||||
|
"onStartWeight": 54
|
||||||
},
|
},
|
||||||
"simulator": {
|
"simulator": {
|
||||||
"autoRun": true,
|
"autoRun": true,
|
||||||
|
@ -14,7 +14,6 @@ namespace pxsim {
|
|||||||
radioState: RadioState;
|
radioState: RadioState;
|
||||||
// TODO: not singletons
|
// TODO: not singletons
|
||||||
neopixelState: NeoPixelState;
|
neopixelState: NeoPixelState;
|
||||||
servosState: MicroServosState;
|
|
||||||
fileSystem: FileSystemState;
|
fileSystem: FileSystemState;
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
@ -53,7 +52,13 @@ namespace pxsim {
|
|||||||
0,
|
0,
|
||||||
DAL.MICROBIT_ID_IO_P19,
|
DAL.MICROBIT_ID_IO_P19,
|
||||||
DAL.MICROBIT_ID_IO_P20
|
DAL.MICROBIT_ID_IO_P20
|
||||||
]
|
],
|
||||||
|
servos: {
|
||||||
|
"P0": DAL.MICROBIT_ID_IO_P0,
|
||||||
|
"P1": DAL.MICROBIT_ID_IO_P1,
|
||||||
|
"P2": DAL.MICROBIT_ID_IO_P2,
|
||||||
|
"P3": DAL.MICROBIT_ID_IO_P3
|
||||||
|
}
|
||||||
});
|
});
|
||||||
this.builtinParts["radio"] = this.radioState = new RadioState(runtime);
|
this.builtinParts["radio"] = this.radioState = new RadioState(runtime);
|
||||||
this.builtinParts["accelerometer"] = this.accelerometerState = new AccelerometerState(runtime);
|
this.builtinParts["accelerometer"] = this.accelerometerState = new AccelerometerState(runtime);
|
||||||
@ -62,12 +67,7 @@ namespace pxsim {
|
|||||||
this.builtinParts["lightsensor"] = this.lightSensorState = new LightSensorState();
|
this.builtinParts["lightsensor"] = this.lightSensorState = new LightSensorState();
|
||||||
this.builtinParts["compass"] = this.compassState = new CompassState();
|
this.builtinParts["compass"] = this.compassState = new CompassState();
|
||||||
this.builtinParts["neopixel"] = this.neopixelState = new NeoPixelState();
|
this.builtinParts["neopixel"] = this.neopixelState = new NeoPixelState();
|
||||||
this.builtinParts["microservo"] = this.servosState = new MicroServosState({
|
this.builtinParts["microservo"] = this.edgeConnectorState;
|
||||||
"P0": DAL.MICROBIT_ID_IO_P0,
|
|
||||||
"P1": DAL.MICROBIT_ID_IO_P1,
|
|
||||||
"P2": DAL.MICROBIT_ID_IO_P2,
|
|
||||||
"P3": DAL.MICROBIT_ID_IO_P3
|
|
||||||
});
|
|
||||||
|
|
||||||
this.builtinVisuals["buttonpair"] = () => new visuals.ButtonPairView();
|
this.builtinVisuals["buttonpair"] = () => new visuals.ButtonPairView();
|
||||||
this.builtinVisuals["ledmatrix"] = () => new visuals.LedMatrixView();
|
this.builtinVisuals["ledmatrix"] = () => new visuals.LedMatrixView();
|
||||||
|
@ -76,8 +76,7 @@ namespace pxsim.pins {
|
|||||||
if (!pin) return;
|
if (!pin) return;
|
||||||
|
|
||||||
analogSetPeriod(pinId, 20000);
|
analogSetPeriod(pinId, 20000);
|
||||||
const state = board().servosState.servoState(pinId);
|
pin.servoAngle = value;
|
||||||
state.setAngle(value);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function servoSetPulse(pinId: number, micros: number) {
|
export function servoSetPulse(pinId: number, micros: number) {
|
||||||
|
@ -28,7 +28,7 @@ namespace pxsim {
|
|||||||
this.data = data;
|
this.data = data;
|
||||||
}
|
}
|
||||||
public print() {
|
public print() {
|
||||||
console.log(`Image id:${this.id} refs:${this.refcnt} size:${this.width}x${Image.height}`)
|
// console.debug(`Image id:${this.id} refs:${this.refcnt} size:${this.width}x${Image.height}`)
|
||||||
}
|
}
|
||||||
public get(x: number, y: number): number {
|
public get(x: number, y: number): number {
|
||||||
if (x < 0 || x >= this.width || y < 0 || y >= 5) return 0;
|
if (x < 0 || x >= this.width || y < 0 || y >= 5) return 0;
|
||||||
@ -228,7 +228,7 @@ namespace pxsim.basic {
|
|||||||
clearScreen();
|
clearScreen();
|
||||||
pause(interval * 5);
|
pause(interval * 5);
|
||||||
} else {
|
} else {
|
||||||
if (s.length == 1) showLeds(createImageFromString(s + " "), interval * 5)
|
if (s.length == 1) showLeds(createImageFromString(s), 0);
|
||||||
else ImageMethods.scrollImage(createImageFromString(s + " "), 1, interval);
|
else ImageMethods.scrollImage(createImageFromString(s + " "), 1, interval);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,56 +1,3 @@
|
|||||||
/*******************************
|
/*******************************
|
||||||
Site Overrides
|
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}
|
|
||||||
}
|
|
@ -1,8 +1,3 @@
|
|||||||
/*******************************
|
/*******************************
|
||||||
User Variable Overrides
|
User Variable Overrides
|
||||||
*******************************/
|
*******************************/
|
||||||
|
|
||||||
@loaderSpeed: 2s;
|
|
||||||
@loaderAngle: 5deg;
|
|
||||||
|
|
||||||
@large : 200px;
|
|
@ -29,10 +29,18 @@
|
|||||||
&:extend(.orange all);
|
&:extend(.orange all);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.ui.button.editortools-btn {
|
||||||
|
&:extend(.blue all);
|
||||||
|
}
|
||||||
|
|
||||||
#filelist, #editortools {
|
#filelist, #editortools {
|
||||||
background: #fff url(https://az742082.vo.msecnd.net/pub/psopafpj) 0 0 repeat !important;
|
background: #fff url(https://az742082.vo.msecnd.net/pub/psopafpj) 0 0 repeat !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#downloadArea {
|
||||||
|
background: transparent !important;
|
||||||
|
}
|
||||||
|
|
||||||
/*******************************
|
/*******************************
|
||||||
Blockly
|
Blockly
|
||||||
*******************************/
|
*******************************/
|
||||||
|
Reference in New Issue
Block a user