RSeries astromech firmware
DomeSensorAnalogPosition.h
Go to the documentation of this file.
1 #ifndef DomeSensorAnalogPosition_h
2 #define DomeSensorAnalogPosition_h
3 
4 #include "ReelTwo.h"
5 #include "drive/DomePosition.h"
6 #include "core/AnalogMonitor.h"
7 
9 {
10 public:
11  DomeSensorAnalogPosition(uint8_t analogPin) :
12  fDomePosition(analogPin)
13  {
14  }
15 
16  bool ready()
17  {
18  return true;
19  }
20 
21  virtual Mode getDomeMode() override
22  {
23  if (!ready())
24  return kOff;
25  return fDomeMode;
26  }
27 
28  virtual void setDomeMode(Mode mode) override
29  {
30  fDomeMode = mode;
31  }
32 
33  virtual bool getDomeFlip() override
34  {
35  return fDomeFlip;
36  }
37 
38  virtual float easingMethod(float completion)
39  {
40  // TODO
41  return completion;
42  }
43 
44  virtual float getDomeSpeedHome() override
45  {
46  return float(fDomeSpeedHome) / 100.0;
47  }
48 
49  virtual unsigned getDomeFudge() override
50  {
51  return fDomeFudge;
52  }
53 
54  virtual unsigned getDomeSeekLeft() override
55  {
56  return fDomeSeekLeft;
57  }
58 
59  virtual unsigned getDomeSeekRight() override
60  {
61  return fDomeSeekRight;
62  }
63 
64  virtual unsigned getDomeMinDelay() override
65  {
66  return fDomeMinDelay;
67  }
68 
69  virtual unsigned getDomeMaxDelay() override
70  {
71  return fDomeMaxDelay;
72  }
73 
74  virtual unsigned getDomeHome() override
75  {
76  return fDomeHome;
77  }
78 
79  virtual unsigned getDomeTargetPosition() override
80  {
81  return fDomeTargetPos;
82  }
83 
84  virtual unsigned getDomePosition() override
85  {
87  unsigned val = fDomePosition.getValue();
88  // Serial.print("val : "); Serial.print(val); Serial.print(" : ");
89  return map(val, 0, 1024, 0, 359);
90  // val = min(max(val, fParams.domespmin), fParams.domespmax);
91  // int pos = map(val, fParams.domespmin, fParams.domespmax, 0, 359);
92  // return 0;
93  }
94 
95 protected:
98  bool fDomeFlip = false;
99  uint16_t fDomeHome = 0;
101  uint8_t fDomeMinDelay = 6;
102  uint8_t fDomeMaxDelay = 8;
103  uint8_t fDomeSeekRight = 80;
104  uint8_t fDomeSeekLeft = 80;
105  uint8_t fDomeFudge = 5;
106  uint8_t fDomeSpeedHome = 40;
107  uint8_t fDomeSpeedSeek = 30;
108 };
109 
110 #endif
DomePosition::Mode
Mode
Definition: DomePosition.h:10
DomePosition::kOff
@ kOff
Definition: DomePosition.h:12
DomeSensorAnalogPosition::getDomeMode
virtual Mode getDomeMode() override
Definition: DomeSensorAnalogPosition.h:21
DomeSensorAnalogPosition::fDomeFudge
uint8_t fDomeFudge
Definition: DomeSensorAnalogPosition.h:105
ReelTwo.h
DomeSensorAnalogPosition::getDomeSeekLeft
virtual unsigned getDomeSeekLeft() override
Definition: DomeSensorAnalogPosition.h:54
DomePosition
Definition: DomePosition.h:7
DomeSensorAnalogPosition::DomeSensorAnalogPosition
DomeSensorAnalogPosition(uint8_t analogPin)
Definition: DomeSensorAnalogPosition.h:11
DomeSensorAnalogPosition::fDomeFlip
bool fDomeFlip
Definition: DomeSensorAnalogPosition.h:98
AnalogMonitor.h
DomeSensorAnalogPosition::fDomeSeekRight
uint8_t fDomeSeekRight
Definition: DomeSensorAnalogPosition.h:103
DomePosition.h
AnalogMonitor::getValue
int getValue()
Definition: AnalogMonitor.h:101
DomeSensorAnalogPosition::fDomeMinDelay
uint8_t fDomeMinDelay
Definition: DomeSensorAnalogPosition.h:101
DomeSensorAnalogPosition::getDomeFudge
virtual unsigned getDomeFudge() override
Definition: DomeSensorAnalogPosition.h:49
DomeSensorAnalogPosition::getDomeHome
virtual unsigned getDomeHome() override
Definition: DomeSensorAnalogPosition.h:74
DomeSensorAnalogPosition
Definition: DomeSensorAnalogPosition.h:8
DomeSensorAnalogPosition::fDomeSeekLeft
uint8_t fDomeSeekLeft
Definition: DomeSensorAnalogPosition.h:104
DomeSensorAnalogPosition::getDomeSeekRight
virtual unsigned getDomeSeekRight() override
Definition: DomeSensorAnalogPosition.h:59
DomeSensorAnalogPosition::easingMethod
virtual float easingMethod(float completion)
Definition: DomeSensorAnalogPosition.h:38
DomeSensorAnalogPosition::fDomePosition
AnalogMonitor fDomePosition
Definition: DomeSensorAnalogPosition.h:96
DomeSensorAnalogPosition::getDomeTargetPosition
virtual unsigned getDomeTargetPosition() override
Definition: DomeSensorAnalogPosition.h:79
DomeSensorAnalogPosition::fDomeHome
uint16_t fDomeHome
Definition: DomeSensorAnalogPosition.h:99
DomeSensorAnalogPosition::getDomePosition
virtual unsigned getDomePosition() override
Definition: DomeSensorAnalogPosition.h:84
DomeSensorAnalogPosition::fDomeMode
Mode fDomeMode
Definition: DomeSensorAnalogPosition.h:97
DomeSensorAnalogPosition::getDomeFlip
virtual bool getDomeFlip() override
Definition: DomeSensorAnalogPosition.h:33
DomeSensorAnalogPosition::setDomeMode
virtual void setDomeMode(Mode mode) override
Definition: DomeSensorAnalogPosition.h:28
DomeSensorAnalogPosition::getDomeSpeedHome
virtual float getDomeSpeedHome() override
Definition: DomeSensorAnalogPosition.h:44
DomeSensorAnalogPosition::fDomeTargetPos
uint16_t fDomeTargetPos
Definition: DomeSensorAnalogPosition.h:100
DomeSensorAnalogPosition::getDomeMaxDelay
virtual unsigned getDomeMaxDelay() override
Definition: DomeSensorAnalogPosition.h:69
DomeSensorAnalogPosition::fDomeMaxDelay
uint8_t fDomeMaxDelay
Definition: DomeSensorAnalogPosition.h:102
DomeSensorAnalogPosition::getDomeMinDelay
virtual unsigned getDomeMinDelay() override
Definition: DomeSensorAnalogPosition.h:64
DomeSensorAnalogPosition::ready
bool ready()
Definition: DomeSensorAnalogPosition.h:16
DomeSensorAnalogPosition::fDomeSpeedSeek
uint8_t fDomeSpeedSeek
Definition: DomeSensorAnalogPosition.h:107
DomeSensorAnalogPosition::fDomeSpeedHome
uint8_t fDomeSpeedHome
Definition: DomeSensorAnalogPosition.h:106
AnalogMonitor
Used for eliminating noise in analogRead inputs without decreasing responsiveness....
Definition: AnalogMonitor.h:51
AnalogMonitor::animate
virtual void animate()
Subclasses must implement this function to run through a single frame of animation/activity.
Definition: AnalogMonitor.h:130