Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: motor/motor.h
- Revision:
- 14:1363e4b2fbac
- Parent:
- 12:e2b7e030193c
- Child:
- 15:5f791bd5dd97
--- a/motor/motor.h Tue Mar 06 08:35:33 2018 +0000 +++ b/motor/motor.h Mon Jul 02 07:41:35 2018 +0000 @@ -13,38 +13,40 @@ class Motor { public: - Motor(PinName p, PinName d, PinName e, char* n, float Tcs, int cw); + Motor(PinName p, PinName d, PinName e, char* n, float Tcs, int cw/*, InterruptIn *c, InterruptIn *cc*/); // p_us = signal period in micro_seconds // dc = signal duty-cycle (0.0 to 1.0) void pwm_io(int p_us, float dc); // not used... void go(int direction); void setSpeed(float cm_s); float speed() { - return (float)TXcm_s/(on_delay+off_delay); + return (float)_TXcm_s/(_onDelay+_offDelay); } void reset() { - pos=0; + _pos=0; } void to(float p); float position() { - return pos; + return _pos; } void setPosition(float p) { - pos = p; + _pos = p; } void stop(void); protected: void toggleOn(void); void toggleOff(void); - Timeout timer; - DigitalOut pulse, dir, error; - int on_delay; - int off_delay; - float TXcm_s; - char* name; - float pos, goal; - int cw,ccw; - bool lock; + void rotateCallBack(void); + Timeout _pulseTimeout, _rotateTimeout; + DigitalOut _pulse, _dir, _error; + int _onDelay; + int _offDelay; + float _TXcm_s; + char* _name; + float _pos, _goal; + int _cw,_ccw; + bool _lock; +// InterruptIn *_clockStop, *_counterClockStop; }; class CD_2D34M: public Motor