Merge branch 'master' of https://github.com/Microsoft/pxt-microbit
This commit is contained in:
commit
c04ddbb459
2
clients/electron/.gitignore
vendored
Normal file
2
clients/electron/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
node_modules
|
||||
projects
|
5
clients/electron/README.md
Normal file
5
clients/electron/README.md
Normal file
@ -0,0 +1,5 @@
|
||||
# PXT micro:bit Electron app
|
||||
|
||||
A very basic wrapper around the web app. To install, copy the contents of this
|
||||
directory to somewhere outside the main `pxt-microbit` repository. Then run `npm
|
||||
install && npm start`.
|
15
clients/electron/index.html
Normal file
15
clients/electron/index.html
Normal file
@ -0,0 +1,15 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>code the micro:bit</title>
|
||||
</head>
|
||||
<body>
|
||||
<webview id="webview" style="position:absolute; left:0; top:0; right:0; bottom:0"/>
|
||||
<script>
|
||||
const webview = document.getElementById("webview")
|
||||
const url = `http://localhost:3232/${window.location.hash}`
|
||||
webview.src = url
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -1,67 +1,39 @@
|
||||
const electron = require('electron')
|
||||
// Module to control application life.
|
||||
const app = electron.app
|
||||
// Module to create native browser window.
|
||||
const BrowserWindow = electron.BrowserWindow
|
||||
// pxt toolchain
|
||||
const {app, BrowserWindow, Menu} = require('electron')
|
||||
const pxt = require('pxt-core')
|
||||
const path = require('path')
|
||||
|
||||
// Keep a global reference of the window object, if you don't, the window will
|
||||
// be closed automatically when the JavaScript object is garbage collected.
|
||||
let mainWindow
|
||||
let win
|
||||
|
||||
const cliPath = path.join(process.cwd(), "node_modules/pxt-microbit")
|
||||
|
||||
function startServerAndCreateWindow() {
|
||||
pxt.mainCli(cliPath, ["serve", "-no-browser"])
|
||||
createWindow()
|
||||
}
|
||||
|
||||
function createWindow () {
|
||||
console.log('starting app...')
|
||||
// Create the browser window.
|
||||
mainWindow = new BrowserWindow({
|
||||
width: 800, height: 600,
|
||||
webPreferences: {
|
||||
nodeIntegration: false,
|
||||
}
|
||||
win = new BrowserWindow({
|
||||
width: 800,
|
||||
height: 600,
|
||||
title: "code the micro:bit"
|
||||
})
|
||||
|
||||
ts.pxt.Util.debug = true;
|
||||
pxt.mainCli("C:/gh/pxt-microbit/clients/electron/node_modules/pxt-microbit", ["serve", "-just"]);
|
||||
|
||||
// no menu
|
||||
mainWindow.setMenu(null);
|
||||
|
||||
// and load the index.html of the app.
|
||||
mainWindow.loadURL(`http://localhost:3232/#local_token=08ba9b8f-6ccb-4202-296d-28fac7a553d9`)
|
||||
|
||||
// Open the DevTools.
|
||||
mainWindow.webContents.openDevTools()
|
||||
|
||||
// Emitted when the window is closed.
|
||||
mainWindow.on('closed', function () {
|
||||
// Dereference the window object, usually you would store windows
|
||||
// in an array if your app supports multi windows, this is the time
|
||||
// when you should delete the corresponding element.
|
||||
mainWindow = null
|
||||
Menu.setApplicationMenu(null)
|
||||
win.loadURL(`file://${__dirname}/index.html#local_token=${pxt.globalConfig.localToken}`)
|
||||
win.on('closed', () => {
|
||||
win = null
|
||||
})
|
||||
}
|
||||
|
||||
// This method will be called when Electron has finished
|
||||
// initialization and is ready to create browser windows.
|
||||
// Some APIs can only be used after this event occurs.
|
||||
app.on('ready', createWindow)
|
||||
app.on('ready', startServerAndCreateWindow)
|
||||
|
||||
// Quit when all windows are closed.
|
||||
app.on('window-all-closed', function () {
|
||||
// On OS X it is common for applications and their menu bar
|
||||
// to stay active until the user quits explicitly with Cmd + Q
|
||||
app.on('window-all-closed', () => {
|
||||
if (process.platform !== 'darwin') {
|
||||
app.quit()
|
||||
}
|
||||
})
|
||||
|
||||
app.on('activate', function () {
|
||||
// On OS X it's common to re-create a window in the app when the
|
||||
// dock icon is clicked and there are no other windows open.
|
||||
if (mainWindow === null) {
|
||||
app.on('activate', () => {
|
||||
if (win === null) {
|
||||
createWindow()
|
||||
}
|
||||
})
|
||||
|
||||
// In this file you can include the rest of your app's specific main process
|
||||
// code. You can also put them in separate files and require them here.
|
@ -1,19 +1,14 @@
|
||||
{
|
||||
"name": "codethemicrobit",
|
||||
"version": "0.1.0",
|
||||
"description": "A Blocks / JavaScript editor for the micro:bit",
|
||||
"name" : "code-the-microbit",
|
||||
"version" : "1.0.0",
|
||||
"description": "Blocks / Javascript editor",
|
||||
"author": "Microsoft",
|
||||
"main" : "main.js",
|
||||
"scripts": {
|
||||
"start": "electron ."
|
||||
"start": "node_modules/.bin/electron ."
|
||||
},
|
||||
"author": "Microsoft",
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"electron-prebuilt": "^1.2.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"typescript": "1.8.7",
|
||||
"pxt-core": "*",
|
||||
"electron": "*",
|
||||
"pxt-microbit": "*"
|
||||
}
|
||||
}
|
@ -99,3 +99,6 @@ latest version of OS X then you'll be using the latest version of Safari.
|
||||
* Click 'About Safari'
|
||||
|
||||
![](/static/configurations/safari-version.png)
|
||||
|
||||
IT administrators should check which browser versions are supported
|
||||
[here](/browsers/technical).
|
||||
|
@ -1,6 +1,16 @@
|
||||
# Unsupported configuration
|
||||
# Recommended browser for Linux
|
||||
|
||||
As you are using Linux, it is recommended that you use Mozilla Firefox or Google
|
||||
Chrome.
|
||||
As you are using Linux, it is recommended that you use [Mozilla
|
||||
Firefox][firefox] or [Google Chrome][chrome].
|
||||
|
||||
Please see [here](/browsers) for more information.
|
||||
Please see [here][technical] for technical information on which browsers are
|
||||
supported, or [here][versions] to check which version you are using.
|
||||
|
||||
[edge]: https://www.microsoft.com/en-us/windows/microsoft-edge
|
||||
[ie]: https://www.microsoft.com/en-us/download/internet-explorer.aspx
|
||||
[firefox]: https://www.mozilla.org/en-US/firefox/new/
|
||||
[chrome]: https://www.google.com/chrome/
|
||||
[opera]: https://www.opera.com
|
||||
[safari]: http://www.apple.com/safari/
|
||||
[technical]: /browsers/technical
|
||||
[versions]: /browsers
|
||||
|
@ -1,6 +1,18 @@
|
||||
# Unsupported configuration
|
||||
# Recommended browser for Mac
|
||||
|
||||
As you are using OS X, it is recommended that you use Safari. Alternatively,
|
||||
Google Chrome and Mozilla Firefox are also supported.
|
||||
As you are using a Mac, it is recommended that you use [Safari][]. Alternatively,
|
||||
[Google Chrome][chrome] and [Mozilla Firefox][firefox] are also supported.
|
||||
|
||||
Please see [here](/browsers) for more information.
|
||||
You cannot use Safari in private browsing mode when using the editor.
|
||||
|
||||
Please see [here][technical] for technical information on which browsers are
|
||||
supported, or [here][versions] to check which version you are using.
|
||||
|
||||
[edge]: https://www.microsoft.com/en-us/windows/microsoft-edge
|
||||
[ie]: https://www.microsoft.com/en-us/download/internet-explorer.aspx
|
||||
[firefox]: https://www.mozilla.org/en-US/firefox/new/
|
||||
[chrome]: https://www.google.com/chrome/
|
||||
[opera]: https://www.opera.com
|
||||
[safari]: http://www.apple.com/safari/
|
||||
[technical]: /browsers/technical
|
||||
[versions]: /browsers
|
||||
|
36
docs/browsers/technical.md
Normal file
36
docs/browsers/technical.md
Normal file
@ -0,0 +1,36 @@
|
||||
# Technical information about browser support
|
||||
|
||||
[codethemicrobit.com][] requires that you use a recent version of a modern
|
||||
browser, such as Microsoft Edge, Google Chrome, Mozilla Firefox, Safari, Opera,
|
||||
or IE11. This is because the editor uses modern web technologies such as [web
|
||||
workers][] to enable compiling [TypeScript][] in the browser, or the using the
|
||||
same [Monaco][] editor that powers [Visual Studio Code][].
|
||||
|
||||
[codethemicrobit.com]: https://codethemicrobit.com
|
||||
[web workers]: http://www.w3.org/TR/workers/
|
||||
[typescript]: http://www.typescriptlang.org
|
||||
[monaco]: https://microsoft.github.io/monaco-editor/
|
||||
[visual studio code]: http://code.visualstudio.com
|
||||
|
||||
Most modern browsers automatically update themselves, but in some environments
|
||||
such as schools these automatic updates are disabled for security. **We
|
||||
strongly recommend that you use the most recent version of any of these
|
||||
browsers**, but if you can't then you must use at least:
|
||||
|
||||
| Browser | Minimum version | Release date | Windows | Mac |
|
||||
| ----------------- | --------------- | -------------- | ----------- | ---------- |
|
||||
| Edge | 12 | March 2015 | Windows 10+ | N/A |
|
||||
| Internet Explorer | 11 | October 2013 | Windows 7+ | N/A |
|
||||
| Mozilla Firefox | 31 ESR | July 2014 | Windows XP+ | OS X 10.6+ |
|
||||
| Google Chrome | 38 | October 2014 | Windows XP+ | OS X 10.6+ |
|
||||
| Safari | 9 | September 2015 | N/A | OS X 10.9+ |
|
||||
| Opera | 21 | May 2014 | Windows 7+ | OS X 10.9+ |
|
||||
|
||||
|
||||
Please see our information for which browsers are recommended for [Windows][],
|
||||
[Mac][], [Linux][], or [Raspberry Pi][].
|
||||
|
||||
[Windows]: /browsers/windows
|
||||
[Mac]: /browsers/mac
|
||||
[Linux]: /browsers/linux
|
||||
[Raspberry Pi]: /raspberry-pi
|
@ -1,8 +1,18 @@
|
||||
# Unsupported configuration
|
||||
# Recommended browser for Windows
|
||||
|
||||
As you are using Windows, it is recommended that you use Microsoft Edge. If you
|
||||
are running a version of Windows prior to Windows 10, you can use Internet
|
||||
Explorer 11. Alternatively, Google Chrome and Mozilla Firefox are also
|
||||
supported.
|
||||
We recommend [Microsoft Edge][edge] if you are running Windows 10, but users on
|
||||
Windows 7 or higher can use [Internet Explorer 11][ie] or recent versions of
|
||||
[Mozilla Firefox][firefox], [Google Chrome][chrome], or [Opera][opera].
|
||||
|
||||
Please see [here](/browsers) for more information.
|
||||
|
||||
Please see [here][technical] for technical information on which browsers are
|
||||
supported, or [here][versions] to check which version you are using.
|
||||
|
||||
[edge]: https://www.microsoft.com/en-us/windows/microsoft-edge
|
||||
[ie]: https://www.microsoft.com/en-us/download/internet-explorer.aspx
|
||||
[firefox]: https://www.mozilla.org/en-US/firefox/new/
|
||||
[chrome]: https://www.google.com/chrome/
|
||||
[opera]: https://www.opera.com
|
||||
[safari]: http://www.apple.com/safari/
|
||||
[technical]: /browsers/technical
|
||||
[versions]: /browsers
|
||||
|
@ -21,6 +21,7 @@
|
||||
### More questions?
|
||||
|
||||
* [Frequently Asked Question](/faq)
|
||||
* [Embedding project](/share)
|
||||
* [Help Translate](/translate)
|
||||
* [Release notes](/release-notes)
|
||||
|
||||
|
@ -18,7 +18,8 @@ to reopen your latest project. You can also open previous project stored locally
|
||||
|
||||
The project source is also stored in each compiled ``.hex`` file. Drag and drop the ``.hex`` file into the web editor to load the project.
|
||||
|
||||
To share your project with others, you can use the **Embed** feature. It stores your project in the cloud and creates a URL that you can share with others.
|
||||
To share your project with others, you can use the [Embed Project...](/share).
|
||||
It stores your project in the cloud and creates a URL that you can share with others.
|
||||
|
||||
If you are using [Visual Studio Code](/code), all your programs are stored as files on your computer and you can use your favorite source control system as needed.
|
||||
|
||||
|
27
docs/share.md
Normal file
27
docs/share.md
Normal file
@ -0,0 +1,27 @@
|
||||
# Sharing your project
|
||||
|
||||
Once you have a cool project, it is possible to save it in the cloud and share it or embed it to your web site.
|
||||
|
||||
### Instructions
|
||||
|
||||
* Click on **More...** then click **Embed Project...**
|
||||
* Click on the **Publish** button
|
||||
|
||||
The embed dialog will provide you with various options to embed your project in your web site.
|
||||
|
||||
### Project URL
|
||||
|
||||
This URL will point to a web page that contains that project.
|
||||
|
||||
* see the "happy" project: https://codethemicrobit.com/pyirlbpsei
|
||||
|
||||
### Embedding into a blog or web site
|
||||
|
||||
* Copy the HTML and paste it into your HTML source.
|
||||
|
||||
|
||||
### ~hint
|
||||
|
||||
**Developers:** This page supports OEmbed as well
|
||||
|
||||
### ~
|
@ -141,7 +141,6 @@ namespace radio {
|
||||
*/
|
||||
//% help=radio/received-number-at
|
||||
//% weight=45 debug=true
|
||||
//% blockId=radio_datagram_received_number_at block="radio receive number|at %VALUE" blockGap=8
|
||||
int receivedNumberAt(int index) {
|
||||
if (radioEnable() != MICROBIT_OK) return 0;
|
||||
if (0 <= index && index < packet.length() / 4) {
|
||||
|
3
libs/microbit-radio/shims.d.ts
vendored
3
libs/microbit-radio/shims.d.ts
vendored
@ -46,8 +46,7 @@ declare namespace radio {
|
||||
* @param index index of the number to read from 0 to 3. 1 eg
|
||||
*/
|
||||
//% help=radio/received-number-at
|
||||
//% weight=45 debug=true
|
||||
//% blockId=radio_datagram_received_number_at block="radio receive number|at %VALUE" blockGap=8 shim=radio::receivedNumberAt
|
||||
//% weight=45 debug=true shim=radio::receivedNumberAt
|
||||
function receivedNumberAt(index: number): number;
|
||||
|
||||
/**
|
||||
|
@ -8,6 +8,7 @@ namespace control {
|
||||
* Returns the value of a C++ runtime constant
|
||||
*/
|
||||
//% weight=2 weight=19 blockId="control_event_source_id" block="%id" blockGap=8
|
||||
//% shim=TD_ID
|
||||
export function eventSourceId(id: EventBusSource): number {
|
||||
return id;
|
||||
}
|
||||
@ -15,6 +16,7 @@ namespace control {
|
||||
* Returns the value of a C++ runtime constant
|
||||
*/
|
||||
//% weight=1 weight=19 blockId="control_event_value_id" block="%id"
|
||||
//% shim=TD_ID
|
||||
export function eventValueId(id: EventBusValue): number {
|
||||
return id;
|
||||
}
|
||||
|
@ -135,7 +135,7 @@ namespace music {
|
||||
*/
|
||||
//% help=music/play-tone weight=90
|
||||
//% blockId=device_play_note block="play|tone %note=device_note|for %duration=device_beat" icon="\uf025" blockGap=8
|
||||
//% parts="speaker"
|
||||
//% parts="headphone"
|
||||
export function playTone(frequency: number, ms: number): void {
|
||||
pins.analogSetPitchPin(AnalogPin.P0);
|
||||
pins.analogPitch(frequency, ms);
|
||||
@ -147,7 +147,7 @@ namespace music {
|
||||
*/
|
||||
//% help=music/ring-tone weight=80
|
||||
//% blockId=device_ring block="ring tone (Hz)|%note=device_note" icon="\uf025" blockGap=8
|
||||
//% parts="speaker"
|
||||
//% parts="headphone"
|
||||
export function ringTone(frequency: number): void {
|
||||
pins.analogSetPitchPin(AnalogPin.P0);
|
||||
pins.analogPitch(frequency, 0);
|
||||
@ -159,7 +159,7 @@ namespace music {
|
||||
*/
|
||||
//% help=music/rest weight=79
|
||||
//% blockId=device_rest block="rest(ms)|%duration=device_beat"
|
||||
//% parts="speaker"
|
||||
//% parts="headphone"
|
||||
export function rest(ms: number): void {
|
||||
playTone(0, ms);
|
||||
}
|
||||
@ -171,7 +171,6 @@ namespace music {
|
||||
*/
|
||||
//% weight=50 help=music/note-frequency
|
||||
//% blockId=device_note block="%note"
|
||||
//% parts="speaker"
|
||||
//% shim=TD_ID
|
||||
export function noteFrequency(name: Note): number {
|
||||
return name;
|
||||
@ -186,7 +185,6 @@ namespace music {
|
||||
*/
|
||||
//% help=music/beat weight=49
|
||||
//% blockId=device_beat block="%fraction|beat"
|
||||
//% parts="speaker"
|
||||
export function beat(fraction?: BeatFraction): number {
|
||||
init();
|
||||
if (fraction == null) fraction = BeatFraction.Whole;
|
||||
@ -203,7 +201,6 @@ namespace music {
|
||||
*/
|
||||
//% help=music/tempo weight=40
|
||||
//% blockId=device_tempo block="tempo (bpm)" blockGap=8
|
||||
//% parts="speaker"
|
||||
export function tempo(): number {
|
||||
init();
|
||||
return beatsPerMinute;
|
||||
@ -215,7 +212,6 @@ namespace music {
|
||||
*/
|
||||
//% help=music/change-tempo weight=39
|
||||
//% blockId=device_change_tempo block="change tempo by (bpm)|%value" blockGap=8
|
||||
//% parts="speaker"
|
||||
export function changeTempoBy(bpm: number): void {
|
||||
init();
|
||||
setTempo(beatsPerMinute + bpm);
|
||||
@ -227,7 +223,6 @@ namespace music {
|
||||
*/
|
||||
//% help=music/set-tempo weight=38
|
||||
//% blockId=device_set_tempo block="set tempo to (bpm)|%value"
|
||||
//% parts="speaker"
|
||||
export function setTempo(bpm: number): void {
|
||||
init();
|
||||
if (bpm > 0) {
|
||||
|
1
libs/microbit/parts/headphone.svg
Normal file
1
libs/microbit/parts/headphone.svg
Normal file
@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="142" height="180" viewBox="0 0 142 180"><rect ry=".3" rx="1" y="58.615" x="-8.878" height="23.571" width="17.143" transform="rotate(-45)" fill="#b3b3b3"/><rect ry=".3" rx="1" y="32.043" x="-8.878" height="23.571" width="17.143" transform="rotate(-45)" fill="#b3b3b3"/><path d="M.346 7.296c-.394.39-.31 4.797-.18 4.898l13.404 10.18c.117.12.337 4.76.73 4.368l5.506-5.56.01.01 6.51-6.444c.39-.392-4.25-.614-4.366-.73L11.777.612c-.1-.132-4.51-.215-4.898.18L4.087 3.636l-.01-.01-3.73 3.67z" fill="#b3b3b3"/><rect ry="6.85" rx="4.571" y="84.758" x="-20.128" height="75.571" width="39.643" transform="rotate(-45)"/><rect ry=".374" rx="1.038" y="29.442" x="-8.925" height="2.228" width="17.238" transform="rotate(-45)" fill="#fff"/><rect ry=".374" rx="1.038" y="55.939" x="-8.925" height="2.228" width="17.238" transform="rotate(-45)" fill="#fff"/><rect ry=".374" rx="1.038" y="82.392" x="-8.925" height="2.228" width="17.238" transform="rotate(-45)" fill="#fff"/><rect ry="2.317" rx="2.183" y="158.876" x="-9.774" height="25.568" width="18.935" transform="rotate(-45)"/><path d="M128.588 128.82s14.97 11.165 7.547 26.35c-8.426 17.24-25.57 20.653-25.57 20.653" fill="none" stroke="#000" stroke-width="6.6" stroke-linecap="round" stroke-linejoin="round"/></svg>
|
After Width: | Height: | Size: 1.3 KiB |
@ -29,6 +29,7 @@
|
||||
"buffer.cpp",
|
||||
"pxtparts.json",
|
||||
"parts/speaker.svg",
|
||||
"parts/headphone.svg",
|
||||
"_locales/fr/microbit-jsdoc-strings.json"
|
||||
],
|
||||
"public": true,
|
||||
|
@ -101,10 +101,32 @@
|
||||
{"pinIndices": [5, 6, 7, 8, 9]}
|
||||
]
|
||||
},
|
||||
"headphone": {
|
||||
"numberOfPins": 2,
|
||||
"visual": {
|
||||
"image": "parts/headphone.svg",
|
||||
"width": 142,
|
||||
"height": 180,
|
||||
"pinDistance": 20,
|
||||
"pinLocations": [
|
||||
{"x": 17, "y": 11},
|
||||
{"x": 55, "y": 50}
|
||||
]
|
||||
},
|
||||
"pinDefinitions": [
|
||||
{"target": "P0", "style": "croc", "orientation": "Y"},
|
||||
{"target": "ground", "style": "croc", "orientation": "Y"}
|
||||
],
|
||||
"instantiation": {"kind": "singleton"},
|
||||
"assembly": [
|
||||
{"part": true, "pinIndices": [0]},
|
||||
{"pinIndices": [1]}
|
||||
]
|
||||
},
|
||||
"speaker": {
|
||||
"numberOfPins": 2,
|
||||
"visual": {
|
||||
"image": "/parts/speaker.svg",
|
||||
"image": "parts/speaker.svg",
|
||||
"width": 500,
|
||||
"height": 500,
|
||||
"pinDistance": 70,
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "pxt-microbit",
|
||||
"version": "0.4.11",
|
||||
"version": "0.4.15",
|
||||
"description": "micro:bit target for PXT",
|
||||
"keywords": [
|
||||
"JavaScript",
|
||||
@ -29,6 +29,6 @@
|
||||
"typescript": "^1.8.7"
|
||||
},
|
||||
"dependencies": {
|
||||
"pxt-core": "0.4.13"
|
||||
"pxt-core": "0.4.21"
|
||||
}
|
||||
}
|
||||
|
@ -116,6 +116,28 @@ namespace pxsim.pins {
|
||||
}
|
||||
}
|
||||
|
||||
namespace pxsim.devices {
|
||||
export function tellCameraTo(action: number) {
|
||||
// TODO
|
||||
}
|
||||
export function tellRemoteControlTo(action: number) {
|
||||
// TODO
|
||||
}
|
||||
export function raiseAlertTo(action: number) {
|
||||
// TODO
|
||||
}
|
||||
export function onSignalStrengthChanged(action: number) {
|
||||
// TODO
|
||||
}
|
||||
export function signalStrength() : number {
|
||||
// TODO
|
||||
return 0;
|
||||
}
|
||||
export function onGamepadButton(button: number, body: RefAction) {
|
||||
// TODO
|
||||
}
|
||||
}
|
||||
|
||||
namespace pxsim.bluetooth {
|
||||
export function startIOPinService(): void {
|
||||
// TODO
|
||||
|
Loading…
Reference in New Issue
Block a user