simulavr
1.1.0
|
Implements "real" analog value as float. More...
#include <pin.h>
Public Types | |
enum | { ST_GND, ST_FLOATING, ST_VCC, ST_ANALOG } |
Public Member Functions | |
AnalogValue (void) | |
standard constructor, status is floating More... | |
AnalogValue (float val) | |
analog value constructor, set real analog value More... | |
AnalogValue (int dig) | |
digital value constructor, set a digital state More... | |
AnalogValue & | operator= (const AnalogValue &a) |
copy operator More... | |
void | setD (int dig) |
set a digital state, see enum definition More... | |
int | getD (void) const |
void | setA (float val) |
set analog value, no check to value range between ground and vcc More... | |
float | getA (float vcc) |
calculate real voltage potential, needs value of Vcc potential More... | |
float | getRaw (void) const |
get raw analog value (no calculation, just content of aValue More... | |
bool | analogValid (void) const |
test, if real analog value is available More... | |
Private Attributes | |
int | dState |
digital state and validity of aValue More... | |
float | aValue |
analog value from setA method or constructor (not checked to valid range!) More... | |
Implements "real" analog value as float.
Problem is, that the Vcc level isn't normally not known and so it's not possible to calculate correct value. So, here the value is calculated, if GetAnalogValue method is called. If no analog value is set by SetAnalogValue method, a replacement value is calculated. An analog value set by GetAnalogValue method is valid till it's not rewritten by a "digital" replacement value.
anonymous enum |
|
inline |
|
inline |
|
inline |
|
inline |
float AnalogValue::getA | ( | float | vcc | ) |
calculate real voltage potential, needs value of Vcc potential
Definition at line 33 of file pin.cpp.
References aValue, dState, REL_FLOATING_POTENTIAL, ST_ANALOG, ST_FLOATING, ST_GND, and ST_VCC.
Referenced by Pin::GetAnalogValue().
|
inline |
get raw analog value (no calculation, just content of aValue
Definition at line 86 of file pin.h.
Referenced by Pin::GetRawAnalog().
|
inline |
|
inline |
set analog value, no check to value range between ground and vcc
Definition at line 82 of file pin.h.
Referenced by Pin::SetRawAnalog().
|
inline |
|
private |
analog value from setA method or constructor (not checked to valid range!)
Definition at line 58 of file pin.h.
Referenced by AnalogValue(), and getA().
|
private |
digital state and validity of aValue
Definition at line 57 of file pin.h.
Referenced by AnalogValue(), and getA().