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.

45 lines
706B

  1. #pragma once
  2. #include "Constants.h"
  3. class SchmidtTrigger
  4. {
  5. public:
  6. SchmidtTrigger(float thLo = cGateLow, float thHi = cGateHi) :
  7. _thLo(thLo), _thHi(thHi), _lastOut(false)
  8. {
  9. }
  10. bool go(float input)
  11. {
  12. if (_lastOut) // if we were true last time
  13. {
  14. if (input < _thLo) {
  15. _lastOut = false;
  16. }
  17. } else {
  18. if (input > _thHi) {
  19. _lastOut = true;
  20. }
  21. }
  22. return _lastOut;
  23. }
  24. float thhi() const
  25. {
  26. return _thHi;
  27. }
  28. float thlo() const
  29. {
  30. return _thLo;
  31. }
  32. private:
  33. const float _thLo;
  34. const float _thHi;
  35. bool _lastOut;
  36. };