parent
49bedcbcc5
commit
fc6fb0811f
@ -52,6 +52,9 @@
|
||||
"console.logValue|param|value": "to write",
|
||||
"console.sendToScreen": "Sends the log messages to the brick screen and uses the brick up and down buttons to scroll.",
|
||||
"control": "Program controls and events.",
|
||||
"control.Timer.millis": "Gets the elapsed time in millis",
|
||||
"control.Timer.reset": "Resets the timer",
|
||||
"control.Timer.seconds": "Gets the elapsed time in seconds",
|
||||
"control.allocateNotifyEvent": "Allocates the next user notification event",
|
||||
"control.deviceFirmwareVersion": "Determine the version of system software currently running.",
|
||||
"control.dmesg": "Write data to DMESG debugging buffer.",
|
||||
|
@ -47,7 +47,18 @@
|
||||
"console.log|block": "console|log %text",
|
||||
"console.sendToScreen|block": "send console to screen",
|
||||
"console|block": "console",
|
||||
"control.Timer.millis|block": "%timer|millis",
|
||||
"control.Timer.reset|block": "%timer|reset",
|
||||
"control.Timer.seconds|block": "%timer|seconds",
|
||||
"control.raiseEvent|block": "raise event|from %src|with value %value",
|
||||
"control.timer1|block": "timer 1",
|
||||
"control.timer2|block": "timer 2",
|
||||
"control.timer3|block": "timer 3",
|
||||
"control.timer4|block": "timer 4",
|
||||
"control.timer5|block": "timer 5",
|
||||
"control.timer6|block": "timer 6",
|
||||
"control.timer7|block": "timer 7",
|
||||
"control.timer8|block": "timer 8",
|
||||
"control|block": "control",
|
||||
"motors.Motor.angle|block": "%motor|angle",
|
||||
"motors.Motor.clearCounts|block": "%motor|clear counts",
|
||||
|
@ -58,7 +58,7 @@ namespace console {
|
||||
|
||||
namespace console.screen {
|
||||
const maxLines = 100;
|
||||
const screenLines = 8;
|
||||
const screenLines = 10;
|
||||
let lines: string[];
|
||||
let scrollPosition = 0;
|
||||
|
||||
@ -66,8 +66,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(-3))
|
||||
brick.buttonDown.onEvent(ButtonEvent.Click, () => scroll(3))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -11,6 +11,7 @@
|
||||
"mmap.cpp",
|
||||
"control.cpp",
|
||||
"console.ts",
|
||||
"timer.ts",
|
||||
"serialnumber.cpp",
|
||||
"buttons.ts",
|
||||
"png.cpp",
|
||||
|
51
libs/core/timer.ts
Normal file
51
libs/core/timer.ts
Normal file
@ -0,0 +1,51 @@
|
||||
namespace control {
|
||||
//% fixedInstances
|
||||
export class Timer {
|
||||
start: number;
|
||||
|
||||
constructor() {
|
||||
this.start = control.millis();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the elapsed time in millis
|
||||
*/
|
||||
//% blockId=timerMillis block="%timer|millis"
|
||||
millis(): number {
|
||||
return control.millis() - this.start;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the elapsed time in seconds
|
||||
*/
|
||||
//% blockId=timerSeconds block="%timer|seconds"
|
||||
seconds(): number {
|
||||
return this.millis() / 1000;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets the timer
|
||||
*/
|
||||
//% blockId=timerRest block="%timer|reset"
|
||||
reset() {
|
||||
this.start = control.millis();
|
||||
}
|
||||
}
|
||||
|
||||
//% whenUsed fixedInstance block="timer 1"
|
||||
export const timer1 = new Timer();
|
||||
//% whenUsed fixedInstance block="timer 2"
|
||||
export const timer2 = new Timer();
|
||||
//% whenUsed fixedInstance block="timer 3"
|
||||
export const timer3 = new Timer();
|
||||
//% whenUsed fixedInstance block="timer 4"
|
||||
export const timer4 = new Timer();
|
||||
//% whenUsed fixedInstance block="timer 5"
|
||||
export const timer5 = new Timer();
|
||||
//% whenUsed fixedInstance block="timer 6"
|
||||
export const timer6 = new Timer();
|
||||
//% whenUsed fixedInstance block="timer 7"
|
||||
export const timer7 = new Timer();
|
||||
//% whenUsed fixedInstance block="timer 8"
|
||||
export const timer8 = new Timer();
|
||||
}
|
Loading…
Reference in New Issue
Block a user