ti bisogna il phaserunner
Dependencies: mbed PID mbed-rtos
Diff: Peripherien/Handgriffbetaetigung.cpp
- Revision:
- 7:15e6fc689368
- Parent:
- 6:a80300ee574d
diff -r a80300ee574d -r 15e6fc689368 Peripherien/Handgriffbetaetigung.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Peripherien/Handgriffbetaetigung.cpp Thu May 16 20:42:39 2019 +0000 @@ -0,0 +1,26 @@ +#include "Handgriffbetaetigung.h" + +Handgriffbetaetigung::Handgriffbetaetigung(): poti(POTIPIN){ + this->Error = false; +} + +uint16_t Handgriffbetaetigung::getValue(){ + int16_t value = this->poti.read() * 100; + + if( value == 0 ){ + this->Error = true; + return 0; + } + + value = value - Handgriffbetaetigung::UNTERGRENZE; + if( value < 0 ) return 0; + + value = value * 100 / (Handgriffbetaetigung::OBERGRENZE-Handgriffbetaetigung::UNTERGRENZE); + + if( value > 100 ) return 100; + return value; +} + +Handgriffbetaetigung::operator int(){ + return getValue(); +}