Compare commits
35 Commits
Author | SHA1 | Date | |
---|---|---|---|
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 |
16
README.md
16
README.md
@ -1,9 +1,17 @@
|
||||
# Calliope target for PXT
|
||||
# Calliope target for Microsoft MakeCode
|
||||
|
||||
This target allow to program a [Calliope](http://calliope.cc/) using
|
||||
PXT ([Microsoft Programming Experience Toolkit](https://github.com/Microsoft/pxt)).
|
||||
This target is hosted at https://makecode.calliope.cc.
|
||||
|
||||
[](https://travis-ci.org/Microsoft/pxt-calliope)
|
||||
|
||||
## Hosted editor and build
|
||||
Hosted at: https://c371bd6d-007a-42fb-a45c-39891824b813.pxt.io</br>
|
||||
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
|
||||
|
||||

|
||||
|
||||
|
@ -2,10 +2,17 @@ import jobs.generation.Utilities;
|
||||
import jobs.generation.InternalUtilities;
|
||||
|
||||
def project = GithubProject
|
||||
def branch = GithubBranchName
|
||||
def projectName = "pxt-calliopemini"
|
||||
|
||||
[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) {
|
||||
steps {
|
||||
shell("chmod +x ./jenkins.sh")
|
||||
@ -15,14 +22,15 @@ def branch = GithubBranchName
|
||||
if (!isPR) {
|
||||
wrappers {
|
||||
credentialsBinding {
|
||||
string('PXT_ACCESS_TOKEN', 'pxt_access_token')
|
||||
string('PXT_RELEASE_REPO', 'pxt_release_repo_calliope')
|
||||
string("PXT_ACCESS_TOKEN", "pxt_access_token")
|
||||
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, "*/*")
|
||||
|
||||
if (isPR) {
|
||||
|
@ -13,6 +13,7 @@ echo isPR: $1
|
||||
|
||||
originRegex="^origin/.*"
|
||||
branchRegex="^origin/\K.*(?=$)"
|
||||
releaseBranchRegex="^(master|v\d+)$"
|
||||
|
||||
if [[ "$GIT_BRANCH" =~ $originRegex ]]; then
|
||||
branchName=$(echo ${GIT_BRANCH} | grep -oP $branchRegex)
|
||||
@ -27,9 +28,9 @@ if [ "$1" == "false" ]; then
|
||||
echo Setting TRAVIS_PULL_REQUEST to false
|
||||
export TRAVIS_PULL_REQUEST=false
|
||||
|
||||
if [ $TRAVIS_BRANCH == "master" ]; then
|
||||
if [[ "$TRAVIS_BRANCH" =~ $releaseBranchRegex ]]; then
|
||||
if [[ -z $PXT_RELEASE_REPO ]]; then
|
||||
echo Cannot find release repo; skipping tag checks
|
||||
echo Cannot find release repo\; skipping tag checks
|
||||
else
|
||||
gitTag=$(git describe --tags --exact-match 2> /dev/null)
|
||||
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
|
||||
|
||||
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
|
||||
export TRAVIS_BRANCH=$gitTag
|
||||
echo Setting TRAVIS_TAG to $gitTag
|
||||
|
@ -1,9 +1,26 @@
|
||||
{
|
||||
"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|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|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.startButtonService": "Starts the Bluetooth button service",
|
||||
"bluetooth.startIOPinService": "Starts the Bluetooth IO pin service.",
|
||||
@ -11,6 +28,7 @@
|
||||
"bluetooth.startMagnetometerService": "Starts the Bluetooth magnetometer service",
|
||||
"bluetooth.startTemperatureService": "Starts the Bluetooth temperature 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.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.",
|
||||
|
@ -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.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.startButtonService|block": "bluetooth button service",
|
||||
"bluetooth.startIOPinService|block": "bluetooth io pin service",
|
||||
@ -8,6 +12,7 @@
|
||||
"bluetooth.startMagnetometerService|block": "bluetooth magnetometer service",
|
||||
"bluetooth.startTemperatureService|block": "bluetooth temperature 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.uartWriteNumber|block": "bluetooth uart|write number %value",
|
||||
"bluetooth.uartWriteString|block": "bluetooth uart|write string %data",
|
||||
|
@ -7,7 +7,7 @@ using namespace pxt;
|
||||
/**
|
||||
* Support for additional Bluetooth services.
|
||||
*/
|
||||
//% color=#0082FB weight=20
|
||||
//% color=#0082FB weight=96 icon="\uf294"
|
||||
namespace bluetooth {
|
||||
MicroBitUARTService *uart = NULL;
|
||||
|
||||
@ -99,6 +99,18 @@ namespace bluetooth {
|
||||
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
|
||||
* @param body Code to run when a Bluetooth connection is established
|
||||
@ -120,4 +132,59 @@ namespace bluetooth {
|
||||
void onBluetoothDisconnected(Action 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.
|
||||
*/
|
||||
//% color=#0082FB weight=20 icon="\uf294"
|
||||
//% color=#0082FB weight=96 icon="\uf294"
|
||||
namespace bluetooth {
|
||||
/**
|
||||
* 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
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -25,12 +25,74 @@
|
||||
"advertising_timeout": 0,
|
||||
"tx_power": 6,
|
||||
"dfu_service": 1,
|
||||
"event_service": 0,
|
||||
"device_info_service": 1,
|
||||
"security_level": "SECURITY_MODE_ENCRYPTION_NO_MITM",
|
||||
"eddystone_url": 1,
|
||||
"eddystone_uid": 1
|
||||
}
|
||||
}
|
||||
},
|
||||
"optionalConfig": {
|
||||
"microbit-dal": {
|
||||
"bluetooth": {
|
||||
"private_addressing": 0,
|
||||
"advertising_timeout": 0,
|
||||
"tx_power": 6,
|
||||
"dfu_service": 1,
|
||||
"event_service": 1,
|
||||
"device_info_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"
|
||||
},
|
||||
"gatt_table_size": "0x700"
|
||||
}
|
||||
}
|
||||
},
|
||||
"userConfigs": [
|
||||
{
|
||||
"description": "Unsecure: Anyone can connect via Bluetooth.",
|
||||
"config": {
|
||||
"microbit-dal": {
|
||||
"bluetooth": {
|
||||
"open": 1,
|
||||
"pairing_mode": 0,
|
||||
"whitelist": 0,
|
||||
"security_level": null
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"description": "JustWorks pairing (default): Button press to pair.",
|
||||
"config": {
|
||||
"microbit-dal": {
|
||||
"bluetooth": {
|
||||
"open": null,
|
||||
"pairing_mode": null,
|
||||
"whitelist": null,
|
||||
"security_level": null
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"description": "Passkey pairing: Button press and 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"
|
||||
}
|
46
libs/bluetooth/shims.d.ts
vendored
46
libs/bluetooth/shims.d.ts
vendored
@ -4,7 +4,7 @@
|
||||
/**
|
||||
* Support for additional Bluetooth services.
|
||||
*/
|
||||
//% color=#0082FB weight=20
|
||||
//% color=#0082FB weight=96 icon="\uf294"
|
||||
declare namespace bluetooth {
|
||||
|
||||
/**
|
||||
@ -63,6 +63,14 @@ declare namespace bluetooth {
|
||||
//% parts="bluetooth" advanced=true shim=bluetooth::startUartService
|
||||
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
|
||||
* @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"
|
||||
//% parts="bluetooth" shim=bluetooth::onBluetoothDisconnected
|
||||
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.
|
||||
|
23
libs/calliope-i2c/i2c.ts
Normal file
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
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
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
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,126 @@
|
||||
{
|
||||
"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.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.max": "Returns the larger 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|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.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|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.",
|
||||
"String.charAt": "Returns the character at the specified index.",
|
||||
"String.charAt|param|index": "The zero-based index of the desired character.",
|
||||
"String.charCodeAt": "Returns the Unicode value of the character at the specified location.",
|
||||
"Number.toString": "Return a string representation of a number.",
|
||||
"String": "Combine, split, and search text strings.\n\nCombine, split, and search text strings.",
|
||||
"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.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.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.isEmpty": "Returns a value indicating if the string is empty",
|
||||
"String.length": "Returns the length of a String object.",
|
||||
"String.substr": "Return substring of the current string.",
|
||||
"String.substr|param|length": "number of characters to extract",
|
||||
"String.substr|param|start": "first character index; can be negative from counting from the end, eg:0",
|
||||
"String.length": "Return the length of a String object.",
|
||||
"String.substr": "Return a substring of the current string.",
|
||||
"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",
|
||||
"basic": "Provides access to basic micro:bit functionality.\n\nProvides access to basic micro:bit functionality.",
|
||||
"basic.clearScreen": "Turn off all LEDs",
|
||||
"basic.color": "Converts the color name to a number",
|
||||
@ -72,6 +167,58 @@
|
||||
"control.waitMicros": "Blocks the current fiber for the given microseconds",
|
||||
"control.waitMicros|param|micros": "number of micro-seconds to wait. eg: 4",
|
||||
"game": "A single-LED sprite game engine",
|
||||
"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": "TODO",
|
||||
"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. All further operation of the sprite will not have any effect.",
|
||||
"game.LedSprite.delete|param|sprite": "TODO",
|
||||
"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, then bounce away.",
|
||||
"game.LedSprite.isTouching": "Reports true if sprite is touching 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",
|
||||
"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": "TODO",
|
||||
"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|param|lives": "TODO",
|
||||
"game.addScore": "Adds points to the current score",
|
||||
@ -190,6 +337,7 @@
|
||||
"music.setTempo": "Sets the tempo to the specified amount",
|
||||
"music.setTempo|param|bpm": "The new tempo in beats per minute, eg: 120",
|
||||
"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.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",
|
||||
|
@ -7,6 +7,16 @@
|
||||
"AcceleratorRange.OneG|block": "1g",
|
||||
"AcceleratorRange.TwoG": "The accelerator measures forces up to 2 gravity",
|
||||
"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",
|
||||
"BaudRate.BaudRate115200|block": "115200",
|
||||
"BaudRate.BaudRate56700|block": "57600",
|
||||
"BaudRate.BaudRate9600|block": "9600",
|
||||
@ -101,12 +111,15 @@
|
||||
"IconNames.Triangle|block": "triangle",
|
||||
"IconNames.Umbrella|block": "umbrella",
|
||||
"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.Brightness|block": "brightness",
|
||||
"LedSpriteProperty.Direction|block": "direction",
|
||||
"LedSpriteProperty.X|block": "x",
|
||||
"LedSpriteProperty.Y|block": "y",
|
||||
"Math.randomBoolean|block": "pick random true or false",
|
||||
"Math.random|block": "pick random 0 to %limit",
|
||||
"Math|block": "Math",
|
||||
"Motor.AB|block": "A and B",
|
||||
"MotorCommand.Break|block": "break",
|
||||
@ -145,6 +158,7 @@
|
||||
"basic.pause|block": "pause (ms) %pause",
|
||||
"basic.rgbw|block": "red %red|green %green|blue %blue|white %white",
|
||||
"basic.setLedColor|block": "set led to %color=color_id",
|
||||
"basic.showArrow|block": "show arrow %i=device_arrow",
|
||||
"basic.showIcon|block": "show icon %i",
|
||||
"basic.showLeds|block": "show leds",
|
||||
"basic.showNumber|block": "show|number %number",
|
||||
@ -162,14 +176,25 @@
|
||||
"control.reset|block": "reset",
|
||||
"control.waitMicros|block": "wait (µs)%micros",
|
||||
"control|block": "control",
|
||||
"game.LedSprite.change|block": "%sprite|change %property|by %value",
|
||||
"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.createSprite|block": "create sprite at|x: %x|y: %y",
|
||||
"game.gameOver|block": "game over",
|
||||
"game.score|block": "score",
|
||||
"game.startCountdown|block": "start countdown|(ms) %duration",
|
||||
"game|block": "game",
|
||||
"images.arrowImage|block": "arrow image %i=device_arrow",
|
||||
"images.arrowNumber|block": "%arrow",
|
||||
"images.createBigImage|block": "create big image",
|
||||
"images.createImage|block": "create image",
|
||||
"images.iconImage|block": "icon image %i",
|
||||
"images|block": "images",
|
||||
"input.acceleration|block": "acceleration (mg)|%NAME",
|
||||
"input.buttonIsPressed|block": "button|%NAME|is pressed",
|
||||
@ -208,6 +233,7 @@
|
||||
"music.setTempo|block": "set tempo to (bpm)|%value",
|
||||
"music.tempo|block": "tempo (bpm)",
|
||||
"music|block": "music",
|
||||
"parseInt|block": "parse to integer %text",
|
||||
"pins.analogPitch|block": "analog pitch %frequency|for (ms) %ms",
|
||||
"pins.analogReadPin|block": "analog read|pin %name",
|
||||
"pins.analogSetPeriod|block": "analog set period|pin %pin|to (µs)%micros",
|
||||
@ -215,8 +241,8 @@
|
||||
"pins.analogWritePin|block": "analog write|pin %name|to %value",
|
||||
"pins.digitalReadPin|block": "digital read|pin %name",
|
||||
"pins.digitalWritePin|block": "digital write|pin %name|to %value",
|
||||
"pins.i2cReadNumber|block": "i2c read number|at address %address|of format %format=i2c_sizeof",
|
||||
"pins.i2cWriteNumber|block": "i2c write number|at address %address|with value %value|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|repeat %repeat",
|
||||
"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.pulseDuration|block": "pulse duration (µs)",
|
||||
@ -238,15 +264,23 @@
|
||||
"serial.writeString|block": "serial|write string %text",
|
||||
"serial.writeValue|block": "serial|write value %name|= %value",
|
||||
"serial|block": "serial",
|
||||
"{id:category}Array": "Array",
|
||||
"{id:category}Arrays": "Arrays",
|
||||
"{id:category}Basic": "Basic",
|
||||
"{id:category}Boolean": "Boolean",
|
||||
"{id:category}Buffer": "Buffer",
|
||||
"{id:category}Console": "Console",
|
||||
"{id:category}Control": "Control",
|
||||
"{id:category}Game": "Game",
|
||||
"{id:category}Helpers": "Helpers",
|
||||
"{id:category}Image": "Image",
|
||||
"{id:category}Images": "Images",
|
||||
"{id:category}Input": "Input",
|
||||
"{id:category}Led": "Led",
|
||||
"{id:category}Math": "Math",
|
||||
"{id:category}Motors": "Motors",
|
||||
"{id:category}Music": "Music",
|
||||
"{id:category}Number": "Number",
|
||||
"{id:category}Pins": "Pins",
|
||||
"{id:category}Serial": "Serial",
|
||||
"{id:category}String": "String",
|
||||
|
26
libs/core/dal.d.ts
vendored
26
libs/core/dal.d.ts
vendored
@ -81,6 +81,8 @@ declare const enum DAL {
|
||||
MICROBIT_BLE_MAXIMUM_BONDS = 4,
|
||||
MICROBIT_BLE_EDDYSTONE_ADV_INTERVAL = 400,
|
||||
MICROBIT_BLE_EDDYSTONE_DEFAULT_POWER = 0xF0,
|
||||
MICROBIT_BLE_STATUS_STORE_SYSATTR = 0x02,
|
||||
MICROBIT_BLE_STATUS_DISCONNECT = 0x04,
|
||||
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/MicroBitDFUService.h
|
||||
@ -207,10 +209,7 @@ declare const enum DAL {
|
||||
CALLIOPE_MAX_FREQUENCY_HZ_S = 20000,
|
||||
CALLIOPE_BOARD_FREQUENCY = 16000000,
|
||||
// built/yt/yotta_modules/microbit-dal/inc/drivers/DynamicPwm.h
|
||||
NO_PWMS = 3,
|
||||
MICROBIT_DEFAULT_PWM_PERIOD = 20000,
|
||||
PWM_PERSISTENCE_TRANSIENT = 1,
|
||||
PWM_PERSISTENCE_PERSISTENT = 2,
|
||||
// built/yt/yotta_modules/microbit-dal/inc/drivers/MicroBitAccelerometer-bmx.h
|
||||
BMX055_ACC_WHOAMI = 0x00,
|
||||
BMX055_ACC_D_X_LSB = 0x02,
|
||||
@ -421,10 +420,11 @@ declare const enum DAL {
|
||||
MICROBIT_ACCELEROMETER_EVT_FACE_UP = 5,
|
||||
MICROBIT_ACCELEROMETER_EVT_FACE_DOWN = 6,
|
||||
MICROBIT_ACCELEROMETER_EVT_FREEFALL = 7,
|
||||
MICROBIT_ACCELEROMETER_EVT_3G = 8,
|
||||
MICROBIT_ACCELEROMETER_EVT_6G = 9,
|
||||
MICROBIT_ACCELEROMETER_EVT_8G = 10,
|
||||
MICROBIT_ACCELEROMETER_EVT_SHAKE = 11,
|
||||
MICROBIT_ACCELEROMETER_EVT_2G = 8,
|
||||
MICROBIT_ACCELEROMETER_EVT_3G = 9,
|
||||
MICROBIT_ACCELEROMETER_EVT_6G = 10,
|
||||
MICROBIT_ACCELEROMETER_EVT_8G = 11,
|
||||
MICROBIT_ACCELEROMETER_EVT_SHAKE = 12,
|
||||
MICROBIT_ACCELEROMETER_REST_TOLERANCE = 200,
|
||||
MICROBIT_ACCELEROMETER_TILT_TOLERANCE = 200,
|
||||
MICROBIT_ACCELEROMETER_FREEFALL_TOLERANCE = 400,
|
||||
@ -438,6 +438,7 @@ declare const enum DAL {
|
||||
MICROBIT_ACCELEROMETER_SHAKE_RTX = 30,
|
||||
MICROBIT_ACCELEROMETER_SHAKE_COUNT_THRESHOLD = 4,
|
||||
// built/yt/yotta_modules/microbit-dal/inc/drivers/MicroBitAccelerometer.h
|
||||
MMA8653_DEFAULT_ADDR = 0x3A,
|
||||
// built/yt/yotta_modules/microbit-dal/inc/drivers/MicroBitButton.h
|
||||
MICROBIT_BUTTON_EVT_DOWN = 1,
|
||||
MICROBIT_BUTTON_EVT_UP = 2,
|
||||
@ -458,7 +459,7 @@ declare const enum DAL {
|
||||
MICROBIT_BUTTON_DOUBLE_CLICK_THRESH = 50,
|
||||
MICROBIT_BUTTON_SIMPLE_EVENTS = 0,
|
||||
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,
|
||||
MAG_DR_STATUS = 0x00,
|
||||
MAG_OUT_X_MSB = 0x01,
|
||||
@ -489,6 +490,7 @@ declare const enum DAL {
|
||||
MICROBIT_COMPASS_STATUS_CALIBRATING = 4,
|
||||
MICROBIT_COMPASS_STATUS_ADDED_TO_IDLE = 8,
|
||||
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/MicroBitDisplay.h
|
||||
MICROBIT_DISPLAY_EVT_ANIMATION_COMPLETE = 1,
|
||||
@ -579,8 +581,12 @@ declare const enum DAL {
|
||||
MICROBIT_PIN_EVT_FALL = 3,
|
||||
MICROBIT_PIN_EVT_PULSE_HI = 4,
|
||||
MICROBIT_PIN_EVT_PULSE_LO = 5,
|
||||
PIN_CAPABILITY_DIGITAL = 0x01,
|
||||
PIN_CAPABILITY_ANALOG = 0x02,
|
||||
PIN_CAPABILITY_DIGITAL_IN = 0x01,
|
||||
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
|
||||
MICROBIT_RADIO_STATUS_INITIALISED = 0x0001,
|
||||
MICROBIT_RADIO_BASE_ADDRESS = 0x75626974,
|
||||
|
48
libs/core/enums.d.ts
vendored
48
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
|
||||
B = 2, // MICROBIT_ID_BUTTON_B
|
||||
//% block="A+B"
|
||||
@ -13,7 +13,7 @@ declare namespace basic {
|
||||
}
|
||||
|
||||
|
||||
declare enum Dimension {
|
||||
declare const enum Dimension {
|
||||
//% block=x
|
||||
X = 0,
|
||||
//% block=y
|
||||
@ -25,7 +25,7 @@ declare namespace basic {
|
||||
}
|
||||
|
||||
|
||||
declare enum Rotation {
|
||||
declare const enum Rotation {
|
||||
//% block=pitch
|
||||
Pitch = 0,
|
||||
//% block=roll
|
||||
@ -33,7 +33,7 @@ declare namespace basic {
|
||||
}
|
||||
|
||||
|
||||
declare enum TouchPin {
|
||||
declare const enum TouchPin {
|
||||
P0 = 19, // MICROBIT_ID_IO_P12
|
||||
P1 = 7, // MICROBIT_ID_IO_P0
|
||||
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
|
||||
*/
|
||||
@ -65,12 +65,12 @@ declare namespace basic {
|
||||
}
|
||||
|
||||
|
||||
declare enum Gesture {
|
||||
declare const enum Gesture {
|
||||
/**
|
||||
* Raised when shaken
|
||||
*/
|
||||
//% 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
|
||||
*/
|
||||
@ -110,12 +110,12 @@ declare namespace basic {
|
||||
* Raised when a 3G shock is detected
|
||||
*/
|
||||
//% block="3g"
|
||||
ThreeG = 8, // MICROBIT_ACCELEROMETER_EVT_3G
|
||||
ThreeG = 9, // MICROBIT_ACCELEROMETER_EVT_3G
|
||||
/**
|
||||
* Raised when a 6G shock is detected
|
||||
*/
|
||||
//% block="6g"
|
||||
SixG = 9, // MICROBIT_ACCELEROMETER_EVT_6G
|
||||
SixG = 10, // MICROBIT_ACCELEROMETER_EVT_6G
|
||||
}
|
||||
declare namespace input {
|
||||
}
|
||||
@ -125,7 +125,7 @@ declare namespace input {
|
||||
* How to create the event.
|
||||
*/
|
||||
|
||||
declare enum EventCreationMode {
|
||||
declare const enum EventCreationMode {
|
||||
/**
|
||||
* MicroBitEvent is initialised, and no further processing takes place.
|
||||
*/
|
||||
@ -137,7 +137,7 @@ declare namespace input {
|
||||
}
|
||||
|
||||
|
||||
declare enum EventBusSource {
|
||||
declare const enum EventBusSource {
|
||||
MICROBIT_ID_BUTTON_A = 1, // MICROBIT_ID_BUTTON_A
|
||||
MICROBIT_ID_BUTTON_B = 2, // MICROBIT_ID_BUTTON_B
|
||||
MICROBIT_ID_BUTTON_AB = 26, // MICROBIT_ID_BUTTON_AB
|
||||
@ -171,7 +171,7 @@ declare namespace input {
|
||||
}
|
||||
|
||||
|
||||
declare enum EventBusValue {
|
||||
declare const enum EventBusValue {
|
||||
MICROBIT_EVT_ANY = 0, // MICROBIT_EVT_ANY
|
||||
MICROBIT_BUTTON_EVT_CLICK = 3, // MICROBIT_BUTTON_EVT_CLICK
|
||||
MICROBIT_RADIO_EVT_DATAGRAM = 1, // MICROBIT_RADIO_EVT_DATAGRAM
|
||||
@ -236,7 +236,7 @@ declare namespace control {
|
||||
}
|
||||
|
||||
|
||||
declare enum DisplayMode {
|
||||
declare const enum DisplayMode {
|
||||
//% block="black and white"
|
||||
BackAndWhite = 0, // DISPLAY_MODE_BLACK_AND_WHITE
|
||||
//% block="greyscale"
|
||||
@ -247,7 +247,7 @@ declare namespace led {
|
||||
}
|
||||
|
||||
|
||||
declare enum MotorCommand {
|
||||
declare const enum MotorCommand {
|
||||
//% block=coast
|
||||
Coast = 0,
|
||||
//% block=break
|
||||
@ -257,7 +257,7 @@ declare namespace led {
|
||||
}
|
||||
|
||||
|
||||
declare enum Motor {
|
||||
declare const enum Motor {
|
||||
A = 0,
|
||||
B = 1,
|
||||
//% block="A and B"
|
||||
@ -267,7 +267,7 @@ declare namespace motors {
|
||||
}
|
||||
|
||||
|
||||
declare enum DigitalPin {
|
||||
declare const enum DigitalPin {
|
||||
P0 = 19, // MICROBIT_ID_IO_P12
|
||||
P1 = 7, // MICROBIT_ID_IO_P0
|
||||
P2 = 8, // MICROBIT_ID_IO_P1
|
||||
@ -288,7 +288,7 @@ declare namespace motors {
|
||||
}
|
||||
|
||||
|
||||
declare enum AnalogPin {
|
||||
declare const enum AnalogPin {
|
||||
P1 = 7, // MICROBIT_ID_IO_P0
|
||||
P2 = 8, // MICROBIT_ID_IO_P1
|
||||
C4 = 10, // MICROBIT_ID_IO_P3
|
||||
@ -300,13 +300,13 @@ declare namespace motors {
|
||||
}
|
||||
|
||||
|
||||
declare enum PulseValue {
|
||||
declare const enum PulseValue {
|
||||
High = 4, // MICROBIT_PIN_EVT_PULSE_HI
|
||||
Low = 5, // MICROBIT_PIN_EVT_PULSE_LO
|
||||
}
|
||||
|
||||
|
||||
declare enum PinPullMode {
|
||||
declare const enum PinPullMode {
|
||||
//% block="down"
|
||||
PullDown = 0,
|
||||
//% block="up"
|
||||
@ -316,7 +316,7 @@ declare namespace motors {
|
||||
}
|
||||
|
||||
|
||||
declare enum PinEventType {
|
||||
declare const enum PinEventType {
|
||||
//% block="edge"
|
||||
Edge = 1, // MICROBIT_PIN_EVENT_ON_EDGE
|
||||
//% block="pulse"
|
||||
@ -328,7 +328,7 @@ declare namespace motors {
|
||||
}
|
||||
|
||||
|
||||
declare enum SerialPin {
|
||||
declare const enum SerialPin {
|
||||
C16 = 9, // MICROBIT_ID_IO_P2
|
||||
C17 = 15, // MICROBIT_ID_IO_P8
|
||||
P0 = 19, // MICROBIT_ID_IO_P12
|
||||
@ -338,7 +338,7 @@ declare namespace motors {
|
||||
}
|
||||
|
||||
|
||||
declare enum BaudRate {
|
||||
declare const enum BaudRate {
|
||||
//% block=115200
|
||||
BaudRate115200 = 115200,
|
||||
//% block=57600
|
||||
@ -348,7 +348,7 @@ declare namespace motors {
|
||||
}
|
||||
|
||||
|
||||
declare enum Delimiters {
|
||||
declare const enum Delimiters {
|
||||
//% block="new line"
|
||||
NewLine = 1,
|
||||
//% block=","
|
||||
@ -366,7 +366,7 @@ declare namespace serial {
|
||||
}
|
||||
|
||||
|
||||
declare enum NumberFormat {
|
||||
declare const enum NumberFormat {
|
||||
Int8LE = 1,
|
||||
UInt8LE = 2,
|
||||
Int16LE = 3,
|
||||
|
@ -206,6 +206,17 @@ namespace pins {
|
||||
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).
|
||||
* @param name pin to write to
|
||||
@ -215,6 +226,7 @@ namespace pins {
|
||||
//% blockId=device_set_servo_pin block="servo write|pin %name|to %value" blockGap=8
|
||||
//% parts=microservo trackArgs=0
|
||||
void servoWritePin(AnalogPin name, int value) {
|
||||
fixMotorIssue(name);
|
||||
PINOP(setServoValue(value));
|
||||
}
|
||||
|
||||
@ -226,6 +238,7 @@ namespace pins {
|
||||
//% help=pins/servo-set-pulse weight=19
|
||||
//% blockId=device_set_servo_pulse block="servo set pulse|pin %value|to (µs) %micros"
|
||||
void servoSetPulse(AnalogPin name, int micros) {
|
||||
fixMotorIssue(name);
|
||||
PINOP(setServoPulseUs(micros));
|
||||
}
|
||||
|
||||
|
@ -22,9 +22,9 @@ namespace pins {
|
||||
* Read one number from 7-bit I2C address.
|
||||
*/
|
||||
//% 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
|
||||
export function i2cReadNumber(address: number, format: NumberFormat): number {
|
||||
let buf = pins.i2cReadBuffer(address, pins.sizeOf(format))
|
||||
//% 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, repeat?: boolean): number {
|
||||
let buf = pins.i2cReadBuffer(address, pins.sizeOf(format), repeat)
|
||||
return buf.getNumber(format, 0)
|
||||
}
|
||||
|
||||
@ -32,11 +32,11 @@ namespace pins {
|
||||
* Write one number to a 7-bit I2C address.
|
||||
*/
|
||||
//% 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
|
||||
export function i2cWriteNumber(address: number, value: number, format: NumberFormat): void {
|
||||
//% 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, repeat?: boolean): void {
|
||||
let buf = createBuffer(pins.sizeOf(format))
|
||||
buf.setNumber(format, 0, value)
|
||||
pins.i2cWriteBuffer(address, buf)
|
||||
pins.i2cWriteBuffer(address, buf, repeat)
|
||||
}
|
||||
|
||||
/**
|
||||
|
10
libs/devices/enums.d.ts
vendored
10
libs/devices/enums.d.ts
vendored
@ -1,7 +1,7 @@
|
||||
// Auto-generated. Do not edit.
|
||||
|
||||
|
||||
declare enum MesCameraEvent {
|
||||
declare const enum MesCameraEvent {
|
||||
//% block="take photo"
|
||||
TakePhoto = 3, // MES_CAMERA_EVT_TAKE_PHOTO
|
||||
//% block="start video capture"
|
||||
@ -21,7 +21,7 @@
|
||||
}
|
||||
|
||||
|
||||
declare enum MesAlertEvent {
|
||||
declare const enum MesAlertEvent {
|
||||
//% block="display toast"
|
||||
DisplayToast = 1, // MES_ALERT_EVT_DISPLAY_TOAST
|
||||
//% block="vibrate"
|
||||
@ -47,7 +47,7 @@
|
||||
}
|
||||
|
||||
|
||||
declare enum MesDeviceInfo {
|
||||
declare const enum MesDeviceInfo {
|
||||
//% block="incoming call"
|
||||
IncomingCall = 7, // MES_DEVICE_INCOMING_CALL
|
||||
//% block="incoming message"
|
||||
@ -65,7 +65,7 @@
|
||||
}
|
||||
|
||||
|
||||
declare enum MesRemoteControlEvent {
|
||||
declare const enum MesRemoteControlEvent {
|
||||
//% block="play"
|
||||
play = 1, // MES_REMOTE_CONTROL_EVT_PLAY
|
||||
//% block="pause"
|
||||
@ -87,7 +87,7 @@
|
||||
}
|
||||
|
||||
|
||||
declare enum MesDpadButtonInfo {
|
||||
declare const enum MesDpadButtonInfo {
|
||||
//% block="A down"
|
||||
ADown = 1, // MES_DPAD_BUTTON_A_DOWN
|
||||
//% block="A up"
|
||||
|
@ -1,5 +1,10 @@
|
||||
{
|
||||
"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.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.",
|
||||
|
3493
package-lock.json
generated
Normal file
3493
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "pxt-calliope",
|
||||
"version": "1.0.8",
|
||||
"version": "1.0.14",
|
||||
"description": "Calliope Mini editor for PXT",
|
||||
"keywords": [
|
||||
"JavaScript",
|
||||
@ -31,10 +31,12 @@
|
||||
"devDependencies": {
|
||||
"typescript": "^1.8.7",
|
||||
"less": "^2.6.0",
|
||||
"rtlcss": "^2.1.2",
|
||||
"autoprefixer": "^6.7.6",
|
||||
"semantic-ui-less": "^2.2.4"
|
||||
},
|
||||
"dependencies": {
|
||||
"pxt-core": "0.11.55"
|
||||
"pxt-core": "0.14.32"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "node node_modules/pxt-core/built/pxt.js travis"
|
||||
|
@ -1,8 +1,8 @@
|
||||
{
|
||||
"id": "calliope",
|
||||
"name": " calliope",
|
||||
"id": "calliopemini",
|
||||
"name": " calliope 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.",
|
||||
"corepkg": "core",
|
||||
"bundleddirs": [
|
||||
@ -15,9 +15,7 @@
|
||||
"workspace": false,
|
||||
"packages": true,
|
||||
"sharing": true,
|
||||
"publishing": true,
|
||||
"preferredPackages": [
|
||||
],
|
||||
"publishing": false,
|
||||
"githubPackages": true
|
||||
},
|
||||
"compile": {
|
||||
@ -171,7 +169,7 @@
|
||||
"yottaTarget": "calliope-mini-classic-gcc",
|
||||
"yottaCorePackage": "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"
|
||||
},
|
||||
"serial": {
|
||||
@ -189,49 +187,24 @@
|
||||
"footerLogo": "./static/Calliopeminieditor.svg",
|
||||
"cardLogo": "./static/icons/apple-touch-icon.png",
|
||||
"appLogo": "./static/icons/apple-touch-icon.png",
|
||||
"homeUrl": "https://calliope.cc/",
|
||||
"embedUrl": "https://mini.pxt.io/",
|
||||
"homeUrl": "https://makecode.calliope.cc/",
|
||||
"embedUrl": "https://makecode.calliope.cc/",
|
||||
"privacyUrl": "https://go.microsoft.com/fwlink/?LinkId=521839",
|
||||
"termsOfUseUrl": "https://go.microsoft.com/fwlink/?LinkID=206977",
|
||||
"githubUrl": "https://github.com/Microsoft/pxt-calliope",
|
||||
"crowdinProject": "kindscript",
|
||||
"organization": "Microsoft",
|
||||
"organizationUrl": "https://pxt.io/",
|
||||
"organization": "Microsoft MakeCode",
|
||||
"organizationUrl": "https://makecode.com/",
|
||||
"organizationLogo": "./static/Microsoft-logo_rgb_c-gray-square.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",
|
||||
"driveDisplayName": "MINI",
|
||||
"hideSideDocs": true,
|
||||
"invertedMenu": true,
|
||||
"invertedToolbox": true,
|
||||
"monacoToolbox": false,
|
||||
"hasAudio": true,
|
||||
"hasAudio": true,
|
||||
"highContrast": true,
|
||||
"simAnimationEnter": "rotate in",
|
||||
"simAnimationExit": "rotate out",
|
||||
"blocklyOptions": {
|
||||
@ -241,6 +214,9 @@
|
||||
"colour": "rgba(189, 195, 199, 0.30)",
|
||||
"snap": false
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"docMenu": [],
|
||||
"hasReferenceDocs": false
|
||||
},
|
||||
"ignoreDocsErrors": true
|
||||
}
|
||||
|
@ -98,7 +98,7 @@ namespace pxsim {
|
||||
break;
|
||||
case "radiopacket":
|
||||
let packet = <SimulatorRadioPacketMessage>msg;
|
||||
this.radioState.recievePacket(packet);
|
||||
this.radioState.receivePacket(packet);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -169,11 +169,14 @@ namespace pxsim.bluetooth {
|
||||
// TODO
|
||||
}
|
||||
export function uartWrite(s : string): void {
|
||||
// TODO
|
||||
serial.writeString(s)
|
||||
}
|
||||
export function uartReadUntil(del: string): string {
|
||||
// TODO
|
||||
return ""
|
||||
return serial.readUntil(del);
|
||||
}
|
||||
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) {
|
||||
// TODO
|
||||
@ -181,5 +184,9 @@ namespace pxsim.bluetooth {
|
||||
export function onBluetoothDisconnected(a : RefAction) {
|
||||
// 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) {}
|
||||
}
|
||||
|
||||
|
@ -4,7 +4,7 @@ namespace pxsim {
|
||||
if (b) {
|
||||
let np = b.neopixelState;
|
||||
if (np) {
|
||||
let buf = <Uint8Array[]>(<any>buffer).data;
|
||||
let buf = <Uint8Array>(<any>buffer).data;
|
||||
np.updateBuffer(buf, pin);
|
||||
runtime.queueDisplayUpdate();
|
||||
}
|
||||
|
@ -21,11 +21,12 @@ namespace pxsim {
|
||||
}
|
||||
|
||||
send(payload: SimulatorRadioPacketPayload) {
|
||||
const b = board();
|
||||
Runtime.postMessage(<SimulatorRadioPacketMessage>{
|
||||
type: "radiopacket",
|
||||
rssi: 0, // Not yet supported
|
||||
serial: board().radioState.bus.transmitSerialNumber ? board().radioState.bus.serial : 0,
|
||||
time: 0, // Not yet supported
|
||||
rssi: 70, // Not yet supported
|
||||
serial: b.radioState.bus.transmitSerialNumber ? pxsim.control.deviceSerialNumber() : 0,
|
||||
time: new Date().getTime(),
|
||||
payload
|
||||
})
|
||||
}
|
||||
@ -41,26 +42,19 @@ namespace pxsim {
|
||||
rssi: -1,
|
||||
serial: 0,
|
||||
time: 0,
|
||||
payload: { type: -1 }
|
||||
payload: { type: -1, groupId: 0 }
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export class RadioBus {
|
||||
// uint8_t radioDefaultGroup = MICROBIT_RADIO_DEFAULT_GROUP;
|
||||
groupId = 0; // todo
|
||||
power = 0;
|
||||
serial = 0;
|
||||
transmitSerialNumber = false;
|
||||
datagram: RadioDatagram;
|
||||
|
||||
constructor(private runtime: Runtime) {
|
||||
this.datagram = new RadioDatagram(runtime);
|
||||
this.serial = Math.floor(Math.random() * Math.pow(2, 32)) - Math.pow(2, 31); // 32 bit signed integer
|
||||
}
|
||||
|
||||
setGroup(id: number) {
|
||||
this.groupId = id & 0xff; // byte only
|
||||
}
|
||||
|
||||
setTransmitPower(power: number) {
|
||||
@ -71,26 +65,37 @@ namespace pxsim {
|
||||
this.transmitSerialNumber = !!sn;
|
||||
}
|
||||
|
||||
broadcast(msg: number) {
|
||||
broadcast(msg: number, groupId: number) {
|
||||
Runtime.postMessage(<SimulatorEventBusMessage>{
|
||||
type: "eventbus",
|
||||
id: DAL.MES_BROADCAST_GENERAL_ID,
|
||||
eventid: msg,
|
||||
power: this.power,
|
||||
group: this.groupId
|
||||
group: groupId
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
export class RadioState {
|
||||
bus: RadioBus;
|
||||
groupId: number;
|
||||
|
||||
constructor(runtime: Runtime) {
|
||||
this.bus = new RadioBus(runtime);
|
||||
this.groupId = 0;
|
||||
}
|
||||
|
||||
public recievePacket(packet: SimulatorRadioPacketMessage) {
|
||||
this.bus.datagram.queue(packet)
|
||||
public setGroup(id: number) {
|
||||
this.groupId = id & 0xff; // byte only
|
||||
}
|
||||
|
||||
public broadcast(msg: number) {
|
||||
this.bus.broadcast(msg, this.groupId)
|
||||
}
|
||||
|
||||
public receivePacket(packet: SimulatorRadioPacketMessage) {
|
||||
if (this.groupId == packet.payload.groupId)
|
||||
this.bus.datagram.queue(packet)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -103,7 +108,7 @@ namespace pxsim.radio {
|
||||
}
|
||||
|
||||
export function broadcastMessage(msg: number): void {
|
||||
board().radioState.bus.broadcast(msg);
|
||||
board().radioState.broadcast(msg);
|
||||
}
|
||||
|
||||
export function onBroadcastMessageReceived(msg: number, handler: RefAction): void {
|
||||
@ -111,7 +116,7 @@ namespace pxsim.radio {
|
||||
}
|
||||
|
||||
export function setGroup(id: number): void {
|
||||
board().radioState.bus.setGroup(id);
|
||||
board().radioState.setGroup(id);
|
||||
}
|
||||
|
||||
export function setTransmitPower(power: number): void {
|
||||
@ -125,7 +130,8 @@ namespace pxsim.radio {
|
||||
export function sendNumber(value: number): void {
|
||||
board().radioState.bus.datagram.send({
|
||||
type: PacketPayloadType.NUMBER,
|
||||
numberData: value
|
||||
groupId: board().radioState.groupId,
|
||||
numberData: value,
|
||||
});
|
||||
}
|
||||
|
||||
@ -133,7 +139,8 @@ namespace pxsim.radio {
|
||||
msg = msg.substr(0, 19);
|
||||
board().radioState.bus.datagram.send({
|
||||
type: PacketPayloadType.STRING,
|
||||
stringData: msg
|
||||
groupId: board().radioState.groupId,
|
||||
stringData: msg,
|
||||
});
|
||||
}
|
||||
|
||||
@ -153,6 +160,7 @@ namespace pxsim.radio {
|
||||
msg.push()
|
||||
board().radioState.bus.datagram.send({
|
||||
type: PacketPayloadType.VALUE,
|
||||
groupId: board().radioState.groupId,
|
||||
stringData: name,
|
||||
numberData: value
|
||||
});
|
||||
@ -186,7 +194,7 @@ namespace pxsim.radio {
|
||||
}
|
||||
|
||||
export function receivedString(): string {
|
||||
return board().radioState.bus.datagram.lastReceived.payload.stringData || "";
|
||||
return initString(board().radioState.bus.datagram.lastReceived.payload.stringData || "");
|
||||
}
|
||||
|
||||
export function receivedTime(): number {
|
||||
|
@ -1386,11 +1386,13 @@ namespace pxsim.visuals {
|
||||
let state = this.board;
|
||||
if (!state || !state.accelerometerState.accelerometer.isActive) return;
|
||||
|
||||
let x = state.accelerometerState.accelerometer.getX();
|
||||
let y = -state.accelerometerState.accelerometer.getY();
|
||||
let af = 8 / 1023;
|
||||
const x = state.accelerometerState.accelerometer.getX();
|
||||
const y = -state.accelerometerState.accelerometer.getY();
|
||||
const af = 8 / 1023;
|
||||
const s = 1 - Math.min(0.1, Math.pow(Math.max(Math.abs(x), Math.abs(y)) / 1023, 2) / 35);
|
||||
|
||||
this.element.style.transform = "perspective(30em) rotateX(" + y * af + "deg) rotateY(" + x * af + "deg)"
|
||||
this.element.style.transform = `perspective(30em) rotateX(${y * af}deg) rotateY(${x * af}deg) scale(${s}, ${s})`
|
||||
|
||||
this.element.style.perspectiveOrigin = "50% 50% 50%";
|
||||
this.element.style.perspective = "30em";
|
||||
}
|
||||
|
@ -2,10 +2,22 @@
|
||||
"packages": {
|
||||
"approvedOrgs": [
|
||||
"Microsoft",
|
||||
"microbit-foundation"
|
||||
"microbit-foundation",
|
||||
"calliope-mini",
|
||||
"ubirch"
|
||||
],
|
||||
"approvedRepos": [
|
||||
"CoderDojoOlney/pxt-olney"
|
||||
"CoderDojoOlney/pxt-olney",
|
||||
"Tinkertanker/pxt-ssd1306-microbit"
|
||||
],
|
||||
"preferredRepos": [
|
||||
"calliope-mini/pxt-calliope-modem",
|
||||
"calliope-mini/pxt-calliope-bc95",
|
||||
"calliope-mini/pxt-calliope-esp",
|
||||
"calliope-mini/pxt-calliope-bunt",
|
||||
"calliope-mini/pxt-isl29125",
|
||||
"ubirch/pxt-ubirch",
|
||||
"Tinkertanker/pxt-ssd1306-microbit"
|
||||
]
|
||||
}
|
||||
}
|
4
tests/i2c.ts
Normal file
4
tests/i2c.ts
Normal file
@ -0,0 +1,4 @@
|
||||
let item = pins.i2cReadNumber(123, NumberFormat.Int8LE)
|
||||
pins.i2cWriteNumber(123, 0, NumberFormat.Int8LE)
|
||||
let item = pins.i2cReadNumber(123, NumberFormat.Int8LE, true)
|
||||
pins.i2cWriteNumber(123, 0, NumberFormat.Int8LE, true)
|
73
theme/blockly.less
Normal file
73
theme/blockly.less
Normal file
@ -0,0 +1,73 @@
|
||||
@import 'themes/default/globals/site.variables';
|
||||
@import 'themes/pxt/globals/site.variables';
|
||||
@import 'site/globals/site.variables';
|
||||
|
||||
@import 'blockly-core';
|
||||
|
||||
/* Reference import */
|
||||
@import (reference) "semantic.less";
|
||||
|
||||
/*******************************
|
||||
Blockly
|
||||
*******************************/
|
||||
|
||||
div.blocklyTreeRow {
|
||||
box-shadow: inset 0 -1px 0 0 #ecf0f1;
|
||||
|
||||
margin-bottom: 0px !important;
|
||||
|
||||
-webkit-transition-property: background-color; /* Safari */
|
||||
-webkit-transition-duration: 1s; /* Safari */
|
||||
transition-property: background-color;
|
||||
transition-duration: 1s;
|
||||
}
|
||||
|
||||
/* Blockly toolbox font size same as the page font */
|
||||
span.blocklyTreeLabel {
|
||||
font-family: @pageFont !important;
|
||||
font-weight: 200;
|
||||
}
|
||||
|
||||
.blocklyToolboxDiv, .monacoToolboxDiv {
|
||||
background-color: white !important;
|
||||
border-left: 1px solid #ecf0f1 !important;
|
||||
box-shadow: 4px 0px 2px -4px rgba(0,0,0,0.12), 4px 0px 2px -4px rgba(0,0,0,0.24);
|
||||
}
|
||||
|
||||
.blocklyFlyoutBackground {
|
||||
fill: #525A67 !important;
|
||||
}
|
||||
|
||||
/* Remove shadow around blockly blocks */
|
||||
.blocklyPathDark, .blocklyPathLight {
|
||||
display: none;
|
||||
}
|
||||
|
||||
/* Blockly Field: Grid picker */
|
||||
.blocklyGridPickerTooltip {
|
||||
padding: 3px 5px;
|
||||
background-color: #fefefe;
|
||||
border: black solid 3px;
|
||||
color: black;
|
||||
border-radius: 10px;
|
||||
}
|
||||
|
||||
/* Mobile */
|
||||
@media only screen and (max-width: @largestMobileScreen) {
|
||||
.blocklyToolboxDiv, .monacoToolboxDiv {
|
||||
border-left: 0 !important;
|
||||
}
|
||||
div.blocklyTreeRoot {
|
||||
padding: 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* Tablet */
|
||||
@media only screen and (min-width: @tabletBreakpoint) and (max-width: @largestTabletScreen) {
|
||||
.blocklyToolboxDiv, .monacoToolboxDiv {
|
||||
border-left: 0 !important;
|
||||
}
|
||||
div.blocklyTreeRoot {
|
||||
padding: 0;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user