eBike / Mbed 2 deprecated ENCODER_TEST3_peddep

Dependencies:   mbed PID mbed-rtos

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Handgriffbetaetigung.cpp Source File

Handgriffbetaetigung.cpp

00001 #include "Handgriffbetaetigung.h"
00002 
00003 Handgriffbetaetigung::Handgriffbetaetigung(): poti(POTIPIN){
00004     this->Error     = false;
00005 }
00006 
00007 uint16_t Handgriffbetaetigung::getValue(){
00008     int16_t value = this->poti.read() * 100;
00009 
00010     if( value == 0 ){
00011         this->Error = true;
00012         return 0;
00013     }
00014 
00015     value = value - Handgriffbetaetigung::UNTERGRENZE;
00016     if( value < 0 ) return 0;
00017 
00018     value = value * 100 / (Handgriffbetaetigung::OBERGRENZE-Handgriffbetaetigung::UNTERGRENZE);
00019 
00020     if( value > 100 ) return 100;
00021     return value;
00022 }
00023 
00024 Handgriffbetaetigung::operator int(){
00025     return getValue();
00026 }