JACCDAC config keys (#814)
* ensure C++ build works * adding getUint8, setUint8 for jacdac-ts * fix console.warn * added config keys
This commit is contained in:
Родитель
5b6ea8980a
Коммит
a769ef13bf
|
@ -1,6 +1,8 @@
|
|||
language: node_js
|
||||
node_js:
|
||||
- "8.9.4"
|
||||
before_install:
|
||||
- sudo apt-get install libudev-dev
|
||||
script:
|
||||
- "node node_modules/pxt-core/built/pxt.js travis"
|
||||
sudo: false
|
||||
|
|
|
@ -23,6 +23,22 @@ void setByte(Buffer buf, int off, int v) {
|
|||
buf->data[off] = v;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads an unsigned byte at a particular location
|
||||
*/
|
||||
//%
|
||||
int getUint8(Buffer buf, int off) {
|
||||
return getByte(buf, off);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes an unsigned byte at a particular location
|
||||
*/
|
||||
//%
|
||||
void setUint8(Buffer buf, int off, int v) {
|
||||
setByte(buf, off, v);
|
||||
}
|
||||
|
||||
int writeBuffer(Buffer buf, int dstOffset, Buffer src, int srcOffset = 0, int length = -1) {
|
||||
if (length < 0)
|
||||
length = src->length;
|
||||
|
|
|
@ -1,6 +1,16 @@
|
|||
#ifndef __PXT_CONFIGKEYS_H
|
||||
#define __PXT_CONFIGKEYS_H
|
||||
|
||||
// used by pins.cpp to mask off the pin name from any config
|
||||
// lower 16 pins of value are the pin name
|
||||
#define CFG_PIN_NAME_MSK 0x0000ffff
|
||||
// upper 16 bits of value is any configuration of the pin.
|
||||
#define CFG_PIN_CONFIG_MSK 0xffff0000
|
||||
|
||||
// begin optional pin configurations
|
||||
#define CFG_PIN_CONFIG_ACTIVE_LO 0x10000
|
||||
|
||||
|
||||
#define CFG_MAGIC0 0x1e9e10f1
|
||||
#define CFG_MAGIC1 0x20227a79
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ namespace console {
|
|||
add(ConsolePriority.Debug, text);
|
||||
}
|
||||
|
||||
export function warning(text: string) {
|
||||
export function warn(text: string) {
|
||||
add(ConsolePriority.Warning, text);
|
||||
}
|
||||
|
||||
|
|
|
@ -171,6 +171,11 @@ namespace control {
|
|||
this.idleCallbacks.push(handler);
|
||||
}
|
||||
|
||||
removeIdleHandler(handler: () => void) {
|
||||
if (handler && this.idleCallbacks)
|
||||
this.idleCallbacks.removeElement(handler);
|
||||
}
|
||||
|
||||
private runIdleHandler() {
|
||||
if (this.idleCallbacks) {
|
||||
const ics = this.idleCallbacks.slice(0);
|
||||
|
@ -235,15 +240,31 @@ namespace control {
|
|||
else {
|
||||
if (!_idleCallbacks) {
|
||||
_idleCallbacks = [];
|
||||
// TODO: use background events
|
||||
control.internalOnEvent(
|
||||
15/*DAL.DEVICE_ID_SCHEDULER*/,
|
||||
2/*DAL.DEVICE_SCHEDULER_EVT_IDLE*/,
|
||||
function() {
|
||||
control.runInBackground(function() {
|
||||
while(_idleCallbacks) {
|
||||
_idleCallbacks.slice(0).forEach(cb => cb());
|
||||
}, 16);
|
||||
pause(20);
|
||||
}
|
||||
})
|
||||
/*
|
||||
control.internalOnEvent(
|
||||
15. // DAL.DEVICE_ID_SCHEDULER
|
||||
2, // DAL.DEVICE_SCHEDULER_EVT_IDLE
|
||||
function() {
|
||||
pins.LED.digitalWrite(on = !on);
|
||||
if (_idleCallbacks)
|
||||
_idleCallbacks.slice(0).forEach(cb => cb());
|
||||
}, 192); // MESSAGE_BUS_LISTENER_IMMEDIATE
|
||||
*/
|
||||
}
|
||||
_idleCallbacks.push(handler);
|
||||
}
|
||||
}
|
||||
|
||||
export function removeIdleHandler(handler: () => void) {
|
||||
if (!handler) return;
|
||||
const ctx = eventContext();
|
||||
if (ctx) ctx.removeIdleHandler(handler);
|
||||
else if (_idleCallbacks) _idleCallbacks.removeElement(handler);
|
||||
}
|
||||
}
|
|
@ -2,8 +2,20 @@
|
|||
|
||||
|
||||
|
||||
//% indexerGet=BufferMethods::getByte indexerSet=BufferMethods::setByte
|
||||
//% indexerGet=BufferMethods::getByte indexerSet=BufferMethods::setByte
|
||||
declare interface Buffer {
|
||||
/**
|
||||
* Reads an unsigned byte at a particular location
|
||||
*/
|
||||
//% shim=BufferMethods::getUint8
|
||||
getUint8(off: int32): int32;
|
||||
|
||||
/**
|
||||
* Writes an unsigned byte at a particular location
|
||||
*/
|
||||
//% shim=BufferMethods::setUint8
|
||||
setUint8(off: int32, v: int32): void;
|
||||
|
||||
/**
|
||||
* Write a number in specified format in the buffer.
|
||||
*/
|
||||
|
|
Загрузка…
Ссылка в новой задаче