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: wheelchaircontrol
Revision 21:b438961f85d5, committed 2019-07-02
- Comitter:
- t1jain
- Date:
- Tue Jul 02 19:19:28 2019 +0000
- Parent:
- 20:bd257ffdef24
- Commit message:
- Comments added
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Tue Jul 02 18:53:53 2019 +0000
+++ b/main.cpp Tue Jul 02 19:19:28 2019 +0000
@@ -1,6 +1,6 @@
-/*************************************************************************
- * Version 1.0 *
- *************************************************************************/
+/**************************************************************************
+ * Version 1.0 *
+ **************************************************************************/
#include "wheelchair.h"
Serial pc(USBTX, USBRX, 57600); // Serial Monitor
@@ -108,76 +108,86 @@
//added
//int emerg_button = e_button;
- Watchdog dog; // Creates Watchdog object
- dog.Configure(watchdogLimit); // Configures timeout for Watchdog
+ Watchdog dog; // Creates Watchdog object
+ dog.Configure(watchdogLimit); // Configures timeout for Watchdog
pc.printf("Code initiated\n");
int set = 0;
while(1) {
if( pc.readable()) {
set = 1;
- char c = pc.getc(); // Read the instruction sent
+ char c = pc.getc(); // Read the instruction sent
if( c == 'w') {
- smart.forward(); // Move foward
+ smart.forward(); // Move foward
}
else if( c == 'a') {
- smart.left(); // Turn left
+ smart.left(); // Turn left
}
else if( c == 'd') {
- smart.right(); // Turn right
+ smart.right(); // Turn right
}
else if( c == 's') {
- smart.backward(); // Turn backwards
+ smart.backward(); // Turn backwards
}
else if( c == 't') {
smart.pid_twistA();
- } else if(c == 'v'){
+ }
+
+ else if(c == 'v'){
smart.showOdom();
- } else if(c == 'o') { // Turns on chair
+ }
+
+ else if(c == 'o') { // Turns on chair
pc.printf("turning on\r\n");
on = 1;
wait(1);
on = 0;
- } else if(c == 'f') { // Turns off chair
+ }
+
+ else if(c == 'f') { // Turns off chair
pc.printf("turning off\r\n");
off = 1;
wait(1);
- off = 0;
+ off = 0;
+ }
- } else if(c == 'k'){ // Sends command to go to the kitchen
+ else if(c == 'k'){ // Sends command to go to the kitchen
smart.pid_twistV();
- } else if( c == 'm' || manual) { // Turns wheelchair to joystick
+ }
+
+ else if( c == 'm' || manual) { // Turns wheelchair to joystick
pc.printf("turning on joystick\r\n");
manual = true;
t.reset();
while(manual) {
- smart.move(x,y); // Reads from joystick and moves
+ smart.move(x,y); // Reads from joystick and moves
if( pc.readable()) {
char d = pc.getc();
- if( d == 'm') { // Turns wheelchair from joystick into auto
+ if( d == 'm') { // Turns wheelchair from joystick into auto
pc.printf("turning off joystick\r\n");
manual = false;
}
}
}
}
- else {
+
+ else {
pc.printf("none \r\n");
- smart.stop(); // If nothing else is happening stop the chair
+ smart.stop(); // If nothing else is happening stop the chair
}
}
- else {
-
- smart.stop(); // If nothing else is happening stop the chair
+
+ else {
+ smart.stop(); // If nothing else is happening stop the chair
}
wait(process);
t.stop();
//pc.printf("Time elapsed: %f seconds, Iteration = %d\n", t.read(), iteration);
- dog.Service(); // Service the Watchdog so it does not cause a system reset - "Kicking"/"Feeding" the dog
+ dog.Service(); // Service the Watchdog so it does not cause a system reset - "Kicking"/"Feeding" the dog
}
}