Frästisch mit elektronischer Höhenverstellung mittels Schrittmotoren.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

RotaryControler.cpp 1.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /*
  2. * RotaryControler.cpp
  3. *
  4. * Created on: 04.02.2022
  5. * Author: FSmilari
  6. */
  7. #include "RotaryControler.h"
  8. /*****************
  9. ** Constructors.
  10. ****************/
  11. RotaryControler::RotaryControler(int RotEnc_Dta_Pin, int RotEnc_Clk_Pin, int RotEnc_Switch_Pin) : Encoder(RotEnc_Dta_Pin, RotEnc_Clk_Pin,
  12. RotaryEncoder::LatchMode::FOUR3), RotarySwitch(RotEnc_Switch_Pin, true, 2000) {
  13. }
  14. /******************
  15. ** Public methods
  16. *****************/
  17. void RotaryControler::tick(void) {
  18. Encoder.tick();
  19. }
  20. void RotaryControler::resetPosition(void) {
  21. Encoder.setPosition(0L);
  22. }
  23. long RotaryControler::getPosition(void) {
  24. return Encoder.getPosition();
  25. }
  26. int RotaryControler::getDirection(void) {
  27. return (int) Encoder.getPosition();
  28. }
  29. bool RotaryControler::isSwitchPressed(void) {
  30. return RotarySwitch.isPressed();
  31. }
  32. bool RotaryControler::isSwitchLongPressed(void) {
  33. return RotarySwitch.isLongPressed();
  34. }
  35. void RotaryControler::setDebounceTime(unsigned long time) {
  36. RotarySwitch.setDebounceTime(time);
  37. }
  38. void RotaryControler::loop(void) {
  39. RotarySwitch.loop();
  40. Encoder.tick();
  41. }