Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of racing_robots by
Revision 5:355240d7126b, committed 2015-02-24
- Comitter:
- pcordemans
- Date:
- Tue Feb 24 09:38:40 2015 +0000
- Parent:
- 4:3743cbfe031b
- Child:
- 6:0dc4e4225881
- Commit message:
- added led implementation; cleaned up error messages
Changed in this revision
| robot_logic.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/robot_logic.cpp Tue Feb 24 09:06:29 2015 +0000
+++ b/robot_logic.cpp Tue Feb 24 09:38:40 2015 +0000
@@ -17,6 +17,7 @@
static int internal_i = 0;
static int internal_d = 0;
static int internal_previous_pos_of_line = 0;
+static int internal_led_state = 0;
/*
* Drive the robot forward or backward.
@@ -50,7 +51,7 @@
*/
void turn(int turnspeed) {
if (turnspeed > MAX_SPEED || turnspeed < -MAX_SPEED) {
- printf("[ERROR] Turn speed out of range");
+ error("Speed out of range");
return;
}
@@ -222,4 +223,21 @@
*/
void await(int milliseconds) {
wait_ms(milliseconds);
+}
+
+
+void led(LedIndex i, LedState state) {
+ if(state == LED_ON){
+ internal_led_state |= (1 << i);
+ }
+ else if(state == LED_OFF) {
+ internal_led_state &= ~(1 << i);
+ }
+ else if(state == LED_TOGGLE){
+ internal_led_state ^= (1 << i);
+ }
+ else{
+ error("Illegal LED state");
+ }
+ m3pi.leds(internal_led_state);
}
\ No newline at end of file
