Merge pull request #1269 from pkendall64/crsf-max-output
[ExpressLRS.git] / src / lib / SCREEN / screen.h
blob58de7e6d201c25a695f74620f82fedd72434de43
2 #pragma once
4 #include "targets.h"
6 #define RATE_MAX_NUMBER 4
7 #define POWER_MAX_NUMBER 8
8 #define RATIO_MAX_NUMBER 8
9 #define POWERSAVING_MAX_NUMBER 2
10 #define SMARTFAN_MAX_NUMBER 3
12 #define VERSION_MAX_LENGTH 6
14 #define IMAGE_RATE 0
15 #define IMAGE_POWER 1
16 #define IMAGE_RATIO 2
17 #define IMAGE_MOTION 3
18 #define IMAGE_FAN 4
19 #define IMAGE_BIND 5
20 #define IMAGE_WIFI 6
23 typedef enum
25 MAIN_MENU_RATE_INDEX = 1,
26 MAIN_MENU_POWER_INDEX,
27 MAIN_MENU_RATIO_INDEX,
28 MAIN_MENU_POWERSAVING_INDEX,
29 MAIN_MENU_SMARTFAN_INDEX,
30 MAIN_MENU_BIND_INDEX,
31 MAIN_MENU_UPDATEFW_INDEX
32 } Screen_MainMenuIndex_t;
34 typedef enum
36 PAGE_MAIN_MENU_INDEX = 0,
37 PAGE_SUB_RATE_INDEX = 1,
38 PAGE_SUB_POWER_INDEX = 2,
39 PAGE_SUB_RATIO_INDEX = 3,
40 PAGE_SUB_POWERSAVING_INDEX = 4,
41 PAGE_SUB_SMARTFAN_INDEX = 5,
43 PAGE_SUB_BIND_INDEX = 6,
44 PAGE_SUB_UPDATEFW_INDEX = 7,
46 PAGE_SUB_BINDING_INDEX = 16
47 } Screen_PageIndex_t;
49 typedef enum
51 USER_ACTION_NONE = 0,
52 USER_ACTION_UP = 1,
53 USER_ACTION_DOWN = 2,
54 USER_ACTION_LEFT = 3,
55 USER_ACTION_RIGHT = 4,
56 USER_ACTION_CONFIRM = 5
57 } Screen_Action_t;
59 typedef enum
61 SCREEN_STATUS_INIT = 0,
62 SCREEN_STATUS_IDLE = 1,
63 SCREEN_STATUS_WORK = 2,
64 SCREEN_STATUS_BINDING = 3
65 } Screen_Status_t;
68 typedef enum
70 USER_POWERSAVING_OFF = 0,
71 USER_POWERSAVING_ON = 1
72 } Screen_User_PowerSaving_t;
74 typedef enum
76 USER_SMARTFAN_AUTO = 0,
77 USER_SMARTFAN_ALAYWS_ON = 1,
78 USER_SMARTFAN_OFF = 2
79 } Screen_User_SMARTFAN_t;
81 typedef enum
84 USER_UPDATE_TYPE_RATE = 0,
85 USER_UPDATE_TYPE_POWER = 1,
86 USER_UPDATE_TYPE_RATIO = 2,
87 USER_UPDATE_TYPE_POWERSAVING = 3,
88 USER_UPDATE_TYPE_SMARTFAN = 4,
89 USER_UPDATE_TYPE_BINDING = 5,
90 USER_UPDATE_TYPE_EXIT_BINDING = 6,
91 USER_UPDATE_TYPE_WIFI = 7,
92 USER_UPDATE_TYPE_EXIT_WIFI = 8
93 } Screen_Update_Type_t;
95 typedef enum
97 SCREEN_BACKLIGHT_ON = 0,
98 SCREEN_BACKLIGHT_OFF = 1
99 } Screen_BackLight_t;
101 class Screen
103 private:
105 void doMainMenuPage(int action);
106 void doPageBack();
107 void doPageForward();
108 void doValueConfirm();
110 protected:
111 // Common Variables
112 int current_page_index;
113 int main_menu_page_index;
114 int current_rate_index;
115 int current_power_index;
116 int current_ratio_index;
117 int current_powersaving_index;
118 int current_smartfan_index;
120 int current_screen_status;
122 uint8_t system_temperature;
124 void nextIndex(int &index, int action, int min, int max);
125 void nextIndex(int &index, int action, int max) { nextIndex(index, action, 0, max); }
126 void doValueSelection(int action);
128 virtual void doRateValueSelect(int action) = 0;
129 virtual void doPowerValueSelect(int action) = 0;
130 virtual void doRatioValueSelect(int action) = 0;
131 virtual void doPowerSavingValueSelect(int action) = 0;
132 virtual void doSmartFanValueSelect(int action) = 0;
134 virtual void updateMainMenuPage() = 0;
135 virtual void updateSubFunctionPage() = 0;
136 virtual void updateSubWIFIModePage() = 0;
137 virtual void updateSubBindConfirmPage() = 0;
138 virtual void updateSubBindingPage() = 0;
141 static const char *rate_string[RATE_MAX_NUMBER];
142 static const char *power_string[POWER_MAX_NUMBER];
143 static const char *ratio_string[RATIO_MAX_NUMBER];
144 static const char *powersaving_string[POWERSAVING_MAX_NUMBER];
145 static const char *smartfan_string[SMARTFAN_MAX_NUMBER];
146 static const char *main_menu_line_1[];
147 static const char *main_menu_line_2[];
149 public:
150 static void nullCallback(int updateType);
151 static void (*updatecallback)(int updateType);
153 virtual void init(bool reboot) = 0;
154 virtual void idleScreen() = 0;
155 virtual void doParamUpdate(uint8_t rate_index, uint8_t power_index, uint8_t ratio_index, uint8_t motion_index, uint8_t fan_index) = 0;
156 virtual void doTemperatureUpdate(uint8_t temperature) = 0;
157 virtual void doScreenBackLight(int state) = 0;
159 void activeScreen();
160 void doUserAction(int action);
161 void setInWifiMode();
163 int getUserRateIndex() { return current_rate_index; }
164 int getUserPowerIndex() { return current_power_index; }
165 int getUserRatioIndex() { return current_ratio_index; }
166 int getScreenStatus() { return current_screen_status; }
167 int getUserPowerSavingIndex() { return current_powersaving_index; }
168 int getUserSmartFanIndex() { return current_smartfan_index; }