Merge branch 'master' of github.com:Microsoft/kindscript-microbit
This commit is contained in:
commit
e63b764568
18
docs/windows10.md
Normal file
18
docs/windows10.md
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
# Windows 10 App
|
||||||
|
|
||||||
|
## Features
|
||||||
|
|
||||||
|
The Windows 10 App provides all the existing features of codemicrobit.com plus the following ones:
|
||||||
|
|
||||||
|
* **auto-upload**: the compiled .hex file is automatically deployed to all connected BBC micro:bits
|
||||||
|
* **serial piping**: all serial data sent by connected BBC micro:bit is automatically imported and analyzed in the editor.
|
||||||
|
|
||||||
|
## Installing the pre-release app
|
||||||
|
|
||||||
|
The following instructions allow to side-load the Windows 10 app. This is required until the app is in the store.
|
||||||
|
|
||||||
|
* Search for “developer settings” in Windows 10 and put your computer in “Developer mode”.
|
||||||
|
* Download https://pxt.io/codemicrobit.appx and unzip it. **DO NOT try to install from a zipped folder.**
|
||||||
|
* Open the extracted folder, right-click on `Add-AppDevPackage.ps1` and click on `Run with PowerShell`. Follow the prompts…
|
||||||
|
|
||||||
|
4) In order to communicate with the micro:bit via serial, you need to install the [ARM mbed driver](https://developer.mbed.org/handbook/Windows-serial-configuration).
|
@ -22,7 +22,7 @@ namespace control {
|
|||||||
/**
|
/**
|
||||||
* Display specified error code and stop the program.
|
* Display specified error code and stop the program.
|
||||||
*/
|
*/
|
||||||
//% shim=pxrt::panic
|
//% shim=pxtrt::panic
|
||||||
export function panic(code:number)
|
export function panic(code:number)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "pxt-microbit",
|
"name": "pxt-microbit",
|
||||||
"version": "0.2.54",
|
"version": "0.2.60",
|
||||||
"description": "BBC micro:bit target for PXT",
|
"description": "BBC micro:bit target for PXT",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"JavaScript",
|
"JavaScript",
|
||||||
@ -29,6 +29,6 @@
|
|||||||
"typescript": "^1.8.7"
|
"typescript": "^1.8.7"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"pxt-core": "0.2.58"
|
"pxt-core": "0.2.62"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -151,7 +151,7 @@ namespace pxsim.basic {
|
|||||||
if (interval < 0) return;
|
if (interval < 0) return;
|
||||||
|
|
||||||
let leds = createImageFromString(x.toString());
|
let leds = createImageFromString(x.toString());
|
||||||
if (x < 0 || x >= 10) scrollImage(leds, interval, 1);
|
if (x < 0 || x >= 10) ImageMethods.scrollImage(leds, interval, 1);
|
||||||
else showLeds(leds, interval * 5);
|
else showLeds(leds, interval * 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -163,7 +163,7 @@ namespace pxsim.basic {
|
|||||||
} else {
|
} else {
|
||||||
let leds = createImageFromString(s);
|
let leds = createImageFromString(s);
|
||||||
if (s.length == 1) showLeds(leds, interval * 5)
|
if (s.length == 1) showLeds(leds, interval * 5)
|
||||||
else scrollImage(leds, interval, 1);
|
else ImageMethods.scrollImage(leds, interval, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -176,32 +176,12 @@ namespace pxsim.basic {
|
|||||||
runtime.queueDisplayUpdate()
|
runtime.queueDisplayUpdate()
|
||||||
}
|
}
|
||||||
|
|
||||||
function scrollImage(leds: Image, interval: number, stride: number): void {
|
|
||||||
let cb = getResume()
|
|
||||||
let off = stride > 0 ? 0 : leds.width - 1;
|
|
||||||
let display = board().image;
|
|
||||||
|
|
||||||
board().animationQ.enqueue({
|
|
||||||
interval: interval,
|
|
||||||
frame: () => {
|
|
||||||
if (off >= leds.width || off < 0) return false;
|
|
||||||
stride > 0 ? display.shiftLeft(stride) : display.shiftRight(-stride);
|
|
||||||
let c = Math.min(stride, leds.width - off);
|
|
||||||
leds.copyTo(off, c, display, 5 - stride)
|
|
||||||
off += stride;
|
|
||||||
return true;
|
|
||||||
},
|
|
||||||
whenDone: cb
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
export function showAnimation(leds: Image, interval: number = 400): void {
|
export function showAnimation(leds: Image, interval: number = 400): void {
|
||||||
scrollImage(leds, interval, 5);
|
ImageMethods.scrollImage(leds, interval, 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function plotLeds(leds: Image): void {
|
export function plotLeds(leds: Image): void {
|
||||||
leds.copyTo(0, 5, board().image, 0)
|
ImageMethods.plotImage(leds, 0);
|
||||||
runtime.queueDisplayUpdate()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -306,6 +286,25 @@ namespace pxsim.input {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function rotation(kind : number) : number {
|
||||||
|
let b = board();
|
||||||
|
let acc = b.accelerometer;
|
||||||
|
acc.activate();
|
||||||
|
let x = acc.getX(MicroBitCoordinateSystem.NORTH_EAST_DOWN);
|
||||||
|
let y = acc.getX(MicroBitCoordinateSystem.NORTH_EAST_DOWN);
|
||||||
|
let z = acc.getX(MicroBitCoordinateSystem.NORTH_EAST_DOWN);
|
||||||
|
|
||||||
|
let roll = Math.atan2(y,z);
|
||||||
|
let pitch = Math.atan(-x / (y*Math.sin(roll) + z*Math.cos(roll)));
|
||||||
|
|
||||||
|
let r = 0;
|
||||||
|
switch(kind) {
|
||||||
|
case 0: r = pitch; break;
|
||||||
|
case 1: r = roll; break;
|
||||||
|
}
|
||||||
|
return Math.floor(r / Math.PI * 180);
|
||||||
|
}
|
||||||
|
|
||||||
export function setAccelerometerRange(range: number) {
|
export function setAccelerometerRange(range: number) {
|
||||||
let b = board();
|
let b = board();
|
||||||
b.accelerometer.setSampleRange(range);
|
b.accelerometer.setSampleRange(range);
|
||||||
@ -365,6 +364,12 @@ namespace pxsim.led {
|
|||||||
board().displayMode = mode;
|
board().displayMode = mode;
|
||||||
runtime.queueDisplayUpdate()
|
runtime.queueDisplayUpdate()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function screenshot() : Image {
|
||||||
|
let img = createImage(5)
|
||||||
|
board().image.copyTo(0, 5, img, 0);
|
||||||
|
return img;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace pxsim.serial {
|
namespace pxsim.serial {
|
||||||
@ -516,5 +521,39 @@ namespace pxsim.ImageMethods {
|
|||||||
runtime.queueDisplayUpdate()
|
runtime.queueDisplayUpdate()
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO ...
|
export function plotImage(leds: Image, offset:number): void {
|
||||||
|
leds.copyTo(offset, 5, board().image, 0)
|
||||||
|
runtime.queueDisplayUpdate()
|
||||||
|
}
|
||||||
|
|
||||||
|
export function clear(i: Image) {
|
||||||
|
i.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
export function setPixelBrightness(i:Image, x:number, y:number, b:number) {
|
||||||
|
i.set(x,y,b);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function pixelBrightness(i:Image, x:number, y:number) : number {
|
||||||
|
return i.get(x,y);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function scrollImage(leds: Image, interval: number, stride: number): void {
|
||||||
|
let cb = getResume()
|
||||||
|
let off = stride > 0 ? 0 : leds.width - 1;
|
||||||
|
let display = board().image;
|
||||||
|
|
||||||
|
board().animationQ.enqueue({
|
||||||
|
interval: interval,
|
||||||
|
frame: () => {
|
||||||
|
if (off >= leds.width || off < 0) return false;
|
||||||
|
stride > 0 ? display.shiftLeft(stride) : display.shiftRight(-stride);
|
||||||
|
let c = Math.min(stride, leds.width - off);
|
||||||
|
leds.copyTo(off, c, display, 5 - stride)
|
||||||
|
off += stride;
|
||||||
|
return true;
|
||||||
|
},
|
||||||
|
whenDone: cb
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -618,12 +618,12 @@ namespace pxsim {
|
|||||||
this.data = data;
|
this.data = data;
|
||||||
}
|
}
|
||||||
public get(x: number, y: number): number {
|
public get(x: number, y: number): number {
|
||||||
// TODO range checking
|
if (x < 0 || x >= this.width || y < 0 || y >= 5) return 0;
|
||||||
return this.data[y * this.width + x];
|
return this.data[y * this.width + x];
|
||||||
}
|
}
|
||||||
public set(x: number, y: number, v: number) {
|
public set(x: number, y: number, v: number) {
|
||||||
// TODO range checking
|
if (x < 0 || x >= this.width || y < 0 || y >= 5) return;
|
||||||
this.data[y * this.width + x] = v;
|
this.data[y * this.width + x] = Math.max(0, Math.min(255, v));
|
||||||
}
|
}
|
||||||
public copyTo(xSrcIndex: number, length: number, target: Image, xTargetIndex: number): void {
|
public copyTo(xSrcIndex: number, length: number, target: Image, xTargetIndex: number): void {
|
||||||
for (let x = 0; x < length; x++) {
|
for (let x = 0; x < length; x++) {
|
||||||
|
Loading…
Reference in New Issue
Block a user