Compare commits

...

29 Commits

Author SHA1 Message Date
f9e0fe1b8d 0.6.11 2016-11-11 06:48:59 -08:00
c49fb27d4c Bump pxt-core to 0.5.68 2016-11-11 06:48:58 -08:00
24b20543c5 moving less, semantic to dev dependencies 2016-11-10 22:56:33 -08:00
be97665ea2 0.6.10 2016-11-10 14:53:50 -08:00
657cdeb53e Bump pxt-core to 0.5.66 2016-11-10 14:53:48 -08:00
08575d352b pxt-microbit can now be required and exports useful information about its bundled pxt-core (#305) 2016-11-10 12:12:57 -08:00
c9ba7af3f3 0.6.9 2016-11-10 08:53:57 -08:00
917072a336 Bump pxt-core to 0.5.64 2016-11-10 08:53:54 -08:00
fd5357b273 simplify projects 2016-11-10 08:37:13 -08:00
3a8bbfbd91 0.6.8 2016-11-09 05:32:09 -08:00
0b457d6a50 Bump pxt-core to 0.5.62 2016-11-09 05:32:08 -08:00
4f960f5585 0.6.7 2016-11-09 05:11:13 -08:00
5e62d5c30d Bump pxt-core to 0.5.61 2016-11-09 05:11:11 -08:00
4aa2d129e9 Adding list of domains that need to be allowed for editor 2016-11-08 15:44:51 -08:00
09f4001c7a exposing programSize function 2016-11-08 10:17:25 -08:00
eae2f0436d 0.6.6 2016-11-08 08:57:34 -08:00
287c9da3bd Bump pxt-core to 0.5.59 2016-11-08 08:57:31 -08:00
056ec1bc96 0.6.5 2016-11-07 22:25:49 -08:00
16439bfca3 Bump pxt-core to 0.5.58 2016-11-07 22:25:45 -08:00
7117ba771e support for multiple simulated servos 2016-11-07 22:25:19 -08:00
633522c800 removing dangling file 2016-11-07 13:31:24 -08:00
3f94033c7d Merge branch 'master' of https://github.com/Microsoft/pxt-microbit 2016-11-07 13:30:53 -08:00
1bc00f476c Requirement for node version used is not correct (#304)
Consider referring to requirements for pxt to reduce time on updating all pxt dependants.
2016-11-07 13:26:19 -08:00
0269ffa5ae support for filesystem in simulator 2016-11-07 11:11:38 -08:00
c64225982e Merge pull request #302 from Microsoft/pr/firefoxtiltfix
Fix for accelerometer simulator not working in firefox.
2016-11-07 10:43:49 -08:00
29eef560b0 whitespace 2016-11-07 10:33:22 -08:00
90e191c4ca 0.6.4 2016-11-07 10:17:20 -08:00
efd310f0b4 added afterProgramPage to C++ declarations 2016-11-07 10:17:03 -08:00
48afb52ef1 Fix for accelerometer simulator not working in firefox. Fixes Microsoft/pxt/#679 2016-11-04 15:39:57 -07:00
23 changed files with 111 additions and 175 deletions

View File

@ -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
View 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"), "..", "..");

View File

@ -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)!

View File

@ -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"
}]
```

View File

@ -1,24 +1,7 @@
# flashing heart
![](/static/mb/projects/a1-display.png)
### ~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. :(

View File

@ -1,7 +1,5 @@
# Guitar
![guitar icon](/static/mb/projects/guitar.png)
### @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

View File

@ -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!

View File

@ -1,8 +1,10 @@
# love meter
![](/static/mb/projects/a3-pins.png)
### ~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

View File

@ -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.

View File

@ -1,51 +1,11 @@
# rock paper scissors
![](/static/mb/projects/a4-motion.png)
### ~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.

View File

@ -1,8 +1,10 @@
# smiley buttons
![](/static/mb/projects/a2-buttons.png)
### ~avatar
Use buttons to show a smiley or frowny face.
Use buttons to show a smiley face!
### ~
## Step 1

View File

@ -1,7 +1,5 @@
# Wallet
![wallet icon](/static/mb/projects/wallet.png)
### @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!
![wallet image](/static/mb/projects/wallet/wallet.jpg)
## 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
View File

@ -0,0 +1,20 @@
# the watch
### ~avatar
Build your own @boardname@ watch from an old pair of jeans and T-shirt!
### ~
![](/static/mb/lessons/the-watch-1.png)
### ~button /projects/watch/make
Let's get started!
### ~
### Acknowledgements
Artistic design by Melinda Hoeneisen.

View File

@ -1,12 +1,14 @@
![](/static/mb/projects/a10-watch.png)
# the watch - Make
# the watch
### @description Maker Project for Watch
![](/static/mb/lessons/the-watch-0.png)
### ~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@
![](/static/mb/lessons/the-watch-1.png)
### ~
## Duration: ~30 minutes
## Materials
@ -147,8 +149,3 @@ Trim any leftover fabric, threads or tape.
![](/static/mb/lessons/the-watch-23.png)
Your watch is ready!
### Acknowledgements
Artistic design by Melinda Hoeneisen.

View File

@ -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.

View File

@ -6,3 +6,7 @@ MicroBitPin *getPin(int id);
typedef ImageData* Image;
typedef BufferData* Buffer;
namespace pxt {
uint32_t programSize();
uint32_t afterProgramPage();
}

View File

@ -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 + '}';
}
}
}

View File

@ -1,6 +1,6 @@
{
"name": "pxt-microbit",
"version": "0.6.3",
"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.54",
"typescript": "^1.8.7",
"less": "^2.6.0",
"semantic-ui-less": "^2.2.4"
},
"dependencies": {
"pxt-core": "0.5.68"
}
}

View File

@ -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"

View File

@ -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();

View File

@ -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
View 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);
}
}

View File

@ -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)));