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

@ -18,7 +18,7 @@
"sensors.ColorSensor.onColorDetected|block": "on %sensor|detected color %color",
"sensors.ColorSensor.onLightChanged|block": "on %sensor|%mode|%condition",
"sensors.ColorSensor.pauseForColor|block": "pause %sensor|for color %color",
"sensors.ColorSensor.pauseForLight|block": "pause %sensor|for %mode|light %condition",
"sensors.ColorSensor.pauseForLight|block": "pause %sensor|for %mode|%condition",
"sensors.color1|block": "color 1",
"sensors.color2|block": "color 2",
"sensors.color3|block": "color 3",

View File

@ -182,7 +182,7 @@ namespace sensors {
* @param color the color to detect
*/
//% help=sensors/color-sensor/pause-for-light
//% block="pause %sensor|for %mode|light %condition"
//% block="pause %sensor|for %mode|%condition"
//% blockId=colorPauseForLight
//% parts="colorsensor"
//% blockNamespace=sensors

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