quentin godbert
/
t2-stm32_thread
avec thread
Fork of T2_STM32 by
StepperMotor.h@2:ab0ccf9bb38c, 2018-01-14 (annotated)
- Committer:
- Tioneb
- Date:
- Sun Jan 14 15:50:49 2018 +0000
- Revision:
- 2:ab0ccf9bb38c
- Child:
- 4:b01a3ce6ef01
Test
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Tioneb | 2:ab0ccf9bb38c | 1 | #ifndef StepperMotor_h |
Tioneb | 2:ab0ccf9bb38c | 2 | #define StepperMotor_h |
Tioneb | 2:ab0ccf9bb38c | 3 | |
Tioneb | 2:ab0ccf9bb38c | 4 | class StepperMotor { |
Tioneb | 2:ab0ccf9bb38c | 5 | |
Tioneb | 2:ab0ccf9bb38c | 6 | public: |
Tioneb | 2:ab0ccf9bb38c | 7 | StepperMotor(int, int, int, int, char, char); |
Tioneb | 2:ab0ccf9bb38c | 8 | ~StepperMotor(void); |
Tioneb | 2:ab0ccf9bb38c | 9 | unsigned char GetCurrentPos(), |
Tioneb | 2:ab0ccf9bb38c | 10 | CurrentPos; |
Tioneb | 2:ab0ccf9bb38c | 11 | protected: |
Tioneb | 2:ab0ccf9bb38c | 12 | char sCurrentPos, |
Tioneb | 2:ab0ccf9bb38c | 13 | TargetPos, |
Tioneb | 2:ab0ccf9bb38c | 14 | sTargetPos, |
Tioneb | 2:ab0ccf9bb38c | 15 | sPos_Min, |
Tioneb | 2:ab0ccf9bb38c | 16 | sPos_Max; |
Tioneb | 2:ab0ccf9bb38c | 17 | int sdirPin, |
Tioneb | 2:ab0ccf9bb38c | 18 | sEnablePin, |
Tioneb | 2:ab0ccf9bb38c | 19 | sOriginSensor, |
Tioneb | 2:ab0ccf9bb38c | 20 | sstepPin; |
Tioneb | 2:ab0ccf9bb38c | 21 | }; |
Tioneb | 2:ab0ccf9bb38c | 22 | |
Tioneb | 2:ab0ccf9bb38c | 23 | StepperMotor::StepperMotor(int OriginSensor, int stepPin, int dirPin, int EnablePin, char Pos_Min, char Pos_Max){ |
Tioneb | 2:ab0ccf9bb38c | 24 | sOriginSensor = OriginSensor; |
Tioneb | 2:ab0ccf9bb38c | 25 | sstepPin = stepPin; |
Tioneb | 2:ab0ccf9bb38c | 26 | sdirPin = dirPin; |
Tioneb | 2:ab0ccf9bb38c | 27 | sEnablePin = EnablePin; |
Tioneb | 2:ab0ccf9bb38c | 28 | sPos_Min = Pos_Min; |
Tioneb | 2:ab0ccf9bb38c | 29 | sPos_Max = Pos_Max; |
Tioneb | 2:ab0ccf9bb38c | 30 | DigitalOut sstepin(sStepPin); |
Tioneb | 2:ab0ccf9bb38c | 31 | DigitalOut sdirPin(sDirPin); |
Tioneb | 2:ab0ccf9bb38c | 32 | DigitalIn soriginsensor(sOriginSensor); |
Tioneb | 2:ab0ccf9bb38c | 33 | } |
Tioneb | 2:ab0ccf9bb38c | 34 | |
Tioneb | 2:ab0ccf9bb38c | 35 | StepperMotor::~StepperMotor(void){ |
Tioneb | 2:ab0ccf9bb38c | 36 | |
Tioneb | 2:ab0ccf9bb38c | 37 | } |
Tioneb | 2:ab0ccf9bb38c | 38 | |
Tioneb | 2:ab0ccf9bb38c | 39 | unsigned char StepperMotor::GetCurrentPos() { |
Tioneb | 2:ab0ccf9bb38c | 40 | return CurrentPos; |
Tioneb | 2:ab0ccf9bb38c | 41 | } |
Tioneb | 2:ab0ccf9bb38c | 42 | |
Tioneb | 2:ab0ccf9bb38c | 43 | #endif |