Merge branch 'master' into speedfield

This commit is contained in:
Peli de Halleux
2018-01-07 09:59:11 -08:00
committed by GitHub
7 changed files with 190 additions and 3 deletions

View File

@ -92,6 +92,7 @@ namespace brick {
//% blockNamespace=brick
//% weight=81 blockGap=8
//% group="Buttons"
//% button.fieldEditor="brickbuttons"
isPressed() {
return this._isPressed
}
@ -107,6 +108,7 @@ namespace brick {
//% blockNamespace=brick
//% weight=80
//% group="Buttons"
//% button.fieldEditor="brickbuttons"
wasPressed() {
const r = this._wasPressed
this._wasPressed = false
@ -125,6 +127,7 @@ namespace brick {
//% blockNamespace=brick
//% weight=99 blockGap=8
//% group="Buttons"
//% button.fieldEditor="brickbuttons"
onEvent(ev: ButtonEvent, body: () => void) {
control.onEvent(this._id, ev, body)
}
@ -139,6 +142,7 @@ namespace brick {
//% blockNamespace=brick
//% weight=98 blockGap=8
//% group="Buttons"
//% button.fieldEditor="brickbuttons"
pauseUntil(ev: ButtonEvent) {
control.waitForEvent(this._id, ev);
}
@ -166,7 +170,6 @@ namespace brick {
// this needs to be done in query(), which is run without the main JS execution mutex
// otherwise, while(true){} will lock the device
if (ret & DAL.BUTTON_ID_ESCAPE) {
motors.stopAllMotors();
control.reset()
}
return ret

View File

@ -483,7 +483,15 @@ void runLMS() {
*/
}
void stopMotors() {
uint8_t cmd[2] = { 0xA3, 0x0F };
int fd = open("/dev/lms_pwm", O_RDWR);
write(fd, cmd, 2);
close(fd);
}
extern "C" void target_reset() {
stopMotors();
if (lmsPid)
runLMS();
else