ti bisogna il phaserunner
Dependencies: mbed PID mbed-rtos
Peripherien/Daumenbetaetigung.cpp@11:39bd79605827, 2019-06-04 (annotated)
- Committer:
- beacon
- Date:
- Tue Jun 04 19:03:39 2019 +0000
- Revision:
- 11:39bd79605827
- Parent:
- 9:56aed8c6779f
ti bisogna il phaserunner
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
EpicG10 | 6:a80300ee574d | 1 | #include "Daumenbetaetigung.h" |
EpicG10 | 6:a80300ee574d | 2 | |
EpicG10 | 9:56aed8c6779f | 3 | Daumenbetaetigung::Daumenbetaetigung(): poti(POTIPIN){ //POTIPIN = PC_3 |
EpicG10 | 6:a80300ee574d | 4 | this->Error = false; |
EpicG10 | 6:a80300ee574d | 5 | } |
EpicG10 | 6:a80300ee574d | 6 | |
EpicG10 | 6:a80300ee574d | 7 | uint16_t Daumenbetaetigung::getValue(){ |
EpicG10 | 6:a80300ee574d | 8 | int16_t value = this->poti.read() * 100; |
EpicG10 | 6:a80300ee574d | 9 | if( value == 0 ){ |
EpicG10 | 6:a80300ee574d | 10 | this->Error = true; |
EpicG10 | 6:a80300ee574d | 11 | return 0; |
EpicG10 | 6:a80300ee574d | 12 | } |
EpicG10 | 6:a80300ee574d | 13 | |
EpicG10 | 6:a80300ee574d | 14 | value = value - Daumenbetaetigung::UNTERGRENZE; |
EpicG10 | 6:a80300ee574d | 15 | if( value < 0 ) return 0; |
EpicG10 | 6:a80300ee574d | 16 | |
EpicG10 | 6:a80300ee574d | 17 | value = value * 100 / (Daumenbetaetigung::OBERGRENZE-Daumenbetaetigung::UNTERGRENZE); |
EpicG10 | 6:a80300ee574d | 18 | |
EpicG10 | 6:a80300ee574d | 19 | if( value > 100 ) return 100; |
EpicG10 | 6:a80300ee574d | 20 | return value; |
EpicG10 | 6:a80300ee574d | 21 | } |
EpicG10 | 6:a80300ee574d | 22 | |
EpicG10 | 6:a80300ee574d | 23 | Daumenbetaetigung::operator int(){ |
EpicG10 | 6:a80300ee574d | 24 | return getValue(); |
EpicG10 | 6:a80300ee574d | 25 | } |