Added more code for side and angled sensor
Dependencies: QEI2 PID Watchdog VL53L1X_Filter BNOWrapper ros_lib_kinetic
Revision 1:c0beadca1617, committed 2018-07-12
- Comitter:
- ryanlin97
- Date:
- Thu Jul 12 19:06:33 2018 +0000
- Parent:
- 0:fc0c4a184482
- Child:
- 2:c2d049efc266
- Commit message:
- symbol__user)perthread_libspace multiply defined(by /build/mbed-os.....)
Changed in this revision
--- a/main.cpp Thu Jul 12 18:36:09 2018 +0000 +++ b/main.cpp Thu Jul 12 19:06:33 2018 +0000 @@ -8,68 +8,68 @@ DigitalOut down(D3); int main(void) { -/* Wheelchair smart(xDir,yDir); + Wheelchair smart(xDir,yDir); on = 1; - while(1){ - if( pc.readable()) { - char c = pc.getc(); - if( c == 'w') { - pc.printf("up \n"); - smart.forward(); + while(1) { + if( pc.readable()) { + char c = pc.getc(); + if( c == 'w') { + pc.printf("up \n"); + smart.forward(); } - - else if( c == 'd') { - pc.printf("left \n"); - smart.left(); + + else if( c == 'd') { + pc.printf("left \n"); + smart.left(); } - - else if( c == 'a') { - pc.printf("right \n"); - smart.right(); + + else if( c == 'a') { + pc.printf("right \n"); + smart.right(); } - - else if( c == 's') { - pc.printf("down \n"); - smart.backward(); + + else if( c == 's') { + pc.printf("down \n"); + smart.backward(); } - - else { - pc.printf("none \n"); - smart.stop(); - if( c == 'o') { - pc.printf("turning on"); - on = 0; - wait(process); - on = 1; + + else { + pc.printf("none \n"); + smart.stop(); + if( c == 'o') { + pc.printf("turning on"); + on = 0; + wait(process); + on = 1; } - - else if( c == 'k') { - off = 0; - wait(process); - off = 1; + + else if( c == 'k') { + off = 0; + wait(process); + off = 1; } - - else if( c == 'u') { - up = 0; - wait(process); - up = 1; + + else if( c == 'u') { + up = 0; + wait(process); + up = 1; } - - else if( c == 'p') { - down = 0; - wait(process); - down = 1; + + else if( c == 'p') { + down = 0; + wait(process); + down = 1; } } - } - - else { - pc.printf("nothing pressed \n"); - smart.stop(); - } - - wait(process); - } -*/ + } + + else { + pc.printf("nothing pressed \n"); + smart.stop(); + } + + wait(process); + } + }
--- a/wheelchair.cpp Thu Jul 12 18:36:09 2018 +0000 +++ b/wheelchair.cpp Thu Jul 12 19:06:33 2018 +0000 @@ -1,34 +1,41 @@ #include "wheelchair.h" -/* -Wheelchair::Wheelchair(PinName xPin, PinName yPin){ - x = new AnalogOut(xPin); - y = new AnalogOut(yPin); - } + +Wheelchair::Wheelchair(PinName xPin, PinName yPin) +{ + x = new AnalogOut(xPin); + y = new AnalogOut(yPin); +} -void Wheelchair::move(float degrees){ - } - -void Wheelchair::forward(){ +void Wheelchair::move(float degrees) +{ +} + +void Wheelchair::forward() +{ x->write(high); y->write(def); } -void Wheelchair::backward(){ +void Wheelchair::backward() +{ x->write(low); y->write(def); } -void Wheelchair::right(){ +void Wheelchair::right() +{ x->write(def); y->write(high); } -void Wheelchair::left(){ +void Wheelchair::left() +{ x->write(def); y->write(low); } -void Wheelchair::stop(){ +void Wheelchair::stop() +{ x->write(def); y->write(def); -}*/ \ No newline at end of file +} \ No newline at end of file
--- a/wheelchair.h Thu Jul 12 18:36:09 2018 +0000 +++ b/wheelchair.h Thu Jul 12 19:06:33 2018 +0000 @@ -13,17 +13,17 @@ class Wheelchair { public: - /*Wheelchair(PinName xPin, PinName yPin); - void move(float degrees); - void forward(); - void backward(); - void right(); - void left(); - void stop(); + Wheelchair(PinName xPin, PinName yPin); + void move(float degrees); + void forward(); + void backward(); + void right(); + void left(); + void stop(); - private: - AnalogOut* x; - AnalogOut* y; - */ +private: + AnalogOut* x; + AnalogOut* y; + }; #endif \ No newline at end of file