Compare commits
33 Commits
Author | SHA1 | Date | |
---|---|---|---|
f9e0fe1b8d | |||
c49fb27d4c | |||
24b20543c5 | |||
be97665ea2 | |||
657cdeb53e | |||
08575d352b | |||
c9ba7af3f3 | |||
917072a336 | |||
fd5357b273 | |||
3a8bbfbd91 | |||
0b457d6a50 | |||
4f960f5585 | |||
5e62d5c30d | |||
4aa2d129e9 | |||
09f4001c7a | |||
eae2f0436d | |||
287c9da3bd | |||
056ec1bc96 | |||
16439bfca3 | |||
7117ba771e | |||
633522c800 | |||
3f94033c7d | |||
1bc00f476c | |||
0269ffa5ae | |||
c64225982e | |||
29eef560b0 | |||
90e191c4ca | |||
efd310f0b4 | |||
0a5c2e4df9 | |||
1d6eaf0370 | |||
b4b789422e | |||
cf982d7c52 | |||
48afb52ef1 |
@ -8,7 +8,6 @@ script:
|
||||
- "(cd libs/lang-test0; node ../../node_modules/pxt-core/built/pxt.js test)"
|
||||
- "(cd libs/lang-test1; node ../../node_modules/pxt-core/built/pxt.js test)"
|
||||
- "node node_modules/pxt-core/built/pxt.js testdir tests"
|
||||
- "node node_modules/pxt-core/built/pxt.js uploaddoc"
|
||||
- "(cd libs/hello; node ../../node_modules/pxt-core/built/pxt.js testconv https://az851932.vo.msecnd.net/files/td-converter-tests-v1.json)"
|
||||
sudo: false
|
||||
notifications:
|
||||
|
@ -15,7 +15,7 @@ The local server allows to run the editor and the documentation from your comput
|
||||
|
||||
The following commands are a 1-time setup after synching the repo on your machine.
|
||||
|
||||
* if not yet installed, install [Node.js 4.4.5 or higher](https://nodejs.org/en/download/)
|
||||
* See requirements for [pxt](https://github.com/Microsoft/pxt)
|
||||
* [clone this repo](https://help.github.com/articles/cloning-a-repository/) to your computer and go in the project folder
|
||||
```
|
||||
git clone https://github.com/microsoft/pxt-microbit
|
||||
|
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"), "..", "..");
|
11
docs/faq.md
11
docs/faq.md
@ -2,4 +2,13 @@
|
||||
|
||||
### @description Frequently asked questions and answers from our users.
|
||||
|
||||
Please search for solutions or open a ticket at [support.microbit.org](https://support.microbit.org)!
|
||||
## Which web sites do I need to unblock for pxt.microbit.org?
|
||||
|
||||
This is the list of domains that need to be unblocked to allow the web editor to load:
|
||||
|
||||
* https://pxt.microbit.org
|
||||
* https://www.pxt.io
|
||||
* https://trg-microbit.userpxt.io
|
||||
* https://pxt.azureedge.net
|
||||
|
||||
Can't find your question? Please search for solutions or open a ticket at [support.microbit.org](https://support.microbit.org)!
|
||||
|
@ -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"
|
||||
}]
|
||||
```
|
||||
|
@ -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.
|
||||
|
@ -1,5 +1,9 @@
|
||||
# Support
|
||||
|
||||
Send us your feedback and ideas on our [User Voice Forum](https://touchdevelop.uservoice.com/forums/402381-code-the-micro-bit/).
|
||||
Use the Microbit Foundation [support web site](https://support.microbit.org)!
|
||||
|
||||
You can also read the [Frequently Asked Questions](/faq).
|
||||
|
||||
## Developers
|
||||
|
||||
You can also use our [GitHub issue tracker](https://github.com/microsoft/pxt-microbit) to report bugs.
|
@ -203,6 +203,19 @@ namespace pxt {
|
||||
void *ptrOfLiteral(int offset);
|
||||
//%
|
||||
int getNumGlobals();
|
||||
|
||||
//%
|
||||
uint32_t programSize() {
|
||||
return bytecode[17] * 2;
|
||||
}
|
||||
|
||||
//%
|
||||
uint32_t afterProgramPage() {
|
||||
uint32_t ptr = (uint32_t)&bytecode[0];
|
||||
ptr += programSize();
|
||||
ptr = (ptr + (PAGE_SIZE - 1)) & ~(PAGE_SIZE - 1);
|
||||
return ptr;
|
||||
}
|
||||
}
|
||||
|
||||
namespace pxtrt {
|
||||
|
@ -6,3 +6,7 @@ MicroBitPin *getPin(int id);
|
||||
typedef ImageData* Image;
|
||||
typedef BufferData* Buffer;
|
||||
|
||||
namespace pxt {
|
||||
uint32_t programSize();
|
||||
uint32_t afterProgramPage();
|
||||
}
|
||||
|
@ -1,51 +0,0 @@
|
||||
namespace messages {
|
||||
var streamid: string;
|
||||
|
||||
export function setStreamId(id: string) {
|
||||
streamid = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new message that includes the board serial number and the stream id if any
|
||||
*/
|
||||
export function createMessage() : Message {
|
||||
let m = new Message();
|
||||
m.addNumber('board', control.deviceSerialNumber());
|
||||
if (streamid != null && streamid.length > 0)
|
||||
m.addString('stream', streamid);
|
||||
return m;
|
||||
}
|
||||
|
||||
/**
|
||||
* A message containig custom data
|
||||
*/
|
||||
export class Message {
|
||||
private buffer:string = '';
|
||||
|
||||
/**
|
||||
* Adds a string field to the message
|
||||
*/
|
||||
//%
|
||||
public addString(name:string, value:string) {
|
||||
if (this.buffer.length > 0) this.buffer += ',';
|
||||
this.buffer += name + ':"' + value + '"';
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a number field to the message
|
||||
*/
|
||||
//%
|
||||
public addNumber(name:string, value: number) {
|
||||
if (this.buffer.length > 0) this.buffer += ',';
|
||||
this.buffer += name + ':' + value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the message to a JSON payload
|
||||
*/
|
||||
//%
|
||||
public toJSON() : string {
|
||||
return '{' + this.buffer + '}';
|
||||
}
|
||||
}
|
||||
}
|
12
package.json
12
package.json
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "pxt-microbit",
|
||||
"version": "0.6.2",
|
||||
"version": "0.6.11",
|
||||
"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.53",
|
||||
"typescript": "^1.8.7",
|
||||
"less": "^2.6.0",
|
||||
"semantic-ui-less": "^2.2.4"
|
||||
},
|
||||
"dependencies": {
|
||||
"pxt-core": "0.5.68"
|
||||
}
|
||||
}
|
||||
|
@ -187,6 +187,7 @@
|
||||
"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",
|
||||
"boardName": "micro:bit",
|
||||
"sideDoc": "getting-started",
|
||||
"browserSupport": [
|
||||
@ -225,10 +226,6 @@
|
||||
"name": "Getting Started",
|
||||
"path": "/getting-started"
|
||||
},
|
||||
{
|
||||
"name": "Projects",
|
||||
"path": "/projects"
|
||||
},
|
||||
{
|
||||
"name": "Reference",
|
||||
"path": "/reference"
|
||||
|
@ -14,12 +14,14 @@ namespace pxsim {
|
||||
radioState: RadioState;
|
||||
// TODO: not singletons
|
||||
neopixelState: NeoPixelState;
|
||||
microServoState: MicroServoState;
|
||||
servosState: MicroServosState;
|
||||
fileSystem: FileSystemState;
|
||||
|
||||
constructor() {
|
||||
super()
|
||||
|
||||
// components
|
||||
this.fileSystem = new FileSystemState();
|
||||
this.builtinParts["ledmatrix"] = this.ledMatrixState = new LedMatrixState(runtime);
|
||||
this.builtinParts["buttonpair"] = this.buttonPairState = new ButtonPairState({
|
||||
ID_BUTTON_A: DAL.MICROBIT_ID_BUTTON_A,
|
||||
@ -60,7 +62,12 @@ namespace pxsim {
|
||||
this.builtinParts["lightsensor"] = this.lightSensorState = new LightSensorState();
|
||||
this.builtinParts["compass"] = this.compassState = new CompassState();
|
||||
this.builtinParts["neopixel"] = this.neopixelState = new NeoPixelState();
|
||||
this.builtinParts["microservo"] = this.microServoState = new MicroServoState();
|
||||
this.builtinParts["microservo"] = this.servosState = new MicroServosState({
|
||||
"P0": DAL.MICROBIT_ID_IO_P0,
|
||||
"P1": DAL.MICROBIT_ID_IO_P1,
|
||||
"P2": DAL.MICROBIT_ID_IO_P2,
|
||||
"P3": DAL.MICROBIT_ID_IO_P3
|
||||
});
|
||||
|
||||
this.builtinVisuals["buttonpair"] = () => new visuals.ButtonPairView();
|
||||
this.builtinVisuals["ledmatrix"] = () => new visuals.LedMatrixView();
|
||||
|
@ -72,12 +72,12 @@ namespace pxsim.pins {
|
||||
}
|
||||
|
||||
export function servoWritePin(pinId: number, value: number) {
|
||||
let pin = getPin(pinId);
|
||||
if (!pin) return;
|
||||
|
||||
analogSetPeriod(pinId, 20000);
|
||||
// TODO: per pin state
|
||||
if (board().microServoState.angle != value) {
|
||||
board().microServoState.angle = value;
|
||||
runtime.queueDisplayUpdate();
|
||||
}
|
||||
const state = board().servosState.servoState(pinId);
|
||||
state.setAngle(value);
|
||||
}
|
||||
|
||||
export function servoSetPulse(pinId: number, micros: number) {
|
||||
|
18
sim/state/filesystem.ts
Normal file
18
sim/state/filesystem.ts
Normal file
@ -0,0 +1,18 @@
|
||||
namespace pxsim.files {
|
||||
export function appendLine(filename: string, text: string) {
|
||||
const b = board();
|
||||
b.fileSystem.append(filename, text + "\r\n");
|
||||
}
|
||||
export function appendString(filename: string, text: string) {
|
||||
const b = board();
|
||||
b.fileSystem.append(filename, text);
|
||||
}
|
||||
export function appendNumber(filename: string, value: number) {
|
||||
const b = board();
|
||||
b.fileSystem.append(filename, value.toString());
|
||||
}
|
||||
export function remove(filename: string) {
|
||||
const b = board();
|
||||
b.fileSystem.remove(filename);
|
||||
}
|
||||
}
|
@ -712,8 +712,9 @@ namespace pxsim.visuals {
|
||||
tiltDecayer = 0;
|
||||
}
|
||||
|
||||
let ax = (ev.clientX - this.element.clientWidth / 2) / (this.element.clientWidth / 3);
|
||||
let ay = (ev.clientY - this.element.clientHeight / 2) / (this.element.clientHeight / 3);
|
||||
let bbox = this.element.getBoundingClientRect();
|
||||
let ax = (ev.clientX - bbox.width / 2) / (bbox.width / 3);
|
||||
let ay = (ev.clientY - bbox.height / 2) / (bbox.height / 3);
|
||||
|
||||
let x = - Math.max(- 1023, Math.min(1023, Math.floor(ax * 1023)));
|
||||
let y = Math.max(- 1023, Math.min(1023, Math.floor(ay * 1023)));
|
||||
|
Reference in New Issue
Block a user