Compare commits

...

18 Commits

Author SHA1 Message Date
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
0a5c2e4df9 0.6.3 2016-11-07 09:52:34 -08:00
1d6eaf0370 Bump pxt-core to 0.5.54 2016-11-07 09:52:30 -08:00
b4b789422e Add afterProgramPage() for filesystem support 2016-11-07 16:04:15 +00:00
cf982d7c52 removing upload step 2016-11-06 20:38:53 -08:00
2dafe5d253 0.6.2 2016-11-06 20:30:31 -08:00
63422bf696 Bump pxt-core to 0.5.53 2016-11-06 20:30:27 -08:00
48afb52ef1 Fix for accelerometer simulator not working in firefox. Fixes Microsoft/pxt/#679 2016-11-04 15:39:57 -07:00
10 changed files with 54 additions and 64 deletions

View File

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

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

View File

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

View File

@ -6,3 +6,6 @@ MicroBitPin *getPin(int id);
typedef ImageData* Image;
typedef BufferData* Buffer;
namespace pxt {
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.1",
"version": "0.6.5",
"description": "micro:bit target for PXT",
"keywords": [
"JavaScript",
@ -30,7 +30,7 @@
"typescript": "^1.8.7"
},
"dependencies": {
"pxt-core": "0.5.51",
"pxt-core": "0.5.58",
"less": "^2.6.0",
"semantic-ui-less": "^2.2.4"
}

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