simulavr  1.1.0
AnalogValue Class Reference

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...
 
AnalogValueoperator= (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...
 

Detailed Description

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.

Definition at line 54 of file pin.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
ST_GND 

digital state, ground potential

ST_FLOATING 

floating potential, not connected or tristate, assumed as FLOATING_POTENTIAL

ST_VCC 

digital state, Vcc potential

ST_ANALOG 

valid analog value between ground and Vcc (and included)

Definition at line 61 of file pin.h.

Constructor & Destructor Documentation

◆ AnalogValue() [1/3]

AnalogValue::AnalogValue ( void  )
inline

standard constructor, status is floating

Definition at line 69 of file pin.h.

◆ AnalogValue() [2/3]

AnalogValue::AnalogValue ( float  val)
inline

analog value constructor, set real analog value

Definition at line 71 of file pin.h.

◆ AnalogValue() [3/3]

AnalogValue::AnalogValue ( int  dig)
inline

digital value constructor, set a digital state

Definition at line 73 of file pin.h.

References aValue, and dState.

Member Function Documentation

◆ analogValid()

bool AnalogValue::analogValid ( void  ) const
inline

test, if real analog value is available

Definition at line 88 of file pin.h.

◆ getA()

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().

◆ getD()

int AnalogValue::getD ( void  ) const
inline

Definition at line 80 of file pin.h.

◆ getRaw()

float AnalogValue::getRaw ( void  ) const
inline

get raw analog value (no calculation, just content of aValue

Definition at line 86 of file pin.h.

Referenced by Pin::GetRawAnalog().

◆ operator=()

AnalogValue& AnalogValue::operator= ( const AnalogValue a)
inline

copy operator

Definition at line 76 of file pin.h.

◆ setA()

void AnalogValue::setA ( float  val)
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().

◆ setD()

void AnalogValue::setD ( int  dig)
inline

set a digital state, see enum definition

Definition at line 79 of file pin.h.

Member Data Documentation

◆ aValue

float AnalogValue::aValue
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().

◆ dState

int AnalogValue::dState
private

digital state and validity of aValue

Definition at line 57 of file pin.h.

Referenced by AnalogValue(), and getA().


The documentation for this class was generated from the following files: