2014 Eurobot fork
Dependencies: mbed-rtos mbed QEI
Actuators/MainMotors/MainMotor.h@92:4a1225fbb146, 2013-10-15 (annotated)
- Committer:
- rsavitski
- Date:
- Tue Oct 15 12:19:32 2013 +0000
- Revision:
- 92:4a1225fbb146
- Parent:
- 5:56a5fdd373c9
touch: ripped out 2013-specific bits. Need to address "2014" comments. Rewrite AI layer and other deleted parts.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
twighk | 0:200635fa1b08 | 1 | |
twighk | 0:200635fa1b08 | 2 | // Eurobot13 MainMotor.h |
twighk | 0:200635fa1b08 | 3 | |
twighk | 0:200635fa1b08 | 4 | #include "mbed.h" |
twighk | 0:200635fa1b08 | 5 | |
madcowswe | 5:56a5fdd373c9 | 6 | class MainMotor{ |
twighk | 0:200635fa1b08 | 7 | private: |
twighk | 0:200635fa1b08 | 8 | PwmOut PWM1; |
twighk | 0:200635fa1b08 | 9 | PwmOut PWM2; |
twighk | 0:200635fa1b08 | 10 | |
twighk | 0:200635fa1b08 | 11 | public: |
twighk | 0:200635fa1b08 | 12 | MainMotor(PinName pin1, PinName pin2) : PWM1(pin1), PWM2(pin2){ |
twighk | 0:200635fa1b08 | 13 | } |
twighk | 0:200635fa1b08 | 14 | |
twighk | 0:200635fa1b08 | 15 | void operator()(float in){ |
twighk | 0:200635fa1b08 | 16 | power(in); |
twighk | 0:200635fa1b08 | 17 | } |
twighk | 0:200635fa1b08 | 18 | |
twighk | 0:200635fa1b08 | 19 | void power(float power){ |
twighk | 0:200635fa1b08 | 20 | if( power > 0 ){ |
twighk | 0:200635fa1b08 | 21 | PWM1 = power; |
twighk | 0:200635fa1b08 | 22 | PWM2 = 0; |
twighk | 0:200635fa1b08 | 23 | } else { |
twighk | 0:200635fa1b08 | 24 | PWM1 = 0; |
twighk | 0:200635fa1b08 | 25 | PWM2 = -power; |
twighk | 0:200635fa1b08 | 26 | } |
twighk | 0:200635fa1b08 | 27 | } |
twighk | 2:45da48fab346 | 28 | |
twighk | 2:45da48fab346 | 29 | virtual void halt (void){ |
madcowswe | 5:56a5fdd373c9 | 30 | //DigitalOut myled(LED2); |
madcowswe | 5:56a5fdd373c9 | 31 | //myled = 1; |
twighk | 2:45da48fab346 | 32 | PWM1 = 0; |
twighk | 2:45da48fab346 | 33 | PWM2 = 0; |
twighk | 2:45da48fab346 | 34 | } |
twighk | 0:200635fa1b08 | 35 | |
twighk | 0:200635fa1b08 | 36 | }; |