added code for PCB on and off, added pointers to e_button and pwm pins
Dependencies: QEI2 chair_BNO055 PID VL53L1X_Filter
Dependents: wheelchairControlSumer2019
wheelchair.cpp@4:29a27953fe70, 2018-07-17 (annotated)
- Committer:
- ryanlin97
- Date:
- Tue Jul 17 02:29:26 2018 +0000
- Revision:
- 4:29a27953fe70
- Parent:
- 3:a5e71bfdb492
- Child:
- 5:e0ccaab3959a
beginning imu class
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ryanlin97 | 0:fc0c4a184482 | 1 | #include "wheelchair.h" |
ryanlin97 | 1:c0beadca1617 | 2 | |
ryanlin97 | 1:c0beadca1617 | 3 | Wheelchair::Wheelchair(PinName xPin, PinName yPin) |
ryanlin97 | 1:c0beadca1617 | 4 | { |
ryanlin97 | 3:a5e71bfdb492 | 5 | x = new PwmOut(xPin); |
ryanlin97 | 3:a5e71bfdb492 | 6 | y = new PwmOut(yPin); |
ryanlin97 | 1:c0beadca1617 | 7 | } |
ryanlin97 | 3:a5e71bfdb492 | 8 | /* |
ryanlin97 | 3:a5e71bfdb492 | 9 | * joystick has analog out of 200-700, scale values between 1.3 and 3.3 |
ryanlin97 | 3:a5e71bfdb492 | 10 | */ |
ryanlin97 | 3:a5e71bfdb492 | 11 | void Wheelchair::move(float x_coor, float y_coor) |
ryanlin97 | 1:c0beadca1617 | 12 | { |
ryanlin97 | 4:29a27953fe70 | 13 | printf("raw is %f %f \n", x_coor, y_coor); |
ryanlin97 | 4:29a27953fe70 | 14 | printf("x is %f y is %f \n", ((x_coor*1.6f) + 1.7f), ((y_coor*1.6f) + 1.7f)); |
ryanlin97 | 4:29a27953fe70 | 15 | float scaled_x = ((x_coor * 1.6f) + 1.7f)/3.3f; |
ryanlin97 | 4:29a27953fe70 | 16 | float scaled_y = (3.3f - (y_coor * 1.6f))/3.3f; |
ryanlin97 | 4:29a27953fe70 | 17 | x->write(scaled_x); |
ryanlin97 | 4:29a27953fe70 | 18 | y->write(scaled_y); |
ryanlin97 | 3:a5e71bfdb492 | 19 | |
ryanlin97 | 1:c0beadca1617 | 20 | } |
ryanlin97 | 1:c0beadca1617 | 21 | |
ryanlin97 | 1:c0beadca1617 | 22 | void Wheelchair::forward() |
ryanlin97 | 1:c0beadca1617 | 23 | { |
ryanlin97 | 0:fc0c4a184482 | 24 | x->write(high); |
ryanlin97 | 3:a5e71bfdb492 | 25 | y->write(def+offset); |
ryanlin97 | 0:fc0c4a184482 | 26 | } |
ryanlin97 | 0:fc0c4a184482 | 27 | |
ryanlin97 | 1:c0beadca1617 | 28 | void Wheelchair::backward() |
ryanlin97 | 1:c0beadca1617 | 29 | { |
ryanlin97 | 0:fc0c4a184482 | 30 | x->write(low); |
ryanlin97 | 0:fc0c4a184482 | 31 | y->write(def); |
ryanlin97 | 0:fc0c4a184482 | 32 | } |
ryanlin97 | 0:fc0c4a184482 | 33 | |
ryanlin97 | 1:c0beadca1617 | 34 | void Wheelchair::right() |
ryanlin97 | 1:c0beadca1617 | 35 | { |
ryanlin97 | 0:fc0c4a184482 | 36 | x->write(def); |
ryanlin97 | 0:fc0c4a184482 | 37 | y->write(high); |
ryanlin97 | 0:fc0c4a184482 | 38 | } |
ryanlin97 | 0:fc0c4a184482 | 39 | |
ryanlin97 | 1:c0beadca1617 | 40 | void Wheelchair::left() |
ryanlin97 | 1:c0beadca1617 | 41 | { |
ryanlin97 | 0:fc0c4a184482 | 42 | x->write(def); |
ryanlin97 | 0:fc0c4a184482 | 43 | y->write(low); |
ryanlin97 | 0:fc0c4a184482 | 44 | } |
ryanlin97 | 0:fc0c4a184482 | 45 | |
ryanlin97 | 1:c0beadca1617 | 46 | void Wheelchair::stop() |
ryanlin97 | 1:c0beadca1617 | 47 | { |
ryanlin97 | 0:fc0c4a184482 | 48 | x->write(def); |
ryanlin97 | 0:fc0c4a184482 | 49 | y->write(def); |
ryanlin97 | 1:c0beadca1617 | 50 | } |