ti bisogna il phaserunner

Dependencies:   mbed PID mbed-rtos

Peripherien/Handgriffbetaetigung.cpp

Committer:
beacon
Date:
2019-06-04
Revision:
11:39bd79605827
Parent:
7:15e6fc689368

File content as of revision 11:39bd79605827:

#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();
}