optimise mavlink SS packet size (#3029)
[ExpressLRS.git] / src / lib / SCREEN / FiveWayButton / FiveWayButton.h
blobfc84a4cca47303ac5815640795aa2e74f349fe45
1 #pragma once
3 #include "targets.h"
5 typedef enum
7 INPUT_KEY_LEFT_PRESS = 2,
8 INPUT_KEY_UP_PRESS = 3,
9 INPUT_KEY_RIGHT_PRESS = 4,
10 INPUT_KEY_DOWN_PRESS = 5,
11 INPUT_KEY_OK_PRESS = 6,
12 INPUT_KEY_NO_PRESS = 7
13 } Input_Key_Value_t;
15 // Number of values in JOY_ADC_VALUES, if defined
16 // These must be ADC readings for {UP, DOWN, LEFT, RIGHT, ENTER, IDLE}
17 constexpr size_t N_JOY_ADC_VALUES = 6;
19 class FiveWayButton
21 private:
22 int keyInProcess;
23 uint32_t keyDownStart;
24 bool isLongPressed;
25 static uint16_t joyAdcValues[N_JOY_ADC_VALUES];
26 uint16_t fuzzValues[N_JOY_ADC_VALUES];
27 void calcFuzzValues();
29 int readKey();
31 public:
32 FiveWayButton();
33 void init();
34 void update(int *keyValue, bool *keyLongPressed);
36 static constexpr uint32_t KEY_DEBOUNCE_MS = 25;
37 static constexpr uint32_t KEY_LONG_PRESS_MS = 1000;