Compare commits
68 Commits
Author | SHA1 | Date | |
---|---|---|---|
b504abc6da | |||
6dbfb9e96e | |||
d1021a30ca | |||
8d37be7cbe | |||
97066e1ba4 | |||
097564748c | |||
d873cbb6c3 | |||
adef3a6487 | |||
be0984cc4a | |||
f0947cddaa | |||
c5c5362b5d | |||
bcbbb1366a | |||
19fb5ecf01 | |||
0401aa60d2 | |||
e0c016fbf4 | |||
f046f0e50c | |||
90f48ac77a | |||
23f83df6df | |||
98e4f80399 | |||
b1fcc51bc8 | |||
63e24ce90a | |||
63d0b86508 | |||
672f3b94ca | |||
f0b91b07c1 | |||
2923d045b1 | |||
3cf36b4549 | |||
a42aa553e6 | |||
b12598e421 | |||
9a85075456 | |||
ce7b630870 | |||
9ac308da92 | |||
6315ca90e5 | |||
ecfe0a7f16 | |||
f701bca23f | |||
7313c76e8b | |||
77003b30f2 | |||
274bb9e042 | |||
e316f068e2 | |||
c75e77593a | |||
ecbf8409ea | |||
411fe52813 | |||
0d04376413 | |||
5deffe832c | |||
528f696b8c | |||
dfb5f7dd11 | |||
a4fb934a18 | |||
59b11ec2a9 | |||
d961e14e5c | |||
83c8c07b94 | |||
152f84cd79 | |||
ef58b54fdb | |||
50e2f3fa94 | |||
14f4e6092a | |||
f7a005c656 | |||
7e19fbb3ca | |||
e706809037 | |||
5d6bc2f5df | |||
22433317b9 | |||
fabf09477c | |||
f9e0fe1b8d | |||
c49fb27d4c | |||
24b20543c5 | |||
be97665ea2 | |||
657cdeb53e | |||
08575d352b | |||
c9ba7af3f3 | |||
917072a336 | |||
fd5357b273 |
26
CONTRIBUTING.md
Normal file
26
CONTRIBUTING.md
Normal file
@ -0,0 +1,26 @@
|
||||
# Contributing Code
|
||||
|
||||
PXT accepts bug fix pull requests. For a bug fix PR to be accepted, it must first have a tracking issue that has been marked approved. Your PR should link to the bug you are fixing. If you've submitted a PR for a bug, please post a comment in the bug to avoid duplication of effort.
|
||||
|
||||
PXT also accepts new feature pull requests. For a feature-level PR to be accepted, it first needs to have design discussion. Design discussion can take one of two forms a) a feature request in the issue tracker that has been marked as approved or b) the PR must be accompanied by a full design spec and this spec is later approved in the open design discussion. Features are evaluated against their complexity, impact on other features, roadmap alignment, and maintainability.
|
||||
|
||||
These two blogs posts on contributing code to open source projects are a good reference: [Open Source Contribution Etiquette](http://tirania.org/blog/archive/2010/Dec-31.html) by Miguel de Icaza and [Don't "Push" Your Pull Requests](https://www.igvita.com/2011/12/19/dont-push-your-pull-requests/) by Ilya Grigorik.
|
||||
|
||||
## Security
|
||||
|
||||
If you believe you have found a security issue in PXT, please share it with us privately following the guidance at the Microsoft [Security TechCenter](https://technet.microsoft.com/en-us/security/ff852094). Reporting it via this channel helps minimize risk to projects built with PXT.
|
||||
|
||||
## Legal
|
||||
|
||||
You will need to complete a Contributor License Agreement (CLA) before your pull request can be accepted. This agreement testifies that you are granting us permission to use the source code you are submitting, and that this work is being submitted under appropriate license that we can use it.
|
||||
|
||||
You can complete the CLA by going through the steps at https://cla.microsoft.com. Once we have received the signed CLA, we'll review the request. You will only need to do this once.
|
||||
|
||||
## Housekeeping
|
||||
|
||||
Your pull request should:
|
||||
* Include a description of what your change intends to do
|
||||
* Be a child commit of a reasonably recent commit in the master branch
|
||||
* Pass all unit tests
|
||||
* Have a clear commit message
|
||||
* Include adequate tests
|
25
LICENSE.txt
Normal file
25
LICENSE.txt
Normal file
@ -0,0 +1,25 @@
|
||||
PXT - Programming Experience Toolkit
|
||||
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) Microsoft Corporation
|
||||
|
||||
All rights reserved.
|
||||
|
||||
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.
|
@ -1,4 +1,5 @@
|
||||
/// <reference path="../node_modules/pxt-core/built/pxt.d.ts"/>
|
||||
/// <reference path="../node_modules/pxt-core/typings/node/node.d.ts"/>
|
||||
/// <reference path="../node_modules/pxt-core/built/pxtlib.d.ts" />
|
||||
|
||||
import * as fs from "fs";
|
||||
import * as path from "path";
|
||||
|
4
cmds/pxtrequire.ts
Normal file
4
cmds/pxtrequire.ts
Normal file
@ -0,0 +1,4 @@
|
||||
import * as path from "path";
|
||||
export let pxtCore = require("pxt-core");
|
||||
// require.resolve() gives path to [pxt dir]/built/pxt.js, so move up twice to get pxt root dir
|
||||
export let pxtCoreDir = path.resolve(require.resolve("pxt-core"), "..", "..");
|
@ -1,6 +1,6 @@
|
||||
# Blocks language
|
||||
|
||||
### @description Langugage constructs for the Block editor.
|
||||
### @description Language constructs for the Block editor.
|
||||
|
||||
```namespaces
|
||||
for (let i = 0;i<5;++i) {}
|
||||
|
@ -1,3 +1,3 @@
|
||||
{
|
||||
"appref": "v0.5.33"
|
||||
"appref": "v0.6.13"
|
||||
}
|
||||
|
@ -57,7 +57,7 @@ Fun games to build with your @boardname@.
|
||||
"imageUrl":"/static/mb/projects/wallet.png"
|
||||
}, {
|
||||
"name": "Watch",
|
||||
"url":"/projects/the-watch",
|
||||
"url":"/projects/watch",
|
||||
"imageUrl":"/static/mb/projects/a10-watch.png"
|
||||
}]
|
||||
```
|
||||
@ -92,4 +92,4 @@ Fun games to build with your @boardname@.
|
||||
|
||||
### See Also
|
||||
|
||||
[Flashing Heart](/projects/flashing-heart), [Smiley Buttons](/projects/smiley-buttons), [Love Meter](/projects/love-meter), [Rock Paper Scissors](/projects/rock-paper-scissors), [Compass](/projects/compass), [Hack your headphones](/projects/hack-your-headphones), [Banana keyboard](/projects/banana-keyboard), [Telegraph](/projects/telegraph), [Radio](/projects/radio), [Guitar](/projects/guitar), [Watch](/projects/the-watch)
|
||||
[Flashing Heart](/projects/flashing-heart), [Smiley Buttons](/projects/smiley-buttons), [Love Meter](/projects/love-meter), [Rock Paper Scissors](/projects/rock-paper-scissors), [Compass](/projects/compass), [Hack your headphones](/projects/hack-your-headphones), [Banana keyboard](/projects/banana-keyboard), [Telegraph](/projects/telegraph), [Radio](/projects/radio), [Guitar](/projects/guitar), [Wallet](/projects/wallet), [Watch](/projects/watch)
|
@ -1,24 +1,7 @@
|
||||
# flashing heart
|
||||
|
||||

|
||||
|
||||
### ~avatar avatar
|
||||
|
||||
```sim
|
||||
basic.forever(() => {
|
||||
basic.showLeds(`
|
||||
. # . # .
|
||||
# # # # #
|
||||
# # # # #
|
||||
. # # # .
|
||||
. . # . .`
|
||||
);
|
||||
basic.pause(500);
|
||||
basic.clearScreen();
|
||||
basic.pause(500);
|
||||
})
|
||||
```
|
||||
|
||||
Use the LEDs to display a flashing heart, and then create
|
||||
an animation of a broken heart. :(
|
||||
|
||||
|
@ -1,7 +1,5 @@
|
||||
# Guitar
|
||||
|
||||

|
||||
|
||||
### @description A beginner-intermediate maker activity, building a guitar with the @boardname@
|
||||
|
||||
### ~avatar avatar
|
||||
@ -9,7 +7,7 @@
|
||||
Make a @boardname@ guitar with this guided tutorial!
|
||||
|
||||
### ~
|
||||
*playing @boardname@ guitar*
|
||||
|
||||
https://youtu.be/GYmdTFvxz80
|
||||
|
||||
## Duration
|
||||
|
@ -19,17 +19,17 @@ Build your own music player @boardname@ from headphones.
|
||||
* Headphones
|
||||
* Crocodile clips
|
||||
|
||||
## Activities
|
||||
|
||||
* [Connect your headphone](/projects/hack-your-headphones/make)
|
||||
* [Play sounds!]()
|
||||
|
||||
# ~hint
|
||||
|
||||
**No crocodile clips!?!?!** Use wires or Aluminium foil! [Read more...](/device/foil-circuits)
|
||||
|
||||
# ~
|
||||
|
||||
## Activities
|
||||
|
||||
* [Connect your headphone](/projects/hack-your-headphones/make)
|
||||
* [Play sounds!]()
|
||||
|
||||
### ~button /projects/hack-your-headphones/make
|
||||
|
||||
Let's get started!
|
||||
|
@ -1,8 +1,10 @@
|
||||
# love meter
|
||||
|
||||

|
||||
### ~avatar avatar
|
||||
|
||||
Use pins P0, P1 and P2 to change the display by creating a circuit with your body.
|
||||
Use pins and your body to change the display!
|
||||
|
||||
### ~
|
||||
|
||||
## Step 1
|
||||
|
||||
|
@ -1,10 +1,8 @@
|
||||
# magic button trick
|
||||
|
||||
Perform a magic trick where you appear to make the **A** and **B** button of your @boardname@ swap over just by moving a sticky label.
|
||||
|
||||
### ~avatar avatar
|
||||
|
||||
Welcome! This activity will teach you how to use the @boardname@'s compass to detect a nearby magnet
|
||||
Build a magic trick that uses the @boardname@'s compass to detect a nearby magnet!
|
||||
|
||||
### ~
|
||||
This is a simple magic trick you can perform to amaze your friends, where by moving the sticky labels on your @boardname@'s **A** and **B** button you appear to make the buttons really switch over. To see the trick performed watch the video below.
|
||||
|
@ -1,51 +1,11 @@
|
||||
# rock paper scissors
|
||||
|
||||

|
||||
|
||||
### ~avatar avatar
|
||||
|
||||
```sim
|
||||
input.onGesture(Gesture.Shake, () => {
|
||||
let img = Math.random(3)
|
||||
if (img == 0) {
|
||||
basic.showLeds(`
|
||||
# # # # #
|
||||
# . . . #
|
||||
# . . . #
|
||||
# . . . #
|
||||
# # # # #
|
||||
`)
|
||||
|
||||
} else if (img == 1) {
|
||||
basic.showLeds(`
|
||||
. . . . .
|
||||
. # # # .
|
||||
. # # # .
|
||||
. # # # .
|
||||
. . . . .
|
||||
`)
|
||||
} else {
|
||||
basic.showLeds(`
|
||||
# # . . #
|
||||
# # . # .
|
||||
. . # . .
|
||||
# # . # .
|
||||
# # . . #
|
||||
`)
|
||||
}
|
||||
})
|
||||
```
|
||||
In this project, you will build a Rock Paper Scissors game with the @boardname@.
|
||||
You can play the game with a friend who has it on a @boardname@.
|
||||
You can also play it with friends who are just using their hands.
|
||||
Build a rock paper scissors game!
|
||||
|
||||
### ~
|
||||
|
||||
|
||||
## Materials needed
|
||||
|
||||
* Your @boardname@ -- that's it!
|
||||
|
||||
## Step 1: Getting started
|
||||
|
||||
We want the @boardname@ to choose rock, paper, or scissors when you shake it.
|
||||
|
@ -1,8 +1,10 @@
|
||||
# smiley buttons
|
||||
|
||||

|
||||
### ~avatar
|
||||
|
||||
Use buttons to show a smiley or frowny face.
|
||||
Use buttons to show a smiley face!
|
||||
|
||||
### ~
|
||||
|
||||
## Step 1
|
||||
|
||||
|
@ -1,7 +1,5 @@
|
||||
# Wallet
|
||||
|
||||

|
||||
|
||||
### @description A beginner maker activity, building a duct tape wallet with the @boardname@
|
||||
|
||||
### ~avatar avatar
|
||||
@ -12,23 +10,6 @@ Make a @boardname@ wallet with this guided tutorial!
|
||||
|
||||

|
||||
|
||||
## Duration
|
||||
|
||||
2 Activities, approx 30-45 min each based on familiarity with the coding concepts
|
||||
|
||||
## Materials
|
||||
|
||||
* Paper sheet
|
||||
* Tape (masking, duct tape, and/or packing tape)
|
||||
* Scissors
|
||||
* 1 @boardname@, battery holder and 2 AAA batteries
|
||||
* Marker or pen
|
||||
|
||||
## Activities
|
||||
|
||||
* [Make](/projects/wallet/make)
|
||||
* [Code](/projects/wallet/code)
|
||||
|
||||
### ~button /projects/wallet/make
|
||||
|
||||
Let's get started!
|
||||
|
20
docs/projects/watch.md
Normal file
20
docs/projects/watch.md
Normal file
@ -0,0 +1,20 @@
|
||||
# the watch
|
||||
|
||||
### ~avatar
|
||||
|
||||
Build your own @boardname@ watch from an old pair of jeans and T-shirt!
|
||||
|
||||
### ~
|
||||
|
||||

|
||||
|
||||
### ~button /projects/watch/make
|
||||
|
||||
Let's get started!
|
||||
|
||||
### ~
|
||||
|
||||
### Acknowledgements
|
||||
|
||||
Artistic design by Melinda Hoeneisen.
|
||||
|
@ -1,12 +1,14 @@
|
||||

|
||||
# the watch - Make
|
||||
|
||||
# the watch
|
||||
### @description Maker Project for Watch
|
||||
|
||||

|
||||
### ~avatar avatar
|
||||
|
||||
In this project, you will build your own wearable @boardname@ watch from an old pair of jeans and T-shirt. Project duration: 15 minutes.
|
||||
Make a watch for your @boardname@
|
||||
|
||||

|
||||
### ~
|
||||
|
||||
## Duration: ~30 minutes
|
||||
|
||||
## Materials
|
||||
|
||||
@ -147,8 +149,3 @@ Trim any leftover fabric, threads or tape.
|
||||

|
||||
|
||||
Your watch is ready!
|
||||
|
||||
### Acknowledgements
|
||||
|
||||
Artistic design by Melinda Hoeneisen.
|
||||
|
@ -30,7 +30,7 @@ control.inBackground(() => {
|
||||
```
|
||||
|
||||
## Bluetooth
|
||||
|
||||
|
||||
```namespaces
|
||||
devices.tellCameraTo(MesCameraEvent.TakePhoto);
|
||||
bluetooth.onBluetoothConnected(() => {});
|
||||
|
@ -31,6 +31,13 @@ bluetooth.uartWriteNumber(0);
|
||||
bluetooth.uartWriteValue("", 0);
|
||||
```
|
||||
|
||||
## Eddystone
|
||||
|
||||
```cards
|
||||
bluetooth.advertiseUrl("https://pxt.microbit.org/", 7);
|
||||
bluetooth.stopAdvertising();
|
||||
```
|
||||
|
||||
```package
|
||||
bluetooth
|
||||
```
|
||||
@ -47,4 +54,7 @@ For more advanced information on the @boardname@ Bluetooth UART service includin
|
||||
[uartWriteString](/reference/bluetooth/uart-write-string),
|
||||
[uartWriteNumber](/reference/bluetooth/uart-write-number),
|
||||
[uartWriteValue](/reference/bluetooth/uart-write-value),
|
||||
[onBluetoothConnected](/reference/bluetooth/on-bluetooth-connected), [onBluetoothDisconnected](/reference/bluetooth/on-bluetooth-disconnected)
|
||||
[onBluetoothConnected](/reference/bluetooth/on-bluetooth-connected),
|
||||
[onBluetoothDisconnected](/reference/bluetooth/on-bluetooth-disconnected),
|
||||
[advertiseUrl](/reference/bluetooth/advertise-url),
|
||||
[stopAdvertising](/reference/bluetooth/stop-advertising)
|
||||
|
41
docs/reference/bluetooth/advertise-url.md
Normal file
41
docs/reference/bluetooth/advertise-url.md
Normal file
@ -0,0 +1,41 @@
|
||||
# Avertise Url
|
||||
|
||||
Advertises a URL via the Eddystone protocol over Bluetooth.
|
||||
|
||||
## ~hint
|
||||
|
||||
### Eddystone
|
||||
|
||||
Bluetooth beacons are used to indicate proximity to a place or object of interest.
|
||||
Beacons use Bluetooth advertising to broadcast a small amount of data,
|
||||
which can be received and acted upon by anyone in range with a suitable device and software, typically a smartphone and application.
|
||||
|
||||
There are various beacon message formats, which define the way Bluetooth advertising packets are used as containers for beacon data.
|
||||
iBeacon is Apple's beacon message format. Eddystone comes from Google.
|
||||
|
||||
Read more at https://lancaster-university.github.io/microbit-docs/ble/eddystone/ .
|
||||
|
||||
## ~
|
||||
|
||||
```sig
|
||||
bluetooth.advertiseUrl("https://pxt.microbit.org/", 7);
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
* ``url`` - a [string](/reference/types/string) containing the URL to broadcast, at most 18 characters long
|
||||
* ``power`` - a [number](/reference/types/number) representing the power level between 0 (short) and 7 (maximum range).
|
||||
|
||||
### Example: Broadcast a secret code
|
||||
|
||||
```blocks
|
||||
bluetooth.advertiseUrl("https://pxt.io?secret=42", 7);
|
||||
```
|
||||
|
||||
## See Also
|
||||
|
||||
[stop-advertising](/reference/bluetooth/stop-advertising)
|
||||
|
||||
```package
|
||||
bluetooth
|
||||
```
|
38
docs/reference/bluetooth/stop-advertising.md
Normal file
38
docs/reference/bluetooth/stop-advertising.md
Normal file
@ -0,0 +1,38 @@
|
||||
# Stop Advertising
|
||||
|
||||
Stops advertising URL via the Eddystone protocol over Bluetooth.
|
||||
|
||||
## ~hint
|
||||
|
||||
### Eddystone
|
||||
|
||||
Bluetooth beacons are used to indicate proximity to a place or object of interest.
|
||||
Beacons use Bluetooth advertising to broadcast a small amount of data,
|
||||
which can be received and acted upon by anyone in range with a suitable device and software, typically a smartphone and application.
|
||||
|
||||
There are various beacon message formats, which define the way Bluetooth advertising packets are used as containers for beacon data.
|
||||
iBeacon is Apple's beacon message format. Eddystone comes from Google.
|
||||
|
||||
Read more at https://lancaster-university.github.io/microbit-docs/ble/eddystone/ .
|
||||
|
||||
## ~
|
||||
|
||||
```sig
|
||||
bluetooth.stopAdvertising();
|
||||
```
|
||||
|
||||
### Example: stop advertising on button pressed
|
||||
|
||||
```blocks
|
||||
input.onButtonPressed(Button.A, () => {
|
||||
bluetooth.stopAdvertising();
|
||||
})
|
||||
```
|
||||
|
||||
## See Also
|
||||
|
||||
[advertise-url](/reference/bluetooth/advertise-url)
|
||||
|
||||
```package
|
||||
bluetooth
|
||||
```
|
28
docs/reference/eddystone.md
Normal file
28
docs/reference/eddystone.md
Normal file
@ -0,0 +1,28 @@
|
||||
# Eddystone
|
||||
|
||||
Support for Eddystone beacons.
|
||||
|
||||
```cards
|
||||
eddystone.advertiseUrl("https://pxt.io/", 6);
|
||||
eddystone.stopAdvertising();
|
||||
```
|
||||
|
||||
### Advanced
|
||||
|
||||
Bluetooth beacons are used to indicate proximity to a place or object of interest.
|
||||
Beacons use Bluetooth advertising to broadcast a small amount of data, which can be received and acted upon by anyone in range
|
||||
with a suitable device and software, typically a smartphone and application.
|
||||
|
||||
There are various beacon message formats, which define the way Bluetooth advertising packets are used as containers for beacon data.
|
||||
iBeacon is Apple's beacon message format. Eddystone comes from Google.
|
||||
|
||||
More information at https://lancaster-university.github.io/microbit-docs/ble/eddystone/
|
||||
|
||||
### See Also
|
||||
|
||||
[eddystone.advertiseUrl](/reference/eddystone/advertise-url),
|
||||
[eddystone.stopAdvertising](/reference/eddystone/stop-advertising),
|
||||
|
||||
```package
|
||||
eddystone
|
||||
```
|
@ -25,6 +25,15 @@ let freq = music.noteFrequency(Note.C)
|
||||
music.playTone(freq, 1000)
|
||||
```
|
||||
|
||||
|
||||
### Using other pins
|
||||
|
||||
Use [analogSetPitchPin](/pins/analog-set-pitch-pin) to change that pin used to generate music.
|
||||
|
||||
```blocks
|
||||
pins.analogSetPitchPin(AnalogPin.P1);
|
||||
```
|
||||
|
||||
### See also
|
||||
|
||||
[rest](/reference/music/rest), [ring tone](/reference/music/ring-tone) , [tempo](/reference/music/tempo), [set tempo](/reference/music/set-tempo),
|
||||
|
@ -32,6 +32,14 @@ basic.forever(() => {
|
||||
})
|
||||
```
|
||||
|
||||
### Using other pins
|
||||
|
||||
Use [analogSetPitchPin](/pins/analog-set-pitch-pin) to change that pin used to generate music.
|
||||
|
||||
```blocks
|
||||
pins.analogSetPitchPin(AnalogPin.P1);
|
||||
```
|
||||
|
||||
### See also
|
||||
|
||||
[rest](/reference/music/rest), [play tone](/reference/music/play-tone),
|
||||
|
@ -1,6 +1,7 @@
|
||||
# Analog Pitch
|
||||
|
||||
Emits a Pulse With Modulation (PWM) signal to the current pitch [pin](/device/pins). Use [analog set pitch pin](/reference/pins/analog-set-pitch-pin) to set the current pitch pin.
|
||||
Emits a Pulse With Modulation (PWM) signal to the pin ``P0``.
|
||||
Use [analog set pitch pin](/reference/pins/analog-set-pitch-pin) to set the current pitch pin.
|
||||
|
||||
```sig
|
||||
pins.analogPitch(440, 300)
|
||||
@ -17,6 +18,7 @@ pins.analogPitch(440, 300)
|
||||
pins.analogSetPitchPin("P0")
|
||||
let frequency1 = 440
|
||||
let duration = 1000
|
||||
pins.analogSetPitchPin(AnalogPin.P1);
|
||||
pins.analogPitch(frequency1, duration)
|
||||
```
|
||||
|
||||
|
@ -1,5 +1,8 @@
|
||||
{
|
||||
"bluetooth": "Support for additional Bluetooth services.",
|
||||
"bluetooth.advertiseUrl": "Advertise an Eddystone URL",
|
||||
"bluetooth.advertiseUrl|param|power": "power level between 0 and 7, e.g.: 7",
|
||||
"bluetooth.advertiseUrl|param|url": "the url to transmit. Must be no longer than the supported eddystone url length",
|
||||
"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",
|
||||
@ -11,6 +14,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,4 +1,5 @@
|
||||
{
|
||||
"bluetooth.advertiseUrl|block": "bluetooth advertise url %url|with power %power",
|
||||
"bluetooth.onBluetoothConnected|block": "on bluetooth connected",
|
||||
"bluetooth.onBluetoothDisconnected|block": "on bluetooth disconnected",
|
||||
"bluetooth.startAccelerometerService|block": "bluetooth accelerometer service",
|
||||
@ -8,6 +9,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",
|
||||
|
6
libs/bluetooth/_locales/de/bluetooth-jsdoc-strings.json
Normal file
6
libs/bluetooth/_locales/de/bluetooth-jsdoc-strings.json
Normal file
@ -0,0 +1,6 @@
|
||||
{
|
||||
"bluetooth.uartWriteNumber": "Gibt einen numerischen Wert an die serielle",
|
||||
"bluetooth.uartWriteValue": "Schreibt ein ``Namen: Wert`` Wertepaar auf die serielle Schnittstelle.",
|
||||
"bluetooth.uartWriteValue|param|name": "Name des Wertestreams, z.B.: x",
|
||||
"bluetooth.uartWriteValue|param|value": "Schreiben"
|
||||
}
|
@ -11,7 +11,6 @@ using namespace pxt;
|
||||
namespace bluetooth {
|
||||
MicroBitUARTService *uart = NULL;
|
||||
|
||||
|
||||
/**
|
||||
* Starts the Bluetooth accelerometer service
|
||||
*/
|
||||
@ -119,5 +118,30 @@ namespace bluetooth {
|
||||
//% parts="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
|
||||
* @param power power level between 0 and 7, e.g.: 7
|
||||
*/
|
||||
//% blockId=eddystone_advertise_url block="bluetooth advertise url %url|with power %power"
|
||||
//% parts=bluetooth weight=11 blockGap=8
|
||||
//% help=bluetooth/advertise-url
|
||||
void advertiseUrl(StringData* url, int power) {
|
||||
int8_t level = CALIBRATED_POWERS[min(7, max(0, power))];
|
||||
uBit.bleManager.advertiseEddystoneUrl(ManagedString(url), level);
|
||||
}
|
||||
|
||||
/**
|
||||
* Stops advertising Eddystone end points
|
||||
*/
|
||||
//% blockId=eddystone_stop_advertising block="bluetooth stop advertising"
|
||||
//% parts=bluetooth weight=10
|
||||
//% help=bluetooth/stop-advertising
|
||||
void stopAdvertising() {
|
||||
uBit.bleManager.stopAdvertising();
|
||||
}
|
||||
}
|
@ -16,19 +16,28 @@
|
||||
"config": {
|
||||
"microbit-dal": {
|
||||
"bluetooth": {
|
||||
"enabled": 1,
|
||||
"pairing_mode": 1,
|
||||
"enabled": 1
|
||||
}
|
||||
}
|
||||
},
|
||||
"optionalConfig": {
|
||||
"microbit-dal": {
|
||||
"bluetooth": {
|
||||
"private_addressing": 0,
|
||||
"open": 0,
|
||||
"whitelist": 1,
|
||||
"advertising_timeout": 0,
|
||||
"tx_power": 6,
|
||||
"dfu_service": 1,
|
||||
"event_service": 1,
|
||||
"device_info_service": 1
|
||||
},
|
||||
"gatt_table_size": "0x700"
|
||||
}
|
||||
"device_info_service": 1,
|
||||
"eddystone_url": 1,
|
||||
"eddystone_uid": 0,
|
||||
"pairing_mode": 1,
|
||||
"open": 0,
|
||||
"security_level": "SECURITY_MODE_ENCRYPTION_WITH_MITM"
|
||||
}
|
||||
},
|
||||
"gatt_table_size": "0x700"
|
||||
}
|
||||
},
|
||||
"installedVersion": "vzlhfd"
|
||||
|
18
libs/bluetooth/shims.d.ts
vendored
18
libs/bluetooth/shims.d.ts
vendored
@ -80,6 +80,24 @@ 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
|
||||
* @param power power level between 0 and 7, e.g.: 7
|
||||
*/
|
||||
//% blockId=eddystone_advertise_url block="bluetooth advertise url %url|with power %power"
|
||||
//% parts=bluetooth weight=11 blockGap=8
|
||||
//% help=bluetooth/advertise-url shim=bluetooth::advertiseUrl
|
||||
function advertiseUrl(url: string, power: number): void;
|
||||
|
||||
/**
|
||||
* Stops advertising Eddystone end points
|
||||
*/
|
||||
//% blockId=eddystone_stop_advertising block="bluetooth stop advertising"
|
||||
//% parts=bluetooth weight=10
|
||||
//% help=bluetooth/stop-advertising shim=bluetooth::stopAdvertising
|
||||
function stopAdvertising(): void;
|
||||
}
|
||||
|
||||
// Auto-generated. Do not edit. Really.
|
||||
|
373
libs/core/ManagedBuffer.cpp
Normal file
373
libs/core/ManagedBuffer.cpp
Normal file
@ -0,0 +1,373 @@
|
||||
#include "MicroBit.h"
|
||||
#include "ManagedBuffer.h"
|
||||
#include <limits.h>
|
||||
|
||||
static const char empty[] __attribute__ ((aligned (4))) = "\xff\xff\0\0\0";
|
||||
|
||||
/**
|
||||
* Internal constructor helper.
|
||||
* Configures this ManagedBuffer to refer to the static empty buffer.
|
||||
*/
|
||||
void ManagedBuffer::initEmpty()
|
||||
{
|
||||
ptr = (BufferData*)(void*)empty;
|
||||
}
|
||||
|
||||
/**
|
||||
* Default Constructor.
|
||||
* Creates an empty ManagedBuffer.
|
||||
*
|
||||
* Example:
|
||||
* @code
|
||||
* ManagedBuffer p();
|
||||
* @endcode
|
||||
*/
|
||||
ManagedBuffer::ManagedBuffer()
|
||||
{
|
||||
initEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* Creates an empty ManagedBuffer of the given size.
|
||||
*
|
||||
* @param length The length of the buffer to create.
|
||||
*
|
||||
* Example:
|
||||
* @code
|
||||
* ManagedBuffer p(16); // Creates a ManagedBuffer 16 bytes long.
|
||||
* @endcode
|
||||
*/
|
||||
ManagedBuffer::ManagedBuffer(int length)
|
||||
{
|
||||
this->init(NULL, length);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* Creates a new ManagedBuffer of the given size,
|
||||
* and fills it with the data provided.
|
||||
*
|
||||
* @param data The data with which to fill the buffer.
|
||||
* @param length The length of the buffer to create.
|
||||
*
|
||||
* Example:
|
||||
* @code
|
||||
* uint8_t buf = {13,5,2};
|
||||
* ManagedBuffer p(buf, 3); // Creates a ManagedBuffer 3 bytes long.
|
||||
* @endcode
|
||||
*/
|
||||
ManagedBuffer::ManagedBuffer(uint8_t *data, int length)
|
||||
{
|
||||
this->init(data, length);
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy Constructor.
|
||||
* Add ourselves as a reference to an existing ManagedBuffer.
|
||||
*
|
||||
* @param buffer The ManagedBuffer to reference.
|
||||
*
|
||||
* Example:
|
||||
* @code
|
||||
* ManagedBuffer p();
|
||||
* ManagedBuffer p2(i); // Refers to the same buffer as p.
|
||||
* @endcode
|
||||
*/
|
||||
ManagedBuffer::ManagedBuffer(const ManagedBuffer &buffer)
|
||||
{
|
||||
ptr = buffer.ptr;
|
||||
ptr->incr();
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* Create a buffer from a raw BufferData pointer. It will ptr->incr(). This is to be used by specialized runtimes.
|
||||
*
|
||||
* @param p The pointer to use.
|
||||
*/
|
||||
ManagedBuffer::ManagedBuffer(BufferData *p)
|
||||
{
|
||||
ptr = p;
|
||||
ptr->incr();
|
||||
}
|
||||
|
||||
/**
|
||||
* Internal constructor-initialiser.
|
||||
*
|
||||
* @param data The data with which to fill the buffer.
|
||||
* @param length The length of the buffer to create.
|
||||
*
|
||||
*/
|
||||
void ManagedBuffer::init(uint8_t *data, int length)
|
||||
{
|
||||
if (length <= 0) {
|
||||
initEmpty();
|
||||
return;
|
||||
}
|
||||
|
||||
ptr = (BufferData *) malloc(sizeof(BufferData) + length);
|
||||
ptr->init();
|
||||
|
||||
ptr->length = length;
|
||||
|
||||
// Copy in the data buffer, if provided.
|
||||
if (data)
|
||||
memcpy(ptr->payload, data, length);
|
||||
else
|
||||
memset(ptr->payload, 0, length);
|
||||
}
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
* Removes buffer resources held by the instance.
|
||||
*/
|
||||
ManagedBuffer::~ManagedBuffer()
|
||||
{
|
||||
ptr->decr();
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy assign operation.
|
||||
*
|
||||
* Called when one ManagedBuffer is assigned the value of another using the '=' operator.
|
||||
* Decrements our reference count and free up the buffer as necessary.
|
||||
* Then, update our buffer to refer to that of the supplied ManagedBuffer,
|
||||
* and increase its reference count.
|
||||
*
|
||||
* @param p The ManagedBuffer to reference.
|
||||
*
|
||||
* Example:
|
||||
* @code
|
||||
* uint8_t buf = {13,5,2};
|
||||
* ManagedBuffer p1(16);
|
||||
* ManagedBuffer p2(buf, 3);
|
||||
*
|
||||
* p1 = p2;
|
||||
* @endcode
|
||||
*/
|
||||
ManagedBuffer& ManagedBuffer::operator = (const ManagedBuffer &p)
|
||||
{
|
||||
if(ptr == p.ptr)
|
||||
return *this;
|
||||
|
||||
ptr->decr();
|
||||
ptr = p.ptr;
|
||||
ptr->incr();
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Equality operation.
|
||||
*
|
||||
* Called when one ManagedBuffer is tested to be equal to another using the '==' operator.
|
||||
*
|
||||
* @param p The ManagedBuffer to test ourselves against.
|
||||
* @return true if this ManagedBuffer is identical to the one supplied, false otherwise.
|
||||
*
|
||||
* Example:
|
||||
* @code
|
||||
*
|
||||
* uint8_t buf = {13,5,2};
|
||||
* ManagedBuffer p1(16);
|
||||
* ManagedBuffer p2(buf, 3);
|
||||
*
|
||||
* if(p1 == p2) // will be true
|
||||
* uBit.display.scroll("same!");
|
||||
* @endcode
|
||||
*/
|
||||
bool ManagedBuffer::operator== (const ManagedBuffer& p)
|
||||
{
|
||||
if (ptr == p.ptr)
|
||||
return true;
|
||||
else
|
||||
return (ptr->length == p.ptr->length && (memcmp(ptr->payload, p.ptr->payload, ptr->length)==0));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the byte at the given index to value provided.
|
||||
* @param position The index of the byte to change.
|
||||
* @param value The new value of the byte (0-255).
|
||||
* @return MICROBIT_OK, or MICROBIT_INVALID_PARAMETER.
|
||||
*
|
||||
* Example:
|
||||
* @code
|
||||
* ManagedBuffer p1(16);
|
||||
* p1.setByte(0,255); // Sets the firts byte in the buffer to the value 255.
|
||||
* @endcode
|
||||
*/
|
||||
int ManagedBuffer::setByte(int position, uint8_t value)
|
||||
{
|
||||
if (0 <= position && position < ptr->length)
|
||||
{
|
||||
ptr->payload[position] = value;
|
||||
return MICROBIT_OK;
|
||||
}
|
||||
else
|
||||
{
|
||||
return MICROBIT_INVALID_PARAMETER;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines the value of the given byte in the buffer.
|
||||
*
|
||||
* @param position The index of the byte to read.
|
||||
* @return The value of the byte at the given position, or MICROBIT_INVALID_PARAMETER.
|
||||
*
|
||||
* Example:
|
||||
* @code
|
||||
* ManagedBuffer p1(16);
|
||||
* p1.setByte(0,255); // Sets the firts byte in the buffer to the value 255.
|
||||
* p1.getByte(0); // Returns 255.
|
||||
* @endcode
|
||||
*/
|
||||
int ManagedBuffer::getByte(int position)
|
||||
{
|
||||
if (0 <= position && position < ptr->length)
|
||||
return ptr->payload[position];
|
||||
else
|
||||
return MICROBIT_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get current ptr, do not decr() it, and set the current instance to an empty buffer.
|
||||
* This is to be used by specialized runtimes which pass BufferData around.
|
||||
*/
|
||||
BufferData *ManagedBuffer::leakData()
|
||||
{
|
||||
BufferData* res = ptr;
|
||||
initEmpty();
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
int ManagedBuffer::fill(uint8_t value, int offset, int length)
|
||||
{
|
||||
if (offset < 0 || offset > ptr->length)
|
||||
return MICROBIT_INVALID_PARAMETER;
|
||||
if (length < 0)
|
||||
length = ptr->length;
|
||||
length = min(length, ptr->length - offset);
|
||||
|
||||
memset(ptr->payload + offset, value, length);
|
||||
|
||||
return MICROBIT_OK;
|
||||
}
|
||||
|
||||
ManagedBuffer ManagedBuffer::slice(int offset, int length) const
|
||||
{
|
||||
offset = min(ptr->length, offset);
|
||||
if (length < 0)
|
||||
length = ptr->length;
|
||||
length = min(length, ptr->length - offset);
|
||||
return ManagedBuffer(ptr->payload + offset, length);
|
||||
}
|
||||
|
||||
void ManagedBuffer::shift(int offset, int start, int len)
|
||||
{
|
||||
if (len < 0) len = ptr->length - start;
|
||||
if (start < 0 || start + len > ptr->length || start + len < start
|
||||
|| len == 0 || offset == 0 || offset == INT_MIN) return;
|
||||
if (offset <= -len || offset >= len) {
|
||||
fill(0);
|
||||
return;
|
||||
}
|
||||
|
||||
uint8_t *data = ptr->payload + start;
|
||||
if (offset < 0) {
|
||||
offset = -offset;
|
||||
memmove(data + offset, data, len - offset);
|
||||
memset(data, 0, offset);
|
||||
} else {
|
||||
len = len - offset;
|
||||
memmove(data, data + offset, len);
|
||||
memset(data + len, 0, offset);
|
||||
}
|
||||
}
|
||||
|
||||
void ManagedBuffer::rotate(int offset, int start, int len)
|
||||
{
|
||||
if (len < 0) len = ptr->length - start;
|
||||
if (start < 0 || start + len > ptr-> length || start + len < start
|
||||
|| len == 0 || offset == 0 || offset == INT_MIN) return;
|
||||
|
||||
if (offset < 0)
|
||||
offset += len << 8; // try to make it positive
|
||||
offset %= len;
|
||||
if (offset < 0)
|
||||
offset += len;
|
||||
|
||||
uint8_t *data = ptr->payload + start;
|
||||
|
||||
uint8_t *n_first = data + offset;
|
||||
uint8_t *first = data;
|
||||
uint8_t *next = n_first;
|
||||
uint8_t *last = data + len;
|
||||
|
||||
while (first != next) {
|
||||
uint8_t tmp = *first;
|
||||
*first++ = *next;
|
||||
*next++ = tmp;
|
||||
if (next == last) {
|
||||
next = n_first;
|
||||
} else if (first == n_first) {
|
||||
n_first = next;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int ManagedBuffer::writeBuffer(int dstOffset, const ManagedBuffer &src, int srcOffset, int length)
|
||||
{
|
||||
if (length < 0)
|
||||
length = src.length();
|
||||
|
||||
if (srcOffset < 0 || dstOffset < 0 || dstOffset > ptr->length)
|
||||
return MICROBIT_INVALID_PARAMETER;
|
||||
|
||||
length = min(src.length() - srcOffset, ptr->length - dstOffset);
|
||||
|
||||
if (length < 0)
|
||||
return MICROBIT_INVALID_PARAMETER;
|
||||
|
||||
if (ptr == src.ptr) {
|
||||
memmove(getBytes() + dstOffset, src.ptr->payload + srcOffset, length);
|
||||
} else {
|
||||
memcpy(getBytes() + dstOffset, src.ptr->payload + srcOffset, length);
|
||||
}
|
||||
|
||||
return MICROBIT_OK;
|
||||
}
|
||||
|
||||
int ManagedBuffer::writeBytes(int offset, uint8_t *src, int length, bool swapBytes)
|
||||
{
|
||||
if (offset < 0 || length < 0 || offset + length > ptr->length)
|
||||
return MICROBIT_INVALID_PARAMETER;
|
||||
|
||||
if (swapBytes) {
|
||||
uint8_t *p = ptr->payload + offset + length;
|
||||
for (int i = 0; i < length; ++i)
|
||||
*--p = src[i];
|
||||
} else {
|
||||
memcpy(ptr->payload + offset, src, length);
|
||||
}
|
||||
|
||||
return MICROBIT_OK;
|
||||
}
|
||||
|
||||
int ManagedBuffer::readBytes(uint8_t *dst, int offset, int length, bool swapBytes) const
|
||||
{
|
||||
if (offset < 0 || length < 0 || offset + length > ptr->length)
|
||||
return MICROBIT_INVALID_PARAMETER;
|
||||
|
||||
if (swapBytes) {
|
||||
uint8_t *p = ptr->payload + offset + length;
|
||||
for (int i = 0; i < length; ++i)
|
||||
dst[i] = *--p;
|
||||
} else {
|
||||
memcpy(dst, ptr->payload + offset, length);
|
||||
}
|
||||
|
||||
return MICROBIT_OK;
|
||||
}
|
257
libs/core/ManagedBuffer.h
Normal file
257
libs/core/ManagedBuffer.h
Normal file
@ -0,0 +1,257 @@
|
||||
#ifndef MICROBIT_MANAGED_BUFFER_H
|
||||
#define MICROBIT_MANAGED_BUFFER_H
|
||||
|
||||
#include "mbed.h"
|
||||
#include "RefCounted.h"
|
||||
|
||||
struct BufferData : RefCounted
|
||||
{
|
||||
uint16_t length; // The length of the payload in bytes
|
||||
uint8_t payload[0]; // ManagedBuffer data
|
||||
};
|
||||
|
||||
/**
|
||||
* Class definition for a ManagedBuffer.
|
||||
* A ManagedBuffer holds a series of bytes, used with MicroBitRadio channels and in other places.
|
||||
* n.b. This is a mutable, managed type.
|
||||
*/
|
||||
class ManagedBuffer
|
||||
{
|
||||
BufferData *ptr; // Pointer to payload data
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Default Constructor.
|
||||
* Creates an empty ManagedBuffer. The 'ptr' field in all empty buffers is shared.
|
||||
*
|
||||
* Example:
|
||||
* @code
|
||||
* ManagedBuffer p();
|
||||
* @endcode
|
||||
*/
|
||||
ManagedBuffer();
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* Creates a new ManagedBuffer of the given size.
|
||||
*
|
||||
* @param length The length of the buffer to create.
|
||||
*
|
||||
* Example:
|
||||
* @code
|
||||
* ManagedBuffer p(16); // Creates a ManagedBuffer 16 bytes long.
|
||||
* @endcode
|
||||
*/
|
||||
ManagedBuffer(int length);
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* Creates an empty ManagedBuffer of the given size,
|
||||
* and fills it with the data provided.
|
||||
*
|
||||
* @param data The data with which to fill the buffer.
|
||||
* @param length The length of the buffer to create.
|
||||
*
|
||||
* Example:
|
||||
* @code
|
||||
* uint8_t buf[] = {13,5,2};
|
||||
* ManagedBuffer p(buf, 3); // Creates a ManagedBuffer 3 bytes long.
|
||||
* @endcode
|
||||
*/
|
||||
ManagedBuffer(uint8_t *data, int length);
|
||||
|
||||
/**
|
||||
* Copy Constructor.
|
||||
* Add ourselves as a reference to an existing ManagedBuffer.
|
||||
*
|
||||
* @param buffer The ManagedBuffer to reference.
|
||||
*
|
||||
* Example:
|
||||
* @code
|
||||
* ManagedBuffer p();
|
||||
* ManagedBuffer p2(i); // Refers to the same buffer as p.
|
||||
* @endcode
|
||||
*/
|
||||
ManagedBuffer(const ManagedBuffer &buffer);
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* Create a buffer from a raw BufferData pointer. It will ptr->incr(). This is to be used by specialized runtimes.
|
||||
*
|
||||
* @param p The pointer to use.
|
||||
*/
|
||||
ManagedBuffer(BufferData *p);
|
||||
|
||||
/**
|
||||
* Internal constructor helper.
|
||||
* Configures this ManagedBuffer to refer to the static empty buffer.
|
||||
*/
|
||||
void initEmpty();
|
||||
|
||||
/**
|
||||
* Internal constructor-initialiser.
|
||||
*
|
||||
* @param data The data with which to fill the buffer.
|
||||
* @param length The length of the buffer to create.
|
||||
*
|
||||
*/
|
||||
void init(uint8_t *data, int length);
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
* Removes buffer resources held by the instance.
|
||||
*/
|
||||
~ManagedBuffer();
|
||||
|
||||
/**
|
||||
* Provide an array containing the buffer data.
|
||||
* @return The contents of this buffer, as an array of bytes.
|
||||
*/
|
||||
uint8_t *getBytes()
|
||||
{
|
||||
return ptr->payload;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get current ptr, do not decr() it, and set the current instance to an empty buffer.
|
||||
* This is to be used by specialized runtimes which pass BufferData around.
|
||||
*/
|
||||
BufferData *leakData();
|
||||
|
||||
/**
|
||||
* Copy assign operation.
|
||||
*
|
||||
* Called when one ManagedBuffer is assigned the value of another using the '=' operator.
|
||||
* Decrements our reference count and free up the buffer as necessary.
|
||||
* Then, update our buffer to refer to that of the supplied ManagedBuffer,
|
||||
* and increase its reference count.
|
||||
*
|
||||
* @param p The ManagedBuffer to reference.
|
||||
*
|
||||
* Example:
|
||||
* @code
|
||||
* uint8_t buf = {13,5,2};
|
||||
* ManagedBuffer p1(16);
|
||||
* ManagedBuffer p2(buf, 3);
|
||||
*
|
||||
* p1 = p2;
|
||||
* @endcode
|
||||
*/
|
||||
ManagedBuffer& operator = (const ManagedBuffer& p);
|
||||
|
||||
/**
|
||||
* Array access operation (read).
|
||||
*
|
||||
* Called when a ManagedBuffer is dereferenced with a [] operation.
|
||||
* Transparently map this through to the underlying payload for elegance of programming.
|
||||
*
|
||||
* Example:
|
||||
* @code
|
||||
* ManagedBuffer p1(16);
|
||||
* uint8_t data = p1[0];
|
||||
* @endcode
|
||||
*/
|
||||
uint8_t operator [] (int i) const
|
||||
{
|
||||
return ptr->payload[i];
|
||||
}
|
||||
|
||||
/**
|
||||
* Array access operation (modify).
|
||||
*
|
||||
* Called when a ManagedBuffer is dereferenced with a [] operation.
|
||||
* Transparently map this through to the underlying payload for elegance of programming.
|
||||
*
|
||||
* Example:
|
||||
* @code
|
||||
* ManagedBuffer p1(16);
|
||||
* p1[0] = 42;
|
||||
* @endcode
|
||||
*/
|
||||
uint8_t& operator [] (int i)
|
||||
{
|
||||
return ptr->payload[i];
|
||||
}
|
||||
|
||||
/**
|
||||
* Equality operation.
|
||||
*
|
||||
* Called when one ManagedBuffer is tested to be equal to another using the '==' operator.
|
||||
*
|
||||
* @param p The ManagedBuffer to test ourselves against.
|
||||
* @return true if this ManagedBuffer is identical to the one supplied, false otherwise.
|
||||
*
|
||||
* Example:
|
||||
* @code
|
||||
*
|
||||
* uint8_t buf = {13,5,2};
|
||||
* ManagedBuffer p1(16);
|
||||
* ManagedBuffer p2(buf, 3);
|
||||
*
|
||||
* if(p1 == p2) // will be true
|
||||
* uBit.display.scroll("same!");
|
||||
* @endcode
|
||||
*/
|
||||
bool operator== (const ManagedBuffer& p);
|
||||
|
||||
/**
|
||||
* Sets the byte at the given index to value provided.
|
||||
* @param position The index of the byte to change.
|
||||
* @param value The new value of the byte (0-255).
|
||||
* @return MICROBIT_OK, or MICROBIT_INVALID_PARAMETER.
|
||||
*
|
||||
* Example:
|
||||
* @code
|
||||
* ManagedBuffer p1(16);
|
||||
* p1.setByte(0,255); // Sets the first byte in the buffer to the value 255.
|
||||
* @endcode
|
||||
*/
|
||||
int setByte(int position, uint8_t value);
|
||||
|
||||
/**
|
||||
* Determines the value of the given byte in the buffer.
|
||||
*
|
||||
* @param position The index of the byte to read.
|
||||
* @return The value of the byte at the given position, or MICROBIT_INVALID_PARAMETER.
|
||||
*
|
||||
* Example:
|
||||
* @code
|
||||
* ManagedBuffer p1(16);
|
||||
* p1.setByte(0,255); // Sets the first byte in the buffer to the value 255.
|
||||
* p1.getByte(0); // Returns 255.
|
||||
* @endcode
|
||||
*/
|
||||
int getByte(int position);
|
||||
|
||||
/**
|
||||
* Gets number of bytes in this buffer
|
||||
* @return The size of the buffer in bytes.
|
||||
*
|
||||
* Example:
|
||||
* @code
|
||||
* ManagedBuffer p1(16);
|
||||
* p1.length(); // Returns 16.
|
||||
* @endcode
|
||||
*/
|
||||
int length() const { return ptr->length; }
|
||||
|
||||
int fill(uint8_t value, int offset = 0, int length = -1);
|
||||
|
||||
ManagedBuffer slice(int offset = 0, int length = -1) const;
|
||||
|
||||
void shift(int offset, int start = 0, int length = -1);
|
||||
|
||||
void rotate(int offset, int start = 0, int length = -1);
|
||||
|
||||
int readBytes(uint8_t *dst, int offset, int length, bool swapBytes = false) const;
|
||||
|
||||
int writeBytes(int dstOffset, uint8_t *src, int length, bool swapBytes = false);
|
||||
|
||||
int writeBuffer(int dstOffset, const ManagedBuffer &src, int srcOffset = 0, int length = -1);
|
||||
|
||||
bool isReadOnly() const { return ptr->isReadOnly(); }
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -179,15 +179,15 @@
|
||||
"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.",
|
||||
"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",
|
||||
"pins.analogPitch|param|ms": "TODO",
|
||||
"pins.analogPitch|param|frequency": "frequency to modulate in Hz.",
|
||||
"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|param|name": "pin to write to",
|
||||
"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|name": "analog pin to set period to",
|
||||
"pins.analogSetPitchPin": "Sets the pin used when using `pins->analog pitch`.",
|
||||
"pins.analogSetPitchPin|param|name": "TODO",
|
||||
"pins.analogSetPitchPin": "Sets the pin used when using `analog pitch` or music.",
|
||||
"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|param|name": "pin name to write to",
|
||||
"pins.analogWritePin|param|value": "value to write to the pin between ``0`` and ``1023``. eg:1023,0",
|
||||
|
@ -1,6 +1,82 @@
|
||||
{
|
||||
"AcceleratorRange.EightG": "The accelerator measures forces up to 8 gravity",
|
||||
"AcceleratorRange.EightG|block": "8g",
|
||||
"AcceleratorRange.FourG": "The accelerator measures forces up to 4 gravity",
|
||||
"AcceleratorRange.FourG|block": "4g",
|
||||
"AcceleratorRange.OneG": "The accelerator measures forces up to 1 gravity",
|
||||
"AcceleratorRange.OneG|block": "1g",
|
||||
"AcceleratorRange.TwoG": "The accelerator measures forces up to 2 gravity",
|
||||
"AcceleratorRange.TwoG|block": "2g",
|
||||
"BaudRate.BaudRate115200|block": "115200",
|
||||
"BaudRate.BaudRate9600|block": "9600",
|
||||
"BeatFraction.Eighth|block": "1/8",
|
||||
"BeatFraction.Half|block": "1/2",
|
||||
"BeatFraction.Quarter|block": "1/4",
|
||||
"BeatFraction.Sixteenth|block": "1/16",
|
||||
"BeatFraction.Whole|block": "1",
|
||||
"Button.AB|block": "A+B",
|
||||
"Delimiters.Colon|block": ":",
|
||||
"Delimiters.Comma|block": ",",
|
||||
"Delimiters.Dollar|block": "$",
|
||||
"Delimiters.Fullstop|block": ".",
|
||||
"Delimiters.Hash|block": "#",
|
||||
"Delimiters.NewLine|block": "new line",
|
||||
"Dimension.Strength|block": "strength",
|
||||
"Dimension.X|block": "x",
|
||||
"Dimension.Y|block": "y",
|
||||
"Dimension.Z|block": "z",
|
||||
"Direction.Left|block": "left",
|
||||
"Direction.Right|block": "right",
|
||||
"DisplayMode.BackAndWhite|block": "black and white",
|
||||
"DisplayMode.Greyscale|block": "greyscale",
|
||||
"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.FreeFall|block": "free fall",
|
||||
"Gesture.LogoDown": "Raised when the logo is downward and the screen is vertical",
|
||||
"Gesture.LogoDown|block": "logo down",
|
||||
"Gesture.LogoUp": "Raised when the logo is upward and the screen is vertical",
|
||||
"Gesture.LogoUp|block": "logo up",
|
||||
"Gesture.ScreenDown": "Raised when the screen is pointing up and the board is horizontal",
|
||||
"Gesture.ScreenDown|block": "screen down",
|
||||
"Gesture.ScreenUp": "Raised when the screen is pointing down and the board is horizontal",
|
||||
"Gesture.ScreenUp|block": "screen up",
|
||||
"Gesture.Shake": "Raised when shaken",
|
||||
"Gesture.Shake|block": "shake",
|
||||
"Gesture.SixG": "Raised when a 6G shock is detected",
|
||||
"Gesture.SixG|block": "6g",
|
||||
"Gesture.ThreeG": "Raised when a 3G shock is detected",
|
||||
"Gesture.ThreeG|block": "3g",
|
||||
"Gesture.TiltLeft": "Raised when the screen is pointing left",
|
||||
"Gesture.TiltLeft|block": "tilt left",
|
||||
"Gesture.TiltRight": "Raised when the screen is pointing right",
|
||||
"Gesture.TiltRight|block": "tilt right",
|
||||
"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|block": "Math",
|
||||
"Note.CSharp3|block": "C#3",
|
||||
"Note.CSharp4|block": "C#4",
|
||||
"Note.CSharp5|block": "C#5",
|
||||
"Note.CSharp|block": "C#",
|
||||
"Note.FSharp3|block": "F#3",
|
||||
"Note.FSharp4|block": "F#4",
|
||||
"Note.FSharp5|block": "F#5",
|
||||
"Note.FSharp|block": "F#",
|
||||
"Note.GSharp3|block": "G#3",
|
||||
"Note.GSharp4|block": "G#4",
|
||||
"Note.GSharp5|block": "G#5",
|
||||
"Note.GSharp|block": "G#",
|
||||
"PinPullMode.PullDown|block": "down",
|
||||
"PinPullMode.PullNone|block": "none",
|
||||
"PinPullMode.PullUp|block": "up",
|
||||
"PulseValue.High|block": "high",
|
||||
"PulseValue.Low|block": "low",
|
||||
"Rotation.Pitch|block": "pitch",
|
||||
"Rotation.Roll|block": "roll",
|
||||
"String.charAt|block": "char from %this|at %pos",
|
||||
"String.compare|block": "compare %this| to %that",
|
||||
"String.concat|block": "join %this|%other",
|
||||
@ -70,8 +146,10 @@
|
||||
"music.setTempo|block": "set tempo to (bpm)|%value",
|
||||
"music.tempo|block": "tempo (bpm)",
|
||||
"music|block": "music",
|
||||
"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",
|
||||
"pins.analogSetPitchPin|block": "analog set pitch pin %name",
|
||||
"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",
|
||||
|
@ -1,6 +1,31 @@
|
||||
{
|
||||
"Math.abs": "Gibt den absoluten Wert einer Zahl aus (den Wert unabhängig davon, ob er positiv oder negativ ist).\nDer absolute Wert von -5 ist zum Beispiel der gleiche wie der von 5.",
|
||||
"Math.abs|param|x": "Ein numerischer Ausdruck, für den der absolute Wert benötigt wird.",
|
||||
"Math.max": "Gibt den größeren von zwei vorhandenen numerischen Ausdrücken aus.",
|
||||
"Math.min": "Gibt den niedrigeren von zwei vorhandenen numerischen Ausdrücken aus.",
|
||||
"Math.pow": "Gibt den Wert eines grundlegenden Ausdrucks bis zu einer bestimmten Stärke aus.",
|
||||
"Math.pow|param|x": "Der Basiswert des Ausdrucks.",
|
||||
"Math.pow|param|y": "Der exponentielle Wert des Ausdrucks.",
|
||||
"Math.random": "Gibt eine pseudozufüllige Zahl zwischen 0 und `max`aus.",
|
||||
"Math.randomBoolean": "Erzeugt zufällig einen \"wahr\" oder \"falsch\"-Wert, wie bei einem Münzwurf.",
|
||||
"Math.sign": "Gibt das Vorzeichen von x aus und zeigt an, ob dieses positiv, negativ oder null ist.",
|
||||
"Math.sign|param|x": "Der numerische Ausdruck, der getestet werden soll",
|
||||
"Math.sqrt": "Gibt die Quadratwurzel einer Zahl aus.",
|
||||
"Math.sqrt|param|x": "Ein numerischer Ausdruck.",
|
||||
"String.charAt": "Gibt den Buchstaben beim angegebenen Index aus.",
|
||||
"String.charAt|param|index": "Der null-basierte index des gewünschten Zeichens.",
|
||||
"String.charCodeAt": "Gibt den Unicode-Wert des Zeichens am vorgegebenen Ort aus.",
|
||||
"String.charCodeAt|param|index": "Der null-basierte Index des gewünschten Zeichens. Wenn kein Zeichen am angegeben Index vorhanden ist, wird NaN ausgegeben.",
|
||||
"String.compare": "Bestimmt die relative Reihenfolge zweier Strings (in ASCII).",
|
||||
"String.compare|param|that": "Zeichenfolge, die mit der Zielzeichenfolge verglichen werden soll",
|
||||
"String.concat": "Gibt eine Zeichenfolge aus, die die Verkettung von zwei oder mehr Zeichenfolgen ist.",
|
||||
"String.concat|param|other": "Die Zeichenfolge, die an das Ende einer Zeichenfolge angehängt werden soll.",
|
||||
"String.fromCharCode": "Erstelle Sie eine Zeichenfolge aus dem angegebenen ASCII-Zeichencode.",
|
||||
"String.isEmpty": "Gibt einen Wert aus, der anzeigt, ob die Zeichenfolge leer ist",
|
||||
"String.length": "Gibt die Länge einer Zeichenfolge aus.",
|
||||
"String.substr": "Gibt eine Teilzeichenfolge der aktuellen Zeichenfolge aus.",
|
||||
"String.substr|param|length": "Anzahl der zu extrahierenden Zeichen",
|
||||
"String.substr|param|start": "Erster Zeichenindex, kann beim zählen vom Ende negativ sein, zum Beispiel: 0",
|
||||
"basic": "Bietet Zugriff auf grundlegende mini-Funktionalität.",
|
||||
"basic.clearScreen": "Schalte alle LEDs aus",
|
||||
"basic.forever": "Wiederholt immer wieder den Code im Hintergrund. Bei jeder Iteration ist es möglich, anderen Code auszuführen.",
|
||||
@ -20,19 +45,50 @@
|
||||
"basic.showString|param|interval": "Wie schnell die Zeichen geändert werden; z.B. 150, 100, 200,-100",
|
||||
"basic.showString|param|text": "Text auf dem Bildschirm dargestellt werden soll, z.B.: \"Hallo!\"",
|
||||
"control": "Laufzeit- und Event-Dienstprogramme.",
|
||||
"control.assert": "Wenn die Bedingung falsch ist, zeige eine Nachricht auf der seriellen Konsole und gebe Panic-Code 098 aus",
|
||||
"control.deviceName": "Erzeugt einen Namen für das Gerät, basierend auf der Seriennummer",
|
||||
"control.eventSourceId": "Gibt den Wert einer C++-Laufzeitkonstanten aus",
|
||||
"control.eventTimestamp": "Holt den Zeitstempel des letzten Events auf dem Bus",
|
||||
"control.eventValue": "Holt den Wert des letzten ausgeführten Events auf dem Bus",
|
||||
"control.eventValueId": "Gibt den Wert einer C++-Laufzeitkonstanten aus",
|
||||
"control.inBackground": "Plant Code, der im Hintergrund wiedergegeben wird.",
|
||||
"control.onEvent": "Startet ein Event auf dem Event-Bus.",
|
||||
"control.panic": "Zeigt einen spezifizierten Fehlercode und hält das Programm an.",
|
||||
"control.raiseEvent": "Startet ein Event auf dem Event-Bus.",
|
||||
"control.raiseEvent|param|mode": "optionale Definition davon, wie ein Event nach dem Erstellen ausgeführt wird (Standard ist \"CREATE_AND_FIRE).",
|
||||
"control.raiseEvent|param|src": "ID der Calliope mini-Komponente, die das Event generiert hat, zum Beispiel CALLIOPE_ID_BUTTON_A.",
|
||||
"control.raiseEvent|param|value": "Komponentenspezifischer Code, der den Grund des Events angibt.",
|
||||
"control.reset": "Seit den mini zurück.",
|
||||
"control.runtimeWarning": "Zeige Warnmeldung im Simulator.",
|
||||
"control.waitMicros": "Sperrt die aktuelle Leitung für die Dauer der angegebenen Mikrosekunden",
|
||||
"control.waitMicros|param|micros": "Anzahl der Mikrosekunden, die gewartet werden soll, z.B.: 4",
|
||||
"game": "Eine Einzel-LED-Sprite-Spielumgebung",
|
||||
"game.addLife": "Fügt Leben zum aktuellen Spielstand hinzu",
|
||||
"game.addLife|param|lives": "TODO",
|
||||
"game.addScore": "Fügt zum aktuellen Spielstand Punkte hinzu",
|
||||
"game.addScore|param|points": "Anzahl von zu verändernden Punkten, z.B.: 1",
|
||||
"game.createSprite": "Erzeugt einen neuen LED-Sprite, der nach rechts zeigt.",
|
||||
"game.createSprite|param|x": "horizontale Koordinate des Sprites, z.B. 2",
|
||||
"game.createSprite|param|y": "vertikale Koordinate des Sprites, z.B. 2",
|
||||
"game.currentTime": "Ruft die verbliebene Zeit (seit `starte Countdown`) oder die aktuelle Zeit (seit das Gerät gestartet wurde oder eine Stoppuhr aktiviert wurde) an.",
|
||||
"game.gameOver": "Gibt über eine Animation ein Spiel wieder.",
|
||||
"game.invalidSprite": "Ruft einen invaliden Sprite ab; wird genutzt, um Locale zu initialisieren.",
|
||||
"game.isGameOver": "Zeigt an, ob das Spil die \"Game Over\"-Sequenz angezeigt hat.",
|
||||
"game.isRunning": "Holt einen Wert, der anzeigt, ob das Spiel noch läuft. Gibt `falsch`aus, wenn das Spiel zu Ende ist.",
|
||||
"game.level": "Ruft das aktuelle Level ab",
|
||||
"game.levelUp": "Erhöht das Level und zeigt eine Nachricht an.",
|
||||
"game.life": "Ruft das aktuelle Leben ab",
|
||||
"game.removeLife": "Entfernt ein Leben",
|
||||
"game.removeLife|param|life": "TODO",
|
||||
"game.score": "Ruft den aktuellen Punktestand ab",
|
||||
"game.setLife": "Setzt den aktuellen Wert der Leben",
|
||||
"game.setLife|param|value": "TODO",
|
||||
"game.setScore": "Setzt den aktuellen Wert des Spielstands",
|
||||
"game.setScore|param|value": "TODO",
|
||||
"game.showScore": "Zeigt den Spielstand auf dem Display.",
|
||||
"game.startCountdown": "Startet einen Spiel-Countdown",
|
||||
"game.startCountdown|param|ms": "Countdown-Dauer in Millisekunden, z.B.: 10000",
|
||||
"game.startStopwatch": "Startet eine Stoppuhr.`aktuelle Zeit`gibt die vergangene Zeit an.",
|
||||
"images": "Erstellung, Bearbeitung und Anzeige von LED-Bildern.",
|
||||
"images.createBigImage": "Erstellt ein Bild mit zwei Einzelbildern.",
|
||||
"images.createImage": "Erstellt ein Bild, das auf den LED-Bildschirm passt.",
|
||||
@ -76,6 +132,7 @@
|
||||
"input.temperature": "Ruft die aktuelle Temperatur in Grad Celsius (°C) ab.",
|
||||
"led": "Steuerung des LED-Bildschirms.",
|
||||
"led.brightness": "Ruft die Helligkeit des Bildschirms ab, von 0 (aus) bis 255 (volle Helligkeit).",
|
||||
"led.enable": "Schaltet das Display an und aus",
|
||||
"led.fadeIn": "Blendet die Bildschirmanzeige ein.",
|
||||
"led.fadeIn|param|ms": "TODO",
|
||||
"led.fadeOut": "Blendet die Bildschirmhelligkeit aus.",
|
||||
@ -133,12 +190,16 @@
|
||||
"pins.analogWritePin": "Legt den Wert des Verbinders auf analog fest. Der Wert muss zwischen 0 und 1023 liegen.",
|
||||
"pins.analogWritePin|param|name": "PIN-Name, auf den geschrieben werden soll",
|
||||
"pins.analogWritePin|param|value": "Wert, der auf den Pin geschrieben werden soll, zwischen ``0`` und ``1023`` z.B.: 1023,0",
|
||||
"pins.createBuffer": "Erstellt einen Null-initialisierten Zwischenspeicher.",
|
||||
"pins.createBuffer|param|size": "Anzahl der Bytes im Zwischenspeicher",
|
||||
"pins.digitalReadPin": "Lese den angegebene Pin oder Verbinder als 0 oder 1",
|
||||
"pins.digitalReadPin|param|name": "Pin, aus dem gelesen werden soll",
|
||||
"pins.digitalWritePin": "Setzt einen Pin- oder Verbinder-Wert auf 0 oder 1.",
|
||||
"pins.digitalWritePin|param|name": "Pin, auf den geschrieben werden soll",
|
||||
"pins.digitalWritePin|param|value": "Wert, der auf dem Pin 1 gesetzt werden soll, z.B. 0",
|
||||
"pins.i2cReadBuffer": "Lese `Größe`bytes aus einer 7-bit I2C-Adresse.",
|
||||
"pins.i2cReadNumber": "Lese eine Nummer aus einer 7-bit I2C-Adresse.",
|
||||
"pins.i2cWriteBuffer": "Schreibt Bytes in eine 7-bit I2C-Adresse.",
|
||||
"pins.i2cWriteNumber": "Schreibe eine Nummer in eine 7-bit I2C-Adresse.",
|
||||
"pins.map": "Definiert eine Nummer von einer Auswahl zu einer anderen um. Ein Wert ``von niedrig``wird so auf ``zu niedrig``umgeändert, ein Wert ``von hoch`` zu ``zu hoch`` etc.",
|
||||
"pins.map|param|fromHigh": "die obere Grenze des aktuellen Wertebereichs, z.B.: 1023",
|
||||
@ -148,6 +209,9 @@
|
||||
"pins.map|param|value": "Wert in Bereichen zuordnen",
|
||||
"pins.onPulsed": "Stellt diesen Pin als einen Digitaleingang ein und generiert Ereignisse, deren Zeitstempel die Dauer darstellt, in der der Pin entweder ``hoch``oder ``niedrig``war.",
|
||||
"pins.pulseDuration": "Ruft die Dauer des letzten Impulses in Mikrosendungen ab. Diese Funktion soll von einem `onPulsed`-Handler aufgerufen werden.",
|
||||
"pins.pulseIn": "Gibt die Dauer eines Pulses in Mikrosekunden an",
|
||||
"pins.pulseIn|param|name": "der Pin, der den Puls misst",
|
||||
"pins.pulseIn|param|value": "der Wert des Pulses (Standard hoch)",
|
||||
"pins.servoSetPulse": "Konfiguriert diesen IO-Pin als einen analogen/PWM-Ausgang, stellt den Zeitraum auf 20 ms ein und setzt die Pulsweite fest, basieren auf dem angegeben Wert **Mikrosekunden** oder `1/1000`Millisekunden.",
|
||||
"pins.servoSetPulse|param|micros": "Impulsdauer in Mikrosekunden, z.B.: 1500",
|
||||
"pins.servoSetPulse|param|name": "PIN-Name",
|
||||
@ -156,10 +220,13 @@
|
||||
"pins.servoWritePin|param|value": "Winkel oder Rotationsbeschleunigung, z.B.: 180,90,0",
|
||||
"pins.setPull": "Stellt die Anziehungskraft des Pins ein.",
|
||||
"pins.setPull|param|name": "Pin, auf dem der Pull-Modus aktiviert wird",
|
||||
"pins.setPull|param|pull": "eine der mbed-Pull-Konfigurationen: PullUp, PullDown, PullNone ",
|
||||
"pins.setPull|param|pull": "eine der mbed-Pull-Konfigurationen: PullUp, PullDown, PullNone",
|
||||
"pins.sizeOf": "Ruft die Bytegröße im spezifierten Nummernformat ab.",
|
||||
"pins.spiWrite": "Schreibe in den SPI-Slave und gebe die Antwort aus",
|
||||
"pins.spiWrite|param|value": "Daten, die an den SPI-Slave geschickt werden sollen",
|
||||
"serial": "Lesen und Schreiben von Daten über eine serielle Verbindung.",
|
||||
"serial.delimiters": "Gibt die mit dem Begrenzer korrespondierende Zeichenfolge aus.",
|
||||
"serial.onLineReceived": "Registriert ein Event, das ausgeführt wird, wenn eine Zeile empfangen wurde",
|
||||
"serial.readLine": "Liest eine Textzeile aus der seriellen Schnittstelle.",
|
||||
"serial.readUntil": "Liest aus eine Textzeile aus dem seriellen Anschluss und gibt den Puffer aus, wenn die Begrenzung erreicht wurde.",
|
||||
"serial.readUntil|param|delimiter": "Text-Begrenzung, die die Textblöcke voneinander trennt",
|
||||
@ -167,7 +234,7 @@
|
||||
"serial.redirect|param|rx": "der neue Empfangs-Pin",
|
||||
"serial.redirect|param|tx": "Der neue Übertragungs-Pin",
|
||||
"serial.writeLine": "Gibt eine Zeile des Textes an die serielle",
|
||||
"serial.writeNumber": " Gibt einen numerischen Wert an die serielle",
|
||||
"serial.writeNumber": "Gibt einen numerischen Wert an die serielle",
|
||||
"serial.writeString": "Sendet ein Stück Text über serielle Verbindung.",
|
||||
"serial.writeValue": "Schreibt ein ``Namen: Wert`` Wertepaar auf die serielle Schnittstelle.",
|
||||
"serial.writeValue|param|name": "Name des Wertestreams, z.B.: x",
|
||||
|
@ -1,20 +1,47 @@
|
||||
{
|
||||
"Math.randomBoolean|block": "Wähle zufälligen Wahr- oder Falsch-Wert",
|
||||
"AcceleratorRange.EightG": "Der Bewegungssensor misst Kräfte bis 8g",
|
||||
"AcceleratorRange.EightG|block": "8g",
|
||||
"AcceleratorRange.FourG": "Der Bewegungssensor misst Kräfte bis 4g",
|
||||
"AcceleratorRange.FourG|block": "4g",
|
||||
"AcceleratorRange.OneG": "Der Bewegungssensor misst Kräfte bis 1g",
|
||||
"AcceleratorRange.OneG|block": "1g",
|
||||
"AcceleratorRange.TwoG": "Der Bewegungssensor misst Kräfte bis 2g",
|
||||
"AcceleratorRange.TwoG|block": "2g",
|
||||
"Gesture.Shake": "Wird erhöht, wenn geschüttelt",
|
||||
"Gesture.Shake|block": "geschüttelt",
|
||||
"LedSpriteProperty.Brightness|block": "Helligkeit",
|
||||
"Math.randomBoolean|block": "wähle zufälligen Wahr- oder Falsch-Wert",
|
||||
"Math|block": "Mathematik",
|
||||
"Rotation.Pitch|block": "Winkel",
|
||||
"String.charAt|block": "Zeichen an Position %pos aus|%this",
|
||||
"String.compare|block": "vergleiche %this| mit %that",
|
||||
"String.concat|block": "hänge %this| mit %other aneinander",
|
||||
"String.fromCharCode|block": "Text aus char code %code",
|
||||
"String.isEmpty|block": "%this| ist leer",
|
||||
"String.length|block": "Länge von %VALUE",
|
||||
"String.substr|block": "extrahiere aus %this|beginnend mit %start|%length Zeichen",
|
||||
"String|block": "Zeichenfolge",
|
||||
"basic.clearScreen|block": "Bildschirminhalt löschen",
|
||||
"basic.forever|block": "dauerhaft",
|
||||
"basic.pause|block": "Pausiere (ms) %pause",
|
||||
"basic.showLeds|block": "Zeige LEDs",
|
||||
"basic.showNumber|block": "Zeige|Nummer %number",
|
||||
"basic.showLeds|block": "zeige LEDs",
|
||||
"basic.showNumber|block": "zeige|Nummer %number",
|
||||
"basic.showString|block": "Zeige|Zeichenfolge %text",
|
||||
"basic|block": "Grundlagen",
|
||||
"control.deviceName|block": "Gerätename",
|
||||
"control.deviceSerialNumber|block": "Seriennnummer",
|
||||
"control.eventSourceId|block": "%id",
|
||||
"control.eventTimestamp|block": "Ereigniszeitstempel",
|
||||
"control.eventValueId|block": "%id",
|
||||
"control.eventValue|block": "Ereigniswert",
|
||||
"control.inBackground|block": "im Hintergrund ausführen",
|
||||
"control.onEvent|block": "wenn Ereignis|von Quelle %src=control_event_source_id|mit Wert %value=control_event_value_id",
|
||||
"control.raiseEvent|block": "Ereignis auslösen|von Quelle %src=control_event_source_id|mit Wert %value=control_event_value_id",
|
||||
"control.reset|block": "zurücksetzen",
|
||||
"control.waitMicros|block": "Warte (µs)%micros",
|
||||
"control|block": "Steuerung",
|
||||
"game.addScore|block": "Ändere Spielstand um|%points",
|
||||
"game.createSprite|block": "erzeuge Sprite an Position|x: %x|y:%y",
|
||||
"game.gameOver|block": "Spiel beendet",
|
||||
"game.score|block": "Spielstand",
|
||||
"game.startCountdown|block": "Countdown| starten (ms) %duration",
|
||||
@ -27,18 +54,18 @@
|
||||
"input.compassHeading|block": "Kompassausrichtung (°)",
|
||||
"input.lightLevel|block": "Lichtstärke",
|
||||
"input.magneticForce|block": "Magnetkraft (µT) |%NAME",
|
||||
"input.onButtonPressed|block": "Wenn Button|%NAME|gedrückt",
|
||||
"input.onButtonPressed|block": "wenn Knopf|%NAME|gedrückt",
|
||||
"input.onGesture|block": "wenn |%NAME",
|
||||
"input.onPinPressed|block": "wenn pin %NAME|gedrückt",
|
||||
"input.onPinReleased|block": "Wenn pin %NAME|released",
|
||||
"input.pinIsPressed|block": "PIN %NAME|ist gedrückt",
|
||||
"input.onPinPressed|block": "wenn Pin %NAME|gedrückt",
|
||||
"input.onPinReleased|block": "wenn Pin %NAME|losgelassen",
|
||||
"input.pinIsPressed|block": "Pin %NAME|ist gedrückt",
|
||||
"input.rotation|block": "Rotation (°)|%NAME",
|
||||
"input.runningTime|block": "Laufzeit (ms)",
|
||||
"input.setAccelerometerRange|block": "Setze Bewegungsmesser|range %range",
|
||||
"input.setAccelerometerRange|block": "setze Bewegungsmesser auf|%range",
|
||||
"input.temperature|block": "Temperatur (°C)",
|
||||
"input|block": "Eingabe",
|
||||
"led.brightness|block": "Helligkeit",
|
||||
"led.plotBarGraph|block": "zeichne Balkendiagramm des %value|bis %high",
|
||||
"led.plotBarGraph|block": "zeichne Balkendiagramm von %value|bis %high",
|
||||
"led.plot|block": "Zeichne|x %x|y %y",
|
||||
"led.point|block": "Punkt|x %x|y %y",
|
||||
"led.setBrightness|block": "Setze Helligkeit auf %value",
|
||||
@ -49,27 +76,29 @@
|
||||
"music.beat|block": "%fraction|Takt",
|
||||
"music.changeTempoBy|block": "ändere die Geschwindigkeit (bpm)|%value",
|
||||
"music.noteFrequency|block": "%note",
|
||||
"music.playTone|block": "play|tone %note=device_note|for %duration=device_beat",
|
||||
"music.rest|block": "rest(ms)|%duration=device_beat",
|
||||
"music.playTone|block": "spiele|Note %note=device_note|für %duration=device_beat",
|
||||
"music.rest|block": "pausiere (ms)|%duration=device_beat",
|
||||
"music.ringTone|block": "Klingelton (Hz) |%note = Device_note",
|
||||
"music.setTempo|block": "ändere Geschwindigkeit auf (bpm)|%value",
|
||||
"music.tempo|block": "Geschwindkeit (bpm)",
|
||||
"music|block": "Musik",
|
||||
"pins.analogReadPin|block": "analog read|pin %name",
|
||||
"pins.analogSetPeriod|block": "analog set period|pin %pin|to (µs)%micros",
|
||||
"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.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.analogReadPin|block": "lese analoge Werte von|Pin %name",
|
||||
"pins.analogSetPeriod|block": "setze Zeitraum für analogen|Pin %pin|auf (µs)%micros",
|
||||
"pins.analogWritePin|block": "schreibe analogen|Pin %name|auf %value",
|
||||
"pins.digitalReadPin|block": "lese digitale Werte von|Pin %name",
|
||||
"pins.digitalWritePin|block": "schreibe digitalen Wert von|pin %name|auf %value",
|
||||
"pins.i2cReadNumber|block": "lese Nummer aus I2C|auf Adresse %address|im Format %format=i2c_sizeof",
|
||||
"pins.i2cWriteNumber|block": "schreibe Nummer aus I2C|auf Adresse %address|mit Wert %value|im Format %format=i2c_sizeof",
|
||||
"pins.map|block": "verteile %value|von niedrig %fromLow|von hoch %fromHigh| bis niedrig %toLow|bis hoch %toHigh",
|
||||
"pins.onPulsed|block": "wenn|Pin %pin|gepulst %pulse",
|
||||
"pins.pulseDuration|block": "Impulsdauer (µs)",
|
||||
"pins.servoSetPulse|block": "servo set pulse|pin %value|to (µs) %micros",
|
||||
"pins.servoWritePin|block": "servo write|pin %name|to %value",
|
||||
"pins.setPull|block": "set pull|pin %pin|to %pull",
|
||||
"pins.spiWrite|block": "spi write %value",
|
||||
"pins.pulseIn|block": "Impuls in (µs)|Pin %name|mit %value",
|
||||
"pins.servoSetPulse|block": "setze den Puls von Servo an|Pin %value|auf (µs) %micros",
|
||||
"pins.servoWritePin|block": "schreibe Servo an|Pin %name|auf %value",
|
||||
"pins.setPull|block": "setze Anziehungskraft von|Pin %pin|auf %pull",
|
||||
"pins.spiWrite|block": "schreibe %value in SPI",
|
||||
"pins|block": "Pins",
|
||||
"serial.delimiters|block": "%del",
|
||||
"serial.readLine|block": "serial|read line",
|
||||
"serial.readUntil|block": "serial|read until %delimiter=serial_delimiter_conv",
|
||||
"serial.redirect|block": "serial|redirect to|TX %tx|RX %rx|at baud rate %rate",
|
||||
@ -87,5 +116,7 @@
|
||||
"{id:category}Math": "Mathematik",
|
||||
"{id:category}Music": "Musik",
|
||||
"{id:category}Pins": "Pins",
|
||||
"{id:category}Serial": "Serielle"
|
||||
"{id:category}Serial": "Serielle",
|
||||
"{id:category}String": "Zeichenfolge",
|
||||
"{id:category}Text": "Text"
|
||||
}
|
@ -1,31 +1,6 @@
|
||||
{
|
||||
"Math.abs": "",
|
||||
"Math.abs|param|x": "",
|
||||
"Math.max": "",
|
||||
"Math.min": "",
|
||||
"Math.pow": "",
|
||||
"Math.pow|param|x": "",
|
||||
"Math.pow|param|y": "",
|
||||
"Math.random": "",
|
||||
"Math.randomBoolean": "Génère une valeur « true » ou « false » au hasard, comme si vous lanciez une pièce de monnaie.",
|
||||
"Math.sign": "",
|
||||
"Math.sign|param|x": "",
|
||||
"Math.sqrt": "",
|
||||
"Math.sqrt|param|x": "",
|
||||
"String.charAt": "",
|
||||
"String.charAt|param|index": "",
|
||||
"String.charCodeAt": "",
|
||||
"String.charCodeAt|param|index": "",
|
||||
"String.compare": "",
|
||||
"String.compare|param|that": "",
|
||||
"String.concat": "",
|
||||
"String.concat|param|other": "",
|
||||
"String.fromCharCode": "Construit une chaîne à partir du code ASCII d'un caractère donné.",
|
||||
"String.isEmpty": "",
|
||||
"String.length": "",
|
||||
"String.substr": "",
|
||||
"String.substr|param|length": "",
|
||||
"String.substr|param|start": "",
|
||||
"basic": "Permet d’accéder aux fonctionnalités de base de la micro:bit.",
|
||||
"basic.clearScreen": "Éteindre toutes les LEDs",
|
||||
"basic.forever": "Répète le code indéfiniment en tâche de fond. A chaque itération, permet aux autres codes de s’exécuter.",
|
||||
@ -44,200 +19,63 @@
|
||||
"basic.showString": "Afficher du texte à l’écran, un caractère à la fois. Si la chaîne rentre sur l’écran (c'est-à-dire une seule lettre), ne défile pas.",
|
||||
"basic.showString|param|interval": "à quelle vitesse se déplacent les caractères ; par ex. : 150, 100, 200, -100",
|
||||
"basic.showString|param|text": "le texte à faire défiler sur l’écran, par exemple : « Bonjour ! »",
|
||||
"control": "",
|
||||
"control.assert": "",
|
||||
"control.deviceName": "",
|
||||
"control.deviceSerialNumber": "",
|
||||
"control.eventSourceId": "",
|
||||
"control.eventTimestamp": "",
|
||||
"control.eventValue": "",
|
||||
"control.eventValueId": "",
|
||||
"control.inBackground": "Planifie le code qui s’exécute en arrière-plan.",
|
||||
"control.onEvent": "",
|
||||
"control.panic": "",
|
||||
"control.raiseEvent": "",
|
||||
"control.raiseEvent|param|mode": "",
|
||||
"control.raiseEvent|param|src": "",
|
||||
"control.raiseEvent|param|value": "",
|
||||
"control.reset": "Réinitialise le micro:bit de BBC.",
|
||||
"control.runtimeWarning": "",
|
||||
"control.waitMicros": "",
|
||||
"control.waitMicros|param|micros": "nombre de microsecondes à attendre. par ex. : 4",
|
||||
"game": "Un moteur de jeu avec une unique LED",
|
||||
"game.addLife": "",
|
||||
"game.addLife|param|lives": "",
|
||||
"game.addLife|param|lives": "TODO",
|
||||
"game.addScore": "Ajoute des points au score actuel",
|
||||
"game.addScore|param|points": "nombre de points à changer, par ex. : 1",
|
||||
"game.createSprite": "",
|
||||
"game.createSprite|param|x": "",
|
||||
"game.createSprite|param|y": "",
|
||||
"game.currentTime": "",
|
||||
"game.gameOver": "Affiche un animation de fin de jeu.",
|
||||
"game.invalidSprite": "",
|
||||
"game.isGameOver": "",
|
||||
"game.isRunning": "",
|
||||
"game.level": "",
|
||||
"game.levelUp": "",
|
||||
"game.life": "",
|
||||
"game.removeLife": "",
|
||||
"game.removeLife|param|life": "",
|
||||
"game.removeLife|param|life": "TODO",
|
||||
"game.score": "Obtient le score actuel",
|
||||
"game.setLife": "",
|
||||
"game.setLife|param|value": "",
|
||||
"game.setLife|param|value": "TODO",
|
||||
"game.setScore": "Définit la valeur du score actuel",
|
||||
"game.setScore|param|value": "",
|
||||
"game.showScore": "",
|
||||
"game.startCountdown": "",
|
||||
"game.startCountdown|param|ms": "",
|
||||
"game.startStopwatch": "",
|
||||
"images": "",
|
||||
"images.createBigImage": "",
|
||||
"images.createImage": "",
|
||||
"input": "",
|
||||
"input.acceleration": "",
|
||||
"input.acceleration|param|dimension": "",
|
||||
"input.buttonIsPressed": "",
|
||||
"input.calibrate": "",
|
||||
"input.compassHeading": "",
|
||||
"input.lightLevel": "",
|
||||
"input.magneticForce": "",
|
||||
"input.magneticForce|param|dimension": "",
|
||||
"input.onButtonPressed": "",
|
||||
"input.onButtonPressed|param|body": "",
|
||||
"input.onButtonPressed|param|button": "",
|
||||
"input.onGesture": "",
|
||||
"input.onGesture|param|body": "",
|
||||
"input.onLogoDown": "",
|
||||
"input.onLogoDown|param|body": "",
|
||||
"input.onLogoUp": "",
|
||||
"input.onLogoUp|param|body": "",
|
||||
"input.onPinPressed": "",
|
||||
"input.onPinPressed|param|body": "",
|
||||
"input.onPinPressed|param|name": "",
|
||||
"input.onPinReleased": "",
|
||||
"input.onPinReleased|param|body": "",
|
||||
"input.onPinReleased|param|name": "",
|
||||
"input.onScreenDown": "",
|
||||
"input.onScreenDown|param|body": "",
|
||||
"input.onScreenUp": "",
|
||||
"input.onScreenUp|param|body": "",
|
||||
"input.onShake": "",
|
||||
"input.onShake|param|body": "",
|
||||
"input.pinIsPressed": "",
|
||||
"input.pinIsPressed|param|name": "",
|
||||
"input.rotation": "",
|
||||
"input.rotation|param|kind": "",
|
||||
"input.runningTime": "",
|
||||
"input.setAccelerometerRange": "",
|
||||
"input.setAccelerometerRange|param|range": "",
|
||||
"input.temperature": "",
|
||||
"led": "",
|
||||
"led.brightness": "",
|
||||
"led.enable": "",
|
||||
"led.fadeIn": "",
|
||||
"led.fadeIn|param|ms": "",
|
||||
"led.fadeOut": "",
|
||||
"led.fadeOut|param|ms": "",
|
||||
"led.plot": "",
|
||||
"led.plotAll": "",
|
||||
"led.plotBarGraph": "",
|
||||
"led.plotBarGraph|param|high": "",
|
||||
"led.plotBarGraph|param|value": "",
|
||||
"led.plot|param|x": "",
|
||||
"led.plot|param|y": "",
|
||||
"led.point": "",
|
||||
"led.point|param|x": "",
|
||||
"led.point|param|y": "",
|
||||
"led.screenshot": "",
|
||||
"led.setBrightness": "",
|
||||
"led.setBrightness|param|value": "",
|
||||
"led.setDisplayMode": "",
|
||||
"led.setDisplayMode|param|mode": "",
|
||||
"led.stopAnimation": "",
|
||||
"led.toggle": "",
|
||||
"led.toggleAll": "",
|
||||
"led.toggle|param|x": "",
|
||||
"led.toggle|param|y": "",
|
||||
"led.unplot": "",
|
||||
"led.unplot|param|x": "",
|
||||
"led.unplot|param|y": "",
|
||||
"music": "",
|
||||
"music.beat": "",
|
||||
"music.changeTempoBy": "",
|
||||
"music.changeTempoBy|param|bpm": "",
|
||||
"music.noteFrequency": "",
|
||||
"music.noteFrequency|param|name": "",
|
||||
"music.playTone": "",
|
||||
"music.playTone|param|frequency": "",
|
||||
"music.playTone|param|ms": "",
|
||||
"game.setScore|param|value": "TODO",
|
||||
"game.startCountdown": "Démarre un compte à rebours de jeu",
|
||||
"game.startCountdown|param|ms": "durée du compte à rebours en millisecondes, par ex. : 10000",
|
||||
"images": "Création, manipulation et affichage d’images LED.",
|
||||
"images.createBigImage": "Crée une image à partir de 2 images.",
|
||||
"images.createImage": "Crée une image qui s’adapte aux dimensions de l’écran LED.",
|
||||
"input": "Événements et des données provenant de capteurs",
|
||||
"input.acceleration|param|dimension": "TODO",
|
||||
"input.calibrate": "Obsolète, le calibrage de la boussole est automatique.",
|
||||
"input.compassHeading": "Obtient la direction actuelle du compas en degrés.",
|
||||
"input.magneticForce|param|dimension": "TODO",
|
||||
"input.onButtonPressed|param|body": "TODO",
|
||||
"input.onButtonPressed|param|button": "TODO",
|
||||
"input.onGesture|param|body": "TODO",
|
||||
"input.onLogoDown|param|body": "TODO",
|
||||
"input.onLogoUp|param|body": "TODO",
|
||||
"input.onPinPressed": "Faire quelque chose lorsque vous appuyez sur une broche.",
|
||||
"input.onPinPressed|param|body": "code à exécuter lorsque la broche est enfoncée",
|
||||
"input.onPinPressed|param|name": "la broche qui doit être pressée",
|
||||
"input.onPinReleased": "Faire quelque chose quand une broche est relâchée.",
|
||||
"input.onPinReleased|param|body": "le code à exécuter lorsque la broche est relâchée",
|
||||
"input.onPinReleased|param|name": "la broche qui doit être relâchée",
|
||||
"input.onScreenDown|param|body": "TODO",
|
||||
"input.onScreenUp|param|body": "TODO",
|
||||
"input.onShake|param|body": "TODO",
|
||||
"input.pinIsPressed|param|name": "broche utilisée pour détecter le contact",
|
||||
"input.rotation|param|kind": "TODO",
|
||||
"input.temperature": "Obtient la température en degrés Celsius (°C).",
|
||||
"led": "Contrôle de l’écran LED.",
|
||||
"led.enable": "Active ou désactive l’affichage",
|
||||
"led.fadeIn|param|ms": "TODO",
|
||||
"led.fadeOut|param|ms": "TODO",
|
||||
"led.plotAll": "Allume toutes les LEDS",
|
||||
"led.plotBarGraph|param|value": "valeur actuelle à tracer",
|
||||
"led.plot|param|x": "TODO",
|
||||
"led.plot|param|y": "TODO",
|
||||
"led.point|param|x": "TODO",
|
||||
"led.point|param|y": "TODO",
|
||||
"led.setBrightness|param|value": "valeur de la luminosité, par ex. : 255, 127, 0",
|
||||
"led.toggle|param|x": "TODO",
|
||||
"led.toggle|param|y": "TODO",
|
||||
"led.unplot|param|x": "TODO",
|
||||
"led.unplot|param|y": "TODO",
|
||||
"music.rest": "Repose (joue rien) pendant une durée spécifiée via broche '' P0''.",
|
||||
"music.rest|param|ms": "",
|
||||
"music.ringTone": "",
|
||||
"music.ringTone|param|frequency": "",
|
||||
"music.setTempo": "",
|
||||
"music.setTempo|param|bpm": "",
|
||||
"music.tempo": "",
|
||||
"pins": "",
|
||||
"pins.analogPitch": "",
|
||||
"pins.analogPitch|param|frequency": "",
|
||||
"pins.analogPitch|param|ms": "",
|
||||
"pins.analogReadPin": "",
|
||||
"pins.analogReadPin|param|name": "",
|
||||
"pins.analogSetPeriod": "",
|
||||
"pins.analogSetPeriod|param|micros": "",
|
||||
"pins.analogSetPeriod|param|name": "",
|
||||
"pins.analogSetPitchPin": "",
|
||||
"pins.analogSetPitchPin|param|name": "",
|
||||
"pins.analogWritePin": "",
|
||||
"pins.analogWritePin|param|name": "",
|
||||
"pins.analogWritePin|param|value": "",
|
||||
"pins.createBuffer": "",
|
||||
"pins.createBuffer|param|size": "",
|
||||
"pins.digitalReadPin": "",
|
||||
"pins.digitalReadPin|param|name": "",
|
||||
"pins.digitalWritePin": "",
|
||||
"pins.digitalWritePin|param|name": "",
|
||||
"pins.digitalWritePin|param|value": "",
|
||||
"pins.i2cReadBuffer": "",
|
||||
"pins.i2cReadNumber": "",
|
||||
"pins.i2cWriteBuffer": "",
|
||||
"pins.i2cWriteNumber": "",
|
||||
"pins.map": "",
|
||||
"pins.map|param|fromHigh": "",
|
||||
"pins.map|param|fromLow": "",
|
||||
"pins.map|param|toHigh": "",
|
||||
"pins.map|param|toLow": "",
|
||||
"pins.map|param|value": "",
|
||||
"pins.onPulsed": "",
|
||||
"pins.pulseDuration": "",
|
||||
"pins.pulseIn": "",
|
||||
"pins.pulseIn|param|name": "",
|
||||
"pins.pulseIn|param|value": "",
|
||||
"pins.servoSetPulse": "",
|
||||
"pins.servoSetPulse|param|micros": "",
|
||||
"pins.servoSetPulse|param|name": "",
|
||||
"pins.servoWritePin": "",
|
||||
"pins.servoWritePin|param|name": "",
|
||||
"pins.servoWritePin|param|value": "",
|
||||
"pins.setPull": "",
|
||||
"pins.setPull|param|name": "",
|
||||
"pins.setPull|param|pull": "",
|
||||
"pins.sizeOf": "",
|
||||
"pins.spiWrite": "",
|
||||
"pins.spiWrite|param|value": "",
|
||||
"serial": "",
|
||||
"serial.delimiters": "",
|
||||
"serial.onLineReceived": "",
|
||||
"serial.readLine": "",
|
||||
"serial.readUntil": "",
|
||||
"serial.readUntil|param|delimiter": "",
|
||||
"serial.redirect": "",
|
||||
"serial.redirect|param|rx": "",
|
||||
"serial.redirect|param|tx": "",
|
||||
"serial.writeLine": "",
|
||||
"serial.writeNumber": "",
|
||||
"serial.writeString": "",
|
||||
"serial.writeValue": "",
|
||||
"serial.writeValue|param|name": "",
|
||||
"serial.writeValue|param|value": ""
|
||||
"pins.analogPitch|param|frequency": "TODO",
|
||||
"pins.analogPitch|param|ms": "TODO",
|
||||
"pins.analogSetPitchPin|param|name": "TODO"
|
||||
}
|
@ -1,35 +1,21 @@
|
||||
{
|
||||
"LedSpriteProperty.Brightness|block": "luminosité",
|
||||
"Math.randomBoolean|block": "choisir au hasard vrai ou faux",
|
||||
"Math|block": "Maths",
|
||||
"String.charAt|block": "",
|
||||
"String.compare|block": "",
|
||||
"String.concat|block": "",
|
||||
"String.fromCharCode|block": "texte du code de charactère %code",
|
||||
"String.isEmpty|block": "",
|
||||
"String.length|block": "",
|
||||
"String.substr|block": "",
|
||||
"String|block": "Texte",
|
||||
"basic.clearScreen|block": "effacer l’écran",
|
||||
"basic.forever|block": "toujours",
|
||||
"basic.pause|block": "pause (ms) %pause",
|
||||
"basic.showLeds|block": "montrer LEDs",
|
||||
"basic.showNumber|block": "montrer|nombre %number",
|
||||
"basic.showString|block": "montrer|texte %text",
|
||||
"basic.showString|block": "afficher|texte %text",
|
||||
"basic|block": "base",
|
||||
"control.deviceName|block": "",
|
||||
"control.deviceSerialNumber|block": "",
|
||||
"control.eventSourceId|block": "",
|
||||
"control.eventTimestamp|block": "",
|
||||
"control.eventValueId|block": "",
|
||||
"control.eventValue|block": "",
|
||||
"control.inBackground|block": "exécuter en arrière-plan",
|
||||
"control.onEvent|block": "",
|
||||
"control.raiseEvent|block": "",
|
||||
"control.reset|block": "remise à zéro",
|
||||
"control.waitMicros|block": "attendre (µs) %micros",
|
||||
"control|block": "contrôle",
|
||||
"game.addScore|block": "changer le score par|%points",
|
||||
"game.createSprite|block": "",
|
||||
"game.gameOver|block": "fin du jeu",
|
||||
"game.score|block": "score",
|
||||
"game.startCountdown|block": "commencer compte à rebours|(ms) %duration",
|
||||
@ -71,22 +57,15 @@
|
||||
"music.tempo|block": "tempo (bpm)",
|
||||
"music|block": "musique",
|
||||
"pins.analogReadPin|block": "lire|la broche analogique %name",
|
||||
"pins.analogSetPeriod|block": "",
|
||||
"pins.analogWritePin|block": "",
|
||||
"pins.digitalReadPin|block": "lire en numérique|broche %name",
|
||||
"pins.digitalWritePin|block": "écrire en numérique|la broche %name|à %value",
|
||||
"pins.i2cReadNumber|block": "i2c lire nombre|à l’adresse %address|de format %format=i2c_sizeof",
|
||||
"pins.i2cWriteNumber|block": "i2c écrire nombre|à l’adresse %address|avec value %value|de format %format=i2c_sizeof",
|
||||
"pins.map|block": "",
|
||||
"pins.onPulsed|block": "lorsque|la broche %pin|est pulsée %pulse",
|
||||
"pins.pulseDuration|block": "durée de l’impulsion (µs)",
|
||||
"pins.pulseIn|block": "",
|
||||
"pins.servoSetPulse|block": "",
|
||||
"pins.servoWritePin|block": "servo écrire|broche %name|à %value",
|
||||
"pins.setPull|block": "",
|
||||
"pins.spiWrite|block": "spi écrire %value",
|
||||
"pins|block": "broches",
|
||||
"serial.delimiters|block": "",
|
||||
"serial.readLine|block": "série|lire ligne",
|
||||
"serial.readUntil|block": "série|lire jusque %delimiter=serial_delimiter_conv",
|
||||
"serial.redirect|block": "série|rediriger vers|TX %tx|RX %rx|au débit en baudes %rate",
|
||||
@ -105,6 +84,5 @@
|
||||
"{id:category}Music": "Musique",
|
||||
"{id:category}Pins": "Broches",
|
||||
"{id:category}Serial": "Communication Série",
|
||||
"{id:category}String": "Texte",
|
||||
"{id:category}Text": ""
|
||||
"{id:category}String": "Texte"
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
#include "ksbit.h"
|
||||
#include "pxt.h"
|
||||
|
||||
|
||||
/**
|
||||
|
@ -1,4 +1,4 @@
|
||||
#include "ksbit.h"
|
||||
#include "pxt.h"
|
||||
|
||||
// keep in sync with github/pxt/pxtsim/libgeneric.ts
|
||||
enum class NumberFormat {
|
||||
|
@ -1,4 +1,4 @@
|
||||
#include "ksbit.h"
|
||||
#include "pxt.h"
|
||||
|
||||
/**
|
||||
* How to create the event.
|
||||
|
@ -1,4 +1,4 @@
|
||||
#include "ksbit.h"
|
||||
#include "pxt.h"
|
||||
#include <limits.h>
|
||||
|
||||
|
||||
|
116
libs/core/dal.d.ts
vendored
116
libs/core/dal.d.ts
vendored
@ -1,11 +1,11 @@
|
||||
// Auto-generated. Do not edit.
|
||||
declare const enum DAL {
|
||||
// built\yt\yotta_modules\microbit-dal\inc\bluetooth\ExternalEvents.h
|
||||
// built/yt/yotta_modules/microbit-dal/inc/bluetooth/ExternalEvents.h
|
||||
MICROBIT_ID_BLE = 1000,
|
||||
MICROBIT_ID_BLE_UART = 1200,
|
||||
MICROBIT_BLE_EVT_CONNECTED = 1,
|
||||
MICROBIT_BLE_EVT_DISCONNECTED = 2,
|
||||
// built\yt\yotta_modules\microbit-dal\inc\bluetooth\MESEvents.h
|
||||
// built/yt/yotta_modules/microbit-dal/inc/bluetooth/MESEvents.h
|
||||
MES_REMOTE_CONTROL_ID = 1001,
|
||||
MES_REMOTE_CONTROL_EVT_PLAY = 1,
|
||||
MES_REMOTE_CONTROL_EVT_PAUSE = 2,
|
||||
@ -70,8 +70,8 @@ declare const enum DAL {
|
||||
MES_DPAD_BUTTON_4_DOWN = 15,
|
||||
MES_DPAD_BUTTON_4_UP = 16,
|
||||
MES_BROADCAST_GENERAL_ID = 2000,
|
||||
// built\yt\yotta_modules\microbit-dal\inc\bluetooth\MicroBitAccelerometerService.h
|
||||
// built\yt\yotta_modules\microbit-dal\inc\bluetooth\MicroBitBLEManager.h
|
||||
// built/yt/yotta_modules/microbit-dal/inc/bluetooth/MicroBitAccelerometerService.h
|
||||
// built/yt/yotta_modules/microbit-dal/inc/bluetooth/MicroBitBLEManager.h
|
||||
MICROBIT_BLE_PAIR_REQUEST = 0x01,
|
||||
MICROBIT_BLE_PAIR_COMPLETE = 0x02,
|
||||
MICROBIT_BLE_PAIR_PASSCODE = 0x04,
|
||||
@ -79,27 +79,29 @@ declare const enum DAL {
|
||||
MICROBIT_BLE_PAIRING_TIMEOUT = 90,
|
||||
MICROBIT_BLE_POWER_LEVELS = 8,
|
||||
MICROBIT_BLE_MAXIMUM_BONDS = 4,
|
||||
MICROBIT_BLE_EDDYSTONE_URL_ADV_INTERVAL = 400,
|
||||
// built\yt\yotta_modules\microbit-dal\inc\bluetooth\MicroBitButtonService.h
|
||||
// built\yt\yotta_modules\microbit-dal\inc\bluetooth\MicroBitDFUService.h
|
||||
MICROBIT_BLE_EDDYSTONE_ADV_INTERVAL = 400,
|
||||
MICROBIT_BLE_EDDYSTONE_DEFAULT_POWER = 0xF0,
|
||||
// built/yt/yotta_modules/microbit-dal/inc/bluetooth/MicroBitButtonService.h
|
||||
// built/yt/yotta_modules/microbit-dal/inc/bluetooth/MicroBitDFUService.h
|
||||
MICROBIT_DFU_OPCODE_START_DFU = 1,
|
||||
MICROBIT_DFU_HISTOGRAM_WIDTH = 5,
|
||||
MICROBIT_DFU_HISTOGRAM_HEIGHT = 5,
|
||||
// built\yt\yotta_modules\microbit-dal\inc\bluetooth\MicroBitEventService.h
|
||||
// built\yt\yotta_modules\microbit-dal\inc\bluetooth\MicroBitIOPinService.h
|
||||
// built/yt/yotta_modules/microbit-dal/inc/bluetooth/MicroBitEddystone.h
|
||||
// built/yt/yotta_modules/microbit-dal/inc/bluetooth/MicroBitEventService.h
|
||||
// built/yt/yotta_modules/microbit-dal/inc/bluetooth/MicroBitIOPinService.h
|
||||
MICROBIT_IO_PIN_SERVICE_PINCOUNT = 19,
|
||||
MICROBIT_IO_PIN_SERVICE_DATA_SIZE = 10,
|
||||
MICROBIT_PWM_PIN_SERVICE_DATA_SIZE = 2,
|
||||
// built\yt\yotta_modules\microbit-dal\inc\bluetooth\MicroBitLEDService.h
|
||||
// built/yt/yotta_modules/microbit-dal/inc/bluetooth/MicroBitLEDService.h
|
||||
MICROBIT_BLE_MAXIMUM_SCROLLTEXT = 20,
|
||||
// built\yt\yotta_modules\microbit-dal\inc\bluetooth\MicroBitMagnetometerService.h
|
||||
// built\yt\yotta_modules\microbit-dal\inc\bluetooth\MicroBitTemperatureService.h
|
||||
// built\yt\yotta_modules\microbit-dal\inc\bluetooth\MicroBitUARTService.h
|
||||
// built/yt/yotta_modules/microbit-dal/inc/bluetooth/MicroBitMagnetometerService.h
|
||||
// built/yt/yotta_modules/microbit-dal/inc/bluetooth/MicroBitTemperatureService.h
|
||||
// built/yt/yotta_modules/microbit-dal/inc/bluetooth/MicroBitUARTService.h
|
||||
MICROBIT_UART_S_DEFAULT_BUF_SIZE = 20,
|
||||
MICROBIT_UART_S_EVT_DELIM_MATCH = 1,
|
||||
MICROBIT_UART_S_EVT_HEAD_MATCH = 2,
|
||||
MICROBIT_UART_S_EVT_RX_FULL = 3,
|
||||
// built\yt\yotta_modules\microbit-dal\inc\core\ErrorNo.h
|
||||
// built/yt/yotta_modules/microbit-dal/inc/core/ErrorNo.h
|
||||
MICROBIT_OK = 0,
|
||||
MICROBIT_INVALID_PARAMETER = -1001,
|
||||
MICROBIT_NOT_SUPPORTED = -1002,
|
||||
@ -114,10 +116,10 @@ declare const enum DAL {
|
||||
MICROBIT_OOM = 20,
|
||||
MICROBIT_HEAP_ERROR = 30,
|
||||
MICROBIT_NULL_DEREFERENCE = 40,
|
||||
// built\yt\yotta_modules\microbit-dal\inc\core\EventModel.h
|
||||
// built\yt\yotta_modules\microbit-dal\inc\core\MemberFunctionCallback.h
|
||||
// built\yt\yotta_modules\microbit-dal\inc\core\MicroBitCompat.h
|
||||
// built\yt\yotta_modules\microbit-dal\inc\core\MicroBitComponent.h
|
||||
// built/yt/yotta_modules/microbit-dal/inc/core/EventModel.h
|
||||
// built/yt/yotta_modules/microbit-dal/inc/core/MemberFunctionCallback.h
|
||||
// built/yt/yotta_modules/microbit-dal/inc/core/MicroBitCompat.h
|
||||
// built/yt/yotta_modules/microbit-dal/inc/core/MicroBitComponent.h
|
||||
MICROBIT_ID_BUTTON_A = 1,
|
||||
MICROBIT_ID_BUTTON_B = 2,
|
||||
MICROBIT_ID_BUTTON_RESET = 3,
|
||||
@ -155,25 +157,25 @@ declare const enum DAL {
|
||||
MICROBIT_ID_NOTIFY_ONE = 1022,
|
||||
MICROBIT_ID_NOTIFY = 1023,
|
||||
MICROBIT_COMPONENT_RUNNING = 0x01,
|
||||
// built\yt\yotta_modules\microbit-dal\inc\core\MicroBitDevice.h
|
||||
// built/yt/yotta_modules/microbit-dal/inc/core/MicroBitDevice.h
|
||||
MICROBIT_NAME_LENGTH = 5,
|
||||
MICROBIT_NAME_CODE_LETTERS = 5,
|
||||
MICROBIT_PANIC_ERROR_CHARS = 4,
|
||||
// built\yt\yotta_modules\microbit-dal\inc\core\MicroBitFiber.h
|
||||
// built/yt/yotta_modules/microbit-dal/inc/core/MicroBitFiber.h
|
||||
MICROBIT_SCHEDULER_RUNNING = 0x01,
|
||||
MICROBIT_FIBER_FLAG_FOB = 0x01,
|
||||
MICROBIT_FIBER_FLAG_PARENT = 0x02,
|
||||
MICROBIT_FIBER_FLAG_CHILD = 0x04,
|
||||
MICROBIT_FIBER_FLAG_DO_NOT_PAGE = 0x08,
|
||||
// built\yt\yotta_modules\microbit-dal\inc\core\MicroBitFont.h
|
||||
// built/yt/yotta_modules/microbit-dal/inc/core/MicroBitFont.h
|
||||
MICROBIT_FONT_WIDTH = 5,
|
||||
MICROBIT_FONT_HEIGHT = 5,
|
||||
MICROBIT_FONT_ASCII_START = 32,
|
||||
MICROBIT_FONT_ASCII_END = 126,
|
||||
// built\yt\yotta_modules\microbit-dal\inc\core\MicroBitHeapAllocator.h
|
||||
// built/yt/yotta_modules/microbit-dal/inc/core/MicroBitHeapAllocator.h
|
||||
MICROBIT_MAXIMUM_HEAPS = 2,
|
||||
MICROBIT_HEAP_BLOCK_FREE = 0x80000000,
|
||||
// built\yt\yotta_modules\microbit-dal\inc\core\MicroBitListener.h
|
||||
// built/yt/yotta_modules/microbit-dal/inc/core/MicroBitListener.h
|
||||
MESSAGE_BUS_LISTENER_PARAMETERISED = 0x0001,
|
||||
MESSAGE_BUS_LISTENER_METHOD = 0x0002,
|
||||
MESSAGE_BUS_LISTENER_BUSY = 0x0004,
|
||||
@ -183,17 +185,17 @@ declare const enum DAL {
|
||||
MESSAGE_BUS_LISTENER_NONBLOCKING = 0x0040,
|
||||
MESSAGE_BUS_LISTENER_URGENT = 0x0080,
|
||||
MESSAGE_BUS_LISTENER_DELETING = 0x8000,
|
||||
// built\yt\yotta_modules\microbit-dal\inc\core\MicroBitSystemTimer.h
|
||||
// built\yt\yotta_modules\microbit-dal\inc\core\NotifyEvents.h
|
||||
// built/yt/yotta_modules/microbit-dal/inc/core/MicroBitSystemTimer.h
|
||||
// built/yt/yotta_modules/microbit-dal/inc/core/NotifyEvents.h
|
||||
MICROBIT_DISPLAY_EVT_FREE = 1,
|
||||
MICROBIT_SERIAL_EVT_TX_EMPTY = 2,
|
||||
MICROBIT_UART_S_EVT_TX_EMPTY = 3,
|
||||
// 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,
|
||||
PWM_PERSISTENCE_TRANSIENT = 1,
|
||||
PWM_PERSISTENCE_PERSISTENT = 2,
|
||||
// built\yt\yotta_modules\microbit-dal\inc\drivers\MicroBitAccelerometer.h
|
||||
// built/yt/yotta_modules/microbit-dal/inc/drivers/MicroBitAccelerometer.h
|
||||
MICROBIT_ACCEL_PITCH_ROLL_VALID = 0x02,
|
||||
MICROBIT_ACCEL_ADDED_TO_IDLE = 0x04,
|
||||
MMA8653_DEFAULT_ADDR = 0x3A,
|
||||
@ -233,7 +235,7 @@ declare const enum DAL {
|
||||
MICROBIT_ACCELEROMETER_SHAKE_DAMPING = 10,
|
||||
MICROBIT_ACCELEROMETER_SHAKE_RTX = 30,
|
||||
MICROBIT_ACCELEROMETER_SHAKE_COUNT_THRESHOLD = 4,
|
||||
// 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_UP = 2,
|
||||
MICROBIT_BUTTON_EVT_CLICK = 3,
|
||||
@ -253,7 +255,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.h
|
||||
MAG3110_DEFAULT_ADDR = 0x1D,
|
||||
MAG_DR_STATUS = 0x00,
|
||||
MAG_OUT_X_MSB = 0x01,
|
||||
@ -284,8 +286,8 @@ 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\MicroBitCompassCalibrator.h
|
||||
// built\yt\yotta_modules\microbit-dal\inc\drivers\MicroBitDisplay.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,
|
||||
MICROBIT_DISPLAY_EVT_LIGHT_SENSE = 2,
|
||||
MICROBIT_DISPLAY_DEFAULT_AUTOCLEAR = 1,
|
||||
@ -307,8 +309,8 @@ declare const enum DAL {
|
||||
MICROBIT_DISPLAY_ROTATION_90 = 1,
|
||||
MICROBIT_DISPLAY_ROTATION_180 = 2,
|
||||
MICROBIT_DISPLAY_ROTATION_270 = 3,
|
||||
// built\yt\yotta_modules\microbit-dal\inc\drivers\MicroBitFile.h
|
||||
// built\yt\yotta_modules\microbit-dal\inc\drivers\MicroBitFileSystem.h
|
||||
// built/yt/yotta_modules/microbit-dal/inc/drivers/MicroBitFile.h
|
||||
// built/yt/yotta_modules/microbit-dal/inc/drivers/MicroBitFileSystem.h
|
||||
MBFS_FILENAME_LENGTH = 16,
|
||||
MB_READ = 0x01,
|
||||
MB_WRITE = 0x02,
|
||||
@ -329,23 +331,23 @@ declare const enum DAL {
|
||||
MBFS_BLOCK_TYPE_FILE = 1,
|
||||
MBFS_BLOCK_TYPE_DIRECTORY = 2,
|
||||
MBFS_BLOCK_TYPE_FILETABLE = 3,
|
||||
// built\yt\yotta_modules\microbit-dal\inc\drivers\MicroBitFlash.h
|
||||
// built/yt/yotta_modules/microbit-dal/inc/drivers/MicroBitFlash.h
|
||||
PAGE_SIZE = 1024,
|
||||
// built\yt\yotta_modules\microbit-dal\inc\drivers\MicroBitI2C.h
|
||||
// built/yt/yotta_modules/microbit-dal/inc/drivers/MicroBitI2C.h
|
||||
MICROBIT_I2C_MAX_RETRIES = 9,
|
||||
// built\yt\yotta_modules\microbit-dal\inc\drivers\MicroBitIO.h
|
||||
// built\yt\yotta_modules\microbit-dal\inc\drivers\MicroBitLightSensor.h
|
||||
// built/yt/yotta_modules/microbit-dal/inc/drivers/MicroBitIO.h
|
||||
// built/yt/yotta_modules/microbit-dal/inc/drivers/MicroBitLightSensor.h
|
||||
MICROBIT_LIGHT_SENSOR_CHAN_NUM = 3,
|
||||
MICROBIT_LIGHT_SENSOR_AN_SET_TIME = 4000,
|
||||
MICROBIT_LIGHT_SENSOR_TICK_PERIOD = 5,
|
||||
MICROBIT_LIGHT_SENSOR_MAX_VALUE = 338,
|
||||
MICROBIT_LIGHT_SENSOR_MIN_VALUE = 75,
|
||||
// built\yt\yotta_modules\microbit-dal\inc\drivers\MicroBitMatrixMaps.h
|
||||
// built/yt/yotta_modules/microbit-dal/inc/drivers/MicroBitMatrixMaps.h
|
||||
NO_CONN = 0,
|
||||
MICROBIT_DISPLAY_WIDTH = 5,
|
||||
MICROBIT_DISPLAY_HEIGHT = 5,
|
||||
// built\yt\yotta_modules\microbit-dal\inc\drivers\MicroBitMessageBus.h
|
||||
// built\yt\yotta_modules\microbit-dal\inc\drivers\MicroBitMultiButton.h
|
||||
// built/yt/yotta_modules/microbit-dal/inc/drivers/MicroBitMessageBus.h
|
||||
// built/yt/yotta_modules/microbit-dal/inc/drivers/MicroBitMultiButton.h
|
||||
MICROBIT_MULTI_BUTTON_STATE_1 = 0x01,
|
||||
MICROBIT_MULTI_BUTTON_STATE_2 = 0x02,
|
||||
MICROBIT_MULTI_BUTTON_HOLD_TRIGGERED_1 = 0x04,
|
||||
@ -353,7 +355,7 @@ declare const enum DAL {
|
||||
MICROBIT_MULTI_BUTTON_SUPRESSED_1 = 0X10,
|
||||
MICROBIT_MULTI_BUTTON_SUPRESSED_2 = 0x20,
|
||||
MICROBIT_MULTI_BUTTON_ATTACHED = 0x40,
|
||||
// built\yt\yotta_modules\microbit-dal\inc\drivers\MicroBitPin.h
|
||||
// built/yt/yotta_modules/microbit-dal/inc/drivers/MicroBitPin.h
|
||||
IO_STATUS_DIGITAL_IN = 0x01,
|
||||
IO_STATUS_DIGITAL_OUT = 0x02,
|
||||
IO_STATUS_ANALOG_IN = 0x04,
|
||||
@ -375,7 +377,7 @@ declare const enum DAL {
|
||||
MICROBIT_PIN_EVT_PULSE_LO = 5,
|
||||
PIN_CAPABILITY_DIGITAL = 0x01,
|
||||
PIN_CAPABILITY_ANALOG = 0x02,
|
||||
// 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_BASE_ADDRESS = 0x75626974,
|
||||
MICROBIT_RADIO_DEFAULT_GROUP = 0,
|
||||
@ -387,9 +389,9 @@ declare const enum DAL {
|
||||
MICROBIT_RADIO_PROTOCOL_DATAGRAM = 1,
|
||||
MICROBIT_RADIO_PROTOCOL_EVENTBUS = 2,
|
||||
MICROBIT_RADIO_EVT_DATAGRAM = 1,
|
||||
// built\yt\yotta_modules\microbit-dal\inc\drivers\MicroBitRadioDatagram.h
|
||||
// built\yt\yotta_modules\microbit-dal\inc\drivers\MicroBitRadioEvent.h
|
||||
// built\yt\yotta_modules\microbit-dal\inc\drivers\MicroBitSerial.h
|
||||
// built/yt/yotta_modules/microbit-dal/inc/drivers/MicroBitRadioDatagram.h
|
||||
// built/yt/yotta_modules/microbit-dal/inc/drivers/MicroBitRadioEvent.h
|
||||
// built/yt/yotta_modules/microbit-dal/inc/drivers/MicroBitSerial.h
|
||||
MICROBIT_SERIAL_DEFAULT_BAUD_RATE = 115200,
|
||||
MICROBIT_SERIAL_DEFAULT_BUFFER_SIZE = 20,
|
||||
MICROBIT_SERIAL_EVT_DELIM_MATCH = 1,
|
||||
@ -402,31 +404,31 @@ declare const enum DAL {
|
||||
ASYNC = 0,
|
||||
SYNC_SPINWAIT = 1,
|
||||
SYNC_SLEEP = 2,
|
||||
// built\yt\yotta_modules\microbit-dal\inc\drivers\MicroBitStorage.h
|
||||
// built/yt/yotta_modules/microbit-dal/inc/drivers/MicroBitStorage.h
|
||||
MICROBIT_STORAGE_MAGIC = 0xCAFE,
|
||||
MICROBIT_STORAGE_BLOCK_SIZE = 48,
|
||||
MICROBIT_STORAGE_KEY_SIZE = 16,
|
||||
MICROBIT_STORAGE_STORE_PAGE_OFFSET = 17,
|
||||
MICROBIT_STORAGE_SCRATCH_PAGE_OFFSET = 19,
|
||||
// built\yt\yotta_modules\microbit-dal\inc\drivers\MicroBitThermometer.h
|
||||
// built/yt/yotta_modules/microbit-dal/inc/drivers/MicroBitThermometer.h
|
||||
MICROBIT_THERMOMETER_PERIOD = 1000,
|
||||
MICROBIT_THERMOMETER_EVT_UPDATE = 1,
|
||||
MICROBIT_THERMOMETER_ADDED_TO_IDLE = 2,
|
||||
// built\yt\yotta_modules\microbit-dal\inc\drivers\TimedInterruptIn.h
|
||||
// built\yt\yotta_modules\microbit-dal\inc\platform\yotta_cfg_mappings.h
|
||||
// built\yt\yotta_modules\microbit-dal\inc\types\ManagedString.h
|
||||
// built\yt\yotta_modules\microbit-dal\inc\types\ManagedType.h
|
||||
// built\yt\yotta_modules\microbit-dal\inc\types\Matrix4.h
|
||||
// built\yt\yotta_modules\microbit-dal\inc\types\MicroBitCoordinateSystem.h
|
||||
// built/yt/yotta_modules/microbit-dal/inc/drivers/TimedInterruptIn.h
|
||||
// built/yt/yotta_modules/microbit-dal/inc/platform/yotta_cfg_mappings.h
|
||||
// built/yt/yotta_modules/microbit-dal/inc/types/ManagedString.h
|
||||
// built/yt/yotta_modules/microbit-dal/inc/types/ManagedType.h
|
||||
// built/yt/yotta_modules/microbit-dal/inc/types/Matrix4.h
|
||||
// built/yt/yotta_modules/microbit-dal/inc/types/MicroBitCoordinateSystem.h
|
||||
RAW = 0,
|
||||
SIMPLE_CARTESIAN = 1,
|
||||
NORTH_EAST_DOWN = 2,
|
||||
// built\yt\yotta_modules\microbit-dal\inc\types\MicroBitEvent.h
|
||||
// built/yt/yotta_modules/microbit-dal/inc/types/MicroBitEvent.h
|
||||
MICROBIT_ID_ANY = 0,
|
||||
MICROBIT_EVT_ANY = 0,
|
||||
CREATE_ONLY = 0,
|
||||
CREATE_AND_FIRE = 1,
|
||||
// built\yt\yotta_modules\microbit-dal\inc\types\MicroBitImage.h
|
||||
// built\yt\yotta_modules\microbit-dal\inc\types\PacketBuffer.h
|
||||
// built\yt\yotta_modules\microbit-dal\inc\types\RefCounted.h
|
||||
// built/yt/yotta_modules/microbit-dal/inc/types/MicroBitImage.h
|
||||
// built/yt/yotta_modules/microbit-dal/inc/types/PacketBuffer.h
|
||||
// built/yt/yotta_modules/microbit-dal/inc/types/RefCounted.h
|
||||
}
|
||||
|
2
libs/core/enums.d.ts
vendored
2
libs/core/enums.d.ts
vendored
@ -275,7 +275,9 @@ declare namespace led {
|
||||
|
||||
|
||||
declare enum PulseValue {
|
||||
//% block=high
|
||||
High = 4, // MICROBIT_PIN_EVT_PULSE_HI
|
||||
//% block=low
|
||||
Low = 5, // MICROBIT_PIN_EVT_PULSE_LO
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
#include "ksbit.h"
|
||||
#include "pxt.h"
|
||||
|
||||
/**
|
||||
* Creation, manipulation and display of LED images.
|
||||
@ -61,18 +61,15 @@ namespace ImageMethods {
|
||||
|
||||
/**
|
||||
* Scrolls an image .
|
||||
* @param frameOffset x offset moved on each animation step, eg: 5, 1, -1
|
||||
* @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
|
||||
*/
|
||||
//% 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
|
||||
//% parts="ledmatrix"
|
||||
void scrollImage(Image id, int frameOffset, int interval) {
|
||||
MicroBitImage i(id);
|
||||
if (i.getWidth() <= 5)
|
||||
showImage(id, 0);
|
||||
else
|
||||
uBit.display.animate(i, interval, frameOffset, 0);
|
||||
uBit.display.animate(i, interval, frameOffset, MICROBIT_DISPLAY_WIDTH - 1);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
#include "ksbit.h"
|
||||
#include "pxt.h"
|
||||
|
||||
enum class Button {
|
||||
A = MICROBIT_ID_BUTTON_A,
|
||||
|
@ -1,12 +0,0 @@
|
||||
#include "pxt.h"
|
||||
#include "ManagedBuffer.h"
|
||||
|
||||
using namespace pxt;
|
||||
MicroBitPin *getPin(int id);
|
||||
typedef ImageData* Image;
|
||||
typedef BufferData* Buffer;
|
||||
|
||||
namespace pxt {
|
||||
uint32_t programSize();
|
||||
uint32_t afterProgramPage();
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
#include "ksbit.h"
|
||||
#include "pxt.h"
|
||||
|
||||
enum class DisplayMode_ {
|
||||
//% block="black and white"
|
||||
|
@ -138,7 +138,6 @@ namespace music {
|
||||
//% blockId=device_play_note block="play|tone %note=device_note|for %duration=device_beat" icon="\uf025" blockGap=8
|
||||
//% parts="headphone"
|
||||
export function playTone(frequency: number, ms: number): void {
|
||||
pins.analogSetPitchPin(AnalogPin.P0);
|
||||
pins.analogPitch(frequency, ms);
|
||||
}
|
||||
|
||||
@ -150,7 +149,6 @@ namespace music {
|
||||
//% blockId=device_ring block="ring tone (Hz)|%note=device_note" icon="\uf025" blockGap=8
|
||||
//% parts="headphone"
|
||||
export function ringTone(frequency: number): void {
|
||||
pins.analogSetPitchPin(AnalogPin.P0);
|
||||
pins.analogPitch(frequency, 0);
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
#include "ksbit.h"
|
||||
#include "pxt.h"
|
||||
|
||||
enum class DigitalPin {
|
||||
P0 = MICROBIT_ID_IO_P0,
|
||||
@ -32,7 +32,9 @@ enum class AnalogPin {
|
||||
};
|
||||
|
||||
enum class PulseValue {
|
||||
//% block=high
|
||||
High = MICROBIT_PIN_EVT_PULSE_HI,
|
||||
//% block=low
|
||||
Low = MICROBIT_PIN_EVT_PULSE_LO
|
||||
};
|
||||
|
||||
@ -145,7 +147,7 @@ namespace pins {
|
||||
/**
|
||||
* Configures this pin to a digital input, and generates events where the timestamp is the duration that this pin was either ``high`` or ``low``.
|
||||
*/
|
||||
//% 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"
|
||||
void onPulsed(DigitalPin name, PulseValue pulse, Action body) {
|
||||
MicroBitPin* pin = getPin((int)name);
|
||||
@ -158,7 +160,7 @@ namespace pins {
|
||||
/**
|
||||
* 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)"
|
||||
//% weight=21 blockGap=8
|
||||
int pulseDuration() {
|
||||
@ -172,7 +174,7 @@ namespace pins {
|
||||
* @param maximum duration in micro-seconds
|
||||
*/
|
||||
//% blockId="pins_pulse_in" block="pulse in (µs)|pin %name|pulsed %value"
|
||||
//% weight=20
|
||||
//% weight=20 advanced=true
|
||||
int pulseIn(DigitalPin name, PulseValue value, int maxDuration = 2000000) {
|
||||
MicroBitPin* pin = getPin((int)name);
|
||||
if (!pin) return 0;
|
||||
@ -221,22 +223,25 @@ namespace pins {
|
||||
MicroBitPin* pitchPin = NULL;
|
||||
|
||||
/**
|
||||
* Sets the pin used when using `pins->analog pitch`.
|
||||
* @param name TODO
|
||||
* Sets the pin used when using `analog pitch` or music.
|
||||
* @param name pin to modulate pitch from
|
||||
*/
|
||||
//% help=pins/analog-set-pitch weight=12
|
||||
//% blockId=device_analog_set_pitch_pin block="analog set pitch pin %name"
|
||||
//% help=pins/analog-set-pitch weight=3 advanced=true
|
||||
void analogSetPitchPin(AnalogPin 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.
|
||||
* @param frequency TODO
|
||||
* @param ms TODO
|
||||
* @param frequency frequency to modulate in Hz.
|
||||
* @param ms duration of the pitch in milli seconds.
|
||||
*/
|
||||
//% help=pins/analog-pitch weight=14 async
|
||||
//% blockId=device_analog_pitch block="analog pitch %frequency|for (ms) %ms"
|
||||
//% help=pins/analog-pitch weight=4 async advanced=true blockGap=8
|
||||
void analogPitch(int frequency, int ms) {
|
||||
if (pitchPin == NULL) return;
|
||||
if (pitchPin == NULL)
|
||||
analogSetPitchPin(AnalogPin::P0);
|
||||
if (frequency <= 0) {
|
||||
pitchPin->setAnalogValue(0);
|
||||
} else {
|
||||
@ -258,7 +263,7 @@ namespace pins {
|
||||
* @param name pin to set the pull mode on
|
||||
* @param pull one of the mbed pull configurations: PullUp, PullDown, PullNone
|
||||
*/
|
||||
//% 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"
|
||||
void setPull(DigitalPin name, PinPullMode pull) {
|
||||
PinMode m = pull == PinPullMode::PullDown
|
||||
@ -309,7 +314,7 @@ namespace pins {
|
||||
* Write to the SPI slave and return the response
|
||||
* @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"
|
||||
int spiWrite(int value) {
|
||||
auto p = allocSPI();
|
||||
|
@ -21,7 +21,7 @@ namespace pins {
|
||||
/**
|
||||
* Read one number from 7-bit I2C address.
|
||||
*/
|
||||
//% help=pins/i2c-read-number blockGap=8
|
||||
//% help=pins/i2c-read-number blockGap=8 advanced=true
|
||||
//% 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))
|
||||
@ -31,7 +31,7 @@ namespace pins {
|
||||
/**
|
||||
* Write one number to a 7-bit I2C address.
|
||||
*/
|
||||
//% help=pins/i2c-write-number blockGap=8
|
||||
//% help=pins/i2c-write-number blockGap=8 advanced=true
|
||||
//% 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 {
|
||||
let buf = createBuffer(pins.sizeOf(format))
|
||||
|
472
libs/core/pxt.cpp
Normal file
472
libs/core/pxt.cpp
Normal file
@ -0,0 +1,472 @@
|
||||
#include "pxt.h"
|
||||
#include <map>
|
||||
|
||||
MicroBit uBit;
|
||||
|
||||
namespace pxt {
|
||||
int incr(uint32_t e)
|
||||
{
|
||||
if (e) {
|
||||
if (hasVTable(e))
|
||||
((RefObject*)e)->ref();
|
||||
else
|
||||
((RefCounted*)e)->incr();
|
||||
}
|
||||
return e;
|
||||
}
|
||||
|
||||
void decr(uint32_t e)
|
||||
{
|
||||
if (e) {
|
||||
if (hasVTable(e))
|
||||
((RefObject*)e)->unref();
|
||||
else
|
||||
((RefCounted*)e)->decr();
|
||||
}
|
||||
}
|
||||
|
||||
Action mkAction(int reflen, int totallen, int startptr)
|
||||
{
|
||||
check(0 <= reflen && reflen <= totallen, ERR_SIZE, 1);
|
||||
check(reflen <= totallen && totallen <= 255, ERR_SIZE, 2);
|
||||
check(bytecode[startptr] == 0xffff, ERR_INVALID_BINARY_HEADER, 3);
|
||||
check(bytecode[startptr + 1] == 0, ERR_INVALID_BINARY_HEADER, 4);
|
||||
|
||||
uint32_t tmp = (uint32_t)&bytecode[startptr];
|
||||
|
||||
if (totallen == 0) {
|
||||
return tmp; // no closure needed
|
||||
}
|
||||
|
||||
void *ptr = ::operator new(sizeof(RefAction) + totallen * sizeof(uint32_t));
|
||||
RefAction *r = new (ptr) RefAction();
|
||||
r->len = totallen;
|
||||
r->reflen = reflen;
|
||||
r->func = (ActionCB)((tmp + 4) | 1);
|
||||
memset(r->fields, 0, r->len * sizeof(uint32_t));
|
||||
|
||||
return (Action)r;
|
||||
}
|
||||
|
||||
uint32_t runAction3(Action a, int arg0, int arg1, int arg2)
|
||||
{
|
||||
if (hasVTable(a))
|
||||
return ((RefAction*)a)->runCore(arg0, arg1, arg2);
|
||||
else {
|
||||
check(*(uint16_t*)a == 0xffff, ERR_INVALID_BINARY_HEADER, 4);
|
||||
return ((ActionCB)((a + 4) | 1))(NULL, arg0, arg1, arg2);
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t runAction2(Action a, int arg0, int arg1)
|
||||
{
|
||||
return runAction3(a, arg0, arg1, 0);
|
||||
}
|
||||
|
||||
uint32_t runAction1(Action a, int arg0)
|
||||
{
|
||||
return runAction3(a, arg0, 0, 0);
|
||||
}
|
||||
|
||||
uint32_t runAction0(Action a)
|
||||
{
|
||||
return runAction3(a, 0, 0, 0);
|
||||
}
|
||||
|
||||
RefRecord* mkClassInstance(int vtableOffset)
|
||||
{
|
||||
VTable *vtable = (VTable*)&bytecode[vtableOffset];
|
||||
|
||||
intcheck(vtable->methods[0] == &RefRecord_destroy, ERR_SIZE, 3);
|
||||
intcheck(vtable->methods[1] == &RefRecord_print, ERR_SIZE, 4);
|
||||
|
||||
void *ptr = ::operator new(vtable->numbytes);
|
||||
RefRecord *r = new (ptr) RefRecord(PXT_VTABLE_TO_INT(vtable));
|
||||
memset(r->fields, 0, vtable->numbytes - sizeof(RefRecord));
|
||||
return r;
|
||||
}
|
||||
|
||||
uint32_t RefRecord::ld(int idx)
|
||||
{
|
||||
//intcheck((reflen == 255 ? 0 : reflen) <= idx && idx < len, ERR_OUT_OF_BOUNDS, 1);
|
||||
return fields[idx];
|
||||
}
|
||||
|
||||
uint32_t RefRecord::ldref(int idx)
|
||||
{
|
||||
//printf("LD %p len=%d reflen=%d idx=%d\n", this, len, reflen, idx);
|
||||
//intcheck(0 <= idx && idx < reflen, ERR_OUT_OF_BOUNDS, 2);
|
||||
uint32_t tmp = fields[idx];
|
||||
incr(tmp);
|
||||
return tmp;
|
||||
}
|
||||
|
||||
void RefRecord::st(int idx, uint32_t v)
|
||||
{
|
||||
//intcheck((reflen == 255 ? 0 : reflen) <= idx && idx < len, ERR_OUT_OF_BOUNDS, 3);
|
||||
fields[idx] = v;
|
||||
}
|
||||
|
||||
void RefRecord::stref(int idx, uint32_t v)
|
||||
{
|
||||
//printf("ST %p len=%d reflen=%d idx=%d\n", this, len, reflen, idx);
|
||||
//intcheck(0 <= idx && idx < reflen, ERR_OUT_OF_BOUNDS, 4);
|
||||
decr(fields[idx]);
|
||||
fields[idx] = v;
|
||||
}
|
||||
|
||||
void RefObject::destroy() {
|
||||
((RefObjectMethod)getVTable()->methods[0])(this);
|
||||
delete this;
|
||||
}
|
||||
|
||||
void RefObject::print() {
|
||||
((RefObjectMethod)getVTable()->methods[1])(this);
|
||||
}
|
||||
|
||||
void RefRecord_destroy(RefRecord *r) {
|
||||
auto tbl = r->getVTable();
|
||||
uint8_t *refmask = (uint8_t*)&tbl->methods[tbl->userdata & 0xff];
|
||||
int len = (tbl->numbytes >> 2) - 1;
|
||||
for (int i = 0; i < len; ++i) {
|
||||
if (refmask[i]) decr(r->fields[i]);
|
||||
r->fields[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void RefRecord_print(RefRecord *r)
|
||||
{
|
||||
printf("RefRecord %p r=%d size=%d bytes\n", r, r->refcnt, r->getVTable()->numbytes);
|
||||
}
|
||||
|
||||
void RefCollection::push(uint32_t x) {
|
||||
if (isRef()) incr(x);
|
||||
data.push_back(x);
|
||||
}
|
||||
|
||||
uint32_t RefCollection::getAt(int x) {
|
||||
if (in_range(x)) {
|
||||
uint32_t tmp = data.at(x);
|
||||
if (isRef()) incr(tmp);
|
||||
return tmp;
|
||||
}
|
||||
else {
|
||||
error(ERR_OUT_OF_BOUNDS);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
void RefCollection::removeAt(int x) {
|
||||
if (!in_range(x))
|
||||
return;
|
||||
|
||||
if (isRef()) decr(data.at(x));
|
||||
data.erase(data.begin()+x);
|
||||
}
|
||||
|
||||
void RefCollection::setAt(int x, uint32_t y) {
|
||||
if (!in_range(x))
|
||||
return;
|
||||
|
||||
if (isRef()) {
|
||||
decr(data.at(x));
|
||||
incr(y);
|
||||
}
|
||||
data.at(x) = y;
|
||||
}
|
||||
|
||||
int RefCollection::indexOf(uint32_t x, int start) {
|
||||
if (!in_range(start))
|
||||
return -1;
|
||||
|
||||
if (isString()) {
|
||||
StringData *xx = (StringData*)x;
|
||||
for (uint32_t i = start; i < data.size(); ++i) {
|
||||
StringData *ee = (StringData*)data.at(i);
|
||||
if (xx->len == ee->len && memcmp(xx->data, ee->data, xx->len) == 0)
|
||||
return (int)i;
|
||||
}
|
||||
} else {
|
||||
for (uint32_t i = start; i < data.size(); ++i)
|
||||
if (data.at(i) == x)
|
||||
return (int)i;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
int RefCollection::removeElement(uint32_t x) {
|
||||
int idx = indexOf(x, 0);
|
||||
if (idx >= 0) {
|
||||
removeAt(idx);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
namespace Coll0 {
|
||||
PXT_VTABLE_BEGIN(RefCollection, 0, 0)
|
||||
PXT_VTABLE_END
|
||||
}
|
||||
namespace Coll1 {
|
||||
PXT_VTABLE_BEGIN(RefCollection, 1, 0)
|
||||
PXT_VTABLE_END
|
||||
}
|
||||
namespace Coll3 {
|
||||
PXT_VTABLE_BEGIN(RefCollection, 3, 0)
|
||||
PXT_VTABLE_END
|
||||
}
|
||||
|
||||
RefCollection::RefCollection(uint16_t flags) : RefObject(0) {
|
||||
switch (flags) {
|
||||
case 0:
|
||||
vtable = PXT_VTABLE_TO_INT(&Coll0::RefCollection_vtable);
|
||||
break;
|
||||
case 1:
|
||||
vtable = PXT_VTABLE_TO_INT(&Coll1::RefCollection_vtable);
|
||||
break;
|
||||
case 3:
|
||||
vtable = PXT_VTABLE_TO_INT(&Coll3::RefCollection_vtable);
|
||||
break;
|
||||
default:
|
||||
error(ERR_SIZE);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void RefCollection::destroy()
|
||||
{
|
||||
if (this->isRef())
|
||||
for (uint32_t i = 0; i < this->data.size(); ++i) {
|
||||
decr(this->data[i]);
|
||||
this->data[i] = 0;
|
||||
}
|
||||
this->data.resize(0);
|
||||
}
|
||||
|
||||
void RefCollection::print()
|
||||
{
|
||||
printf("RefCollection %p r=%d flags=%d size=%d [%p, ...]\n", this, refcnt, getFlags(), data.size(), data.size() > 0 ? data[0] : 0);
|
||||
}
|
||||
|
||||
PXT_VTABLE_CTOR(RefAction) {}
|
||||
|
||||
// fields[] contain captured locals
|
||||
void RefAction::destroy()
|
||||
{
|
||||
for (int i = 0; i < this->reflen; ++i) {
|
||||
decr(fields[i]);
|
||||
fields[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void RefAction::print()
|
||||
{
|
||||
printf("RefAction %p r=%d pc=0x%lx size=%d (%d refs)\n", this, refcnt, (const uint8_t*)func - (const uint8_t*)bytecode, len, reflen);
|
||||
}
|
||||
|
||||
void RefLocal::print()
|
||||
{
|
||||
printf("RefLocal %p r=%d v=%d\n", this, refcnt, v);
|
||||
}
|
||||
|
||||
void RefLocal::destroy()
|
||||
{
|
||||
}
|
||||
|
||||
PXT_VTABLE_CTOR(RefLocal) {
|
||||
v = 0;
|
||||
}
|
||||
|
||||
PXT_VTABLE_CTOR(RefRefLocal) {
|
||||
v = 0;
|
||||
}
|
||||
|
||||
void RefRefLocal::print()
|
||||
{
|
||||
printf("RefRefLocal %p r=%d v=%p\n", this, refcnt, (void*)v);
|
||||
}
|
||||
|
||||
void RefRefLocal::destroy()
|
||||
{
|
||||
decr(v);
|
||||
}
|
||||
|
||||
PXT_VTABLE_BEGIN(RefMap, 0, RefMapMarker)
|
||||
PXT_VTABLE_END
|
||||
RefMap::RefMap() : PXT_VTABLE_INIT(RefMap) {}
|
||||
|
||||
void RefMap::destroy() {
|
||||
for (unsigned i = 0; i < data.size(); ++i) {
|
||||
if (data[i].key & 1) {
|
||||
decr(data[i].val);
|
||||
}
|
||||
data[i].val = 0;
|
||||
}
|
||||
data.resize(0);
|
||||
}
|
||||
|
||||
int RefMap::findIdx(uint32_t key) {
|
||||
for (unsigned i = 0; i < data.size(); ++i) {
|
||||
if (data[i].key >> 1 == key)
|
||||
return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
void RefMap::print()
|
||||
{
|
||||
printf("RefMap %p r=%d size=%d\n", this, refcnt, data.size());
|
||||
}
|
||||
|
||||
|
||||
#ifdef DEBUG_MEMLEAKS
|
||||
std::set<RefObject*> allptrs;
|
||||
void debugMemLeaks()
|
||||
{
|
||||
printf("LIVE POINTERS:\n");
|
||||
for(std::set<RefObject*>::iterator itr = allptrs.begin();itr!=allptrs.end();itr++)
|
||||
{
|
||||
(*itr)->print();
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
#else
|
||||
void debugMemLeaks() {}
|
||||
#endif
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// An adapter for the API expected by the run-time.
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
map<pair<int, int>, Action> handlersMap;
|
||||
|
||||
MicroBitEvent lastEvent;
|
||||
|
||||
// We have the invariant that if [dispatchEvent] is registered against the DAL
|
||||
// for a given event, then [handlersMap] contains a valid entry for that
|
||||
// event.
|
||||
void dispatchEvent(MicroBitEvent e) {
|
||||
|
||||
lastEvent = e;
|
||||
|
||||
Action curr = handlersMap[{ e.source, e.value }];
|
||||
if (curr)
|
||||
runAction1(curr, e.value);
|
||||
|
||||
curr = handlersMap[{ e.source, MICROBIT_EVT_ANY }];
|
||||
if (curr)
|
||||
runAction1(curr, e.value);
|
||||
}
|
||||
|
||||
void registerWithDal(int id, int event, Action a) {
|
||||
Action prev = handlersMap[{ id, event }];
|
||||
if (prev)
|
||||
decr(prev);
|
||||
else
|
||||
uBit.messageBus.listen(id, event, dispatchEvent);
|
||||
incr(a);
|
||||
handlersMap[{ id, event }] = a;
|
||||
}
|
||||
|
||||
void fiberDone(void *a)
|
||||
{
|
||||
decr((Action)a);
|
||||
release_fiber();
|
||||
}
|
||||
|
||||
|
||||
void runInBackground(Action a) {
|
||||
if (a != 0) {
|
||||
incr(a);
|
||||
create_fiber((void(*)(void*))runAction0, (void*)a, fiberDone);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void error(ERROR code, int subcode)
|
||||
{
|
||||
printf("Error: %d [%d]\n", code, subcode);
|
||||
uBit.panic(42);
|
||||
}
|
||||
|
||||
uint16_t *bytecode;
|
||||
uint32_t *globals;
|
||||
int numGlobals;
|
||||
|
||||
uint32_t *allocate(uint16_t sz)
|
||||
{
|
||||
uint32_t *arr = new uint32_t[sz];
|
||||
memset(arr, 0, sz * 4);
|
||||
return arr;
|
||||
}
|
||||
|
||||
void checkStr(bool cond, const char *msg)
|
||||
{
|
||||
if (!cond) {
|
||||
while (true) {
|
||||
uBit.display.scroll(msg, 100);
|
||||
uBit.sleep(100);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int templateHash()
|
||||
{
|
||||
return ((int*)bytecode)[4];
|
||||
}
|
||||
|
||||
int programHash()
|
||||
{
|
||||
return ((int*)bytecode)[6];
|
||||
}
|
||||
|
||||
int getNumGlobals()
|
||||
{
|
||||
return bytecode[16];
|
||||
}
|
||||
|
||||
void exec_binary(int32_t *pc)
|
||||
{
|
||||
// XXX re-enable once the calibration code is fixed and [editor/embedded.ts]
|
||||
// properly prepends a call to [internal_main].
|
||||
// ::touch_develop::internal_main();
|
||||
|
||||
// unique group for radio based on source hash
|
||||
// ::touch_develop::micro_bit::radioDefaultGroup = programHash();
|
||||
|
||||
// repeat error 4 times and restart as needed
|
||||
microbit_panic_timeout(4);
|
||||
|
||||
int32_t ver = *pc++;
|
||||
checkStr(ver == 0x4209, ":( Bad runtime version");
|
||||
|
||||
bytecode = *((uint16_t**)pc++); // the actual bytecode is here
|
||||
globals = allocate(getNumGlobals());
|
||||
|
||||
// just compare the first word
|
||||
checkStr(((uint32_t*)bytecode)[0] == 0x923B8E70 &&
|
||||
templateHash() == *pc,
|
||||
":( Failed partial flash");
|
||||
|
||||
uint32_t startptr = (uint32_t)bytecode;
|
||||
startptr += 48; // header
|
||||
startptr |= 1; // Thumb state
|
||||
|
||||
((uint32_t (*)())startptr)();
|
||||
|
||||
#ifdef DEBUG_MEMLEAKS
|
||||
pxt::debugMemLeaks();
|
||||
#endif
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void start()
|
||||
{
|
||||
exec_binary((int32_t*)functionsAndBytecode);
|
||||
}
|
||||
}
|
||||
|
||||
// vim: ts=2 sw=2 expandtab
|
341
libs/core/pxt.h
Normal file
341
libs/core/pxt.h
Normal file
@ -0,0 +1,341 @@
|
||||
#ifndef __PXT_H
|
||||
#define __PXT_H
|
||||
|
||||
// #define DEBUG_MEMLEAKS 1
|
||||
|
||||
#pragma GCC diagnostic ignored "-Wunused-parameter"
|
||||
|
||||
#include "MicroBit.h"
|
||||
#include "MicroBitImage.h"
|
||||
#include "ManagedString.h"
|
||||
#include "ManagedType.h"
|
||||
#include "ManagedBuffer.h"
|
||||
|
||||
#define printf(...) uBit.serial.printf(__VA_ARGS__)
|
||||
// #define printf(...)
|
||||
|
||||
#define intcheck(...) check(__VA_ARGS__)
|
||||
//#define intcheck(...) do {} while (0)
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <vector>
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef DEBUG_MEMLEAKS
|
||||
#include <set>
|
||||
#endif
|
||||
|
||||
extern MicroBit uBit;
|
||||
|
||||
namespace pxt {
|
||||
typedef uint32_t Action;
|
||||
typedef uint32_t ImageLiteral;
|
||||
|
||||
|
||||
typedef enum {
|
||||
ERR_INVALID_BINARY_HEADER = 5,
|
||||
ERR_OUT_OF_BOUNDS = 8,
|
||||
ERR_REF_DELETED = 7,
|
||||
ERR_SIZE = 9,
|
||||
} ERROR;
|
||||
|
||||
extern const uint32_t functionsAndBytecode[];
|
||||
extern uint32_t *globals;
|
||||
extern uint16_t *bytecode;
|
||||
class RefRecord;
|
||||
|
||||
// Utility functions
|
||||
extern MicroBitEvent lastEvent;
|
||||
void registerWithDal(int id, int event, Action a);
|
||||
void runInBackground(Action a);
|
||||
uint32_t runAction3(Action a, int arg0, int arg1, int arg2);
|
||||
uint32_t runAction2(Action a, int arg0, int arg1);
|
||||
uint32_t runAction1(Action a, int arg0);
|
||||
uint32_t runAction0(Action a);
|
||||
Action mkAction(int reflen, int totallen, int startptr);
|
||||
void error(ERROR code, int subcode = 0);
|
||||
void exec_binary(uint16_t *pc);
|
||||
void start();
|
||||
void debugMemLeaks();
|
||||
// allocate [sz] words and clear them
|
||||
uint32_t *allocate(uint16_t sz);
|
||||
int templateHash();
|
||||
int programHash();
|
||||
uint32_t programSize();
|
||||
uint32_t afterProgramPage();
|
||||
int getNumGlobals();
|
||||
RefRecord* mkClassInstance(int vtableOffset);
|
||||
|
||||
// The standard calling convention is:
|
||||
// - when a pointer is loaded from a local/global/field etc, and incr()ed
|
||||
// (in other words, its presence on stack counts as a reference)
|
||||
// - after a function call, all pointers are popped off the stack and decr()ed
|
||||
// This does not apply to the RefRecord and st/ld(ref) methods - they unref()
|
||||
// the RefRecord* this.
|
||||
int incr(uint32_t e);
|
||||
void decr(uint32_t e);
|
||||
|
||||
inline void *ptrOfLiteral(int offset)
|
||||
{
|
||||
return &bytecode[offset];
|
||||
}
|
||||
|
||||
inline ImageData* imageBytes(int offset)
|
||||
{
|
||||
return (ImageData*)(void*)&bytecode[offset];
|
||||
}
|
||||
|
||||
// Checks if object has a VTable, or if its RefCounted* from the runtime.
|
||||
inline bool hasVTable(uint32_t e)
|
||||
{
|
||||
return (*((uint32_t*)e) & 1) == 0;
|
||||
}
|
||||
|
||||
inline void check(int cond, ERROR code, int subcode = 0)
|
||||
{
|
||||
if (!cond) error(code, subcode);
|
||||
}
|
||||
|
||||
|
||||
class RefObject;
|
||||
#ifdef DEBUG_MEMLEAKS
|
||||
extern std::set<RefObject*> allptrs;
|
||||
#endif
|
||||
|
||||
typedef void (*RefObjectMethod)(RefObject *self);
|
||||
typedef void *PVoid;
|
||||
typedef void **PPVoid;
|
||||
|
||||
const PPVoid RefMapMarker = (PPVoid)(void*)43;
|
||||
|
||||
struct VTable {
|
||||
uint16_t numbytes; // in the entire object, including the vtable pointer
|
||||
uint16_t userdata;
|
||||
PVoid *ifaceTable;
|
||||
PVoid methods[2]; // we only use up to two methods here; pxt will generate more
|
||||
// refmask sits at &methods[nummethods]
|
||||
};
|
||||
|
||||
const int vtableShift = 2;
|
||||
|
||||
// A base abstract class for ref-counted objects.
|
||||
class RefObject
|
||||
{
|
||||
public:
|
||||
uint16_t refcnt;
|
||||
uint16_t vtable;
|
||||
|
||||
RefObject(uint16_t vt)
|
||||
{
|
||||
refcnt = 2;
|
||||
vtable = vt;
|
||||
#ifdef DEBUG_MEMLEAKS
|
||||
allptrs.insert(this);
|
||||
#endif
|
||||
}
|
||||
|
||||
inline VTable *getVTable() {
|
||||
return (VTable*)(vtable << vtableShift);
|
||||
}
|
||||
|
||||
void destroy();
|
||||
void print();
|
||||
|
||||
// Call to disable pointer tracking on the current instance (in destructor or some other hack)
|
||||
inline void untrack() {
|
||||
#ifdef DEBUG_MEMLEAKS
|
||||
allptrs.erase(this);
|
||||
#endif
|
||||
}
|
||||
|
||||
// Increment/decrement the ref-count. Decrementing to zero deletes the current object.
|
||||
inline void ref()
|
||||
{
|
||||
check(refcnt > 0, ERR_REF_DELETED);
|
||||
//printf("INCR "); this->print();
|
||||
refcnt += 2;
|
||||
}
|
||||
|
||||
inline void unref()
|
||||
{
|
||||
//printf("DECR "); this->print();
|
||||
refcnt -= 2;
|
||||
if (refcnt == 0) {
|
||||
destroy();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// A ref-counted collection of either primitive or ref-counted objects (String, Image,
|
||||
// user-defined record, another collection)
|
||||
class RefCollection
|
||||
: public RefObject
|
||||
{
|
||||
public:
|
||||
// 1 - collection of refs (need decr)
|
||||
// 2 - collection of strings (in fact we always have 3, never 2 alone)
|
||||
inline uint32_t getFlags() { return getVTable()->userdata; }
|
||||
inline bool isRef() { return getFlags() & 1; }
|
||||
inline bool isString() { return getFlags() & 2; }
|
||||
|
||||
std::vector<uint32_t> data;
|
||||
|
||||
RefCollection(uint16_t f);
|
||||
|
||||
inline bool in_range(int x) {
|
||||
return (0 <= x && x < (int)data.size());
|
||||
}
|
||||
|
||||
inline int length() { return data.size(); }
|
||||
|
||||
void destroy();
|
||||
void print();
|
||||
|
||||
void push(uint32_t x);
|
||||
uint32_t getAt(int x);
|
||||
void removeAt(int x);
|
||||
void setAt(int x, uint32_t y);
|
||||
int indexOf(uint32_t x, int start);
|
||||
int removeElement(uint32_t x);
|
||||
};
|
||||
|
||||
struct MapEntry {
|
||||
uint32_t key;
|
||||
uint32_t val;
|
||||
};
|
||||
|
||||
class RefMap
|
||||
: public RefObject
|
||||
{
|
||||
public:
|
||||
std::vector<MapEntry> data;
|
||||
|
||||
RefMap();
|
||||
void destroy();
|
||||
void print();
|
||||
int findIdx(uint32_t key);
|
||||
};
|
||||
|
||||
// A ref-counted, user-defined JS object.
|
||||
class RefRecord
|
||||
: public RefObject
|
||||
{
|
||||
public:
|
||||
// The object is allocated, so that there is space at the end for the fields.
|
||||
uint32_t fields[];
|
||||
|
||||
RefRecord(uint16_t v) : RefObject(v) {}
|
||||
|
||||
uint32_t ld(int idx);
|
||||
uint32_t ldref(int idx);
|
||||
void st(int idx, uint32_t v);
|
||||
void stref(int idx, uint32_t v);
|
||||
};
|
||||
|
||||
// these are needed when constructing vtables for user-defined classes
|
||||
void RefRecord_destroy(RefRecord *r);
|
||||
void RefRecord_print(RefRecord *r);
|
||||
|
||||
class RefAction;
|
||||
typedef uint32_t (*ActionCB)(uint32_t *captured, uint32_t arg0, uint32_t arg1, uint32_t arg2);
|
||||
|
||||
// Ref-counted function pointer. It's currently always a ()=>void procedure pointer.
|
||||
class RefAction
|
||||
: public RefObject
|
||||
{
|
||||
public:
|
||||
// This is the same as for RefRecord.
|
||||
uint8_t len;
|
||||
uint8_t reflen;
|
||||
ActionCB func; // The function pointer
|
||||
// fields[] contain captured locals
|
||||
uint32_t fields[];
|
||||
|
||||
void destroy();
|
||||
void print();
|
||||
|
||||
RefAction();
|
||||
|
||||
inline void stCore(int idx, uint32_t v)
|
||||
{
|
||||
//printf("ST [%d] = %d ", idx, v); this->print();
|
||||
intcheck(0 <= idx && idx < len, ERR_OUT_OF_BOUNDS, 10);
|
||||
intcheck(fields[idx] == 0, ERR_OUT_OF_BOUNDS, 11); // only one assignment permitted
|
||||
fields[idx] = v;
|
||||
}
|
||||
|
||||
inline uint32_t runCore(int arg0, int arg1, int arg2) // internal; use runAction*() functions
|
||||
{
|
||||
this->ref();
|
||||
uint32_t r = this->func(&this->fields[0], arg0, arg1, arg2);
|
||||
this->unref();
|
||||
return r;
|
||||
}
|
||||
};
|
||||
|
||||
// These two are used to represent locals written from inside inline functions
|
||||
class RefLocal
|
||||
: public RefObject
|
||||
{
|
||||
public:
|
||||
uint32_t v;
|
||||
void destroy();
|
||||
void print();
|
||||
RefLocal();
|
||||
};
|
||||
|
||||
class RefRefLocal
|
||||
: public RefObject
|
||||
{
|
||||
public:
|
||||
uint32_t v;
|
||||
void destroy();
|
||||
void print();
|
||||
RefRefLocal();
|
||||
};
|
||||
}
|
||||
|
||||
using namespace pxt;
|
||||
MicroBitPin *getPin(int id);
|
||||
typedef ImageData* Image;
|
||||
typedef BufferData* Buffer;
|
||||
|
||||
// The ARM Thumb generator in the JavaScript code is parsing
|
||||
// the hex file and looks for the magic numbers as present here.
|
||||
//
|
||||
// Then it fetches function pointer addresses from there.
|
||||
|
||||
#define PXT_SHIMS_BEGIN \
|
||||
namespace pxt { \
|
||||
const uint32_t functionsAndBytecode[] __attribute__((aligned(0x20))) = { \
|
||||
0x08010801, 0x42424242, 0x08010801, 0x8de9d83e,
|
||||
|
||||
#define PXT_SHIMS_END }; }
|
||||
|
||||
#pragma GCC diagnostic ignored "-Wpmf-conversions"
|
||||
|
||||
#define PXT_VTABLE_TO_INT(vt) ((uint32_t)(vt) >> vtableShift)
|
||||
#define PXT_VTABLE_BEGIN(classname, flags, iface) \
|
||||
const VTable classname ## _vtable \
|
||||
__attribute__((aligned(1 << vtableShift))) \
|
||||
= { \
|
||||
sizeof(classname), \
|
||||
flags, \
|
||||
iface, \
|
||||
{ \
|
||||
(void*)&classname::destroy, \
|
||||
(void*)&classname::print,
|
||||
|
||||
#define PXT_VTABLE_END } };
|
||||
|
||||
#define PXT_VTABLE_INIT(classname) \
|
||||
RefObject(PXT_VTABLE_TO_INT(&classname ## _vtable))
|
||||
|
||||
#define PXT_VTABLE_CTOR(classname) \
|
||||
PXT_VTABLE_BEGIN(classname, 0, 0) PXT_VTABLE_END \
|
||||
classname::classname() : PXT_VTABLE_INIT(classname)
|
||||
|
||||
#endif
|
||||
|
||||
// vim: ts=2 sw=2 expandtab
|
@ -4,11 +4,14 @@
|
||||
"installedVersion": "tsmdvf",
|
||||
"files": [
|
||||
"README.md",
|
||||
"ManagedBuffer.cpp",
|
||||
"ManagedBuffer.h",
|
||||
"pxt.cpp",
|
||||
"pxt.h",
|
||||
"dal.d.ts",
|
||||
"enums.d.ts",
|
||||
"shims.d.ts",
|
||||
"pxt-core.d.ts",
|
||||
"ksbit.h",
|
||||
"core.cpp",
|
||||
"pxt-helpers.ts",
|
||||
"helpers.ts",
|
||||
@ -39,8 +42,7 @@
|
||||
"public": true,
|
||||
"dependencies": {},
|
||||
"yotta": {
|
||||
"configIsJustDefaults": true,
|
||||
"config": {
|
||||
"optionalConfig": {
|
||||
"microbit-dal": {
|
||||
"bluetooth": {
|
||||
"enabled": 0
|
||||
|
@ -1,4 +1,4 @@
|
||||
#include "ksbit.h"
|
||||
#include "pxt.h"
|
||||
|
||||
enum SerialPin {
|
||||
P0 = MICROBIT_ID_IO_P0,
|
||||
|
28
libs/core/shims.d.ts
vendored
28
libs/core/shims.d.ts
vendored
@ -53,10 +53,10 @@ declare interface Image {
|
||||
|
||||
/**
|
||||
* Scrolls an image .
|
||||
* @param frameOffset x offset moved on each animation step, eg: 5, 1, -1
|
||||
* @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
|
||||
*/
|
||||
//% 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
|
||||
//% parts="ledmatrix" shim=ImageMethods::scrollImage
|
||||
scrollImage(frameOffset: number, interval: number): void;
|
||||
@ -557,14 +557,14 @@ declare namespace pins {
|
||||
/**
|
||||
* Configures this pin to a digital input, and generates events where the timestamp is the duration that this pin was either ``high`` or ``low``.
|
||||
*/
|
||||
//% 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
|
||||
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.
|
||||
*/
|
||||
//% help=pins/pulse-duration
|
||||
//% help=pins/pulse-duration advanced=true
|
||||
//% blockId=pins_pulse_duration block="pulse duration (µs)"
|
||||
//% weight=21 blockGap=8 shim=pins::pulseDuration
|
||||
function pulseDuration(): number;
|
||||
@ -576,7 +576,7 @@ declare namespace pins {
|
||||
* @param maximum duration in micro-seconds
|
||||
*/
|
||||
//% blockId="pins_pulse_in" block="pulse in (µs)|pin %name|pulsed %value"
|
||||
//% weight=20 maxDuration.defl=2000000 shim=pins::pulseIn
|
||||
//% weight=20 advanced=true maxDuration.defl=2000000 shim=pins::pulseIn
|
||||
function pulseIn(name: DigitalPin, value: PulseValue, maxDuration?: number): number;
|
||||
|
||||
/**
|
||||
@ -599,18 +599,20 @@ declare namespace pins {
|
||||
function servoSetPulse(name: AnalogPin, micros: number): void;
|
||||
|
||||
/**
|
||||
* Sets the pin used when using `pins->analog pitch`.
|
||||
* @param name TODO
|
||||
* Sets the pin used when using `analog pitch` or music.
|
||||
* @param name pin to modulate pitch from
|
||||
*/
|
||||
//% help=pins/analog-set-pitch weight=12 shim=pins::analogSetPitchPin
|
||||
//% blockId=device_analog_set_pitch_pin block="analog set pitch pin %name"
|
||||
//% help=pins/analog-set-pitch weight=3 advanced=true shim=pins::analogSetPitchPin
|
||||
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.
|
||||
* @param frequency TODO
|
||||
* @param ms TODO
|
||||
* @param frequency frequency to modulate in Hz.
|
||||
* @param ms duration of the pitch in milli seconds.
|
||||
*/
|
||||
//% help=pins/analog-pitch weight=14 async shim=pins::analogPitch
|
||||
//% 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
|
||||
function analogPitch(frequency: number, ms: number): void;
|
||||
|
||||
/**
|
||||
@ -618,7 +620,7 @@ declare namespace pins {
|
||||
* @param name pin to set the pull mode on
|
||||
* @param pull one of the mbed pull configurations: PullUp, PullDown, PullNone
|
||||
*/
|
||||
//% 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
|
||||
function setPull(name: DigitalPin, pull: PinPullMode): void;
|
||||
|
||||
@ -645,7 +647,7 @@ declare namespace pins {
|
||||
* Write to the SPI slave and return the response
|
||||
* @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
|
||||
function spiWrite(value: number): number;
|
||||
}
|
||||
|
@ -1,4 +1,55 @@
|
||||
{
|
||||
"MesAlertEvent.DisplayToast|block": "display toast",
|
||||
"MesAlertEvent.FindMyPhone|block": "find my phone",
|
||||
"MesAlertEvent.PlayRingtone|block": "play ring tone",
|
||||
"MesAlertEvent.PlaySound|block": "play sound",
|
||||
"MesAlertEvent.RingAlarm2|block": "ring alarm 2",
|
||||
"MesAlertEvent.RingAlarm3|block": "ring alarm 3",
|
||||
"MesAlertEvent.RingAlarm4|block": "ring alarm 4",
|
||||
"MesAlertEvent.RingAlarm5|block": "ring alarm 5",
|
||||
"MesAlertEvent.RingAlarm6|block": "ring alarm 6",
|
||||
"MesAlertEvent.RingAlarm|block": "ring alarm",
|
||||
"MesAlertEvent.Vibrate|block": "vibrate",
|
||||
"MesCameraEvent.LaunchPhotoMode|block": "launch photo mode",
|
||||
"MesCameraEvent.LaunchVideoMode|block": "launch video mode",
|
||||
"MesCameraEvent.StartVideoCapture|block": "start video capture",
|
||||
"MesCameraEvent.StopPhotoMode|block": "stop photo mode",
|
||||
"MesCameraEvent.StopVideoCapture|block": "stop video capture",
|
||||
"MesCameraEvent.StopVideoMode|block": "stop video mode",
|
||||
"MesCameraEvent.TakePhoto|block": "take photo",
|
||||
"MesCameraEvent.ToggleFrontRear|block": "toggle front-rear",
|
||||
"MesDeviceInfo.DisplayOff|block": "display off",
|
||||
"MesDeviceInfo.DisplayOn|block": "display on",
|
||||
"MesDeviceInfo.IncomingCall|block": "incoming call",
|
||||
"MesDeviceInfo.IncomingMessage|block": "incoming message",
|
||||
"MesDeviceInfo.OrientationLandscape|block": "orientation landscape",
|
||||
"MesDeviceInfo.OrientationPortrait|block": "orientation portrait",
|
||||
"MesDeviceInfo.Shaken|block": "shaken",
|
||||
"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",
|
||||
"MesRemoteControlEvent.forward|block": "forward",
|
||||
"MesRemoteControlEvent.nextTrack|block": "next track",
|
||||
"MesRemoteControlEvent.pause|block": "pause",
|
||||
"MesRemoteControlEvent.play|block": "play",
|
||||
"MesRemoteControlEvent.previousTrack|block": "previous track",
|
||||
"MesRemoteControlEvent.rewind|block": "rewind",
|
||||
"MesRemoteControlEvent.stop|block": "stop",
|
||||
"MesRemoteControlEvent.volumeDown|block": "volume down",
|
||||
"MesRemoteControlEvent.volumeUp|block": "volume up",
|
||||
"devices.onGamepadButton|block": "on gamepad button|%NAME",
|
||||
"devices.onNotified|block": "on notified|%event",
|
||||
"devices.onSignalStrengthChanged|block": "on signal strength changed",
|
||||
|
@ -33,7 +33,7 @@ namespace radio {
|
||||
* received packet from the radio queue.
|
||||
*/
|
||||
//% help=radio/on-data-packet-received
|
||||
//% mutate=true
|
||||
//% mutate=objectdestructuring
|
||||
//% mutateText=Packet
|
||||
//% mutateDefaults="receivedNumber;receivedString:name,receivedNumber:value;receivedString"
|
||||
//% blockId=radio_on_packet block="on radio received" blockGap=8
|
||||
|
12
package.json
12
package.json
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "pxt-microbit",
|
||||
"version": "0.6.8",
|
||||
"version": "0.6.22",
|
||||
"description": "micro:bit target for PXT",
|
||||
"keywords": [
|
||||
"JavaScript",
|
||||
@ -26,12 +26,14 @@
|
||||
"docs/*/*.md",
|
||||
"docs/*/*/*.md"
|
||||
],
|
||||
"main": "built/pxtrequire.js",
|
||||
"typings": "built/pxtrequire.d.ts",
|
||||
"devDependencies": {
|
||||
"typescript": "^1.8.7"
|
||||
},
|
||||
"dependencies": {
|
||||
"pxt-core": "0.5.62",
|
||||
"typescript": "^1.8.7",
|
||||
"less": "^2.6.0",
|
||||
"semantic-ui-less": "^2.2.4"
|
||||
},
|
||||
"dependencies": {
|
||||
"pxt-core": "0.5.84"
|
||||
}
|
||||
}
|
||||
|
@ -160,10 +160,10 @@
|
||||
},
|
||||
"compileService": {
|
||||
"yottaTarget": "bbc-microbit-classic-gcc",
|
||||
"yottaCorePackage": "pxt-microbit-core",
|
||||
"githubCorePackage": "microsoft/pxt-microbit-core",
|
||||
"gittag": "v0.5.1",
|
||||
"serviceId": "ws"
|
||||
"yottaCorePackage": "microbit",
|
||||
"githubCorePackage": "lancaster-university/microbit",
|
||||
"gittag": "v2.0.0-rc7",
|
||||
"serviceId": "microbit"
|
||||
},
|
||||
"serial": {
|
||||
"manufacturerFilter": "^mbed$",
|
||||
@ -187,6 +187,8 @@
|
||||
"privacyUrl": "https://go.microsoft.com/fwlink/?LinkId=521839",
|
||||
"termsOfUseUrl": "https://go.microsoft.com/fwlink/?LinkID=206977",
|
||||
"githubUrl": "https://github.com/Microsoft/pxt-microbit",
|
||||
"projectGallery": "projects",
|
||||
"crowdinProject": "kindscript",
|
||||
"boardName": "micro:bit",
|
||||
"sideDoc": "getting-started",
|
||||
"browserSupport": [
|
||||
@ -246,6 +248,7 @@
|
||||
"path": "/device"
|
||||
}
|
||||
],
|
||||
"hasReferenceDocs": true,
|
||||
"usbDocs": "/device/usb",
|
||||
"usbHelp": [
|
||||
{
|
||||
|
@ -134,7 +134,7 @@ namespace pxsim.devices {
|
||||
export function onSignalStrengthChanged(action: number) {
|
||||
// TODO
|
||||
}
|
||||
export function signalStrength() : number {
|
||||
export function signalStrength(): number {
|
||||
// TODO
|
||||
return 0;
|
||||
}
|
||||
@ -165,18 +165,19 @@ namespace pxsim.bluetooth {
|
||||
export function startUartService(): void {
|
||||
// TODO
|
||||
}
|
||||
export function uartWrite(s : string): void {
|
||||
// TODO
|
||||
export function uartWrite(s: string): void {
|
||||
serial.writeString(s)
|
||||
}
|
||||
export function uartReadUntil(del: string): string {
|
||||
// TODO
|
||||
return ""
|
||||
return serial.readUntil(del);
|
||||
}
|
||||
export function onBluetoothConnected(a : RefAction) {
|
||||
export function onBluetoothConnected(a: RefAction) {
|
||||
// TODO
|
||||
}
|
||||
export function onBluetoothDisconnected(a : RefAction) {
|
||||
export function onBluetoothDisconnected(a: RefAction) {
|
||||
// TODO
|
||||
}
|
||||
export function advertiseUrl(url: string, power: number) { }
|
||||
export function stopAdvertising() { }
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user