Compare commits
18 Commits
Author | SHA1 | Date | |
---|---|---|---|
056ec1bc96 | |||
16439bfca3 | |||
7117ba771e | |||
633522c800 | |||
3f94033c7d | |||
1bc00f476c | |||
0269ffa5ae | |||
c64225982e | |||
29eef560b0 | |||
90e191c4ca | |||
efd310f0b4 | |||
0a5c2e4df9 | |||
1d6eaf0370 | |||
b4b789422e | |||
cf982d7c52 | |||
2dafe5d253 | |||
63422bf696 | |||
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
|
||||
|
@ -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,6 @@ MicroBitPin *getPin(int id);
|
||||
typedef ImageData* Image;
|
||||
typedef BufferData* Buffer;
|
||||
|
||||
namespace pxt {
|
||||
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 + '}';
|
||||
}
|
||||
}
|
||||
}
|
@ -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"
|
||||
}
|
||||
|
@ -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