better test support

This commit is contained in:
Peli de Halleux
2017-12-19 13:10:40 -08:00
parent e07d6e3a31
commit eac3e183c3
4 changed files with 38 additions and 31 deletions

View File

@ -67,8 +67,8 @@ namespace console.screen {
if (!lines) {
lines = [];
console.addListener(log);
brick.buttonUp.onEvent(ButtonEvent.Click, () => scroll(1))
brick.buttonDown.onEvent(ButtonEvent.Click, () => scroll(-1))
brick.buttonUp.onEvent(ButtonEvent.Click, () => scroll(-1))
brick.buttonDown.onEvent(ButtonEvent.Click, () => scroll(1))
}
}

View File

@ -75,9 +75,9 @@ namespace motors {
* @param buf message buffer
*/
//%
export function readPWM(buf: Buffer): number {
export function readPWM(buf: Buffer): void {
init()
return pwmMM.read(buf);
pwmMM.read(buf);
}
/**
@ -261,9 +261,16 @@ namespace motors {
//%
isReady(): boolean {
this.init();
const r = readPWM(mkCmd(this._port, DAL.opOutputTest, 0))
// 0 = ready, 1 = busy
return r == 0;
const buf = mkCmd(this._port, DAL.opOutputTest, 2);
readPWM(buf)
const flags = buf.getNumber(NumberFormat.UInt8LE, 2);
// TODO: FIX with ~ support
for(let i = 0; i < DAL.NUM_OUTPUTS; ++i) {
const flag = 1 << i;
if ((this._port & flag) && (flags & flag))
return false;
}
return true;
}
/**
@ -529,8 +536,8 @@ namespace motors {
export const largeCD = new SynchedMotorPair(Output.CD);
function reset(out: Output) {
let b = mkCmd(out, DAL.opOutputReset, 0)
writePWM(b)
writePWM(mkCmd(out, DAL.opOutputReset, 0))
writePWM(mkCmd(out, DAL.opOutputClearCount, 0))
}
function outOffset(out: Output) {