gyro boy improvements (#236)

gyro boy improvements
This commit is contained in:
Peli de Halleux
2018-01-13 08:31:10 -08:00
committed by GitHub
parent 25fded6afb
commit 0b763978f2
13 changed files with 400 additions and 38 deletions

View File

@ -53,6 +53,8 @@
"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.pauseUntil": "Pauses until the timer reaches the given amount of milliseconds",
"control.Timer.pauseUntil|param|ms": "how long to pause for, eg: 5, 100, 200, 500, 1000, 2000",
"control.Timer.reset": "Resets the timer",
"control.Timer.seconds": "Gets the elapsed time in seconds",
"control.allocateNotifyEvent": "Allocates the next user notification event",

View File

@ -48,6 +48,7 @@
"console.sendToScreen|block": "send console to screen",
"console|block": "console",
"control.Timer.millis|block": "%timer|millis",
"control.Timer.pauseUntil|block": "%timer|pause until (ms) %ms",
"control.Timer.reset|block": "%timer|reset",
"control.Timer.seconds|block": "%timer|seconds",
"control.raiseEvent|block": "raise event|from %src|with value %value",

View File

@ -312,6 +312,7 @@ namespace sensors.internal {
reset() {
if (this.isActive()) uartReset(this._port);
this.realmode = 0;
}
}

View File

@ -30,6 +30,16 @@ namespace control {
reset() {
this.start = control.millis();
}
/**
* Pauses until the timer reaches the given amount of milliseconds
* @param ms how long to pause for, eg: 5, 100, 200, 500, 1000, 2000
*/
//% blockId=timerPauseUntil block="%timer|pause until (ms) %ms"
pauseUntil(ms: number) {
const remaining = this.millis() - ms;
loops.pause(Math.max(0, remaining));
}
}
//% whenUsed fixedInstance block="timer 1"