Skip to content

Commit 0b3edff

Browse files
authored
add led off support (#468)
1 parent 066dbe7 commit 0b3edff

File tree

7 files changed

+32
-18
lines changed

7 files changed

+32
-18
lines changed

Diff for: assets.ts

+1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ namespace microcode {
3333
if (name == TID_MODIFIER_CAR_LED_COLOR_1) return icondb.tile_color_red
3434
if (name == TID_MODIFIER_CAR_LED_COLOR_2) return icondb.tile_color_green
3535
if (name == TID_MODIFIER_CAR_LED_COLOR_3) return icondb.tile_color_blue
36+
if (name == TID_MODIFIER_CAR_LED_COLOR_4) return icondb.tile_color_black
3637
if (name == TID_SENSOR_CAR_WALL) return icondb.car_wall
3738
if (name == TID_SENSOR_LINE) return icondb.line_sensor
3839
if (name == TID_FILTER_LINE_LEFT) return icondb.line_left_on

Diff for: docs.ts

+1
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,7 @@ namespace docs {
245245
microcode.TID_MODIFIER_CAR_LED_COLOR_1,
246246
microcode.TID_MODIFIER_CAR_LED_COLOR_2,
247247
microcode.TID_MODIFIER_CAR_LED_COLOR_3,
248+
microcode.TID_MODIFIER_CAR_LED_COLOR_4,
248249
microcode.TID_SENSOR_CAR_WALL,
249250
microcode.TID_SENSOR_LINE,
250251
microcode.TID_FILTER_LINE_LEFT,

Diff for: locales/tooltips.json

+1
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@
164164
"CAR9": "LED red",
165165
"CAR10": "LED green",
166166
"CAR11": "LED blue",
167+
"CAR12": "LED OFF",
167168

168169
"S13": "wall",
169170
"S14": "line",

Diff for: robot/protocol.ts

+13-12
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,19 @@ namespace microcode.robots {
1818
* Compact commands through radio numbers
1919
*/
2020
export const enum RobotCompactCommand {
21-
MotorState = 0xfffff00,
22-
MotorRunForward = MotorState | 0x1,
23-
MotorRunBackward = MotorState | 0x2,
24-
MotorTurnLeft = MotorState | 0x3,
25-
MotorTurnRight = MotorState | 0x4,
26-
MotorStop = MotorState | 0x5,
27-
MotorRunForwardFast = MotorState | 0x6,
28-
MotorSpinLeft = MotorState | 0x7,
29-
MotorSpinRight = MotorState | 0x8,
30-
MotorLEDRed = MotorState | 0x09,
31-
MotorLEDGreen = MotorState | 0x0a,
32-
MotorLEDBlue = MotorState | 0x0b,
21+
Command = 0xfffff00,
22+
MotorRunForward = Command | 0x1,
23+
MotorRunBackward = Command | 0x2,
24+
MotorTurnLeft = Command | 0x3,
25+
MotorTurnRight = Command | 0x4,
26+
MotorStop = Command | 0x5,
27+
MotorRunForwardFast = Command | 0x6,
28+
MotorSpinLeft = Command | 0x7,
29+
MotorSpinRight = Command | 0x8,
30+
LEDRed = Command | 0x09,
31+
LEDGreen = Command | 0x0a,
32+
LEDBlue = Command | 0x0b,
33+
LEDOff = Command | 0x0c,
3334

3435
/**
3536
* sonar detected obstable

Diff for: robot/robotdriver.ts

+6-3
Original file line numberDiff line numberDiff line change
@@ -514,15 +514,18 @@ namespace microcode {
514514
this.playTone(440, 40)
515515
break
516516
}
517-
case microcode.robots.RobotCompactCommand.MotorLEDRed:
517+
case microcode.robots.RobotCompactCommand.LEDRed:
518518
this.setColor(0xff0000)
519519
break
520-
case microcode.robots.RobotCompactCommand.MotorLEDGreen:
520+
case microcode.robots.RobotCompactCommand.LEDGreen:
521521
this.setColor(0x00ff00)
522522
break
523-
case microcode.robots.RobotCompactCommand.MotorLEDBlue:
523+
case microcode.robots.RobotCompactCommand.LEDBlue:
524524
this.setColor(0x0000ff)
525525
break
526+
case microcode.robots.RobotCompactCommand.LEDOff:
527+
this.setColor(0x00000)
528+
break
526529
}
527530
}
528531
}

Diff for: tids.ts

+6
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ namespace microcode {
133133
export const TID_MODIFIER_CAR_LED_COLOR_1 = "CAR9"
134134
export const TID_MODIFIER_CAR_LED_COLOR_2 = "CAR10"
135135
export const TID_MODIFIER_CAR_LED_COLOR_3 = "CAR11"
136+
export const TID_MODIFIER_CAR_LED_COLOR_4 = "CAR12"
136137

137138
// should fit into a byte
138139
export enum Tid {
@@ -270,6 +271,7 @@ namespace microcode {
270271
TID_MODIFIER_CAR_LED_COLOR_1,
271272
TID_MODIFIER_CAR_LED_COLOR_2,
272273
TID_MODIFIER_CAR_LED_COLOR_3,
274+
TID_MODIFIER_CAR_LED_COLOR_4,
273275
MODIFER_END,
274276
}
275277

@@ -515,6 +517,8 @@ namespace microcode {
515517
return Tid.TID_MODIFIER_CAR_LED_COLOR_2
516518
case TID_MODIFIER_CAR_LED_COLOR_3:
517519
return Tid.TID_MODIFIER_CAR_LED_COLOR_3
520+
case TID_MODIFIER_CAR_LED_COLOR_4:
521+
return Tid.TID_MODIFIER_CAR_LED_COLOR_4
518522
default:
519523
return undefined
520524
}
@@ -762,6 +766,8 @@ namespace microcode {
762766
return TID_MODIFIER_CAR_LED_COLOR_2
763767
case Tid.TID_MODIFIER_CAR_LED_COLOR_3:
764768
return TID_MODIFIER_CAR_LED_COLOR_3
769+
case Tid.TID_MODIFIER_CAR_LED_COLOR_4:
770+
return TID_MODIFIER_CAR_LED_COLOR_4
765771
default:
766772
return undefined
767773
}

Diff for: tiles.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -436,9 +436,10 @@ namespace microcode {
436436
microcode.robots.RobotCompactCommand.MotorRunForwardFast,
437437
microcode.robots.RobotCompactCommand.MotorSpinLeft,
438438
microcode.robots.RobotCompactCommand.MotorSpinRight,
439-
microcode.robots.RobotCompactCommand.MotorLEDRed,
440-
microcode.robots.RobotCompactCommand.MotorLEDGreen,
441-
microcode.robots.RobotCompactCommand.MotorLEDBlue,
439+
microcode.robots.RobotCompactCommand.LEDRed,
440+
microcode.robots.RobotCompactCommand.LEDGreen,
441+
microcode.robots.RobotCompactCommand.LEDBlue,
442+
microcode.robots.RobotCompactCommand.LEDOff,
442443
]
443444
make_vals(car_commands, "car", "CAR", 1)
444445

0 commit comments

Comments
 (0)