Driver for two motors library
Revision 1:e417951c16d7, committed 2020-07-29
- Comitter:
- cristian_junca
- Date:
- Wed Jul 29 04:40:37 2020 +0000
- Parent:
- 0:eafb70ae80f7
- Commit message:
- Library to driver two dc motors;
Changed in this revision
Driver.cpp | Show annotated file Show diff for this revision Revisions of this file |
Driver.h | Show annotated file Show diff for this revision Revisions of this file |
diff -r eafb70ae80f7 -r e417951c16d7 Driver.cpp --- 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)
diff -r eafb70ae80f7 -r e417951c16d7 Driver.h --- a/Driver.h Tue Jul 28 05:46:24 2020 +0000 +++ b/Driver.h Wed Jul 29 04:40:37 2020 +0000 @@ -1,9 +1,9 @@ #include "mbed.h" -class driver{ +class Driver{ public: - driver(PinName M1A, PinName M1B, PinName M2A, PinName M2B); + Driver(PinName M1A, PinName M1B, PinName M2A, PinName M2B); void setPeriod_ms(int32_t); void forward(float, float); void backward(float, float);