Compare commits
62 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3bf6f9a2ae | ||
|
|
74f38d41a3 | ||
|
|
34af44d299 | ||
|
|
1199845c52 | ||
|
|
003150643d | ||
|
|
500de7fb13 | ||
|
|
88934881f9 | ||
|
|
433e8c8805 | ||
|
|
b8b7d3d1b8 | ||
|
|
052cca94a2 | ||
|
|
93dd793fb7 | ||
|
|
41c2012d42 | ||
|
|
d4934b19d1 | ||
|
|
4f741981e3 | ||
|
|
e93ae5e01b | ||
|
|
baee733aad | ||
|
|
13f252c6f4 | ||
|
|
694c24406f | ||
|
|
2250aa9d4b | ||
|
|
a1f1911eb0 | ||
|
|
a5f8e9a643 | ||
|
|
5a6cbf2639 | ||
|
|
ff11e70c84 | ||
|
|
a6487f62c0 | ||
|
|
63047454cb | ||
|
|
1373c2616c | ||
|
|
739584e465 | ||
|
|
73e5263a0a | ||
|
|
9c24e5f87f | ||
|
|
34d27f5d58 | ||
|
|
df0acab002 | ||
|
|
b48dcd9afa | ||
|
|
40666cf457 | ||
|
|
44dd7465d4 | ||
|
|
90fe68943e | ||
|
|
aa6b6daf45 | ||
|
|
3fc7888aab | ||
|
|
25c3a60166 | ||
|
|
0e125f75bc | ||
|
|
8e7e405e8d | ||
|
|
67ea86b33e | ||
|
|
14d7c0920b | ||
|
|
4718f1b4ae | ||
|
|
4107b920f3 | ||
|
|
76cf451ebc | ||
|
|
79d810c7da | ||
|
|
a7c81358aa | ||
|
|
879615dcc1 | ||
|
|
5c02964085 | ||
|
|
832f340feb | ||
|
|
08c89d0743 | ||
|
|
21addf843c | ||
|
|
499bd198cd | ||
|
|
213c52dd00 | ||
|
|
8e6917d677 | ||
|
|
712782dfd3 | ||
|
|
436e376de9 | ||
|
|
c84a90c4a5 | ||
|
|
7f1a7dfa1e | ||
|
|
56961552bc | ||
|
|
99fe19953f | ||
|
|
adc27cc80e |
15
README.md
@@ -1,9 +1,16 @@
|
|||||||
# Calliope target for PXT
|
# Calliope target for Microsoft MakeCode
|
||||||
|
|
||||||
This target allow to program a [Calliope](http://calliope.cc/) using
|
This target is hosted at https://makecode.calliope.cc.
|
||||||
PXT ([Microsoft Programming Experience Toolkit](https://github.com/Microsoft/pxt)).
|
|
||||||
|
|
||||||
[](https://travis-ci.org/Microsoft/pxt-calliope)
|
## Hosted editor and build
|
||||||
|
|
||||||
|
Jenkins build: https://ci2.dot.net/job/Private/job/pxt_project_teal/job/master/
|
||||||
|
|
||||||
|
|
||||||
|
### BUILD COMMENTS
|
||||||
|
|
||||||
|
- build libs/core/dal.d.ts new requires some meddling, as the `#define` parser does not parse `#ifdef` and thus
|
||||||
|
has some conflicts with double defines constants
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
{
|
{
|
||||||
"appref": "v0.8.30"
|
"appref": "v"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,10 +2,17 @@ import jobs.generation.Utilities;
|
|||||||
import jobs.generation.InternalUtilities;
|
import jobs.generation.InternalUtilities;
|
||||||
|
|
||||||
def project = GithubProject
|
def project = GithubProject
|
||||||
def branch = GithubBranchName
|
def projectName = "pxt-calliopemini"
|
||||||
|
|
||||||
[true, false].each { isPR ->
|
[true, false].each { isPR ->
|
||||||
def newJobName = InternalUtilities.getFullJobName(project, "Default", isPR)
|
def newJobName = projectName
|
||||||
|
|
||||||
|
if (isPR) {
|
||||||
|
newJobName += "_PR"
|
||||||
|
} else {
|
||||||
|
newJobName += "_Push"
|
||||||
|
}
|
||||||
|
|
||||||
def newJob = job(newJobName) {
|
def newJob = job(newJobName) {
|
||||||
steps {
|
steps {
|
||||||
shell("chmod +x ./jenkins.sh")
|
shell("chmod +x ./jenkins.sh")
|
||||||
@@ -15,14 +22,15 @@ def branch = GithubBranchName
|
|||||||
if (!isPR) {
|
if (!isPR) {
|
||||||
wrappers {
|
wrappers {
|
||||||
credentialsBinding {
|
credentialsBinding {
|
||||||
string('PXT_ACCESS_TOKEN', 'pxt_access_token')
|
string("PXT_ACCESS_TOKEN", "pxt_access_token")
|
||||||
string('PXT_RELEASE_REPO', 'pxt_release_repo_calliope')
|
string("PXT_RELEASE_REPO", "pxt_release_repo_calliopemini")
|
||||||
|
string("CROWDIN_KEY", "pxt_crowdin_key")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Utilities.setMachineAffinity(newJob, 'Ubuntu', '20161020')
|
Utilities.setMachineAffinity(newJob, "Ubuntu", "20161020")
|
||||||
InternalUtilities.standardJobSetup(newJob, project, isPR, "*/*")
|
InternalUtilities.standardJobSetup(newJob, project, isPR, "*/*")
|
||||||
|
|
||||||
if (isPR) {
|
if (isPR) {
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ echo isPR: $1
|
|||||||
|
|
||||||
originRegex="^origin/.*"
|
originRegex="^origin/.*"
|
||||||
branchRegex="^origin/\K.*(?=$)"
|
branchRegex="^origin/\K.*(?=$)"
|
||||||
|
releaseBranchRegex="^(master|v\d+)$"
|
||||||
|
|
||||||
if [[ "$GIT_BRANCH" =~ $originRegex ]]; then
|
if [[ "$GIT_BRANCH" =~ $originRegex ]]; then
|
||||||
branchName=$(echo ${GIT_BRANCH} | grep -oP $branchRegex)
|
branchName=$(echo ${GIT_BRANCH} | grep -oP $branchRegex)
|
||||||
@@ -27,9 +28,9 @@ if [ "$1" == "false" ]; then
|
|||||||
echo Setting TRAVIS_PULL_REQUEST to false
|
echo Setting TRAVIS_PULL_REQUEST to false
|
||||||
export TRAVIS_PULL_REQUEST=false
|
export TRAVIS_PULL_REQUEST=false
|
||||||
|
|
||||||
if [ $TRAVIS_BRANCH == "master" ]; then
|
if [[ "$TRAVIS_BRANCH" =~ $releaseBranchRegex ]]; then
|
||||||
if [[ -z $PXT_RELEASE_REPO ]]; then
|
if [[ -z $PXT_RELEASE_REPO ]]; then
|
||||||
echo Cannot find release repo; skipping tag checks
|
echo Cannot find release repo\; skipping tag checks
|
||||||
else
|
else
|
||||||
gitTag=$(git describe --tags --exact-match 2> /dev/null)
|
gitTag=$(git describe --tags --exact-match 2> /dev/null)
|
||||||
builtTag=$(git ls-remote --tags $PXT_RELEASE_REPO | grep -o "refs/tags/$gitTag$")
|
builtTag=$(git ls-remote --tags $PXT_RELEASE_REPO | grep -o "refs/tags/$gitTag$")
|
||||||
@@ -38,7 +39,7 @@ if [ "$1" == "false" ]; then
|
|||||||
echo Built tag: $builtTag
|
echo Built tag: $builtTag
|
||||||
|
|
||||||
if [[ ! -z $gitTag && -z $builtTag ]]; then
|
if [[ ! -z $gitTag && -z $builtTag ]]; then
|
||||||
echo Built tag not found; building tag
|
echo Built tag not found\; building tag
|
||||||
echo Setting TRAVIS_BRANCH to $gitTag
|
echo Setting TRAVIS_BRANCH to $gitTag
|
||||||
export TRAVIS_BRANCH=$gitTag
|
export TRAVIS_BRANCH=$gitTag
|
||||||
echo Setting TRAVIS_TAG to $gitTag
|
echo Setting TRAVIS_TAG to $gitTag
|
||||||
|
|||||||
@@ -1,9 +1,26 @@
|
|||||||
{
|
{
|
||||||
"bluetooth": "Support for additional Bluetooth services.\n\nSupport for additional Bluetooth services.",
|
"bluetooth": "Support for additional Bluetooth services.\n\nSupport for additional Bluetooth services.",
|
||||||
|
"bluetooth.advertiseUid": "Advertise an Eddystone UID",
|
||||||
|
"bluetooth.advertiseUidBuffer": "Advertise an Eddystone UID",
|
||||||
|
"bluetooth.advertiseUidBuffer|param|connectable": "true to keep bluetooth connectable for other services, false otherwise.",
|
||||||
|
"bluetooth.advertiseUidBuffer|param|nsAndInstance": "16 bytes buffer of namespace (bytes 0-9) and instance (bytes 10-15)",
|
||||||
|
"bluetooth.advertiseUidBuffer|param|power": "power level between 0 and 7, eg: 7",
|
||||||
|
"bluetooth.advertiseUid|param|connectable": "true to keep bluetooth connectable for other services, false otherwise.",
|
||||||
|
"bluetooth.advertiseUid|param|instance": "4 last bytes of the instance uid",
|
||||||
|
"bluetooth.advertiseUid|param|ns": "4 last bytes of the namespace uid",
|
||||||
|
"bluetooth.advertiseUid|param|power": "power level between 0 and 7, eg: 7",
|
||||||
|
"bluetooth.advertiseUrl": "Advertise an Eddystone URL",
|
||||||
|
"bluetooth.advertiseUrl|param|connectable": "true to keep bluetooth connectable for other services, false otherwise.",
|
||||||
|
"bluetooth.advertiseUrl|param|power": "power level between 0 and 7, eg: 7",
|
||||||
|
"bluetooth.advertiseUrl|param|url": "the url to transmit. Must be no longer than the supported eddystone url length, eg: \"https://makecode.com\"",
|
||||||
"bluetooth.onBluetoothConnected": "Register code to run when the micro:bit is connected to over Bluetooth",
|
"bluetooth.onBluetoothConnected": "Register code to run when the micro:bit is connected to over Bluetooth",
|
||||||
"bluetooth.onBluetoothConnected|param|body": "Code to run when a Bluetooth connection is established",
|
"bluetooth.onBluetoothConnected|param|body": "Code to run when a Bluetooth connection is established",
|
||||||
"bluetooth.onBluetoothDisconnected": "Register code to run when a bluetooth connection to the micro:bit is lost",
|
"bluetooth.onBluetoothDisconnected": "Register code to run when a bluetooth connection to the micro:bit is lost",
|
||||||
"bluetooth.onBluetoothDisconnected|param|body": "Code to run when a Bluetooth connection is lost",
|
"bluetooth.onBluetoothDisconnected|param|body": "Code to run when a Bluetooth connection is lost",
|
||||||
|
"bluetooth.onUartDataReceived": "Registers an event to be fired when one of the delimiter is matched.",
|
||||||
|
"bluetooth.onUartDataReceived|param|delimiters": "the characters to match received characters against.",
|
||||||
|
"bluetooth.setTransmitPower": "Sets the bluetooth transmit power between 0 (minimal) and 7 (maximum).",
|
||||||
|
"bluetooth.setTransmitPower|param|power": "power level between 0 (minimal) and 7 (maximum), eg: 7.",
|
||||||
"bluetooth.startAccelerometerService": "Starts the Bluetooth accelerometer service",
|
"bluetooth.startAccelerometerService": "Starts the Bluetooth accelerometer service",
|
||||||
"bluetooth.startButtonService": "Starts the Bluetooth button service",
|
"bluetooth.startButtonService": "Starts the Bluetooth button service",
|
||||||
"bluetooth.startIOPinService": "Starts the Bluetooth IO pin service.",
|
"bluetooth.startIOPinService": "Starts the Bluetooth IO pin service.",
|
||||||
@@ -11,6 +28,7 @@
|
|||||||
"bluetooth.startMagnetometerService": "Starts the Bluetooth magnetometer service",
|
"bluetooth.startMagnetometerService": "Starts the Bluetooth magnetometer service",
|
||||||
"bluetooth.startTemperatureService": "Starts the Bluetooth temperature service",
|
"bluetooth.startTemperatureService": "Starts the Bluetooth temperature service",
|
||||||
"bluetooth.startUartService": "Starts the Bluetooth UART service",
|
"bluetooth.startUartService": "Starts the Bluetooth UART service",
|
||||||
|
"bluetooth.stopAdvertising": "Stops advertising Eddystone end points",
|
||||||
"bluetooth.uartReadUntil": "Reads from the Bluetooth UART service buffer, returning its contents when the specified delimiter character is encountered.",
|
"bluetooth.uartReadUntil": "Reads from the Bluetooth UART service buffer, returning its contents when the specified delimiter character is encountered.",
|
||||||
"bluetooth.uartWriteNumber": "Prints a numeric value to the serial",
|
"bluetooth.uartWriteNumber": "Prints a numeric value to the serial",
|
||||||
"bluetooth.uartWriteString": "Writes to the Bluetooth UART service buffer. From there the data is transmitted over Bluetooth to a connected device.",
|
"bluetooth.uartWriteString": "Writes to the Bluetooth UART service buffer. From there the data is transmitted over Bluetooth to a connected device.",
|
||||||
|
|||||||
@@ -1,6 +1,10 @@
|
|||||||
{
|
{
|
||||||
|
"bluetooth.advertiseUid|block": "bluetooth advertise UID|namespace (bytes 6-9)%ns|instance (bytes 2-6)%instance|with power %power|connectable %connectable",
|
||||||
|
"bluetooth.advertiseUrl|block": "bluetooth advertise url %url|with power %power|connectable %connectable",
|
||||||
"bluetooth.onBluetoothConnected|block": "on bluetooth connected",
|
"bluetooth.onBluetoothConnected|block": "on bluetooth connected",
|
||||||
"bluetooth.onBluetoothDisconnected|block": "on bluetooth disconnected",
|
"bluetooth.onBluetoothDisconnected|block": "on bluetooth disconnected",
|
||||||
|
"bluetooth.onUartDataReceived|block": "bluetooth|on data received %delimiters=serial_delimiter_conv",
|
||||||
|
"bluetooth.setTransmitPower|block": "bluetooth set transmit power %power",
|
||||||
"bluetooth.startAccelerometerService|block": "bluetooth accelerometer service",
|
"bluetooth.startAccelerometerService|block": "bluetooth accelerometer service",
|
||||||
"bluetooth.startButtonService|block": "bluetooth button service",
|
"bluetooth.startButtonService|block": "bluetooth button service",
|
||||||
"bluetooth.startIOPinService|block": "bluetooth io pin service",
|
"bluetooth.startIOPinService|block": "bluetooth io pin service",
|
||||||
@@ -8,6 +12,7 @@
|
|||||||
"bluetooth.startMagnetometerService|block": "bluetooth magnetometer service",
|
"bluetooth.startMagnetometerService|block": "bluetooth magnetometer service",
|
||||||
"bluetooth.startTemperatureService|block": "bluetooth temperature service",
|
"bluetooth.startTemperatureService|block": "bluetooth temperature service",
|
||||||
"bluetooth.startUartService|block": "bluetooth uart service",
|
"bluetooth.startUartService|block": "bluetooth uart service",
|
||||||
|
"bluetooth.stopAdvertising|block": "bluetooth stop advertising",
|
||||||
"bluetooth.uartReadUntil|block": "bluetooth uart|read until %del=serial_delimiter_conv",
|
"bluetooth.uartReadUntil|block": "bluetooth uart|read until %del=serial_delimiter_conv",
|
||||||
"bluetooth.uartWriteNumber|block": "bluetooth uart|write number %value",
|
"bluetooth.uartWriteNumber|block": "bluetooth uart|write number %value",
|
||||||
"bluetooth.uartWriteString|block": "bluetooth uart|write string %data",
|
"bluetooth.uartWriteString|block": "bluetooth uart|write string %data",
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ using namespace pxt;
|
|||||||
/**
|
/**
|
||||||
* Support for additional Bluetooth services.
|
* Support for additional Bluetooth services.
|
||||||
*/
|
*/
|
||||||
//% color=#0082FB weight=20
|
//% color=#0082FB weight=96 icon="\uf294"
|
||||||
namespace bluetooth {
|
namespace bluetooth {
|
||||||
MicroBitUARTService *uart = NULL;
|
MicroBitUARTService *uart = NULL;
|
||||||
|
|
||||||
@@ -99,6 +99,18 @@ namespace bluetooth {
|
|||||||
return uart->readUntil(ManagedString(del)).leakData();
|
return uart->readUntil(ManagedString(del)).leakData();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Registers an event to be fired when one of the delimiter is matched.
|
||||||
|
* @param delimiters the characters to match received characters against.
|
||||||
|
*/
|
||||||
|
//% help=bluetooth/on-uart-data-received
|
||||||
|
//% weight=18 blockId=bluetooth_on_data_received block="bluetooth|on data received %delimiters=serial_delimiter_conv"
|
||||||
|
void onUartDataReceived(StringData* delimiters, Action body) {
|
||||||
|
startUartService();
|
||||||
|
uart->eventOn(ManagedString(delimiters));
|
||||||
|
registerWithDal(MICROBIT_ID_BLE_UART, MICROBIT_UART_S_EVT_DELIM_MATCH, body);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register code to run when the micro:bit is connected to over Bluetooth
|
* Register code to run when the micro:bit is connected to over Bluetooth
|
||||||
* @param body Code to run when a Bluetooth connection is established
|
* @param body Code to run when a Bluetooth connection is established
|
||||||
@@ -120,4 +132,59 @@ namespace bluetooth {
|
|||||||
void onBluetoothDisconnected(Action body) {
|
void onBluetoothDisconnected(Action body) {
|
||||||
registerWithDal(MICROBIT_ID_BLE, MICROBIT_BLE_EVT_DISCONNECTED, body);
|
registerWithDal(MICROBIT_ID_BLE, MICROBIT_BLE_EVT_DISCONNECTED, body);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const int8_t CALIBRATED_POWERS[] = {-49, -37, -33, -28, -25, -20, -15, -10};
|
||||||
|
/**
|
||||||
|
* Advertise an Eddystone URL
|
||||||
|
* @param url the url to transmit. Must be no longer than the supported eddystone url length, eg: "https://makecode.com"
|
||||||
|
* @param power power level between 0 and 7, eg: 7
|
||||||
|
* @param connectable true to keep bluetooth connectable for other services, false otherwise.
|
||||||
|
*/
|
||||||
|
//% blockId=eddystone_advertise_url block="bluetooth advertise url %url|with power %power|connectable %connectable"
|
||||||
|
//% parts=bluetooth weight=11 blockGap=8
|
||||||
|
//% help=bluetooth/advertise-url blockExternalInputs=1
|
||||||
|
void advertiseUrl(StringData* url, int power, bool connectable) {
|
||||||
|
power = min(MICROBIT_BLE_POWER_LEVELS-1, max(0, power));
|
||||||
|
int8_t level = CALIBRATED_POWERS[power];
|
||||||
|
uBit.bleManager.advertiseEddystoneUrl(ManagedString(url), level, connectable);
|
||||||
|
uBit.bleManager.setTransmitPower(power);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Advertise an Eddystone UID
|
||||||
|
* @param nsAndInstance 16 bytes buffer of namespace (bytes 0-9) and instance (bytes 10-15)
|
||||||
|
* @param power power level between 0 and 7, eg: 7
|
||||||
|
* @param connectable true to keep bluetooth connectable for other services, false otherwise.
|
||||||
|
*/
|
||||||
|
//% parts=bluetooth weight=12 advanced=true
|
||||||
|
void advertiseUidBuffer(Buffer nsAndInstance, int power, bool connectable) {
|
||||||
|
ManagedBuffer buf(nsAndInstance);
|
||||||
|
if (buf.length() != 16) return;
|
||||||
|
|
||||||
|
power = min(MICROBIT_BLE_POWER_LEVELS-1, max(0, power));
|
||||||
|
int8_t level = CALIBRATED_POWERS[power];
|
||||||
|
uint8_t uidNs[10]; buf.readBytes(uidNs, 0, 10);
|
||||||
|
uint8_t uidInst[6]; buf.readBytes(uidInst, 10, 6);
|
||||||
|
uBit.bleManager.advertiseEddystoneUid((const char*)uidNs, (const char*)uidInst, level, connectable);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the bluetooth transmit power between 0 (minimal) and 7 (maximum).
|
||||||
|
* @param power power level between 0 (minimal) and 7 (maximum), eg: 7.
|
||||||
|
*/
|
||||||
|
//% parts=bluetooth weight=5 help=bluetooth/set-transmit-power advanced=true
|
||||||
|
//% blockId=bluetooth_settransmitpower block="bluetooth set transmit power %power"
|
||||||
|
void setTransmitPower(int power) {
|
||||||
|
uBit.bleManager.setTransmitPower(min(MICROBIT_BLE_POWER_LEVELS-1, max(0, power)));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stops advertising Eddystone end points
|
||||||
|
*/
|
||||||
|
//% blockId=eddystone_stop_advertising block="bluetooth stop advertising"
|
||||||
|
//% parts=bluetooth weight=10
|
||||||
|
//% help=bluetooth/stop-advertising advanced=true
|
||||||
|
void stopAdvertising() {
|
||||||
|
uBit.bleManager.stopAdvertising();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
/**
|
/**
|
||||||
* Support for additional Bluetooth services.
|
* Support for additional Bluetooth services.
|
||||||
*/
|
*/
|
||||||
//% color=#0082FB weight=20 icon="\uf294"
|
//% color=#0082FB weight=96 icon="\uf294"
|
||||||
namespace bluetooth {
|
namespace bluetooth {
|
||||||
/**
|
/**
|
||||||
* Writes to the Bluetooth UART service buffer. From there the data is transmitted over Bluetooth to a connected device.
|
* Writes to the Bluetooth UART service buffer. From there the data is transmitted over Bluetooth to a connected device.
|
||||||
@@ -46,4 +46,21 @@ namespace bluetooth {
|
|||||||
// dummy implementation for simulator
|
// dummy implementation for simulator
|
||||||
return "???"
|
return "???"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Advertise an Eddystone UID
|
||||||
|
* @param ns 4 last bytes of the namespace uid
|
||||||
|
* @param instance 4 last bytes of the instance uid
|
||||||
|
* @param power power level between 0 and 7, eg: 7
|
||||||
|
* @param connectable true to keep bluetooth connectable for other services, false otherwise.
|
||||||
|
*/
|
||||||
|
//% blockId=eddystone_advertise_uid block="bluetooth advertise UID|namespace (bytes 6-9)%ns|instance (bytes 2-6)%instance|with power %power|connectable %connectable"
|
||||||
|
//% parts=bluetooth weight=12 blockGap=8
|
||||||
|
//% help=bluetooth/advertise-uid blockExternalInputs=1
|
||||||
|
export function advertiseUid(ns: number, instance: number, power: number, connectable: boolean) {
|
||||||
|
const buf = pins.createBuffer(16);
|
||||||
|
buf.setNumber(NumberFormat.Int32BE, 6, ns);
|
||||||
|
buf.setNumber(NumberFormat.Int32BE, 12, instance);
|
||||||
|
bluetooth.advertiseUidBuffer(buf, power, connectable);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,20 +17,56 @@
|
|||||||
"config": {
|
"config": {
|
||||||
"microbit-dal": {
|
"microbit-dal": {
|
||||||
"bluetooth": {
|
"bluetooth": {
|
||||||
"enabled": 1,
|
"enabled": 1
|
||||||
"pairing_mode": 1,
|
}
|
||||||
"private_addressing": 0,
|
}
|
||||||
"open": 0,
|
},
|
||||||
"whitelist": 1,
|
"optionalConfig": {
|
||||||
"advertising_timeout": 0,
|
"microbit-dal": {
|
||||||
"tx_power": 6,
|
|
||||||
"dfu_service": 1,
|
|
||||||
"event_service": 1,
|
|
||||||
"device_info_service": 1
|
|
||||||
},
|
|
||||||
"gatt_table_size": "0x700"
|
"gatt_table_size": "0x700"
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
"userConfigs": [
|
||||||
|
{
|
||||||
|
"description": "No Pairing Required: Anyone can connect via Bluetooth.",
|
||||||
|
"config": {
|
||||||
|
"microbit-dal": {
|
||||||
|
"bluetooth": {
|
||||||
|
"open": 1,
|
||||||
|
"pairing_mode": 0,
|
||||||
|
"whitelist": 0,
|
||||||
|
"security_level": null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"description": "JustWorks pairing (default): Pairing is automatic once the pairing is initiated.",
|
||||||
|
"config": {
|
||||||
|
"microbit-dal": {
|
||||||
|
"bluetooth": {
|
||||||
|
"open": null,
|
||||||
|
"pairing_mode": null,
|
||||||
|
"whitelist": null,
|
||||||
|
"security_level": null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"description": "Passkey pairing: Pairing requires 6 digit key to pair.",
|
||||||
|
"config": {
|
||||||
|
"microbit-dal": {
|
||||||
|
"bluetooth": {
|
||||||
|
"open": 0,
|
||||||
|
"pairing_mode": 1,
|
||||||
|
"whitelist": 1,
|
||||||
|
"security_level": "SECURITY_MODE_ENCRYPTION_WITH_MITM"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"installedVersion": "vzlhfd"
|
"installedVersion": "vzlhfd"
|
||||||
}
|
}
|
||||||
46
libs/bluetooth/shims.d.ts
vendored
@@ -4,7 +4,7 @@
|
|||||||
/**
|
/**
|
||||||
* Support for additional Bluetooth services.
|
* Support for additional Bluetooth services.
|
||||||
*/
|
*/
|
||||||
//% color=#0082FB weight=20
|
//% color=#0082FB weight=96 icon="\uf294"
|
||||||
declare namespace bluetooth {
|
declare namespace bluetooth {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -63,6 +63,14 @@ declare namespace bluetooth {
|
|||||||
//% parts="bluetooth" advanced=true shim=bluetooth::startUartService
|
//% parts="bluetooth" advanced=true shim=bluetooth::startUartService
|
||||||
function startUartService(): void;
|
function startUartService(): void;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Registers an event to be fired when one of the delimiter is matched.
|
||||||
|
* @param delimiters the characters to match received characters against.
|
||||||
|
*/
|
||||||
|
//% help=bluetooth/on-uart-data-received
|
||||||
|
//% weight=18 blockId=bluetooth_on_data_received block="bluetooth|on data received %delimiters=serial_delimiter_conv" shim=bluetooth::onUartDataReceived
|
||||||
|
function onUartDataReceived(delimiters: string, body: () => void): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register code to run when the micro:bit is connected to over Bluetooth
|
* Register code to run when the micro:bit is connected to over Bluetooth
|
||||||
* @param body Code to run when a Bluetooth connection is established
|
* @param body Code to run when a Bluetooth connection is established
|
||||||
@@ -80,6 +88,42 @@ declare namespace bluetooth {
|
|||||||
//% blockId=bluetooth_on_disconnected block="on bluetooth disconnected"
|
//% blockId=bluetooth_on_disconnected block="on bluetooth disconnected"
|
||||||
//% parts="bluetooth" shim=bluetooth::onBluetoothDisconnected
|
//% parts="bluetooth" shim=bluetooth::onBluetoothDisconnected
|
||||||
function onBluetoothDisconnected(body: () => void): void;
|
function onBluetoothDisconnected(body: () => void): void;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Advertise an Eddystone URL
|
||||||
|
* @param url the url to transmit. Must be no longer than the supported eddystone url length, eg: "https://makecode.com"
|
||||||
|
* @param power power level between 0 and 7, eg: 7
|
||||||
|
* @param connectable true to keep bluetooth connectable for other services, false otherwise.
|
||||||
|
*/
|
||||||
|
//% blockId=eddystone_advertise_url block="bluetooth advertise url %url|with power %power|connectable %connectable"
|
||||||
|
//% parts=bluetooth weight=11 blockGap=8
|
||||||
|
//% help=bluetooth/advertise-url blockExternalInputs=1 shim=bluetooth::advertiseUrl
|
||||||
|
function advertiseUrl(url: string, power: number, connectable: boolean): void;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Advertise an Eddystone UID
|
||||||
|
* @param nsAndInstance 16 bytes buffer of namespace (bytes 0-9) and instance (bytes 10-15)
|
||||||
|
* @param power power level between 0 and 7, eg: 7
|
||||||
|
* @param connectable true to keep bluetooth connectable for other services, false otherwise.
|
||||||
|
*/
|
||||||
|
//% parts=bluetooth weight=12 advanced=true shim=bluetooth::advertiseUidBuffer
|
||||||
|
function advertiseUidBuffer(nsAndInstance: Buffer, power: number, connectable: boolean): void;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the bluetooth transmit power between 0 (minimal) and 7 (maximum).
|
||||||
|
* @param power power level between 0 (minimal) and 7 (maximum), eg: 7.
|
||||||
|
*/
|
||||||
|
//% parts=bluetooth weight=5 help=bluetooth/set-transmit-power advanced=true
|
||||||
|
//% blockId=bluetooth_settransmitpower block="bluetooth set transmit power %power" shim=bluetooth::setTransmitPower
|
||||||
|
function setTransmitPower(power: number): void;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stops advertising Eddystone end points
|
||||||
|
*/
|
||||||
|
//% blockId=eddystone_stop_advertising block="bluetooth stop advertising"
|
||||||
|
//% parts=bluetooth weight=10
|
||||||
|
//% help=bluetooth/stop-advertising advanced=true shim=bluetooth::stopAdvertising
|
||||||
|
function stopAdvertising(): void;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Auto-generated. Do not edit. Really.
|
// Auto-generated. Do not edit. Really.
|
||||||
|
|||||||
23
libs/calliope-i2c/i2c.ts
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
import rgbw = basic.rgbw;
|
||||||
|
serial.writeLine("I2C");
|
||||||
|
// send to 0x44, register 0x00, value 0x46 (RESET ISL29125)
|
||||||
|
pins.i2cWriteNumber(0x44, 0x0046, NumberFormat.UInt16BE);
|
||||||
|
// send to 0x44, register 0x01, value 0x05 (GRB SAMPLING)
|
||||||
|
pins.i2cWriteNumber(0x44, 0x0105, NumberFormat.UInt16BE);
|
||||||
|
basic.forever(() => {
|
||||||
|
serial.writeString("[");
|
||||||
|
pins.i2cWriteNumber(0x44, 0x0A, NumberFormat.Int8BE);
|
||||||
|
let g = pins.i2cReadNumber(0x44, NumberFormat.UInt8BE);
|
||||||
|
serial.writeNumber(r);
|
||||||
|
serial.writeString(",");
|
||||||
|
pins.i2cWriteNumber(0x44, 0x0C, NumberFormat.UInt8BE);
|
||||||
|
let r = pins.i2cReadNumber(0x44, NumberFormat.UInt8BE);
|
||||||
|
serial.writeNumber(g);
|
||||||
|
serial.writeString(",");
|
||||||
|
pins.i2cWriteNumber(0x44, 0x0E, NumberFormat.UInt8BE);
|
||||||
|
let b = pins.i2cReadNumber(0x44, NumberFormat.UInt8LE);
|
||||||
|
serial.writeNumber(b);
|
||||||
|
serial.writeLine("]");
|
||||||
|
basic.setLedColor(basic.rgbw(r,g,b, 0));
|
||||||
|
basic.pause(1000);
|
||||||
|
});
|
||||||
11
libs/calliope-i2c/pxt.json
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"name": "calliope-i2c",
|
||||||
|
"description": "Calliope I2C test",
|
||||||
|
"files": [
|
||||||
|
"i2c.ts"
|
||||||
|
],
|
||||||
|
"public": true,
|
||||||
|
"dependencies": {
|
||||||
|
"core": "file:../core"
|
||||||
|
}
|
||||||
|
}
|
||||||
23
libs/calliope-midi/midi.ts
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
serial.redirect(
|
||||||
|
SerialPin.P0,
|
||||||
|
SerialPin.P1,
|
||||||
|
31250
|
||||||
|
);
|
||||||
|
|
||||||
|
basic.forever(() => {
|
||||||
|
for (let note = 0; note <= 90 - 1; note++) {
|
||||||
|
// Note on channel 1 (0x90), some note value (note),
|
||||||
|
// middle velocity (0x45):
|
||||||
|
serial.writeString(String.fromCharCode(144));
|
||||||
|
serial.writeString(String.fromCharCode(note));
|
||||||
|
serial.writeString(String.fromCharCode(69));
|
||||||
|
basic.pause(100);
|
||||||
|
// Note on channel 1 (0x90), some note value (note),
|
||||||
|
// silent velocity (0x00):
|
||||||
|
serial.writeString(String.fromCharCode(144));
|
||||||
|
serial.writeString(String.fromCharCode(note));
|
||||||
|
serial.writeString("\0");
|
||||||
|
basic.pause(100);
|
||||||
|
basic.pause(1000);
|
||||||
|
}
|
||||||
|
});
|
||||||
11
libs/calliope-midi/pxt.json
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"name": "midi",
|
||||||
|
"description": "MIDI Example via Serial",
|
||||||
|
"files": [
|
||||||
|
"midi.ts"
|
||||||
|
],
|
||||||
|
"public": true,
|
||||||
|
"dependencies": {
|
||||||
|
"core": "file:../core"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,31 +1,127 @@
|
|||||||
{
|
{
|
||||||
"Math.abs": "Returns the absolute value of a number (the value without regard to whether it is positive or negative). \nFor example, the absolute value of -5 is the same as the absolute value of 5.",
|
"AcceleratorRange.EightG": "The accelerator measures forces up to 8 gravity",
|
||||||
|
"AcceleratorRange.FourG": "The accelerator measures forces up to 4 gravity",
|
||||||
|
"AcceleratorRange.OneG": "The accelerator measures forces up to 1 gravity",
|
||||||
|
"AcceleratorRange.TwoG": "The accelerator measures forces up to 2 gravity",
|
||||||
|
"Array": "Add, remove, and replace items in lists.\n\nAdd, remove, and replace items in lists.",
|
||||||
|
"Array.filter": "Return the elements of an array that meet the condition specified in a callback function.",
|
||||||
|
"Array.filter|param|callbackfn": "A function that accepts up to two arguments. The filter method calls the callbackfn function one time for each element in the array.",
|
||||||
|
"Array.get": "Get the value at a particular index.",
|
||||||
|
"Array.get|param|index": "the zero-based position in the list of the item, eg: 0",
|
||||||
|
"Array.indexOf": "Return the index of the first occurrence of a value in an array.",
|
||||||
|
"Array.indexOf|param|fromIndex": "The array index at which to begin the search. If fromIndex is omitted, the search starts at index 0.",
|
||||||
|
"Array.indexOf|param|item": "The value to locate in the array.",
|
||||||
|
"Array.insertAt": "Insert the value at a particular index, increase the array length by 1.",
|
||||||
|
"Array.insertAt|param|index": "the zero-based position in the list to insert the value, eg: 0",
|
||||||
|
"Array.insertAt|param|value": "to insert, eg: 0",
|
||||||
|
"Array.length": "Gets or sets the length of the array. This is a number one higher than the highest element defined in an array.",
|
||||||
|
"Array.map": "Call a defined callback function on each element of an array, and return an array containing the results.",
|
||||||
|
"Array.map|param|callbackfn": "A function that accepts up to two arguments. The map method calls the callbackfn function one time for each element in the array.",
|
||||||
|
"Array.pop": "Remove the last element from an array and return it.",
|
||||||
|
"Array.push": "Append a new elements to an array.",
|
||||||
|
"Array.push|param|item": "to append to the Array.",
|
||||||
|
"Array.reduce": "Call the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function.",
|
||||||
|
"Array.reduce|param|callbackfn": "A function that accepts up to three arguments. The reduce method calls the callbackfn function one time for each element in the array.",
|
||||||
|
"Array.reduce|param|initialValue": "Initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value.",
|
||||||
|
"Array.removeAt": "Remove the element at a certain index.",
|
||||||
|
"Array.removeAt|param|index": "the zero-based position in the list to remove the value from, eg: 0",
|
||||||
|
"Array.removeElement": "Remove the first occurence of an object. Return true if removed.",
|
||||||
|
"Array.reverse": "Reverse the elements in an array. The first array element becomes the last, and the last array element becomes the first.",
|
||||||
|
"Array.set": "Store a value at a particular index.",
|
||||||
|
"Array.set|param|index": "the zero-based position in the list to store the value, eg: 0",
|
||||||
|
"Array.shift": "Remove the first element from an array and return it. This method changes the length of the array.",
|
||||||
|
"Array.slice": "Return a section of an array.",
|
||||||
|
"Array.slice|param|end": "The end of the specified portion of the array. eg: 0",
|
||||||
|
"Array.slice|param|start": "The beginning of the specified portion of the array. eg: 0",
|
||||||
|
"Array.sort": "Sort the elements of an array in place and returns the array. The sort is not necessarily stable.",
|
||||||
|
"Array.splice": "Remove elements from an array.",
|
||||||
|
"Array.splice|param|deleteCount": "The number of elements to remove. eg: 0",
|
||||||
|
"Array.splice|param|start": "The zero-based location in the array from which to start removing elements. eg: 0",
|
||||||
|
"Array.unshift": "Add one element to the beginning of an array and return the new length of the array.",
|
||||||
|
"Array.unshift|param|value": "to insert at the start of the Array.",
|
||||||
|
"Boolean.toString": "Returns a string representation of an object.",
|
||||||
|
"Buffer.fill": "Fill (a fragment) of the buffer with given value.",
|
||||||
|
"Buffer.getNumber": "Read a number in specified format from the buffer.",
|
||||||
|
"Buffer.length": "Returns the length of a Buffer object.",
|
||||||
|
"Buffer.rotate": "Rotate buffer left in place.",
|
||||||
|
"Buffer.rotate|param|length": "number of elements in buffer. If negative, length is set as the buffer length minus start. eg: -1",
|
||||||
|
"Buffer.rotate|param|offset": "number of bytes to shift; use negative value to shift right",
|
||||||
|
"Buffer.rotate|param|start": "start offset in buffer. Default is 0.",
|
||||||
|
"Buffer.setNumber": "Write a number in specified format in the buffer.",
|
||||||
|
"Buffer.shift": "Shift buffer left in place, with zero padding.",
|
||||||
|
"Buffer.shift|param|length": "number of elements in buffer. If negative, length is set as the buffer length minus start. eg: -1",
|
||||||
|
"Buffer.shift|param|offset": "number of bytes to shift; use negative value to shift right",
|
||||||
|
"Buffer.shift|param|start": "start offset in buffer. Default is 0.",
|
||||||
|
"Buffer.slice": "Return a copy of a fragment of a buffer.",
|
||||||
|
"Buffer.write": "Write contents of `src` at `dstOffset` in current buffer.",
|
||||||
|
"Colors": "Well known colors",
|
||||||
|
"EventCreationMode": "How to create the event.",
|
||||||
|
"EventCreationMode.CreateAndFire": "MicroBitEvent is initialised, and its event handlers are immediately fired (not suitable for use in interrupts!).",
|
||||||
|
"EventCreationMode.CreateOnly": "MicroBitEvent is initialised, and no further processing takes place.",
|
||||||
|
"Gesture.EightG": "Raised when a 8G shock is detected",
|
||||||
|
"Gesture.FreeFall": "Raised when the board is falling!",
|
||||||
|
"Gesture.LogoDown": "Raised when the logo is downward and the screen is vertical",
|
||||||
|
"Gesture.LogoUp": "Raised when the logo is upward and the screen is vertical",
|
||||||
|
"Gesture.ScreenDown": "Raised when the screen is pointing up and the board is horizontal",
|
||||||
|
"Gesture.ScreenUp": "Raised when the screen is pointing down and the board is horizontal",
|
||||||
|
"Gesture.Shake": "Raised when shaken",
|
||||||
|
"Gesture.SixG": "Raised when a 6G shock is detected",
|
||||||
|
"Gesture.ThreeG": "Raised when a 3G shock is detected",
|
||||||
|
"Gesture.TiltLeft": "Raised when the screen is pointing left",
|
||||||
|
"Gesture.TiltRight": "Raised when the screen is pointing right",
|
||||||
|
"Image.clear": "Sets all pixels off.",
|
||||||
|
"Image.height": "Gets the height in rows (always 5)",
|
||||||
|
"Image.pixel": "Get the pixel state at position ``(x,y)``",
|
||||||
|
"Image.pixelBrightness": "Gets the pixel brightness ([0..255]) at a given position",
|
||||||
|
"Image.pixel|param|x": "TODO",
|
||||||
|
"Image.pixel|param|y": "TODO",
|
||||||
|
"Image.plotFrame": "Draws the ``index``-th frame of the image on the screen.",
|
||||||
|
"Image.plotFrame|param|xOffset": "column index to start displaying the image",
|
||||||
|
"Image.plotImage": "Plots the image at a given column to the screen",
|
||||||
|
"Image.scrollImage": "Scrolls an image .",
|
||||||
|
"Image.scrollImage|param|frameOffset": "x offset moved on each animation step, eg: 1, 2, 5",
|
||||||
|
"Image.scrollImage|param|interval": "time between each animation step in milli seconds, eg: 200",
|
||||||
|
"Image.setPixel": "Set a pixel state at position ``(x,y)``",
|
||||||
|
"Image.setPixelBrightness": "Sets a specific pixel brightness at a given position",
|
||||||
|
"Image.setPixel|param|value": "TODO",
|
||||||
|
"Image.setPixel|param|x": "TODO",
|
||||||
|
"Image.setPixel|param|y": "TODO",
|
||||||
|
"Image.showFrame": "Shows a particular frame of the image strip.",
|
||||||
|
"Image.showFrame|param|frame": "TODO",
|
||||||
|
"Image.showImage": "Shows an frame from the image at offset ``x offset``.",
|
||||||
|
"Image.showImage|param|xOffset": "column index to start displaying the image",
|
||||||
|
"Image.width": "Gets the width in columns",
|
||||||
|
"Math": "More complex operations with numbers.",
|
||||||
|
"Math.abs": "Returns the absolute value of a number (the value without regard to whether it is positive or negative).\nFor example, the absolute value of -5 is the same as the absolute value of 5.",
|
||||||
"Math.abs|param|x": "A numeric expression for which the absolute value is needed.",
|
"Math.abs|param|x": "A numeric expression for which the absolute value is needed.",
|
||||||
"Math.max": "Returns the larger of two supplied numeric expressions.",
|
"Math.max": "Returns the larger of two supplied numeric expressions.",
|
||||||
"Math.min": "Returns the smaller of two supplied numeric expressions.",
|
"Math.min": "Returns the smaller of two supplied numeric expressions.",
|
||||||
"Math.pow": "Returns the value of a base expression taken to a specified power.",
|
"Math.pow": "Return the value of a base expression taken to a specified power.",
|
||||||
"Math.pow|param|x": "The base value of the expression.",
|
"Math.pow|param|x": "The base value of the expression.",
|
||||||
"Math.pow|param|y": "The exponent value of the expression.",
|
"Math.pow|param|y": "The exponent value of the expression.",
|
||||||
"Math.random": "Returns a pseudorandom number between 0 and `max`.",
|
"Math.random": "Return a pseudorandom number between 0 and `limit`.",
|
||||||
"Math.randomBoolean": "Generates a `true` or `false` value randomly, just like flipping a coin.",
|
"Math.randomBoolean": "Generates a `true` or `false` value randomly, just like flipping a coin.",
|
||||||
|
"Math.random|param|limit": "the upper bound of the number generated, eg: 4",
|
||||||
"Math.sign": "Returns the sign of the x, indicating whether x is positive, negative or zero.",
|
"Math.sign": "Returns the sign of the x, indicating whether x is positive, negative or zero.",
|
||||||
"Math.sign|param|x": "The numeric expression to test",
|
"Math.sign|param|x": "The numeric expression to test",
|
||||||
"Math.sqrt": "Returns the square root of a number.",
|
"Math.sqrt": "Return the square root of a number.",
|
||||||
"Math.sqrt|param|x": "A numeric expression.",
|
"Math.sqrt|param|x": "A numeric expression.",
|
||||||
"String.charAt": "Returns the character at the specified index.",
|
"Number.toString": "Return a string representation of a number.",
|
||||||
"String.charAt|param|index": "The zero-based index of the desired character.",
|
"String": "Combine, split, and search text strings.\n\nCombine, split, and search text strings.",
|
||||||
"String.charCodeAt": "Returns the Unicode value of the character at the specified location.",
|
"String.charAt": "Return the character at the specified index.",
|
||||||
|
"String.charAt|param|index": "The zero-based index of the desired character, eg: 0",
|
||||||
|
"String.charCodeAt": "Return the Unicode value of the character at the specified location.",
|
||||||
"String.charCodeAt|param|index": "The zero-based index of the desired character. If there is no character at the specified index, NaN is returned.",
|
"String.charCodeAt|param|index": "The zero-based index of the desired character. If there is no character at the specified index, NaN is returned.",
|
||||||
"String.compare": "Determines whether relative order of two strings (in ASCII encoding).",
|
"String.compare": "See how the order of characters in two strings is different (in ASCII encoding).",
|
||||||
"String.compare|param|that": "String to compare to target string",
|
"String.compare|param|that": "String to compare to target string",
|
||||||
"String.concat": "Returns a string that contains the concatenation of two or more strings.",
|
"String.concat": "Returns a string that contains the concatenation of two or more strings.",
|
||||||
"String.concat|param|other": "The string to append to the end of the string.",
|
"String.concat|param|other": "The string to append to the end of the string, eg: \"add me!\"",
|
||||||
"String.fromCharCode": "Make a string from the given ASCII character code.",
|
"String.fromCharCode": "Make a string from the given ASCII character code.",
|
||||||
"String.isEmpty": "Returns a value indicating if the string is empty",
|
"String.isEmpty": "Returns a value indicating if the string is empty",
|
||||||
"String.length": "Returns the length of a String object.",
|
"String.length": "Return the length of a String object.",
|
||||||
"String.substr": "Return substring of the current string.",
|
"String.substr": "Return a substring of the current string.",
|
||||||
"String.substr|param|length": "number of characters to extract",
|
"String.substr|param|length": "number of characters to extract, eg: 3",
|
||||||
"String.substr|param|start": "first character index; can be negative from counting from the end, eg:0",
|
"String.substr|param|start": "first character index; can be negative from counting from the end, eg: 0",
|
||||||
"basic": "Provides access to basic micro:bit functionality.\n\nProvides access to basic micro:bit functionality.",
|
"basic": "Provides access to basic micro:bit functionality.\n\nProvides access to basic micro:bit functionality.",
|
||||||
"basic.clearScreen": "Turn off all LEDs",
|
"basic.clearScreen": "Turn off all LEDs",
|
||||||
"basic.color": "Converts the color name to a number",
|
"basic.color": "Converts the color name to a number",
|
||||||
@@ -43,7 +139,12 @@
|
|||||||
"basic.showAnimation": "Shows a sequence of LED screens as an animation.",
|
"basic.showAnimation": "Shows a sequence of LED screens as an animation.",
|
||||||
"basic.showAnimation|param|interval": "time in milliseconds between each redraw",
|
"basic.showAnimation|param|interval": "time in milliseconds between each redraw",
|
||||||
"basic.showAnimation|param|leds": "pattern of LEDs to turn on/off",
|
"basic.showAnimation|param|leds": "pattern of LEDs to turn on/off",
|
||||||
|
"basic.showArrow": "Shows an arrow on screent",
|
||||||
|
"basic.showArrow|param|direction": "the direction of the arrow",
|
||||||
|
"basic.showArrow|param|interval": "the amount of time (milliseconds) to show the icon. Default is 600.",
|
||||||
"basic.showIcon": "Draws the selected icon on the LED screen",
|
"basic.showIcon": "Draws the selected icon on the LED screen",
|
||||||
|
"basic.showIcon|param|icon": "the predifined icon id",
|
||||||
|
"basic.showIcon|param|interval": "the amount of time (milliseconds) to show the icon. Default is 600.",
|
||||||
"basic.showLeds": "Draws an image on the LED screen.",
|
"basic.showLeds": "Draws an image on the LED screen.",
|
||||||
"basic.showLeds|param|interval": "time in milliseconds to pause after drawing",
|
"basic.showLeds|param|interval": "time in milliseconds to pause after drawing",
|
||||||
"basic.showLeds|param|leds": "the pattern of LED to turn on/off",
|
"basic.showLeds|param|leds": "the pattern of LED to turn on/off",
|
||||||
@@ -72,30 +173,85 @@
|
|||||||
"control.waitMicros": "Blocks the current fiber for the given microseconds",
|
"control.waitMicros": "Blocks the current fiber for the given microseconds",
|
||||||
"control.waitMicros|param|micros": "number of micro-seconds to wait. eg: 4",
|
"control.waitMicros|param|micros": "number of micro-seconds to wait. eg: 4",
|
||||||
"game": "A single-LED sprite game engine",
|
"game": "A single-LED sprite game engine",
|
||||||
|
"game.LedSprite": "A game sprite rendered as a single LED",
|
||||||
|
"game.LedSprite.blink": "Reports the ``blink`` duration of a sprite",
|
||||||
|
"game.LedSprite.brightness": "Reports the ``brightness` of a sprite on the LED screen",
|
||||||
|
"game.LedSprite.change": "Changes a property of the sprite",
|
||||||
|
"game.LedSprite.changeBlinkBy": "Changes the ``blink`` duration by the given amount of millisecons",
|
||||||
|
"game.LedSprite.changeBlinkBy|param|ms": "TODO",
|
||||||
|
"game.LedSprite.changeBrightnessBy": "Changes the ``y`` position by the given amount",
|
||||||
|
"game.LedSprite.changeBrightnessBy|param|value": "the value to change brightness",
|
||||||
|
"game.LedSprite.changeDirectionBy": "Changes the ``direction`` position by the given amount by turning right",
|
||||||
|
"game.LedSprite.changeDirectionBy|param|angle": "TODO",
|
||||||
|
"game.LedSprite.changeXBy": "Changes the ``x`` position by the given amount",
|
||||||
|
"game.LedSprite.changeXBy|param|x": "TODO",
|
||||||
|
"game.LedSprite.changeYBy": "Changes the ``y`` position by the given amount",
|
||||||
|
"game.LedSprite.changeYBy|param|y": "TODO",
|
||||||
|
"game.LedSprite.change|param|property": "the name of the property to change",
|
||||||
|
"game.LedSprite.change|param|value": "amount of change, eg: 1",
|
||||||
|
"game.LedSprite.delete": "Deletes the sprite from the game engine. The sprite will no longer appear on the screen or interact with other sprites.",
|
||||||
|
"game.LedSprite.direction": "Reports the current direction of a sprite",
|
||||||
|
"game.LedSprite.get": "Gets a property of the sprite",
|
||||||
|
"game.LedSprite.get|param|property": "the name of the property to change",
|
||||||
|
"game.LedSprite.goTo": "Go to this position on the screen",
|
||||||
|
"game.LedSprite.goTo|param|x": "TODO",
|
||||||
|
"game.LedSprite.goTo|param|y": "TODO",
|
||||||
|
"game.LedSprite.ifOnEdgeBounce": "If touching the edge of the stage and facing towards it, then turn away.",
|
||||||
|
"game.LedSprite.isTouching": "Reports true if sprite has the same position as specified sprite",
|
||||||
|
"game.LedSprite.isTouchingEdge": "Reports true if sprite is touching an edge",
|
||||||
|
"game.LedSprite.isTouching|param|other": "TODO",
|
||||||
|
"game.LedSprite.move": "Move a certain number of LEDs in the current direction",
|
||||||
|
"game.LedSprite.move|param|leds": "number of leds to move, eg: 1, -1",
|
||||||
|
"game.LedSprite.off": "Turns off the sprite (on by default)",
|
||||||
|
"game.LedSprite.on": "Turns on the sprite (on by default)",
|
||||||
|
"game.LedSprite.set": "Sets a property of the sprite",
|
||||||
|
"game.LedSprite.setBlink": "Sets the blink duration interval in millisecond.",
|
||||||
|
"game.LedSprite.setBlink|param|ms": "TODO",
|
||||||
|
"game.LedSprite.setBrightness": "Set the ``brightness`` of a sprite",
|
||||||
|
"game.LedSprite.setBrightness|param|brightness": "the brightness from 0 (off) to 255 (on), eg: 255.",
|
||||||
|
"game.LedSprite.setDirection": "Set the direction of the current sprite, rounded to the nearest multiple of 45",
|
||||||
|
"game.LedSprite.setDirection|param|degrees": "TODO",
|
||||||
|
"game.LedSprite.setX": "Set the ``x`` position of a sprite",
|
||||||
|
"game.LedSprite.setX|param|x": "TODO",
|
||||||
|
"game.LedSprite.setY": "Set the ``y`` position of a sprite",
|
||||||
|
"game.LedSprite.setY|param|y": "TODO",
|
||||||
|
"game.LedSprite.set|param|property": "the name of the property to change",
|
||||||
|
"game.LedSprite.turn": "Turn the sprite",
|
||||||
|
"game.LedSprite.turnLeft": "Turn to the left (counter-clockwise)",
|
||||||
|
"game.LedSprite.turnLeft|param|degrees": "TODO",
|
||||||
|
"game.LedSprite.turnRight": "Turn to the right (clockwise)",
|
||||||
|
"game.LedSprite.turnRight|param|degrees": "TODO",
|
||||||
|
"game.LedSprite.turn|param|degrees": "angle in degrees to turn, eg: 45, 90, 180, 135",
|
||||||
|
"game.LedSprite.turn|param|direction": "left or right",
|
||||||
|
"game.LedSprite.x": "Reports the ``x`` position of a sprite on the LED screen",
|
||||||
|
"game.LedSprite.y": "Reports the ``y`` position of a sprite on the LED screen",
|
||||||
"game.addLife": "Adds life points to the current life",
|
"game.addLife": "Adds life points to the current life",
|
||||||
"game.addLife|param|lives": "TODO",
|
"game.addLife|param|lives": "TODO",
|
||||||
"game.addScore": "Adds points to the current score",
|
"game.addScore": "Adds points to the current score and shows an animation",
|
||||||
"game.addScore|param|points": "amount of points to change, eg: 1",
|
"game.addScore|param|points": "amount of points to change, eg: 1",
|
||||||
"game.createSprite": "Creates a new LED sprite pointing to the right.",
|
"game.createSprite": "Creates a new LED sprite pointing to the right.",
|
||||||
"game.createSprite|param|x": "sprite horizontal coordinate, eg: 2",
|
"game.createSprite|param|x": "sprite horizontal coordinate, eg: 2",
|
||||||
"game.createSprite|param|y": "sprite vertical coordinate, eg: 2",
|
"game.createSprite|param|y": "sprite vertical coordinate, eg: 2",
|
||||||
"game.currentTime": "Gets the remaining time (since `start countdown`) or current time (since the device started or `start stopwatch`) in milliseconds.",
|
"game.currentTime": "Gets the remaining time (since `start countdown`) or current time (since the device started or `start stopwatch`) in milliseconds.",
|
||||||
"game.gameOver": "Displays a game over animation.",
|
"game.gameOver": "Displays a game over animation and the score.",
|
||||||
"game.invalidSprite": "Gets an invalid sprite; used to initialize locals.",
|
"game.invalidSprite": "Gets an invalid sprite; used to initialize locals.",
|
||||||
"game.isGameOver": "Indicates if the game is display the game over sequence.",
|
"game.isGameOver": "Indicates if the game is display the game over sequence.",
|
||||||
|
"game.isPaused": "Indicates if the game rendering is paused to allow other animations",
|
||||||
"game.isRunning": "Gets a value indicating if the game is still running. Returns `false` if game over.",
|
"game.isRunning": "Gets a value indicating if the game is still running. Returns `false` if game over.",
|
||||||
"game.level": "Gets the current level",
|
"game.level": "Gets the current level",
|
||||||
"game.levelUp": "Increments the level and display a message.",
|
"game.levelUp": "Increments the level and display a message.",
|
||||||
"game.life": "Gets the current life",
|
"game.life": "Gets the current life",
|
||||||
|
"game.pause": "Pauses the game rendering engine to allow other animations",
|
||||||
"game.removeLife": "Removes some life",
|
"game.removeLife": "Removes some life",
|
||||||
"game.removeLife|param|life": "TODO",
|
"game.removeLife|param|life": "TODO",
|
||||||
|
"game.resume": "Resumes the game rendering engine",
|
||||||
"game.score": "Gets the current score",
|
"game.score": "Gets the current score",
|
||||||
"game.setLife": "Sets the current life value",
|
"game.setLife": "Sets the current life value",
|
||||||
"game.setLife|param|value": "TODO",
|
"game.setLife|param|value": "TODO",
|
||||||
"game.setScore": "Sets the current score value",
|
"game.setScore": "Sets the current score value",
|
||||||
"game.setScore|param|value": "TODO",
|
"game.setScore|param|value": "new score value.",
|
||||||
"game.showScore": "Displays the score on the screen.",
|
"game.showScore": "Displays the score on the screen.",
|
||||||
"game.startCountdown": "Starts a game countdown timer",
|
"game.startCountdown": "Shows an animation, then starts a game countdown timer, which causes Game Over when it reaches 0",
|
||||||
"game.startCountdown|param|ms": "countdown duration in milliseconds, eg: 10000",
|
"game.startCountdown|param|ms": "countdown duration in milliseconds, eg: 10000",
|
||||||
"game.startStopwatch": "Starts a stopwatch timer. `current time` will return the elapsed time.",
|
"game.startStopwatch": "Starts a stopwatch timer. `current time` will return the elapsed time.",
|
||||||
"images": "Creation, manipulation and display of LED images.",
|
"images": "Creation, manipulation and display of LED images.",
|
||||||
@@ -105,26 +261,28 @@
|
|||||||
"input.acceleration": "Get the acceleration value in milli-gravitys (when the board is laying flat with the screen up, x=0, y=0 and z=-1024)",
|
"input.acceleration": "Get the acceleration value in milli-gravitys (when the board is laying flat with the screen up, x=0, y=0 and z=-1024)",
|
||||||
"input.acceleration|param|dimension": "TODO",
|
"input.acceleration|param|dimension": "TODO",
|
||||||
"input.buttonIsPressed": "Get the button state (pressed or not) for ``A`` and ``B``.",
|
"input.buttonIsPressed": "Get the button state (pressed or not) for ``A`` and ``B``.",
|
||||||
"input.calibrate": "Obsolete, compass calibration is automatic.",
|
"input.buttonIsPressed|param|button": "the button to query the request, eg: Button.A",
|
||||||
|
"input.calibrateCompass": "Obsolete, compass calibration is automatic.",
|
||||||
"input.compassHeading": "Get the current compass heading in degrees.",
|
"input.compassHeading": "Get the current compass heading in degrees.",
|
||||||
"input.lightLevel": "Reads the light level applied to the LED screen in a range from ``0`` (dark) to ``255`` bright.",
|
"input.lightLevel": "Reads the light level applied to the LED screen in a range from ``0`` (dark) to ``255`` bright.",
|
||||||
"input.magneticForce": "Get the magnetic force value in ``micro-Teslas`` (``µT``). This function is not supported in the simulator.",
|
"input.magneticForce": "Get the magnetic force value in ``micro-Teslas`` (``µT``). This function is not supported in the simulator.",
|
||||||
"input.magneticForce|param|dimension": "TODO",
|
"input.magneticForce|param|dimension": "TODO",
|
||||||
"input.onButtonPressed": "Do something when a button (``A``, ``B`` or both ``A+B``) is pressed",
|
"input.onButtonPressed": "Do something when a button (A, B or both A+B) is pushed down and released again.",
|
||||||
"input.onButtonPressed|param|body": "TODO",
|
"input.onButtonPressed|param|body": "code to run when event is raised",
|
||||||
"input.onButtonPressed|param|button": "TODO",
|
"input.onButtonPressed|param|button": "the button that needs to be pressed",
|
||||||
"input.onGesture": "Do something when when a gesture is done (like shaking the micro:bit).",
|
"input.onGesture": "Do something when when a gesture is done (like shaking the micro:bit).",
|
||||||
"input.onGesture|param|body": "TODO",
|
"input.onGesture|param|body": "code to run when gesture is raised",
|
||||||
|
"input.onGesture|param|gesture": "the type of gesture to track, eg: Gesture.Shake",
|
||||||
"input.onLogoDown": "Attaches code to run when the logo is oriented downwards and the board is vertical.",
|
"input.onLogoDown": "Attaches code to run when the logo is oriented downwards and the board is vertical.",
|
||||||
"input.onLogoDown|param|body": "TODO",
|
"input.onLogoDown|param|body": "TODO",
|
||||||
"input.onLogoUp": "Attaches code to run when the logo is oriented upwards and the board is vertical.",
|
"input.onLogoUp": "Attaches code to run when the logo is oriented upwards and the board is vertical.",
|
||||||
"input.onLogoUp|param|body": "TODO",
|
"input.onLogoUp|param|body": "TODO",
|
||||||
"input.onPinPressed": "Do something when a pin is pressed.",
|
"input.onPinPressed": "Do something when a pin is touched and released again (while also touching the GND pin).",
|
||||||
"input.onPinPressed|param|body": "the code to run when the pin is pressed",
|
"input.onPinPressed|param|body": "the code to run when the pin is pressed",
|
||||||
"input.onPinPressed|param|name": "the pin that needs to be pressed",
|
"input.onPinPressed|param|name": "the pin that needs to be pressed, eg: TouchPin.P0",
|
||||||
"input.onPinReleased": "Do something when a pin is released.",
|
"input.onPinReleased": "Do something when a pin is released.",
|
||||||
"input.onPinReleased|param|body": "the code to run when the pin is released",
|
"input.onPinReleased|param|body": "the code to run when the pin is released",
|
||||||
"input.onPinReleased|param|name": "the pin that needs to be released",
|
"input.onPinReleased|param|name": "the pin that needs to be released, eg: TouchPin.P0",
|
||||||
"input.onScreenDown": "Attaches code to run when the screen is facing down.",
|
"input.onScreenDown": "Attaches code to run when the screen is facing down.",
|
||||||
"input.onScreenDown|param|body": "TODO",
|
"input.onScreenDown|param|body": "TODO",
|
||||||
"input.onScreenUp": "Attaches code to run when the screen is facing up.",
|
"input.onScreenUp": "Attaches code to run when the screen is facing up.",
|
||||||
@@ -132,15 +290,17 @@
|
|||||||
"input.onShake": "Attaches code to run when the device is shaken.",
|
"input.onShake": "Attaches code to run when the device is shaken.",
|
||||||
"input.onShake|param|body": "TODO",
|
"input.onShake|param|body": "TODO",
|
||||||
"input.pinIsPressed": "Get the pin state (pressed or not). Requires to hold the ground to close the circuit.",
|
"input.pinIsPressed": "Get the pin state (pressed or not). Requires to hold the ground to close the circuit.",
|
||||||
"input.pinIsPressed|param|name": "pin used to detect the touch",
|
"input.pinIsPressed|param|name": "pin used to detect the touch, eg: TouchPin.P0",
|
||||||
"input.rotation": "The pitch or roll of the device, rotation along the ``x-axis`` or ``y-axis``, in degrees.",
|
"input.rotation": "The pitch or roll of the device, rotation along the ``x-axis`` or ``y-axis``, in degrees.",
|
||||||
"input.rotation|param|kind": "TODO",
|
"input.rotation|param|kind": "TODO",
|
||||||
"input.runningTime": "Gets the number of milliseconds elapsed since power on.",
|
"input.runningTime": "Gets the number of milliseconds elapsed since power on.",
|
||||||
|
"input.runningTimeMicros": "Gets the number of microseconds elapsed since power on.",
|
||||||
"input.setAccelerometerRange": "Sets the accelerometer sample range in gravities.",
|
"input.setAccelerometerRange": "Sets the accelerometer sample range in gravities.",
|
||||||
"input.setAccelerometerRange|param|range": "a value describe the maximum strengh of acceleration measured",
|
"input.setAccelerometerRange|param|range": "a value describe the maximum strengh of acceleration measured",
|
||||||
"input.temperature": "Gets the temperature in Celsius degrees (°C).",
|
"input.temperature": "Gets the temperature in Celsius degrees (°C).",
|
||||||
"led": "Control of the LED screen.",
|
"led": "Control of the LED screen.",
|
||||||
"led.brightness": "Get the screen brightness from 0 (off) to 255 (full bright).",
|
"led.brightness": "Get the screen brightness from 0 (off) to 255 (full bright).",
|
||||||
|
"led.displayMode": "Gets the current display mode",
|
||||||
"led.enable": "Turns on or off the display",
|
"led.enable": "Turns on or off the display",
|
||||||
"led.fadeIn": "Fades in the screen display.",
|
"led.fadeIn": "Fades in the screen display.",
|
||||||
"led.fadeIn|param|ms": "TODO",
|
"led.fadeIn|param|ms": "TODO",
|
||||||
@@ -151,8 +311,12 @@
|
|||||||
"led.plotBarGraph": "Displays a vertical bar graph based on the `value` and `high` value.\nIf `high` is 0, the chart gets adjusted automatically.",
|
"led.plotBarGraph": "Displays a vertical bar graph based on the `value` and `high` value.\nIf `high` is 0, the chart gets adjusted automatically.",
|
||||||
"led.plotBarGraph|param|high": "maximum value. If 0, maximum value adjusted automatically, eg: 0",
|
"led.plotBarGraph|param|high": "maximum value. If 0, maximum value adjusted automatically, eg: 0",
|
||||||
"led.plotBarGraph|param|value": "current value to plot",
|
"led.plotBarGraph|param|value": "current value to plot",
|
||||||
"led.plot|param|x": "TODO",
|
"led.plotBrightness": "Turn on the specified LED with specific brightness using x, y coordinates (x is horizontal, y is vertical). (0,0) is upper left.",
|
||||||
"led.plot|param|y": "TODO",
|
"led.plotBrightness|param|brightness": "the brightness from 0 (off) to 255 (bright), eg:255",
|
||||||
|
"led.plotBrightness|param|x": "the horizontal coordinate of the LED starting at 0",
|
||||||
|
"led.plotBrightness|param|y": "the vertical coordinate of the LED starting at 0",
|
||||||
|
"led.plot|param|x": "the horizontal coordinate of the LED starting at 0",
|
||||||
|
"led.plot|param|y": "the vertical coordinate of the LED starting at 0",
|
||||||
"led.point": "Get the on/off state of the specified LED using x, y coordinates. (0,0) is upper left.",
|
"led.point": "Get the on/off state of the specified LED using x, y coordinates. (0,0) is upper left.",
|
||||||
"led.point|param|x": "TODO",
|
"led.point|param|x": "TODO",
|
||||||
"led.point|param|y": "TODO",
|
"led.point|param|y": "TODO",
|
||||||
@@ -174,42 +338,52 @@
|
|||||||
"motors.motorCommand": "Send break, coast or sleep commands to the motor. Has no effect in dual-motor mode.",
|
"motors.motorCommand": "Send break, coast or sleep commands to the motor. Has no effect in dual-motor mode.",
|
||||||
"motors.motorPower": "Turns on the motor at a certain percent of power. Switches to single motor mode!",
|
"motors.motorPower": "Turns on the motor at a certain percent of power. Switches to single motor mode!",
|
||||||
"motors.motorPower|param|power": "%percent of power sent to the motor. Negative power goes backward. eg: 50",
|
"motors.motorPower|param|power": "%percent of power sent to the motor. Negative power goes backward. eg: 50",
|
||||||
"music": "Generation of music tones through pin ``P0``.",
|
"music": "Generation of music tones.",
|
||||||
"music.beat": "Returns the duration of a beat in milli-seconds",
|
"music.beat": "Returns the duration of a beat in milli-seconds",
|
||||||
|
"music.beginMelody": "Starts playing a melody.\nNotes are expressed as a string of characters with this format: NOTE[octave][:duration]",
|
||||||
|
"music.beginMelody|param|melodyArray": "the melody array to play, eg: ['g5:1']",
|
||||||
|
"music.beginMelody|param|options": "melody options, once / forever, in the foreground / background",
|
||||||
|
"music.builtInMelody": "Gets the melody array of a built-in melody.",
|
||||||
"music.changeTempoBy": "Change the tempo by the specified amount",
|
"music.changeTempoBy": "Change the tempo by the specified amount",
|
||||||
"music.changeTempoBy|param|bpm": "The change in beats per minute to the tempo, eg: 20",
|
"music.changeTempoBy|param|bpm": "The change in beats per minute to the tempo, eg: 20",
|
||||||
"music.noteFrequency": "Gets the frequency of a note.",
|
"music.noteFrequency": "Gets the frequency of a note.",
|
||||||
"music.noteFrequency|param|name": "the note name",
|
"music.noteFrequency|param|name": "the note name, eg: Note.C",
|
||||||
"music.playTone": "Plays a tone through ``speaker`` for the given duration.",
|
"music.onEvent": "Registers code to run on various melody events",
|
||||||
|
"music.playTone": "Plays a tone through pin ``P0`` for the given duration.",
|
||||||
"music.playTone|param|frequency": "pitch of the tone to play in Hertz (Hz)",
|
"music.playTone|param|frequency": "pitch of the tone to play in Hertz (Hz)",
|
||||||
"music.playTone|param|ms": "tone duration in milliseconds (ms)",
|
"music.playTone|param|ms": "tone duration in milliseconds (ms)",
|
||||||
"music.rest": "Rests (plays nothing) for a specified time through pin ``P0``.",
|
"music.rest": "Rests (plays nothing) for a specified time through pin ``P0``.",
|
||||||
"music.rest|param|ms": "rest duration in milliseconds (ms)",
|
"music.rest|param|ms": "rest duration in milliseconds (ms)",
|
||||||
"music.ringTone": "Plays a tone through ``speaker``.",
|
"music.ringTone": "Plays a tone through pin ``P0``.",
|
||||||
"music.ringTone|param|frequency": "pitch of the tone to play in Hertz (Hz)",
|
"music.ringTone|param|frequency": "pitch of the tone to play in Hertz (Hz)",
|
||||||
|
"music.setPlayTone": "Sets a custom playTone function for playing melodies",
|
||||||
"music.setTempo": "Sets the tempo to the specified amount",
|
"music.setTempo": "Sets the tempo to the specified amount",
|
||||||
"music.setTempo|param|bpm": "The new tempo in beats per minute, eg: 120",
|
"music.setTempo|param|bpm": "The new tempo in beats per minute, eg: 120",
|
||||||
|
"music.speakerPlayTone": "Plays a tone through ``speaker`` for the given duration.",
|
||||||
|
"music.speakerPlayTone|param|frequency": "pitch of the tone to play in Hertz (Hz)",
|
||||||
|
"music.speakerPlayTone|param|ms": "tone duration in milliseconds (ms)",
|
||||||
"music.tempo": "Returns the tempo in beats per minute. Tempo is the speed (bpm = beats per minute) at which notes play. The larger the tempo value, the faster the notes will play.",
|
"music.tempo": "Returns the tempo in beats per minute. Tempo is the speed (bpm = beats per minute) at which notes play. The larger the tempo value, the faster the notes will play.",
|
||||||
|
"parseInt": "Convert A string to an integer.",
|
||||||
"pins": "Control currents in Pins for analog/digital signals, servos, i2c, ...",
|
"pins": "Control currents in Pins for analog/digital signals, servos, i2c, ...",
|
||||||
"pins.analogPitch": "Emits a Pulse-width modulation (PWM) signal to the current pitch pin. Use `analog set pitch pin` to define the pitch pin.",
|
"pins.analogPitch": "Emits a Pulse-width modulation (PWM) signal to the current pitch pin. Use `analog set pitch pin` to define the pitch pin.",
|
||||||
"pins.analogPitch|param|frequency": "TODO",
|
"pins.analogPitch|param|frequency": "frequency to modulate in Hz.",
|
||||||
"pins.analogPitch|param|ms": "TODO",
|
"pins.analogPitch|param|ms": "duration of the pitch in milli seconds.",
|
||||||
"pins.analogReadPin": "Read the connector value as analog, that is, as a value comprised between 0 and 1023.",
|
"pins.analogReadPin": "Read the connector value as analog, that is, as a value comprised between 0 and 1023.",
|
||||||
"pins.analogReadPin|param|name": "pin to write to",
|
"pins.analogReadPin|param|name": "pin to write to, eg: AnalogPin.P0",
|
||||||
"pins.analogSetPeriod": "Configures the Pulse-width modulation (PWM) of the analog output to the given value in **microseconds** or `1/1000` milliseconds.\nIf this pin is not configured as an analog output (using `analog write pin`), the operation has no effect.",
|
"pins.analogSetPeriod": "Configures the Pulse-width modulation (PWM) of the analog output to the given value in **microseconds** or `1/1000` milliseconds.\nIf this pin is not configured as an analog output (using `analog write pin`), the operation has no effect.",
|
||||||
"pins.analogSetPeriod|param|micros": "period in micro seconds. eg:20000",
|
"pins.analogSetPeriod|param|micros": "period in micro seconds. eg:20000",
|
||||||
"pins.analogSetPeriod|param|name": "analog pin to set period to",
|
"pins.analogSetPeriod|param|name": "analog pin to set period to, eg: AnalogPin.P0",
|
||||||
"pins.analogSetPitchPin": "Sets the pin used when using `pins->analog pitch`.",
|
"pins.analogSetPitchPin": "Sets the pin used when using `analog pitch` or music.",
|
||||||
"pins.analogSetPitchPin|param|name": "TODO",
|
"pins.analogSetPitchPin|param|name": "pin to modulate pitch from",
|
||||||
"pins.analogWritePin": "Set the connector value as analog. Value must be comprised between 0 and 1023.",
|
"pins.analogWritePin": "Set the connector value as analog. Value must be comprised between 0 and 1023.",
|
||||||
"pins.analogWritePin|param|name": "pin name to write to",
|
"pins.analogWritePin|param|name": "pin name to write to, eg: AnalogPin.P0",
|
||||||
"pins.analogWritePin|param|value": "value to write to the pin between ``0`` and ``1023``. eg:1023,0",
|
"pins.analogWritePin|param|value": "value to write to the pin between ``0`` and ``1023``. eg:1023,0",
|
||||||
"pins.createBuffer": "Create a new zero-initialized buffer.",
|
"pins.createBuffer": "Create a new zero-initialized buffer.",
|
||||||
"pins.createBuffer|param|size": "number of bytes in the buffer",
|
"pins.createBuffer|param|size": "number of bytes in the buffer",
|
||||||
"pins.digitalReadPin": "Read the specified pin or connector as either 0 or 1",
|
"pins.digitalReadPin": "Read the specified pin or connector as either 0 or 1",
|
||||||
"pins.digitalReadPin|param|name": "pin to read from",
|
"pins.digitalReadPin|param|name": "pin to read from, eg: DigitalPin.P0",
|
||||||
"pins.digitalWritePin": "Set a pin or connector value to either 0 or 1.",
|
"pins.digitalWritePin": "Set a pin or connector value to either 0 or 1.",
|
||||||
"pins.digitalWritePin|param|name": "pin to write to",
|
"pins.digitalWritePin|param|name": "pin to write to, eg: DigitalPin.P0",
|
||||||
"pins.digitalWritePin|param|value": "value to set on the pin, 1 eg,0",
|
"pins.digitalWritePin|param|value": "value to set on the pin, 1 eg,0",
|
||||||
"pins.i2cReadBuffer": "Read `size` bytes from a 7-bit I2C `address`.",
|
"pins.i2cReadBuffer": "Read `size` bytes from a 7-bit I2C `address`.",
|
||||||
"pins.i2cReadNumber": "Read one number from 7-bit I2C address.",
|
"pins.i2cReadNumber": "Read one number from 7-bit I2C address.",
|
||||||
@@ -222,23 +396,31 @@
|
|||||||
"pins.map|param|toLow": "the lower bound of the value's target range",
|
"pins.map|param|toLow": "the lower bound of the value's target range",
|
||||||
"pins.map|param|value": "value to map in ranges",
|
"pins.map|param|value": "value to map in ranges",
|
||||||
"pins.onPulsed": "Configures this pin to a digital input, and generates events where the timestamp is the duration that this pin was either ``high`` or ``low``.",
|
"pins.onPulsed": "Configures this pin to a digital input, and generates events where the timestamp is the duration that this pin was either ``high`` or ``low``.",
|
||||||
|
"pins.onPulsed|param|name": "digital pin to register to, eg: DigitalPin.P0",
|
||||||
|
"pins.onPulsed|param|pulse": "the value of the pulse, eg: PulseValue.High",
|
||||||
"pins.pulseDuration": "Gets the duration of the last pulse in micro-seconds. This function should be called from a ``onPulsed`` handler.",
|
"pins.pulseDuration": "Gets the duration of the last pulse in micro-seconds. This function should be called from a ``onPulsed`` handler.",
|
||||||
"pins.pulseIn": "Returns the duration of a pulse in microseconds",
|
"pins.pulseIn": "Returns the duration of a pulse in microseconds",
|
||||||
"pins.pulseIn|param|name": "the pin which measures the pulse",
|
"pins.pulseIn|param|name": "the pin which measures the pulse, eg: DigitalPin.P0",
|
||||||
"pins.pulseIn|param|value": "the value of the pulse (default high)",
|
"pins.pulseIn|param|value": "the value of the pulse, eg: PulseValue.High",
|
||||||
"pins.servoSetPulse": "Configures this IO pin as an analog/pwm output, configures the period to be 20 ms, and sets the pulse width, based on the value it is given **microseconds** or `1/1000` milliseconds.",
|
"pins.servoSetPulse": "Configures this IO pin as an analog/pwm output, configures the period to be 20 ms, and sets the pulse width, based on the value it is given **microseconds** or `1/1000` milliseconds.",
|
||||||
"pins.servoSetPulse|param|micros": "pulse duration in micro seconds, eg:1500",
|
"pins.servoSetPulse|param|micros": "pulse duration in micro seconds, eg:1500",
|
||||||
"pins.servoSetPulse|param|name": "pin name",
|
"pins.servoSetPulse|param|name": "pin name",
|
||||||
"pins.servoWritePin": "Writes a value to the servo, controlling the shaft accordingly. On a standard servo, this will set the angle of the shaft (in degrees), moving the shaft to that orientation. On a continuous rotation servo, this will set the speed of the servo (with ``0`` being full-speed in one direction, ``180`` being full speed in the other, and a value near ``90`` being no movement).",
|
"pins.servoWritePin": "Writes a value to the servo, controlling the shaft accordingly. On a standard servo, this will set the angle of the shaft (in degrees), moving the shaft to that orientation. On a continuous rotation servo, this will set the speed of the servo (with ``0`` being full-speed in one direction, ``180`` being full speed in the other, and a value near ``90`` being no movement).",
|
||||||
"pins.servoWritePin|param|name": "pin to write to",
|
"pins.servoWritePin|param|name": "pin to write to, eg: AnalogPin.P0",
|
||||||
"pins.servoWritePin|param|value": "angle or rotation speed, eg:180,90,0",
|
"pins.servoWritePin|param|value": "angle or rotation speed, eg:180,90,0",
|
||||||
"pins.setEvents": "Configures the events emitted by this pin. Events can be subscribed to\nusing ``control.onEvent()``.",
|
"pins.setEvents": "Configures the events emitted by this pin. Events can be subscribed to\nusing ``control.onEvent()``.",
|
||||||
"pins.setEvents|param|name": "pin to set the event mode on, eg: DigitalPin.P0",
|
"pins.setEvents|param|name": "pin to set the event mode on, eg: DigitalPin.P0",
|
||||||
"pins.setEvents|param|type": "the type of events for this pin to emit, eg: PinEventType.Edge",
|
"pins.setEvents|param|type": "the type of events for this pin to emit, eg: PinEventType.Edge",
|
||||||
"pins.setPull": "Configures the pull of this pin.",
|
"pins.setPull": "Configures the pull of this pin.",
|
||||||
"pins.setPull|param|name": "pin to set the pull mode on",
|
"pins.setPull|param|name": "pin to set the pull mode on, eg: DigitalPin.P0",
|
||||||
"pins.setPull|param|pull": "one of the mbed pull configurations: PullUp, PullDown, PullNone ",
|
"pins.setPull|param|pull": "one of the mbed pull configurations, eg: PinPullMode.PullUp",
|
||||||
"pins.sizeOf": "Get the size in bytes of specified number format.",
|
"pins.sizeOf": "Get the size in bytes of specified number format.",
|
||||||
|
"pins.spiFormat": "Sets the SPI bits and mode",
|
||||||
|
"pins.spiFormat|param|bits": "the number of bits, eg: 8",
|
||||||
|
"pins.spiFormat|param|mode": "the mode, eg: 3",
|
||||||
|
"pins.spiFrequency": "Sets the SPI frequency",
|
||||||
|
"pins.spiFrequency|param|frequency": "the clock frequency, eg: 1000000",
|
||||||
|
"pins.spiPins": "Sets the MOSI, MISO, SCK pins used by the SPI instance",
|
||||||
"pins.spiWrite": "Write to the SPI slave and return the response",
|
"pins.spiWrite": "Write to the SPI slave and return the response",
|
||||||
"pins.spiWrite|param|value": "Data to be sent to the SPI slave",
|
"pins.spiWrite|param|value": "Data to be sent to the SPI slave",
|
||||||
"serial": "Reading and writing data over a serial connection.",
|
"serial": "Reading and writing data over a serial connection.",
|
||||||
|
|||||||
@@ -7,9 +7,29 @@
|
|||||||
"AcceleratorRange.OneG|block": "1g",
|
"AcceleratorRange.OneG|block": "1g",
|
||||||
"AcceleratorRange.TwoG": "The accelerator measures forces up to 2 gravity",
|
"AcceleratorRange.TwoG": "The accelerator measures forces up to 2 gravity",
|
||||||
"AcceleratorRange.TwoG|block": "2g",
|
"AcceleratorRange.TwoG|block": "2g",
|
||||||
|
"Array.indexOf|block": "%list| find index of %value",
|
||||||
|
"Array.insertAt|block": "%list| insert at %index| value %value",
|
||||||
|
"Array.length|block": "length of %VALUE",
|
||||||
|
"Array.pop|block": "get and remove last value from %list",
|
||||||
|
"Array.push|block": "%list| add value %value| to end",
|
||||||
|
"Array.removeAt|block": "%list| remove value at %index",
|
||||||
|
"Array.reverse|block": "reverse %list",
|
||||||
|
"Array.shift|block": "get and remove first value from %list",
|
||||||
|
"Array.unshift|block": "%list| insert %value| at beginning",
|
||||||
|
"Array|block": "Array",
|
||||||
|
"ArrowNames.East|block": "East",
|
||||||
|
"ArrowNames.NorthEast|block": "North East",
|
||||||
|
"ArrowNames.NorthWest|block": "North West",
|
||||||
|
"ArrowNames.North|block": "North",
|
||||||
|
"ArrowNames.SouthEast|block": "South East",
|
||||||
|
"ArrowNames.SouthWest|block": "South West",
|
||||||
|
"ArrowNames.South|block": "South",
|
||||||
|
"ArrowNames.West|block": "West",
|
||||||
"BaudRate.BaudRate115200|block": "115200",
|
"BaudRate.BaudRate115200|block": "115200",
|
||||||
"BaudRate.BaudRate56700|block": "57600",
|
"BaudRate.BaudRate56700|block": "57600",
|
||||||
"BaudRate.BaudRate9600|block": "9600",
|
"BaudRate.BaudRate9600|block": "9600",
|
||||||
|
"BeatFraction.Breve|block": "4",
|
||||||
|
"BeatFraction.Double|block": "2",
|
||||||
"BeatFraction.Eighth|block": "1/8",
|
"BeatFraction.Eighth|block": "1/8",
|
||||||
"BeatFraction.Half|block": "1/2",
|
"BeatFraction.Half|block": "1/2",
|
||||||
"BeatFraction.Quarter|block": "1/4",
|
"BeatFraction.Quarter|block": "1/4",
|
||||||
@@ -41,6 +61,8 @@
|
|||||||
"DisplayMode.Greyscale|block": "greyscale",
|
"DisplayMode.Greyscale|block": "greyscale",
|
||||||
"EventCreationMode.CreateAndFire": "MicroBitEvent is initialised, and its event handlers are immediately fired (not suitable for use in interrupts!).",
|
"EventCreationMode.CreateAndFire": "MicroBitEvent is initialised, and its event handlers are immediately fired (not suitable for use in interrupts!).",
|
||||||
"EventCreationMode.CreateOnly": "MicroBitEvent is initialised, and no further processing takes place.",
|
"EventCreationMode.CreateOnly": "MicroBitEvent is initialised, and no further processing takes place.",
|
||||||
|
"Gesture.EightG": "Raised when a 8G shock is detected",
|
||||||
|
"Gesture.EightG|block": "8g",
|
||||||
"Gesture.FreeFall": "Raised when the board is falling!",
|
"Gesture.FreeFall": "Raised when the board is falling!",
|
||||||
"Gesture.FreeFall|block": "free fall",
|
"Gesture.FreeFall|block": "free fall",
|
||||||
"Gesture.LogoDown": "Raised when the logo is downward and the screen is vertical",
|
"Gesture.LogoDown": "Raised when the logo is downward and the screen is vertical",
|
||||||
@@ -79,12 +101,12 @@
|
|||||||
"IconNames.LeftTriangle|block": "left triangle",
|
"IconNames.LeftTriangle|block": "left triangle",
|
||||||
"IconNames.Meh|block": "meh",
|
"IconNames.Meh|block": "meh",
|
||||||
"IconNames.No|block": "no",
|
"IconNames.No|block": "no",
|
||||||
"IconNames.Pacman|block": "pac man",
|
|
||||||
"IconNames.Pitchfork|block": "pitchfork",
|
"IconNames.Pitchfork|block": "pitchfork",
|
||||||
"IconNames.QuarterNote|block": "quarter note",
|
"IconNames.QuarterNote|block": "quarter note",
|
||||||
"IconNames.Rabbit|block": "rabbit",
|
"IconNames.Rabbit|block": "rabbit",
|
||||||
"IconNames.Rollerskate|block": "roller skate",
|
"IconNames.Rollerskate|block": "roller skate",
|
||||||
"IconNames.Sad|block": "sad",
|
"IconNames.Sad|block": "sad",
|
||||||
|
"IconNames.Scissors|block": "scissors",
|
||||||
"IconNames.Silly|block": "silly",
|
"IconNames.Silly|block": "silly",
|
||||||
"IconNames.Skull|block": "skull",
|
"IconNames.Skull|block": "skull",
|
||||||
"IconNames.SmallDiamond|block": "small diamond",
|
"IconNames.SmallDiamond|block": "small diamond",
|
||||||
@@ -101,17 +123,70 @@
|
|||||||
"IconNames.Triangle|block": "triangle",
|
"IconNames.Triangle|block": "triangle",
|
||||||
"IconNames.Umbrella|block": "umbrella",
|
"IconNames.Umbrella|block": "umbrella",
|
||||||
"IconNames.Yes|block": "yes",
|
"IconNames.Yes|block": "yes",
|
||||||
|
"Image.scrollImage|block": "scroll image %sprite|with offset %frameoffset|and interval (ms) %delay",
|
||||||
|
"Image.showImage|block": "show image %sprite|at offset %offset",
|
||||||
"LedSpriteProperty.Blink|block": "blink",
|
"LedSpriteProperty.Blink|block": "blink",
|
||||||
"LedSpriteProperty.Brightness|block": "brightness",
|
"LedSpriteProperty.Brightness|block": "brightness",
|
||||||
"LedSpriteProperty.Direction|block": "direction",
|
"LedSpriteProperty.Direction|block": "direction",
|
||||||
"LedSpriteProperty.X|block": "x",
|
"LedSpriteProperty.X|block": "x",
|
||||||
"LedSpriteProperty.Y|block": "y",
|
"LedSpriteProperty.Y|block": "y",
|
||||||
"Math.randomBoolean|block": "pick random true or false",
|
"Math.randomBoolean|block": "pick random true or false",
|
||||||
|
"Math.random|block": "pick random 0 to %limit",
|
||||||
"Math|block": "Math",
|
"Math|block": "Math",
|
||||||
|
"Melodies.BaDing|block": "ba ding",
|
||||||
|
"Melodies.Baddy|block": "baddy",
|
||||||
|
"Melodies.Birthday|block": "birthday",
|
||||||
|
"Melodies.Blues|block": "blues",
|
||||||
|
"Melodies.Chase|block": "chase",
|
||||||
|
"Melodies.Dadadadum|block": "dadadum",
|
||||||
|
"Melodies.Entertainer|block": "entertainer",
|
||||||
|
"Melodies.Funeral|block": "funereal",
|
||||||
|
"Melodies.Funk|block": "funk",
|
||||||
|
"Melodies.JumpDown|block": "jump down",
|
||||||
|
"Melodies.JumpUp|block": "jump up",
|
||||||
|
"Melodies.Nyan|block": "nyan",
|
||||||
|
"Melodies.Ode|block": "ode",
|
||||||
|
"Melodies.PowerDown|block": "power down",
|
||||||
|
"Melodies.PowerUp|block": "power up",
|
||||||
|
"Melodies.Prelude|block": "prelude",
|
||||||
|
"Melodies.Punchline|block": "punchline",
|
||||||
|
"Melodies.Ringtone|block": "ringtone",
|
||||||
|
"Melodies.Wawawawaa|block": "wawawawaa",
|
||||||
|
"Melodies.Wedding|block": "wedding",
|
||||||
|
"MelodyOptions.ForeverInBackground|block": "forever in background",
|
||||||
|
"MelodyOptions.Forever|block": "forever",
|
||||||
|
"MelodyOptions.OnceInBackground|block": "once in background",
|
||||||
|
"MelodyOptions.Once|block": "once",
|
||||||
|
"MesDpadButtonInfo.ADown|block": "A down",
|
||||||
|
"MesDpadButtonInfo.AUp|block": "A up",
|
||||||
|
"MesDpadButtonInfo.BDown|block": "B down",
|
||||||
|
"MesDpadButtonInfo.BUp|block": "B up",
|
||||||
|
"MesDpadButtonInfo.CDown|block": "C down",
|
||||||
|
"MesDpadButtonInfo.CUp|block": "C up",
|
||||||
|
"MesDpadButtonInfo.DDown|block": "D down",
|
||||||
|
"MesDpadButtonInfo.DUp|block": "D up",
|
||||||
|
"MesDpadButtonInfo._1Down|block": "1 down",
|
||||||
|
"MesDpadButtonInfo._1Up|block": "1 up",
|
||||||
|
"MesDpadButtonInfo._2Down|block": "2 down",
|
||||||
|
"MesDpadButtonInfo._2Up|block": "2 up",
|
||||||
|
"MesDpadButtonInfo._3Down|block": "3 down",
|
||||||
|
"MesDpadButtonInfo._3Up|block": "3 up",
|
||||||
|
"MesDpadButtonInfo._4Down|block": "4 down",
|
||||||
|
"MesDpadButtonInfo._4Up|block": "4 up",
|
||||||
"Motor.AB|block": "A and B",
|
"Motor.AB|block": "A and B",
|
||||||
"MotorCommand.Break|block": "break",
|
"MotorCommand.Break|block": "break",
|
||||||
"MotorCommand.Coast|block": "coast",
|
"MotorCommand.Coast|block": "coast",
|
||||||
"MotorCommand.Sleep|block": "sleep",
|
"MotorCommand.Sleep|block": "sleep",
|
||||||
|
"MusicEvent.BackgroundMelodyEnded|block": "background melody ended",
|
||||||
|
"MusicEvent.BackgroundMelodyNotePlayed|block": "background melody note played",
|
||||||
|
"MusicEvent.BackgroundMelodyPaused|block": "background melody paused",
|
||||||
|
"MusicEvent.BackgroundMelodyRepeated|block": "background melody repeated",
|
||||||
|
"MusicEvent.BackgroundMelodyResumed|block": "background melody resumed",
|
||||||
|
"MusicEvent.BackgroundMelodyStarted|block": "background melody started",
|
||||||
|
"MusicEvent.MelodyEnded|block": "melody ended",
|
||||||
|
"MusicEvent.MelodyNotePlayed|block": "melody note played",
|
||||||
|
"MusicEvent.MelodyRepeated|block": "melody repeated",
|
||||||
|
"MusicEvent.MelodyStarted|block": "melody started",
|
||||||
"Note.CSharp3|block": "C#3",
|
"Note.CSharp3|block": "C#3",
|
||||||
"Note.CSharp4|block": "C#4",
|
"Note.CSharp4|block": "C#4",
|
||||||
"Note.CSharp5|block": "C#5",
|
"Note.CSharp5|block": "C#5",
|
||||||
@@ -145,6 +220,7 @@
|
|||||||
"basic.pause|block": "pause (ms) %pause",
|
"basic.pause|block": "pause (ms) %pause",
|
||||||
"basic.rgbw|block": "red %red|green %green|blue %blue|white %white",
|
"basic.rgbw|block": "red %red|green %green|blue %blue|white %white",
|
||||||
"basic.setLedColor|block": "set led to %color=color_id",
|
"basic.setLedColor|block": "set led to %color=color_id",
|
||||||
|
"basic.showArrow|block": "show arrow %i=device_arrow",
|
||||||
"basic.showIcon|block": "show icon %i",
|
"basic.showIcon|block": "show icon %i",
|
||||||
"basic.showLeds|block": "show leds",
|
"basic.showLeds|block": "show leds",
|
||||||
"basic.showNumber|block": "show|number %number",
|
"basic.showNumber|block": "show|number %number",
|
||||||
@@ -162,32 +238,51 @@
|
|||||||
"control.reset|block": "reset",
|
"control.reset|block": "reset",
|
||||||
"control.waitMicros|block": "wait (µs)%micros",
|
"control.waitMicros|block": "wait (µs)%micros",
|
||||||
"control|block": "control",
|
"control|block": "control",
|
||||||
|
"game.LedSprite.change|block": "%sprite|change %property|by %value",
|
||||||
|
"game.LedSprite.delete|block": "delete %this",
|
||||||
|
"game.LedSprite.get|block": "%sprite|%property",
|
||||||
|
"game.LedSprite.ifOnEdgeBounce|block": "%sprite|if on edge, bounce",
|
||||||
|
"game.LedSprite.isTouchingEdge|block": "%sprite|touching edge?",
|
||||||
|
"game.LedSprite.isTouching|block": "%sprite|touching %other|?",
|
||||||
|
"game.LedSprite.move|block": "%sprite|move by %leds",
|
||||||
|
"game.LedSprite.set|block": "%sprite|set %property|to %value",
|
||||||
|
"game.LedSprite.turn|block": "%sprite|turn %direction|by (°) %degrees",
|
||||||
"game.addScore|block": "change score by|%points",
|
"game.addScore|block": "change score by|%points",
|
||||||
"game.createSprite|block": "create sprite at|x: %x|y: %y",
|
"game.createSprite|block": "create sprite at|x: %x|y: %y",
|
||||||
"game.gameOver|block": "game over",
|
"game.gameOver|block": "game over",
|
||||||
|
"game.pause|block": "pause",
|
||||||
|
"game.resume|block": "resume",
|
||||||
"game.score|block": "score",
|
"game.score|block": "score",
|
||||||
|
"game.setScore|block": "set score %points",
|
||||||
"game.startCountdown|block": "start countdown|(ms) %duration",
|
"game.startCountdown|block": "start countdown|(ms) %duration",
|
||||||
"game|block": "game",
|
"game|block": "game",
|
||||||
|
"images.arrowImage|block": "arrow image %i=device_arrow",
|
||||||
|
"images.arrowNumber|block": "%arrow",
|
||||||
"images.createBigImage|block": "create big image",
|
"images.createBigImage|block": "create big image",
|
||||||
"images.createImage|block": "create image",
|
"images.createImage|block": "create image",
|
||||||
|
"images.iconImage|block": "icon image %i",
|
||||||
"images|block": "images",
|
"images|block": "images",
|
||||||
"input.acceleration|block": "acceleration (mg)|%NAME",
|
"input.acceleration|block": "acceleration (mg)|%NAME",
|
||||||
"input.buttonIsPressed|block": "button|%NAME|is pressed",
|
"input.buttonIsPressed|block": "button|%NAME|is pressed",
|
||||||
|
"input.calibrateCompass|block": "calibrate compass",
|
||||||
"input.compassHeading|block": "compass heading (°)",
|
"input.compassHeading|block": "compass heading (°)",
|
||||||
"input.lightLevel|block": "light level",
|
"input.lightLevel|block": "light level",
|
||||||
"input.magneticForce|block": "magnetic force (µT)|%NAME",
|
"input.magneticForce|block": "magnetic force (µT)|%NAME",
|
||||||
"input.onButtonPressed|block": "on button|%NAME|pressed",
|
"input.onButtonPressed|block": "on button|%NAME|pressed",
|
||||||
"input.onGesture|block": "on |%NAME",
|
"input.onGesture|block": "on |%NAME",
|
||||||
"input.onPinPressed|block": "on pin %NAME|pressed",
|
"input.onPinPressed|block": "on pin %name|pressed",
|
||||||
"input.onPinReleased|block": "on pin %NAME|released",
|
"input.onPinReleased|block": "on pin %NAME|released",
|
||||||
"input.pinIsPressed|block": "pin %NAME|is pressed",
|
"input.pinIsPressed|block": "pin %NAME|is pressed",
|
||||||
"input.rotation|block": "rotation (°)|%NAME",
|
"input.rotation|block": "rotation (°)|%NAME",
|
||||||
|
"input.runningTimeMicros|block": "running time (micros)",
|
||||||
"input.runningTime|block": "running time (ms)",
|
"input.runningTime|block": "running time (ms)",
|
||||||
"input.setAccelerometerRange|block": "set accelerometer|range %range",
|
"input.setAccelerometerRange|block": "set accelerometer|range %range",
|
||||||
"input.temperature|block": "temperature (°C)",
|
"input.temperature|block": "temperature (°C)",
|
||||||
"input|block": "input",
|
"input|block": "input",
|
||||||
"led.brightness|block": "brightness",
|
"led.brightness|block": "brightness",
|
||||||
|
"led.enable|block": "led enable %on",
|
||||||
"led.plotBarGraph|block": "plot bar graph of %value |up to %high",
|
"led.plotBarGraph|block": "plot bar graph of %value |up to %high",
|
||||||
|
"led.plotBrightness|block": "plot|x %x|y %y|brightness %brightness",
|
||||||
"led.plot|block": "plot|x %x|y %y",
|
"led.plot|block": "plot|x %x|y %y",
|
||||||
"led.point|block": "point|x %x|y %y",
|
"led.point|block": "point|x %x|y %y",
|
||||||
"led.setBrightness|block": "set brightness %value",
|
"led.setBrightness|block": "set brightness %value",
|
||||||
@@ -200,14 +295,18 @@
|
|||||||
"motors.motorPower|block": "motor on at %percent",
|
"motors.motorPower|block": "motor on at %percent",
|
||||||
"motors|block": "motors",
|
"motors|block": "motors",
|
||||||
"music.beat|block": "%fraction|beat",
|
"music.beat|block": "%fraction|beat",
|
||||||
|
"music.beginMelody|block": "start melody %melody=device_builtin_melody| repeating %options",
|
||||||
|
"music.builtInMelody|block": "%melody",
|
||||||
"music.changeTempoBy|block": "change tempo by (bpm)|%value",
|
"music.changeTempoBy|block": "change tempo by (bpm)|%value",
|
||||||
"music.noteFrequency|block": "%note",
|
"music.noteFrequency|block": "%note",
|
||||||
|
"music.onEvent|block": "music on %value",
|
||||||
"music.playTone|block": "play|tone %note=device_note|for %duration=device_beat",
|
"music.playTone|block": "play|tone %note=device_note|for %duration=device_beat",
|
||||||
"music.rest|block": "rest(ms)|%duration=device_beat",
|
"music.rest|block": "rest(ms)|%duration=device_beat",
|
||||||
"music.ringTone|block": "ring tone (Hz)|%note=device_note",
|
"music.ringTone|block": "ring tone (Hz)|%note=device_note",
|
||||||
"music.setTempo|block": "set tempo to (bpm)|%value",
|
"music.setTempo|block": "set tempo to (bpm)|%value",
|
||||||
"music.tempo|block": "tempo (bpm)",
|
"music.tempo|block": "tempo (bpm)",
|
||||||
"music|block": "music",
|
"music|block": "music",
|
||||||
|
"parseInt|block": "parse to integer %text",
|
||||||
"pins.analogPitch|block": "analog pitch %frequency|for (ms) %ms",
|
"pins.analogPitch|block": "analog pitch %frequency|for (ms) %ms",
|
||||||
"pins.analogReadPin|block": "analog read|pin %name",
|
"pins.analogReadPin|block": "analog read|pin %name",
|
||||||
"pins.analogSetPeriod|block": "analog set period|pin %pin|to (µs)%micros",
|
"pins.analogSetPeriod|block": "analog set period|pin %pin|to (µs)%micros",
|
||||||
@@ -215,8 +314,8 @@
|
|||||||
"pins.analogWritePin|block": "analog write|pin %name|to %value",
|
"pins.analogWritePin|block": "analog write|pin %name|to %value",
|
||||||
"pins.digitalReadPin|block": "digital read|pin %name",
|
"pins.digitalReadPin|block": "digital read|pin %name",
|
||||||
"pins.digitalWritePin|block": "digital write|pin %name|to %value",
|
"pins.digitalWritePin|block": "digital write|pin %name|to %value",
|
||||||
"pins.i2cReadNumber|block": "i2c read number|at address %address|of format %format=i2c_sizeof",
|
"pins.i2cReadNumber|block": "i2c read number|at address %address|of format %format=i2c_sizeof|repeat %repeat",
|
||||||
"pins.i2cWriteNumber|block": "i2c write number|at address %address|with value %value|of format %format=i2c_sizeof",
|
"pins.i2cWriteNumber|block": "i2c write number|at address %address|with value %value|of format %format=i2c_sizeof|repeat %repeat",
|
||||||
"pins.map|block": "map %value|from low %fromLow|from high %fromHigh|to low %toLow|to high %toHigh",
|
"pins.map|block": "map %value|from low %fromLow|from high %fromHigh|to low %toLow|to high %toHigh",
|
||||||
"pins.onPulsed|block": "on|pin %pin|pulsed %pulse",
|
"pins.onPulsed|block": "on|pin %pin|pulsed %pulse",
|
||||||
"pins.pulseDuration|block": "pulse duration (µs)",
|
"pins.pulseDuration|block": "pulse duration (µs)",
|
||||||
@@ -225,6 +324,9 @@
|
|||||||
"pins.servoWritePin|block": "servo write|pin %name|to %value",
|
"pins.servoWritePin|block": "servo write|pin %name|to %value",
|
||||||
"pins.setEvents|block": "set pin %pin|to emit %type|events",
|
"pins.setEvents|block": "set pin %pin|to emit %type|events",
|
||||||
"pins.setPull|block": "set pull|pin %pin|to %pull",
|
"pins.setPull|block": "set pull|pin %pin|to %pull",
|
||||||
|
"pins.spiFormat|block": "spi format|bits %bits|mode %mode",
|
||||||
|
"pins.spiFrequency|block": "spi frequency %frequency",
|
||||||
|
"pins.spiPins|block": "spi set pins|MOSI %mosi|MISO %miso|SCK %sck",
|
||||||
"pins.spiWrite|block": "spi write %value",
|
"pins.spiWrite|block": "spi write %value",
|
||||||
"pins|block": "pins",
|
"pins|block": "pins",
|
||||||
"serial.delimiters|block": "%del",
|
"serial.delimiters|block": "%del",
|
||||||
@@ -238,15 +340,23 @@
|
|||||||
"serial.writeString|block": "serial|write string %text",
|
"serial.writeString|block": "serial|write string %text",
|
||||||
"serial.writeValue|block": "serial|write value %name|= %value",
|
"serial.writeValue|block": "serial|write value %name|= %value",
|
||||||
"serial|block": "serial",
|
"serial|block": "serial",
|
||||||
|
"{id:category}Array": "Array",
|
||||||
|
"{id:category}Arrays": "Arrays",
|
||||||
"{id:category}Basic": "Basic",
|
"{id:category}Basic": "Basic",
|
||||||
|
"{id:category}Boolean": "Boolean",
|
||||||
|
"{id:category}Buffer": "Buffer",
|
||||||
|
"{id:category}Console": "Console",
|
||||||
"{id:category}Control": "Control",
|
"{id:category}Control": "Control",
|
||||||
"{id:category}Game": "Game",
|
"{id:category}Game": "Game",
|
||||||
|
"{id:category}Helpers": "Helpers",
|
||||||
|
"{id:category}Image": "Image",
|
||||||
"{id:category}Images": "Images",
|
"{id:category}Images": "Images",
|
||||||
"{id:category}Input": "Input",
|
"{id:category}Input": "Input",
|
||||||
"{id:category}Led": "Led",
|
"{id:category}Led": "Led",
|
||||||
"{id:category}Math": "Math",
|
"{id:category}Math": "Math",
|
||||||
"{id:category}Motors": "Motors",
|
"{id:category}Motors": "Motors",
|
||||||
"{id:category}Music": "Music",
|
"{id:category}Music": "Music",
|
||||||
|
"{id:category}Number": "Number",
|
||||||
"{id:category}Pins": "Pins",
|
"{id:category}Pins": "Pins",
|
||||||
"{id:category}Serial": "Serial",
|
"{id:category}Serial": "Serial",
|
||||||
"{id:category}String": "String",
|
"{id:category}String": "String",
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
*/
|
*/
|
||||||
//% color=#54C9C9 weight=100 icon="\uf00a"
|
//% color=#54C9C9 weight=100 icon="\uf00a"
|
||||||
namespace basic {
|
namespace basic {
|
||||||
/**
|
/**
|
||||||
* Sets the color on the build-in LED. Set to 0 to turn off.
|
* Sets the color on the build-in LED. Set to 0 to turn off.
|
||||||
*/
|
*/
|
||||||
//% blockId=device_set_led_color block="set led to %color=color_id"
|
//% blockId=device_set_led_color block="set led to %color=color_id"
|
||||||
@@ -34,10 +34,9 @@ namespace basic {
|
|||||||
//% blockId=device_show_number block="show|number %number" blockGap=8
|
//% blockId=device_show_number block="show|number %number" blockGap=8
|
||||||
//% async
|
//% async
|
||||||
//% parts="ledmatrix"
|
//% parts="ledmatrix"
|
||||||
void showNumber(int value, int interval = 150) {
|
void showNumber(int value, int interval = 150) {
|
||||||
if (interval < 0)
|
if (interval <= 0)
|
||||||
return;
|
interval = 1;
|
||||||
|
|
||||||
ManagedString t(value);
|
ManagedString t(value);
|
||||||
if (value < 0 || value >= 10) {
|
if (value < 0 || value >= 10) {
|
||||||
uBit.display.scroll(t, interval);
|
uBit.display.scroll(t, interval);
|
||||||
@@ -51,11 +50,11 @@ namespace basic {
|
|||||||
* @param leds the pattern of LED to turn on/off
|
* @param leds the pattern of LED to turn on/off
|
||||||
* @param interval time in milliseconds to pause after drawing
|
* @param interval time in milliseconds to pause after drawing
|
||||||
*/
|
*/
|
||||||
//% help=basic/show-leds
|
//% help=basic/show-leds
|
||||||
//% weight=95 blockGap=8
|
//% weight=95 blockGap=8
|
||||||
//% imageLiteral=1 async
|
//% imageLiteral=1 async
|
||||||
//% blockId=device_show_leds
|
//% blockId=device_show_leds
|
||||||
//% block="show leds"
|
//% block="show leds" icon="\uf00a"
|
||||||
//% parts="ledmatrix"
|
//% parts="ledmatrix"
|
||||||
void showLeds(ImageLiteral leds, int interval = 400) {
|
void showLeds(ImageLiteral leds, int interval = 400) {
|
||||||
uBit.display.print(MicroBitImage(imageBytes(leds)), 0, 0, 0, interval);
|
uBit.display.print(MicroBitImage(imageBytes(leds)), 0, 0, 0, interval);
|
||||||
@@ -66,15 +65,15 @@ namespace basic {
|
|||||||
* @param text the text to scroll on the screen, eg: "Hello!"
|
* @param text the text to scroll on the screen, eg: "Hello!"
|
||||||
* @param interval how fast to shift characters; eg: 150, 100, 200, -100
|
* @param interval how fast to shift characters; eg: 150, 100, 200, -100
|
||||||
*/
|
*/
|
||||||
//% help=basic/show-string
|
//% help=basic/show-string
|
||||||
//% weight=87 blockGap=8
|
//% weight=87 blockGap=8
|
||||||
//% block="show|string %text"
|
//% block="show|string %text"
|
||||||
//% async
|
//% async
|
||||||
//% blockId=device_print_message
|
//% blockId=device_print_message
|
||||||
//% parts="ledmatrix"
|
//% parts="ledmatrix"
|
||||||
void showString(StringData *text, int interval = 150) {
|
void showString(StringData *text, int interval = 150) {
|
||||||
if (interval < 0)
|
if (interval <= 0)
|
||||||
return;
|
interval = 1;
|
||||||
ManagedString s(text);
|
ManagedString s(text);
|
||||||
int l = s.length();
|
int l = s.length();
|
||||||
if (l == 0) {
|
if (l == 0) {
|
||||||
@@ -93,6 +92,7 @@ namespace basic {
|
|||||||
//% help=basic/clear-screen weight=79
|
//% help=basic/clear-screen weight=79
|
||||||
//% blockId=device_clear_display block="clear screen"
|
//% blockId=device_clear_display block="clear screen"
|
||||||
//% parts="ledmatrix"
|
//% parts="ledmatrix"
|
||||||
|
//% advanced=true
|
||||||
void clearScreen() {
|
void clearScreen() {
|
||||||
uBit.display.image.clear();
|
uBit.display.image.clear();
|
||||||
}
|
}
|
||||||
@@ -105,7 +105,7 @@ namespace basic {
|
|||||||
//% help=basic/show-animation imageLiteral=1 async
|
//% help=basic/show-animation imageLiteral=1 async
|
||||||
//% parts="ledmatrix"
|
//% parts="ledmatrix"
|
||||||
void showAnimation(ImageLiteral leds, int interval = 400) {
|
void showAnimation(ImageLiteral leds, int interval = 400) {
|
||||||
uBit.display.animate(MicroBitImage(imageBytes(leds)), interval, 5, 0);
|
uBit.display.animate(MicroBitImage(imageBytes(leds)), interval, 5, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -130,8 +130,8 @@ namespace basic {
|
|||||||
* Repeats the code forever in the background. On each iteration, allows other codes to run.
|
* Repeats the code forever in the background. On each iteration, allows other codes to run.
|
||||||
* @param body code to execute
|
* @param body code to execute
|
||||||
*/
|
*/
|
||||||
//% help=basic/forever weight=55 blockGap=8
|
//% help=basic/forever weight=55 blockGap=8 blockAllowMultiple=1 afterOnStart=true
|
||||||
//% blockId=device_forever block="forever"
|
//% blockId=device_forever block="forever" icon="\uf01e"
|
||||||
void forever(Action a) {
|
void forever(Action a) {
|
||||||
if (a != 0) {
|
if (a != 0) {
|
||||||
incr(a);
|
incr(a);
|
||||||
@@ -145,7 +145,7 @@ namespace basic {
|
|||||||
*/
|
*/
|
||||||
//% help=basic/pause weight=54
|
//% help=basic/pause weight=54
|
||||||
//% async block="pause (ms) %pause"
|
//% async block="pause (ms) %pause"
|
||||||
//% blockId=device_pause
|
//% blockId=device_pause icon="\uf110"
|
||||||
void pause(int ms) {
|
void pause(int ms) {
|
||||||
fiber_sleep(ms);
|
fiber_sleep(ms);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,97 +20,190 @@ enum class EventCreationMode {
|
|||||||
// TODO shouldn't these be renamed to something more sensible anyways?
|
// TODO shouldn't these be renamed to something more sensible anyways?
|
||||||
|
|
||||||
enum EventBusSource {
|
enum EventBusSource {
|
||||||
|
//% blockIdentity="control.eventSourceId"
|
||||||
MICROBIT_ID_BUTTON_A_ = MICROBIT_ID_BUTTON_A,
|
MICROBIT_ID_BUTTON_A_ = MICROBIT_ID_BUTTON_A,
|
||||||
|
//% blockIdentity="control.eventSourceId"
|
||||||
MICROBIT_ID_BUTTON_B_ = MICROBIT_ID_BUTTON_B,
|
MICROBIT_ID_BUTTON_B_ = MICROBIT_ID_BUTTON_B,
|
||||||
|
//% blockIdentity="control.eventSourceId"
|
||||||
MICROBIT_ID_BUTTON_AB_ = MICROBIT_ID_BUTTON_AB,
|
MICROBIT_ID_BUTTON_AB_ = MICROBIT_ID_BUTTON_AB,
|
||||||
|
//% blockIdentity="control.eventSourceId"
|
||||||
MICROBIT_ID_RADIO_ = MICROBIT_ID_RADIO,
|
MICROBIT_ID_RADIO_ = MICROBIT_ID_RADIO,
|
||||||
|
//% blockIdentity="control.eventSourceId"
|
||||||
MICROBIT_ID_GESTURE_ = MICROBIT_ID_GESTURE,
|
MICROBIT_ID_GESTURE_ = MICROBIT_ID_GESTURE,
|
||||||
|
//% blockIdentity="control.eventSourceId"
|
||||||
MICROBIT_ID_ACCELEROMETER_ = MICROBIT_ID_ACCELEROMETER,
|
MICROBIT_ID_ACCELEROMETER_ = MICROBIT_ID_ACCELEROMETER,
|
||||||
|
//% blockIdentity="control.eventSourceId"
|
||||||
MICROBIT_ID_IO_P0_ = MICROBIT_ID_IO_P0,
|
MICROBIT_ID_IO_P0_ = MICROBIT_ID_IO_P0,
|
||||||
|
//% blockIdentity="control.eventSourceId"
|
||||||
MICROBIT_ID_IO_P1_ = MICROBIT_ID_IO_P1,
|
MICROBIT_ID_IO_P1_ = MICROBIT_ID_IO_P1,
|
||||||
|
//% blockIdentity="control.eventSourceId"
|
||||||
MICROBIT_ID_IO_P2_ = MICROBIT_ID_IO_P2,
|
MICROBIT_ID_IO_P2_ = MICROBIT_ID_IO_P2,
|
||||||
|
//% blockIdentity="control.eventSourceId"
|
||||||
MICROBIT_ID_IO_P3_ = MICROBIT_ID_IO_P3,
|
MICROBIT_ID_IO_P3_ = MICROBIT_ID_IO_P3,
|
||||||
|
//% blockIdentity="control.eventSourceId"
|
||||||
MICROBIT_ID_IO_P4_ = MICROBIT_ID_IO_P4,
|
MICROBIT_ID_IO_P4_ = MICROBIT_ID_IO_P4,
|
||||||
|
//% blockIdentity="control.eventSourceId"
|
||||||
MICROBIT_ID_IO_P5_ = MICROBIT_ID_IO_P5,
|
MICROBIT_ID_IO_P5_ = MICROBIT_ID_IO_P5,
|
||||||
|
//% blockIdentity="control.eventSourceId"
|
||||||
MICROBIT_ID_IO_P6_ = MICROBIT_ID_IO_P6,
|
MICROBIT_ID_IO_P6_ = MICROBIT_ID_IO_P6,
|
||||||
|
//% blockIdentity="control.eventSourceId"
|
||||||
MICROBIT_ID_IO_P7_ = MICROBIT_ID_IO_P7,
|
MICROBIT_ID_IO_P7_ = MICROBIT_ID_IO_P7,
|
||||||
|
//% blockIdentity="control.eventSourceId"
|
||||||
MICROBIT_ID_IO_P8_ = MICROBIT_ID_IO_P8,
|
MICROBIT_ID_IO_P8_ = MICROBIT_ID_IO_P8,
|
||||||
|
//% blockIdentity="control.eventSourceId"
|
||||||
MICROBIT_ID_IO_P9_ = MICROBIT_ID_IO_P9,
|
MICROBIT_ID_IO_P9_ = MICROBIT_ID_IO_P9,
|
||||||
|
//% blockIdentity="control.eventSourceId"
|
||||||
MICROBIT_ID_IO_P10_ = MICROBIT_ID_IO_P10,
|
MICROBIT_ID_IO_P10_ = MICROBIT_ID_IO_P10,
|
||||||
|
//% blockIdentity="control.eventSourceId"
|
||||||
MICROBIT_ID_IO_P11_ = MICROBIT_ID_IO_P11,
|
MICROBIT_ID_IO_P11_ = MICROBIT_ID_IO_P11,
|
||||||
|
//% blockIdentity="control.eventSourceId"
|
||||||
MICROBIT_ID_IO_P12_ = MICROBIT_ID_IO_P12,
|
MICROBIT_ID_IO_P12_ = MICROBIT_ID_IO_P12,
|
||||||
|
//% blockIdentity="control.eventSourceId"
|
||||||
MICROBIT_ID_IO_P13_ = MICROBIT_ID_IO_P13,
|
MICROBIT_ID_IO_P13_ = MICROBIT_ID_IO_P13,
|
||||||
|
//% blockIdentity="control.eventSourceId"
|
||||||
MICROBIT_ID_IO_P14_ = MICROBIT_ID_IO_P14,
|
MICROBIT_ID_IO_P14_ = MICROBIT_ID_IO_P14,
|
||||||
|
//% blockIdentity="control.eventSourceId"
|
||||||
MICROBIT_ID_IO_P15_ = MICROBIT_ID_IO_P15,
|
MICROBIT_ID_IO_P15_ = MICROBIT_ID_IO_P15,
|
||||||
|
//% blockIdentity="control.eventSourceId"
|
||||||
MICROBIT_ID_IO_P16_ = MICROBIT_ID_IO_P16,
|
MICROBIT_ID_IO_P16_ = MICROBIT_ID_IO_P16,
|
||||||
|
//% blockIdentity="control.eventSourceId"
|
||||||
MICROBIT_ID_IO_P19_ = MICROBIT_ID_IO_P19,
|
MICROBIT_ID_IO_P19_ = MICROBIT_ID_IO_P19,
|
||||||
|
//% blockIdentity="control.eventSourceId"
|
||||||
MICROBIT_ID_IO_P20_ = MICROBIT_ID_IO_P20,
|
MICROBIT_ID_IO_P20_ = MICROBIT_ID_IO_P20,
|
||||||
|
//% blockIdentity="control.eventSourceId"
|
||||||
MICROBIT_ID_IO_P21_ = MICROBIT_ID_IO_P21,
|
MICROBIT_ID_IO_P21_ = MICROBIT_ID_IO_P21,
|
||||||
|
//% blockIdentity="control.eventSourceId"
|
||||||
MES_DEVICE_INFO_ID_ = MES_DEVICE_INFO_ID,
|
MES_DEVICE_INFO_ID_ = MES_DEVICE_INFO_ID,
|
||||||
|
//% blockIdentity="control.eventSourceId"
|
||||||
MES_SIGNAL_STRENGTH_ID_ = MES_SIGNAL_STRENGTH_ID,
|
MES_SIGNAL_STRENGTH_ID_ = MES_SIGNAL_STRENGTH_ID,
|
||||||
|
//% blockIdentity="control.eventSourceId"
|
||||||
MES_DPAD_CONTROLLER_ID_ = MES_DPAD_CONTROLLER_ID,
|
MES_DPAD_CONTROLLER_ID_ = MES_DPAD_CONTROLLER_ID,
|
||||||
|
//% blockIdentity="control.eventSourceId"
|
||||||
MES_BROADCAST_GENERAL_ID_ = MES_BROADCAST_GENERAL_ID,
|
MES_BROADCAST_GENERAL_ID_ = MES_BROADCAST_GENERAL_ID,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum EventBusValue {
|
enum EventBusValue {
|
||||||
|
//% blockIdentity="control.eventValueId"
|
||||||
MICROBIT_EVT_ANY_ = MICROBIT_EVT_ANY,
|
MICROBIT_EVT_ANY_ = MICROBIT_EVT_ANY,
|
||||||
|
//% blockIdentity="control.eventValueId"
|
||||||
|
MICROBIT_BUTTON_EVT_DOWN_ = MICROBIT_BUTTON_EVT_DOWN,
|
||||||
|
//% blockIdentity="control.eventValueId"
|
||||||
|
MICROBIT_BUTTON_EVT_UP_ = MICROBIT_BUTTON_EVT_UP,
|
||||||
|
//% blockIdentity="control.eventValueId"
|
||||||
MICROBIT_BUTTON_EVT_CLICK_ = MICROBIT_BUTTON_EVT_CLICK,
|
MICROBIT_BUTTON_EVT_CLICK_ = MICROBIT_BUTTON_EVT_CLICK,
|
||||||
|
//% blockIdentity="control.eventValueId"
|
||||||
MICROBIT_RADIO_EVT_DATAGRAM_ = MICROBIT_RADIO_EVT_DATAGRAM,
|
MICROBIT_RADIO_EVT_DATAGRAM_ = MICROBIT_RADIO_EVT_DATAGRAM,
|
||||||
|
//% blockIdentity="control.eventValueId"
|
||||||
MICROBIT_ACCELEROMETER_EVT_DATA_UPDATE_ = MICROBIT_ACCELEROMETER_EVT_DATA_UPDATE,
|
MICROBIT_ACCELEROMETER_EVT_DATA_UPDATE_ = MICROBIT_ACCELEROMETER_EVT_DATA_UPDATE,
|
||||||
|
//% blockIdentity="control.eventValueId"
|
||||||
MICROBIT_PIN_EVT_RISE_ = MICROBIT_PIN_EVT_RISE,
|
MICROBIT_PIN_EVT_RISE_ = MICROBIT_PIN_EVT_RISE,
|
||||||
|
//% blockIdentity="control.eventValueId"
|
||||||
MICROBIT_PIN_EVT_FALL_ = MICROBIT_PIN_EVT_FALL,
|
MICROBIT_PIN_EVT_FALL_ = MICROBIT_PIN_EVT_FALL,
|
||||||
|
//% blockIdentity="control.eventValueId"
|
||||||
MICROBIT_PIN_EVT_PULSE_HI_ = MICROBIT_PIN_EVT_PULSE_HI,
|
MICROBIT_PIN_EVT_PULSE_HI_ = MICROBIT_PIN_EVT_PULSE_HI,
|
||||||
|
//% blockIdentity="control.eventValueId"
|
||||||
MICROBIT_PIN_EVT_PULSE_LO_ = MICROBIT_PIN_EVT_PULSE_LO,
|
MICROBIT_PIN_EVT_PULSE_LO_ = MICROBIT_PIN_EVT_PULSE_LO,
|
||||||
|
//% blockIdentity="control.eventValueId"
|
||||||
MES_ALERT_EVT_ALARM1_ = MES_ALERT_EVT_ALARM1,
|
MES_ALERT_EVT_ALARM1_ = MES_ALERT_EVT_ALARM1,
|
||||||
|
//% blockIdentity="control.eventValueId"
|
||||||
MES_ALERT_EVT_ALARM2_ = MES_ALERT_EVT_ALARM2,
|
MES_ALERT_EVT_ALARM2_ = MES_ALERT_EVT_ALARM2,
|
||||||
|
//% blockIdentity="control.eventValueId"
|
||||||
MES_ALERT_EVT_ALARM3_ = MES_ALERT_EVT_ALARM3,
|
MES_ALERT_EVT_ALARM3_ = MES_ALERT_EVT_ALARM3,
|
||||||
|
//% blockIdentity="control.eventValueId"
|
||||||
MES_ALERT_EVT_ALARM4_ = MES_ALERT_EVT_ALARM4,
|
MES_ALERT_EVT_ALARM4_ = MES_ALERT_EVT_ALARM4,
|
||||||
|
//% blockIdentity="control.eventValueId"
|
||||||
MES_ALERT_EVT_ALARM5_ = MES_ALERT_EVT_ALARM5,
|
MES_ALERT_EVT_ALARM5_ = MES_ALERT_EVT_ALARM5,
|
||||||
|
//% blockIdentity="control.eventValueId"
|
||||||
MES_ALERT_EVT_ALARM6_ = MES_ALERT_EVT_ALARM6,
|
MES_ALERT_EVT_ALARM6_ = MES_ALERT_EVT_ALARM6,
|
||||||
|
//% blockIdentity="control.eventValueId"
|
||||||
MES_ALERT_EVT_DISPLAY_TOAST_ = MES_ALERT_EVT_DISPLAY_TOAST,
|
MES_ALERT_EVT_DISPLAY_TOAST_ = MES_ALERT_EVT_DISPLAY_TOAST,
|
||||||
|
//% blockIdentity="control.eventValueId"
|
||||||
MES_ALERT_EVT_FIND_MY_PHONE_ = MES_ALERT_EVT_FIND_MY_PHONE,
|
MES_ALERT_EVT_FIND_MY_PHONE_ = MES_ALERT_EVT_FIND_MY_PHONE,
|
||||||
|
//% blockIdentity="control.eventValueId"
|
||||||
MES_ALERT_EVT_PLAY_RINGTONE_ = MES_ALERT_EVT_PLAY_RINGTONE,
|
MES_ALERT_EVT_PLAY_RINGTONE_ = MES_ALERT_EVT_PLAY_RINGTONE,
|
||||||
|
//% blockIdentity="control.eventValueId"
|
||||||
MES_ALERT_EVT_PLAY_SOUND_ = MES_ALERT_EVT_PLAY_SOUND,
|
MES_ALERT_EVT_PLAY_SOUND_ = MES_ALERT_EVT_PLAY_SOUND,
|
||||||
|
//% blockIdentity="control.eventValueId"
|
||||||
MES_ALERT_EVT_VIBRATE_ = MES_ALERT_EVT_VIBRATE,
|
MES_ALERT_EVT_VIBRATE_ = MES_ALERT_EVT_VIBRATE,
|
||||||
|
//% blockIdentity="control.eventValueId"
|
||||||
MES_CAMERA_EVT_LAUNCH_PHOTO_MODE_ = MES_CAMERA_EVT_LAUNCH_PHOTO_MODE,
|
MES_CAMERA_EVT_LAUNCH_PHOTO_MODE_ = MES_CAMERA_EVT_LAUNCH_PHOTO_MODE,
|
||||||
|
//% blockIdentity="control.eventValueId"
|
||||||
MES_CAMERA_EVT_LAUNCH_VIDEO_MODE_ = MES_CAMERA_EVT_LAUNCH_VIDEO_MODE,
|
MES_CAMERA_EVT_LAUNCH_VIDEO_MODE_ = MES_CAMERA_EVT_LAUNCH_VIDEO_MODE,
|
||||||
|
//% blockIdentity="control.eventValueId"
|
||||||
MES_CAMERA_EVT_START_VIDEO_CAPTURE_ = MES_CAMERA_EVT_START_VIDEO_CAPTURE,
|
MES_CAMERA_EVT_START_VIDEO_CAPTURE_ = MES_CAMERA_EVT_START_VIDEO_CAPTURE,
|
||||||
|
//% blockIdentity="control.eventValueId"
|
||||||
MES_CAMERA_EVT_STOP_PHOTO_MODE_ = MES_CAMERA_EVT_STOP_PHOTO_MODE,
|
MES_CAMERA_EVT_STOP_PHOTO_MODE_ = MES_CAMERA_EVT_STOP_PHOTO_MODE,
|
||||||
|
//% blockIdentity="control.eventValueId"
|
||||||
MES_CAMERA_EVT_STOP_VIDEO_CAPTURE_ = MES_CAMERA_EVT_STOP_VIDEO_CAPTURE,
|
MES_CAMERA_EVT_STOP_VIDEO_CAPTURE_ = MES_CAMERA_EVT_STOP_VIDEO_CAPTURE,
|
||||||
|
//% blockIdentity="control.eventValueId"
|
||||||
MES_CAMERA_EVT_STOP_VIDEO_MODE_ = MES_CAMERA_EVT_STOP_VIDEO_MODE,
|
MES_CAMERA_EVT_STOP_VIDEO_MODE_ = MES_CAMERA_EVT_STOP_VIDEO_MODE,
|
||||||
|
//% blockIdentity="control.eventValueId"
|
||||||
MES_CAMERA_EVT_TAKE_PHOTO_ = MES_CAMERA_EVT_TAKE_PHOTO,
|
MES_CAMERA_EVT_TAKE_PHOTO_ = MES_CAMERA_EVT_TAKE_PHOTO,
|
||||||
|
//% blockIdentity="control.eventValueId"
|
||||||
MES_CAMERA_EVT_TOGGLE_FRONT_REAR_ = MES_CAMERA_EVT_TOGGLE_FRONT_REAR,
|
MES_CAMERA_EVT_TOGGLE_FRONT_REAR_ = MES_CAMERA_EVT_TOGGLE_FRONT_REAR,
|
||||||
|
//% blockIdentity="control.eventValueId"
|
||||||
MES_DEVICE_DISPLAY_OFF_ = MES_DEVICE_DISPLAY_OFF,
|
MES_DEVICE_DISPLAY_OFF_ = MES_DEVICE_DISPLAY_OFF,
|
||||||
|
//% blockIdentity="control.eventValueId"
|
||||||
MES_DEVICE_DISPLAY_ON_ = MES_DEVICE_DISPLAY_ON,
|
MES_DEVICE_DISPLAY_ON_ = MES_DEVICE_DISPLAY_ON,
|
||||||
|
//% blockIdentity="control.eventValueId"
|
||||||
MES_DEVICE_GESTURE_DEVICE_SHAKEN_ = MES_DEVICE_GESTURE_DEVICE_SHAKEN,
|
MES_DEVICE_GESTURE_DEVICE_SHAKEN_ = MES_DEVICE_GESTURE_DEVICE_SHAKEN,
|
||||||
|
//% blockIdentity="control.eventValueId"
|
||||||
MES_DEVICE_INCOMING_CALL_ = MES_DEVICE_INCOMING_CALL,
|
MES_DEVICE_INCOMING_CALL_ = MES_DEVICE_INCOMING_CALL,
|
||||||
|
//% blockIdentity="control.eventValueId"
|
||||||
MES_DEVICE_INCOMING_MESSAGE_ = MES_DEVICE_INCOMING_MESSAGE,
|
MES_DEVICE_INCOMING_MESSAGE_ = MES_DEVICE_INCOMING_MESSAGE,
|
||||||
|
//% blockIdentity="control.eventValueId"
|
||||||
MES_DEVICE_ORIENTATION_LANDSCAPE_ = MES_DEVICE_ORIENTATION_LANDSCAPE,
|
MES_DEVICE_ORIENTATION_LANDSCAPE_ = MES_DEVICE_ORIENTATION_LANDSCAPE,
|
||||||
|
//% blockIdentity="control.eventValueId"
|
||||||
MES_DEVICE_ORIENTATION_PORTRAIT_ = MES_DEVICE_ORIENTATION_PORTRAIT,
|
MES_DEVICE_ORIENTATION_PORTRAIT_ = MES_DEVICE_ORIENTATION_PORTRAIT,
|
||||||
|
//% blockIdentity="control.eventValueId"
|
||||||
MES_DPAD_BUTTON_1_DOWN_ = MES_DPAD_BUTTON_1_DOWN,
|
MES_DPAD_BUTTON_1_DOWN_ = MES_DPAD_BUTTON_1_DOWN,
|
||||||
|
//% blockIdentity="control.eventValueId"
|
||||||
MES_DPAD_BUTTON_1_UP_ = MES_DPAD_BUTTON_1_UP,
|
MES_DPAD_BUTTON_1_UP_ = MES_DPAD_BUTTON_1_UP,
|
||||||
|
//% blockIdentity="control.eventValueId"
|
||||||
MES_DPAD_BUTTON_2_DOWN_ = MES_DPAD_BUTTON_2_DOWN,
|
MES_DPAD_BUTTON_2_DOWN_ = MES_DPAD_BUTTON_2_DOWN,
|
||||||
|
//% blockIdentity="control.eventValueId"
|
||||||
MES_DPAD_BUTTON_2_UP_ = MES_DPAD_BUTTON_2_UP,
|
MES_DPAD_BUTTON_2_UP_ = MES_DPAD_BUTTON_2_UP,
|
||||||
|
//% blockIdentity="control.eventValueId"
|
||||||
MES_DPAD_BUTTON_3_DOWN_ = MES_DPAD_BUTTON_3_DOWN,
|
MES_DPAD_BUTTON_3_DOWN_ = MES_DPAD_BUTTON_3_DOWN,
|
||||||
|
//% blockIdentity="control.eventValueId"
|
||||||
MES_DPAD_BUTTON_3_UP_ = MES_DPAD_BUTTON_3_UP,
|
MES_DPAD_BUTTON_3_UP_ = MES_DPAD_BUTTON_3_UP,
|
||||||
|
//% blockIdentity="control.eventValueId"
|
||||||
MES_DPAD_BUTTON_4_DOWN_ = MES_DPAD_BUTTON_4_DOWN,
|
MES_DPAD_BUTTON_4_DOWN_ = MES_DPAD_BUTTON_4_DOWN,
|
||||||
|
//% blockIdentity="control.eventValueId"
|
||||||
MES_DPAD_BUTTON_4_UP_ = MES_DPAD_BUTTON_4_UP,
|
MES_DPAD_BUTTON_4_UP_ = MES_DPAD_BUTTON_4_UP,
|
||||||
|
//% blockIdentity="control.eventValueId"
|
||||||
MES_DPAD_BUTTON_A_DOWN_ = MES_DPAD_BUTTON_A_DOWN,
|
MES_DPAD_BUTTON_A_DOWN_ = MES_DPAD_BUTTON_A_DOWN,
|
||||||
|
//% blockIdentity="control.eventValueId"
|
||||||
MES_DPAD_BUTTON_A_UP_ = MES_DPAD_BUTTON_A_UP,
|
MES_DPAD_BUTTON_A_UP_ = MES_DPAD_BUTTON_A_UP,
|
||||||
|
//% blockIdentity="control.eventValueId"
|
||||||
MES_DPAD_BUTTON_B_DOWN_ = MES_DPAD_BUTTON_B_DOWN,
|
MES_DPAD_BUTTON_B_DOWN_ = MES_DPAD_BUTTON_B_DOWN,
|
||||||
|
//% blockIdentity="control.eventValueId"
|
||||||
MES_DPAD_BUTTON_B_UP_ = MES_DPAD_BUTTON_B_UP,
|
MES_DPAD_BUTTON_B_UP_ = MES_DPAD_BUTTON_B_UP,
|
||||||
|
//% blockIdentity="control.eventValueId"
|
||||||
MES_DPAD_BUTTON_C_DOWN_ = MES_DPAD_BUTTON_C_DOWN,
|
MES_DPAD_BUTTON_C_DOWN_ = MES_DPAD_BUTTON_C_DOWN,
|
||||||
|
//% blockIdentity="control.eventValueId"
|
||||||
MES_DPAD_BUTTON_C_UP_ = MES_DPAD_BUTTON_C_UP,
|
MES_DPAD_BUTTON_C_UP_ = MES_DPAD_BUTTON_C_UP,
|
||||||
|
//% blockIdentity="control.eventValueId"
|
||||||
MES_DPAD_BUTTON_D_DOWN_ = MES_DPAD_BUTTON_D_DOWN,
|
MES_DPAD_BUTTON_D_DOWN_ = MES_DPAD_BUTTON_D_DOWN,
|
||||||
|
//% blockIdentity="control.eventValueId"
|
||||||
MES_DPAD_BUTTON_D_UP_ = MES_DPAD_BUTTON_D_UP,
|
MES_DPAD_BUTTON_D_UP_ = MES_DPAD_BUTTON_D_UP,
|
||||||
|
//% blockIdentity="control.eventValueId"
|
||||||
MES_REMOTE_CONTROL_EVT_FORWARD_ = MES_REMOTE_CONTROL_EVT_FORWARD,
|
MES_REMOTE_CONTROL_EVT_FORWARD_ = MES_REMOTE_CONTROL_EVT_FORWARD,
|
||||||
|
//% blockIdentity="control.eventValueId"
|
||||||
MES_REMOTE_CONTROL_EVT_NEXTTRACK_ = MES_REMOTE_CONTROL_EVT_NEXTTRACK,
|
MES_REMOTE_CONTROL_EVT_NEXTTRACK_ = MES_REMOTE_CONTROL_EVT_NEXTTRACK,
|
||||||
|
//% blockIdentity="control.eventValueId"
|
||||||
MES_REMOTE_CONTROL_EVT_PAUSE_ = MES_REMOTE_CONTROL_EVT_PAUSE,
|
MES_REMOTE_CONTROL_EVT_PAUSE_ = MES_REMOTE_CONTROL_EVT_PAUSE,
|
||||||
|
//% blockIdentity="control.eventValueId"
|
||||||
MES_REMOTE_CONTROL_EVT_PLAY_ = MES_REMOTE_CONTROL_EVT_PLAY,
|
MES_REMOTE_CONTROL_EVT_PLAY_ = MES_REMOTE_CONTROL_EVT_PLAY,
|
||||||
|
//% blockIdentity="control.eventValueId"
|
||||||
MES_REMOTE_CONTROL_EVT_PREVTRACK_ = MES_REMOTE_CONTROL_EVT_PREVTRACK,
|
MES_REMOTE_CONTROL_EVT_PREVTRACK_ = MES_REMOTE_CONTROL_EVT_PREVTRACK,
|
||||||
|
//% blockIdentity="control.eventValueId"
|
||||||
MES_REMOTE_CONTROL_EVT_REWIND_ = MES_REMOTE_CONTROL_EVT_REWIND,
|
MES_REMOTE_CONTROL_EVT_REWIND_ = MES_REMOTE_CONTROL_EVT_REWIND,
|
||||||
|
//% blockIdentity="control.eventValueId"
|
||||||
MES_REMOTE_CONTROL_EVT_STOP_ = MES_REMOTE_CONTROL_EVT_STOP,
|
MES_REMOTE_CONTROL_EVT_STOP_ = MES_REMOTE_CONTROL_EVT_STOP,
|
||||||
|
//% blockIdentity="control.eventValueId"
|
||||||
MES_REMOTE_CONTROL_EVT_VOLUMEDOWN_ = MES_REMOTE_CONTROL_EVT_VOLUMEDOWN,
|
MES_REMOTE_CONTROL_EVT_VOLUMEDOWN_ = MES_REMOTE_CONTROL_EVT_VOLUMEDOWN,
|
||||||
|
//% blockIdentity="control.eventValueId"
|
||||||
MES_REMOTE_CONTROL_EVT_VOLUMEUP_ = MES_REMOTE_CONTROL_EVT_VOLUMEUP,
|
MES_REMOTE_CONTROL_EVT_VOLUMEUP_ = MES_REMOTE_CONTROL_EVT_VOLUMEUP,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -126,7 +219,7 @@ namespace control {
|
|||||||
/**
|
/**
|
||||||
* Schedules code that run in the background.
|
* Schedules code that run in the background.
|
||||||
*/
|
*/
|
||||||
//% help=control/in-background
|
//% help=control/in-background blockAllowMultiple=1 afterOnStart=true
|
||||||
//% blockId="control_in_background" block="run in background" blockGap=8
|
//% blockId="control_in_background" block="run in background" blockGap=8
|
||||||
void inBackground(Action a) {
|
void inBackground(Action a) {
|
||||||
runInBackground(a);
|
runInBackground(a);
|
||||||
@@ -158,6 +251,7 @@ namespace control {
|
|||||||
* @param mode optional definition of how the event should be processed after construction (default is CREATE_AND_FIRE).
|
* @param mode optional definition of how the event should be processed after construction (default is CREATE_AND_FIRE).
|
||||||
*/
|
*/
|
||||||
//% weight=21 blockGap=12 blockId="control_raise_event" block="raise event|from source %src=control_event_source_id|with value %value=control_event_value_id" blockExternalInputs=1
|
//% weight=21 blockGap=12 blockId="control_raise_event" block="raise event|from source %src=control_event_source_id|with value %value=control_event_value_id" blockExternalInputs=1
|
||||||
|
//% help=control/raise-event
|
||||||
//% mode.defl=CREATE_AND_FIRE
|
//% mode.defl=CREATE_AND_FIRE
|
||||||
void raiseEvent(int src, int value, EventCreationMode mode) {
|
void raiseEvent(int src, int value, EventCreationMode mode) {
|
||||||
MicroBitEvent evt(src, value, (MicroBitEventLaunchMode)mode);
|
MicroBitEvent evt(src, value, (MicroBitEventLaunchMode)mode);
|
||||||
@@ -167,6 +261,7 @@ namespace control {
|
|||||||
* Raises an event in the event bus.
|
* Raises an event in the event bus.
|
||||||
*/
|
*/
|
||||||
//% weight=20 blockGap=8 blockId="control_on_event" block="on event|from %src=control_event_source_id|with value %value=control_event_value_id"
|
//% weight=20 blockGap=8 blockId="control_on_event" block="on event|from %src=control_event_source_id|with value %value=control_event_value_id"
|
||||||
|
//% help=control/on-event
|
||||||
//% blockExternalInputs=1
|
//% blockExternalInputs=1
|
||||||
void onEvent(int src, int value, Action handler) {
|
void onEvent(int src, int value, Action handler) {
|
||||||
registerWithDal(src, value, handler);
|
registerWithDal(src, value, handler);
|
||||||
@@ -176,6 +271,7 @@ namespace control {
|
|||||||
* Gets the value of the last event executed on the bus
|
* Gets the value of the last event executed on the bus
|
||||||
*/
|
*/
|
||||||
//% blockId=control_event_value" block="event value"
|
//% blockId=control_event_value" block="event value"
|
||||||
|
//% help=control/event-value
|
||||||
//% weight=18
|
//% weight=18
|
||||||
int eventValue() {
|
int eventValue() {
|
||||||
return pxt::lastEvent.value;
|
return pxt::lastEvent.value;
|
||||||
@@ -185,6 +281,7 @@ namespace control {
|
|||||||
* Gets the timestamp of the last event executed on the bus
|
* Gets the timestamp of the last event executed on the bus
|
||||||
*/
|
*/
|
||||||
//% blockId=control_event_timestamp" block="event timestamp"
|
//% blockId=control_event_timestamp" block="event timestamp"
|
||||||
|
//% help=control/event-timestamp
|
||||||
//% weight=19 blockGap=8
|
//% weight=19 blockGap=8
|
||||||
int eventTimestamp() {
|
int eventTimestamp() {
|
||||||
return pxt::lastEvent.timestamp;
|
return pxt::lastEvent.timestamp;
|
||||||
@@ -194,6 +291,7 @@ namespace control {
|
|||||||
* Gets a friendly name for the device derived from the its serial number
|
* Gets a friendly name for the device derived from the its serial number
|
||||||
*/
|
*/
|
||||||
//% blockId="control_device_name" block="device name" weight=10 blockGap=8
|
//% blockId="control_device_name" block="device name" weight=10 blockGap=8
|
||||||
|
//% advanced=true
|
||||||
StringData* deviceName() {
|
StringData* deviceName() {
|
||||||
return ManagedString(microbit_friendly_name()).leakData();
|
return ManagedString(microbit_friendly_name()).leakData();
|
||||||
}
|
}
|
||||||
@@ -202,6 +300,7 @@ namespace control {
|
|||||||
* Derive a unique, consistent serial number of this device from internal data.
|
* Derive a unique, consistent serial number of this device from internal data.
|
||||||
*/
|
*/
|
||||||
//% blockId="control_device_serial_number" block="device serial number" weight=9
|
//% blockId="control_device_serial_number" block="device serial number" weight=9
|
||||||
|
//% advanced=true
|
||||||
int deviceSerialNumber() {
|
int deviceSerialNumber() {
|
||||||
return microbit_serial_number();
|
return microbit_serial_number();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,46 +4,47 @@
|
|||||||
//% weight=1 color="#42495F" icon="\uf233"
|
//% weight=1 color="#42495F" icon="\uf233"
|
||||||
//% advanced=true
|
//% advanced=true
|
||||||
namespace control {
|
namespace control {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the value of a C++ runtime constant
|
* Returns the value of a C++ runtime constant
|
||||||
*/
|
*/
|
||||||
//% weight=2 weight=19 blockId="control_event_source_id" block="%id" blockGap=8
|
//% weight=2 weight=19 blockId="control_event_source_id" block="%id" blockGap=8
|
||||||
//% shim=TD_ID
|
//% shim=TD_ID advanced=true
|
||||||
export function eventSourceId(id: EventBusSource): number {
|
export function eventSourceId(id: EventBusSource): number {
|
||||||
return id;
|
return id;
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Returns the value of a C++ runtime constant
|
|
||||||
*/
|
|
||||||
//% weight=1 weight=19 blockId="control_event_value_id" block="%id"
|
|
||||||
//% shim=TD_ID
|
|
||||||
export function eventValueId(id: EventBusValue): number {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Display specified error code and stop the program.
|
|
||||||
*/
|
|
||||||
//% shim=pxtrt::panic
|
|
||||||
export function panic(code: number) { }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* If the condition is false, display msg on serial console, and panic with code 098.
|
|
||||||
*/
|
|
||||||
export function assert(condition: boolean, msg ?: string) {
|
|
||||||
if (!condition) {
|
|
||||||
console.log("ASSERTION FAILED")
|
|
||||||
if (msg != null) {
|
|
||||||
console.log(msg)
|
|
||||||
}
|
|
||||||
panic(98)
|
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Returns the value of a C++ runtime constant
|
||||||
|
*/
|
||||||
|
//% weight=1 weight=19 blockId="control_event_value_id" block="%id"
|
||||||
|
//% shim=TD_ID advanced=true
|
||||||
|
export function eventValueId(id: EventBusValue): number {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display specified error code and stop the program.
|
||||||
|
*/
|
||||||
|
//% shim=pxtrt::panic
|
||||||
|
export function panic(code: number) { }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If the condition is false, display msg on serial console, and panic with code 098.
|
||||||
|
*/
|
||||||
|
export function assert(condition: boolean, msg?: string) {
|
||||||
|
if (!condition) {
|
||||||
|
console.log("ASSERTION FAILED")
|
||||||
|
if (msg != null) {
|
||||||
|
console.log(msg)
|
||||||
|
}
|
||||||
|
panic(98)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display warning in the simulator.
|
||||||
|
*/
|
||||||
|
//% shim=pxtrt::runtimeWarning
|
||||||
|
export function runtimeWarning(message: string) { }
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Display warning in the simulator.
|
|
||||||
*/
|
|
||||||
//% shim=pxtrt::runtimeWarning
|
|
||||||
export function runtimeWarning(message: string) { }
|
|
||||||
}
|
|
||||||
@@ -29,6 +29,15 @@ namespace String_ {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//%
|
||||||
|
int compareDecr(StringData *s, StringData *that) {
|
||||||
|
int r = compare(s, that);
|
||||||
|
if (r == 0)
|
||||||
|
decr((uint32_t)that);
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//%
|
//%
|
||||||
int length(StringData *s) { return s->len; }
|
int length(StringData *s) { return s->len; }
|
||||||
|
|
||||||
@@ -112,6 +121,15 @@ namespace Number_ {
|
|||||||
int div(int x, int y) { return x / y; }
|
int div(int x, int y) { return x / y; }
|
||||||
//%
|
//%
|
||||||
int mod(int x, int y) { return x % y; }
|
int mod(int x, int y) { return x % y; }
|
||||||
|
|
||||||
|
//%
|
||||||
|
bool eqDecr(int x, int y) {
|
||||||
|
if(x == y) {
|
||||||
|
decr(y);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace Math_ {
|
namespace Math_ {
|
||||||
@@ -220,17 +238,12 @@ namespace pxt {
|
|||||||
return bytecode[17] * 2;
|
return bytecode[17] * 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef PAGE_SIZE
|
|
||||||
|
|
||||||
#define PAGE_SIZE 1
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//%
|
//%
|
||||||
uint32_t afterProgramPage() {
|
uint32_t afterProgramPage() {
|
||||||
uint32_t ptr = (uint32_t)&bytecode[0];
|
uint32_t ptr = (uint32_t)&bytecode[0];
|
||||||
ptr += programSize();
|
ptr += programSize();
|
||||||
ptr = (ptr + (PAGE_SIZE - 1)) & ~(PAGE_SIZE - 1);
|
if (ptr % PAGE_SIZE != 0)
|
||||||
|
ptr = (ptr & ~(PAGE_SIZE-1)) + PAGE_SIZE;
|
||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
26
libs/core/dal.d.ts
vendored
@@ -81,6 +81,8 @@ declare const enum DAL {
|
|||||||
MICROBIT_BLE_MAXIMUM_BONDS = 4,
|
MICROBIT_BLE_MAXIMUM_BONDS = 4,
|
||||||
MICROBIT_BLE_EDDYSTONE_ADV_INTERVAL = 400,
|
MICROBIT_BLE_EDDYSTONE_ADV_INTERVAL = 400,
|
||||||
MICROBIT_BLE_EDDYSTONE_DEFAULT_POWER = 0xF0,
|
MICROBIT_BLE_EDDYSTONE_DEFAULT_POWER = 0xF0,
|
||||||
|
MICROBIT_BLE_STATUS_STORE_SYSATTR = 0x02,
|
||||||
|
MICROBIT_BLE_STATUS_DISCONNECT = 0x04,
|
||||||
MICROBIT_BLE_DISCONNECT_AFTER_PAIRING_DELAY = 500,
|
MICROBIT_BLE_DISCONNECT_AFTER_PAIRING_DELAY = 500,
|
||||||
// built/yt/yotta_modules/microbit-dal/inc/bluetooth/MicroBitButtonService.h
|
// built/yt/yotta_modules/microbit-dal/inc/bluetooth/MicroBitButtonService.h
|
||||||
// built/yt/yotta_modules/microbit-dal/inc/bluetooth/MicroBitDFUService.h
|
// built/yt/yotta_modules/microbit-dal/inc/bluetooth/MicroBitDFUService.h
|
||||||
@@ -207,10 +209,7 @@ declare const enum DAL {
|
|||||||
CALLIOPE_MAX_FREQUENCY_HZ_S = 20000,
|
CALLIOPE_MAX_FREQUENCY_HZ_S = 20000,
|
||||||
CALLIOPE_BOARD_FREQUENCY = 16000000,
|
CALLIOPE_BOARD_FREQUENCY = 16000000,
|
||||||
// built/yt/yotta_modules/microbit-dal/inc/drivers/DynamicPwm.h
|
// built/yt/yotta_modules/microbit-dal/inc/drivers/DynamicPwm.h
|
||||||
NO_PWMS = 3,
|
|
||||||
MICROBIT_DEFAULT_PWM_PERIOD = 20000,
|
MICROBIT_DEFAULT_PWM_PERIOD = 20000,
|
||||||
PWM_PERSISTENCE_TRANSIENT = 1,
|
|
||||||
PWM_PERSISTENCE_PERSISTENT = 2,
|
|
||||||
// built/yt/yotta_modules/microbit-dal/inc/drivers/MicroBitAccelerometer-bmx.h
|
// built/yt/yotta_modules/microbit-dal/inc/drivers/MicroBitAccelerometer-bmx.h
|
||||||
BMX055_ACC_WHOAMI = 0x00,
|
BMX055_ACC_WHOAMI = 0x00,
|
||||||
BMX055_ACC_D_X_LSB = 0x02,
|
BMX055_ACC_D_X_LSB = 0x02,
|
||||||
@@ -421,10 +420,11 @@ declare const enum DAL {
|
|||||||
MICROBIT_ACCELEROMETER_EVT_FACE_UP = 5,
|
MICROBIT_ACCELEROMETER_EVT_FACE_UP = 5,
|
||||||
MICROBIT_ACCELEROMETER_EVT_FACE_DOWN = 6,
|
MICROBIT_ACCELEROMETER_EVT_FACE_DOWN = 6,
|
||||||
MICROBIT_ACCELEROMETER_EVT_FREEFALL = 7,
|
MICROBIT_ACCELEROMETER_EVT_FREEFALL = 7,
|
||||||
MICROBIT_ACCELEROMETER_EVT_3G = 8,
|
MICROBIT_ACCELEROMETER_EVT_2G = 8,
|
||||||
MICROBIT_ACCELEROMETER_EVT_6G = 9,
|
MICROBIT_ACCELEROMETER_EVT_3G = 9,
|
||||||
MICROBIT_ACCELEROMETER_EVT_8G = 10,
|
MICROBIT_ACCELEROMETER_EVT_6G = 10,
|
||||||
MICROBIT_ACCELEROMETER_EVT_SHAKE = 11,
|
MICROBIT_ACCELEROMETER_EVT_8G = 11,
|
||||||
|
MICROBIT_ACCELEROMETER_EVT_SHAKE = 12,
|
||||||
MICROBIT_ACCELEROMETER_REST_TOLERANCE = 200,
|
MICROBIT_ACCELEROMETER_REST_TOLERANCE = 200,
|
||||||
MICROBIT_ACCELEROMETER_TILT_TOLERANCE = 200,
|
MICROBIT_ACCELEROMETER_TILT_TOLERANCE = 200,
|
||||||
MICROBIT_ACCELEROMETER_FREEFALL_TOLERANCE = 400,
|
MICROBIT_ACCELEROMETER_FREEFALL_TOLERANCE = 400,
|
||||||
@@ -438,6 +438,7 @@ declare const enum DAL {
|
|||||||
MICROBIT_ACCELEROMETER_SHAKE_RTX = 30,
|
MICROBIT_ACCELEROMETER_SHAKE_RTX = 30,
|
||||||
MICROBIT_ACCELEROMETER_SHAKE_COUNT_THRESHOLD = 4,
|
MICROBIT_ACCELEROMETER_SHAKE_COUNT_THRESHOLD = 4,
|
||||||
// built/yt/yotta_modules/microbit-dal/inc/drivers/MicroBitAccelerometer.h
|
// built/yt/yotta_modules/microbit-dal/inc/drivers/MicroBitAccelerometer.h
|
||||||
|
MMA8653_DEFAULT_ADDR = 0x3A,
|
||||||
// built/yt/yotta_modules/microbit-dal/inc/drivers/MicroBitButton.h
|
// built/yt/yotta_modules/microbit-dal/inc/drivers/MicroBitButton.h
|
||||||
MICROBIT_BUTTON_EVT_DOWN = 1,
|
MICROBIT_BUTTON_EVT_DOWN = 1,
|
||||||
MICROBIT_BUTTON_EVT_UP = 2,
|
MICROBIT_BUTTON_EVT_UP = 2,
|
||||||
@@ -458,7 +459,7 @@ declare const enum DAL {
|
|||||||
MICROBIT_BUTTON_DOUBLE_CLICK_THRESH = 50,
|
MICROBIT_BUTTON_DOUBLE_CLICK_THRESH = 50,
|
||||||
MICROBIT_BUTTON_SIMPLE_EVENTS = 0,
|
MICROBIT_BUTTON_SIMPLE_EVENTS = 0,
|
||||||
MICROBIT_BUTTON_ALL_EVENTS = 1,
|
MICROBIT_BUTTON_ALL_EVENTS = 1,
|
||||||
// built/yt/yotta_modules/microbit-dal/inc/drivers/MicroBitCompass.h
|
// built/yt/yotta_modules/microbit-dal/inc/drivers/MicroBitCompass-bmx.h
|
||||||
MAG3110_DEFAULT_ADDR = 0x1D,
|
MAG3110_DEFAULT_ADDR = 0x1D,
|
||||||
MAG_DR_STATUS = 0x00,
|
MAG_DR_STATUS = 0x00,
|
||||||
MAG_OUT_X_MSB = 0x01,
|
MAG_OUT_X_MSB = 0x01,
|
||||||
@@ -489,6 +490,7 @@ declare const enum DAL {
|
|||||||
MICROBIT_COMPASS_STATUS_CALIBRATING = 4,
|
MICROBIT_COMPASS_STATUS_CALIBRATING = 4,
|
||||||
MICROBIT_COMPASS_STATUS_ADDED_TO_IDLE = 8,
|
MICROBIT_COMPASS_STATUS_ADDED_TO_IDLE = 8,
|
||||||
MAG3110_WHOAMI_VAL = 0xC4,
|
MAG3110_WHOAMI_VAL = 0xC4,
|
||||||
|
// built/yt/yotta_modules/microbit-dal/inc/drivers/MicroBitCompass.h
|
||||||
// built/yt/yotta_modules/microbit-dal/inc/drivers/MicroBitCompassCalibrator.h
|
// built/yt/yotta_modules/microbit-dal/inc/drivers/MicroBitCompassCalibrator.h
|
||||||
// built/yt/yotta_modules/microbit-dal/inc/drivers/MicroBitDisplay.h
|
// built/yt/yotta_modules/microbit-dal/inc/drivers/MicroBitDisplay.h
|
||||||
MICROBIT_DISPLAY_EVT_ANIMATION_COMPLETE = 1,
|
MICROBIT_DISPLAY_EVT_ANIMATION_COMPLETE = 1,
|
||||||
@@ -579,8 +581,12 @@ declare const enum DAL {
|
|||||||
MICROBIT_PIN_EVT_FALL = 3,
|
MICROBIT_PIN_EVT_FALL = 3,
|
||||||
MICROBIT_PIN_EVT_PULSE_HI = 4,
|
MICROBIT_PIN_EVT_PULSE_HI = 4,
|
||||||
MICROBIT_PIN_EVT_PULSE_LO = 5,
|
MICROBIT_PIN_EVT_PULSE_LO = 5,
|
||||||
PIN_CAPABILITY_DIGITAL = 0x01,
|
PIN_CAPABILITY_DIGITAL_IN = 0x01,
|
||||||
PIN_CAPABILITY_ANALOG = 0x02,
|
PIN_CAPABILITY_DIGITAL_OUT = 0x02,
|
||||||
|
// built/yt/yotta_modules/microbit-dal/inc/drivers/MicroBitQuadratureDecoder.h
|
||||||
|
QDEC_USE_SYSTEM_TICK = 0x01,
|
||||||
|
QDEC_USE_DEBOUNCE = 0x02,
|
||||||
|
QDEC_LED_ACTIVE_LOW = 0x04,
|
||||||
// built/yt/yotta_modules/microbit-dal/inc/drivers/MicroBitRadio.h
|
// built/yt/yotta_modules/microbit-dal/inc/drivers/MicroBitRadio.h
|
||||||
MICROBIT_RADIO_STATUS_INITIALISED = 0x0001,
|
MICROBIT_RADIO_STATUS_INITIALISED = 0x0001,
|
||||||
MICROBIT_RADIO_BASE_ADDRESS = 0x75626974,
|
MICROBIT_RADIO_BASE_ADDRESS = 0x75626974,
|
||||||
|
|||||||
182
libs/core/enums.d.ts
vendored
@@ -5,7 +5,7 @@ declare namespace basic {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
declare enum Button {
|
declare const enum Button {
|
||||||
A = 1, // MICROBIT_ID_BUTTON_A
|
A = 1, // MICROBIT_ID_BUTTON_A
|
||||||
B = 2, // MICROBIT_ID_BUTTON_B
|
B = 2, // MICROBIT_ID_BUTTON_B
|
||||||
//% block="A+B"
|
//% block="A+B"
|
||||||
@@ -13,7 +13,7 @@ declare namespace basic {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
declare enum Dimension {
|
declare const enum Dimension {
|
||||||
//% block=x
|
//% block=x
|
||||||
X = 0,
|
X = 0,
|
||||||
//% block=y
|
//% block=y
|
||||||
@@ -25,7 +25,7 @@ declare namespace basic {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
declare enum Rotation {
|
declare const enum Rotation {
|
||||||
//% block=pitch
|
//% block=pitch
|
||||||
Pitch = 0,
|
Pitch = 0,
|
||||||
//% block=roll
|
//% block=roll
|
||||||
@@ -33,7 +33,7 @@ declare namespace basic {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
declare enum TouchPin {
|
declare const enum TouchPin {
|
||||||
P0 = 19, // MICROBIT_ID_IO_P12
|
P0 = 19, // MICROBIT_ID_IO_P12
|
||||||
P1 = 7, // MICROBIT_ID_IO_P0
|
P1 = 7, // MICROBIT_ID_IO_P0
|
||||||
P2 = 8, // MICROBIT_ID_IO_P1
|
P2 = 8, // MICROBIT_ID_IO_P1
|
||||||
@@ -41,7 +41,7 @@ declare namespace basic {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
declare enum AcceleratorRange {
|
declare const enum AcceleratorRange {
|
||||||
/**
|
/**
|
||||||
* The accelerator measures forces up to 1 gravity
|
* The accelerator measures forces up to 1 gravity
|
||||||
*/
|
*/
|
||||||
@@ -65,12 +65,12 @@ declare namespace basic {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
declare enum Gesture {
|
declare const enum Gesture {
|
||||||
/**
|
/**
|
||||||
* Raised when shaken
|
* Raised when shaken
|
||||||
*/
|
*/
|
||||||
//% block=shake
|
//% block=shake
|
||||||
Shake = 11, // MICROBIT_ACCELEROMETER_EVT_SHAKE
|
Shake = 12, // MICROBIT_ACCELEROMETER_EVT_SHAKE
|
||||||
/**
|
/**
|
||||||
* Raised when the logo is upward and the screen is vertical
|
* Raised when the logo is upward and the screen is vertical
|
||||||
*/
|
*/
|
||||||
@@ -110,12 +110,53 @@ declare namespace basic {
|
|||||||
* Raised when a 3G shock is detected
|
* Raised when a 3G shock is detected
|
||||||
*/
|
*/
|
||||||
//% block="3g"
|
//% block="3g"
|
||||||
ThreeG = 8, // MICROBIT_ACCELEROMETER_EVT_3G
|
ThreeG = 9, // MICROBIT_ACCELEROMETER_EVT_3G
|
||||||
/**
|
/**
|
||||||
* Raised when a 6G shock is detected
|
* Raised when a 6G shock is detected
|
||||||
*/
|
*/
|
||||||
//% block="6g"
|
//% block="6g"
|
||||||
SixG = 9, // MICROBIT_ACCELEROMETER_EVT_6G
|
SixG = 10, // MICROBIT_ACCELEROMETER_EVT_6G
|
||||||
|
/**
|
||||||
|
* Raised when a 8G shock is detected
|
||||||
|
*/
|
||||||
|
//% block="8g"
|
||||||
|
EightG = 11, // MICROBIT_ACCELEROMETER_EVT_8G
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
declare const enum MesDpadButtonInfo {
|
||||||
|
//% block="A down"
|
||||||
|
ADown = 1, // MES_DPAD_BUTTON_A_DOWN
|
||||||
|
//% block="A up"
|
||||||
|
AUp = 2, // MES_DPAD_BUTTON_A_UP
|
||||||
|
//% block="B down"
|
||||||
|
BDown = 3, // MES_DPAD_BUTTON_B_DOWN
|
||||||
|
//% block="B up"
|
||||||
|
BUp = 4, // MES_DPAD_BUTTON_B_UP
|
||||||
|
//% block="C down"
|
||||||
|
CDown = 5, // MES_DPAD_BUTTON_C_DOWN
|
||||||
|
//% block="C up"
|
||||||
|
CUp = 6, // MES_DPAD_BUTTON_C_UP
|
||||||
|
//% block="D down"
|
||||||
|
DDown = 7, // MES_DPAD_BUTTON_D_DOWN
|
||||||
|
//% block="D up"
|
||||||
|
DUp = 8, // MES_DPAD_BUTTON_D_UP
|
||||||
|
//% block="1 down"
|
||||||
|
_1Down = 9, // MES_DPAD_BUTTON_1_DOWN
|
||||||
|
//% block="1 up"
|
||||||
|
_1Up = 10, // MES_DPAD_BUTTON_1_UP
|
||||||
|
//% block="2 down"
|
||||||
|
_2Down = 11, // MES_DPAD_BUTTON_2_DOWN
|
||||||
|
//% block="2 up"
|
||||||
|
_2Up = 12, // MES_DPAD_BUTTON_2_UP
|
||||||
|
//% block="3 down"
|
||||||
|
_3Down = 13, // MES_DPAD_BUTTON_3_DOWN
|
||||||
|
//% block="3 up"
|
||||||
|
_3Up = 14, // MES_DPAD_BUTTON_3_UP
|
||||||
|
//% block="4 down"
|
||||||
|
_4Down = 15, // MES_DPAD_BUTTON_4_DOWN
|
||||||
|
//% block="4 up"
|
||||||
|
_4Up = 16, // MES_DPAD_BUTTON_4_UP
|
||||||
}
|
}
|
||||||
declare namespace input {
|
declare namespace input {
|
||||||
}
|
}
|
||||||
@@ -125,7 +166,7 @@ declare namespace input {
|
|||||||
* How to create the event.
|
* How to create the event.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
declare enum EventCreationMode {
|
declare const enum EventCreationMode {
|
||||||
/**
|
/**
|
||||||
* MicroBitEvent is initialised, and no further processing takes place.
|
* MicroBitEvent is initialised, and no further processing takes place.
|
||||||
*/
|
*/
|
||||||
@@ -137,106 +178,199 @@ declare namespace input {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
declare enum EventBusSource {
|
declare const enum EventBusSource {
|
||||||
|
//% blockIdentity="control.eventSourceId"
|
||||||
MICROBIT_ID_BUTTON_A = 1, // MICROBIT_ID_BUTTON_A
|
MICROBIT_ID_BUTTON_A = 1, // MICROBIT_ID_BUTTON_A
|
||||||
|
//% blockIdentity="control.eventSourceId"
|
||||||
MICROBIT_ID_BUTTON_B = 2, // MICROBIT_ID_BUTTON_B
|
MICROBIT_ID_BUTTON_B = 2, // MICROBIT_ID_BUTTON_B
|
||||||
|
//% blockIdentity="control.eventSourceId"
|
||||||
MICROBIT_ID_BUTTON_AB = 26, // MICROBIT_ID_BUTTON_AB
|
MICROBIT_ID_BUTTON_AB = 26, // MICROBIT_ID_BUTTON_AB
|
||||||
|
//% blockIdentity="control.eventSourceId"
|
||||||
MICROBIT_ID_RADIO = 29, // MICROBIT_ID_RADIO
|
MICROBIT_ID_RADIO = 29, // MICROBIT_ID_RADIO
|
||||||
|
//% blockIdentity="control.eventSourceId"
|
||||||
MICROBIT_ID_GESTURE = 27, // MICROBIT_ID_GESTURE
|
MICROBIT_ID_GESTURE = 27, // MICROBIT_ID_GESTURE
|
||||||
|
//% blockIdentity="control.eventSourceId"
|
||||||
MICROBIT_ID_ACCELEROMETER = 4, // MICROBIT_ID_ACCELEROMETER
|
MICROBIT_ID_ACCELEROMETER = 4, // MICROBIT_ID_ACCELEROMETER
|
||||||
|
//% blockIdentity="control.eventSourceId"
|
||||||
MICROBIT_ID_IO_P0 = 7, // MICROBIT_ID_IO_P0
|
MICROBIT_ID_IO_P0 = 7, // MICROBIT_ID_IO_P0
|
||||||
|
//% blockIdentity="control.eventSourceId"
|
||||||
MICROBIT_ID_IO_P1 = 8, // MICROBIT_ID_IO_P1
|
MICROBIT_ID_IO_P1 = 8, // MICROBIT_ID_IO_P1
|
||||||
|
//% blockIdentity="control.eventSourceId"
|
||||||
MICROBIT_ID_IO_P2 = 9, // MICROBIT_ID_IO_P2
|
MICROBIT_ID_IO_P2 = 9, // MICROBIT_ID_IO_P2
|
||||||
|
//% blockIdentity="control.eventSourceId"
|
||||||
MICROBIT_ID_IO_P3 = 10, // MICROBIT_ID_IO_P3
|
MICROBIT_ID_IO_P3 = 10, // MICROBIT_ID_IO_P3
|
||||||
|
//% blockIdentity="control.eventSourceId"
|
||||||
MICROBIT_ID_IO_P4 = 11, // MICROBIT_ID_IO_P4
|
MICROBIT_ID_IO_P4 = 11, // MICROBIT_ID_IO_P4
|
||||||
|
//% blockIdentity="control.eventSourceId"
|
||||||
MICROBIT_ID_IO_P5 = 12, // MICROBIT_ID_IO_P5
|
MICROBIT_ID_IO_P5 = 12, // MICROBIT_ID_IO_P5
|
||||||
|
//% blockIdentity="control.eventSourceId"
|
||||||
MICROBIT_ID_IO_P6 = 13, // MICROBIT_ID_IO_P6
|
MICROBIT_ID_IO_P6 = 13, // MICROBIT_ID_IO_P6
|
||||||
|
//% blockIdentity="control.eventSourceId"
|
||||||
MICROBIT_ID_IO_P7 = 14, // MICROBIT_ID_IO_P7
|
MICROBIT_ID_IO_P7 = 14, // MICROBIT_ID_IO_P7
|
||||||
|
//% blockIdentity="control.eventSourceId"
|
||||||
MICROBIT_ID_IO_P8 = 15, // MICROBIT_ID_IO_P8
|
MICROBIT_ID_IO_P8 = 15, // MICROBIT_ID_IO_P8
|
||||||
|
//% blockIdentity="control.eventSourceId"
|
||||||
MICROBIT_ID_IO_P9 = 16, // MICROBIT_ID_IO_P9
|
MICROBIT_ID_IO_P9 = 16, // MICROBIT_ID_IO_P9
|
||||||
|
//% blockIdentity="control.eventSourceId"
|
||||||
MICROBIT_ID_IO_P10 = 17, // MICROBIT_ID_IO_P10
|
MICROBIT_ID_IO_P10 = 17, // MICROBIT_ID_IO_P10
|
||||||
|
//% blockIdentity="control.eventSourceId"
|
||||||
MICROBIT_ID_IO_P11 = 18, // MICROBIT_ID_IO_P11
|
MICROBIT_ID_IO_P11 = 18, // MICROBIT_ID_IO_P11
|
||||||
|
//% blockIdentity="control.eventSourceId"
|
||||||
MICROBIT_ID_IO_P12 = 19, // MICROBIT_ID_IO_P12
|
MICROBIT_ID_IO_P12 = 19, // MICROBIT_ID_IO_P12
|
||||||
|
//% blockIdentity="control.eventSourceId"
|
||||||
MICROBIT_ID_IO_P13 = 20, // MICROBIT_ID_IO_P13
|
MICROBIT_ID_IO_P13 = 20, // MICROBIT_ID_IO_P13
|
||||||
|
//% blockIdentity="control.eventSourceId"
|
||||||
MICROBIT_ID_IO_P14 = 21, // MICROBIT_ID_IO_P14
|
MICROBIT_ID_IO_P14 = 21, // MICROBIT_ID_IO_P14
|
||||||
|
//% blockIdentity="control.eventSourceId"
|
||||||
MICROBIT_ID_IO_P15 = 22, // MICROBIT_ID_IO_P15
|
MICROBIT_ID_IO_P15 = 22, // MICROBIT_ID_IO_P15
|
||||||
|
//% blockIdentity="control.eventSourceId"
|
||||||
MICROBIT_ID_IO_P16 = 23, // MICROBIT_ID_IO_P16
|
MICROBIT_ID_IO_P16 = 23, // MICROBIT_ID_IO_P16
|
||||||
|
//% blockIdentity="control.eventSourceId"
|
||||||
MICROBIT_ID_IO_P19 = 24, // MICROBIT_ID_IO_P19
|
MICROBIT_ID_IO_P19 = 24, // MICROBIT_ID_IO_P19
|
||||||
|
//% blockIdentity="control.eventSourceId"
|
||||||
MICROBIT_ID_IO_P20 = 25, // MICROBIT_ID_IO_P20
|
MICROBIT_ID_IO_P20 = 25, // MICROBIT_ID_IO_P20
|
||||||
|
//% blockIdentity="control.eventSourceId"
|
||||||
MICROBIT_ID_IO_P21 = 50, // MICROBIT_ID_IO_P21
|
MICROBIT_ID_IO_P21 = 50, // MICROBIT_ID_IO_P21
|
||||||
|
//% blockIdentity="control.eventSourceId"
|
||||||
MES_DEVICE_INFO_ID = 1103, // MES_DEVICE_INFO_ID
|
MES_DEVICE_INFO_ID = 1103, // MES_DEVICE_INFO_ID
|
||||||
|
//% blockIdentity="control.eventSourceId"
|
||||||
MES_SIGNAL_STRENGTH_ID = 1101, // MES_SIGNAL_STRENGTH_ID
|
MES_SIGNAL_STRENGTH_ID = 1101, // MES_SIGNAL_STRENGTH_ID
|
||||||
|
//% blockIdentity="control.eventSourceId"
|
||||||
MES_DPAD_CONTROLLER_ID = 1104, // MES_DPAD_CONTROLLER_ID
|
MES_DPAD_CONTROLLER_ID = 1104, // MES_DPAD_CONTROLLER_ID
|
||||||
|
//% blockIdentity="control.eventSourceId"
|
||||||
MES_BROADCAST_GENERAL_ID = 2000, // MES_BROADCAST_GENERAL_ID
|
MES_BROADCAST_GENERAL_ID = 2000, // MES_BROADCAST_GENERAL_ID
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
declare enum EventBusValue {
|
declare const enum EventBusValue {
|
||||||
|
//% blockIdentity="control.eventValueId"
|
||||||
MICROBIT_EVT_ANY = 0, // MICROBIT_EVT_ANY
|
MICROBIT_EVT_ANY = 0, // MICROBIT_EVT_ANY
|
||||||
|
//% blockIdentity="control.eventValueId"
|
||||||
|
MICROBIT_BUTTON_EVT_DOWN = 1, // MICROBIT_BUTTON_EVT_DOWN
|
||||||
|
//% blockIdentity="control.eventValueId"
|
||||||
|
MICROBIT_BUTTON_EVT_UP = 2, // MICROBIT_BUTTON_EVT_UP
|
||||||
|
//% blockIdentity="control.eventValueId"
|
||||||
MICROBIT_BUTTON_EVT_CLICK = 3, // MICROBIT_BUTTON_EVT_CLICK
|
MICROBIT_BUTTON_EVT_CLICK = 3, // MICROBIT_BUTTON_EVT_CLICK
|
||||||
|
//% blockIdentity="control.eventValueId"
|
||||||
MICROBIT_RADIO_EVT_DATAGRAM = 1, // MICROBIT_RADIO_EVT_DATAGRAM
|
MICROBIT_RADIO_EVT_DATAGRAM = 1, // MICROBIT_RADIO_EVT_DATAGRAM
|
||||||
|
//% blockIdentity="control.eventValueId"
|
||||||
MICROBIT_ACCELEROMETER_EVT_DATA_UPDATE = 1, // MICROBIT_ACCELEROMETER_EVT_DATA_UPDATE
|
MICROBIT_ACCELEROMETER_EVT_DATA_UPDATE = 1, // MICROBIT_ACCELEROMETER_EVT_DATA_UPDATE
|
||||||
|
//% blockIdentity="control.eventValueId"
|
||||||
MICROBIT_PIN_EVT_RISE = 2, // MICROBIT_PIN_EVT_RISE
|
MICROBIT_PIN_EVT_RISE = 2, // MICROBIT_PIN_EVT_RISE
|
||||||
|
//% blockIdentity="control.eventValueId"
|
||||||
MICROBIT_PIN_EVT_FALL = 3, // MICROBIT_PIN_EVT_FALL
|
MICROBIT_PIN_EVT_FALL = 3, // MICROBIT_PIN_EVT_FALL
|
||||||
|
//% blockIdentity="control.eventValueId"
|
||||||
MICROBIT_PIN_EVT_PULSE_HI = 4, // MICROBIT_PIN_EVT_PULSE_HI
|
MICROBIT_PIN_EVT_PULSE_HI = 4, // MICROBIT_PIN_EVT_PULSE_HI
|
||||||
|
//% blockIdentity="control.eventValueId"
|
||||||
MICROBIT_PIN_EVT_PULSE_LO = 5, // MICROBIT_PIN_EVT_PULSE_LO
|
MICROBIT_PIN_EVT_PULSE_LO = 5, // MICROBIT_PIN_EVT_PULSE_LO
|
||||||
|
//% blockIdentity="control.eventValueId"
|
||||||
MES_ALERT_EVT_ALARM1 = 6, // MES_ALERT_EVT_ALARM1
|
MES_ALERT_EVT_ALARM1 = 6, // MES_ALERT_EVT_ALARM1
|
||||||
|
//% blockIdentity="control.eventValueId"
|
||||||
MES_ALERT_EVT_ALARM2 = 7, // MES_ALERT_EVT_ALARM2
|
MES_ALERT_EVT_ALARM2 = 7, // MES_ALERT_EVT_ALARM2
|
||||||
|
//% blockIdentity="control.eventValueId"
|
||||||
MES_ALERT_EVT_ALARM3 = 8, // MES_ALERT_EVT_ALARM3
|
MES_ALERT_EVT_ALARM3 = 8, // MES_ALERT_EVT_ALARM3
|
||||||
|
//% blockIdentity="control.eventValueId"
|
||||||
MES_ALERT_EVT_ALARM4 = 9, // MES_ALERT_EVT_ALARM4
|
MES_ALERT_EVT_ALARM4 = 9, // MES_ALERT_EVT_ALARM4
|
||||||
|
//% blockIdentity="control.eventValueId"
|
||||||
MES_ALERT_EVT_ALARM5 = 10, // MES_ALERT_EVT_ALARM5
|
MES_ALERT_EVT_ALARM5 = 10, // MES_ALERT_EVT_ALARM5
|
||||||
|
//% blockIdentity="control.eventValueId"
|
||||||
MES_ALERT_EVT_ALARM6 = 11, // MES_ALERT_EVT_ALARM6
|
MES_ALERT_EVT_ALARM6 = 11, // MES_ALERT_EVT_ALARM6
|
||||||
|
//% blockIdentity="control.eventValueId"
|
||||||
MES_ALERT_EVT_DISPLAY_TOAST = 1, // MES_ALERT_EVT_DISPLAY_TOAST
|
MES_ALERT_EVT_DISPLAY_TOAST = 1, // MES_ALERT_EVT_DISPLAY_TOAST
|
||||||
|
//% blockIdentity="control.eventValueId"
|
||||||
MES_ALERT_EVT_FIND_MY_PHONE = 5, // MES_ALERT_EVT_FIND_MY_PHONE
|
MES_ALERT_EVT_FIND_MY_PHONE = 5, // MES_ALERT_EVT_FIND_MY_PHONE
|
||||||
|
//% blockIdentity="control.eventValueId"
|
||||||
MES_ALERT_EVT_PLAY_RINGTONE = 4, // MES_ALERT_EVT_PLAY_RINGTONE
|
MES_ALERT_EVT_PLAY_RINGTONE = 4, // MES_ALERT_EVT_PLAY_RINGTONE
|
||||||
|
//% blockIdentity="control.eventValueId"
|
||||||
MES_ALERT_EVT_PLAY_SOUND = 3, // MES_ALERT_EVT_PLAY_SOUND
|
MES_ALERT_EVT_PLAY_SOUND = 3, // MES_ALERT_EVT_PLAY_SOUND
|
||||||
|
//% blockIdentity="control.eventValueId"
|
||||||
MES_ALERT_EVT_VIBRATE = 2, // MES_ALERT_EVT_VIBRATE
|
MES_ALERT_EVT_VIBRATE = 2, // MES_ALERT_EVT_VIBRATE
|
||||||
|
//% blockIdentity="control.eventValueId"
|
||||||
MES_CAMERA_EVT_LAUNCH_PHOTO_MODE = 1, // MES_CAMERA_EVT_LAUNCH_PHOTO_MODE
|
MES_CAMERA_EVT_LAUNCH_PHOTO_MODE = 1, // MES_CAMERA_EVT_LAUNCH_PHOTO_MODE
|
||||||
|
//% blockIdentity="control.eventValueId"
|
||||||
MES_CAMERA_EVT_LAUNCH_VIDEO_MODE = 2, // MES_CAMERA_EVT_LAUNCH_VIDEO_MODE
|
MES_CAMERA_EVT_LAUNCH_VIDEO_MODE = 2, // MES_CAMERA_EVT_LAUNCH_VIDEO_MODE
|
||||||
|
//% blockIdentity="control.eventValueId"
|
||||||
MES_CAMERA_EVT_START_VIDEO_CAPTURE = 4, // MES_CAMERA_EVT_START_VIDEO_CAPTURE
|
MES_CAMERA_EVT_START_VIDEO_CAPTURE = 4, // MES_CAMERA_EVT_START_VIDEO_CAPTURE
|
||||||
|
//% blockIdentity="control.eventValueId"
|
||||||
MES_CAMERA_EVT_STOP_PHOTO_MODE = 6, // MES_CAMERA_EVT_STOP_PHOTO_MODE
|
MES_CAMERA_EVT_STOP_PHOTO_MODE = 6, // MES_CAMERA_EVT_STOP_PHOTO_MODE
|
||||||
|
//% blockIdentity="control.eventValueId"
|
||||||
MES_CAMERA_EVT_STOP_VIDEO_CAPTURE = 5, // MES_CAMERA_EVT_STOP_VIDEO_CAPTURE
|
MES_CAMERA_EVT_STOP_VIDEO_CAPTURE = 5, // MES_CAMERA_EVT_STOP_VIDEO_CAPTURE
|
||||||
|
//% blockIdentity="control.eventValueId"
|
||||||
MES_CAMERA_EVT_STOP_VIDEO_MODE = 7, // MES_CAMERA_EVT_STOP_VIDEO_MODE
|
MES_CAMERA_EVT_STOP_VIDEO_MODE = 7, // MES_CAMERA_EVT_STOP_VIDEO_MODE
|
||||||
|
//% blockIdentity="control.eventValueId"
|
||||||
MES_CAMERA_EVT_TAKE_PHOTO = 3, // MES_CAMERA_EVT_TAKE_PHOTO
|
MES_CAMERA_EVT_TAKE_PHOTO = 3, // MES_CAMERA_EVT_TAKE_PHOTO
|
||||||
|
//% blockIdentity="control.eventValueId"
|
||||||
MES_CAMERA_EVT_TOGGLE_FRONT_REAR = 8, // MES_CAMERA_EVT_TOGGLE_FRONT_REAR
|
MES_CAMERA_EVT_TOGGLE_FRONT_REAR = 8, // MES_CAMERA_EVT_TOGGLE_FRONT_REAR
|
||||||
|
//% blockIdentity="control.eventValueId"
|
||||||
MES_DEVICE_DISPLAY_OFF = 5, // MES_DEVICE_DISPLAY_OFF
|
MES_DEVICE_DISPLAY_OFF = 5, // MES_DEVICE_DISPLAY_OFF
|
||||||
|
//% blockIdentity="control.eventValueId"
|
||||||
MES_DEVICE_DISPLAY_ON = 6, // MES_DEVICE_DISPLAY_ON
|
MES_DEVICE_DISPLAY_ON = 6, // MES_DEVICE_DISPLAY_ON
|
||||||
|
//% blockIdentity="control.eventValueId"
|
||||||
MES_DEVICE_GESTURE_DEVICE_SHAKEN = 4, // MES_DEVICE_GESTURE_DEVICE_SHAKEN
|
MES_DEVICE_GESTURE_DEVICE_SHAKEN = 4, // MES_DEVICE_GESTURE_DEVICE_SHAKEN
|
||||||
|
//% blockIdentity="control.eventValueId"
|
||||||
MES_DEVICE_INCOMING_CALL = 7, // MES_DEVICE_INCOMING_CALL
|
MES_DEVICE_INCOMING_CALL = 7, // MES_DEVICE_INCOMING_CALL
|
||||||
|
//% blockIdentity="control.eventValueId"
|
||||||
MES_DEVICE_INCOMING_MESSAGE = 8, // MES_DEVICE_INCOMING_MESSAGE
|
MES_DEVICE_INCOMING_MESSAGE = 8, // MES_DEVICE_INCOMING_MESSAGE
|
||||||
|
//% blockIdentity="control.eventValueId"
|
||||||
MES_DEVICE_ORIENTATION_LANDSCAPE = 1, // MES_DEVICE_ORIENTATION_LANDSCAPE
|
MES_DEVICE_ORIENTATION_LANDSCAPE = 1, // MES_DEVICE_ORIENTATION_LANDSCAPE
|
||||||
|
//% blockIdentity="control.eventValueId"
|
||||||
MES_DEVICE_ORIENTATION_PORTRAIT = 2, // MES_DEVICE_ORIENTATION_PORTRAIT
|
MES_DEVICE_ORIENTATION_PORTRAIT = 2, // MES_DEVICE_ORIENTATION_PORTRAIT
|
||||||
|
//% blockIdentity="control.eventValueId"
|
||||||
MES_DPAD_BUTTON_1_DOWN = 9, // MES_DPAD_BUTTON_1_DOWN
|
MES_DPAD_BUTTON_1_DOWN = 9, // MES_DPAD_BUTTON_1_DOWN
|
||||||
|
//% blockIdentity="control.eventValueId"
|
||||||
MES_DPAD_BUTTON_1_UP = 10, // MES_DPAD_BUTTON_1_UP
|
MES_DPAD_BUTTON_1_UP = 10, // MES_DPAD_BUTTON_1_UP
|
||||||
|
//% blockIdentity="control.eventValueId"
|
||||||
MES_DPAD_BUTTON_2_DOWN = 11, // MES_DPAD_BUTTON_2_DOWN
|
MES_DPAD_BUTTON_2_DOWN = 11, // MES_DPAD_BUTTON_2_DOWN
|
||||||
|
//% blockIdentity="control.eventValueId"
|
||||||
MES_DPAD_BUTTON_2_UP = 12, // MES_DPAD_BUTTON_2_UP
|
MES_DPAD_BUTTON_2_UP = 12, // MES_DPAD_BUTTON_2_UP
|
||||||
|
//% blockIdentity="control.eventValueId"
|
||||||
MES_DPAD_BUTTON_3_DOWN = 13, // MES_DPAD_BUTTON_3_DOWN
|
MES_DPAD_BUTTON_3_DOWN = 13, // MES_DPAD_BUTTON_3_DOWN
|
||||||
|
//% blockIdentity="control.eventValueId"
|
||||||
MES_DPAD_BUTTON_3_UP = 14, // MES_DPAD_BUTTON_3_UP
|
MES_DPAD_BUTTON_3_UP = 14, // MES_DPAD_BUTTON_3_UP
|
||||||
|
//% blockIdentity="control.eventValueId"
|
||||||
MES_DPAD_BUTTON_4_DOWN = 15, // MES_DPAD_BUTTON_4_DOWN
|
MES_DPAD_BUTTON_4_DOWN = 15, // MES_DPAD_BUTTON_4_DOWN
|
||||||
|
//% blockIdentity="control.eventValueId"
|
||||||
MES_DPAD_BUTTON_4_UP = 16, // MES_DPAD_BUTTON_4_UP
|
MES_DPAD_BUTTON_4_UP = 16, // MES_DPAD_BUTTON_4_UP
|
||||||
|
//% blockIdentity="control.eventValueId"
|
||||||
MES_DPAD_BUTTON_A_DOWN = 1, // MES_DPAD_BUTTON_A_DOWN
|
MES_DPAD_BUTTON_A_DOWN = 1, // MES_DPAD_BUTTON_A_DOWN
|
||||||
|
//% blockIdentity="control.eventValueId"
|
||||||
MES_DPAD_BUTTON_A_UP = 2, // MES_DPAD_BUTTON_A_UP
|
MES_DPAD_BUTTON_A_UP = 2, // MES_DPAD_BUTTON_A_UP
|
||||||
|
//% blockIdentity="control.eventValueId"
|
||||||
MES_DPAD_BUTTON_B_DOWN = 3, // MES_DPAD_BUTTON_B_DOWN
|
MES_DPAD_BUTTON_B_DOWN = 3, // MES_DPAD_BUTTON_B_DOWN
|
||||||
|
//% blockIdentity="control.eventValueId"
|
||||||
MES_DPAD_BUTTON_B_UP = 4, // MES_DPAD_BUTTON_B_UP
|
MES_DPAD_BUTTON_B_UP = 4, // MES_DPAD_BUTTON_B_UP
|
||||||
|
//% blockIdentity="control.eventValueId"
|
||||||
MES_DPAD_BUTTON_C_DOWN = 5, // MES_DPAD_BUTTON_C_DOWN
|
MES_DPAD_BUTTON_C_DOWN = 5, // MES_DPAD_BUTTON_C_DOWN
|
||||||
|
//% blockIdentity="control.eventValueId"
|
||||||
MES_DPAD_BUTTON_C_UP = 6, // MES_DPAD_BUTTON_C_UP
|
MES_DPAD_BUTTON_C_UP = 6, // MES_DPAD_BUTTON_C_UP
|
||||||
|
//% blockIdentity="control.eventValueId"
|
||||||
MES_DPAD_BUTTON_D_DOWN = 7, // MES_DPAD_BUTTON_D_DOWN
|
MES_DPAD_BUTTON_D_DOWN = 7, // MES_DPAD_BUTTON_D_DOWN
|
||||||
|
//% blockIdentity="control.eventValueId"
|
||||||
MES_DPAD_BUTTON_D_UP = 8, // MES_DPAD_BUTTON_D_UP
|
MES_DPAD_BUTTON_D_UP = 8, // MES_DPAD_BUTTON_D_UP
|
||||||
|
//% blockIdentity="control.eventValueId"
|
||||||
MES_REMOTE_CONTROL_EVT_FORWARD = 6, // MES_REMOTE_CONTROL_EVT_FORWARD
|
MES_REMOTE_CONTROL_EVT_FORWARD = 6, // MES_REMOTE_CONTROL_EVT_FORWARD
|
||||||
|
//% blockIdentity="control.eventValueId"
|
||||||
MES_REMOTE_CONTROL_EVT_NEXTTRACK = 4, // MES_REMOTE_CONTROL_EVT_NEXTTRACK
|
MES_REMOTE_CONTROL_EVT_NEXTTRACK = 4, // MES_REMOTE_CONTROL_EVT_NEXTTRACK
|
||||||
|
//% blockIdentity="control.eventValueId"
|
||||||
MES_REMOTE_CONTROL_EVT_PAUSE = 2, // MES_REMOTE_CONTROL_EVT_PAUSE
|
MES_REMOTE_CONTROL_EVT_PAUSE = 2, // MES_REMOTE_CONTROL_EVT_PAUSE
|
||||||
|
//% blockIdentity="control.eventValueId"
|
||||||
MES_REMOTE_CONTROL_EVT_PLAY = 1, // MES_REMOTE_CONTROL_EVT_PLAY
|
MES_REMOTE_CONTROL_EVT_PLAY = 1, // MES_REMOTE_CONTROL_EVT_PLAY
|
||||||
|
//% blockIdentity="control.eventValueId"
|
||||||
MES_REMOTE_CONTROL_EVT_PREVTRACK = 5, // MES_REMOTE_CONTROL_EVT_PREVTRACK
|
MES_REMOTE_CONTROL_EVT_PREVTRACK = 5, // MES_REMOTE_CONTROL_EVT_PREVTRACK
|
||||||
|
//% blockIdentity="control.eventValueId"
|
||||||
MES_REMOTE_CONTROL_EVT_REWIND = 7, // MES_REMOTE_CONTROL_EVT_REWIND
|
MES_REMOTE_CONTROL_EVT_REWIND = 7, // MES_REMOTE_CONTROL_EVT_REWIND
|
||||||
|
//% blockIdentity="control.eventValueId"
|
||||||
MES_REMOTE_CONTROL_EVT_STOP = 3, // MES_REMOTE_CONTROL_EVT_STOP
|
MES_REMOTE_CONTROL_EVT_STOP = 3, // MES_REMOTE_CONTROL_EVT_STOP
|
||||||
|
//% blockIdentity="control.eventValueId"
|
||||||
MES_REMOTE_CONTROL_EVT_VOLUMEDOWN = 9, // MES_REMOTE_CONTROL_EVT_VOLUMEDOWN
|
MES_REMOTE_CONTROL_EVT_VOLUMEDOWN = 9, // MES_REMOTE_CONTROL_EVT_VOLUMEDOWN
|
||||||
|
//% blockIdentity="control.eventValueId"
|
||||||
MES_REMOTE_CONTROL_EVT_VOLUMEUP = 8, // MES_REMOTE_CONTROL_EVT_VOLUMEUP
|
MES_REMOTE_CONTROL_EVT_VOLUMEUP = 8, // MES_REMOTE_CONTROL_EVT_VOLUMEUP
|
||||||
}
|
}
|
||||||
declare namespace control {
|
declare namespace control {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
declare enum DisplayMode {
|
declare const enum DisplayMode {
|
||||||
//% block="black and white"
|
//% block="black and white"
|
||||||
BackAndWhite = 0, // DISPLAY_MODE_BLACK_AND_WHITE
|
BackAndWhite = 0, // DISPLAY_MODE_BLACK_AND_WHITE
|
||||||
//% block="greyscale"
|
//% block="greyscale"
|
||||||
@@ -247,7 +381,7 @@ declare namespace led {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
declare enum MotorCommand {
|
declare const enum MotorCommand {
|
||||||
//% block=coast
|
//% block=coast
|
||||||
Coast = 0,
|
Coast = 0,
|
||||||
//% block=break
|
//% block=break
|
||||||
@@ -257,7 +391,7 @@ declare namespace led {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
declare enum Motor {
|
declare const enum Motor {
|
||||||
A = 0,
|
A = 0,
|
||||||
B = 1,
|
B = 1,
|
||||||
//% block="A and B"
|
//% block="A and B"
|
||||||
@@ -267,7 +401,7 @@ declare namespace motors {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
declare enum DigitalPin {
|
declare const enum DigitalPin {
|
||||||
P0 = 19, // MICROBIT_ID_IO_P12
|
P0 = 19, // MICROBIT_ID_IO_P12
|
||||||
P1 = 7, // MICROBIT_ID_IO_P0
|
P1 = 7, // MICROBIT_ID_IO_P0
|
||||||
P2 = 8, // MICROBIT_ID_IO_P1
|
P2 = 8, // MICROBIT_ID_IO_P1
|
||||||
@@ -288,7 +422,7 @@ declare namespace motors {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
declare enum AnalogPin {
|
declare const enum AnalogPin {
|
||||||
P1 = 7, // MICROBIT_ID_IO_P0
|
P1 = 7, // MICROBIT_ID_IO_P0
|
||||||
P2 = 8, // MICROBIT_ID_IO_P1
|
P2 = 8, // MICROBIT_ID_IO_P1
|
||||||
C4 = 10, // MICROBIT_ID_IO_P3
|
C4 = 10, // MICROBIT_ID_IO_P3
|
||||||
@@ -300,13 +434,13 @@ declare namespace motors {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
declare enum PulseValue {
|
declare const enum PulseValue {
|
||||||
High = 4, // MICROBIT_PIN_EVT_PULSE_HI
|
High = 4, // MICROBIT_PIN_EVT_PULSE_HI
|
||||||
Low = 5, // MICROBIT_PIN_EVT_PULSE_LO
|
Low = 5, // MICROBIT_PIN_EVT_PULSE_LO
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
declare enum PinPullMode {
|
declare const enum PinPullMode {
|
||||||
//% block="down"
|
//% block="down"
|
||||||
PullDown = 0,
|
PullDown = 0,
|
||||||
//% block="up"
|
//% block="up"
|
||||||
@@ -316,7 +450,7 @@ declare namespace motors {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
declare enum PinEventType {
|
declare const enum PinEventType {
|
||||||
//% block="edge"
|
//% block="edge"
|
||||||
Edge = 1, // MICROBIT_PIN_EVENT_ON_EDGE
|
Edge = 1, // MICROBIT_PIN_EVENT_ON_EDGE
|
||||||
//% block="pulse"
|
//% block="pulse"
|
||||||
@@ -328,7 +462,7 @@ declare namespace motors {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
declare enum SerialPin {
|
declare const enum SerialPin {
|
||||||
C16 = 9, // MICROBIT_ID_IO_P2
|
C16 = 9, // MICROBIT_ID_IO_P2
|
||||||
C17 = 15, // MICROBIT_ID_IO_P8
|
C17 = 15, // MICROBIT_ID_IO_P8
|
||||||
P0 = 19, // MICROBIT_ID_IO_P12
|
P0 = 19, // MICROBIT_ID_IO_P12
|
||||||
@@ -338,7 +472,7 @@ declare namespace motors {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
declare enum BaudRate {
|
declare const enum BaudRate {
|
||||||
//% block=115200
|
//% block=115200
|
||||||
BaudRate115200 = 115200,
|
BaudRate115200 = 115200,
|
||||||
//% block=57600
|
//% block=57600
|
||||||
@@ -348,7 +482,7 @@ declare namespace motors {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
declare enum Delimiters {
|
declare const enum Delimiters {
|
||||||
//% block="new line"
|
//% block="new line"
|
||||||
NewLine = 1,
|
NewLine = 1,
|
||||||
//% block=","
|
//% block=","
|
||||||
@@ -366,7 +500,7 @@ declare namespace serial {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
declare enum NumberFormat {
|
declare const enum NumberFormat {
|
||||||
Int8LE = 1,
|
Int8LE = 1,
|
||||||
UInt8LE = 2,
|
UInt8LE = 2,
|
||||||
Int16LE = 3,
|
Int16LE = 3,
|
||||||
|
|||||||
@@ -32,22 +32,22 @@ namespace game {
|
|||||||
let _countdownPause: number = 0;
|
let _countdownPause: number = 0;
|
||||||
let _level: number = 1;
|
let _level: number = 1;
|
||||||
let _gameId: number = 0;
|
let _gameId: number = 0;
|
||||||
let img: Image;
|
let _img: Image;
|
||||||
let sprites: LedSprite[];
|
let _sprites: LedSprite[];
|
||||||
|
let _paused: boolean = false;
|
||||||
|
let _backgroundAnimation = false; // indicates if an auxiliary animation (and fiber) is already running
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new LED sprite pointing to the right.
|
* Creates a new LED sprite pointing to the right.
|
||||||
* @param x sprite horizontal coordinate, eg: 2
|
* @param x sprite horizontal coordinate, eg: 2
|
||||||
* @param y sprite vertical coordinate, eg: 2
|
* @param y sprite vertical coordinate, eg: 2
|
||||||
*/
|
*/
|
||||||
//% weight=60
|
//% weight=60 blockGap=8 help=game/create-sprite
|
||||||
//% blockId=game_create_sprite block="create sprite at|x: %x|y: %y"
|
//% blockId=game_create_sprite block="create sprite at|x: %x|y: %y"
|
||||||
//% parts="ledmatrix"
|
//% parts="ledmatrix"
|
||||||
export function createSprite(x: number, y: number): LedSprite {
|
export function createSprite(x: number, y: number): LedSprite {
|
||||||
init();
|
init();
|
||||||
let p = new LedSprite(x, y);
|
let p = new LedSprite(x, y);
|
||||||
sprites.push(p);
|
|
||||||
plot();
|
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -61,7 +61,7 @@ namespace game {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds points to the current score
|
* Adds points to the current score and shows an animation
|
||||||
* @param points amount of points to change, eg: 1
|
* @param points amount of points to change, eg: 1
|
||||||
*/
|
*/
|
||||||
//% weight=10 help=game/add-score
|
//% weight=10 help=game/add-score
|
||||||
@@ -69,18 +69,22 @@ namespace game {
|
|||||||
//% parts="ledmatrix"
|
//% parts="ledmatrix"
|
||||||
export function addScore(points: number): void {
|
export function addScore(points: number): void {
|
||||||
setScore(_score + points);
|
setScore(_score + points);
|
||||||
control.inBackground(() => {
|
if (!_paused && !_backgroundAnimation) {
|
||||||
led.stopAnimation();
|
_backgroundAnimation = true;
|
||||||
basic.showAnimation(`0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 0 0 0 1 0 0 0 0 0
|
control.inBackground(() => {
|
||||||
0 0 0 0 0 0 0 1 0 0 0 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0
|
led.stopAnimation();
|
||||||
0 0 1 0 0 0 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
basic.showAnimation(`0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 0 0 0 1 0 0 0 0 0
|
||||||
0 0 0 0 0 0 0 1 0 0 0 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0
|
0 0 0 0 0 0 0 1 0 0 0 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0
|
||||||
0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 0 0 0 1 0 0 0 0 0`, 20);
|
0 0 1 0 0 0 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||||
});
|
0 0 0 0 0 0 0 1 0 0 0 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0
|
||||||
|
0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 0 0 0 1 0 0 0 0 0`, 20);
|
||||||
|
_backgroundAnimation = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Starts a game countdown timer
|
* Shows an animation, then starts a game countdown timer, which causes Game Over when it reaches 0
|
||||||
* @param ms countdown duration in milliseconds, eg: 10000
|
* @param ms countdown duration in milliseconds, eg: 10000
|
||||||
*/
|
*/
|
||||||
//% weight=9 help=game/start-countdown
|
//% weight=9 help=game/start-countdown
|
||||||
@@ -96,6 +100,7 @@ namespace game {
|
|||||||
_countdownPause = Math.max(500, ms);
|
_countdownPause = Math.max(500, ms);
|
||||||
_startTime = -1;
|
_startTime = -1;
|
||||||
_endTime = input.runningTime() + _countdownPause;
|
_endTime = input.runningTime() + _countdownPause;
|
||||||
|
_paused = false;
|
||||||
control.inBackground(() => {
|
control.inBackground(() => {
|
||||||
basic.pause(_countdownPause);
|
basic.pause(_countdownPause);
|
||||||
gameOver();
|
gameOver();
|
||||||
@@ -104,7 +109,7 @@ namespace game {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Displays a game over animation.
|
* Displays a game over animation and the score.
|
||||||
*/
|
*/
|
||||||
//% weight=8 help=game/game-over
|
//% weight=8 help=game/game-over
|
||||||
//% blockId=game_game_over block="game over"
|
//% blockId=game_game_over block="game over"
|
||||||
@@ -115,7 +120,6 @@ namespace game {
|
|||||||
unplugEvents();
|
unplugEvents();
|
||||||
led.stopAnimation();
|
led.stopAnimation();
|
||||||
led.setBrightness(255);
|
led.setBrightness(255);
|
||||||
led.setDisplayMode(DisplayMode.BackAndWhite);
|
|
||||||
while (true) {
|
while (true) {
|
||||||
for (let i = 0; i < 8; i++) {
|
for (let i = 0; i < 8; i++) {
|
||||||
basic.clearScreen();
|
basic.clearScreen();
|
||||||
@@ -146,8 +150,9 @@ namespace game {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the current score value
|
* Sets the current score value
|
||||||
* @param value TODO
|
* @param value new score value.
|
||||||
*/
|
*/
|
||||||
|
//% blockId=game_set_score block="set score %points" blockGap=8
|
||||||
//% weight=10 help=game/set-score
|
//% weight=10 help=game/set-score
|
||||||
export function setScore(value: number): void {
|
export function setScore(value: number): void {
|
||||||
_score = Math.max(0, value);
|
_score = Math.max(0, value);
|
||||||
@@ -202,14 +207,15 @@ namespace game {
|
|||||||
//% parts="ledmatrix"
|
//% parts="ledmatrix"
|
||||||
export function removeLife(life: number): void {
|
export function removeLife(life: number): void {
|
||||||
setLife(_life - life);
|
setLife(_life - life);
|
||||||
control.inBackground(() => {
|
if (!_paused)
|
||||||
led.stopAnimation();
|
control.inBackground(() => {
|
||||||
basic.showAnimation(`1 0 0 0 1 0 0 0 0 0 1 0 0 0 1 0 0 0 0 0
|
led.stopAnimation();
|
||||||
|
basic.showAnimation(`1 0 0 0 1 0 0 0 0 0 1 0 0 0 1 0 0 0 0 0
|
||||||
0 1 0 1 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0
|
0 1 0 1 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0
|
||||||
0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0
|
0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0
|
||||||
0 1 0 1 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0
|
0 1 0 1 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0
|
||||||
1 0 0 0 1 0 0 0 0 0 1 0 0 0 1 0 0 0 0 0`, 40);
|
1 0 0 0 1 0 0 0 0 0 1 0 0 0 1 0 0 0 0 0`, 40);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -264,10 +270,38 @@ namespace game {
|
|||||||
* Indicates if the game is display the game over sequence.
|
* Indicates if the game is display the game over sequence.
|
||||||
*/
|
*/
|
||||||
export function isGameOver(): boolean {
|
export function isGameOver(): boolean {
|
||||||
let over: boolean;
|
|
||||||
return _isGameOver;
|
return _isGameOver;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Indicates if the game rendering is paused to allow other animations
|
||||||
|
*/
|
||||||
|
//%
|
||||||
|
export function isPaused(): boolean {
|
||||||
|
return _paused;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Pauses the game rendering engine to allow other animations
|
||||||
|
*/
|
||||||
|
//% blockId=game_pause block="pause"
|
||||||
|
//% advanced=true blockGap=8 help=game/pause
|
||||||
|
export function pause(): void {
|
||||||
|
plot()
|
||||||
|
_paused = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resumes the game rendering engine
|
||||||
|
*/
|
||||||
|
//% blockId=game_resume block="resume"
|
||||||
|
//% advanced=true blockGap=8 help=game/resumeP
|
||||||
|
export function resume(): void {
|
||||||
|
_paused = false;
|
||||||
|
plot();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* returns false if game can't start
|
* returns false if game can't start
|
||||||
*/
|
*/
|
||||||
@@ -287,29 +321,35 @@ namespace game {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A game sprite rendered as a single LED
|
||||||
|
*/
|
||||||
|
//%
|
||||||
export class LedSprite {
|
export class LedSprite {
|
||||||
private _x: number;
|
private _x: number;
|
||||||
private _y: number;
|
private _y: number;
|
||||||
private _dir: number;
|
private _dir: number;
|
||||||
private _brightness: number;
|
private _brightness: number;
|
||||||
private _blink: number;
|
private _blink: number;
|
||||||
|
private _enabled: boolean;
|
||||||
|
|
||||||
constructor(x: number, y: number) {
|
constructor(x: number, y: number) {
|
||||||
this._x = Math.clamp(0, 4, x);
|
this._x = Math.clamp(0, 4, x);
|
||||||
this._y = Math.clamp(0, 4, y);
|
this._y = Math.clamp(0, 4, y);
|
||||||
this._dir = 90;
|
this._dir = 90;
|
||||||
this._brightness = 255;
|
this._brightness = 255;
|
||||||
|
this._enabled = true;
|
||||||
init();
|
init();
|
||||||
sprites.push(this);
|
_sprites.push(this);
|
||||||
plot();
|
plot();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Move a certain number of LEDs
|
* Move a certain number of LEDs in the current direction
|
||||||
* @param this the sprite to move
|
* @param this the sprite to move
|
||||||
* @param leds number of leds to move, eg: 1, -1
|
* @param leds number of leds to move, eg: 1, -1
|
||||||
*/
|
*/
|
||||||
//% weight=50
|
//% weight=50 help=game/move
|
||||||
//% blockId=game_move_sprite block="%sprite|move by %leds" blockGap=8
|
//% blockId=game_move_sprite block="%sprite|move by %leds" blockGap=8
|
||||||
//% parts="ledmatrix"
|
//% parts="ledmatrix"
|
||||||
public move(leds: number): void {
|
public move(leds: number): void {
|
||||||
@@ -355,10 +395,10 @@ namespace game {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If touching the edge of the stage, then bounce away.
|
* If touching the edge of the stage and facing towards it, then turn away.
|
||||||
* @param this TODO
|
* @param this TODO
|
||||||
*/
|
*/
|
||||||
//% weight=18
|
//% weight=18 help=game/if-on-edge-bounce
|
||||||
//% blockId=game_sprite_bounce block="%sprite|if on edge, bounce"
|
//% blockId=game_sprite_bounce block="%sprite|if on edge, bounce"
|
||||||
//% parts="ledmatrix"
|
//% parts="ledmatrix"
|
||||||
public ifOnEdgeBounce(): void {
|
public ifOnEdgeBounce(): void {
|
||||||
@@ -412,7 +452,7 @@ namespace game {
|
|||||||
* @param direction left or right
|
* @param direction left or right
|
||||||
* @param degrees angle in degrees to turn, eg: 45, 90, 180, 135
|
* @param degrees angle in degrees to turn, eg: 45, 90, 180, 135
|
||||||
*/
|
*/
|
||||||
//% weight=49
|
//% weight=49 help=game/turn
|
||||||
//% blockId=game_turn_sprite block="%sprite|turn %direction|by (°) %degrees"
|
//% blockId=game_turn_sprite block="%sprite|turn %direction|by (°) %degrees"
|
||||||
public turn(direction: Direction, degrees: number) {
|
public turn(direction: Direction, degrees: number) {
|
||||||
if (direction == Direction.Right)
|
if (direction == Direction.Right)
|
||||||
@@ -444,7 +484,7 @@ namespace game {
|
|||||||
* @param property the name of the property to change
|
* @param property the name of the property to change
|
||||||
* @param the updated value
|
* @param the updated value
|
||||||
*/
|
*/
|
||||||
//% weight=29
|
//% weight=29 help=game/set
|
||||||
//% blockId=game_sprite_set_property block="%sprite|set %property|to %value" blockGap=8
|
//% blockId=game_sprite_set_property block="%sprite|set %property|to %value" blockGap=8
|
||||||
public set(property: LedSpriteProperty, value: number) {
|
public set(property: LedSpriteProperty, value: number) {
|
||||||
switch (property) {
|
switch (property) {
|
||||||
@@ -461,7 +501,7 @@ namespace game {
|
|||||||
* @param property the name of the property to change
|
* @param property the name of the property to change
|
||||||
* @param value amount of change, eg: 1
|
* @param value amount of change, eg: 1
|
||||||
*/
|
*/
|
||||||
//% weight=30
|
//% weight=30 help=game/change
|
||||||
//% blockId=game_sprite_change_xy block="%sprite|change %property|by %value" blockGap=8
|
//% blockId=game_sprite_change_xy block="%sprite|change %property|by %value" blockGap=8
|
||||||
public change(property: LedSpriteProperty, value: number) {
|
public change(property: LedSpriteProperty, value: number) {
|
||||||
switch (property) {
|
switch (property) {
|
||||||
@@ -477,7 +517,7 @@ namespace game {
|
|||||||
* Gets a property of the sprite
|
* Gets a property of the sprite
|
||||||
* @param property the name of the property to change
|
* @param property the name of the property to change
|
||||||
*/
|
*/
|
||||||
//% weight=28
|
//% weight=28 help=game/get
|
||||||
//% blockId=game_sprite_property block="%sprite|%property"
|
//% blockId=game_sprite_property block="%sprite|%property"
|
||||||
public get(property: LedSpriteProperty) {
|
public get(property: LedSpriteProperty) {
|
||||||
switch (property) {
|
switch (property) {
|
||||||
@@ -567,21 +607,21 @@ namespace game {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reports true if sprite is touching specified sprite
|
* Reports true if sprite has the same position as specified sprite
|
||||||
* @param this TODO
|
* @param this TODO
|
||||||
* @param other TODO
|
* @param other TODO
|
||||||
*/
|
*/
|
||||||
//% weight=20
|
//% weight=20 help=game/is-touching
|
||||||
//% blockId=game_sprite_touching_sprite block="%sprite|touching %other|?" blockGap=8
|
//% blockId=game_sprite_touching_sprite block="%sprite|touching %other|?" blockGap=8
|
||||||
public isTouching(other: LedSprite): boolean {
|
public isTouching(other: LedSprite): boolean {
|
||||||
return this._x == other._x && this._y == other._y;
|
return this._enabled && other._enabled && this._x == other._x && this._y == other._y;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reports true if sprite is touching an edge
|
* Reports true if sprite is touching an edge
|
||||||
* @param this TODO
|
* @param this TODO
|
||||||
*/
|
*/
|
||||||
//% weight=19
|
//% weight=19 help=game/is-touching-edge
|
||||||
//% blockId=game_sprite_touching_edge block="%sprite|touching edge?" blockGap=8
|
//% blockId=game_sprite_touching_edge block="%sprite|touching edge?" blockGap=8
|
||||||
public isTouchingEdge(): boolean {
|
public isTouchingEdge(): boolean {
|
||||||
return this._x == 0 || this._x == 4 || this._y == 0 || this._y == 4;
|
return this._x == 0 || this._x == 4 || this._y == 0 || this._y == 4;
|
||||||
@@ -589,7 +629,7 @@ namespace game {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Turns on the sprite (on by default)
|
* Turns on the sprite (on by default)
|
||||||
* @param this TODO
|
* @param this the sprite
|
||||||
*/
|
*/
|
||||||
public on(): void {
|
public on(): void {
|
||||||
this.setBrightness(255);
|
this.setBrightness(255);
|
||||||
@@ -597,7 +637,7 @@ namespace game {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Turns off the sprite (on by default)
|
* Turns off the sprite (on by default)
|
||||||
* @param this TODO
|
* @param this the sprite
|
||||||
*/
|
*/
|
||||||
public off(): void {
|
public off(): void {
|
||||||
this.setBrightness(0);
|
this.setBrightness(0);
|
||||||
@@ -605,8 +645,8 @@ namespace game {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the ``brightness`` of a sprite
|
* Set the ``brightness`` of a sprite
|
||||||
* @param this TODO
|
* @param this the sprite
|
||||||
* @param brightness TODO
|
* @param brightness the brightness from 0 (off) to 255 (on), eg: 255.
|
||||||
*/
|
*/
|
||||||
//% parts="ledmatrix"
|
//% parts="ledmatrix"
|
||||||
public setBrightness(brightness: number): void {
|
public setBrightness(brightness: number): void {
|
||||||
@@ -616,8 +656,9 @@ namespace game {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Reports the ``brightness` of a sprite on the LED screen
|
* Reports the ``brightness` of a sprite on the LED screen
|
||||||
* @param this TODO
|
* @param this the sprite
|
||||||
*/
|
*/
|
||||||
|
//% parts="ledmatrix"
|
||||||
public brightness(): number {
|
public brightness(): number {
|
||||||
let r: number;
|
let r: number;
|
||||||
return this._brightness;
|
return this._brightness;
|
||||||
@@ -625,8 +666,8 @@ namespace game {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Changes the ``y`` position by the given amount
|
* Changes the ``y`` position by the given amount
|
||||||
* @param this TODO
|
* @param this the sprite
|
||||||
* @param value TODO
|
* @param value the value to change brightness
|
||||||
*/
|
*/
|
||||||
public changeBrightnessBy(value: number): void {
|
public changeBrightnessBy(value: number): void {
|
||||||
this.setBrightness(this._brightness + value);
|
this.setBrightness(this._brightness + value);
|
||||||
@@ -642,11 +683,15 @@ namespace game {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deletes the sprite from the game engine. All further operation of the sprite will not have any effect.
|
* Deletes the sprite from the game engine. The sprite will no longer appear on the screen or interact with other sprites.
|
||||||
* @param sprite TODO
|
* @param this sprite to delete
|
||||||
*/
|
*/
|
||||||
public delete(sprite: LedSprite): void {
|
//% weight=59 help=game/delete
|
||||||
sprites.removeElement(sprite);
|
//% blockId="game_delete_sprite" block="delete %this"
|
||||||
|
public delete(): void {
|
||||||
|
this._enabled = false;
|
||||||
|
if (_sprites.removeElement(this))
|
||||||
|
plot();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -686,30 +731,29 @@ namespace game {
|
|||||||
r = (now / ps._blink) % 2;
|
r = (now / ps._blink) % 2;
|
||||||
}
|
}
|
||||||
if (r == 0) {
|
if (r == 0) {
|
||||||
img.setPixelBrightness(ps._x, ps._y, img.pixelBrightness(ps._x, ps._y) + ps._brightness);
|
_img.setPixelBrightness(ps._x, ps._y, _img.pixelBrightness(ps._x, ps._y) + ps._brightness);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function init(): void {
|
function init(): void {
|
||||||
if (img == null) {
|
if (_img) return;
|
||||||
img = images.createImage(
|
const img = images.createImage(
|
||||||
`0 0 0 0 0
|
`0 0 0 0 0
|
||||||
0 0 0 0 0
|
0 0 0 0 0
|
||||||
0 0 0 0 0
|
0 0 0 0 0
|
||||||
0 0 0 0 0
|
0 0 0 0 0
|
||||||
0 0 0 0 0`);
|
0 0 0 0 0`);
|
||||||
sprites = (<LedSprite[]>[]);
|
_sprites = (<LedSprite[]>[]);
|
||||||
led.setDisplayMode(DisplayMode.Greyscale);
|
basic.forever(() => {
|
||||||
basic.forever(() => {
|
basic.pause(30);
|
||||||
basic.pause(30);
|
plot();
|
||||||
plot();
|
if (game.isGameOver()) {
|
||||||
if (game.isGameOver()) {
|
basic.pause(600);
|
||||||
basic.pause(600);
|
}
|
||||||
}
|
});
|
||||||
});
|
_img = img;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -717,15 +761,23 @@ namespace game {
|
|||||||
*/
|
*/
|
||||||
//% parts="ledmatrix"
|
//% parts="ledmatrix"
|
||||||
function plot(): void {
|
function plot(): void {
|
||||||
if (game.isGameOver()) {
|
if (game.isGameOver() || game.isPaused() || !_img || _backgroundAnimation) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let now = input.runningTime();
|
// ensure greyscale mode
|
||||||
img.clear();
|
const dm = led.displayMode();
|
||||||
for (let i = 0; i < sprites.length; i++) {
|
if (dm != DisplayMode.Greyscale)
|
||||||
sprites[i]._plot(now);
|
led.setDisplayMode(DisplayMode.Greyscale);
|
||||||
|
// render sprites
|
||||||
|
const now = input.runningTime();
|
||||||
|
_img.clear();
|
||||||
|
for (let i = 0; i < _sprites.length; i++) {
|
||||||
|
_sprites[i]._plot(now);
|
||||||
}
|
}
|
||||||
img.plotImage(0);
|
_img.plotImage(0);
|
||||||
|
// restore previous display mode
|
||||||
|
if (dm != DisplayMode.Greyscale)
|
||||||
|
led.setDisplayMode(dm);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -737,4 +789,3 @@ namespace game {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -27,103 +27,143 @@ THE SOFTWARE.
|
|||||||
|
|
||||||
enum IconNames {
|
enum IconNames {
|
||||||
//% block="heart"
|
//% block="heart"
|
||||||
|
//% blockImage=1
|
||||||
Heart = 0,
|
Heart = 0,
|
||||||
//% block="small heart"
|
//% block="small heart"
|
||||||
|
//% blockImage=1
|
||||||
SmallHeart,
|
SmallHeart,
|
||||||
//% block="yes"
|
//% block="yes"
|
||||||
|
//% blockImage=1
|
||||||
Yes,
|
Yes,
|
||||||
//% block="no"
|
//% block="no"
|
||||||
|
//% blockImage=1
|
||||||
No,
|
No,
|
||||||
//% block="happy"
|
//% block="happy"
|
||||||
|
//% blockImage=1
|
||||||
Happy,
|
Happy,
|
||||||
//% block="sad"
|
//% block="sad"
|
||||||
|
//% blockImage=1
|
||||||
Sad,
|
Sad,
|
||||||
//% block="confused"
|
//% block="confused"
|
||||||
|
//% blockImage=1
|
||||||
Confused,
|
Confused,
|
||||||
//% block="angry"
|
//% block="angry"
|
||||||
|
//% blockImage=1
|
||||||
Angry,
|
Angry,
|
||||||
//% block="asleep"
|
//% block="asleep"
|
||||||
|
//% blockImage=1
|
||||||
Asleep,
|
Asleep,
|
||||||
//% block="surprised"
|
//% block="surprised"
|
||||||
|
//% blockImage=1
|
||||||
Surprised,
|
Surprised,
|
||||||
//% block="silly"
|
//% block="silly"
|
||||||
|
//% blockImage=1
|
||||||
Silly,
|
Silly,
|
||||||
//% block="fabulous"
|
//% block="fabulous"
|
||||||
|
//% blockImage=1
|
||||||
Fabulous,
|
Fabulous,
|
||||||
//% block="meh"
|
//% block="meh"
|
||||||
|
//% blockImage=1
|
||||||
Meh,
|
Meh,
|
||||||
//% block="t-shirt"
|
//% block="t-shirt"
|
||||||
|
//% blockImage=1
|
||||||
TShirt,
|
TShirt,
|
||||||
//% block="roller skate"
|
//% block="roller skate"
|
||||||
|
//% blockImage=1
|
||||||
Rollerskate,
|
Rollerskate,
|
||||||
//% block="duck"
|
//% block="duck"
|
||||||
|
//% blockImage=1
|
||||||
Duck,
|
Duck,
|
||||||
//% block="house"
|
//% block="house"
|
||||||
|
//% blockImage=1
|
||||||
House,
|
House,
|
||||||
//% block="tortoise"
|
//% block="tortoise"
|
||||||
|
//% blockImage=1
|
||||||
Tortoise,
|
Tortoise,
|
||||||
//% block="butterfly"
|
//% block="butterfly"
|
||||||
|
//% blockImage=1
|
||||||
Butterfly,
|
Butterfly,
|
||||||
//% block="stick figure"
|
//% block="stick figure"
|
||||||
|
//% blockImage=1
|
||||||
StickFigure,
|
StickFigure,
|
||||||
//% block="ghost"
|
//% block="ghost"
|
||||||
|
//% blockImage=1
|
||||||
Ghost,
|
Ghost,
|
||||||
//% block="sword"
|
//% block="sword"
|
||||||
|
//% blockImage=1
|
||||||
Sword,
|
Sword,
|
||||||
//% block="giraffe"
|
//% block="giraffe"
|
||||||
|
//% blockImage=1
|
||||||
Giraffe,
|
Giraffe,
|
||||||
//% block="skull"
|
//% block="skull"
|
||||||
|
//% blockImage=1
|
||||||
Skull,
|
Skull,
|
||||||
//% block="umbrella"
|
//% block="umbrella"
|
||||||
|
//% blockImage=1
|
||||||
Umbrella,
|
Umbrella,
|
||||||
//% block="snake"
|
//% block="snake"
|
||||||
|
//% blockImage=1
|
||||||
Snake,
|
Snake,
|
||||||
//% block="rabbit"
|
//% block="rabbit"
|
||||||
|
//% blockImage=1
|
||||||
Rabbit,
|
Rabbit,
|
||||||
//% block="cow"
|
//% block="cow"
|
||||||
|
//% blockImage=1
|
||||||
Cow,
|
Cow,
|
||||||
//% block="quarter note"
|
//% block="quarter note"
|
||||||
|
//% blockImage=1
|
||||||
QuarterNote,
|
QuarterNote,
|
||||||
//% block="eigth note"
|
//% block="eigth note"
|
||||||
|
//% blockImage=1
|
||||||
EigthNote,
|
EigthNote,
|
||||||
//% block="pitchfork"
|
//% block="pitchfork"
|
||||||
|
//% blockImage=1
|
||||||
Pitchfork,
|
Pitchfork,
|
||||||
//% block="pac man"
|
|
||||||
Pacman,
|
|
||||||
//% block="target"
|
//% block="target"
|
||||||
|
//% blockImage=1
|
||||||
Target,
|
Target,
|
||||||
//% block="triangle"
|
//% block="triangle"
|
||||||
|
//% blockImage=1
|
||||||
Triangle,
|
Triangle,
|
||||||
//% block="left triangle"
|
//% block="left triangle"
|
||||||
|
//% blockImage=1
|
||||||
LeftTriangle,
|
LeftTriangle,
|
||||||
//% block="chess board"
|
//% block="chess board"
|
||||||
|
//% blockImage=1
|
||||||
Chessboard,
|
Chessboard,
|
||||||
//% block="diamond"
|
//% block="diamond"
|
||||||
|
//% blockImage=1
|
||||||
Diamond,
|
Diamond,
|
||||||
//% block="small diamond"
|
//% block="small diamond"
|
||||||
|
//% blockImage=1
|
||||||
SmallDiamond,
|
SmallDiamond,
|
||||||
//% block="square"
|
//% block="square"
|
||||||
|
//% blockImage=1
|
||||||
Square,
|
Square,
|
||||||
//% block="small square"
|
//% block="small square"
|
||||||
SmallSquare,
|
//% blockImage=1
|
||||||
|
SmallSquare,
|
||||||
|
//% block="scissors"
|
||||||
|
//% blockImage=1
|
||||||
|
Scissors
|
||||||
}
|
}
|
||||||
|
|
||||||
enum ArrowNames {
|
enum ArrowNames {
|
||||||
//% blockIdentity=images.arrowNumber
|
//% blockIdentity=images.arrowNumber block="North"
|
||||||
North = 0,
|
North = 0,
|
||||||
//% blockIdentity=images.arrowNumber
|
//% blockIdentity=images.arrowNumber block="North East"
|
||||||
NorthEast,
|
NorthEast,
|
||||||
//% blockIdentity=images.arrowNumber
|
//% blockIdentity=images.arrowNumber block="East"
|
||||||
East,
|
East,
|
||||||
//% blockIdentity=images.arrowNumber
|
//% blockIdentity=images.arrowNumber block="South East"
|
||||||
SouthEast,
|
SouthEast,
|
||||||
//% blockIdentity=images.arrowNumber
|
//% blockIdentity=images.arrowNumber block="South"
|
||||||
South,
|
South,
|
||||||
//% blockIdentity=images.arrowNumber
|
//% blockIdentity=images.arrowNumber block="South West"
|
||||||
SouthWest,
|
SouthWest,
|
||||||
//% blockIdentity=images.arrowNumber
|
//% blockIdentity=images.arrowNumber block="West"
|
||||||
West,
|
West,
|
||||||
//% blockIdentity=images.arrowNumber
|
//% blockIdentity=images.arrowNumber block="North West"
|
||||||
NorthWest,
|
NorthWest,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -131,393 +171,376 @@ namespace basic {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Draws the selected icon on the LED screen
|
* Draws the selected icon on the LED screen
|
||||||
|
* @param icon the predifined icon id
|
||||||
|
* @param interval the amount of time (milliseconds) to show the icon. Default is 600.
|
||||||
*/
|
*/
|
||||||
//% weight=90 blockGap=8
|
//% weight=90 blockGap=8
|
||||||
//% blockId=basic_show_icon
|
//% blockId=basic_show_icon
|
||||||
//% block="show icon %i" icon="\uf00a"
|
//% block="show icon %i" icon="\uf00a"
|
||||||
//% parts="ledmatrix"
|
//% parts="ledmatrix"
|
||||||
//% help=basic/show-icon
|
//% help=basic/show-icon
|
||||||
export function showIcon(icon: IconNames) {
|
//% i.fieldEditor="gridpicker"
|
||||||
|
//% i.fieldOptions.width="400" i.fieldOptions.columns="5"
|
||||||
|
//% i.fieldOptions.itemColour="black" i.fieldOptions.tooltips="true"
|
||||||
|
export function showIcon(icon: IconNames, interval = 600) {
|
||||||
let res = images.iconImage(icon)
|
let res = images.iconImage(icon)
|
||||||
res.showImage(0)
|
res.showImage(0, interval)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Shows an arrow on screent
|
||||||
|
* @param direction the direction of the arrow
|
||||||
|
* @param interval the amount of time (milliseconds) to show the icon. Default is 600.
|
||||||
|
*/
|
||||||
//% weight=50 blockGap=8
|
//% weight=50 blockGap=8
|
||||||
//% blockId=basic_show_arrow
|
//% blockId=basic_show_arrow
|
||||||
//% block="show arrow %i=device_arrow"
|
//% block="show arrow %i=device_arrow"
|
||||||
//% parts="ledmatrix"
|
//% parts="ledmatrix"
|
||||||
//% advanced=true
|
//% advanced=true
|
||||||
//% help=basic/show-arrow
|
//% help=basic/show-arrow
|
||||||
export function showArrow(i: number) {
|
export function showArrow(direction: number, interval = 600) {
|
||||||
let res = images.arrowImage(i)
|
let res = images.arrowImage(direction)
|
||||||
res.showImage(0)
|
res.showImage(0, interval)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
namespace images {
|
namespace images {
|
||||||
|
|
||||||
function getArrow(i : ArrowNames): string {
|
//% weight=50 blockGap=8
|
||||||
switch(i) {
|
//% help=images/arrow-image
|
||||||
|
//% blockId=builtin_arrow_image block="arrow image %i=device_arrow"
|
||||||
|
export function arrowImage(i: ArrowNames): Image {
|
||||||
|
switch (i) {
|
||||||
// compass directions
|
// compass directions
|
||||||
case ArrowNames.North: return `
|
case ArrowNames.North: return images.createImage(`
|
||||||
. . # . .
|
. . # . .
|
||||||
. # # # .
|
. # # # .
|
||||||
# . # . #
|
# . # . #
|
||||||
. . # . .
|
. . # . .
|
||||||
. . # . .`;
|
. . # . .`);
|
||||||
case ArrowNames.NorthEast: return `
|
case ArrowNames.NorthEast: return images.createImage(`
|
||||||
. . # # #
|
. . # # #
|
||||||
. . . # #
|
. . . # #
|
||||||
. . # . #
|
. . # . #
|
||||||
. # . . .
|
. # . . .
|
||||||
# . . . .`;
|
# . . . .`);
|
||||||
case ArrowNames.East: return `
|
case ArrowNames.East: return images.createImage(`
|
||||||
. . # . .
|
. . # . .
|
||||||
. . . # .
|
. . . # .
|
||||||
# # # # #
|
# # # # #
|
||||||
. . . # .
|
. . . # .
|
||||||
. . # . .`;
|
. . # . .`);
|
||||||
case ArrowNames.SouthEast: return `
|
case ArrowNames.SouthEast: return images.createImage(`
|
||||||
# . . . .
|
# . . . .
|
||||||
. # . . .
|
. # . . .
|
||||||
. . # . #
|
. . # . #
|
||||||
. . . # #
|
. . . # #
|
||||||
. . # # #`;
|
. . # # #`);
|
||||||
case ArrowNames.South: return `
|
case ArrowNames.South: return images.createImage(`
|
||||||
. . # . .
|
. . # . .
|
||||||
. . # . .
|
. . # . .
|
||||||
# . # . #
|
# . # . #
|
||||||
. # # # .
|
. # # # .
|
||||||
. . # . .`;
|
. . # . .`);
|
||||||
case ArrowNames.SouthWest: return `
|
case ArrowNames.SouthWest: return images.createImage(`
|
||||||
. . . . #
|
. . . . #
|
||||||
. . . # .
|
. . . # .
|
||||||
# . # . .
|
# . # . .
|
||||||
# # . . .
|
# # . . .
|
||||||
# # # . .`;
|
# # # . .`);
|
||||||
case ArrowNames.West: return `
|
case ArrowNames.West: return images.createImage(`
|
||||||
. . # . .
|
. . # . .
|
||||||
. # . . .
|
. # . . .
|
||||||
# # # # #
|
# # # # #
|
||||||
. # . . .
|
. # . . .
|
||||||
. . # . .`;
|
. . # . .`);
|
||||||
case ArrowNames.NorthWest: return `
|
case ArrowNames.NorthWest: return images.createImage(`
|
||||||
# # # . .
|
# # # . .
|
||||||
# # . . .
|
# # . . .
|
||||||
# . # . .
|
# . # . .
|
||||||
. . . # .
|
. . . # .
|
||||||
. . . . #`;
|
. . . . #`);
|
||||||
default: return `
|
default: return images.createImage(`
|
||||||
. . . . .
|
. . . . .
|
||||||
. . . . .
|
. . . . .
|
||||||
. . . . .
|
. . . . .
|
||||||
. . . . .
|
. . . . .
|
||||||
. . . . .
|
. . . . .
|
||||||
`;
|
`);
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function getIcon(i: IconNames): string {
|
|
||||||
|
|
||||||
switch (i) {
|
|
||||||
case IconNames.Heart : return `
|
|
||||||
. # . # .
|
|
||||||
# # # # #
|
|
||||||
# # # # #
|
|
||||||
. # # # .
|
|
||||||
. . # . .`;
|
|
||||||
|
|
||||||
case IconNames.SmallHeart : return `
|
|
||||||
. . . . .
|
|
||||||
. # . # .
|
|
||||||
. # # # .
|
|
||||||
. . # . .
|
|
||||||
. . . . .`;
|
|
||||||
//faces
|
|
||||||
case IconNames.Happy: return `
|
|
||||||
. . . . .
|
|
||||||
. # . # .
|
|
||||||
. . . . .
|
|
||||||
# . . . #
|
|
||||||
. # # # .`;
|
|
||||||
case IconNames.Sad: return `
|
|
||||||
. . . . .
|
|
||||||
. # . # .
|
|
||||||
. . . . .
|
|
||||||
. # # # .
|
|
||||||
# . . . #`;
|
|
||||||
case IconNames.Confused: return `
|
|
||||||
. . . . .
|
|
||||||
. # . # .
|
|
||||||
. . . . .
|
|
||||||
. # . # .
|
|
||||||
# . # . #`;
|
|
||||||
case IconNames.Angry: return `
|
|
||||||
# . . . #
|
|
||||||
. # . # .
|
|
||||||
. . . . .
|
|
||||||
# # # # #
|
|
||||||
# . # . #`;
|
|
||||||
case IconNames.Asleep: return `
|
|
||||||
. . . . .
|
|
||||||
# # . # #
|
|
||||||
. . . . .
|
|
||||||
. # # # .
|
|
||||||
. . . . .`;
|
|
||||||
case IconNames.Surprised: return `
|
|
||||||
. # . # .
|
|
||||||
. . . . .
|
|
||||||
. . # . .
|
|
||||||
. # . # .
|
|
||||||
. . # . .`;
|
|
||||||
case IconNames.Silly: return `
|
|
||||||
# . . . #
|
|
||||||
. . . . .
|
|
||||||
# # # # #
|
|
||||||
. . . # #
|
|
||||||
. . . # #`;
|
|
||||||
case IconNames.Fabulous: return `
|
|
||||||
# # # # #
|
|
||||||
# # . # #
|
|
||||||
. . . . .
|
|
||||||
. # . # .
|
|
||||||
. # # # .`;
|
|
||||||
case IconNames.Meh: return `
|
|
||||||
# # . # #
|
|
||||||
. . . . .
|
|
||||||
. . . # .
|
|
||||||
. . # . .
|
|
||||||
. # . . .`;
|
|
||||||
case IconNames.Yes: return `
|
|
||||||
. . . . .
|
|
||||||
. . . . #
|
|
||||||
. . . # .
|
|
||||||
# . # . .
|
|
||||||
. # . . .`;
|
|
||||||
case IconNames.No: return `
|
|
||||||
# . . . #
|
|
||||||
. # . # .
|
|
||||||
. . # . .
|
|
||||||
. # . # .
|
|
||||||
# . . . #`;
|
|
||||||
case IconNames.Triangle: return `
|
|
||||||
. . . . .
|
|
||||||
. . # . .
|
|
||||||
. # . # .
|
|
||||||
# # # # #
|
|
||||||
. . . . .`;
|
|
||||||
case IconNames.LeftTriangle: return `
|
|
||||||
# . . . .
|
|
||||||
# # . . .
|
|
||||||
# . # . .
|
|
||||||
# . . # .
|
|
||||||
# # # # #`;
|
|
||||||
case IconNames.Chessboard: return `
|
|
||||||
. # . # .
|
|
||||||
# . # . #
|
|
||||||
. # . # .
|
|
||||||
# . # . #
|
|
||||||
. # . # .`;
|
|
||||||
case IconNames.Diamond: return `
|
|
||||||
. . # . .
|
|
||||||
. # . # .
|
|
||||||
# . . . #
|
|
||||||
. # . # .
|
|
||||||
. . # . .`;
|
|
||||||
case IconNames.SmallDiamond: return `
|
|
||||||
. . . . .
|
|
||||||
. . # . .
|
|
||||||
. # . # .
|
|
||||||
. . # . .
|
|
||||||
. . . . .`;
|
|
||||||
case IconNames.Square: return `
|
|
||||||
# # # # #
|
|
||||||
# . . . #
|
|
||||||
# . . . #
|
|
||||||
# . . . #
|
|
||||||
# # # # #`;
|
|
||||||
case IconNames.SmallSquare: return `
|
|
||||||
. . . . .
|
|
||||||
. # # # .
|
|
||||||
. # . # .
|
|
||||||
. # # # .
|
|
||||||
. . . . .`;
|
|
||||||
// The following images were designed by Abbie Brooks.
|
|
||||||
case IconNames.TShirt: return `
|
|
||||||
# # . # #
|
|
||||||
# # # # #
|
|
||||||
. # # # .
|
|
||||||
. # # # .
|
|
||||||
. # # # .`;
|
|
||||||
case IconNames.Rollerskate: return `
|
|
||||||
. . . # #
|
|
||||||
. . . # #
|
|
||||||
# # # # #
|
|
||||||
# # # # #
|
|
||||||
. # . # .`;
|
|
||||||
case IconNames.Duck: return `
|
|
||||||
. # # . .
|
|
||||||
# # # . .
|
|
||||||
. # # # #
|
|
||||||
. # # # .
|
|
||||||
. .. . .`;
|
|
||||||
case IconNames.House: return `
|
|
||||||
. . # . .
|
|
||||||
. # # # .
|
|
||||||
# # # # #
|
|
||||||
. # # # .
|
|
||||||
. # . # .`;
|
|
||||||
case IconNames.Tortoise: return `
|
|
||||||
. . . . .
|
|
||||||
. # # # .
|
|
||||||
# # # # #
|
|
||||||
. # . # .
|
|
||||||
. . . . .`;
|
|
||||||
case IconNames.Butterfly: return `
|
|
||||||
# # . # #
|
|
||||||
# # # # #
|
|
||||||
. . # . .
|
|
||||||
# # # # #
|
|
||||||
# # . # #`;
|
|
||||||
case IconNames.StickFigure: return `
|
|
||||||
. . # . .
|
|
||||||
# # # # #
|
|
||||||
. . # . .
|
|
||||||
. # . # .
|
|
||||||
# . . . #`;
|
|
||||||
case IconNames.Ghost: return `
|
|
||||||
. # # # .
|
|
||||||
# . # . #
|
|
||||||
# # # # #
|
|
||||||
# # # # #
|
|
||||||
# . # . #`;
|
|
||||||
case IconNames.Sword: return `
|
|
||||||
. . # . .
|
|
||||||
. . # . .
|
|
||||||
. . # . .
|
|
||||||
. # # # .
|
|
||||||
. . # . .`;
|
|
||||||
case IconNames.Giraffe: return `
|
|
||||||
# # . . .
|
|
||||||
. # . . .
|
|
||||||
. # . . .
|
|
||||||
. # # # .
|
|
||||||
. # . # .`;
|
|
||||||
case IconNames.Skull: return `
|
|
||||||
. # # # .
|
|
||||||
# . # . #
|
|
||||||
# # # # #
|
|
||||||
. # # # .
|
|
||||||
. # # # .`;
|
|
||||||
case IconNames.Umbrella: return `
|
|
||||||
. # # # .
|
|
||||||
# # # # #
|
|
||||||
. . # . .
|
|
||||||
# . # . .
|
|
||||||
# # # . .`;
|
|
||||||
case IconNames.Snake: return `
|
|
||||||
# # . . .
|
|
||||||
# # . # #
|
|
||||||
. # . # .
|
|
||||||
. # # # .
|
|
||||||
. . . . .`;
|
|
||||||
// animals
|
|
||||||
case IconNames.Rabbit: return `
|
|
||||||
# . # . .
|
|
||||||
# . # . .
|
|
||||||
# # # # .
|
|
||||||
# # . # .
|
|
||||||
# # # # .`;
|
|
||||||
case IconNames.Cow: return `
|
|
||||||
# . . . #
|
|
||||||
# . . . #
|
|
||||||
# # # # #
|
|
||||||
. # # # .
|
|
||||||
. . # . .`;
|
|
||||||
// musical notes
|
|
||||||
case IconNames.QuarterNote: return `
|
|
||||||
. . # . .
|
|
||||||
. . # . .
|
|
||||||
. . # . .
|
|
||||||
# # # . .
|
|
||||||
# # # . .`;
|
|
||||||
case IconNames.EigthNote: return `
|
|
||||||
. . # . .
|
|
||||||
. . # # .
|
|
||||||
. . # . #
|
|
||||||
# # # . .
|
|
||||||
# # # . .`;
|
|
||||||
// other icons
|
|
||||||
case IconNames.Pitchfork: return `
|
|
||||||
# . # . #
|
|
||||||
# . # . #
|
|
||||||
# # # # #
|
|
||||||
. . # . .
|
|
||||||
. . # . .`;
|
|
||||||
case IconNames.Pacman: return `
|
|
||||||
. # # # #
|
|
||||||
# # # # .
|
|
||||||
# # # . .
|
|
||||||
# # # # .
|
|
||||||
. # # # #`;
|
|
||||||
case IconNames.Target: return `
|
|
||||||
. . # . .
|
|
||||||
. # # # .
|
|
||||||
# # . # #
|
|
||||||
. # # # .
|
|
||||||
. . # . .`;
|
|
||||||
default: return `
|
|
||||||
. . . . .
|
|
||||||
. . . . .
|
|
||||||
. . . . .
|
|
||||||
. . . . .
|
|
||||||
. . . . .
|
|
||||||
`;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//% weight=50 blockGap=8
|
//% weight=50 blockGap=8
|
||||||
|
//% help=images/icon-image
|
||||||
|
//% blockId=builtin_image block="icon image %i"
|
||||||
|
//% i.fieldEditor="gridpicker"
|
||||||
|
//% i.fieldOptions.width="400" i.fieldOptions.columns="5"
|
||||||
|
//% i.fieldOptions.itemColour="black" i.fieldOptions.tooltips="true"
|
||||||
|
export function iconImage(i: IconNames): Image {
|
||||||
|
switch (i) {
|
||||||
|
case IconNames.Heart: return images.createImage(`
|
||||||
|
. # . # .
|
||||||
|
# # # # #
|
||||||
|
# # # # #
|
||||||
|
. # # # .
|
||||||
|
. . # . .`);
|
||||||
|
|
||||||
|
case IconNames.SmallHeart: return images.createImage(`
|
||||||
|
. . . . .
|
||||||
|
. # . # .
|
||||||
|
. # # # .
|
||||||
|
. . # . .
|
||||||
|
. . . . .`);
|
||||||
|
//faces
|
||||||
|
case IconNames.Happy: return images.createImage(`
|
||||||
|
. . . . .
|
||||||
|
. # . # .
|
||||||
|
. . . . .
|
||||||
|
# . . . #
|
||||||
|
. # # # .`);
|
||||||
|
case IconNames.Sad: return images.createImage(`
|
||||||
|
. . . . .
|
||||||
|
. # . # .
|
||||||
|
. . . . .
|
||||||
|
. # # # .
|
||||||
|
# . . . #`);
|
||||||
|
case IconNames.Confused: return images.createImage(`
|
||||||
|
. . . . .
|
||||||
|
. # . # .
|
||||||
|
. . . . .
|
||||||
|
. # . # .
|
||||||
|
# . # . #`);
|
||||||
|
case IconNames.Angry: return images.createImage(`
|
||||||
|
# . . . #
|
||||||
|
. # . # .
|
||||||
|
. . . . .
|
||||||
|
# # # # #
|
||||||
|
# . # . #`);
|
||||||
|
case IconNames.Asleep: return images.createImage(`
|
||||||
|
. . . . .
|
||||||
|
# # . # #
|
||||||
|
. . . . .
|
||||||
|
. # # # .
|
||||||
|
. . . . .`);
|
||||||
|
case IconNames.Surprised: return images.createImage(`
|
||||||
|
. # . # .
|
||||||
|
. . . . .
|
||||||
|
. . # . .
|
||||||
|
. # . # .
|
||||||
|
. . # . .`);
|
||||||
|
case IconNames.Silly: return images.createImage(`
|
||||||
|
# . . . #
|
||||||
|
. . . . .
|
||||||
|
# # # # #
|
||||||
|
. . . # #
|
||||||
|
. . . # #`);
|
||||||
|
case IconNames.Fabulous: return images.createImage(`
|
||||||
|
# # # # #
|
||||||
|
# # . # #
|
||||||
|
. . . . .
|
||||||
|
. # . # .
|
||||||
|
. # # # .`);
|
||||||
|
case IconNames.Meh: return images.createImage(`
|
||||||
|
# # . # #
|
||||||
|
. . . . .
|
||||||
|
. . . # .
|
||||||
|
. . # . .
|
||||||
|
. # . . .`);
|
||||||
|
case IconNames.Yes: return images.createImage(`
|
||||||
|
. . . . .
|
||||||
|
. . . . #
|
||||||
|
. . . # .
|
||||||
|
# . # . .
|
||||||
|
. # . . .`);
|
||||||
|
case IconNames.No: return images.createImage(`
|
||||||
|
# . . . #
|
||||||
|
. # . # .
|
||||||
|
. . # . .
|
||||||
|
. # . # .
|
||||||
|
# . . . #`);
|
||||||
|
case IconNames.Triangle: return images.createImage(`
|
||||||
|
. . . . .
|
||||||
|
. . # . .
|
||||||
|
. # . # .
|
||||||
|
# # # # #
|
||||||
|
. . . . .`);
|
||||||
|
case IconNames.LeftTriangle: return images.createImage(`
|
||||||
|
# . . . .
|
||||||
|
# # . . .
|
||||||
|
# . # . .
|
||||||
|
# . . # .
|
||||||
|
# # # # #`);
|
||||||
|
case IconNames.Chessboard: return images.createImage(`
|
||||||
|
. # . # .
|
||||||
|
# . # . #
|
||||||
|
. # . # .
|
||||||
|
# . # . #
|
||||||
|
. # . # .`);
|
||||||
|
case IconNames.Diamond: return images.createImage(`
|
||||||
|
. . # . .
|
||||||
|
. # . # .
|
||||||
|
# . . . #
|
||||||
|
. # . # .
|
||||||
|
. . # . .`);
|
||||||
|
case IconNames.SmallDiamond: return images.createImage(`
|
||||||
|
. . . . .
|
||||||
|
. . # . .
|
||||||
|
. # . # .
|
||||||
|
. . # . .
|
||||||
|
. . . . .`);
|
||||||
|
case IconNames.Square: return images.createImage(`
|
||||||
|
# # # # #
|
||||||
|
# . . . #
|
||||||
|
# . . . #
|
||||||
|
# . . . #
|
||||||
|
# # # # #`);
|
||||||
|
case IconNames.SmallSquare: return images.createImage(`
|
||||||
|
. . . . .
|
||||||
|
. # # # .
|
||||||
|
. # . # .
|
||||||
|
. # # # .
|
||||||
|
. . . . .`);
|
||||||
|
|
||||||
|
case IconNames.Scissors: return images.createImage(`
|
||||||
|
# # . . #
|
||||||
|
# # . # .
|
||||||
|
. . # . .
|
||||||
|
# # . # .
|
||||||
|
# # . . #`);
|
||||||
|
// The following images were designed by Abbie Brooks.
|
||||||
|
case IconNames.TShirt: return images.createImage(`
|
||||||
|
# # . # #
|
||||||
|
# # # # #
|
||||||
|
. # # # .
|
||||||
|
. # # # .
|
||||||
|
. # # # .`);
|
||||||
|
case IconNames.Rollerskate: return images.createImage(`
|
||||||
|
. . . # #
|
||||||
|
. . . # #
|
||||||
|
# # # # #
|
||||||
|
# # # # #
|
||||||
|
. # . # .`);
|
||||||
|
case IconNames.Duck: return images.createImage(`
|
||||||
|
. # # . .
|
||||||
|
# # # . .
|
||||||
|
. # # # #
|
||||||
|
. # # # .
|
||||||
|
. . . . .`);
|
||||||
|
case IconNames.House: return images.createImage(`
|
||||||
|
. . # . .
|
||||||
|
. # # # .
|
||||||
|
# # # # #
|
||||||
|
. # # # .
|
||||||
|
. # . # .`);
|
||||||
|
case IconNames.Tortoise: return images.createImage(`
|
||||||
|
. . . . .
|
||||||
|
. # # # .
|
||||||
|
# # # # #
|
||||||
|
. # . # .
|
||||||
|
. . . . .`);
|
||||||
|
case IconNames.Butterfly: return images.createImage(`
|
||||||
|
# # . # #
|
||||||
|
# # # # #
|
||||||
|
. . # . .
|
||||||
|
# # # # #
|
||||||
|
# # . # #`);
|
||||||
|
case IconNames.StickFigure: return images.createImage(`
|
||||||
|
. . # . .
|
||||||
|
# # # # #
|
||||||
|
. . # . .
|
||||||
|
. # . # .
|
||||||
|
# . . . #`);
|
||||||
|
case IconNames.Ghost: return images.createImage(`
|
||||||
|
. # # # .
|
||||||
|
# . # . #
|
||||||
|
# # # # #
|
||||||
|
# # # # #
|
||||||
|
# . # . #`);
|
||||||
|
case IconNames.Sword: return images.createImage(`
|
||||||
|
. . # . .
|
||||||
|
. . # . .
|
||||||
|
. . # . .
|
||||||
|
. # # # .
|
||||||
|
. . # . .`);
|
||||||
|
case IconNames.Giraffe: return images.createImage(`
|
||||||
|
# # . . .
|
||||||
|
. # . . .
|
||||||
|
. # . . .
|
||||||
|
. # # # .
|
||||||
|
. # . # .`);
|
||||||
|
case IconNames.Skull: return images.createImage(`
|
||||||
|
. # # # .
|
||||||
|
# . # . #
|
||||||
|
# # # # #
|
||||||
|
. # # # .
|
||||||
|
. # # # .`);
|
||||||
|
case IconNames.Umbrella: return images.createImage(`
|
||||||
|
. # # # .
|
||||||
|
# # # # #
|
||||||
|
. . # . .
|
||||||
|
# . # . .
|
||||||
|
# # # . .`);
|
||||||
|
case IconNames.Snake: return images.createImage(`
|
||||||
|
# # . . .
|
||||||
|
# # . # #
|
||||||
|
. # . # .
|
||||||
|
. # # # .
|
||||||
|
. . . . .`);
|
||||||
|
// animals
|
||||||
|
case IconNames.Rabbit: return images.createImage(`
|
||||||
|
# . # . .
|
||||||
|
# . # . .
|
||||||
|
# # # # .
|
||||||
|
# # . # .
|
||||||
|
# # # # .`);
|
||||||
|
case IconNames.Cow: return images.createImage(`
|
||||||
|
# . . . #
|
||||||
|
# . . . #
|
||||||
|
# # # # #
|
||||||
|
. # # # .
|
||||||
|
. . # . .`);
|
||||||
|
// musical notes
|
||||||
|
case IconNames.QuarterNote: return images.createImage(`
|
||||||
|
. . # . .
|
||||||
|
. . # . .
|
||||||
|
. . # . .
|
||||||
|
# # # . .
|
||||||
|
# # # . .`);
|
||||||
|
case IconNames.EigthNote: return images.createImage(`
|
||||||
|
. . # . .
|
||||||
|
. . # # .
|
||||||
|
. . # . #
|
||||||
|
# # # . .
|
||||||
|
# # # . .`);
|
||||||
|
// other icons
|
||||||
|
case IconNames.Pitchfork: return images.createImage(`
|
||||||
|
# . # . #
|
||||||
|
# . # . #
|
||||||
|
# # # # #
|
||||||
|
. . # . .
|
||||||
|
. . # . .`);
|
||||||
|
case IconNames.Target: return images.createImage(`
|
||||||
|
. . # . .
|
||||||
|
. # # # .
|
||||||
|
# # . # #
|
||||||
|
. # # # .
|
||||||
|
. . # . .`);
|
||||||
|
default: return images.createImage(`
|
||||||
|
. . . . .
|
||||||
|
. . . . .
|
||||||
|
. . . . .
|
||||||
|
. . . . .
|
||||||
|
. . . . .
|
||||||
|
`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//% weight=50 blockGap=8
|
||||||
|
//% help=images/arrow-number
|
||||||
//% blockId=device_arrow block="%arrow"
|
//% blockId=device_arrow block="%arrow"
|
||||||
//% shim=TD_ID
|
//% shim=TD_ID
|
||||||
export function arrowNumber(arrow: ArrowNames): number {
|
export function arrowNumber(arrow: ArrowNames): number {
|
||||||
return arrow;
|
return arrow;
|
||||||
}
|
}
|
||||||
|
|
||||||
//% weight=50 blockGap=8
|
|
||||||
//% blockId=builtin_arrow_image block="arrow image %i=device_arrow"
|
|
||||||
export function arrowImage(i: ArrowNames): Image {
|
|
||||||
let res = images.createImage(`
|
|
||||||
. . . . .
|
|
||||||
. . . . .
|
|
||||||
. . . . .
|
|
||||||
. . . . .
|
|
||||||
. . . . .
|
|
||||||
`)
|
|
||||||
return set(res, getArrow(i));
|
|
||||||
}
|
|
||||||
|
|
||||||
//% weight=50 blockGap=8
|
|
||||||
//% blockId=builtin_image block="icon image %i"
|
|
||||||
export function iconImage(i: IconNames): Image {
|
|
||||||
let res = images.createImage(`
|
|
||||||
. . . . .
|
|
||||||
. . . . .
|
|
||||||
. . . . .
|
|
||||||
. . . . .
|
|
||||||
. . . . .
|
|
||||||
`)
|
|
||||||
return set(res, getIcon(i));
|
|
||||||
}
|
|
||||||
|
|
||||||
function set(res: Image, s: string) {
|
|
||||||
let j = 0;
|
|
||||||
for (let x of s) {
|
|
||||||
if (x == "." || x == "#") {
|
|
||||||
res.setPixel(j % 5, j / 5, x == "#")
|
|
||||||
j++
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return res
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -64,12 +64,12 @@ namespace ImageMethods {
|
|||||||
* @param frameOffset x offset moved on each animation step, eg: 1, 2, 5
|
* @param frameOffset x offset moved on each animation step, eg: 1, 2, 5
|
||||||
* @param interval time between each animation step in milli seconds, eg: 200
|
* @param interval time between each animation step in milli seconds, eg: 200
|
||||||
*/
|
*/
|
||||||
//% help=images/show-image weight=79 async blockNamespace=images
|
//% help=images/scroll-image weight=79 async blockNamespace=images
|
||||||
//% blockId=device_scroll_image block="scroll image %sprite|with offset %frameoffset|and interval (ms) %delay" blockGap=8
|
//% blockId=device_scroll_image block="scroll image %sprite|with offset %frameoffset|and interval (ms) %delay" blockGap=8
|
||||||
//% parts="ledmatrix"
|
//% parts="ledmatrix"
|
||||||
void scrollImage(Image id, int frameOffset, int interval) {
|
void scrollImage(Image id, int frameOffset, int interval) {
|
||||||
MicroBitImage i(id);
|
MicroBitImage i(id);
|
||||||
uBit.display.animate(i, interval, frameOffset, MICROBIT_DISPLAY_WIDTH - 1);
|
uBit.display.animate(i, interval, frameOffset, MICROBIT_DISPLAY_ANIMATE_DEFAULT_POS, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -105,15 +105,55 @@ enum class Gesture {
|
|||||||
* Raised when a 6G shock is detected
|
* Raised when a 6G shock is detected
|
||||||
*/
|
*/
|
||||||
//% block="6g"
|
//% block="6g"
|
||||||
SixG = MICROBIT_ACCELEROMETER_EVT_6G
|
SixG = MICROBIT_ACCELEROMETER_EVT_6G,
|
||||||
|
/**
|
||||||
|
* Raised when a 8G shock is detected
|
||||||
|
*/
|
||||||
|
//% block="8g"
|
||||||
|
EightG = MICROBIT_ACCELEROMETER_EVT_8G
|
||||||
};
|
};
|
||||||
|
|
||||||
//% color=#C90072 weight=99 icon="\uf192"
|
enum class MesDpadButtonInfo {
|
||||||
|
//% block="A down"
|
||||||
|
ADown = MES_DPAD_BUTTON_A_DOWN,
|
||||||
|
//% block="A up"
|
||||||
|
AUp = MES_DPAD_BUTTON_A_UP,
|
||||||
|
//% block="B down"
|
||||||
|
BDown = MES_DPAD_BUTTON_B_DOWN,
|
||||||
|
//% block="B up"
|
||||||
|
BUp = MES_DPAD_BUTTON_B_UP,
|
||||||
|
//% block="C down"
|
||||||
|
CDown = MES_DPAD_BUTTON_C_DOWN,
|
||||||
|
//% block="C up"
|
||||||
|
CUp = MES_DPAD_BUTTON_C_UP,
|
||||||
|
//% block="D down"
|
||||||
|
DDown = MES_DPAD_BUTTON_D_DOWN,
|
||||||
|
//% block="D up"
|
||||||
|
DUp = MES_DPAD_BUTTON_D_UP,
|
||||||
|
//% block="1 down"
|
||||||
|
_1Down = MES_DPAD_BUTTON_1_DOWN,
|
||||||
|
//% block="1 up"
|
||||||
|
_1Up = MES_DPAD_BUTTON_1_UP,
|
||||||
|
//% block="2 down"
|
||||||
|
_2Down = MES_DPAD_BUTTON_2_DOWN,
|
||||||
|
//% block="2 up"
|
||||||
|
_2Up = MES_DPAD_BUTTON_2_UP,
|
||||||
|
//% block="3 down"
|
||||||
|
_3Down = MES_DPAD_BUTTON_3_DOWN,
|
||||||
|
//% block="3 up"
|
||||||
|
_3Up = MES_DPAD_BUTTON_3_UP,
|
||||||
|
//% block="4 down"
|
||||||
|
_4Down = MES_DPAD_BUTTON_4_DOWN,
|
||||||
|
//% block="4 up"
|
||||||
|
_4Up = MES_DPAD_BUTTON_4_UP,
|
||||||
|
};
|
||||||
|
|
||||||
|
//% color=#B4009E weight=99 icon="\uf192"
|
||||||
namespace input {
|
namespace input {
|
||||||
/**
|
/**
|
||||||
* Do something when a button (``A``, ``B`` or both ``A+B``) is pressed
|
* Do something when a button (A, B or both A+B) is pushed down and released again.
|
||||||
* @param button TODO
|
* @param button the button that needs to be pressed
|
||||||
* @param body TODO
|
* @param body code to run when event is raised
|
||||||
*/
|
*/
|
||||||
//% help=input/on-button-pressed weight=85 blockGap=8
|
//% help=input/on-button-pressed weight=85 blockGap=8
|
||||||
//% blockId=device_button_event block="on button|%NAME|pressed"
|
//% blockId=device_button_event block="on button|%NAME|pressed"
|
||||||
@@ -124,26 +164,29 @@ namespace input {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Do something when when a gesture is done (like shaking the micro:bit).
|
* Do something when when a gesture is done (like shaking the micro:bit).
|
||||||
* @param body TODO
|
* @param gesture the type of gesture to track, eg: Gesture.Shake
|
||||||
|
* @param body code to run when gesture is raised
|
||||||
*/
|
*/
|
||||||
//% help=input/on-gesture weight=84 blockGap=8
|
//% help=input/on-gesture weight=84 blockGap=8
|
||||||
//% blockId=device_gesture_event block="on |%NAME"
|
//% blockId=device_gesture_event block="on |%NAME"
|
||||||
//% parts="accelerometer"
|
//% parts="accelerometer"
|
||||||
|
//% NAME.fieldEditor="gridpicker" NAME.fieldOptions.columns=4
|
||||||
void onGesture(Gesture gesture, Action body) {
|
void onGesture(Gesture gesture, Action body) {
|
||||||
if ((int)gesture == MICROBIT_ACCELEROMETER_EVT_3G && uBit.accelerometer.getRange() < 3)
|
int gi = (int)gesture;
|
||||||
uBit.accelerometer.setRange(6);
|
if (gi == MICROBIT_ACCELEROMETER_EVT_3G && uBit.accelerometer.getRange() < 3)
|
||||||
else if ((int)gesture == MICROBIT_ACCELEROMETER_EVT_6G && uBit.accelerometer.getRange() < 6)
|
uBit.accelerometer.setRange(4);
|
||||||
|
else if ((gi == MICROBIT_ACCELEROMETER_EVT_6G || gi == MICROBIT_ACCELEROMETER_EVT_8G) && uBit.accelerometer.getRange() < 6)
|
||||||
uBit.accelerometer.setRange(8);
|
uBit.accelerometer.setRange(8);
|
||||||
registerWithDal(MICROBIT_ID_GESTURE, (int)gesture, body);
|
registerWithDal(MICROBIT_ID_GESTURE, gi, body);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Do something when a pin is pressed.
|
* Do something when a pin is touched and released again (while also touching the GND pin).
|
||||||
* @param name the pin that needs to be pressed
|
* @param name the pin that needs to be pressed, eg: TouchPin.P0
|
||||||
* @param body the code to run when the pin is pressed
|
* @param body the code to run when the pin is pressed
|
||||||
*/
|
*/
|
||||||
//% help=input/on-pin-pressed weight=83
|
//% help=input/on-pin-pressed weight=83
|
||||||
//% blockId=device_pin_event block="on pin %NAME|pressed"
|
//% blockId=device_pin_event block="on pin %name|pressed"
|
||||||
void onPinPressed(TouchPin name, Action body) {
|
void onPinPressed(TouchPin name, Action body) {
|
||||||
auto pin = getPin((int)name);
|
auto pin = getPin((int)name);
|
||||||
if (!pin) return;
|
if (!pin) return;
|
||||||
@@ -155,7 +198,7 @@ namespace input {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Do something when a pin is released.
|
* Do something when a pin is released.
|
||||||
* @param name the pin that needs to be released
|
* @param name the pin that needs to be released, eg: TouchPin.P0
|
||||||
* @param body the code to run when the pin is released
|
* @param body the code to run when the pin is released
|
||||||
*/
|
*/
|
||||||
//% help=input/on-pin-released weight=6 blockGap=8
|
//% help=input/on-pin-released weight=6 blockGap=8
|
||||||
@@ -172,6 +215,7 @@ namespace input {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the button state (pressed or not) for ``A`` and ``B``.
|
* Get the button state (pressed or not) for ``A`` and ``B``.
|
||||||
|
* @param button the button to query the request, eg: Button.A
|
||||||
*/
|
*/
|
||||||
//% help=input/button-is-pressed weight=60
|
//% help=input/button-is-pressed weight=60
|
||||||
//% block="button|%NAME|is pressed"
|
//% block="button|%NAME|is pressed"
|
||||||
@@ -190,7 +234,7 @@ namespace input {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the pin state (pressed or not). Requires to hold the ground to close the circuit.
|
* Get the pin state (pressed or not). Requires to hold the ground to close the circuit.
|
||||||
* @param name pin used to detect the touch
|
* @param name pin used to detect the touch, eg: TouchPin.P0
|
||||||
*/
|
*/
|
||||||
//% help=input/pin-is-pressed weight=58
|
//% help=input/pin-is-pressed weight=58
|
||||||
//% blockId="device_pin_is_pressed" block="pin %NAME|is pressed"
|
//% blockId="device_pin_is_pressed" block="pin %NAME|is pressed"
|
||||||
@@ -205,7 +249,7 @@ namespace input {
|
|||||||
double y = uBit.accelerometer.getY();
|
double y = uBit.accelerometer.getY();
|
||||||
double z = uBit.accelerometer.getZ();
|
double z = uBit.accelerometer.getZ();
|
||||||
return (int)sqrt(x*x+y*y+z*z);
|
return (int)sqrt(x*x+y*y+z*z);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the acceleration value in milli-gravitys (when the board is laying flat with the screen up, x=0, y=0 and z=-1024)
|
* Get the acceleration value in milli-gravitys (when the board is laying flat with the screen up, x=0, y=0 and z=-1024)
|
||||||
@@ -296,18 +340,31 @@ namespace input {
|
|||||||
/**
|
/**
|
||||||
* Gets the number of milliseconds elapsed since power on.
|
* Gets the number of milliseconds elapsed since power on.
|
||||||
*/
|
*/
|
||||||
//% help=input/running-time weight=50
|
//% help=input/running-time weight=50 blockGap=8
|
||||||
//% blockId=device_get_running_time block="running time (ms)"
|
//% blockId=device_get_running_time block="running time (ms)"
|
||||||
//% advanced=true
|
//% advanced=true
|
||||||
int runningTime() {
|
int runningTime() {
|
||||||
return system_timer_current_time();
|
return system_timer_current_time();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the number of microseconds elapsed since power on.
|
||||||
|
*/
|
||||||
|
//% help=input/running-time-micros weight=49
|
||||||
|
//% blockId=device_get_running_time_micros block="running time (micros)"
|
||||||
|
//% advanced=true
|
||||||
|
int runningTimeMicros() {
|
||||||
|
return system_timer_current_time_us();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Obsolete, compass calibration is automatic.
|
* Obsolete, compass calibration is automatic.
|
||||||
*/
|
*/
|
||||||
//% help=input/calibrate weight=0
|
//% help=input/calibrate-compass advanced=true
|
||||||
void calibrate() { }
|
//% blockId="input_compass_calibrate" block="calibrate compass"
|
||||||
|
void calibrateCompass() {
|
||||||
|
uBit.compass.calibrate();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the accelerometer sample range in gravities.
|
* Sets the accelerometer sample range in gravities.
|
||||||
|
|||||||
@@ -13,14 +13,34 @@ namespace led {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Turn on the specified LED using x, y coordinates (x is horizontal, y is vertical). (0,0) is upper left.
|
* Turn on the specified LED using x, y coordinates (x is horizontal, y is vertical). (0,0) is upper left.
|
||||||
* @param x TODO
|
* @param x the horizontal coordinate of the LED starting at 0
|
||||||
* @param y TODO
|
* @param y the vertical coordinate of the LED starting at 0
|
||||||
*/
|
*/
|
||||||
//% help=led/plot weight=78
|
//% help=led/plot weight=78
|
||||||
//% blockId=device_plot block="plot|x %x|y %y" blockGap=8
|
//% blockId=device_plot block="plot|x %x|y %y" blockGap=8
|
||||||
//% parts="ledmatrix"
|
//% parts="ledmatrix"
|
||||||
|
//% x.min=0 x.max=4 y.min=0 y.max=4
|
||||||
void plot(int x, int y) {
|
void plot(int x, int y) {
|
||||||
uBit.display.image.setPixelValue(x, y, 1);
|
uBit.display.image.setPixelValue(x, y, 0xff);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Turn on the specified LED with specific brightness using x, y coordinates (x is horizontal, y is vertical). (0,0) is upper left.
|
||||||
|
* @param x the horizontal coordinate of the LED starting at 0
|
||||||
|
* @param y the vertical coordinate of the LED starting at 0
|
||||||
|
* @param brightness the brightness from 0 (off) to 255 (bright), eg:255
|
||||||
|
*/
|
||||||
|
//% help=led/plot-brightness weight=78
|
||||||
|
//% blockId=device_plot_brightness block="plot|x %x|y %y|brightness %brightness" blockGap=8
|
||||||
|
//% parts="ledmatrix"
|
||||||
|
//% x.min=0 x.max=4 y.min=0 y.max=4 brightness.min=0 brightness.max=255
|
||||||
|
//% advanced=true
|
||||||
|
void plotBrightness(int x, int y, int brightness) {
|
||||||
|
brightness = max(0, min(0xff, brightness));
|
||||||
|
// enable greyscale as needed
|
||||||
|
if (brightness != 0 && brightness != 0xff && uBit.display.getDisplayMode() != DISPLAY_MODE_GREYSCALE)
|
||||||
|
uBit.display.setDisplayMode(DISPLAY_MODE_GREYSCALE);
|
||||||
|
uBit.display.image.setPixelValue(x, y, brightness);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -31,6 +51,7 @@ namespace led {
|
|||||||
//% help=led/unplot weight=77
|
//% help=led/unplot weight=77
|
||||||
//% blockId=device_unplot block="unplot|x %x|y %y" blockGap=8
|
//% blockId=device_unplot block="unplot|x %x|y %y" blockGap=8
|
||||||
//% parts="ledmatrix"
|
//% parts="ledmatrix"
|
||||||
|
//% x.min=0 x.max=4 y.min=0 y.max=4
|
||||||
void unplot(int x, int y) {
|
void unplot(int x, int y) {
|
||||||
uBit.display.image.setPixelValue(x, y, 0);
|
uBit.display.image.setPixelValue(x, y, 0);
|
||||||
}
|
}
|
||||||
@@ -43,6 +64,7 @@ namespace led {
|
|||||||
//% help=led/point weight=76
|
//% help=led/point weight=76
|
||||||
//% blockId=device_point block="point|x %x|y %y"
|
//% blockId=device_point block="point|x %x|y %y"
|
||||||
//% parts="ledmatrix"
|
//% parts="ledmatrix"
|
||||||
|
//% x.min=0 x.max=4 y.min=0 y.max=4
|
||||||
bool point(int x, int y) {
|
bool point(int x, int y) {
|
||||||
int pix = uBit.display.image.getPixelValue(x, y);
|
int pix = uBit.display.image.getPixelValue(x, y);
|
||||||
return pix > 0;
|
return pix > 0;
|
||||||
@@ -67,6 +89,7 @@ namespace led {
|
|||||||
//% blockId=device_set_brightness block="set brightness %value"
|
//% blockId=device_set_brightness block="set brightness %value"
|
||||||
//% parts="ledmatrix"
|
//% parts="ledmatrix"
|
||||||
//% advanced=true
|
//% advanced=true
|
||||||
|
//% value.min=0 value.max=255
|
||||||
void setBrightness(int value) {
|
void setBrightness(int value) {
|
||||||
uBit.display.setBrightness(value);
|
uBit.display.setBrightness(value);
|
||||||
}
|
}
|
||||||
@@ -92,10 +115,18 @@ namespace led {
|
|||||||
uBit.display.setDisplayMode((DisplayMode)mode);
|
uBit.display.setDisplayMode((DisplayMode)mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the current display mode
|
||||||
|
*/
|
||||||
|
//% weight=1 parts="ledmatrix" advanced=true
|
||||||
|
DisplayMode_ displayMode() {
|
||||||
|
return (DisplayMode_)uBit.display.getDisplayMode();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Turns on or off the display
|
* Turns on or off the display
|
||||||
*/
|
*/
|
||||||
//% help=led/enable blockId=device_led_enable
|
//% help=led/enable blockId=device_led_enable block="led enable %on"
|
||||||
//% advanced=true parts="ledmatrix"
|
//% advanced=true parts="ledmatrix"
|
||||||
void enable(bool on) {
|
void enable(bool on) {
|
||||||
if (on) uBit.display.enable();
|
if (on) uBit.display.enable();
|
||||||
|
|||||||
119
libs/core/melodies.ts
Normal file
@@ -0,0 +1,119 @@
|
|||||||
|
/*
|
||||||
|
The MIT License (MIT)
|
||||||
|
|
||||||
|
Copyright (c) 2013-2016 The MicroPython-on-micro:bit Developers, as listed
|
||||||
|
in the accompanying AUTHORS file
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in
|
||||||
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Melodies from file microbitmusictunes.c https://github.com/bbcmicrobit/MicroPython
|
||||||
|
|
||||||
|
enum Melodies {
|
||||||
|
//% block="dadadum" blockIdentity=music.builtInMelody
|
||||||
|
Dadadadum = 0,
|
||||||
|
//% block="entertainer" blockIdentity=music.builtInMelody
|
||||||
|
Entertainer,
|
||||||
|
//% block="prelude" blockIdentity=music.builtInMelody
|
||||||
|
Prelude,
|
||||||
|
//% block="ode" blockIdentity=music.builtInMelody
|
||||||
|
Ode,
|
||||||
|
//% block="nyan" blockIdentity=music.builtInMelody
|
||||||
|
Nyan,
|
||||||
|
//% block="ringtone" blockIdentity=music.builtInMelody
|
||||||
|
Ringtone,
|
||||||
|
//% block="funk" blockIdentity=music.builtInMelody
|
||||||
|
Funk,
|
||||||
|
//% block="blues" blockIdentity=music.builtInMelody
|
||||||
|
Blues,
|
||||||
|
//% block="birthday" blockIdentity=music.builtInMelody
|
||||||
|
Birthday,
|
||||||
|
//% block="wedding" blockIdentity=music.builtInMelody
|
||||||
|
Wedding,
|
||||||
|
//% block="funereal" blockIdentity=music.builtInMelody
|
||||||
|
Funeral,
|
||||||
|
//% block="punchline" blockIdentity=music.builtInMelody
|
||||||
|
Punchline,
|
||||||
|
//% block="baddy" blockIdentity=music.builtInMelody
|
||||||
|
Baddy,
|
||||||
|
//% block="chase" blockIdentity=music.builtInMelody
|
||||||
|
Chase,
|
||||||
|
//% block="ba ding" blockIdentity=music.builtInMelody
|
||||||
|
BaDing,
|
||||||
|
//% block="wawawawaa" blockIdentity=music.builtInMelody
|
||||||
|
Wawawawaa,
|
||||||
|
//% block="jump up" blockIdentity=music.builtInMelody
|
||||||
|
JumpUp,
|
||||||
|
//% block="jump down" blockIdentity=music.builtInMelody
|
||||||
|
JumpDown,
|
||||||
|
//% block="power up" blockIdentity=music.builtInMelody
|
||||||
|
PowerUp,
|
||||||
|
//% block="power down" blockIdentity=music.builtInMelody
|
||||||
|
PowerDown,
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace music {
|
||||||
|
|
||||||
|
export function getMelody(melody: Melodies): string[] {
|
||||||
|
switch (melody) {
|
||||||
|
case Melodies.Dadadadum:
|
||||||
|
return ['r4:2', 'g', 'g', 'g', 'eb:8', 'r:2', 'f', 'f', 'f', 'd:8'];
|
||||||
|
case Melodies.Entertainer:
|
||||||
|
return ['d4:1', 'd#', 'e', 'c5:2', 'e4:1', 'c5:2', 'e4:1', 'c5:3', 'c:1', 'd', 'd#', 'e', 'c', 'd', 'e:2', 'b4:1', 'd5:2', 'c:4'];
|
||||||
|
case Melodies.Prelude:
|
||||||
|
return ['c4:1', 'e', 'g', 'c5', 'e', 'g4', 'c5', 'e', 'c4', 'e', 'g', 'c5', 'e', 'g4', 'c5', 'e', 'c4', 'd', 'g', 'd5', 'f', 'g4', 'd5', 'f', 'c4', 'd', 'g', 'd5', 'f', 'g4', 'd5', 'f', 'b3', 'd4', 'g', 'd5', 'f', 'g4', 'd5', 'f', 'b3', 'd4', 'g', 'd5', 'f', 'g4', 'd5', 'f', 'c4', 'e', 'g', 'c5', 'e', 'g4', 'c5', 'e', 'c4', 'e', 'g', 'c5', 'e', 'g4', 'c5', 'e'];
|
||||||
|
case Melodies.Ode:
|
||||||
|
return ['e4', 'e', 'f', 'g', 'g', 'f', 'e', 'd', 'c', 'c', 'd', 'e', 'e:6', 'd:2', 'd:8', 'e:4', 'e', 'f', 'g', 'g', 'f', 'e', 'd', 'c', 'c', 'd', 'e', 'd:6', 'c:2', 'c:8'];
|
||||||
|
case Melodies.Nyan:
|
||||||
|
return ['f#5:2', 'g#', 'c#:1', 'd#:2', 'b4:1', 'd5:1', 'c#', 'b4:2', 'b', 'c#5', 'd', 'd:1', 'c#', 'b4:1', 'c#5:1', 'd#', 'f#', 'g#', 'd#', 'f#', 'c#', 'd', 'b4', 'c#5', 'b4', 'd#5:2', 'f#', 'g#:1', 'd#', 'f#', 'c#', 'd#', 'b4', 'd5', 'd#', 'd', 'c#', 'b4', 'c#5', 'd:2', 'b4:1', 'c#5', 'd#', 'f#', 'c#', 'd', 'c#', 'b4', 'c#5:2', 'b4', 'c#5', 'b4', 'f#:1', 'g#', 'b:2', 'f#:1', 'g#', 'b', 'c#5', 'd#', 'b4', 'e5', 'd#', 'e', 'f#', 'b4:2', 'b', 'f#:1', 'g#', 'b', 'f#', 'e5', 'd#', 'c#', 'b4', 'f#', 'd#', 'e', 'f#', 'b:2', 'f#:1', 'g#', 'b:2', 'f#:1', 'g#', 'b', 'b', 'c#5', 'd#', 'b4', 'f#', 'g#', 'f#', 'b:2', 'b:1', 'a#', 'b', 'f#', 'g#', 'b', 'e5', 'd#', 'e', 'f#', 'b4:2', 'c#5'];
|
||||||
|
case Melodies.Ringtone:
|
||||||
|
return ['c4:1', 'd', 'e:2', 'g', 'd:1', 'e', 'f:2', 'a', 'e:1', 'f', 'g:2', 'b', 'c5:4'];
|
||||||
|
case Melodies.Funk:
|
||||||
|
return ['c2:2', 'c', 'd#', 'c:1', 'f:2', 'c:1', 'f:2', 'f#', 'g', 'c', 'c', 'g', 'c:1', 'f#:2', 'c:1', 'f#:2', 'f', 'd#'];
|
||||||
|
case Melodies.Blues:
|
||||||
|
return ['c2:2', 'e', 'g', 'a', 'a#', 'a', 'g', 'e', 'c2:2', 'e', 'g', 'a', 'a#', 'a', 'g', 'e', 'f', 'a', 'c3', 'd', 'd#', 'd', 'c', 'a2', 'c2:2', 'e', 'g', 'a', 'a#', 'a', 'g', 'e', 'g', 'b', 'd3', 'f', 'f2', 'a', 'c3', 'd#', 'c2:2', 'e', 'g', 'e', 'g', 'f', 'e', 'd'];
|
||||||
|
case Melodies.Birthday:
|
||||||
|
return ['c4:3', 'c:1', 'd:4', 'c:4', 'f', 'e:8', 'c:3', 'c:1', 'd:4', 'c:4', 'g', 'f:8', 'c:3', 'c:1', 'c5:4', 'a4', 'f', 'e', 'd', 'a#:3', 'a#:1', 'a:4', 'f', 'g', 'f:8'];
|
||||||
|
case Melodies.Wedding:
|
||||||
|
return ['c4:4', 'f:3', 'f:1', 'f:8', 'c:4', 'g:3', 'e:1', 'f:8', 'c:4', 'f:3', 'a:1', 'c5:4', 'a4:3', 'f:1', 'f:4', 'e:3', 'f:1', 'g:8'];
|
||||||
|
case Melodies.Funeral:
|
||||||
|
return ['c3:4', 'c:3', 'c:1', 'c:4', 'd#:3', 'd:1', 'd:3', 'c:1', 'c:3', 'b2:1', 'c3:4'];
|
||||||
|
case Melodies.Punchline:
|
||||||
|
return ['c4:3', 'g3:1', 'f#', 'g', 'g#:3', 'g', 'r', 'b', 'c4'];
|
||||||
|
case Melodies.Baddy:
|
||||||
|
return ['c3:3', 'r', 'd:2', 'd#', 'r', 'c', 'r', 'f#:8'];
|
||||||
|
case Melodies.Chase:
|
||||||
|
return ['a4:1', 'b', 'c5', 'b4', 'a:2', 'r', 'a:1', 'b', 'c5', 'b4', 'a:2', 'r', 'a:2', 'e5', 'd#', 'e', 'f', 'e', 'd#', 'e', 'b4:1', 'c5', 'd', 'c', 'b4:2', 'r', 'b:1', 'c5', 'd', 'c', 'b4:2', 'r', 'b:2', 'e5', 'd#', 'e', 'f', 'e', 'd#', 'e'];
|
||||||
|
case Melodies.BaDing:
|
||||||
|
return ['b5:1', 'e6:3'];
|
||||||
|
case Melodies.Wawawawaa:
|
||||||
|
return ['e3:3', 'r:1', 'd#:3', 'r:1', 'd:4', 'r:1', 'c#:8'];
|
||||||
|
case Melodies.JumpUp:
|
||||||
|
return ['c5:1', 'd', 'e', 'f', 'g'];
|
||||||
|
case Melodies.JumpDown:
|
||||||
|
return ['g5:1', 'f', 'e', 'd', 'c'];
|
||||||
|
case Melodies.PowerUp:
|
||||||
|
return ['g4:1', 'c5', 'e', 'g:2', 'e:1', 'g:3'];
|
||||||
|
case Melodies.PowerDown:
|
||||||
|
return ['g5:1', 'd#', 'c', 'g4:2', 'b:1', 'c5:3'];
|
||||||
|
default:
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -6,10 +6,9 @@ namespace music {
|
|||||||
* @param frequency pitch of the tone to play in Hertz (Hz)
|
* @param frequency pitch of the tone to play in Hertz (Hz)
|
||||||
* @param ms tone duration in milliseconds (ms)
|
* @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
|
|
||||||
//% parts="speaker" async useEnumVal=1
|
//% parts="speaker" async useEnumVal=1
|
||||||
void playTone(int frequency, int ms) {
|
void speakerPlayTone(int frequency, int ms) {
|
||||||
if(frequency > 0) uBit.soundmotor.soundOn(frequency);
|
if(frequency > 0) uBit.soundmotor.soundOn(frequency);
|
||||||
else uBit.soundmotor.soundOff();
|
else uBit.soundmotor.soundOff();
|
||||||
if(ms > 0) {
|
if(ms > 0) {
|
||||||
|
|||||||
@@ -119,15 +119,82 @@ enum BeatFraction {
|
|||||||
//% block="1/8"
|
//% block="1/8"
|
||||||
Eighth = 8,
|
Eighth = 8,
|
||||||
//% block="1/16"
|
//% block="1/16"
|
||||||
Sixteenth = 16
|
Sixteenth = 16,
|
||||||
|
//% block="2"
|
||||||
|
Double = 32,
|
||||||
|
//% block="4",
|
||||||
|
Breve = 64
|
||||||
|
}
|
||||||
|
|
||||||
|
enum MelodyOptions {
|
||||||
|
//% block="once""
|
||||||
|
Once = 1,
|
||||||
|
//% block="forever"
|
||||||
|
Forever = 2,
|
||||||
|
//% block="once in background"
|
||||||
|
OnceInBackground = 4,
|
||||||
|
//% block="forever in background"
|
||||||
|
ForeverInBackground = 8
|
||||||
|
}
|
||||||
|
|
||||||
|
enum MusicEvent {
|
||||||
|
//% block="melody note played"
|
||||||
|
MelodyNotePlayed = 1,
|
||||||
|
//% block="melody started"
|
||||||
|
MelodyStarted = 2,
|
||||||
|
//% block="melody ended"
|
||||||
|
MelodyEnded = 3,
|
||||||
|
//% block="melody repeated"
|
||||||
|
MelodyRepeated = 4,
|
||||||
|
//% block="background melody note played"
|
||||||
|
BackgroundMelodyNotePlayed = MelodyNotePlayed | 0xf0,
|
||||||
|
//% block="background melody started"
|
||||||
|
BackgroundMelodyStarted = MelodyStarted | 0xf0,
|
||||||
|
//% block="background melody ended"
|
||||||
|
BackgroundMelodyEnded = MelodyEnded | 0xf0,
|
||||||
|
//% block="background melody repeated"
|
||||||
|
BackgroundMelodyRepeated = MelodyRepeated | 0xf0,
|
||||||
|
//% block="background melody paused"
|
||||||
|
BackgroundMelodyPaused = 5 | 0xf0,
|
||||||
|
//% block="background melody resumed"
|
||||||
|
BackgroundMelodyResumed = 6 | 0xf0
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generation of music tones through pin ``P0``.
|
* Generation of music tones.
|
||||||
*/
|
*/
|
||||||
//% color=#DF4600 weight=98 icon="\uf025"
|
//% color=#DF4600 weight=98 icon="\uf025"
|
||||||
namespace music {
|
namespace music {
|
||||||
let beatsPerMinute: number = 120;
|
let beatsPerMinute: number = 120;
|
||||||
|
let freqTable: number[] = [];
|
||||||
|
let _playTone: (frequency: number, duration: number) => void;
|
||||||
|
const MICROBIT_MELODY_ID = 2000;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Plays a tone through pin ``P0`` for the given duration.
|
||||||
|
* @param frequency pitch of the tone to play in Hertz (Hz)
|
||||||
|
* @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" blockGap=8
|
||||||
|
//% parts="headphone"
|
||||||
|
//% useEnumVal=1
|
||||||
|
export function playTone(frequency: number, ms: number): void {
|
||||||
|
if (_playTone) _playTone(frequency, ms);
|
||||||
|
else speakerPlayTone(frequency, ms);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Plays a tone through pin ``P0``.
|
||||||
|
* @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" blockGap=8
|
||||||
|
//% parts="headphone"
|
||||||
|
//% useEnumVal=1
|
||||||
|
export function ringTone(frequency: number): void {
|
||||||
|
playTone(frequency, 0);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Rests (plays nothing) for a specified time through pin ``P0``.
|
* Rests (plays nothing) for a specified time through pin ``P0``.
|
||||||
@@ -135,38 +202,28 @@ namespace music {
|
|||||||
*/
|
*/
|
||||||
//% help=music/rest weight=79
|
//% help=music/rest weight=79
|
||||||
//% blockId=device_rest block="rest(ms)|%duration=device_beat"
|
//% blockId=device_rest block="rest(ms)|%duration=device_beat"
|
||||||
//% parts="speaker"
|
//% parts="headphone"
|
||||||
export function rest(ms: number): void {
|
export function rest(ms: number): void {
|
||||||
playTone(0, ms);
|
playTone(0, ms);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Plays a tone through ``speaker``.
|
|
||||||
* @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" blockGap=8
|
|
||||||
//% parts="speaker" async
|
|
||||||
//% useEnumVal=1
|
|
||||||
export function ringTone(frequency: number) {
|
|
||||||
playTone(frequency, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the frequency of a note.
|
* Gets the frequency of a note.
|
||||||
* @param name the note name
|
* @param name the note name, eg: Note.C
|
||||||
*/
|
*/
|
||||||
//% weight=50 help=music/note-frequency
|
//% weight=50 help=music/note-frequency
|
||||||
//% blockId=device_note block="%note"
|
//% blockId=device_note block="%note"
|
||||||
//% shim=TD_ID blockHidden=true
|
//% shim=TD_ID
|
||||||
//% blockFieldEditor="note_editor"
|
//% note.fieldEditor="note" note.defl="262"
|
||||||
//% useEnumVal = 1
|
//% useEnumVal=1
|
||||||
export function noteFrequency(name: Note): number {
|
export function noteFrequency(name: Note): number {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
if (beatsPerMinute <= 0) beatsPerMinute = 120;
|
if (beatsPerMinute <= 0) beatsPerMinute = 120;
|
||||||
|
if (freqTable.length == 0) freqTable = [31, 33, 35, 37, 39, 41, 44, 46, 49, 52, 55, 58, 62, 65, 69, 73, 78, 82, 87, 92, 98, 104, 110, 117, 123, 131, 139, 147, 156, 165, 175, 185, 196, 208, 220, 233, 247, 262, 277, 294, 311, 330, 349, 370, 392, 415, 440, 466, 494, 523, 554, 587, 622, 659, 698, 740, 784, 831, 880, 932, 988, 1047, 1109, 1175, 1245, 1319, 1397, 1480, 1568, 1661, 1760, 1865, 1976, 2093, 2217, 2349, 2489, 2637, 2794, 2960, 3136, 3322, 3520, 3729, 3951, 4186]
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -178,11 +235,15 @@ namespace music {
|
|||||||
init();
|
init();
|
||||||
if (fraction == null) fraction = BeatFraction.Whole;
|
if (fraction == null) fraction = BeatFraction.Whole;
|
||||||
let beat = 60000 / beatsPerMinute;
|
let beat = 60000 / beatsPerMinute;
|
||||||
if (fraction == BeatFraction.Whole) return beat;
|
switch (fraction) {
|
||||||
else if (fraction == BeatFraction.Half) return beat / 2;
|
case BeatFraction.Half: return beat / 2;
|
||||||
else if (fraction == BeatFraction.Quarter) return beat / 4;
|
case BeatFraction.Quarter: return beat / 4;
|
||||||
else if (fraction == BeatFraction.Eighth) return beat / 8;
|
case BeatFraction.Eighth: return beat / 8;
|
||||||
else return beat / 16;
|
case BeatFraction.Sixteenth: return beat / 16;
|
||||||
|
case BeatFraction.Double: return beat * 2;
|
||||||
|
case BeatFraction.Breve: return beat * 4;
|
||||||
|
default: return beat;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -212,10 +273,166 @@ namespace music {
|
|||||||
*/
|
*/
|
||||||
//% help=music/set-tempo weight=38
|
//% help=music/set-tempo weight=38
|
||||||
//% blockId=device_set_tempo block="set tempo to (bpm)|%value"
|
//% blockId=device_set_tempo block="set tempo to (bpm)|%value"
|
||||||
|
//% bpm.min=4 bpm.max=400
|
||||||
export function setTempo(bpm: number): void {
|
export function setTempo(bpm: number): void {
|
||||||
init();
|
init();
|
||||||
if (bpm > 0) {
|
if (bpm > 0) {
|
||||||
beatsPerMinute = Math.max(1, bpm);
|
beatsPerMinute = Math.max(1, bpm);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let currentMelody: Melody;
|
||||||
|
let currentBackgroundMelody: Melody;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the melody array of a built-in melody.
|
||||||
|
* @param name the note name, eg: Note.C
|
||||||
|
*/
|
||||||
|
//% weight=50 help=music/builtin-melody
|
||||||
|
//% blockId=device_builtin_melody block="%melody"
|
||||||
|
//% blockHidden=true
|
||||||
|
export function builtInMelody(melody: Melodies): string[] {
|
||||||
|
return getMelody(melody);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Registers code to run on various melody events
|
||||||
|
*/
|
||||||
|
//% blockId=melody_on_event block="music on %value"
|
||||||
|
//% help=music/on-event weight=59
|
||||||
|
export function onEvent(value: MusicEvent, handler: Action) {
|
||||||
|
control.onEvent(MICROBIT_MELODY_ID, value, handler);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Starts playing a melody.
|
||||||
|
* Notes are expressed as a string of characters with this format: NOTE[octave][:duration]
|
||||||
|
* @param melodyArray the melody array to play, eg: ['g5:1']
|
||||||
|
* @param options melody options, once / forever, in the foreground / background
|
||||||
|
*/
|
||||||
|
//% help=music/begin-melody weight=60 blockGap=8
|
||||||
|
//% blockId=device_start_melody block="start melody %melody=device_builtin_melody| repeating %options"
|
||||||
|
//% parts="headphone"
|
||||||
|
export function beginMelody(melodyArray: string[], options: MelodyOptions = 1) {
|
||||||
|
init();
|
||||||
|
if (currentMelody != undefined) {
|
||||||
|
if (((options & MelodyOptions.OnceInBackground) == 0)
|
||||||
|
&& ((options & MelodyOptions.ForeverInBackground) == 0)
|
||||||
|
&& currentMelody.background) {
|
||||||
|
currentBackgroundMelody = currentMelody;
|
||||||
|
currentMelody = null;
|
||||||
|
control.raiseEvent(MICROBIT_MELODY_ID, MusicEvent.BackgroundMelodyPaused);
|
||||||
|
}
|
||||||
|
if (currentMelody)
|
||||||
|
control.raiseEvent(MICROBIT_MELODY_ID, currentMelody.background ? MusicEvent.BackgroundMelodyEnded : MusicEvent.MelodyEnded);
|
||||||
|
currentMelody = new Melody(melodyArray, options);
|
||||||
|
control.raiseEvent(MICROBIT_MELODY_ID, currentMelody.background ? MusicEvent.BackgroundMelodyStarted : MusicEvent.MelodyStarted);
|
||||||
|
} else {
|
||||||
|
currentMelody = new Melody(melodyArray, options);
|
||||||
|
control.raiseEvent(MICROBIT_MELODY_ID, currentMelody.background ? MusicEvent.BackgroundMelodyStarted : MusicEvent.MelodyStarted);
|
||||||
|
// Only start the fiber once
|
||||||
|
control.inBackground(() => {
|
||||||
|
while (currentMelody.hasNextNote()) {
|
||||||
|
playNextNote(currentMelody);
|
||||||
|
if (!currentMelody.hasNextNote() && currentBackgroundMelody) {
|
||||||
|
// Swap the background melody back
|
||||||
|
currentMelody = currentBackgroundMelody;
|
||||||
|
currentBackgroundMelody = null;
|
||||||
|
control.raiseEvent(MICROBIT_MELODY_ID, MusicEvent.MelodyEnded);
|
||||||
|
control.raiseEvent(MICROBIT_MELODY_ID, MusicEvent.BackgroundMelodyResumed);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
control.raiseEvent(MICROBIT_MELODY_ID, currentMelody.background ? MusicEvent.BackgroundMelodyEnded : MusicEvent.MelodyEnded);
|
||||||
|
currentMelody = null;
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets a custom playTone function for playing melodies
|
||||||
|
*/
|
||||||
|
//% help=music/set-play-tone
|
||||||
|
//% advanced=true
|
||||||
|
export function setPlayTone(f: (frequency: number, duration: number) => void) {
|
||||||
|
_playTone = f;
|
||||||
|
}
|
||||||
|
|
||||||
|
function playNextNote(melody: Melody): void {
|
||||||
|
// cache elements
|
||||||
|
let currNote = melody.nextNote();
|
||||||
|
let currentPos = melody.currentPos;
|
||||||
|
let currentDuration = melody.currentDuration;
|
||||||
|
let currentOctave = melody.currentOctave;
|
||||||
|
|
||||||
|
let note: number;
|
||||||
|
let isrest: boolean = false;
|
||||||
|
let beatPos: number;
|
||||||
|
let parsingOctave: boolean = true;
|
||||||
|
|
||||||
|
for (let pos = 0; pos < currNote.length; pos++) {
|
||||||
|
let noteChar = currNote.charAt(pos);
|
||||||
|
switch (noteChar) {
|
||||||
|
case 'c': case 'C': note = 1; break;
|
||||||
|
case 'd': case 'D': note = 3; break;
|
||||||
|
case 'e': case 'E': note = 5; break;
|
||||||
|
case 'f': case 'F': note = 6; break;
|
||||||
|
case 'g': case 'G': note = 8; break;
|
||||||
|
case 'a': case 'A': note = 10; break;
|
||||||
|
case 'b': case 'B': note = 12; break;
|
||||||
|
case 'r': case 'R': isrest = true; break;
|
||||||
|
case '#': note++; break;
|
||||||
|
case 'b': note--; break;
|
||||||
|
case ':': parsingOctave = false; beatPos = pos; break;
|
||||||
|
default: if (parsingOctave) currentOctave = parseInt(noteChar);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!parsingOctave) {
|
||||||
|
currentDuration = parseInt(currNote.substr(beatPos + 1, currNote.length - beatPos));
|
||||||
|
}
|
||||||
|
let beat = (60000 / beatsPerMinute) / 4;
|
||||||
|
if (isrest) {
|
||||||
|
music.rest(currentDuration * beat)
|
||||||
|
} else {
|
||||||
|
let keyNumber = note + (12 * (currentOctave - 1));
|
||||||
|
let frequency = keyNumber >= 0 && keyNumber < freqTable.length ? freqTable[keyNumber] : 0;
|
||||||
|
music.playTone(frequency, currentDuration * beat);
|
||||||
|
}
|
||||||
|
melody.currentDuration = currentDuration;
|
||||||
|
melody.currentOctave = currentOctave;
|
||||||
|
const repeating = melody.repeating && currentPos == melody.melodyArray.length - 1;
|
||||||
|
melody.currentPos = repeating ? 0 : currentPos + 1;
|
||||||
|
|
||||||
|
control.raiseEvent(MICROBIT_MELODY_ID, melody.background ? MusicEvent.BackgroundMelodyNotePlayed : MusicEvent.MelodyNotePlayed);
|
||||||
|
if (repeating)
|
||||||
|
control.raiseEvent(MICROBIT_MELODY_ID, melody.background ? MusicEvent.BackgroundMelodyRepeated : MusicEvent.MelodyRepeated);
|
||||||
|
}
|
||||||
|
|
||||||
|
class Melody {
|
||||||
|
public melodyArray: string[];
|
||||||
|
public currentDuration: number;
|
||||||
|
public currentOctave: number;
|
||||||
|
public currentPos: number;
|
||||||
|
public repeating: boolean;
|
||||||
|
public background: boolean;
|
||||||
|
|
||||||
|
constructor(melodyArray: string[], options: MelodyOptions) {
|
||||||
|
this.melodyArray = melodyArray;
|
||||||
|
this.repeating = ((options & MelodyOptions.Forever) != 0);
|
||||||
|
this.repeating = this.repeating ? true : ((options & MelodyOptions.ForeverInBackground) != 0)
|
||||||
|
this.background = ((options & MelodyOptions.OnceInBackground) != 0);
|
||||||
|
this.background = this.background ? true : ((options & MelodyOptions.ForeverInBackground) != 0);
|
||||||
|
this.currentDuration = 4; //Default duration (Crotchet)
|
||||||
|
this.currentOctave = 4; //Middle octave
|
||||||
|
this.currentPos = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
hasNextNote() {
|
||||||
|
return this.repeating || this.currentPos < this.melodyArray.length;
|
||||||
|
}
|
||||||
|
|
||||||
|
nextNote(): string {
|
||||||
|
const currentNote = this.melodyArray[this.currentPos];
|
||||||
|
return currentNote;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -102,42 +102,52 @@ namespace pins {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Read the specified pin or connector as either 0 or 1
|
* Read the specified pin or connector as either 0 or 1
|
||||||
* @param name pin to read from
|
* @param name pin to read from, eg: DigitalPin.P0
|
||||||
*/
|
*/
|
||||||
//% help=pins/digital-read-pin weight=30
|
//% help=pins/digital-read-pin weight=30
|
||||||
//% blockId=device_get_digital_pin block="digital read|pin %name" blockGap=8
|
//% blockId=device_get_digital_pin block="digital read|pin %name" blockGap=8
|
||||||
|
//% name.fieldEditor="gridpicker" name.fieldOptions.columns=4
|
||||||
|
//% name.fieldOptions.tooltips="false" name.fieldOptions.width="300"
|
||||||
int digitalReadPin(DigitalPin name) {
|
int digitalReadPin(DigitalPin name) {
|
||||||
PINREAD(getDigitalValue());
|
PINREAD(getDigitalValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set a pin or connector value to either 0 or 1.
|
* Set a pin or connector value to either 0 or 1.
|
||||||
* @param name pin to write to
|
* @param name pin to write to, eg: DigitalPin.P0
|
||||||
* @param value value to set on the pin, 1 eg,0
|
* @param value value to set on the pin, 1 eg,0
|
||||||
*/
|
*/
|
||||||
//% help=pins/digital-write-pin weight=29
|
//% help=pins/digital-write-pin weight=29
|
||||||
//% blockId=device_set_digital_pin block="digital write|pin %name|to %value"
|
//% blockId=device_set_digital_pin block="digital write|pin %name|to %value"
|
||||||
|
//% value.min=0 value.max=1
|
||||||
|
//% name.fieldEditor="gridpicker" name.fieldOptions.columns=4
|
||||||
|
//% name.fieldOptions.tooltips="false" name.fieldOptions.width="300"
|
||||||
void digitalWritePin(DigitalPin name, int value) {
|
void digitalWritePin(DigitalPin name, int value) {
|
||||||
PINOP(setDigitalValue(value));
|
PINOP(setDigitalValue(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Read the connector value as analog, that is, as a value comprised between 0 and 1023.
|
* Read the connector value as analog, that is, as a value comprised between 0 and 1023.
|
||||||
* @param name pin to write to
|
* @param name pin to write to, eg: AnalogPin.P0
|
||||||
*/
|
*/
|
||||||
//% help=pins/analog-read-pin weight=25
|
//% help=pins/analog-read-pin weight=25
|
||||||
//% blockId=device_get_analog_pin block="analog read|pin %name" blockGap="8"
|
//% blockId=device_get_analog_pin block="analog read|pin %name" blockGap="8"
|
||||||
|
//% name.fieldEditor="gridpicker" name.fieldOptions.columns=4
|
||||||
|
//% name.fieldOptions.tooltips="false"
|
||||||
int analogReadPin(AnalogPin name) {
|
int analogReadPin(AnalogPin name) {
|
||||||
PINREAD(getAnalogValue());
|
PINREAD(getAnalogValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the connector value as analog. Value must be comprised between 0 and 1023.
|
* Set the connector value as analog. Value must be comprised between 0 and 1023.
|
||||||
* @param name pin name to write to
|
* @param name pin name to write to, eg: AnalogPin.P0
|
||||||
* @param value value to write to the pin between ``0`` and ``1023``. eg:1023,0
|
* @param value value to write to the pin between ``0`` and ``1023``. eg:1023,0
|
||||||
*/
|
*/
|
||||||
//% help=pins/analog-write-pin weight=24
|
//% help=pins/analog-write-pin weight=24
|
||||||
//% blockId=device_set_analog_pin block="analog write|pin %name|to %value" blockGap=8
|
//% blockId=device_set_analog_pin block="analog write|pin %name|to %value" blockGap=8
|
||||||
|
//% value.min=0 value.max=1023
|
||||||
|
//% name.fieldEditor="gridpicker" name.fieldOptions.columns=4
|
||||||
|
//% name.fieldOptions.tooltips="false"
|
||||||
void analogWritePin(AnalogPin name, int value) {
|
void analogWritePin(AnalogPin name, int value) {
|
||||||
PINOP(setAnalogValue(value));
|
PINOP(setAnalogValue(value));
|
||||||
}
|
}
|
||||||
@@ -145,20 +155,26 @@ namespace pins {
|
|||||||
/**
|
/**
|
||||||
* Configures the Pulse-width modulation (PWM) of the analog output to the given value in **microseconds** or `1/1000` milliseconds.
|
* Configures the Pulse-width modulation (PWM) of the analog output to the given value in **microseconds** or `1/1000` milliseconds.
|
||||||
* If this pin is not configured as an analog output (using `analog write pin`), the operation has no effect.
|
* If this pin is not configured as an analog output (using `analog write pin`), the operation has no effect.
|
||||||
* @param name analog pin to set period to
|
* @param name analog pin to set period to, eg: AnalogPin.P0
|
||||||
* @param micros period in micro seconds. eg:20000
|
* @param micros period in micro seconds. eg:20000
|
||||||
*/
|
*/
|
||||||
//% help=pins/analog-set-period weight=23 blockGap=8
|
//% help=pins/analog-set-period weight=23 blockGap=8
|
||||||
//% blockId=device_set_analog_period block="analog set period|pin %pin|to (µs)%micros"
|
//% blockId=device_set_analog_period block="analog set period|pin %pin|to (µs)%micros"
|
||||||
|
//% pin.fieldEditor="gridpicker" pin.fieldOptions.columns=4
|
||||||
|
//% pin.fieldOptions.tooltips="false"
|
||||||
void analogSetPeriod(AnalogPin name, int micros) {
|
void analogSetPeriod(AnalogPin name, int micros) {
|
||||||
PINOP(setAnalogPeriodUs(micros));
|
PINOP(setAnalogPeriodUs(micros));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Configures this pin to a digital input, and generates events where the timestamp is the duration that this pin was either ``high`` or ``low``.
|
* Configures this pin to a digital input, and generates events where the timestamp is the duration that this pin was either ``high`` or ``low``.
|
||||||
|
* @param name digital pin to register to, eg: DigitalPin.P0
|
||||||
|
* @param pulse the value of the pulse, eg: PulseValue.High
|
||||||
*/
|
*/
|
||||||
//% help=pins/on-pulsed weight=22 blockGap=8
|
//% help=pins/on-pulsed weight=22 blockGap=8 advanced=true
|
||||||
//% blockId=pins_on_pulsed block="on|pin %pin|pulsed %pulse"
|
//% blockId=pins_on_pulsed block="on|pin %pin|pulsed %pulse"
|
||||||
|
//% pin.fieldEditor="gridpicker" pin.fieldOptions.columns=4
|
||||||
|
//% pin.fieldOptions.tooltips="false" pin.fieldOptions.width="300"
|
||||||
void onPulsed(DigitalPin name, PulseValue pulse, Action body) {
|
void onPulsed(DigitalPin name, PulseValue pulse, Action body) {
|
||||||
MicroBitPin* pin = getPin((int)name);
|
MicroBitPin* pin = getPin((int)name);
|
||||||
if (!pin) return;
|
if (!pin) return;
|
||||||
@@ -170,7 +186,7 @@ namespace pins {
|
|||||||
/**
|
/**
|
||||||
* Gets the duration of the last pulse in micro-seconds. This function should be called from a ``onPulsed`` handler.
|
* Gets the duration of the last pulse in micro-seconds. This function should be called from a ``onPulsed`` handler.
|
||||||
*/
|
*/
|
||||||
//% help=pins/pulse-duration
|
//% help=pins/pulse-duration advanced=true
|
||||||
//% blockId=pins_pulse_duration block="pulse duration (µs)"
|
//% blockId=pins_pulse_duration block="pulse duration (µs)"
|
||||||
//% weight=21 blockGap=8
|
//% weight=21 blockGap=8
|
||||||
int pulseDuration() {
|
int pulseDuration() {
|
||||||
@@ -179,12 +195,15 @@ namespace pins {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the duration of a pulse in microseconds
|
* Returns the duration of a pulse in microseconds
|
||||||
* @param name the pin which measures the pulse
|
* @param name the pin which measures the pulse, eg: DigitalPin.P0
|
||||||
* @param value the value of the pulse (default high)
|
* @param value the value of the pulse, eg: PulseValue.High
|
||||||
* @param maximum duration in micro-seconds
|
* @param maximum duration in micro-seconds
|
||||||
*/
|
*/
|
||||||
//% blockId="pins_pulse_in" block="pulse in (µs)|pin %name|pulsed %value"
|
//% blockId="pins_pulse_in" block="pulse in (µs)|pin %name|pulsed %value"
|
||||||
//% weight=20
|
//% weight=20 advanced=true
|
||||||
|
//% help=pins/pulse-in
|
||||||
|
//% name.fieldEditor="gridpicker" name.fieldOptions.columns=4
|
||||||
|
//% name.fieldOptions.tooltips="false" name.fieldOptions.width="300"
|
||||||
int pulseIn(DigitalPin name, PulseValue value, int maxDuration = 2000000) {
|
int pulseIn(DigitalPin name, PulseValue value, int maxDuration = 2000000) {
|
||||||
MicroBitPin* pin = getPin((int)name);
|
MicroBitPin* pin = getPin((int)name);
|
||||||
if (!pin) return 0;
|
if (!pin) return 0;
|
||||||
@@ -206,15 +225,30 @@ namespace pins {
|
|||||||
return end - start;
|
return end - start;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO FIX THIS IN THE DAL!
|
||||||
|
inline void fixMotorIssue(AnalogPin name) {
|
||||||
|
NRF_TIMER2->SHORTS = TIMER_SHORTS_COMPARE3_CLEAR_Msk;
|
||||||
|
NRF_TIMER2->INTENCLR = TIMER_INTENCLR_COMPARE3_Msk;
|
||||||
|
NRF_TIMER2->PRESCALER = 4;
|
||||||
|
NRF_TIMER2->CC[3] = 20000;
|
||||||
|
NRF_TIMER2->TASKS_START = 1;
|
||||||
|
NRF_TIMER2->EVENTS_COMPARE[3] = 0;
|
||||||
|
PINOP(getDigitalValue());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Writes a value to the servo, controlling the shaft accordingly. On a standard servo, this will set the angle of the shaft (in degrees), moving the shaft to that orientation. On a continuous rotation servo, this will set the speed of the servo (with ``0`` being full-speed in one direction, ``180`` being full speed in the other, and a value near ``90`` being no movement).
|
* Writes a value to the servo, controlling the shaft accordingly. On a standard servo, this will set the angle of the shaft (in degrees), moving the shaft to that orientation. On a continuous rotation servo, this will set the speed of the servo (with ``0`` being full-speed in one direction, ``180`` being full speed in the other, and a value near ``90`` being no movement).
|
||||||
* @param name pin to write to
|
* @param name pin to write to, eg: AnalogPin.P0
|
||||||
* @param value angle or rotation speed, eg:180,90,0
|
* @param value angle or rotation speed, eg:180,90,0
|
||||||
*/
|
*/
|
||||||
//% help=pins/servo-write-pin weight=20
|
//% help=pins/servo-write-pin weight=20
|
||||||
//% blockId=device_set_servo_pin block="servo write|pin %name|to %value" blockGap=8
|
//% blockId=device_set_servo_pin block="servo write|pin %name|to %value" blockGap=8
|
||||||
//% parts=microservo trackArgs=0
|
//% parts=microservo trackArgs=0
|
||||||
|
//% value.min=0 value.max=180
|
||||||
|
//% name.fieldEditor="gridpicker" name.fieldOptions.columns=4
|
||||||
|
//% name.fieldOptions.tooltips="false"
|
||||||
void servoWritePin(AnalogPin name, int value) {
|
void servoWritePin(AnalogPin name, int value) {
|
||||||
|
fixMotorIssue(name);
|
||||||
PINOP(setServoValue(value));
|
PINOP(setServoValue(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -225,7 +259,10 @@ namespace pins {
|
|||||||
*/
|
*/
|
||||||
//% help=pins/servo-set-pulse weight=19
|
//% help=pins/servo-set-pulse weight=19
|
||||||
//% blockId=device_set_servo_pulse block="servo set pulse|pin %value|to (µs) %micros"
|
//% blockId=device_set_servo_pulse block="servo set pulse|pin %value|to (µs) %micros"
|
||||||
|
//% value.fieldEditor="gridpicker" value.fieldOptions.columns=4
|
||||||
|
//% value.fieldOptions.tooltips="false"
|
||||||
void servoSetPulse(AnalogPin name, int micros) {
|
void servoSetPulse(AnalogPin name, int micros) {
|
||||||
|
fixMotorIssue(name);
|
||||||
PINOP(setServoPulseUs(micros));
|
PINOP(setServoPulseUs(micros));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -233,48 +270,52 @@ namespace pins {
|
|||||||
MicroBitPin* pitchPin = NULL;
|
MicroBitPin* pitchPin = NULL;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the pin used when using `pins->analog pitch`.
|
* Sets the pin used when using `analog pitch` or music.
|
||||||
* @param name TODO
|
* @param name pin to modulate pitch from
|
||||||
*/
|
*/
|
||||||
//% blockId=device_analog_set_pitch_pin block="analog set pitch pin %name"
|
//% blockId=device_analog_set_pitch_pin block="analog set pitch pin %name"
|
||||||
//% help=pins/analog-set-pitch weight=3 advanced=true
|
//% help=pins/analog-set-pitch-pin weight=3 advanced=true
|
||||||
|
//% name.fieldEditor="gridpicker" name.fieldOptions.columns=4
|
||||||
|
//% name.fieldOptions.tooltips="false"
|
||||||
void analogSetPitchPin(AnalogPin name) {
|
void analogSetPitchPin(AnalogPin name) {
|
||||||
pitchPin = getPin((int)name);
|
pitchPin = getPin((int)name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Emits a Pulse-width modulation (PWM) signal to the current pitch pin. Use `analog set pitch pin` to define the pitch pin.
|
* Emits a Pulse-width modulation (PWM) signal to the current pitch pin. Use `analog set pitch pin` to define the pitch pin.
|
||||||
* @param frequency TODO
|
* @param frequency frequency to modulate in Hz.
|
||||||
* @param ms TODO
|
* @param ms duration of the pitch in milli seconds.
|
||||||
*/
|
*/
|
||||||
//% blockId=device_analog_pitch block="analog pitch %frequency|for (ms) %ms"
|
//% blockId=device_analog_pitch block="analog pitch %frequency|for (ms) %ms"
|
||||||
//% help=pins/analog-pitch weight=4 async advanced=true blockGap=8
|
//% help=pins/analog-pitch weight=4 async advanced=true blockGap=8
|
||||||
void analogPitch(int frequency, int ms) {
|
void analogPitch(int frequency, int ms) {
|
||||||
if (pitchPin == NULL)
|
if (pitchPin == NULL)
|
||||||
analogSetPitchPin(AnalogPin::P1);
|
analogSetPitchPin(AnalogPin::P1);
|
||||||
if (frequency <= 0) {
|
if (frequency <= 0) {
|
||||||
pitchPin->setAnalogValue(0);
|
|
||||||
} else {
|
|
||||||
pitchPin->setAnalogValue(512);
|
|
||||||
pitchPin->setAnalogPeriodUs(1000000/frequency);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ms > 0) {
|
|
||||||
fiber_sleep(ms);
|
|
||||||
pitchPin->setAnalogValue(0);
|
pitchPin->setAnalogValue(0);
|
||||||
// TODO why do we use wait_ms() here? it's a busy wait I think
|
} else {
|
||||||
wait_ms(5);
|
pitchPin->setAnalogValue(512);
|
||||||
}
|
pitchPin->setAnalogPeriodUs(1000000/frequency);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ms > 0) {
|
||||||
|
fiber_sleep(ms);
|
||||||
|
pitchPin->setAnalogValue(0);
|
||||||
|
// TODO why do we use wait_ms() here? it's a busy wait I think
|
||||||
|
wait_ms(5);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Configures the pull of this pin.
|
* Configures the pull of this pin.
|
||||||
* @param name pin to set the pull mode on
|
* @param name pin to set the pull mode on, eg: DigitalPin.P0
|
||||||
* @param pull one of the mbed pull configurations: PullUp, PullDown, PullNone
|
* @param pull one of the mbed pull configurations, eg: PinPullMode.PullUp
|
||||||
*/
|
*/
|
||||||
//% help=pins/set-pull weight=3
|
//% help=pins/set-pull weight=3 advanced=true
|
||||||
//% blockId=device_set_pull block="set pull|pin %pin|to %pull"
|
//% blockId=device_set_pull block="set pull|pin %pin|to %pull"
|
||||||
|
//% pin.fieldEditor="gridpicker" pin.fieldOptions.columns=4
|
||||||
|
//% pin.fieldOptions.tooltips="false" pin.fieldOptions.width="300"
|
||||||
void setPull(DigitalPin name, PinPullMode pull) {
|
void setPull(DigitalPin name, PinPullMode pull) {
|
||||||
PinMode m = pull == PinPullMode::PullDown
|
PinMode m = pull == PinPullMode::PullDown
|
||||||
? PinMode::PullDown
|
? PinMode::PullDown
|
||||||
@@ -291,6 +332,8 @@ namespace pins {
|
|||||||
*/
|
*/
|
||||||
//% help=pins/set-events weight=4 advanced=true
|
//% help=pins/set-events weight=4 advanced=true
|
||||||
//% blockId=device_set_pin_events block="set pin %pin|to emit %type|events"
|
//% blockId=device_set_pin_events block="set pin %pin|to emit %type|events"
|
||||||
|
//% pin.fieldEditor="gridpicker" pin.fieldOptions.columns=4
|
||||||
|
//% pin.fieldOptions.tooltips="false" pin.fieldOptions.width="300"
|
||||||
void setEvents(DigitalPin name, PinEventType type) {
|
void setEvents(DigitalPin name, PinEventType type) {
|
||||||
getPin((int)name)->eventOn((int)type);
|
getPin((int)name)->eventOn((int)type);
|
||||||
}
|
}
|
||||||
@@ -324,10 +367,10 @@ namespace pins {
|
|||||||
{
|
{
|
||||||
uBit.i2c.write(address << 1, (char*)buf->payload, buf->length, repeat);
|
uBit.i2c.write(address << 1, (char*)buf->payload, buf->length, repeat);
|
||||||
}
|
}
|
||||||
|
|
||||||
SPI* spi = NULL;
|
SPI* spi = NULL;
|
||||||
SPI* allocSPI() {
|
SPI* allocSPI() {
|
||||||
if (spi == NULL)
|
if (NULL == spi)
|
||||||
spi = new SPI(MOSI, MISO, SCK);
|
spi = new SPI(MOSI, MISO, SCK);
|
||||||
return spi;
|
return spi;
|
||||||
}
|
}
|
||||||
@@ -336,11 +379,54 @@ namespace pins {
|
|||||||
* Write to the SPI slave and return the response
|
* Write to the SPI slave and return the response
|
||||||
* @param value Data to be sent to the SPI slave
|
* @param value Data to be sent to the SPI slave
|
||||||
*/
|
*/
|
||||||
//% help=pins/spi-write weight=5
|
//% help=pins/spi-write weight=5 advanced=true
|
||||||
//% blockId=spi_write block="spi write %value"
|
//% blockId=spi_write block="spi write %value"
|
||||||
int spiWrite(int value) {
|
int spiWrite(int value) {
|
||||||
auto p = allocSPI();
|
auto p = allocSPI();
|
||||||
return p->write(value);
|
return p->write(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the SPI frequency
|
||||||
|
* @param frequency the clock frequency, eg: 1000000
|
||||||
|
*/
|
||||||
|
//% help=pins/spi-frequency weight=4 advanced=true
|
||||||
|
//% blockId=spi_frequency block="spi frequency %frequency"
|
||||||
|
void spiFrequency(int frequency) {
|
||||||
|
auto p = allocSPI();
|
||||||
|
p->frequency(frequency);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the SPI bits and mode
|
||||||
|
* @param bits the number of bits, eg: 8
|
||||||
|
* @param mode the mode, eg: 3
|
||||||
|
*/
|
||||||
|
//% help=pins/spi-format weight=3 advanced=true
|
||||||
|
//% blockId=spi_format block="spi format|bits %bits|mode %mode"
|
||||||
|
void spiFormat(int bits, int mode) {
|
||||||
|
auto p = allocSPI();
|
||||||
|
p->format(bits, mode);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the MOSI, MISO, SCK pins used by the SPI instance
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
//% help=pins/spi-pins weight=2 advanced=true
|
||||||
|
//% blockId=spi_pins block="spi set pins|MOSI %mosi|MISO %miso|SCK %sck"
|
||||||
|
//% mosi.fieldEditor="gridpicker" mosi.fieldOptions.columns=4
|
||||||
|
//% mosi.fieldOptions.tooltips="false" mosi.fieldOptions.width="300"
|
||||||
|
//% miso.fieldEditor="gridpicker" miso.fieldOptions.columns=4
|
||||||
|
//% miso.fieldOptions.tooltips="false" miso.fieldOptions.width="300"
|
||||||
|
//% sck.fieldEditor="gridpicker" sck.fieldOptions.columns=4
|
||||||
|
//% sck.fieldOptions.tooltips="false" sck.fieldOptions.width="300"
|
||||||
|
void spiPins(DigitalPin mosi, DigitalPin miso, DigitalPin sck) {
|
||||||
|
if (NULL != spi) {
|
||||||
|
delete spi;
|
||||||
|
spi = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
spi = new SPI(getPin((int)mosi)->name, getPin((int)miso)->name, getPin((int)sck)->name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,9 +22,9 @@ namespace pins {
|
|||||||
* Read one number from 7-bit I2C address.
|
* Read one number from 7-bit I2C address.
|
||||||
*/
|
*/
|
||||||
//% help=pins/i2c-read-number blockGap=8
|
//% help=pins/i2c-read-number blockGap=8
|
||||||
//% blockId=pins_i2c_readnumber block="i2c read number|at address %address|of format %format=i2c_sizeof" weight=7
|
//% blockId=pins_i2c_readnumber block="i2c read number|at address %address|of format %format=i2c_sizeof|repeat %repeat" weight=7
|
||||||
export function i2cReadNumber(address: number, format: NumberFormat): number {
|
export function i2cReadNumber(address: number, format: NumberFormat, repeat?: boolean): number {
|
||||||
let buf = pins.i2cReadBuffer(address, pins.sizeOf(format))
|
let buf = pins.i2cReadBuffer(address, pins.sizeOf(format), repeat)
|
||||||
return buf.getNumber(format, 0)
|
return buf.getNumber(format, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -32,11 +32,11 @@ namespace pins {
|
|||||||
* Write one number to a 7-bit I2C address.
|
* Write one number to a 7-bit I2C address.
|
||||||
*/
|
*/
|
||||||
//% help=pins/i2c-write-number blockGap=8
|
//% help=pins/i2c-write-number blockGap=8
|
||||||
//% blockId=i2c_writenumber block="i2c write number|at address %address|with value %value|of format %format=i2c_sizeof" weight=6
|
//% blockId=i2c_writenumber block="i2c write number|at address %address|with value %value|of format %format=i2c_sizeof|repeat %repeat" weight=6
|
||||||
export function i2cWriteNumber(address: number, value: number, format: NumberFormat): void {
|
export function i2cWriteNumber(address: number, value: number, format: NumberFormat, repeat?: boolean): void {
|
||||||
let buf = createBuffer(pins.sizeOf(format))
|
let buf = createBuffer(pins.sizeOf(format))
|
||||||
buf.setNumber(format, 0, value)
|
buf.setNumber(format, 0, value)
|
||||||
pins.i2cWriteBuffer(address, buf)
|
pins.i2cWriteBuffer(address, buf, repeat)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -146,16 +146,16 @@ namespace pxt {
|
|||||||
#ifdef DEBUG_BUILD
|
#ifdef DEBUG_BUILD
|
||||||
printf("In Segment::get index:%u\n", i);
|
printf("In Segment::get index:%u\n", i);
|
||||||
this->print();
|
this->print();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (i < length)
|
if (i < length)
|
||||||
{
|
{
|
||||||
return data[i];
|
return data[i];
|
||||||
}
|
}
|
||||||
return Segment::DefaultValue;
|
return Segment::DefaultValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Segment::set(uint32_t i, uint32_t value)
|
void Segment::set(uint32_t i, uint32_t value)
|
||||||
{
|
{
|
||||||
if (i < size)
|
if (i < size)
|
||||||
{
|
{
|
||||||
@@ -168,16 +168,16 @@ namespace pxt {
|
|||||||
}
|
}
|
||||||
if (length <= i)
|
if (length <= i)
|
||||||
{
|
{
|
||||||
length = i + 1;
|
length = i + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG_BUILD
|
#ifdef DEBUG_BUILD
|
||||||
printf("In Segment::set\n");
|
printf("In Segment::set\n");
|
||||||
this->print();
|
this->print();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t Segment::growthFactor(uint16_t size)
|
uint16_t Segment::growthFactor(uint16_t size)
|
||||||
{
|
{
|
||||||
@@ -201,12 +201,12 @@ namespace pxt {
|
|||||||
growBy(max(minSize, growthFactor(size)));
|
growBy(max(minSize, growthFactor(size)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Segment::growBy(uint16_t newSize)
|
void Segment::growBy(uint16_t newSize)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_BUILD
|
#ifdef DEBUG_BUILD
|
||||||
printf("growBy: %d\n", newSize);
|
printf("growBy: %d\n", newSize);
|
||||||
this->print();
|
this->print();
|
||||||
#endif
|
#endif
|
||||||
if (size < newSize)
|
if (size < newSize)
|
||||||
{
|
{
|
||||||
//this will throw if unable to allocate
|
//this will throw if unable to allocate
|
||||||
@@ -221,16 +221,16 @@ namespace pxt {
|
|||||||
memset(tmp + size, Segment::DefaultValue, (newSize - size) * sizeof(uint32_t));
|
memset(tmp + size, Segment::DefaultValue, (newSize - size) * sizeof(uint32_t));
|
||||||
|
|
||||||
//free older segment;
|
//free older segment;
|
||||||
::operator delete(data);
|
::operator delete(data);
|
||||||
|
|
||||||
data = tmp;
|
data = tmp;
|
||||||
size = newSize;
|
size = newSize;
|
||||||
|
|
||||||
#ifdef DEBUG_BUILD
|
#ifdef DEBUG_BUILD
|
||||||
printf("growBy - after reallocation\n");
|
printf("growBy - after reallocation\n");
|
||||||
this->print();
|
this->print();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
//else { no shrinking yet; }
|
//else { no shrinking yet; }
|
||||||
return;
|
return;
|
||||||
@@ -249,42 +249,42 @@ namespace pxt {
|
|||||||
{
|
{
|
||||||
if (newLength > size)
|
if (newLength > size)
|
||||||
{
|
{
|
||||||
ensure(length);
|
ensure(length);
|
||||||
}
|
}
|
||||||
length = newLength;
|
length = newLength;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Segment::push(uint32_t value)
|
void Segment::push(uint32_t value)
|
||||||
{
|
{
|
||||||
this->set(length, value);
|
this->set(length, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t Segment::pop()
|
uint32_t Segment::pop()
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_BUILD
|
#ifdef DEBUG_BUILD
|
||||||
printf("In Segment::pop\n");
|
printf("In Segment::pop\n");
|
||||||
this->print();
|
this->print();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (length > 0)
|
if (length > 0)
|
||||||
{
|
{
|
||||||
|
--length;
|
||||||
uint32_t value = data[length];
|
uint32_t value = data[length];
|
||||||
data[length] = Segment::DefaultValue;
|
data[length] = Segment::DefaultValue;
|
||||||
--length;
|
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
return Segment::DefaultValue;
|
return Segment::DefaultValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
//this function removes an element at index i and shifts the rest of the elements to
|
//this function removes an element at index i and shifts the rest of the elements to
|
||||||
//left to fill the gap
|
//left to fill the gap
|
||||||
uint32_t Segment::remove(uint32_t i)
|
uint32_t Segment::remove(uint32_t i)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_BUILD
|
#ifdef DEBUG_BUILD
|
||||||
printf("In Segment::remove index:%u\n", i);
|
printf("In Segment::remove index:%u\n", i);
|
||||||
this->print();
|
this->print();
|
||||||
#endif
|
#endif
|
||||||
if (i < length)
|
if (i < length)
|
||||||
{
|
{
|
||||||
//value to return
|
//value to return
|
||||||
@@ -294,24 +294,24 @@ namespace pxt {
|
|||||||
//Move the rest of the elements to fill in the gap.
|
//Move the rest of the elements to fill in the gap.
|
||||||
memmove(data + i, data + i + 1, (length - i - 1) * sizeof(uint32_t));
|
memmove(data + i, data + i + 1, (length - i - 1) * sizeof(uint32_t));
|
||||||
}
|
}
|
||||||
length--;
|
length--;
|
||||||
data[length] = Segment::DefaultValue;
|
data[length] = Segment::DefaultValue;
|
||||||
#ifdef DEBUG_BUILD
|
#ifdef DEBUG_BUILD
|
||||||
printf("After Segment::remove index:%u\n", i);
|
printf("After Segment::remove index:%u\n", i);
|
||||||
this->print();
|
this->print();
|
||||||
#endif
|
#endif
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
return Segment::DefaultValue;
|
return Segment::DefaultValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
//this function inserts element value at index i by shifting the rest of the elements right.
|
//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)
|
void Segment::insert(uint32_t i, uint32_t value)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_BUILD
|
#ifdef DEBUG_BUILD
|
||||||
printf("In Segment::insert index:%u value:%u\n", i, value);
|
printf("In Segment::insert index:%u value:%u\n", i, value);
|
||||||
this->print();
|
this->print();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (i < length)
|
if (i < length)
|
||||||
{
|
{
|
||||||
@@ -322,7 +322,7 @@ namespace pxt {
|
|||||||
memmove(data + i + 1, data + i, (length - i) * sizeof(uint32_t));
|
memmove(data + i + 1, data + i, (length - i) * sizeof(uint32_t));
|
||||||
}
|
}
|
||||||
|
|
||||||
data[i] = value;
|
data[i] = value;
|
||||||
length++;
|
length++;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -333,7 +333,7 @@ namespace pxt {
|
|||||||
#ifdef DEBUG_BUILD
|
#ifdef DEBUG_BUILD
|
||||||
printf("After Segment::insert index:%u\n", i);
|
printf("After Segment::insert index:%u\n", i);
|
||||||
this->print();
|
this->print();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void Segment::print()
|
void Segment::print()
|
||||||
@@ -360,29 +360,29 @@ namespace pxt {
|
|||||||
#ifdef DEBUG_BUILD
|
#ifdef DEBUG_BUILD
|
||||||
printf("In Segment::destroy\n");
|
printf("In Segment::destroy\n");
|
||||||
this->print();
|
this->print();
|
||||||
#endif
|
#endif
|
||||||
length = size = 0;
|
length = size = 0;
|
||||||
::operator delete(data);
|
::operator delete(data);
|
||||||
data = nullptr;
|
data = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RefCollection::push(uint32_t x)
|
void RefCollection::push(uint32_t x)
|
||||||
{
|
{
|
||||||
if (isRef()) incr(x);
|
if (isRef()) incr(x);
|
||||||
head.push(x);
|
head.push(x);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t RefCollection::pop()
|
uint32_t RefCollection::pop()
|
||||||
{
|
{
|
||||||
uint32_t ret = head.pop();
|
uint32_t ret = head.pop();
|
||||||
if (isRef())
|
if (isRef())
|
||||||
{
|
{
|
||||||
incr(ret);
|
incr(ret);
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t RefCollection::getAt(int i)
|
uint32_t RefCollection::getAt(int i)
|
||||||
{
|
{
|
||||||
uint32_t tmp = head.get(i);
|
uint32_t tmp = head.get(i);
|
||||||
if (isRef())
|
if (isRef())
|
||||||
@@ -392,27 +392,24 @@ namespace pxt {
|
|||||||
return tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t RefCollection::removeAt(int i)
|
uint32_t RefCollection::removeAt(int i)
|
||||||
{
|
{
|
||||||
if (isRef())
|
// no decr() - we return the result
|
||||||
{
|
|
||||||
decr(head.get(i));
|
|
||||||
}
|
|
||||||
return head.remove(i);
|
return head.remove(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RefCollection::insertAt(int i, uint32_t value)
|
void RefCollection::insertAt(int i, uint32_t value)
|
||||||
{
|
{
|
||||||
head.insert(i, value);
|
head.insert(i, value);
|
||||||
if (isRef())
|
if (isRef())
|
||||||
{
|
{
|
||||||
incr(value);
|
incr(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void RefCollection::setAt(int i, uint32_t value)
|
void RefCollection::setAt(int i, uint32_t value)
|
||||||
{
|
{
|
||||||
if (isRef())
|
if (isRef())
|
||||||
{
|
{
|
||||||
if (head.isValidIndex((uint32_t)i))
|
if (head.isValidIndex((uint32_t)i))
|
||||||
{
|
{
|
||||||
@@ -423,9 +420,9 @@ namespace pxt {
|
|||||||
head.set(i, value);
|
head.set(i, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
int RefCollection::indexOf(uint32_t x, int start)
|
int RefCollection::indexOf(uint32_t x, int start)
|
||||||
{
|
{
|
||||||
if (isString())
|
if (isString())
|
||||||
{
|
{
|
||||||
StringData *xx = (StringData*)x;
|
StringData *xx = (StringData*)x;
|
||||||
uint32_t i = start;
|
uint32_t i = start;
|
||||||
@@ -443,8 +440,8 @@ namespace pxt {
|
|||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
uint32_t i = start;
|
uint32_t i = start;
|
||||||
while(head.isValidIndex(i))
|
while(head.isValidIndex(i))
|
||||||
@@ -460,11 +457,12 @@ namespace pxt {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int RefCollection::removeElement(uint32_t x)
|
int RefCollection::removeElement(uint32_t x)
|
||||||
{
|
{
|
||||||
int idx = indexOf(x, 0);
|
int idx = indexOf(x, 0);
|
||||||
if (idx >= 0) {
|
if (idx >= 0) {
|
||||||
removeAt(idx);
|
uint32_t elt = removeAt(idx);
|
||||||
|
if (isRef()) decr(elt);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
@@ -745,4 +743,4 @@ namespace pxt {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// vim: ts=2 sw=2 expandtab
|
// vim: ts=2 sw=2 expandtab
|
||||||
|
|||||||
@@ -160,6 +160,7 @@ namespace pxt {
|
|||||||
inline void unref()
|
inline void unref()
|
||||||
{
|
{
|
||||||
//printf("DECR "); this->print();
|
//printf("DECR "); this->print();
|
||||||
|
check(refcnt > 0, ERR_REF_DELETED);
|
||||||
refcnt -= 2;
|
refcnt -= 2;
|
||||||
if (refcnt == 0) {
|
if (refcnt == 0) {
|
||||||
destroy();
|
destroy();
|
||||||
|
|||||||
@@ -27,6 +27,7 @@
|
|||||||
"led.ts",
|
"led.ts",
|
||||||
"motors.cpp",
|
"motors.cpp",
|
||||||
"music.cpp",
|
"music.cpp",
|
||||||
|
"melodies.ts",
|
||||||
"music.ts",
|
"music.ts",
|
||||||
"pins.cpp",
|
"pins.cpp",
|
||||||
"pins.ts",
|
"pins.ts",
|
||||||
@@ -47,7 +48,18 @@
|
|||||||
"optionalConfig": {
|
"optionalConfig": {
|
||||||
"microbit-dal": {
|
"microbit-dal": {
|
||||||
"bluetooth": {
|
"bluetooth": {
|
||||||
"enabled": 0
|
"private_addressing": 0,
|
||||||
|
"advertising_timeout": 0,
|
||||||
|
"tx_power": 6,
|
||||||
|
"dfu_service": 1,
|
||||||
|
"event_service": 1,
|
||||||
|
"device_info_service": 1,
|
||||||
|
"eddystone_url": 1,
|
||||||
|
"eddystone_uid": 1,
|
||||||
|
"open": 0,
|
||||||
|
"pairing_mode": 1,
|
||||||
|
"whitelist": 1,
|
||||||
|
"security_level": "SECURITY_MODE_ENCRYPTION_NO_MITM"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
236
libs/core/shims.d.ts
vendored
@@ -56,7 +56,7 @@ declare interface Image {
|
|||||||
* @param frameOffset x offset moved on each animation step, eg: 1, 2, 5
|
* @param frameOffset x offset moved on each animation step, eg: 1, 2, 5
|
||||||
* @param interval time between each animation step in milli seconds, eg: 200
|
* @param interval time between each animation step in milli seconds, eg: 200
|
||||||
*/
|
*/
|
||||||
//% help=images/show-image weight=79 async blockNamespace=images
|
//% help=images/scroll-image weight=79 async blockNamespace=images
|
||||||
//% blockId=device_scroll_image block="scroll image %sprite|with offset %frameoffset|and interval (ms) %delay" blockGap=8
|
//% blockId=device_scroll_image block="scroll image %sprite|with offset %frameoffset|and interval (ms) %delay" blockGap=8
|
||||||
//% parts="ledmatrix" shim=ImageMethods::scrollImage
|
//% parts="ledmatrix" shim=ImageMethods::scrollImage
|
||||||
scrollImage(frameOffset: number, interval: number): void;
|
scrollImage(frameOffset: number, interval: number): void;
|
||||||
@@ -152,11 +152,11 @@ declare namespace basic {
|
|||||||
* @param leds the pattern of LED to turn on/off
|
* @param leds the pattern of LED to turn on/off
|
||||||
* @param interval time in milliseconds to pause after drawing
|
* @param interval time in milliseconds to pause after drawing
|
||||||
*/
|
*/
|
||||||
//% help=basic/show-leds
|
//% help=basic/show-leds
|
||||||
//% weight=95 blockGap=8
|
//% weight=95 blockGap=8
|
||||||
//% imageLiteral=1 async
|
//% imageLiteral=1 async
|
||||||
//% blockId=device_show_leds
|
//% blockId=device_show_leds
|
||||||
//% block="show leds"
|
//% block="show leds" icon="\uf00a"
|
||||||
//% parts="ledmatrix" interval.defl=400 shim=basic::showLeds
|
//% parts="ledmatrix" interval.defl=400 shim=basic::showLeds
|
||||||
function showLeds(leds: string, interval?: number): void;
|
function showLeds(leds: string, interval?: number): void;
|
||||||
|
|
||||||
@@ -165,9 +165,9 @@ declare namespace basic {
|
|||||||
* @param text the text to scroll on the screen, eg: "Hello!"
|
* @param text the text to scroll on the screen, eg: "Hello!"
|
||||||
* @param interval how fast to shift characters; eg: 150, 100, 200, -100
|
* @param interval how fast to shift characters; eg: 150, 100, 200, -100
|
||||||
*/
|
*/
|
||||||
//% help=basic/show-string
|
//% help=basic/show-string
|
||||||
//% weight=87 blockGap=8
|
//% weight=87 blockGap=8
|
||||||
//% block="show|string %text"
|
//% block="show|string %text"
|
||||||
//% async
|
//% async
|
||||||
//% blockId=device_print_message
|
//% blockId=device_print_message
|
||||||
//% parts="ledmatrix" interval.defl=150 shim=basic::showString
|
//% parts="ledmatrix" interval.defl=150 shim=basic::showString
|
||||||
@@ -178,7 +178,8 @@ declare namespace basic {
|
|||||||
*/
|
*/
|
||||||
//% help=basic/clear-screen weight=79
|
//% help=basic/clear-screen weight=79
|
||||||
//% blockId=device_clear_display block="clear screen"
|
//% blockId=device_clear_display block="clear screen"
|
||||||
//% parts="ledmatrix" shim=basic::clearScreen
|
//% parts="ledmatrix"
|
||||||
|
//% advanced=true shim=basic::clearScreen
|
||||||
function clearScreen(): void;
|
function clearScreen(): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -202,8 +203,8 @@ declare namespace basic {
|
|||||||
* Repeats the code forever in the background. On each iteration, allows other codes to run.
|
* Repeats the code forever in the background. On each iteration, allows other codes to run.
|
||||||
* @param body code to execute
|
* @param body code to execute
|
||||||
*/
|
*/
|
||||||
//% help=basic/forever weight=55 blockGap=8
|
//% help=basic/forever weight=55 blockGap=8 blockAllowMultiple=1 afterOnStart=true
|
||||||
//% blockId=device_forever block="forever" shim=basic::forever
|
//% blockId=device_forever block="forever" icon="\uf01e" shim=basic::forever
|
||||||
function forever(a: () => void): void;
|
function forever(a: () => void): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -212,19 +213,19 @@ declare namespace basic {
|
|||||||
*/
|
*/
|
||||||
//% help=basic/pause weight=54
|
//% help=basic/pause weight=54
|
||||||
//% async block="pause (ms) %pause"
|
//% async block="pause (ms) %pause"
|
||||||
//% blockId=device_pause shim=basic::pause
|
//% blockId=device_pause icon="\uf110" shim=basic::pause
|
||||||
function pause(ms: number): void;
|
function pause(ms: number): void;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//% color=#C90072 weight=99 icon="\uf192"
|
//% color=#B4009E weight=99 icon="\uf192"
|
||||||
declare namespace input {
|
declare namespace input {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Do something when a button (``A``, ``B`` or both ``A+B``) is pressed
|
* Do something when a button (A, B or both A+B) is pushed down and released again.
|
||||||
* @param button TODO
|
* @param button the button that needs to be pressed
|
||||||
* @param body TODO
|
* @param body code to run when event is raised
|
||||||
*/
|
*/
|
||||||
//% help=input/on-button-pressed weight=85 blockGap=8
|
//% help=input/on-button-pressed weight=85 blockGap=8
|
||||||
//% blockId=device_button_event block="on button|%NAME|pressed"
|
//% blockId=device_button_event block="on button|%NAME|pressed"
|
||||||
@@ -233,25 +234,27 @@ declare namespace input {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Do something when when a gesture is done (like shaking the micro:bit).
|
* Do something when when a gesture is done (like shaking the micro:bit).
|
||||||
* @param body TODO
|
* @param gesture the type of gesture to track, eg: Gesture.Shake
|
||||||
|
* @param body code to run when gesture is raised
|
||||||
*/
|
*/
|
||||||
//% help=input/on-gesture weight=84 blockGap=8
|
//% help=input/on-gesture weight=84 blockGap=8
|
||||||
//% blockId=device_gesture_event block="on |%NAME"
|
//% blockId=device_gesture_event block="on |%NAME"
|
||||||
//% parts="accelerometer" shim=input::onGesture
|
//% parts="accelerometer"
|
||||||
|
//% NAME.fieldEditor="gridpicker" NAME.fieldOptions.columns=4 shim=input::onGesture
|
||||||
function onGesture(gesture: Gesture, body: () => void): void;
|
function onGesture(gesture: Gesture, body: () => void): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Do something when a pin is pressed.
|
* Do something when a pin is touched and released again (while also touching the GND pin).
|
||||||
* @param name the pin that needs to be pressed
|
* @param name the pin that needs to be pressed, eg: TouchPin.P0
|
||||||
* @param body the code to run when the pin is pressed
|
* @param body the code to run when the pin is pressed
|
||||||
*/
|
*/
|
||||||
//% help=input/on-pin-pressed weight=83
|
//% help=input/on-pin-pressed weight=83
|
||||||
//% blockId=device_pin_event block="on pin %NAME|pressed" shim=input::onPinPressed
|
//% blockId=device_pin_event block="on pin %name|pressed" shim=input::onPinPressed
|
||||||
function onPinPressed(name: TouchPin, body: () => void): void;
|
function onPinPressed(name: TouchPin, body: () => void): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Do something when a pin is released.
|
* Do something when a pin is released.
|
||||||
* @param name the pin that needs to be released
|
* @param name the pin that needs to be released, eg: TouchPin.P0
|
||||||
* @param body the code to run when the pin is released
|
* @param body the code to run when the pin is released
|
||||||
*/
|
*/
|
||||||
//% help=input/on-pin-released weight=6 blockGap=8
|
//% help=input/on-pin-released weight=6 blockGap=8
|
||||||
@@ -261,6 +264,7 @@ declare namespace input {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the button state (pressed or not) for ``A`` and ``B``.
|
* Get the button state (pressed or not) for ``A`` and ``B``.
|
||||||
|
* @param button the button to query the request, eg: Button.A
|
||||||
*/
|
*/
|
||||||
//% help=input/button-is-pressed weight=60
|
//% help=input/button-is-pressed weight=60
|
||||||
//% block="button|%NAME|is pressed"
|
//% block="button|%NAME|is pressed"
|
||||||
@@ -271,7 +275,7 @@ declare namespace input {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the pin state (pressed or not). Requires to hold the ground to close the circuit.
|
* Get the pin state (pressed or not). Requires to hold the ground to close the circuit.
|
||||||
* @param name pin used to detect the touch
|
* @param name pin used to detect the touch, eg: TouchPin.P0
|
||||||
*/
|
*/
|
||||||
//% help=input/pin-is-pressed weight=58
|
//% help=input/pin-is-pressed weight=58
|
||||||
//% blockId="device_pin_is_pressed" block="pin %NAME|is pressed"
|
//% blockId="device_pin_is_pressed" block="pin %NAME|is pressed"
|
||||||
@@ -335,16 +339,25 @@ declare namespace input {
|
|||||||
/**
|
/**
|
||||||
* Gets the number of milliseconds elapsed since power on.
|
* Gets the number of milliseconds elapsed since power on.
|
||||||
*/
|
*/
|
||||||
//% help=input/running-time weight=50
|
//% help=input/running-time weight=50 blockGap=8
|
||||||
//% blockId=device_get_running_time block="running time (ms)"
|
//% blockId=device_get_running_time block="running time (ms)"
|
||||||
//% advanced=true shim=input::runningTime
|
//% advanced=true shim=input::runningTime
|
||||||
function runningTime(): number;
|
function runningTime(): number;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the number of microseconds elapsed since power on.
|
||||||
|
*/
|
||||||
|
//% help=input/running-time-micros weight=49
|
||||||
|
//% blockId=device_get_running_time_micros block="running time (micros)"
|
||||||
|
//% advanced=true shim=input::runningTimeMicros
|
||||||
|
function runningTimeMicros(): number;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Obsolete, compass calibration is automatic.
|
* Obsolete, compass calibration is automatic.
|
||||||
*/
|
*/
|
||||||
//% help=input/calibrate weight=0 shim=input::calibrate
|
//% help=input/calibrate-compass advanced=true
|
||||||
function calibrate(): void;
|
//% blockId="input_compass_calibrate" block="calibrate compass" shim=input::calibrateCompass
|
||||||
|
function calibrateCompass(): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the accelerometer sample range in gravities.
|
* Sets the accelerometer sample range in gravities.
|
||||||
@@ -367,7 +380,7 @@ declare namespace control {
|
|||||||
/**
|
/**
|
||||||
* Schedules code that run in the background.
|
* Schedules code that run in the background.
|
||||||
*/
|
*/
|
||||||
//% help=control/in-background
|
//% help=control/in-background blockAllowMultiple=1 afterOnStart=true
|
||||||
//% blockId="control_in_background" block="run in background" blockGap=8 shim=control::inBackground
|
//% blockId="control_in_background" block="run in background" blockGap=8 shim=control::inBackground
|
||||||
function inBackground(a: () => void): void;
|
function inBackground(a: () => void): void;
|
||||||
|
|
||||||
@@ -393,6 +406,7 @@ declare namespace control {
|
|||||||
* @param mode optional definition of how the event should be processed after construction (default is CREATE_AND_FIRE).
|
* @param mode optional definition of how the event should be processed after construction (default is CREATE_AND_FIRE).
|
||||||
*/
|
*/
|
||||||
//% weight=21 blockGap=12 blockId="control_raise_event" block="raise event|from source %src=control_event_source_id|with value %value=control_event_value_id" blockExternalInputs=1
|
//% weight=21 blockGap=12 blockId="control_raise_event" block="raise event|from source %src=control_event_source_id|with value %value=control_event_value_id" blockExternalInputs=1
|
||||||
|
//% help=control/raise-event
|
||||||
//% mode.defl=1 shim=control::raiseEvent
|
//% mode.defl=1 shim=control::raiseEvent
|
||||||
function raiseEvent(src: number, value: number, mode?: EventCreationMode): void;
|
function raiseEvent(src: number, value: number, mode?: EventCreationMode): void;
|
||||||
|
|
||||||
@@ -400,6 +414,7 @@ declare namespace control {
|
|||||||
* Raises an event in the event bus.
|
* Raises an event in the event bus.
|
||||||
*/
|
*/
|
||||||
//% weight=20 blockGap=8 blockId="control_on_event" block="on event|from %src=control_event_source_id|with value %value=control_event_value_id"
|
//% weight=20 blockGap=8 blockId="control_on_event" block="on event|from %src=control_event_source_id|with value %value=control_event_value_id"
|
||||||
|
//% help=control/on-event
|
||||||
//% blockExternalInputs=1 shim=control::onEvent
|
//% blockExternalInputs=1 shim=control::onEvent
|
||||||
function onEvent(src: number, value: number, handler: () => void): void;
|
function onEvent(src: number, value: number, handler: () => void): void;
|
||||||
|
|
||||||
@@ -407,6 +422,7 @@ declare namespace control {
|
|||||||
* Gets the value of the last event executed on the bus
|
* Gets the value of the last event executed on the bus
|
||||||
*/
|
*/
|
||||||
//% blockId=control_event_value" block="event value"
|
//% blockId=control_event_value" block="event value"
|
||||||
|
//% help=control/event-value
|
||||||
//% weight=18 shim=control::eventValue
|
//% weight=18 shim=control::eventValue
|
||||||
function eventValue(): number;
|
function eventValue(): number;
|
||||||
|
|
||||||
@@ -414,19 +430,22 @@ declare namespace control {
|
|||||||
* Gets the timestamp of the last event executed on the bus
|
* Gets the timestamp of the last event executed on the bus
|
||||||
*/
|
*/
|
||||||
//% blockId=control_event_timestamp" block="event timestamp"
|
//% blockId=control_event_timestamp" block="event timestamp"
|
||||||
|
//% help=control/event-timestamp
|
||||||
//% weight=19 blockGap=8 shim=control::eventTimestamp
|
//% weight=19 blockGap=8 shim=control::eventTimestamp
|
||||||
function eventTimestamp(): number;
|
function eventTimestamp(): number;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a friendly name for the device derived from the its serial number
|
* Gets a friendly name for the device derived from the its serial number
|
||||||
*/
|
*/
|
||||||
//% blockId="control_device_name" block="device name" weight=10 blockGap=8 shim=control::deviceName
|
//% blockId="control_device_name" block="device name" weight=10 blockGap=8
|
||||||
|
//% advanced=true shim=control::deviceName
|
||||||
function deviceName(): string;
|
function deviceName(): string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Derive a unique, consistent serial number of this device from internal data.
|
* Derive a unique, consistent serial number of this device from internal data.
|
||||||
*/
|
*/
|
||||||
//% blockId="control_device_serial_number" block="device serial number" weight=9 shim=control::deviceSerialNumber
|
//% blockId="control_device_serial_number" block="device serial number" weight=9
|
||||||
|
//% advanced=true shim=control::deviceSerialNumber
|
||||||
function deviceSerialNumber(): number;
|
function deviceSerialNumber(): number;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -437,14 +456,28 @@ declare namespace led {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Turn on the specified LED using x, y coordinates (x is horizontal, y is vertical). (0,0) is upper left.
|
* Turn on the specified LED using x, y coordinates (x is horizontal, y is vertical). (0,0) is upper left.
|
||||||
* @param x TODO
|
* @param x the horizontal coordinate of the LED starting at 0
|
||||||
* @param y TODO
|
* @param y the vertical coordinate of the LED starting at 0
|
||||||
*/
|
*/
|
||||||
//% help=led/plot weight=78
|
//% help=led/plot weight=78
|
||||||
//% blockId=device_plot block="plot|x %x|y %y" blockGap=8
|
//% blockId=device_plot block="plot|x %x|y %y" blockGap=8
|
||||||
//% parts="ledmatrix" shim=led::plot
|
//% parts="ledmatrix"
|
||||||
|
//% x.min=0 x.max=4 y.min=0 y.max=4 shim=led::plot
|
||||||
function plot(x: number, y: number): void;
|
function plot(x: number, y: number): void;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Turn on the specified LED with specific brightness using x, y coordinates (x is horizontal, y is vertical). (0,0) is upper left.
|
||||||
|
* @param x the horizontal coordinate of the LED starting at 0
|
||||||
|
* @param y the vertical coordinate of the LED starting at 0
|
||||||
|
* @param brightness the brightness from 0 (off) to 255 (bright), eg:255
|
||||||
|
*/
|
||||||
|
//% help=led/plot-brightness weight=78
|
||||||
|
//% blockId=device_plot_brightness block="plot|x %x|y %y|brightness %brightness" blockGap=8
|
||||||
|
//% parts="ledmatrix"
|
||||||
|
//% x.min=0 x.max=4 y.min=0 y.max=4 brightness.min=0 brightness.max=255
|
||||||
|
//% advanced=true shim=led::plotBrightness
|
||||||
|
function plotBrightness(x: number, y: number, brightness: number): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Turn off the specified LED using x, y coordinates (x is horizontal, y is vertical). (0,0) is upper left.
|
* Turn off the specified LED using x, y coordinates (x is horizontal, y is vertical). (0,0) is upper left.
|
||||||
* @param x TODO
|
* @param x TODO
|
||||||
@@ -452,7 +485,8 @@ declare namespace led {
|
|||||||
*/
|
*/
|
||||||
//% help=led/unplot weight=77
|
//% help=led/unplot weight=77
|
||||||
//% blockId=device_unplot block="unplot|x %x|y %y" blockGap=8
|
//% blockId=device_unplot block="unplot|x %x|y %y" blockGap=8
|
||||||
//% parts="ledmatrix" shim=led::unplot
|
//% parts="ledmatrix"
|
||||||
|
//% x.min=0 x.max=4 y.min=0 y.max=4 shim=led::unplot
|
||||||
function unplot(x: number, y: number): void;
|
function unplot(x: number, y: number): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -462,7 +496,8 @@ declare namespace led {
|
|||||||
*/
|
*/
|
||||||
//% help=led/point weight=76
|
//% help=led/point weight=76
|
||||||
//% blockId=device_point block="point|x %x|y %y"
|
//% blockId=device_point block="point|x %x|y %y"
|
||||||
//% parts="ledmatrix" shim=led::point
|
//% parts="ledmatrix"
|
||||||
|
//% x.min=0 x.max=4 y.min=0 y.max=4 shim=led::point
|
||||||
function point(x: number, y: number): boolean;
|
function point(x: number, y: number): boolean;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -481,7 +516,8 @@ declare namespace led {
|
|||||||
//% help=led/set-brightness weight=59
|
//% help=led/set-brightness weight=59
|
||||||
//% blockId=device_set_brightness block="set brightness %value"
|
//% blockId=device_set_brightness block="set brightness %value"
|
||||||
//% parts="ledmatrix"
|
//% parts="ledmatrix"
|
||||||
//% advanced=true shim=led::setBrightness
|
//% advanced=true
|
||||||
|
//% value.min=0 value.max=255 shim=led::setBrightness
|
||||||
function setBrightness(value: number): void;
|
function setBrightness(value: number): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -501,10 +537,16 @@ declare namespace led {
|
|||||||
//% parts="ledmatrix" advanced=true shim=led::setDisplayMode
|
//% parts="ledmatrix" advanced=true shim=led::setDisplayMode
|
||||||
function setDisplayMode(mode: DisplayMode): void;
|
function setDisplayMode(mode: DisplayMode): void;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the current display mode
|
||||||
|
*/
|
||||||
|
//% weight=1 parts="ledmatrix" advanced=true shim=led::displayMode
|
||||||
|
function displayMode(): DisplayMode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Turns on or off the display
|
* Turns on or off the display
|
||||||
*/
|
*/
|
||||||
//% help=led/enable blockId=device_led_enable
|
//% help=led/enable blockId=device_led_enable block="led enable %on"
|
||||||
//% advanced=true parts="ledmatrix" shim=led::enable
|
//% advanced=true parts="ledmatrix" shim=led::enable
|
||||||
function enable(on: boolean): void;
|
function enable(on: boolean): void;
|
||||||
|
|
||||||
@@ -552,90 +594,111 @@ declare namespace music {
|
|||||||
* @param frequency pitch of the tone to play in Hertz (Hz)
|
* @param frequency pitch of the tone to play in Hertz (Hz)
|
||||||
* @param ms tone duration in milliseconds (ms)
|
* @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
|
//% parts="speaker" async useEnumVal=1 shim=music::speakerPlayTone
|
||||||
//% parts="speaker" async useEnumVal=1 shim=music::playTone
|
function speakerPlayTone(frequency: number, ms: number): void;
|
||||||
function playTone(frequency: number, ms: number): void;
|
|
||||||
}
|
}
|
||||||
declare namespace pins {
|
declare namespace pins {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Read the specified pin or connector as either 0 or 1
|
* Read the specified pin or connector as either 0 or 1
|
||||||
* @param name pin to read from
|
* @param name pin to read from, eg: DigitalPin.P0
|
||||||
*/
|
*/
|
||||||
//% help=pins/digital-read-pin weight=30
|
//% help=pins/digital-read-pin weight=30
|
||||||
//% blockId=device_get_digital_pin block="digital read|pin %name" blockGap=8 shim=pins::digitalReadPin
|
//% blockId=device_get_digital_pin block="digital read|pin %name" blockGap=8
|
||||||
|
//% name.fieldEditor="gridpicker" name.fieldOptions.columns=4
|
||||||
|
//% name.fieldOptions.tooltips="false" name.fieldOptions.width="300" shim=pins::digitalReadPin
|
||||||
function digitalReadPin(name: DigitalPin): number;
|
function digitalReadPin(name: DigitalPin): number;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set a pin or connector value to either 0 or 1.
|
* Set a pin or connector value to either 0 or 1.
|
||||||
* @param name pin to write to
|
* @param name pin to write to, eg: DigitalPin.P0
|
||||||
* @param value value to set on the pin, 1 eg,0
|
* @param value value to set on the pin, 1 eg,0
|
||||||
*/
|
*/
|
||||||
//% help=pins/digital-write-pin weight=29
|
//% help=pins/digital-write-pin weight=29
|
||||||
//% blockId=device_set_digital_pin block="digital write|pin %name|to %value" shim=pins::digitalWritePin
|
//% blockId=device_set_digital_pin block="digital write|pin %name|to %value"
|
||||||
|
//% value.min=0 value.max=1
|
||||||
|
//% name.fieldEditor="gridpicker" name.fieldOptions.columns=4
|
||||||
|
//% name.fieldOptions.tooltips="false" name.fieldOptions.width="300" shim=pins::digitalWritePin
|
||||||
function digitalWritePin(name: DigitalPin, value: number): void;
|
function digitalWritePin(name: DigitalPin, value: number): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Read the connector value as analog, that is, as a value comprised between 0 and 1023.
|
* Read the connector value as analog, that is, as a value comprised between 0 and 1023.
|
||||||
* @param name pin to write to
|
* @param name pin to write to, eg: AnalogPin.P0
|
||||||
*/
|
*/
|
||||||
//% help=pins/analog-read-pin weight=25
|
//% help=pins/analog-read-pin weight=25
|
||||||
//% blockId=device_get_analog_pin block="analog read|pin %name" blockGap="8" shim=pins::analogReadPin
|
//% blockId=device_get_analog_pin block="analog read|pin %name" blockGap="8"
|
||||||
|
//% name.fieldEditor="gridpicker" name.fieldOptions.columns=4
|
||||||
|
//% name.fieldOptions.tooltips="false" shim=pins::analogReadPin
|
||||||
function analogReadPin(name: AnalogPin): number;
|
function analogReadPin(name: AnalogPin): number;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the connector value as analog. Value must be comprised between 0 and 1023.
|
* Set the connector value as analog. Value must be comprised between 0 and 1023.
|
||||||
* @param name pin name to write to
|
* @param name pin name to write to, eg: AnalogPin.P0
|
||||||
* @param value value to write to the pin between ``0`` and ``1023``. eg:1023,0
|
* @param value value to write to the pin between ``0`` and ``1023``. eg:1023,0
|
||||||
*/
|
*/
|
||||||
//% help=pins/analog-write-pin weight=24
|
//% help=pins/analog-write-pin weight=24
|
||||||
//% blockId=device_set_analog_pin block="analog write|pin %name|to %value" blockGap=8 shim=pins::analogWritePin
|
//% blockId=device_set_analog_pin block="analog write|pin %name|to %value" blockGap=8
|
||||||
|
//% value.min=0 value.max=1023
|
||||||
|
//% name.fieldEditor="gridpicker" name.fieldOptions.columns=4
|
||||||
|
//% name.fieldOptions.tooltips="false" shim=pins::analogWritePin
|
||||||
function analogWritePin(name: AnalogPin, value: number): void;
|
function analogWritePin(name: AnalogPin, value: number): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Configures the Pulse-width modulation (PWM) of the analog output to the given value in **microseconds** or `1/1000` milliseconds.
|
* Configures the Pulse-width modulation (PWM) of the analog output to the given value in **microseconds** or `1/1000` milliseconds.
|
||||||
* If this pin is not configured as an analog output (using `analog write pin`), the operation has no effect.
|
* If this pin is not configured as an analog output (using `analog write pin`), the operation has no effect.
|
||||||
* @param name analog pin to set period to
|
* @param name analog pin to set period to, eg: AnalogPin.P0
|
||||||
* @param micros period in micro seconds. eg:20000
|
* @param micros period in micro seconds. eg:20000
|
||||||
*/
|
*/
|
||||||
//% help=pins/analog-set-period weight=23 blockGap=8
|
//% help=pins/analog-set-period weight=23 blockGap=8
|
||||||
//% blockId=device_set_analog_period block="analog set period|pin %pin|to (µs)%micros" shim=pins::analogSetPeriod
|
//% blockId=device_set_analog_period block="analog set period|pin %pin|to (µs)%micros"
|
||||||
|
//% pin.fieldEditor="gridpicker" pin.fieldOptions.columns=4
|
||||||
|
//% pin.fieldOptions.tooltips="false" shim=pins::analogSetPeriod
|
||||||
function analogSetPeriod(name: AnalogPin, micros: number): void;
|
function analogSetPeriod(name: AnalogPin, micros: number): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Configures this pin to a digital input, and generates events where the timestamp is the duration that this pin was either ``high`` or ``low``.
|
* Configures this pin to a digital input, and generates events where the timestamp is the duration that this pin was either ``high`` or ``low``.
|
||||||
|
* @param name digital pin to register to, eg: DigitalPin.P0
|
||||||
|
* @param pulse the value of the pulse, eg: PulseValue.High
|
||||||
*/
|
*/
|
||||||
//% help=pins/on-pulsed weight=22 blockGap=8
|
//% help=pins/on-pulsed weight=22 blockGap=8 advanced=true
|
||||||
//% blockId=pins_on_pulsed block="on|pin %pin|pulsed %pulse" shim=pins::onPulsed
|
//% blockId=pins_on_pulsed block="on|pin %pin|pulsed %pulse"
|
||||||
|
//% pin.fieldEditor="gridpicker" pin.fieldOptions.columns=4
|
||||||
|
//% pin.fieldOptions.tooltips="false" pin.fieldOptions.width="300" shim=pins::onPulsed
|
||||||
function onPulsed(name: DigitalPin, pulse: PulseValue, body: () => void): void;
|
function onPulsed(name: DigitalPin, pulse: PulseValue, body: () => void): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the duration of the last pulse in micro-seconds. This function should be called from a ``onPulsed`` handler.
|
* Gets the duration of the last pulse in micro-seconds. This function should be called from a ``onPulsed`` handler.
|
||||||
*/
|
*/
|
||||||
//% help=pins/pulse-duration
|
//% help=pins/pulse-duration advanced=true
|
||||||
//% blockId=pins_pulse_duration block="pulse duration (µs)"
|
//% blockId=pins_pulse_duration block="pulse duration (µs)"
|
||||||
//% weight=21 blockGap=8 shim=pins::pulseDuration
|
//% weight=21 blockGap=8 shim=pins::pulseDuration
|
||||||
function pulseDuration(): number;
|
function pulseDuration(): number;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the duration of a pulse in microseconds
|
* Returns the duration of a pulse in microseconds
|
||||||
* @param name the pin which measures the pulse
|
* @param name the pin which measures the pulse, eg: DigitalPin.P0
|
||||||
* @param value the value of the pulse (default high)
|
* @param value the value of the pulse, eg: PulseValue.High
|
||||||
* @param maximum duration in micro-seconds
|
* @param maximum duration in micro-seconds
|
||||||
*/
|
*/
|
||||||
//% blockId="pins_pulse_in" block="pulse in (µs)|pin %name|pulsed %value"
|
//% blockId="pins_pulse_in" block="pulse in (µs)|pin %name|pulsed %value"
|
||||||
//% weight=20 maxDuration.defl=2000000 shim=pins::pulseIn
|
//% weight=20 advanced=true
|
||||||
|
//% help=pins/pulse-in
|
||||||
|
//% name.fieldEditor="gridpicker" name.fieldOptions.columns=4
|
||||||
|
//% name.fieldOptions.tooltips="false" name.fieldOptions.width="300" maxDuration.defl=2000000 shim=pins::pulseIn
|
||||||
function pulseIn(name: DigitalPin, value: PulseValue, maxDuration?: number): number;
|
function pulseIn(name: DigitalPin, value: PulseValue, maxDuration?: number): number;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Writes a value to the servo, controlling the shaft accordingly. On a standard servo, this will set the angle of the shaft (in degrees), moving the shaft to that orientation. On a continuous rotation servo, this will set the speed of the servo (with ``0`` being full-speed in one direction, ``180`` being full speed in the other, and a value near ``90`` being no movement).
|
* Writes a value to the servo, controlling the shaft accordingly. On a standard servo, this will set the angle of the shaft (in degrees), moving the shaft to that orientation. On a continuous rotation servo, this will set the speed of the servo (with ``0`` being full-speed in one direction, ``180`` being full speed in the other, and a value near ``90`` being no movement).
|
||||||
* @param name pin to write to
|
* @param name pin to write to, eg: AnalogPin.P0
|
||||||
* @param value angle or rotation speed, eg:180,90,0
|
* @param value angle or rotation speed, eg:180,90,0
|
||||||
*/
|
*/
|
||||||
//% help=pins/servo-write-pin weight=20
|
//% help=pins/servo-write-pin weight=20
|
||||||
//% blockId=device_set_servo_pin block="servo write|pin %name|to %value" blockGap=8
|
//% blockId=device_set_servo_pin block="servo write|pin %name|to %value" blockGap=8
|
||||||
//% parts=microservo trackArgs=0 shim=pins::servoWritePin
|
//% parts=microservo trackArgs=0
|
||||||
|
//% value.min=0 value.max=180
|
||||||
|
//% name.fieldEditor="gridpicker" name.fieldOptions.columns=4
|
||||||
|
//% name.fieldOptions.tooltips="false" shim=pins::servoWritePin
|
||||||
function servoWritePin(name: AnalogPin, value: number): void;
|
function servoWritePin(name: AnalogPin, value: number): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -644,21 +707,25 @@ declare namespace pins {
|
|||||||
* @param micros pulse duration in micro seconds, eg:1500
|
* @param micros pulse duration in micro seconds, eg:1500
|
||||||
*/
|
*/
|
||||||
//% help=pins/servo-set-pulse weight=19
|
//% help=pins/servo-set-pulse weight=19
|
||||||
//% blockId=device_set_servo_pulse block="servo set pulse|pin %value|to (µs) %micros" shim=pins::servoSetPulse
|
//% blockId=device_set_servo_pulse block="servo set pulse|pin %value|to (µs) %micros"
|
||||||
|
//% value.fieldEditor="gridpicker" value.fieldOptions.columns=4
|
||||||
|
//% value.fieldOptions.tooltips="false" shim=pins::servoSetPulse
|
||||||
function servoSetPulse(name: AnalogPin, micros: number): void;
|
function servoSetPulse(name: AnalogPin, micros: number): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the pin used when using `pins->analog pitch`.
|
* Sets the pin used when using `analog pitch` or music.
|
||||||
* @param name TODO
|
* @param name pin to modulate pitch from
|
||||||
*/
|
*/
|
||||||
//% blockId=device_analog_set_pitch_pin block="analog set pitch pin %name"
|
//% blockId=device_analog_set_pitch_pin block="analog set pitch pin %name"
|
||||||
//% help=pins/analog-set-pitch weight=3 advanced=true shim=pins::analogSetPitchPin
|
//% help=pins/analog-set-pitch-pin weight=3 advanced=true
|
||||||
|
//% name.fieldEditor="gridpicker" name.fieldOptions.columns=4
|
||||||
|
//% name.fieldOptions.tooltips="false" shim=pins::analogSetPitchPin
|
||||||
function analogSetPitchPin(name: AnalogPin): void;
|
function analogSetPitchPin(name: AnalogPin): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Emits a Pulse-width modulation (PWM) signal to the current pitch pin. Use `analog set pitch pin` to define the pitch pin.
|
* Emits a Pulse-width modulation (PWM) signal to the current pitch pin. Use `analog set pitch pin` to define the pitch pin.
|
||||||
* @param frequency TODO
|
* @param frequency frequency to modulate in Hz.
|
||||||
* @param ms TODO
|
* @param ms duration of the pitch in milli seconds.
|
||||||
*/
|
*/
|
||||||
//% blockId=device_analog_pitch block="analog pitch %frequency|for (ms) %ms"
|
//% blockId=device_analog_pitch block="analog pitch %frequency|for (ms) %ms"
|
||||||
//% help=pins/analog-pitch weight=4 async advanced=true blockGap=8 shim=pins::analogPitch
|
//% help=pins/analog-pitch weight=4 async advanced=true blockGap=8 shim=pins::analogPitch
|
||||||
@@ -666,11 +733,13 @@ declare namespace pins {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Configures the pull of this pin.
|
* Configures the pull of this pin.
|
||||||
* @param name pin to set the pull mode on
|
* @param name pin to set the pull mode on, eg: DigitalPin.P0
|
||||||
* @param pull one of the mbed pull configurations: PullUp, PullDown, PullNone
|
* @param pull one of the mbed pull configurations, eg: PinPullMode.PullUp
|
||||||
*/
|
*/
|
||||||
//% help=pins/set-pull weight=3
|
//% help=pins/set-pull weight=3 advanced=true
|
||||||
//% blockId=device_set_pull block="set pull|pin %pin|to %pull" shim=pins::setPull
|
//% blockId=device_set_pull block="set pull|pin %pin|to %pull"
|
||||||
|
//% pin.fieldEditor="gridpicker" pin.fieldOptions.columns=4
|
||||||
|
//% pin.fieldOptions.tooltips="false" pin.fieldOptions.width="300" shim=pins::setPull
|
||||||
function setPull(name: DigitalPin, pull: PinPullMode): void;
|
function setPull(name: DigitalPin, pull: PinPullMode): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -680,7 +749,9 @@ declare namespace pins {
|
|||||||
* @param type the type of events for this pin to emit, eg: PinEventType.Edge
|
* @param type the type of events for this pin to emit, eg: PinEventType.Edge
|
||||||
*/
|
*/
|
||||||
//% help=pins/set-events weight=4 advanced=true
|
//% help=pins/set-events weight=4 advanced=true
|
||||||
//% blockId=device_set_pin_events block="set pin %pin|to emit %type|events" shim=pins::setEvents
|
//% blockId=device_set_pin_events block="set pin %pin|to emit %type|events"
|
||||||
|
//% pin.fieldEditor="gridpicker" pin.fieldOptions.columns=4
|
||||||
|
//% pin.fieldOptions.tooltips="false" pin.fieldOptions.width="300" shim=pins::setEvents
|
||||||
function setEvents(name: DigitalPin, type: PinEventType): void;
|
function setEvents(name: DigitalPin, type: PinEventType): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -706,9 +777,40 @@ declare namespace pins {
|
|||||||
* Write to the SPI slave and return the response
|
* Write to the SPI slave and return the response
|
||||||
* @param value Data to be sent to the SPI slave
|
* @param value Data to be sent to the SPI slave
|
||||||
*/
|
*/
|
||||||
//% help=pins/spi-write weight=5
|
//% help=pins/spi-write weight=5 advanced=true
|
||||||
//% blockId=spi_write block="spi write %value" shim=pins::spiWrite
|
//% blockId=spi_write block="spi write %value" shim=pins::spiWrite
|
||||||
function spiWrite(value: number): number;
|
function spiWrite(value: number): number;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the SPI frequency
|
||||||
|
* @param frequency the clock frequency, eg: 1000000
|
||||||
|
*/
|
||||||
|
//% help=pins/spi-frequency weight=4 advanced=true
|
||||||
|
//% blockId=spi_frequency block="spi frequency %frequency" shim=pins::spiFrequency
|
||||||
|
function spiFrequency(frequency: number): void;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the SPI bits and mode
|
||||||
|
* @param bits the number of bits, eg: 8
|
||||||
|
* @param mode the mode, eg: 3
|
||||||
|
*/
|
||||||
|
//% help=pins/spi-format weight=3 advanced=true
|
||||||
|
//% blockId=spi_format block="spi format|bits %bits|mode %mode" shim=pins::spiFormat
|
||||||
|
function spiFormat(bits: number, mode: number): void;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the MOSI, MISO, SCK pins used by the SPI instance
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
//% help=pins/spi-pins weight=2 advanced=true
|
||||||
|
//% blockId=spi_pins block="spi set pins|MOSI %mosi|MISO %miso|SCK %sck"
|
||||||
|
//% mosi.fieldEditor="gridpicker" mosi.fieldOptions.columns=4
|
||||||
|
//% mosi.fieldOptions.tooltips="false" mosi.fieldOptions.width="300"
|
||||||
|
//% miso.fieldEditor="gridpicker" miso.fieldOptions.columns=4
|
||||||
|
//% miso.fieldOptions.tooltips="false" miso.fieldOptions.width="300"
|
||||||
|
//% sck.fieldEditor="gridpicker" sck.fieldOptions.columns=4
|
||||||
|
//% sck.fieldOptions.tooltips="false" sck.fieldOptions.width="300" shim=pins::spiPins
|
||||||
|
function spiPins(mosi: DigitalPin, miso: DigitalPin, sck: DigitalPin): void;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
10
libs/devices/enums.d.ts
vendored
@@ -1,7 +1,7 @@
|
|||||||
// Auto-generated. Do not edit.
|
// Auto-generated. Do not edit.
|
||||||
|
|
||||||
|
|
||||||
declare enum MesCameraEvent {
|
declare const enum MesCameraEvent {
|
||||||
//% block="take photo"
|
//% block="take photo"
|
||||||
TakePhoto = 3, // MES_CAMERA_EVT_TAKE_PHOTO
|
TakePhoto = 3, // MES_CAMERA_EVT_TAKE_PHOTO
|
||||||
//% block="start video capture"
|
//% block="start video capture"
|
||||||
@@ -21,7 +21,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
declare enum MesAlertEvent {
|
declare const enum MesAlertEvent {
|
||||||
//% block="display toast"
|
//% block="display toast"
|
||||||
DisplayToast = 1, // MES_ALERT_EVT_DISPLAY_TOAST
|
DisplayToast = 1, // MES_ALERT_EVT_DISPLAY_TOAST
|
||||||
//% block="vibrate"
|
//% block="vibrate"
|
||||||
@@ -47,7 +47,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
declare enum MesDeviceInfo {
|
declare const enum MesDeviceInfo {
|
||||||
//% block="incoming call"
|
//% block="incoming call"
|
||||||
IncomingCall = 7, // MES_DEVICE_INCOMING_CALL
|
IncomingCall = 7, // MES_DEVICE_INCOMING_CALL
|
||||||
//% block="incoming message"
|
//% block="incoming message"
|
||||||
@@ -65,7 +65,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
declare enum MesRemoteControlEvent {
|
declare const enum MesRemoteControlEvent {
|
||||||
//% block="play"
|
//% block="play"
|
||||||
play = 1, // MES_REMOTE_CONTROL_EVT_PLAY
|
play = 1, // MES_REMOTE_CONTROL_EVT_PLAY
|
||||||
//% block="pause"
|
//% block="pause"
|
||||||
@@ -87,7 +87,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
declare enum MesDpadButtonInfo {
|
declare const enum MesDpadButtonInfo {
|
||||||
//% block="A down"
|
//% block="A down"
|
||||||
ADown = 1, // MES_DPAD_BUTTON_A_DOWN
|
ADown = 1, // MES_DPAD_BUTTON_A_DOWN
|
||||||
//% block="A up"
|
//% block="A up"
|
||||||
|
|||||||
@@ -1,5 +1,10 @@
|
|||||||
{
|
{
|
||||||
"radio": "Communicate data using radio packets",
|
"radio": "Communicate data using radio packets",
|
||||||
|
"radio.Packet.receivedNumber": "The number payload if a number was sent in this packet (via ``sendNumber()`` or ``sendValue()``)\nor 0 if this packet did not contain a number.",
|
||||||
|
"radio.Packet.receivedString": "The string payload if a string was sent in this packet (via ``sendString()`` or ``sendValue()``)\nor the empty string if this packet did not contain a string.",
|
||||||
|
"radio.Packet.serial": "The serial number of the sender of the packet or 0 if the sender did not sent their serial number.",
|
||||||
|
"radio.Packet.signal": "The received signal strength indicator (RSSI) of the packet.",
|
||||||
|
"radio.Packet.time": "The system time of the sender of the packet at the time the packet was sent.",
|
||||||
"radio.onDataPacketReceived": "Registers code to run when the radio receives a packet. Also takes the\nreceived packet from the radio queue.",
|
"radio.onDataPacketReceived": "Registers code to run when the radio receives a packet. Also takes the\nreceived packet from the radio queue.",
|
||||||
"radio.onDataReceived": "Registers code to run when a packet is received over radio.",
|
"radio.onDataReceived": "Registers code to run when a packet is received over radio.",
|
||||||
"radio.receiveNumber": "Reads the next packet from the radio queue and returns the packet's number\npayload or 0 if the packet did not contain a number.",
|
"radio.receiveNumber": "Reads the next packet from the radio queue and returns the packet's number\npayload or 0 if the packet did not contain a number.",
|
||||||
|
|||||||
3493
package-lock.json
generated
Normal file
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "pxt-calliope",
|
"name": "pxt-calliope",
|
||||||
"version": "1.0.8",
|
"version": "1.0.20",
|
||||||
"description": "Calliope Mini editor for PXT",
|
"description": "Calliope Mini editor for PXT",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"JavaScript",
|
"JavaScript",
|
||||||
@@ -31,10 +31,12 @@
|
|||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"typescript": "^1.8.7",
|
"typescript": "^1.8.7",
|
||||||
"less": "^2.6.0",
|
"less": "^2.6.0",
|
||||||
|
"rtlcss": "^2.1.2",
|
||||||
|
"autoprefixer": "^6.7.6",
|
||||||
"semantic-ui-less": "^2.2.4"
|
"semantic-ui-less": "^2.2.4"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"pxt-core": "0.11.55"
|
"pxt-core": "0.17.4"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "node node_modules/pxt-core/built/pxt.js travis"
|
"test": "node node_modules/pxt-core/built/pxt.js travis"
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
{
|
{
|
||||||
"id": "calliope",
|
"id": "calliopemini",
|
||||||
"name": " calliope",
|
"name": " calliope mini",
|
||||||
"nickname": "mini",
|
"nickname": "mini",
|
||||||
"title": "calliope mini - Blocks / Javascript editor",
|
"title": "Calliope mini - Blocks / Javascript editor",
|
||||||
"description": "A Blocks / JavaScript code editor for the calliope mini.",
|
"description": "A Blocks / JavaScript code editor for the calliope mini.",
|
||||||
"corepkg": "core",
|
"corepkg": "core",
|
||||||
"bundleddirs": [
|
"bundleddirs": [
|
||||||
@@ -15,9 +15,7 @@
|
|||||||
"workspace": false,
|
"workspace": false,
|
||||||
"packages": true,
|
"packages": true,
|
||||||
"sharing": true,
|
"sharing": true,
|
||||||
"publishing": true,
|
"publishing": false,
|
||||||
"preferredPackages": [
|
|
||||||
],
|
|
||||||
"githubPackages": true
|
"githubPackages": true
|
||||||
},
|
},
|
||||||
"compile": {
|
"compile": {
|
||||||
@@ -26,6 +24,10 @@
|
|||||||
"deployDrives": "MINI",
|
"deployDrives": "MINI",
|
||||||
"driveName": "MINI",
|
"driveName": "MINI",
|
||||||
"hexMimeType": "application/x-calliope-hex",
|
"hexMimeType": "application/x-calliope-hex",
|
||||||
|
"openocdScript": "source [find interface/cmsis-dap.cfg]; source [find target/nrf51.cfg]",
|
||||||
|
"flashUsableEnd": 245760,
|
||||||
|
"flashEnd": 245760,
|
||||||
|
"flashCodeAlign": 1024,
|
||||||
"upgrades": [
|
"upgrades": [
|
||||||
{
|
{
|
||||||
"type": "package",
|
"type": "package",
|
||||||
@@ -56,11 +58,15 @@
|
|||||||
"logicBlocks": true,
|
"logicBlocks": true,
|
||||||
"variablesBlocks": true,
|
"variablesBlocks": true,
|
||||||
"textBlocks": true,
|
"textBlocks": true,
|
||||||
|
"listsBlocks": true,
|
||||||
|
"functionBlocks": true,
|
||||||
"onStartColor": "#54C9C9",
|
"onStartColor": "#54C9C9",
|
||||||
"onStartNamespace": "basic"
|
"onStartNamespace": "basic",
|
||||||
|
"onStartWeight": 54
|
||||||
},
|
},
|
||||||
"simulator": {
|
"simulator": {
|
||||||
"autoRun": true,
|
"autoRun": true,
|
||||||
|
"enableTrace": true,
|
||||||
"streams": true,
|
"streams": true,
|
||||||
"aspectRatio": 1.13,
|
"aspectRatio": 1.13,
|
||||||
"parts": false,
|
"parts": false,
|
||||||
@@ -171,7 +177,7 @@
|
|||||||
"yottaTarget": "calliope-mini-classic-gcc",
|
"yottaTarget": "calliope-mini-classic-gcc",
|
||||||
"yottaCorePackage": "microbit",
|
"yottaCorePackage": "microbit",
|
||||||
"githubCorePackage": "calliope-mini/microbit",
|
"githubCorePackage": "calliope-mini/microbit",
|
||||||
"gittag": "v2.0.0-rc7-calliope-1.0.1",
|
"gittag": "v2.0.0-rc8-calliope-1.0.3",
|
||||||
"serviceId": "calliope"
|
"serviceId": "calliope"
|
||||||
},
|
},
|
||||||
"serial": {
|
"serial": {
|
||||||
@@ -189,49 +195,24 @@
|
|||||||
"footerLogo": "./static/Calliopeminieditor.svg",
|
"footerLogo": "./static/Calliopeminieditor.svg",
|
||||||
"cardLogo": "./static/icons/apple-touch-icon.png",
|
"cardLogo": "./static/icons/apple-touch-icon.png",
|
||||||
"appLogo": "./static/icons/apple-touch-icon.png",
|
"appLogo": "./static/icons/apple-touch-icon.png",
|
||||||
"homeUrl": "https://calliope.cc/",
|
"homeUrl": "https://makecode.calliope.cc/",
|
||||||
"embedUrl": "https://mini.pxt.io/",
|
"embedUrl": "https://makecode.calliope.cc/",
|
||||||
"privacyUrl": "https://go.microsoft.com/fwlink/?LinkId=521839",
|
"privacyUrl": "https://go.microsoft.com/fwlink/?LinkId=521839",
|
||||||
"termsOfUseUrl": "https://go.microsoft.com/fwlink/?LinkID=206977",
|
"termsOfUseUrl": "https://go.microsoft.com/fwlink/?LinkID=206977",
|
||||||
"githubUrl": "https://github.com/Microsoft/pxt-calliope",
|
"githubUrl": "https://github.com/Microsoft/pxt-calliope",
|
||||||
"crowdinProject": "kindscript",
|
"crowdinProject": "kindscript",
|
||||||
"organization": "Microsoft",
|
"organization": "Microsoft MakeCode",
|
||||||
"organizationUrl": "https://pxt.io/",
|
"organizationUrl": "https://makecode.com/",
|
||||||
"organizationLogo": "./static/Microsoft-logo_rgb_c-gray-square.png",
|
"organizationLogo": "./static/Microsoft-logo_rgb_c-gray-square.png",
|
||||||
"organizationWideLogo": "./static/Microsoft-logo_rgb_c-white.png",
|
"organizationWideLogo": "./static/Microsoft-logo_rgb_c-white.png",
|
||||||
"browserSupport": [
|
|
||||||
{
|
|
||||||
"name": "unsupported",
|
|
||||||
"os": "*",
|
|
||||||
"path": "/browsers"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "unsupported",
|
|
||||||
"os": "mac",
|
|
||||||
"path": "/browsers/mac"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "unsupported",
|
|
||||||
"os": "linux",
|
|
||||||
"path": "browsers/linux"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "unsupported",
|
|
||||||
"os": "rpi",
|
|
||||||
"path": "/raspberry-pi"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "unsupported",
|
|
||||||
"os": "windows",
|
|
||||||
"path": "/browsers/windows"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"boardName": "Calliope mini",
|
"boardName": "Calliope mini",
|
||||||
|
"driveDisplayName": "MINI",
|
||||||
"hideSideDocs": true,
|
"hideSideDocs": true,
|
||||||
"invertedMenu": true,
|
"invertedMenu": true,
|
||||||
"invertedToolbox": true,
|
"invertedToolbox": true,
|
||||||
"monacoToolbox": false,
|
"monacoToolbox": true,
|
||||||
"hasAudio": true,
|
"hasAudio": true,
|
||||||
|
"highContrast": true,
|
||||||
"simAnimationEnter": "rotate in",
|
"simAnimationEnter": "rotate in",
|
||||||
"simAnimationExit": "rotate out",
|
"simAnimationExit": "rotate out",
|
||||||
"blocklyOptions": {
|
"blocklyOptions": {
|
||||||
@@ -241,6 +222,9 @@
|
|||||||
"colour": "rgba(189, 195, 199, 0.30)",
|
"colour": "rgba(189, 195, 199, 0.30)",
|
||||||
"snap": false
|
"snap": false
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
}
|
"docMenu": [],
|
||||||
|
"hasReferenceDocs": false
|
||||||
|
},
|
||||||
|
"ignoreDocsErrors": true
|
||||||
}
|
}
|
||||||
|
|||||||
295
pxtwapp/.gitignore
vendored
Normal file
@@ -0,0 +1,295 @@
|
|||||||
|
## Ignore Visual Studio temporary files, build results, and
|
||||||
|
## files generated by popular Visual Studio add-ons.
|
||||||
|
##
|
||||||
|
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
|
||||||
|
|
||||||
|
# User-specific files
|
||||||
|
*.suo
|
||||||
|
*.user
|
||||||
|
*.userosscache
|
||||||
|
*.sln.docstates
|
||||||
|
|
||||||
|
# User-specific files (MonoDevelop/Xamarin Studio)
|
||||||
|
*.userprefs
|
||||||
|
|
||||||
|
# Build results
|
||||||
|
[Dd]ebug/
|
||||||
|
[Dd]ebugPublic/
|
||||||
|
[Rr]elease/
|
||||||
|
[Rr]eleases/
|
||||||
|
x64/
|
||||||
|
x86/
|
||||||
|
bld/
|
||||||
|
[Bb]in/
|
||||||
|
[Oo]bj/
|
||||||
|
[Ll]og/
|
||||||
|
|
||||||
|
# Visual Studio 2015 cache/options directory
|
||||||
|
.vs/
|
||||||
|
# Uncomment if you have tasks that create the project's static files in wwwroot
|
||||||
|
#wwwroot/
|
||||||
|
|
||||||
|
# MSTest test Results
|
||||||
|
[Tt]est[Rr]esult*/
|
||||||
|
[Bb]uild[Ll]og.*
|
||||||
|
|
||||||
|
# NUNIT
|
||||||
|
*.VisualState.xml
|
||||||
|
TestResult.xml
|
||||||
|
|
||||||
|
# Build Results of an ATL Project
|
||||||
|
[Dd]ebugPS/
|
||||||
|
[Rr]eleasePS/
|
||||||
|
dlldata.c
|
||||||
|
|
||||||
|
# Benchmark Results
|
||||||
|
BenchmarkDotNet.Artifacts/
|
||||||
|
|
||||||
|
# .NET Core
|
||||||
|
project.lock.json
|
||||||
|
project.fragment.lock.json
|
||||||
|
artifacts/
|
||||||
|
**/Properties/launchSettings.json
|
||||||
|
|
||||||
|
*_i.c
|
||||||
|
*_p.c
|
||||||
|
*_i.h
|
||||||
|
*.ilk
|
||||||
|
*.meta
|
||||||
|
*.obj
|
||||||
|
*.pch
|
||||||
|
*.pdb
|
||||||
|
*.pgc
|
||||||
|
*.pgd
|
||||||
|
*.rsp
|
||||||
|
*.sbr
|
||||||
|
*.tlb
|
||||||
|
*.tli
|
||||||
|
*.tlh
|
||||||
|
*.tmp
|
||||||
|
*.tmp_proj
|
||||||
|
*.log
|
||||||
|
*.vspscc
|
||||||
|
*.vssscc
|
||||||
|
.builds
|
||||||
|
*.pidb
|
||||||
|
*.svclog
|
||||||
|
*.scc
|
||||||
|
|
||||||
|
# Chutzpah Test files
|
||||||
|
_Chutzpah*
|
||||||
|
|
||||||
|
# Visual C++ cache files
|
||||||
|
ipch/
|
||||||
|
*.aps
|
||||||
|
*.ncb
|
||||||
|
*.opendb
|
||||||
|
*.opensdf
|
||||||
|
*.sdf
|
||||||
|
*.cachefile
|
||||||
|
*.VC.db
|
||||||
|
*.VC.VC.opendb
|
||||||
|
|
||||||
|
# Visual Studio profiler
|
||||||
|
*.psess
|
||||||
|
*.vsp
|
||||||
|
*.vspx
|
||||||
|
*.sap
|
||||||
|
|
||||||
|
# TFS 2012 Local Workspace
|
||||||
|
$tf/
|
||||||
|
|
||||||
|
# Guidance Automation Toolkit
|
||||||
|
*.gpState
|
||||||
|
|
||||||
|
# ReSharper is a .NET coding add-in
|
||||||
|
_ReSharper*/
|
||||||
|
*.[Rr]e[Ss]harper
|
||||||
|
*.DotSettings.user
|
||||||
|
|
||||||
|
# JustCode is a .NET coding add-in
|
||||||
|
.JustCode
|
||||||
|
|
||||||
|
# TeamCity is a build add-in
|
||||||
|
_TeamCity*
|
||||||
|
|
||||||
|
# DotCover is a Code Coverage Tool
|
||||||
|
*.dotCover
|
||||||
|
|
||||||
|
# Visual Studio code coverage results
|
||||||
|
*.coverage
|
||||||
|
*.coveragexml
|
||||||
|
|
||||||
|
# NCrunch
|
||||||
|
_NCrunch_*
|
||||||
|
.*crunch*.local.xml
|
||||||
|
nCrunchTemp_*
|
||||||
|
|
||||||
|
# MightyMoose
|
||||||
|
*.mm.*
|
||||||
|
AutoTest.Net/
|
||||||
|
|
||||||
|
# Web workbench (sass)
|
||||||
|
.sass-cache/
|
||||||
|
|
||||||
|
# Installshield output folder
|
||||||
|
[Ee]xpress/
|
||||||
|
|
||||||
|
# DocProject is a documentation generator add-in
|
||||||
|
DocProject/buildhelp/
|
||||||
|
DocProject/Help/*.HxT
|
||||||
|
DocProject/Help/*.HxC
|
||||||
|
DocProject/Help/*.hhc
|
||||||
|
DocProject/Help/*.hhk
|
||||||
|
DocProject/Help/*.hhp
|
||||||
|
DocProject/Help/Html2
|
||||||
|
DocProject/Help/html
|
||||||
|
|
||||||
|
# Click-Once directory
|
||||||
|
publish/
|
||||||
|
|
||||||
|
# Publish Web Output
|
||||||
|
*.[Pp]ublish.xml
|
||||||
|
*.azurePubxml
|
||||||
|
# TODO: Comment the next line if you want to checkin your web deploy settings
|
||||||
|
# but database connection strings (with potential passwords) will be unencrypted
|
||||||
|
*.pubxml
|
||||||
|
*.publishproj
|
||||||
|
|
||||||
|
# Microsoft Azure Web App publish settings. Comment the next line if you want to
|
||||||
|
# checkin your Azure Web App publish settings, but sensitive information contained
|
||||||
|
# in these scripts will be unencrypted
|
||||||
|
PublishScripts/
|
||||||
|
|
||||||
|
# NuGet Packages
|
||||||
|
*.nupkg
|
||||||
|
# The packages folder can be ignored because of Package Restore
|
||||||
|
**/packages/*
|
||||||
|
# except build/, which is used as an MSBuild target.
|
||||||
|
!**/packages/build/
|
||||||
|
# Uncomment if necessary however generally it will be regenerated when needed
|
||||||
|
#!**/packages/repositories.config
|
||||||
|
# NuGet v3's project.json files produces more ignorable files
|
||||||
|
*.nuget.props
|
||||||
|
*.nuget.targets
|
||||||
|
|
||||||
|
# Microsoft Azure Build Output
|
||||||
|
csx/
|
||||||
|
*.build.csdef
|
||||||
|
|
||||||
|
# Microsoft Azure Emulator
|
||||||
|
ecf/
|
||||||
|
rcf/
|
||||||
|
|
||||||
|
# Windows Store app package directories and files
|
||||||
|
AppPackages/
|
||||||
|
BundleArtifacts/
|
||||||
|
Package.StoreAssociation.xml
|
||||||
|
_pkginfo.txt
|
||||||
|
*.appx
|
||||||
|
|
||||||
|
# Visual Studio cache files
|
||||||
|
# files ending in .cache can be ignored
|
||||||
|
*.[Cc]ache
|
||||||
|
# but keep track of directories ending in .cache
|
||||||
|
!*.[Cc]ache/
|
||||||
|
|
||||||
|
# Others
|
||||||
|
ClientBin/
|
||||||
|
~$*
|
||||||
|
*~
|
||||||
|
*.dbmdl
|
||||||
|
*.dbproj.schemaview
|
||||||
|
*.jfm
|
||||||
|
*.pfx
|
||||||
|
*.publishsettings
|
||||||
|
orleans.codegen.cs
|
||||||
|
|
||||||
|
# Since there are multiple workflows, uncomment next line to ignore bower_components
|
||||||
|
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
|
||||||
|
#bower_components/
|
||||||
|
|
||||||
|
# RIA/Silverlight projects
|
||||||
|
Generated_Code/
|
||||||
|
|
||||||
|
# Backup & report files from converting an old project file
|
||||||
|
# to a newer Visual Studio version. Backup files are not needed,
|
||||||
|
# because we have git ;-)
|
||||||
|
_UpgradeReport_Files/
|
||||||
|
Backup*/
|
||||||
|
UpgradeLog*.XML
|
||||||
|
UpgradeLog*.htm
|
||||||
|
|
||||||
|
# SQL Server files
|
||||||
|
*.mdf
|
||||||
|
*.ldf
|
||||||
|
*.ndf
|
||||||
|
|
||||||
|
# Business Intelligence projects
|
||||||
|
*.rdl.data
|
||||||
|
*.bim.layout
|
||||||
|
*.bim_*.settings
|
||||||
|
|
||||||
|
# Microsoft Fakes
|
||||||
|
FakesAssemblies/
|
||||||
|
|
||||||
|
# GhostDoc plugin setting file
|
||||||
|
*.GhostDoc.xml
|
||||||
|
|
||||||
|
# Node.js Tools for Visual Studio
|
||||||
|
.ntvs_analysis.dat
|
||||||
|
node_modules/
|
||||||
|
|
||||||
|
# Typescript v1 declaration files
|
||||||
|
typings/
|
||||||
|
|
||||||
|
# Visual Studio 6 build log
|
||||||
|
*.plg
|
||||||
|
|
||||||
|
# Visual Studio 6 workspace options file
|
||||||
|
*.opt
|
||||||
|
|
||||||
|
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
|
||||||
|
*.vbw
|
||||||
|
|
||||||
|
# Visual Studio LightSwitch build output
|
||||||
|
**/*.HTMLClient/GeneratedArtifacts
|
||||||
|
**/*.DesktopClient/GeneratedArtifacts
|
||||||
|
**/*.DesktopClient/ModelManifest.xml
|
||||||
|
**/*.Server/GeneratedArtifacts
|
||||||
|
**/*.Server/ModelManifest.xml
|
||||||
|
_Pvt_Extensions
|
||||||
|
|
||||||
|
# Paket dependency manager
|
||||||
|
.paket/paket.exe
|
||||||
|
paket-files/
|
||||||
|
|
||||||
|
# FAKE - F# Make
|
||||||
|
.fake/
|
||||||
|
|
||||||
|
# JetBrains Rider
|
||||||
|
.idea/
|
||||||
|
*.sln.iml
|
||||||
|
|
||||||
|
# CodeRush
|
||||||
|
.cr/
|
||||||
|
|
||||||
|
# Python Tools for Visual Studio (PTVS)
|
||||||
|
__pycache__/
|
||||||
|
*.pyc
|
||||||
|
|
||||||
|
# Cake - Uncomment if you are using it
|
||||||
|
# tools/**
|
||||||
|
# !tools/packages.config
|
||||||
|
|
||||||
|
# Tabs Studio
|
||||||
|
*.tss
|
||||||
|
|
||||||
|
# Telerik's JustMock configuration file
|
||||||
|
*.jmconfig
|
||||||
|
|
||||||
|
# BizTalk build output
|
||||||
|
*.btp.cs
|
||||||
|
*.btm.cs
|
||||||
|
*.odx.cs
|
||||||
|
*.xsd.cs
|
||||||
48
pxtwapp/pxtwapp.sln
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
# Visual Studio 15
|
||||||
|
VisualStudioVersion = 15.0.26430.15
|
||||||
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
|
Project("{262852C6-CD72-467D-83FE-5EEB1973A190}") = "pxtwapp", "pxtwapp\pxtwapp.jsproj", "{34E8CDE2-3991-414E-BB19-BFF4BD5E031A}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
Debug|ARM = Debug|ARM
|
||||||
|
Debug|x64 = Debug|x64
|
||||||
|
Debug|x86 = Debug|x86
|
||||||
|
Release|Any CPU = Release|Any CPU
|
||||||
|
Release|ARM = Release|ARM
|
||||||
|
Release|x64 = Release|x64
|
||||||
|
Release|x86 = Release|x86
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{34E8CDE2-3991-414E-BB19-BFF4BD5E031A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{34E8CDE2-3991-414E-BB19-BFF4BD5E031A}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{34E8CDE2-3991-414E-BB19-BFF4BD5E031A}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
|
||||||
|
{34E8CDE2-3991-414E-BB19-BFF4BD5E031A}.Debug|ARM.ActiveCfg = Debug|ARM
|
||||||
|
{34E8CDE2-3991-414E-BB19-BFF4BD5E031A}.Debug|ARM.Build.0 = Debug|ARM
|
||||||
|
{34E8CDE2-3991-414E-BB19-BFF4BD5E031A}.Debug|ARM.Deploy.0 = Debug|ARM
|
||||||
|
{34E8CDE2-3991-414E-BB19-BFF4BD5E031A}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
|
{34E8CDE2-3991-414E-BB19-BFF4BD5E031A}.Debug|x64.Build.0 = Debug|x64
|
||||||
|
{34E8CDE2-3991-414E-BB19-BFF4BD5E031A}.Debug|x64.Deploy.0 = Debug|x64
|
||||||
|
{34E8CDE2-3991-414E-BB19-BFF4BD5E031A}.Debug|x86.ActiveCfg = Debug|x86
|
||||||
|
{34E8CDE2-3991-414E-BB19-BFF4BD5E031A}.Debug|x86.Build.0 = Debug|x86
|
||||||
|
{34E8CDE2-3991-414E-BB19-BFF4BD5E031A}.Debug|x86.Deploy.0 = Debug|x86
|
||||||
|
{34E8CDE2-3991-414E-BB19-BFF4BD5E031A}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{34E8CDE2-3991-414E-BB19-BFF4BD5E031A}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{34E8CDE2-3991-414E-BB19-BFF4BD5E031A}.Release|Any CPU.Deploy.0 = Release|Any CPU
|
||||||
|
{34E8CDE2-3991-414E-BB19-BFF4BD5E031A}.Release|ARM.ActiveCfg = Release|ARM
|
||||||
|
{34E8CDE2-3991-414E-BB19-BFF4BD5E031A}.Release|ARM.Build.0 = Release|ARM
|
||||||
|
{34E8CDE2-3991-414E-BB19-BFF4BD5E031A}.Release|ARM.Deploy.0 = Release|ARM
|
||||||
|
{34E8CDE2-3991-414E-BB19-BFF4BD5E031A}.Release|x64.ActiveCfg = Release|x64
|
||||||
|
{34E8CDE2-3991-414E-BB19-BFF4BD5E031A}.Release|x64.Build.0 = Release|x64
|
||||||
|
{34E8CDE2-3991-414E-BB19-BFF4BD5E031A}.Release|x64.Deploy.0 = Release|x64
|
||||||
|
{34E8CDE2-3991-414E-BB19-BFF4BD5E031A}.Release|x86.ActiveCfg = Release|x86
|
||||||
|
{34E8CDE2-3991-414E-BB19-BFF4BD5E031A}.Release|x86.Build.0 = Release|x86
|
||||||
|
{34E8CDE2-3991-414E-BB19-BFF4BD5E031A}.Release|x86.Deploy.0 = Release|x86
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
||||||
BIN
pxtwapp/pxtwapp/images/SmallTile.scale-200.png
Normal file
|
After Width: | Height: | Size: 3.6 KiB |
BIN
pxtwapp/pxtwapp/images/SplashScreen.scale-200.png
Normal file
|
After Width: | Height: | Size: 18 KiB |
BIN
pxtwapp/pxtwapp/images/Square150x150Logo.scale-200.png
Normal file
|
After Width: | Height: | Size: 6.6 KiB |
|
After Width: | Height: | Size: 1.9 KiB |
BIN
pxtwapp/pxtwapp/images/Square44x44Logo.scale-200.png
Normal file
|
After Width: | Height: | Size: 2.6 KiB |
BIN
pxtwapp/pxtwapp/images/Square44x44Logo.targetsize-48.png
Normal file
|
After Width: | Height: | Size: 1.9 KiB |
BIN
pxtwapp/pxtwapp/images/Wide310x150Logo.scale-200.png
Normal file
|
After Width: | Height: | Size: 7.5 KiB |
BIN
pxtwapp/pxtwapp/images/logo.png
Normal file
|
After Width: | Height: | Size: 11 KiB |
BIN
pxtwapp/pxtwapp/images/storelogo.scale-200.png
Normal file
|
After Width: | Height: | Size: 2.9 KiB |
40
pxtwapp/pxtwapp/msapp-error.css
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
body {
|
||||||
|
margin: 10px;
|
||||||
|
background-color: #6633cc;
|
||||||
|
color: #FFFFFF;
|
||||||
|
font-family: 'Open Sans', 'Helvetica Neue', Arial, Helvetica, sans-serif;
|
||||||
|
}
|
||||||
|
|
||||||
|
.paramName {
|
||||||
|
font-size: 10px;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
.paramValue {
|
||||||
|
font-size: 10px;
|
||||||
|
padding-left: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.param {
|
||||||
|
margin-bottom: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#retryButton {
|
||||||
|
box-shadow: 0px 0em 0px 0px rgba(34, 36, 38, 0.15) inset;
|
||||||
|
outline: none;
|
||||||
|
border: none;
|
||||||
|
vertical-align: baseline;
|
||||||
|
padding: 0.78571429em 1.5em 0.78571429em;
|
||||||
|
text-transform: none;
|
||||||
|
font-weight: bold;
|
||||||
|
font-style: normal;
|
||||||
|
text-align: center;
|
||||||
|
text-decoration: none;
|
||||||
|
border-radius: 0.28571429rem;
|
||||||
|
background-color: #ff8b27;
|
||||||
|
margin: 15px 10px 100px 10px;
|
||||||
|
width: 80px;
|
||||||
|
height: 35px;
|
||||||
|
font-size: 15px;
|
||||||
|
color: #FFFFFF;
|
||||||
|
}
|
||||||
24
pxtwapp/pxtwapp/msapp-error.html
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Oops!</title>
|
||||||
|
<link href="msapp-error.css" rel="stylesheet" type="text/css" />
|
||||||
|
<script src="msapp-error.js" type="text/javascript"></script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>Oops! Please connect to the Internet.</h1>
|
||||||
|
<button id="retryButton">Retry</button>
|
||||||
|
<div id="failureUrl" class="param">
|
||||||
|
<span class="paramName">URL:</span>
|
||||||
|
<span id="failureUrlValue" class="paramValue"></span>
|
||||||
|
</div>
|
||||||
|
<div id="httpStatus" class="param">
|
||||||
|
<span class="paramName">HTTP status:</span>
|
||||||
|
<span id="httpStatusValue" class="paramValue"></span>
|
||||||
|
</div>
|
||||||
|
<div id="failureName">
|
||||||
|
<span class="paramName">Failure name:</span>
|
||||||
|
<span id="failureNameValue" class="paramValue"></span>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
47
pxtwapp/pxtwapp/msapp-error.js
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
(function () {
|
||||||
|
var validParameterNames = ["httpStatus", "failureName", "failureUrl"];
|
||||||
|
|
||||||
|
function parseQueryParameters() {
|
||||||
|
var query = location.search.slice(1);
|
||||||
|
return query.split("&").reduce(function (queryParameters, rawPair) {
|
||||||
|
var pair = rawPair.split("=").map(decodeURIComponent);
|
||||||
|
queryParameters[pair[0]] = pair[1];
|
||||||
|
return queryParameters;
|
||||||
|
}, {});
|
||||||
|
}
|
||||||
|
|
||||||
|
function initialize() {
|
||||||
|
var queryParameters = parseQueryParameters();
|
||||||
|
var url = queryParameters["failureUrl"];
|
||||||
|
var retryButton = document.getElementById("retryButton");
|
||||||
|
|
||||||
|
if (url) {
|
||||||
|
retryButton.addEventListener("click", (e) => {
|
||||||
|
window.location.href = url;
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
retryButton.style.display = none;
|
||||||
|
}
|
||||||
|
|
||||||
|
validParameterNames.forEach(function (parameterName) {
|
||||||
|
var parameterValue = queryParameters[parameterName];
|
||||||
|
|
||||||
|
if (parameterValue) {
|
||||||
|
document.getElementById(parameterName + "Value").textContent = parameterValue;
|
||||||
|
} else {
|
||||||
|
document.getElementById(parameterName).remove();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateOnlineStatus(e) {
|
||||||
|
var queryParameters = parseQueryParameters();
|
||||||
|
var url = queryParameters["failureUrl"];
|
||||||
|
if (url) {
|
||||||
|
window.location.href = url;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
window.addEventListener("online", updateOnlineStatus);
|
||||||
|
document.addEventListener("DOMContentLoaded", initialize);
|
||||||
|
}());
|
||||||
59
pxtwapp/pxtwapp/package.appxmanifest
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Package xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10" xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest" xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10" xmlns:uap3="http://schemas.microsoft.com/appx/manifest/uap/windows10/3" IgnorableNamespaces="uap uap3 mp">
|
||||||
|
<Identity Name="CalliopeMini" Version="1.0.0.0" Publisher="CN=calliope" />
|
||||||
|
<mp:PhoneIdentity PhoneProductId="5ddd542e-5ab4-48bc-b116-0782dc08ab97" PhonePublisherId="00000000-0000-0000-0000-000000000000" />
|
||||||
|
<Properties>
|
||||||
|
<DisplayName>Microsoft MakeCode for Calliope Mini</DisplayName>
|
||||||
|
<PublisherDisplayName>Calliope.cc</PublisherDisplayName>
|
||||||
|
<Logo>images\storelogo.png</Logo>
|
||||||
|
</Properties>
|
||||||
|
<Dependencies>
|
||||||
|
<TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.0.0" MaxVersionTested="10.0.0.0" />
|
||||||
|
</Dependencies>
|
||||||
|
<Resources>
|
||||||
|
<Resource Language="x-generate" />
|
||||||
|
</Resources>
|
||||||
|
<Applications>
|
||||||
|
<Application Id="App" StartPage="https://makecode.calliope.cc/">
|
||||||
|
<uap:ApplicationContentUriRules>
|
||||||
|
<uap:Rule Match="https://makecode.calliope.cc/" Type="include" WindowsRuntimeAccess="all" />
|
||||||
|
<uap:Rule Match="https://trg-calliope.userpxt.io/---simulator" Type="include" WindowsRuntimeAccess="none" />
|
||||||
|
<uap:Rule Match="https://makecode.calliope.cc/beta" Type="include" WindowsRuntimeAccess="all" />
|
||||||
|
<uap:Rule Match="https://trg-calliope.userpxt.io/beta---simulator" Type="include" WindowsRuntimeAccess="none" />
|
||||||
|
</uap:ApplicationContentUriRules>
|
||||||
|
<uap:VisualElements DisplayName="Microsoft MakeCode for Calliope Mini" Description="Microsoft MakeCode for Calliope Mini" BackgroundColor="#249899" Square150x150Logo="images\Square150x150Logo.png" Square44x44Logo="images\Square44x44Logo.png">
|
||||||
|
<uap:DefaultTile Wide310x150Logo="images\Wide310x150Logo.png" Square71x71Logo="images\SmallTile.png">
|
||||||
|
</uap:DefaultTile>
|
||||||
|
<uap:SplashScreen Image="images\SplashScreen.png" BackgroundColor="#303030" />
|
||||||
|
</uap:VisualElements>
|
||||||
|
<Extensions>
|
||||||
|
<uap:Extension Category="windows.fileTypeAssociation">
|
||||||
|
<uap:FileTypeAssociation Name="makecode">
|
||||||
|
<uap:DisplayName>Microsoft MakeCode binary file</uap:DisplayName>
|
||||||
|
<uap:SupportedFileTypes>
|
||||||
|
<uap:FileType ContentType="application/x-makecode-hex">.hex</uap:FileType>
|
||||||
|
</uap:SupportedFileTypes>
|
||||||
|
</uap:FileTypeAssociation>
|
||||||
|
</uap:Extension>
|
||||||
|
<uap3:Extension Category="windows.appUriHandler">
|
||||||
|
<uap3:AppUriHandler>
|
||||||
|
<uap3:Host Name="makecode.calliope.cc" />
|
||||||
|
</uap3:AppUriHandler>
|
||||||
|
</uap3:Extension>
|
||||||
|
</Extensions>
|
||||||
|
</Application>
|
||||||
|
</Applications>
|
||||||
|
<Capabilities>
|
||||||
|
<Capability Name="internetClient" />
|
||||||
|
<DeviceCapability Name="serialcommunication">
|
||||||
|
<Device Id="any">
|
||||||
|
<Function Type="name:serialPort" />
|
||||||
|
</Device>
|
||||||
|
</DeviceCapability>
|
||||||
|
<DeviceCapability Name="humaninterfacedevice">
|
||||||
|
<Device Id="vidpid:0d28 0204">
|
||||||
|
<Function Type="usage:FF00 *" />
|
||||||
|
</Device>
|
||||||
|
</DeviceCapability>
|
||||||
|
</Capabilities>
|
||||||
|
</Package>
|
||||||
91
pxtwapp/pxtwapp/pxtwapp.jsproj
Normal file
@@ -0,0 +1,91 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<ItemGroup Label="ProjectConfigurations">
|
||||||
|
<ProjectConfiguration Include="Debug|AnyCPU">
|
||||||
|
<Configuration>Debug</Configuration>
|
||||||
|
<Platform>AnyCPU</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Debug|ARM">
|
||||||
|
<Configuration>Debug</Configuration>
|
||||||
|
<Platform>ARM</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Debug|x64">
|
||||||
|
<Configuration>Debug</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Debug|x86">
|
||||||
|
<Configuration>Debug</Configuration>
|
||||||
|
<Platform>x86</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release|AnyCPU">
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>AnyCPU</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release|ARM">
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>ARM</Platform>
|
||||||
|
<UseDotNetNativeToolchain>true</UseDotNetNativeToolchain>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release|x64">
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
<UseDotNetNativeToolchain>true</UseDotNetNativeToolchain>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release|x86">
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>x86</Platform>
|
||||||
|
<UseDotNetNativeToolchain>true</UseDotNetNativeToolchain>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
</ItemGroup>
|
||||||
|
<PropertyGroup Label="Globals">
|
||||||
|
<ProjectGuid>34e8cde2-3991-414e-bb19-bff4bd5e031a</ProjectGuid>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||||
|
<PropertyGroup Condition="'$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' < '14.0'">
|
||||||
|
<VisualStudioVersion>14.0</VisualStudioVersion>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\$(WMSJSProjectDirectory)\Microsoft.VisualStudio.$(WMSJSProject).Default.props" />
|
||||||
|
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\$(WMSJSProjectDirectory)\Microsoft.VisualStudio.$(WMSJSProject).props" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetPlatformIdentifier>UAP</TargetPlatformIdentifier>
|
||||||
|
<TargetPlatformVersion>10.0.15063.0</TargetPlatformVersion>
|
||||||
|
<TargetPlatformMinVersion>10.0.10240.0</TargetPlatformMinVersion>
|
||||||
|
<MinimumVisualStudioVersion>$(VersionNumberMajor).$(VersionNumberMinor)</MinimumVisualStudioVersion>
|
||||||
|
<DefaultLanguage>en-US</DefaultLanguage>
|
||||||
|
<PackageCertificateKeyFile>pxtwapp_TemporaryKey.pfx</PackageCertificateKeyFile>
|
||||||
|
<AppxAutoIncrementPackageRevision>true</AppxAutoIncrementPackageRevision>
|
||||||
|
<AppxBundle>Always</AppxBundle>
|
||||||
|
<AppxBundlePlatforms>x86|x64|arm</AppxBundlePlatforms>
|
||||||
|
<PackageCertificateThumbprint>BA3D3E800661F789BAE7216F8D6F76608D1C4D62</PackageCertificateThumbprint>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<AppxManifest Include="package.appxmanifest">
|
||||||
|
<SubType>Designer</SubType>
|
||||||
|
</AppxManifest>
|
||||||
|
<Content Include="images\logo.png" />
|
||||||
|
<Content Include="images\SmallTile.scale-200.png" />
|
||||||
|
<Content Include="images\Square44x44Logo.altform-unplated_targetsize-48.png" />
|
||||||
|
<Content Include="images\Square44x44Logo.targetsize-48.png" />
|
||||||
|
<Content Include="images\storelogo.scale-200.png" />
|
||||||
|
<Content Include="msapp-error.js" />
|
||||||
|
<Content Include="msapp-error.css" />
|
||||||
|
<Content Include="msapp-error.html" />
|
||||||
|
<Content Include="images\SplashScreen.scale-200.png" />
|
||||||
|
<Content Include="images\Square150x150Logo.scale-200.png" />
|
||||||
|
<Content Include="images\Square44x44Logo.scale-200.png" />
|
||||||
|
<Content Include="images\Wide310x150Logo.scale-200.png" />
|
||||||
|
<None Include="pxtwapp_TemporaryKey.pfx" />
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\$(WMSJSProjectDirectory)\Microsoft.VisualStudio.$(WMSJSProject).targets" />
|
||||||
|
<!-- To modify your build process, add your task inside one of the targets below then uncomment
|
||||||
|
that target and the DisableFastUpToDateCheck PropertyGroup.
|
||||||
|
Other similar extension points exist, see Microsoft.Common.targets.
|
||||||
|
<Target Name="BeforeBuild">
|
||||||
|
</Target>
|
||||||
|
<Target Name="AfterBuild">
|
||||||
|
</Target>
|
||||||
|
<PropertyGroup>
|
||||||
|
<DisableFastUpToDateCheck>true</DisableFastUpToDateCheck>
|
||||||
|
</PropertyGroup>
|
||||||
|
-->
|
||||||
|
</Project>
|
||||||
@@ -18,6 +18,9 @@ namespace pxsim {
|
|||||||
speakerState: SpeakerState;
|
speakerState: SpeakerState;
|
||||||
fileSystem: FileSystemState;
|
fileSystem: FileSystemState;
|
||||||
|
|
||||||
|
// visual
|
||||||
|
view: SVGElement;
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super()
|
super()
|
||||||
|
|
||||||
@@ -94,11 +97,11 @@ namespace pxsim {
|
|||||||
break;
|
break;
|
||||||
case "serial":
|
case "serial":
|
||||||
let data = (<SimulatorSerialMessage>msg).data || "";
|
let data = (<SimulatorSerialMessage>msg).data || "";
|
||||||
this.serialState.recieveData(data);
|
this.serialState.receiveData(data);
|
||||||
break;
|
break;
|
||||||
case "radiopacket":
|
case "radiopacket":
|
||||||
let packet = <SimulatorRadioPacketMessage>msg;
|
let packet = <SimulatorRadioPacketMessage>msg;
|
||||||
this.radioState.recievePacket(packet);
|
this.radioState.receivePacket(packet);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -121,16 +124,22 @@ namespace pxsim {
|
|||||||
fnArgs: fnArgs,
|
fnArgs: fnArgs,
|
||||||
maxWidth: "100%",
|
maxWidth: "100%",
|
||||||
maxHeight: "100%",
|
maxHeight: "100%",
|
||||||
|
highContrast: msg.highContrast
|
||||||
};
|
};
|
||||||
const viewHost = new visuals.BoardHost(pxsim.visuals.mkBoardView({
|
const viewHost = new visuals.BoardHost(pxsim.visuals.mkBoardView({
|
||||||
visual: boardDef.visual
|
visual: boardDef.visual,
|
||||||
|
highContrast: msg.highContrast
|
||||||
}), opts);
|
}), opts);
|
||||||
|
|
||||||
document.body.innerHTML = ""; // clear children
|
document.body.innerHTML = ""; // clear children
|
||||||
document.body.appendChild(viewHost.getView());
|
document.body.appendChild(this.view = viewHost.getView());
|
||||||
|
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
screenshot(): string {
|
||||||
|
return svg.toDataUri(new XMLSerializer().serializeToString(this.view));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function initRuntimeWithDalBoard() {
|
export function initRuntimeWithDalBoard() {
|
||||||
|
|||||||
BIN
sim/public/blocks/iconnames/angry.png
Normal file
|
After Width: | Height: | Size: 2.6 KiB |
BIN
sim/public/blocks/iconnames/asleep.png
Normal file
|
After Width: | Height: | Size: 2.5 KiB |
BIN
sim/public/blocks/iconnames/butterfly.png
Normal file
|
After Width: | Height: | Size: 2.8 KiB |
BIN
sim/public/blocks/iconnames/chessboard.png
Normal file
|
After Width: | Height: | Size: 2.7 KiB |
BIN
sim/public/blocks/iconnames/confused.png
Normal file
|
After Width: | Height: | Size: 2.5 KiB |
BIN
sim/public/blocks/iconnames/cow.png
Normal file
|
After Width: | Height: | Size: 2.6 KiB |
BIN
sim/public/blocks/iconnames/diamond.png
Normal file
|
After Width: | Height: | Size: 2.7 KiB |
BIN
sim/public/blocks/iconnames/duck.png
Normal file
|
After Width: | Height: | Size: 2.6 KiB |
BIN
sim/public/blocks/iconnames/eigthnote.png
Normal file
|
After Width: | Height: | Size: 2.7 KiB |
BIN
sim/public/blocks/iconnames/fabulous.png
Normal file
|
After Width: | Height: | Size: 2.6 KiB |
BIN
sim/public/blocks/iconnames/ghost.png
Normal file
|
After Width: | Height: | Size: 2.7 KiB |
BIN
sim/public/blocks/iconnames/giraffe.png
Normal file
|
After Width: | Height: | Size: 2.7 KiB |
BIN
sim/public/blocks/iconnames/happy.png
Normal file
|
After Width: | Height: | Size: 2.5 KiB |
BIN
sim/public/blocks/iconnames/heart.png
Normal file
|
After Width: | Height: | Size: 2.7 KiB |
BIN
sim/public/blocks/iconnames/house.png
Normal file
|
After Width: | Height: | Size: 2.7 KiB |
BIN
sim/public/blocks/iconnames/lefttriangle.png
Normal file
|
After Width: | Height: | Size: 2.7 KiB |
BIN
sim/public/blocks/iconnames/meh.png
Normal file
|
After Width: | Height: | Size: 2.7 KiB |
BIN
sim/public/blocks/iconnames/no.png
Normal file
|
After Width: | Height: | Size: 2.6 KiB |
BIN
sim/public/blocks/iconnames/pitchfork.png
Normal file
|
After Width: | Height: | Size: 2.8 KiB |
BIN
sim/public/blocks/iconnames/quarternote.png
Normal file
|
After Width: | Height: | Size: 2.7 KiB |
BIN
sim/public/blocks/iconnames/rabbit.png
Normal file
|
After Width: | Height: | Size: 2.7 KiB |
BIN
sim/public/blocks/iconnames/rollerskate.png
Normal file
|
After Width: | Height: | Size: 2.6 KiB |
BIN
sim/public/blocks/iconnames/sad.png
Normal file
|
After Width: | Height: | Size: 2.5 KiB |
BIN
sim/public/blocks/iconnames/scissors.png
Normal file
|
After Width: | Height: | Size: 8.0 KiB |
BIN
sim/public/blocks/iconnames/silly.png
Normal file
|
After Width: | Height: | Size: 2.5 KiB |
BIN
sim/public/blocks/iconnames/skull.png
Normal file
|
After Width: | Height: | Size: 2.7 KiB |
BIN
sim/public/blocks/iconnames/smalldiamond.png
Normal file
|
After Width: | Height: | Size: 2.5 KiB |
BIN
sim/public/blocks/iconnames/smallheart.png
Normal file
|
After Width: | Height: | Size: 2.5 KiB |
BIN
sim/public/blocks/iconnames/smallsquare.png
Normal file
|
After Width: | Height: | Size: 2.5 KiB |
BIN
sim/public/blocks/iconnames/snake.png
Normal file
|
After Width: | Height: | Size: 2.6 KiB |
BIN
sim/public/blocks/iconnames/square.png
Normal file
|
After Width: | Height: | Size: 2.5 KiB |
BIN
sim/public/blocks/iconnames/stickfigure.png
Normal file
|
After Width: | Height: | Size: 2.7 KiB |
BIN
sim/public/blocks/iconnames/surprised.png
Normal file
|
After Width: | Height: | Size: 2.6 KiB |
BIN
sim/public/blocks/iconnames/sword.png
Normal file
|
After Width: | Height: | Size: 2.7 KiB |
BIN
sim/public/blocks/iconnames/target.png
Normal file
|
After Width: | Height: | Size: 2.7 KiB |
BIN
sim/public/blocks/iconnames/tortoise.png
Normal file
|
After Width: | Height: | Size: 2.5 KiB |
BIN
sim/public/blocks/iconnames/triangle.png
Normal file
|
After Width: | Height: | Size: 2.6 KiB |
BIN
sim/public/blocks/iconnames/tshirt.png
Normal file
|
After Width: | Height: | Size: 2.7 KiB |
BIN
sim/public/blocks/iconnames/umbrella.png
Normal file
|
After Width: | Height: | Size: 2.8 KiB |
BIN
sim/public/blocks/iconnames/yes.png
Normal file
|
After Width: | Height: | Size: 2.5 KiB |
@@ -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;
|
||||||
@@ -131,15 +131,33 @@ namespace pxsim.images {
|
|||||||
namespace pxsim.ImageMethods {
|
namespace pxsim.ImageMethods {
|
||||||
export function showImage(leds: Image, offset: number, interval: number) {
|
export function showImage(leds: Image, offset: number, interval: number) {
|
||||||
pxtrt.nullCheck(leds)
|
pxtrt.nullCheck(leds)
|
||||||
leds.copyTo(offset, 5, board().ledMatrixState.image, 0)
|
let cb = getResume();
|
||||||
runtime.queueDisplayUpdate()
|
let first = true;
|
||||||
basic.pause(interval);
|
|
||||||
|
board().ledMatrixState.animationQ.enqueue({
|
||||||
|
interval,
|
||||||
|
frame: () => {
|
||||||
|
if (first) {
|
||||||
|
leds.copyTo(offset, 5, board().ledMatrixState.image, 0)
|
||||||
|
first = false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
},
|
||||||
|
whenDone: cb
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export function plotImage(leds: Image, offset: number): void {
|
export function plotImage(leds: Image, offset: number): void {
|
||||||
pxtrt.nullCheck(leds)
|
pxtrt.nullCheck(leds)
|
||||||
leds.copyTo(offset, 5, board().ledMatrixState.image, 0)
|
|
||||||
runtime.queueDisplayUpdate()
|
board().ledMatrixState.animationQ.enqueue({
|
||||||
|
interval: 0,
|
||||||
|
frame: () => {
|
||||||
|
leds.copyTo(offset, 5, board().ledMatrixState.image, 0)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export function height(leds: Image): number {
|
export function height(leds: Image): number {
|
||||||
@@ -216,15 +234,16 @@ namespace pxsim.ImageMethods {
|
|||||||
|
|
||||||
namespace pxsim.basic {
|
namespace pxsim.basic {
|
||||||
export function showNumber(x: number, interval: number) {
|
export function showNumber(x: number, interval: number) {
|
||||||
if (interval < 0) return;
|
if (interval <= 0)
|
||||||
|
interval = 1;
|
||||||
let leds = createImageFromString(x.toString());
|
let leds = createImageFromString(x.toString());
|
||||||
if (x < 0 || x >= 10) ImageMethods.scrollImage(leds, 1, interval);
|
if (x < 0 || x >= 10) ImageMethods.scrollImage(leds, 1, interval);
|
||||||
else showLeds(leds, interval * 5);
|
else showLeds(leds, interval * 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function showString(s: string, interval: number) {
|
export function showString(s: string, interval: number) {
|
||||||
if (interval < 0) return;
|
if (interval <= 0)
|
||||||
|
interval = 1;
|
||||||
if (s.length == 0) {
|
if (s.length == 0) {
|
||||||
clearScreen();
|
clearScreen();
|
||||||
pause(interval * 5);
|
pause(interval * 5);
|
||||||
@@ -254,7 +273,16 @@ namespace pxsim.basic {
|
|||||||
|
|
||||||
namespace pxsim.led {
|
namespace pxsim.led {
|
||||||
export function plot(x: number, y: number) {
|
export function plot(x: number, y: number) {
|
||||||
board().ledMatrixState.image.set(x, y, 255);
|
board().ledMatrixState.image.set(x, y, 0xff);
|
||||||
|
runtime.queueDisplayUpdate()
|
||||||
|
}
|
||||||
|
|
||||||
|
export function plotBrightness(x: number, y: number, brightness: number) {
|
||||||
|
const state = board().ledMatrixState;
|
||||||
|
brightness = Math.max(0, Math.min(0xff, brightness));
|
||||||
|
if (brightness != 0 && brightness != 0xff && state.displayMode != DisplayMode.greyscale)
|
||||||
|
state.displayMode = DisplayMode.greyscale;
|
||||||
|
state.image.set(x, y, brightness);
|
||||||
runtime.queueDisplayUpdate()
|
runtime.queueDisplayUpdate()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -272,7 +300,7 @@ namespace pxsim.led {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function setBrightness(value: number): void {
|
export function setBrightness(value: number): void {
|
||||||
board().ledMatrixState.brigthness = value;
|
board().ledMatrixState.brigthness = Math.max(0, Math.min(255, value));
|
||||||
runtime.queueDisplayUpdate()
|
runtime.queueDisplayUpdate()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -286,6 +314,10 @@ namespace pxsim.led {
|
|||||||
runtime.queueDisplayUpdate()
|
runtime.queueDisplayUpdate()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function displayMode(): DisplayMode {
|
||||||
|
return board().ledMatrixState.displayMode;
|
||||||
|
}
|
||||||
|
|
||||||
export function screenshot(): Image {
|
export function screenshot(): Image {
|
||||||
let img = createImage(5)
|
let img = createImage(5)
|
||||||
board().ledMatrixState.image.copyTo(0, 5, img, 0);
|
board().ledMatrixState.image.copyTo(0, 5, img, 0);
|
||||||
|
|||||||
@@ -169,11 +169,14 @@ namespace pxsim.bluetooth {
|
|||||||
// TODO
|
// TODO
|
||||||
}
|
}
|
||||||
export function uartWrite(s : string): void {
|
export function uartWrite(s : string): void {
|
||||||
// TODO
|
serial.writeString(s)
|
||||||
}
|
}
|
||||||
export function uartReadUntil(del: string): string {
|
export function uartReadUntil(del: string): string {
|
||||||
// TODO
|
return serial.readUntil(del);
|
||||||
return ""
|
}
|
||||||
|
export function onDataReceived(delimiters: string, handler: RefAction) {
|
||||||
|
let b = board();
|
||||||
|
b.bus.listen(DAL.MICROBIT_ID_BLE_UART, DAL.MICROBIT_UART_S_EVT_DELIM_MATCH, handler);
|
||||||
}
|
}
|
||||||
export function onBluetoothConnected(a : RefAction) {
|
export function onBluetoothConnected(a : RefAction) {
|
||||||
// TODO
|
// TODO
|
||||||
@@ -181,5 +184,9 @@ namespace pxsim.bluetooth {
|
|||||||
export function onBluetoothDisconnected(a : RefAction) {
|
export function onBluetoothDisconnected(a : RefAction) {
|
||||||
// TODO
|
// TODO
|
||||||
}
|
}
|
||||||
|
export function advertiseUrl(url: string, power: number, connectable: boolean) { }
|
||||||
|
export function advertiseUidBuffer(nsAndInstance: Buffer, power: number, connectable: boolean) { }
|
||||||
|
export function stopAdvertising() { }
|
||||||
|
export function setTransmitPower(power: number) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||