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.
Dependencies: m3Dpi mbed-rtos mbed MbedJSONValue
Revision 17:b73fcdb828f3, committed 2017-08-30
- Comitter:
- sillevl
- Date:
- Wed Aug 30 11:54:19 2017 +0000
- Parent:
- 16:0043244f8a61
- Commit message:
- demo distance sensors
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Wed Jan 20 17:57:05 2016 +0000
+++ b/main.cpp Wed Aug 30 11:54:19 2017 +0000
@@ -21,7 +21,11 @@
int colors[8] = {distance.front, distance.front_right, distance.right, distance.back_right, distance.back, distance.back_left, distance.left, distance.front_left};
// shift distance value to get red colors
for(int i = 0; i < 8; i++){
- colors[i] = ((~(colors[i]*2)) & 0xFF) << 16;
+ //colors[i] = ((~(colors[i]*2)) & 0xFF) << 16;
+ if(colors[i] < 50) {colors[i] = Color::RED;}
+ else if(colors[i] < 100) {colors[i] = Color::YELLOW;}
+ else if(colors[i] < 150) {colors[i] = Color::GREEN;}
+ else{colors[i] = Color::BLACK;}
}
robot.setLeds(colors);
}
@@ -29,13 +33,13 @@
void read_sensors_task(void const *name)
{
//Timer t; t.start();
- robot.setStatus(Color::GREEN);
+ robot.setStatus(Color::BLACK);
::distance = robot.getDistance();
- direction = robot.getDirection();
- rotation = robot.getRotation();
- acceleration = robot.getAcceleration();
+ //direction = robot.getDirection();
+ //rotation = robot.getRotation();
+ //acceleration = robot.getAcceleration();
setLeds(::distance);
- robot.setStatus(Color::BLACK);
+ robot.setStatus(Color::RED);
//t.stop();pc.printf("*** Sensor acquisition time: %d us\r\n", t.read_us());
}
@@ -67,10 +71,10 @@
read_sensors_timer.start(50);
RtosTimer report_timer(report_task, osTimerPeriodic);
- report_timer.start(500);
+// report_timer.start(500);
- Thread receive_thread(receive_task);
- Thread idle_thread(idle_task, NULL, osPriorityLow);
+// Thread receive_thread(receive_task);
+// Thread idle_thread(idle_task, NULL, osPriorityLow);
Thread::wait(osWaitForever);
}
\ No newline at end of file
