/
RadioMMI.h
97 lines (62 loc) · 1.17 KB
/
RadioMMI.h
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
/* Radio MMI
*
* by Daniel Hjort, 2014.
*/
#ifndef RadioMMI_h
#define RadioMMI_h
#include <inttypes.h>
#include <Encoder.h>
#include <LCD.h>
typedef enum {
NOT_PRESSED,
PRESSED,
LONG_PRESSED
} button_state_t;
typedef enum {
CHANGE_FREQ,
CHANGE_RIT,
MENU
} mmi_state_t;
class RadioMMI
{
public:
void begin(LCD* lcd, Encoder* encoder, int ditPin, int dahPin);
void readInput();
void setIsInTx(bool inTx);
void setFreq(long freq);
long getFreq();
void setRit(int rit);
int getRit();
bool isPaddleConnected();
bool ditDown();
bool dahDown();
bool keyDown();
bool buttonPressed();
void updateUi();
private:
void printFreq(long freq);
void printRit(int rit);
void onRotateLeft();
void onRotateRight();
void onPressed();
void onLongPressed();
bool mUpdate;
LCD* mLcd;
Encoder* mEncoder;
int mDitPin;
int mDahPin;
long mEncoderPosition;
bool mIsInTx;
bool mIsPaddleConnected;
struct store_t
{
int first;
long freq;
int rit;
int step;
} mStore;
button_state_t mButtonState;
long mButtonDownSince;
mmi_state_t mMMIState;
};
#endif