-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathColorSelectMonitor.h
More file actions
45 lines (37 loc) · 1.36 KB
/
ColorSelectMonitor.h
File metadata and controls
45 lines (37 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#ifndef COLORSELECTMONITOR_HEADERGUARD
#define COLORSELECTMONITOR_HEADERGUARD
#if defined(ARDUINO) && ARDUINO >= 100
#include "Arduino.h"
#else
#include "WProgram.h"
#include <pins_arduino.h>
#endif
#include "TaskScheduler.h"
#include "ColorWheelDisplay.h"
#include "RunningAverageFilter.h"
// Constantly monitors an analog pin and interprets its value as a RGB color
// Displays the current selected color on the LED display when the analog pin
// changes to a new value.
class ColorSelectMonitor
{
public:
ColorSelectMonitor(TaskScheduler& scheduler, LedDisplay& display, uint8_t monitorPin);
~ColorSelectMonitor();
void enable();
void disable();
uint32_t getColor();
static void checkAnalogPin0(void* clientData); //should only be called by the taskScheduler.
private:
// Private functions
void checkAnalogPin();
// Private variables
TaskScheduler& m_scheduler;
taskToken_t m_currentScheduledTask;
ColorWheelDisplay m_colorWheelDisplay;
uint8_t m_pinToMonitor;
int16_t m_previousReading;
uint32_t m_timeIdleMs;
bool m_showingColorWheel;
RunningAverageFilter m_lowPassFilter; //Filter to smooth out analog readings
};//end ColorSelectMonitor
#endif //COLORSELECTMONITOR_HEADERGUARD