Driver for two motors library
Diff: Driver.cpp
- Revision:
- 1:e417951c16d7
- Parent:
- 0:eafb70ae80f7
--- a/Driver.cpp Tue Jul 28 05:46:24 2020 +0000 +++ b/Driver.cpp Wed Jul 29 04:40:37 2020 +0000 @@ -1,12 +1,12 @@ #include "mbed.h" #include "Driver.h" -driver::driver(PinName M1A, PinName M1B, PinName M2A, PinName M2B): +Driver::Driver(PinName M1A, PinName M1B, PinName M2A, PinName M2B): M1A(M1A), M1B(M1B), M2A(M2A), M2B(M2B){ setPeriod_ms(1000); } -void driver::setPeriod_ms(int32_t period){ +void Driver::setPeriod_ms(int32_t period){ _period = period; M1A.period_ms(_period); M1B.period_ms(_period); @@ -14,14 +14,14 @@ M2B.period_ms(_period); } -void driver::neutral(){ +void Driver::neutral(){ M1A.write(0); M1B.write(0); M2A.write(0); M2B.write(0); } -void driver::forward(float dutyCycle1, float dutyCycle2){ +void Driver::forward(float dutyCycle1, float dutyCycle2){ _dutyCycle1 = dutyCycle1; _dutyCycle2 = dutyCycle2; if(_dutyCycle1 > 1.0f) @@ -39,7 +39,7 @@ M2B.write(0); } -void driver::backward(float dutyCycle1, float dutyCycle2){ +void Driver::backward(float dutyCycle1, float dutyCycle2){ _dutyCycle1 = dutyCycle1; _dutyCycle2 = dutyCycle2; if(_dutyCycle1 > 1.0f) @@ -57,7 +57,7 @@ M2B.write(_dutyCycle2); } -void driver::right(float dutyCycle1, float dutyCycle2){ +void Driver::right(float dutyCycle1, float dutyCycle2){ _dutyCycle1 = dutyCycle1; _dutyCycle2 = dutyCycle2; if(_dutyCycle1 > 1.0f) @@ -75,7 +75,7 @@ M2B.write(0); } -void driver::left(float dutyCycle1, float dutyCycle2){ +void Driver::left(float dutyCycle1, float dutyCycle2){ _dutyCycle1 = dutyCycle1; _dutyCycle2 = dutyCycle2; if(_dutyCycle1 > 1.0f)