a
Dependencies: LCD_DISCO_F429ZI mbed BSP_DISCO_F429ZI
stepper.cpp
- Committer:
- matis755
- Date:
- 2020-05-21
- Revision:
- 4:e48aee3e8d09
- Child:
- 5:3c19c3ae6286
File content as of revision 4:e48aee3e8d09:
#include "stepper.h" enum Step{LEFT,RIGHT}; Stepper::Stepper() : Button(USER_BUTTON){ } void Stepper::Step(enum Step eStep){ if(eStep == LEFT){ ucLedIdx++; } else if(eStep == RIGHT){ ucLedIdx--; } else{} ucLedIdx = ucLedIdx % 4; MyLed.On(ucLedIdx); } void Stepper::StepLeft(void){ Step(LEFT); } void Stepper::StepRight(void){ Step(RIGHT); } void Stepper::Callib(void) { while(!Button) { StepRight(); wait(0.1); } } void Stepper::Goto(unsigned char ucDestination) { ucDesiredPos = ucDestination; while (ucCurrentPos > ucDesiredPos) { StepLeft(); ucCurrentPos --; wait(0.2); } while (ucCurrentPos < ucDesiredPos) { StepRight(); ucCurrentPos ++; wait(0.2); } } void Stepper::Step(unsigned char ucSteps) { ucDesiredPos = ucCurrentPos + ucSteps; while (ucCurrentPos < ucDesiredPos) { StepRight(); ucCurrentPos ++; wait(0.2); } }