Compare commits
24 Commits
Author | SHA1 | Date | |
---|---|---|---|
2336521df1 | |||
2ce72aeb28 | |||
e746c13212 | |||
9e073aee36 | |||
3906f06a2f | |||
d89747fa46 | |||
c4e6618baa | |||
5232be58ce | |||
5a75483811 | |||
4b40585690 | |||
dd65efaab6 | |||
890c2566af | |||
cd71fc5d13 | |||
f626dd4bbb | |||
956992e9ab | |||
91ddcef6ce | |||
49fa42473f | |||
564de8863a | |||
1dd70100d6 | |||
a38ff18eaf | |||
d46ef1efca | |||
c54cd21efa | |||
94f18340ec | |||
13bdcf762d |
@ -11,9 +11,13 @@
|
||||
"dependencies": {
|
||||
"microbit": "file:../microbit"
|
||||
},
|
||||
"microbit": {
|
||||
"yotta": {
|
||||
"config": {
|
||||
"MICROBIT_BLE_ENABLED": "1"
|
||||
"microbit-dal": {
|
||||
"bluetooth": {
|
||||
"enabled": 1
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"installedVersion": "zakvul"
|
||||
|
@ -12,10 +12,14 @@
|
||||
"dependencies": {
|
||||
"microbit": "file:../microbit"
|
||||
},
|
||||
"microbit": {
|
||||
"yotta": {
|
||||
"config": {
|
||||
"MICROBIT_BLE_ENABLED": "0"
|
||||
"microbit-dal": {
|
||||
"bluetooth": {
|
||||
"enabled": 0
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"installedVersion": "rlfgis"
|
||||
}
|
||||
}
|
@ -58,7 +58,7 @@ namespace basic {
|
||||
int l = s.length();
|
||||
if (l == 0) {
|
||||
uBit.display.clear();
|
||||
uBit.sleep(interval * 5);
|
||||
fiber_sleep(interval * 5);
|
||||
} else if (l > 1) {
|
||||
uBit.display.scroll(s, interval);
|
||||
} else {
|
||||
@ -98,7 +98,7 @@ namespace basic {
|
||||
void forever_stub(void *a) {
|
||||
while (true) {
|
||||
runAction0((Action)a);
|
||||
uBit.sleep(20);
|
||||
fiber_sleep(20);
|
||||
}
|
||||
}
|
||||
|
||||
@ -123,6 +123,6 @@ namespace basic {
|
||||
//% async block="pause (ms) %pause"
|
||||
//% blockId=device_pause icon="\uf110"
|
||||
void pause(int ms) {
|
||||
uBit.sleep(ms);
|
||||
fiber_sleep(ms);
|
||||
}
|
||||
}
|
||||
|
@ -132,7 +132,7 @@ namespace control {
|
||||
//% weight=30 async help=control/reset
|
||||
//% blockId="control_reset" block="reset"
|
||||
void reset() {
|
||||
uBit.reset();
|
||||
microbit_reset();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,6 +1,7 @@
|
||||
#include "ksbit.h"
|
||||
#include <limits.h>
|
||||
|
||||
|
||||
namespace String_ {
|
||||
//%
|
||||
StringData *charAt(StringData *s, int pos) {
|
||||
@ -127,13 +128,13 @@ namespace Math_ {
|
||||
//%
|
||||
int random(int max) {
|
||||
if (max == INT_MIN)
|
||||
return -uBit.random(INT_MAX);
|
||||
return -microbit_random(INT_MAX);
|
||||
else if (max < 0)
|
||||
return -uBit.random(-max);
|
||||
return -microbit_random(-max);
|
||||
else if (max == 0)
|
||||
return 0;
|
||||
else
|
||||
return uBit.random(max);
|
||||
return microbit_random(max);
|
||||
}
|
||||
|
||||
//%
|
||||
@ -298,6 +299,6 @@ namespace pxtrt {
|
||||
//%
|
||||
void panic(int code)
|
||||
{
|
||||
uBit.panic(code);
|
||||
microbit_panic(code);
|
||||
}
|
||||
}
|
||||
|
9
libs/microbit/dal.d.ts
vendored
9
libs/microbit/dal.d.ts
vendored
@ -2,7 +2,9 @@
|
||||
declare const enum DAL {
|
||||
// built/yt/yotta_modules/microbit-dal/inc//bluetooth/ExternalEvents.h
|
||||
MICROBIT_ID_BLE = 1000,
|
||||
MICROBIT_ID_BLE_UART = 1001,
|
||||
MICROBIT_ID_BLE_UART = 1200,
|
||||
MICROBIT_BLE_EVT_CONNECTED = 1,
|
||||
MICROBIT_BLE_EVT_DISCONNECTED = 2,
|
||||
// built/yt/yotta_modules/microbit-dal/inc//bluetooth/MESEvents.h
|
||||
MES_REMOTE_CONTROL_ID = 1001,
|
||||
MES_REMOTE_CONTROL_EVT_PLAY = 1,
|
||||
@ -294,6 +296,7 @@ declare const enum DAL {
|
||||
// built/yt/yotta_modules/microbit-dal/inc//drivers/MicroBitDisplay.h
|
||||
MICROBIT_DISPLAY_EVT_ANIMATION_COMPLETE = 1,
|
||||
MICROBIT_DISPLAY_EVT_LIGHT_SENSE = 2,
|
||||
MICROBIT_DISPLAY_DEFAULT_AUTOCLEAR = 1,
|
||||
MICROBIT_DISPLAY_SPACING = 1,
|
||||
MICROBIT_DISPLAY_GREYSCALE_BIT_DEPTH = 8,
|
||||
MICROBIT_DISPLAY_ANIMATE_DEFAULT_POS = -255,
|
||||
@ -303,7 +306,8 @@ declare const enum DAL {
|
||||
ANIMATION_MODE_PRINT_TEXT = 3,
|
||||
ANIMATION_MODE_SCROLL_IMAGE = 4,
|
||||
ANIMATION_MODE_ANIMATE_IMAGE = 5,
|
||||
ANIMATION_MODE_PRINT_CHARACTER = 6,
|
||||
ANIMATION_MODE_ANIMATE_IMAGE_WITH_CLEAR = 6,
|
||||
ANIMATION_MODE_PRINT_CHARACTER = 7,
|
||||
DISPLAY_MODE_BLACK_AND_WHITE = 0,
|
||||
DISPLAY_MODE_GREYSCALE = 1,
|
||||
DISPLAY_MODE_BLACK_AND_WHITE_LIGHT_SENSE = 2,
|
||||
@ -384,6 +388,7 @@ declare const enum DAL {
|
||||
MICROBIT_THERMOMETER_PERIOD = 1000,
|
||||
MICROBIT_THERMOMETER_EVT_UPDATE = 1,
|
||||
MICROBIT_THERMOMETER_ADDED_TO_IDLE = 2,
|
||||
// built/yt/yotta_modules/microbit-dal/inc//platform/yotta_cfg_mappings.h
|
||||
// built/yt/yotta_modules/microbit-dal/inc//types/ManagedString.h
|
||||
// built/yt/yotta_modules/microbit-dal/inc//types/ManagedType.h
|
||||
// built/yt/yotta_modules/microbit-dal/inc//types/Matrix4.h
|
||||
|
@ -247,7 +247,7 @@ namespace input {
|
||||
//% help=input/running-time weight=50
|
||||
//% blockId=device_get_running_time block="running time (ms)" icon="\uf017"
|
||||
int runningTime() {
|
||||
return uBit.systemTime();
|
||||
return system_timer_current_time();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -4,18 +4,33 @@
|
||||
//% color=3 weight=35
|
||||
namespace led {
|
||||
|
||||
// what's the current high value
|
||||
let barGraphHigh = 0;
|
||||
// when was the current high value recorded
|
||||
let barGraphHighLast = 0;
|
||||
|
||||
/**
|
||||
* Displays a vertical bar graph based on the ``value`` and ``high`` value.
|
||||
* Displays a vertical bar graph based on the `value` and `high` value.
|
||||
* If `high` is 0, the chart gets adjusted automatically.
|
||||
* @param value current value to plot
|
||||
* @param high maximum value, eg: 1023, 255
|
||||
* @param high maximum value. If 0, maximum value adjusted automatically, eg: 0
|
||||
*/
|
||||
//% help=/led/plot-bar-graph weight=20
|
||||
//% blockId=device_plot_bar_graph block="plot bar graph of %value |up to %high" icon="\uf080" blockExternalInputs=true
|
||||
export function plotBarGraph(value: number, high: number): void {
|
||||
|
||||
export function plotBarGraph(value: number, high: number): void {
|
||||
let now = input.runningTime();
|
||||
serial.writeString(value.toString() + "\r\n");
|
||||
value = Math.abs(value);
|
||||
|
||||
let v = Math.abs((value * 15) / high);
|
||||
if (high != 0) barGraphHigh = high;
|
||||
else if (value > barGraphHigh || now - barGraphHighLast > 5000) {
|
||||
barGraphHigh = value;
|
||||
barGraphHighLast = now;
|
||||
}
|
||||
|
||||
barGraphHigh = Math.max(barGraphHigh, 16);
|
||||
|
||||
let v = (value * 15) / barGraphHigh;
|
||||
let k = 0;
|
||||
for(let y = 4; y >= 0; --y) {
|
||||
for (let x = 0; x < 3; ++x) {
|
||||
|
@ -180,8 +180,9 @@ namespace pins {
|
||||
}
|
||||
|
||||
if (ms > 0) {
|
||||
uBit.sleep(ms);
|
||||
fiber_sleep(ms);
|
||||
pitchPin->setAnalogValue(0);
|
||||
// TODO why do we use wait_ms() here? it's a busy wait I think
|
||||
wait_ms(5);
|
||||
}
|
||||
}
|
||||
|
@ -31,9 +31,13 @@
|
||||
],
|
||||
"public": true,
|
||||
"dependencies": {},
|
||||
"microbit": {
|
||||
"yotta": {
|
||||
"config": {
|
||||
"MESSAGE_BUS_LISTENER_DEFAULT_FLAGS": "MESSAGE_BUS_LISTENER_QUEUE_IF_BUSY"
|
||||
"microbit-dal": {
|
||||
"bluetooth": {
|
||||
"enabled": 0
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ namespace serial {
|
||||
* Prints a line of text to the serial
|
||||
* @param value to send over serial
|
||||
*/
|
||||
//% help=/serial/write-line
|
||||
//% help=serial/write-line
|
||||
//% blockId=serial_writeline block="serial|write %text"
|
||||
export function writeLine(text: string): void {
|
||||
writeString(text);
|
||||
@ -27,7 +27,7 @@ namespace serial {
|
||||
* @param value to write
|
||||
*/
|
||||
//% weight=80
|
||||
//% help=/serial/write-value
|
||||
//% help=serial/write-value
|
||||
//% blockId=serial_writevalue block="serial|write %name|= %value"
|
||||
export function writeValue(name: string, value: number): void {
|
||||
writeString(name);
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "pxt-microbit",
|
||||
"version": "0.2.78",
|
||||
"version": "0.2.86",
|
||||
"description": "BBC micro:bit target for PXT",
|
||||
"keywords": [
|
||||
"JavaScript",
|
||||
@ -29,6 +29,6 @@
|
||||
"typescript": "^1.8.7"
|
||||
},
|
||||
"dependencies": {
|
||||
"pxt-core": "0.2.82"
|
||||
"pxt-core": "0.2.93"
|
||||
}
|
||||
}
|
||||
|
@ -56,11 +56,14 @@
|
||||
"hasHex": true,
|
||||
"deployDrives": "^MICROBIT"
|
||||
},
|
||||
"runtime": {
|
||||
"mathBlocks": true
|
||||
},
|
||||
"simulator": {
|
||||
"autoRun": true
|
||||
},
|
||||
"compileService": {
|
||||
"gittag": "v0.1.7",
|
||||
"gittag": "v0.1.8",
|
||||
"serviceId": "ws"
|
||||
},
|
||||
"serial": {
|
||||
|
@ -5,10 +5,20 @@
|
||||
<meta charset="utf-8">
|
||||
<title>microbit simulator</title>
|
||||
<style>
|
||||
body {
|
||||
background: transparent;
|
||||
overflow: hidden;
|
||||
}
|
||||
html {
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
body {
|
||||
height: 100%;
|
||||
padding: 0;
|
||||
overflow: hidden;
|
||||
margin: 0;
|
||||
-webkit-overflow-scrolling: touch;
|
||||
overflow-scrolling: touch;
|
||||
}
|
||||
</style>
|
||||
<script src="/cdn/bluebird.min.js"></script>
|
||||
<script src="/cdn/pxtsim.js"></script>
|
||||
|
@ -219,7 +219,7 @@ namespace pxsim.micro_bit {
|
||||
rx:5, ry:5,
|
||||
fill:`url(#${gid})`
|
||||
});
|
||||
this.thermometerText = Svg.child(this.g, "text", { class:'sim-text', x:60, y:130}) as SVGTextElement;
|
||||
this.thermometerText = Svg.child(this.g, "text", { class:'sim-text', x:58, y:130}) as SVGTextElement;
|
||||
this.updateTheme();
|
||||
|
||||
let pt = this.element.createSVGPoint();
|
||||
|
Reference in New Issue
Block a user