-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathButtons.hpp
50 lines (40 loc) · 1.06 KB
/
Buttons.hpp
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
46
47
48
49
50
#pragma once
#include <Arduino.h>
#include "src/MAX5160/DigiPot.hpp"
#include "CanDevice.hpp"
#define PRINT_BUTTONS
class Buttons : public CanDevice {
enum Type {
LEFT_SCROLL_UP,
LEFT_SCROLL_CLICK,
LEFT_SCROLL_DOWN,
LEFT_UPPER_BTN,
LEFT_LOWER_BTN,
RIGHT_SCROLL_UP,
RIGHT_SCROLL_DOWN,
RIGHT_UPPER_BTN,
RIGHT_LOWER_BTN
};
DigiPot* channel0;
DigiPot* channel1;
uint32_t timer = 0;
const static uint8_t buttonCount = 9;
bool status[buttonCount] = {};
uint32_t activation[buttonCount] = {};
static uint8_t frames[buttonCount][3];
static uint8_t channels[buttonCount];
static MAX5160::Resistance resistances[buttonCount];
#ifdef PRINT_BUTTONS
static const char* names[buttonCount];
#endif
void activate(uint8_t buttonId);
void deactivate(uint8_t buttonId);
public:
Buttons(DigiPot* channel0, DigiPot* channel1);
void begin();
bool parseFrame(Can::Frame* frame);
void iterate();
#ifdef PRINT_BUTTONS
void printButtons();
#endif
};