RSeries astromech firmware
SoftPot.h
Go to the documentation of this file.
1 #ifndef SoftPot_h
2 #define SoftPot_h
3 
4 #include "ReelTwo.h"
5 #include "core/SetupEvent.h"
6 #include "core/AnimatedEvent.h"
7 
21 class SoftPot :
23 {
24 public:
28  SoftPot(const byte pin) :
29  fPin(pin),
30  fValue(0)
31  {}
32 
36  virtual int getValue()
37  {
38  return fValue;
39  }
40 
44  virtual void setup() override
45  {
46  pinMode(fPin, INPUT);
47  }
48 
52  virtual void animate() override
53  {
54  fValue = analogRead(fPin);
55  }
56 
57 protected:
58  byte fPin;
59  int fValue;
60 };
61 
62 #endif
SoftPot::fPin
byte fPin
Definition: SoftPot.h:58
ReelTwo.h
SetupEvent.h
AnimatedEvent
Base class for all animated devices. AnimatedEvent::animate() is called for each device once through ...
Definition: AnimatedEvent.h:18
SetupEvent
Base class for all devices that require setup that cannot happen in the constructor....
Definition: SetupEvent.h:15
AnimatedEvent.h
SoftPot::getValue
virtual int getValue()
Definition: SoftPot.h:36
SoftPot::fValue
int fValue
Definition: SoftPot.h:59
SoftPot
Encapsulate a soft potentiometer. Value is read once every cycle.
Definition: SoftPot.h:21
SoftPot::setup
virtual void setup() override
Setup pin mode for analog read.
Definition: SoftPot.h:44
SoftPot::SoftPot
SoftPot(const byte pin)
Default Constructor.
Definition: SoftPot.h:28
SoftPot::animate
virtual void animate() override
Read the pot once through the loop.
Definition: SoftPot.h:52