ti bisogna il phaserunner
Dependencies: mbed PID mbed-rtos
Diff: Daumenbetaetigung.cpp
- Revision:
- 6:a80300ee574d
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Daumenbetaetigung.cpp Thu May 09 11:50:43 2019 +0000 @@ -0,0 +1,25 @@ +#include "Daumenbetaetigung.h" + +Daumenbetaetigung::Daumenbetaetigung(): poti(PC_3){ + this->Error = false; +} + +uint16_t Daumenbetaetigung::getValue(){ + int16_t value = this->poti.read() * 100; + if( value == 0 ){ + this->Error = true; + return 0; + } + + value = value - Daumenbetaetigung::UNTERGRENZE; + if( value < 0 ) return 0; + + value = value * 100 / (Daumenbetaetigung::OBERGRENZE-Daumenbetaetigung::UNTERGRENZE); + + if( value > 100 ) return 100; + return value; +} + +Daumenbetaetigung::operator int(){ + return getValue(); +}