eBike / Mbed 2 deprecated ENCODER_TEST3_peddep

Dependencies:   mbed PID mbed-rtos

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Daumenbetaetigung.cpp Source File

Daumenbetaetigung.cpp

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