Tue, 05 Nov 2019 11:31:59 +0100
Moved the user interface into a separate task. Added a real seconds timer to this task.
21
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1 | /** |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
2 | * @file task_user.c |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
3 | * @brief co2meter project. |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
4 | */ |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
5 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
6 | #include "config.h" |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
7 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
8 | static const char *TAG = "task_user"; |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
9 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
10 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
11 | EventGroupHandle_t xEventGroupUser; ///< Events User task |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
12 | esp_timer_handle_t timerHandle; ///< Seconds timer |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
13 | uint32_t SecsCount = 0; ///< Seconds counter |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
14 | uint32_t UserTimer = 0; ///< User inactive timeout |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
15 | int Main_Loop2 = -1; ///< Effective menu |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
16 | int New_Loop2 = ML2_INIT; ///< New menu |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
17 | int SubMenu = 0; ///< Submenu number |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
18 | u8g2_t u8g2; ///< A structure which will contain all the data for one display |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
19 | rotary_encoder_info_t rinfo = { 0 }; ///< Rotary encoder record |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
20 | rotary_encoder_event_t event = { 0 }; |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
21 | QueueHandle_t event_queue; |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
22 | static int PushDuration = 0; ///< Duration of the pushed button |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
23 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
24 | extern const esp_app_desc_t *app_desc; |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
25 | extern unit_t units[3]; ///< Pressure test units |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
26 | extern SemaphoreHandle_t xSemaphoreUnits; ///< Units lock semaphore |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
27 | extern DS18B20_State *ds18b20_state; ///< DS18B20 state |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
28 | extern SemaphoreHandle_t xSemaphoreDS18B20; ///< DS18B20 lock semaphore |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
29 | extern ADC_State *adc_state; ///< ADC state |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
30 | extern SemaphoreHandle_t xSemaphoreADC; ///< ADC lock semaphore |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
31 | extern WIFI_State *wifi_state; ///< WiFi state |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
32 | extern int count_pub; ///< Published MQTT messages in transit |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
33 | static xQueueHandle gpio_evt_queue = NULL; ///< Rotary pushbutton queue |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
34 | extern int Main_Loop1; ///< Main measure loop |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
35 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
36 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
37 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
38 | const int TASK_USER_COLD = BIT0; ///< System cold start |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
39 | const int TASK_USER_WAKEUP = BIT1; ///< System wakeup from deepsleep |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
40 | const int TASK_USER_BUSY = BIT2; ///< User interface is busy doing something. |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
41 | const int TASK_USER_REFRESH = BIT3; ///< Refresh measurement results |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
42 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
43 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
44 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
45 | /** |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
46 | * @brief Seconds timer callback. |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
47 | */ |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
48 | void TimerCallback(void *arg); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
49 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
50 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
51 | /***************************************************************************/ |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
52 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
53 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
54 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
55 | void TimerCallback(void *arg) |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
56 | { |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
57 | SecsCount++; |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
58 | if ((SecsCount % 60) == 0) { |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
59 | if (Main_Loop1 == ML1_DONE) |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
60 | Main_Loop1 = ML1_INIT; |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
61 | } |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
62 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
63 | if (UserTimer == 1) { |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
64 | ESP_LOGI(TAG, "User inactivity timeout"); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
65 | xEventGroupClearBits(xEventGroupUser, TASK_USER_BUSY); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
66 | u8g2_SetPowerSave(&u8g2, 1); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
67 | } |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
68 | if (UserTimer) { |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
69 | UserTimer--; |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
70 | } |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
71 | } |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
72 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
73 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
74 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
75 | void user_cold() |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
76 | { |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
77 | xEventGroupSetBits(xEventGroupUser, TASK_USER_COLD); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
78 | } |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
79 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
80 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
81 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
82 | void user_wakeup() |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
83 | { |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
84 | xEventGroupSetBits(xEventGroupUser, TASK_USER_WAKEUP); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
85 | } |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
86 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
87 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
88 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
89 | void user_refresh() |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
90 | { |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
91 | xEventGroupSetBits(xEventGroupUser, TASK_USER_REFRESH); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
92 | } |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
93 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
94 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
95 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
96 | bool user_busy(void) |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
97 | { |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
98 | if (xEventGroupGetBits(xEventGroupUser) & TASK_USER_BUSY) |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
99 | return true; |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
100 | return false; |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
101 | } |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
102 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
103 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
104 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
105 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
106 | /** |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
107 | * @brief Get a keyboard character from the rotary encoder. |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
108 | * @param curkey The referenced value if the key being edited. NOTE, start at 0 for a new char?? |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
109 | * @param type The edittype, all values, integer or float. |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
110 | * @param x The x position on the screen. |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
111 | * @param y The y position on the screen. |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
112 | * @return 1 if short keypress, meaning enter key. 2 if long press, enter key and editing is ready. |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
113 | */ |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
114 | int getkey(int *curkey, int type, int x, int y) |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
115 | { |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
116 | int key = *curkey; |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
117 | int rc = 0; |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
118 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
119 | u8g2_DrawHLine(&u8g2, x, y+3, 12); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
120 | u8g2_SendBuffer(&u8g2); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
121 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
122 | for (;;) { |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
123 | if (xQueueReceive(event_queue, &event, 100 / portTICK_PERIOD_MS) == pdTRUE) { |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
124 | UserTimer = INACTIVITY; |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
125 | if (event.state.position != 0) { |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
126 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
127 | u8g2_SetDrawColor(&u8g2, 0); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
128 | u8g2_DrawGlyph(&u8g2, x, y, key); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
129 | u8g2_SetDrawColor(&u8g2, 1); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
130 | u8g2_SendBuffer(&u8g2); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
131 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
132 | if (event.state.position > 0) { |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
133 | if (key == 126) |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
134 | key = 171; |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
135 | else if (key < 126) |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
136 | key++; |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
137 | } else if (event.state.position < 0) { |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
138 | if (key == 171) |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
139 | key = 126; |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
140 | else if (key > 32) |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
141 | key--; |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
142 | } |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
143 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
144 | ESP_ERROR_CHECK(rotary_encoder_reset(&rinfo)); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
145 | u8g2_DrawGlyph(&u8g2, x, y, key); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
146 | u8g2_SendBuffer(&u8g2); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
147 | } |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
148 | } else { |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
149 | if (PushDuration) { |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
150 | if (PushDuration > 500) |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
151 | rc = 2; |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
152 | else |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
153 | rc = 1; |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
154 | PushDuration = 0; |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
155 | break; |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
156 | } |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
157 | } |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
158 | } |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
159 | u8g2_SetDrawColor(&u8g2, 0); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
160 | u8g2_DrawHLine(&u8g2, x, y+3, 12); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
161 | u8g2_SetDrawColor(&u8g2, 1); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
162 | u8g2_SendBuffer(&u8g2); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
163 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
164 | *curkey = key; |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
165 | return rc; |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
166 | } |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
167 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
168 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
169 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
170 | /** |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
171 | * @brief Editor using the rotary switch. |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
172 | * @param label The label of the edit field. |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
173 | * @param txt The string to edit. |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
174 | * @param errmsg The error message if needed. |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
175 | * @param len The maximum length for the string. |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
176 | * @param type The edit type. |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
177 | */ |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
178 | void rotary_editer(char *label, char *txt, char *errmsg, int len, int type) |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
179 | { |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
180 | char buf[65]; |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
181 | int key, x, y, rc; |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
182 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
183 | u8g2_ClearBuffer(&u8g2); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
184 | u8g2_DrawHLine(&u8g2, 0, 14, 128); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
185 | u8g2_DrawHLine(&u8g2, 0, 49, 128); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
186 | u8g2_SetFont(&u8g2, u8g2_font_t0_15_tf); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
187 | sprintf(buf, "Edit %s", label); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
188 | u8g2_DrawStr(&u8g2,0,12,buf); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
189 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
190 | if (strlen(errmsg)) { |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
191 | u8g2_SetFont(&u8g2, u8g2_font_t0_12b_tf); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
192 | u8g2_DrawStr(&u8g2, 0, 61, errmsg); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
193 | } |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
194 | u8g2_SetFont(&u8g2, u8g2_font_t0_12_tf); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
195 | y = 36; |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
196 | u8g2_DrawStr(&u8g2, 0, y, txt); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
197 | u8g2_SendBuffer(&u8g2); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
198 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
199 | for (;;) { |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
200 | x = u8g2_GetUTF8Width(&u8g2, txt); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
201 | key = 'a'; |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
202 | rc = getkey(&key, type, x, y); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
203 | if (rc == 1) { |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
204 | if (key >= 32 && key <= 126 && strlen(txt) < len) { |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
205 | txt[strlen(txt) + 1] = '\0'; |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
206 | txt[strlen(txt)] = key; |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
207 | } else if (key == 171 && strlen(txt)) { |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
208 | // delete key |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
209 | txt[strlen(txt) - 1] = '\0'; |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
210 | } |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
211 | printf("strlen %d x %d key %d\n", strlen(txt), x, key); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
212 | } else if (rc == 2) { |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
213 | break; |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
214 | } |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
215 | } |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
216 | } |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
217 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
218 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
219 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
220 | /** |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
221 | * @brief Write a menu line on the display. |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
222 | * @param bright Display the line with a bold or normal font. |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
223 | * @param x The horizontal start position of the line. |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
224 | * @param y The vertical bottom of the line position. |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
225 | * @param format The formatted data to display. |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
226 | */ |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
227 | void menu_line(int bright, int x, int y, const char *format, ...) |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
228 | { |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
229 | char buf[65]; |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
230 | va_list va_ptr; |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
231 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
232 | if (bright) |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
233 | u8g2_SetFont(&u8g2, u8g2_font_t0_12b_tr); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
234 | else |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
235 | u8g2_SetFont(&u8g2, u8g2_font_t0_12_tr); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
236 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
237 | va_start(va_ptr, format); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
238 | vsnprintf(buf, 65, format, va_ptr); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
239 | va_end(va_ptr); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
240 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
241 | u8g2_DrawStr(&u8g2, x, y, buf); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
242 | } |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
243 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
244 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
245 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
246 | /** |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
247 | * @brief Clear the display and prepare the top of the display. |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
248 | * @format The formatted data to display at the top. |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
249 | */ |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
250 | void screen_top(const char *format, ...) |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
251 | { |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
252 | char buf[65]; |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
253 | va_list va_ptr; |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
254 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
255 | va_start(va_ptr, format); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
256 | vsnprintf(buf, 65, format, va_ptr); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
257 | va_end(va_ptr); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
258 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
259 | u8g2_ClearBuffer(&u8g2); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
260 | u8g2_DrawHLine(&u8g2, 0, 14, 128); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
261 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
262 | u8g2_SetFont(&u8g2, u8g2_font_t0_15_tr); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
263 | u8g2_uint_t w = u8g2_GetStrWidth(&u8g2, buf); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
264 | u8g2_DrawStr(&u8g2, (128 - w) / 2,12, buf); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
265 | } |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
266 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
267 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
268 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
269 | /** |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
270 | * @brief The splash screen shown during cold boot or user wakeup. |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
271 | */ |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
272 | void screen_splash() |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
273 | { |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
274 | screen_top("CO2 meter %s", app_desc->version); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
275 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
276 | u8g2_SetFont(&u8g2, u8g2_font_t0_22b_tf); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
277 | u8g2_uint_t w = u8g2_GetUTF8Width(&u8g2, "START"); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
278 | u8g2_DrawUTF8(&u8g2, (128 - w) / 2,50, "START"); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
279 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
280 | u8g2_SendBuffer(&u8g2); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
281 | u8g2_SetPowerSave(&u8g2, 0); // wake up display |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
282 | } |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
283 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
284 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
285 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
286 | /** |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
287 | * @brief The main overview screen. |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
288 | */ |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
289 | void screen_main() |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
290 | { |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
291 | char buf[65]; |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
292 | int i; |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
293 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
294 | screen_top("CO2 meter %s", app_desc->version); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
295 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
296 | if (xSemaphoreTake(xSemaphoreUnits, 25) == pdTRUE) { |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
297 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
298 | u8g2_SetFont(&u8g2, u8g2_font_t0_22b_tf); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
299 | sprintf(buf, "%.1f °C", units[0].temperature / 1000.0); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
300 | u8g2_uint_t w = u8g2_GetUTF8Width(&u8g2, buf); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
301 | u8g2_DrawUTF8(&u8g2, (128 - w) / 2,40, buf); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
302 | u8g2_SetFont(&u8g2, u8g2_font_t0_18b_tf); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
303 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
304 | for (i = 0; i < 3; i++) { |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
305 | sprintf(buf, "%.1f", units[i].pressure / 1000.0); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
306 | w = u8g2_GetUTF8Width(&u8g2, buf); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
307 | u8g2_DrawUTF8(&u8g2, ((42 - w) / 2) + i * 43,63, buf); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
308 | } |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
309 | xSemaphoreGive(xSemaphoreUnits); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
310 | } |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
311 | u8g2_SendBuffer(&u8g2); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
312 | u8g2_SetPowerSave(&u8g2, 0); // wake up display |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
313 | } |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
314 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
315 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
316 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
317 | /** |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
318 | * @brief The unit display screen. |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
319 | * @param no The unit index number. |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
320 | */ |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
321 | void screen_unit(int no) |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
322 | { |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
323 | char buf[65]; |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
324 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
325 | if (xSemaphoreTake(xSemaphoreUnits, 25) == pdTRUE) { |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
326 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
327 | screen_top("Unit %d %s", no + 1, units[no].mode ? "On":"Off"); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
328 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
329 | u8g2_SetFont(&u8g2, u8g2_font_t0_22b_tf); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
330 | sprintf(buf, "%.1f °C", units[no].temperature / 1000.0); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
331 | u8g2_uint_t w = u8g2_GetUTF8Width(&u8g2, buf); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
332 | u8g2_DrawUTF8(&u8g2, (128 - w) / 2,40, buf); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
333 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
334 | sprintf(buf, "%.2f bar", units[no].pressure / 1000.0); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
335 | w = u8g2_GetUTF8Width(&u8g2, buf); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
336 | u8g2_DrawUTF8(&u8g2, (128 - w) / 2,63, buf); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
337 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
338 | xSemaphoreGive(xSemaphoreUnits); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
339 | } |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
340 | u8g2_SendBuffer(&u8g2); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
341 | u8g2_SetPowerSave(&u8g2, 0); // wake up display |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
342 | } |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
343 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
344 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
345 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
346 | /** |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
347 | * @brief The unit zero setup screen. |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
348 | * @param no The unit index number. |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
349 | * @param sub The submenu index number. |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
350 | */ |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
351 | void screen_unit_zero(int no, int sub) |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
352 | { |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
353 | screen_top("Unit %d zero mV", no + 1); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
354 | menu_line( 0, 2, 25, "Current %d", units[no].pressure_zero); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
355 | menu_line(sub == 0, 2, 37, "New value %d", units[no].pressure_voltage / (adc_state->Batt_voltage / 1000)); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
356 | menu_line(sub == 1, 2, 49, "Return"); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
357 | printf("current %d p_voltage %d batt %d\n", units[no].pressure_zero, units[no].pressure_voltage, adc_state->Batt_voltage); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
358 | u8g2_SendBuffer(&u8g2); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
359 | u8g2_SetPowerSave(&u8g2, 0); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
360 | } |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
361 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
362 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
363 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
364 | /** |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
365 | * @brief The unit setup screen. |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
366 | * @param no The unit index number. |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
367 | * @param sub The submenu index number. |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
368 | */ |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
369 | void screen_unit_setup(int no, int sub) |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
370 | { |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
371 | screen_top("Unit %d setup", no + 1); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
372 | menu_line(sub == 0, 2, 25, "Mode %s", units[no].mode ? "ON":"OFF"); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
373 | menu_line(sub == 1, 2, 37, "Zero mV %d", units[no].pressure_zero); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
374 | menu_line(sub == 2, 2, 49, "DS18B20 %s", units[no].temperature_rom_code); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
375 | menu_line(sub == 3, 2, 61, "Return"); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
376 | u8g2_SendBuffer(&u8g2); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
377 | u8g2_SetPowerSave(&u8g2, 0); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
378 | } |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
379 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
380 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
381 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
382 | void screen_wifi() |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
383 | { |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
384 | char buf[65]; |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
385 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
386 | screen_top("WiFi Status"); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
387 | snprintf(buf, 65, "SSID %s", wifi_state->STA_ssid); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
388 | u8g2_DrawStr(&u8g2, 1, 28, buf); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
389 | snprintf(buf, 65, "Online %s", wifi_state->STA_online ? "Yes":"No"); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
390 | u8g2_DrawStr(&u8g2, 1, 43, buf); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
391 | snprintf(buf, 65, "RSSI %d", wifi_state->STA_rssi); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
392 | u8g2_DrawStr(&u8g2, 1, 59, buf); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
393 | u8g2_SendBuffer(&u8g2); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
394 | u8g2_SetPowerSave(&u8g2, 0); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
395 | } |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
396 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
397 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
398 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
399 | void screen_wifi_setup(int sub) |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
400 | { |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
401 | screen_top("WiFi Setup"); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
402 | menu_line(sub == 0, 2, 25, "Connect"); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
403 | menu_line(sub == 1, 2, 37, "New"); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
404 | menu_line(sub == 2, 2, 49, "Delete"); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
405 | menu_line(sub == 3, 2, 61, "Return"); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
406 | u8g2_SendBuffer(&u8g2); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
407 | u8g2_SetPowerSave(&u8g2, 0); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
408 | } |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
409 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
410 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
411 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
412 | void screen_network() |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
413 | { |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
414 | screen_top("Network Status"); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
415 | menu_line(0, 1, 25, "IP %s", wifi_state->STA_ip); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
416 | menu_line(0, 1, 37, "Mask %s", wifi_state->STA_nm); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
417 | menu_line(0, 1, 49, "GW %s", wifi_state->STA_gw); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
418 | menu_line(0, 1, 61, "Name %s", config.hostname); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
419 | u8g2_SendBuffer(&u8g2); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
420 | u8g2_SetPowerSave(&u8g2, 0); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
421 | } |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
422 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
423 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
424 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
425 | void screen_mqtt() |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
426 | { |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
427 | screen_top("MQTT Status"); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
428 | menu_line(0, 1, 25, "serv %s", config.mqtt_server); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
429 | menu_line(0, 1, 37, "port %d", config.mqtt_port); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
430 | menu_line(0, 1, 49, "user %s", config.mqtt_user); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
431 | u8g2_SendBuffer(&u8g2); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
432 | u8g2_SetPowerSave(&u8g2, 0); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
433 | } |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
434 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
435 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
436 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
437 | void screen_update() |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
438 | { |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
439 | screen_top("Update firmware"); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
440 | menu_line(0, 1, 43, "Push to update"); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
441 | u8g2_SendBuffer(&u8g2); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
442 | u8g2_SetPowerSave(&u8g2, 0); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
443 | } |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
444 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
445 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
446 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
447 | /** |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
448 | * @brief Fatal messages on the screen. |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
449 | * @param e1 The first line. |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
450 | * @param e2 The second line. |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
451 | */ |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
452 | void screen_fatal(char *e1, char *e2) |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
453 | { |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
454 | u8g2_SetFont(&u8g2, u8g2_font_t0_15_tr); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
455 | u8g2_DrawStr(&u8g2,2,12,e1); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
456 | u8g2_DrawStr(&u8g2,2,24,e2); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
457 | u8g2_SendBuffer(&u8g2); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
458 | u8g2_SetPowerSave(&u8g2, 0); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
459 | } |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
460 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
461 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
462 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
463 | /** |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
464 | * @brief Interrupt service routine for the rotary pushbutton. |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
465 | */ |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
466 | static void IRAM_ATTR gpio_isr_handler(void* arg) |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
467 | { |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
468 | uint32_t gpio_num = (uint32_t) arg; |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
469 | xQueueSendFromISR(gpio_evt_queue, &gpio_num, NULL); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
470 | } |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
471 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
472 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
473 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
474 | /** |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
475 | * @brief GPIO queue task. See if there is a rotary pushbutton event on the queue. |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
476 | */ |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
477 | static void gpio_task(void* arg) |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
478 | { |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
479 | uint32_t io_num; |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
480 | static int64_t pushed = 0; |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
481 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
482 | for(;;) { |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
483 | if (xQueueReceive(gpio_evt_queue, &io_num, portMAX_DELAY)) { |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
484 | if (io_num == ROT_ENC_SW_GPIO) { |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
485 | if (gpio_get_level(io_num) == 0) { |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
486 | pushed = esp_timer_get_time(); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
487 | PushDuration = 0; |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
488 | } else if (gpio_get_level(io_num) == 1) { |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
489 | PushDuration = (esp_timer_get_time() - pushed) / 1000; |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
490 | ESP_LOGI(TAG, "GPIO rotary button intr, val: %d time: %d", gpio_get_level(io_num), PushDuration); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
491 | } |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
492 | } else { |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
493 | ESP_LOGE(TAG, "GPIO[%d] unknown intr, val: %d", io_num, gpio_get_level(io_num)); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
494 | } |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
495 | UserTimer = INACTIVITY; |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
496 | } |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
497 | } |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
498 | } |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
499 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
500 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
501 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
502 | /** |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
503 | * @brief Select new menu number on a postitive or negative rotary position. |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
504 | * @param pos The new position, positive, negative or zero. |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
505 | * @param next_menu The selected menu if rotated clockwise. |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
506 | * @param prev_menu The selected menu if rotated counter-clockwise. |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
507 | */ |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
508 | static void rotate_to_menu(rotary_encoder_position_t pos, int next_menu, int prev_menu) |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
509 | { |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
510 | if (pos > 0) |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
511 | New_Loop2 = next_menu; |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
512 | else if (pos < 0) |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
513 | New_Loop2 = prev_menu; |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
514 | ESP_ERROR_CHECK(rotary_encoder_reset(&rinfo)); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
515 | } |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
516 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
517 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
518 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
519 | /** |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
520 | * @brief Rotate subscreens numbers. |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
521 | * @param pos The new position, positive, negative or zero. |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
522 | * @param min The lowest number. If already at the lowest, select the highest. |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
523 | * @param max The highest number. If already at the highest, select the lowest. |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
524 | * @param cursub The subscreen number by reference. This is updated with the new number. |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
525 | * @return Returns true if a new number is selected, false if nothing changed. |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
526 | */ |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
527 | bool rotate_to_sub(rotary_encoder_position_t pos, int min, int max, int *cursub) |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
528 | { |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
529 | int sub = *cursub; |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
530 | bool rc = false; |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
531 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
532 | if (pos > 0) { |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
533 | if (sub < max) |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
534 | sub++; |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
535 | else |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
536 | sub = min; |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
537 | ESP_ERROR_CHECK(rotary_encoder_reset(&rinfo)); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
538 | rc = true; |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
539 | } else if (pos < 0) { |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
540 | if (sub > min) |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
541 | sub--; |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
542 | else |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
543 | sub = max; |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
544 | ESP_ERROR_CHECK(rotary_encoder_reset(&rinfo)); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
545 | rc = true; |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
546 | } |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
547 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
548 | *cursub = sub; |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
549 | return rc; |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
550 | } |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
551 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
552 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
553 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
554 | void menu_change(void) |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
555 | { |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
556 | char txt[65]; |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
557 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
558 | if (New_Loop2 != Main_Loop2) { |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
559 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
560 | Main_Loop2 = New_Loop2; |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
561 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
562 | switch (Main_Loop2) { |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
563 | case ML2_INIT: |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
564 | ESP_LOGI(TAG, "Loop user: Init"); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
565 | New_Loop2 = ML2_USER; |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
566 | break; |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
567 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
568 | case ML2_USER: |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
569 | ESP_LOGI(TAG, "Loop user: User mainmenu"); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
570 | screen_main(); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
571 | break; |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
572 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
573 | case ML2_UNIT1: |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
574 | case ML2_UNIT2: |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
575 | case ML2_UNIT3: |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
576 | ESP_LOGI(TAG, "Loop user: Unit %d", Main_Loop2 - ML2_UNIT1); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
577 | screen_unit(Main_Loop2 - ML2_UNIT1); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
578 | break; |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
579 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
580 | case ML2_WIFI: |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
581 | ESP_LOGI(TAG, "Loop user: WiFi"); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
582 | screen_wifi(); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
583 | break; |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
584 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
585 | case ML2_NETWORK: |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
586 | ESP_LOGI(TAG, "Loop user: Network"); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
587 | screen_network(); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
588 | break; |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
589 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
590 | case ML2_MQTT: |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
591 | ESP_LOGI(TAG, "Loop user: MQTT"); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
592 | screen_mqtt(); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
593 | break; |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
594 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
595 | case ML2_SETUP_MQTT: |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
596 | ESP_LOGI(TAG, "Loop user: MQTT setup"); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
597 | sprintf(txt, "EDtXt"); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
598 | rotary_editer("MQTT demo", txt, "", 16, EDIT_TYPE_TEXT); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
599 | New_Loop2 = ML2_MQTT; |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
600 | break; |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
601 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
602 | case ML2_UPDATE: |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
603 | ESP_LOGI(TAG, "Loop user: Update"); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
604 | screen_update(); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
605 | break; |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
606 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
607 | case ML2_SETUP_UNIT1: |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
608 | case ML2_SETUP_UNIT2: |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
609 | case ML2_SETUP_UNIT3: |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
610 | ESP_LOGI(TAG, "Loop user: Setup Unit %d", Main_Loop2 - ML2_SETUP_UNIT1); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
611 | SubMenu = 0; |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
612 | screen_unit_setup(Main_Loop2 - ML2_SETUP_UNIT1, SubMenu); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
613 | break; |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
614 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
615 | case ML2_ZERO_UNIT1: |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
616 | case ML2_ZERO_UNIT2: |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
617 | case ML2_ZERO_UNIT3: |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
618 | ESP_LOGI(TAG, "Loop user: Zero Unit %d", Main_Loop2 - ML2_ZERO_UNIT1); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
619 | SubMenu = 0; |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
620 | screen_unit_zero(Main_Loop2 - ML2_ZERO_UNIT1, SubMenu); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
621 | break; |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
622 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
623 | case ML2_INACTIVE: |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
624 | ESP_LOGI(TAG, "Loop user: Inactive"); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
625 | u8g2_SetPowerSave(&u8g2, 1); // powersave display |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
626 | New_Loop2 = ML2_DONE; |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
627 | break; |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
628 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
629 | default: |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
630 | break; |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
631 | } |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
632 | } |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
633 | } |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
634 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
635 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
636 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
637 | void menu_rotary(void) |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
638 | { |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
639 | switch (Main_Loop2) { |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
640 | case ML2_USER: rotate_to_menu(event.state.position, ML2_UNIT1, ML2_USER); break; |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
641 | case ML2_UNIT1: rotate_to_menu(event.state.position, ML2_UNIT2, ML2_USER); break; |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
642 | case ML2_UNIT2: rotate_to_menu(event.state.position, ML2_UNIT3, ML2_UNIT1); break; |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
643 | case ML2_UNIT3: rotate_to_menu(event.state.position, ML2_WIFI, ML2_UNIT2); break; |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
644 | case ML2_WIFI: rotate_to_menu(event.state.position, ML2_NETWORK, ML2_UNIT3); break; |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
645 | case ML2_NETWORK: rotate_to_menu(event.state.position, ML2_MQTT, ML2_WIFI); break; |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
646 | case ML2_MQTT: rotate_to_menu(event.state.position, ML2_UPDATE, ML2_NETWORK); break; |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
647 | case ML2_UPDATE: rotate_to_menu(event.state.position, ML2_UPDATE, ML2_MQTT); break; |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
648 | case ML2_SETUP_UNIT1: |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
649 | case ML2_SETUP_UNIT2: |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
650 | case ML2_SETUP_UNIT3: if (rotate_to_sub(event.state.position, 0, 3, &SubMenu)) |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
651 | screen_unit_setup(Main_Loop2 - ML2_SETUP_UNIT1, SubMenu); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
652 | break; |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
653 | case ML2_ZERO_UNIT1: |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
654 | case ML2_ZERO_UNIT2: |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
655 | case ML2_ZERO_UNIT3: if (rotate_to_sub(event.state.position, 0, 1, &SubMenu)) |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
656 | screen_unit_zero(Main_Loop2 - ML2_ZERO_UNIT1, SubMenu); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
657 | break; |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
658 | default: |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
659 | ESP_LOGI(TAG, "Event: position %d, direction %s", event.state.position, |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
660 | event.state.direction ? (event.state.direction == ROTARY_ENCODER_DIRECTION_CLOCKWISE ? "CW":"CCW"):"NOT_SET"); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
661 | } |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
662 | } |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
663 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
664 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
665 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
666 | void menu_loop(void) |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
667 | { |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
668 | int idx = 0; |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
669 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
670 | switch (Main_Loop2) { |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
671 | case ML2_UNIT1: |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
672 | case ML2_UNIT2: |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
673 | case ML2_UNIT3: |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
674 | New_Loop2 = ML2_SETUP_UNIT1 + (Main_Loop2 - ML2_UNIT1); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
675 | break; |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
676 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
677 | case ML2_SETUP_UNIT1: |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
678 | case ML2_SETUP_UNIT2: |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
679 | case ML2_SETUP_UNIT3: |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
680 | idx = Main_Loop2 - ML2_SETUP_UNIT1; |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
681 | if (SubMenu == 0) { |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
682 | if (xSemaphoreTake(xSemaphoreUnits, 25) == pdTRUE) { |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
683 | if (units[idx].mode) |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
684 | units[idx].mode = 0; |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
685 | else |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
686 | units[idx].mode = 1; |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
687 | write_units(); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
688 | xSemaphoreGive(xSemaphoreUnits); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
689 | } |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
690 | screen_unit_setup(idx, SubMenu); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
691 | if (Main_Loop1 == ML1_DONE) |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
692 | Main_Loop1 = ML1_INIT; |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
693 | } |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
694 | if (SubMenu == 1) |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
695 | New_Loop2 = ML2_ZERO_UNIT1 + idx; |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
696 | if (SubMenu == 3) |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
697 | New_Loop2 = ML2_UNIT1 + idx; |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
698 | printf("unit setup sub %d new %d idx %d\n", SubMenu, New_Loop2, idx); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
699 | break; |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
700 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
701 | case ML2_ZERO_UNIT1: |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
702 | case ML2_ZERO_UNIT2: |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
703 | case ML2_ZERO_UNIT3: |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
704 | idx = Main_Loop2 - ML2_ZERO_UNIT1; |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
705 | if (SubMenu == 0) { |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
706 | if (xSemaphoreTake(xSemaphoreUnits, 25) == pdTRUE && |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
707 | xSemaphoreTake(xSemaphoreADC, 10) == pdTRUE && |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
708 | adc_state->Pressure[idx].voltage > 165 && |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
709 | adc_state->Pressure[idx].voltage < 660) { |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
710 | units[idx].pressure_zero = adc_state->Pressure[idx].voltage / (adc_state->Batt_voltage / 1000); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
711 | write_units(); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
712 | xSemaphoreGive(xSemaphoreADC); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
713 | xSemaphoreGive(xSemaphoreUnits); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
714 | screen_unit_zero(idx, SubMenu); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
715 | if (Main_Loop1 == ML1_DONE) |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
716 | Main_Loop1 = ML1_INIT; |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
717 | } |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
718 | } |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
719 | if (SubMenu == 1) { |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
720 | New_Loop2 = ML2_SETUP_UNIT1 + idx; |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
721 | SubMenu = 1; |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
722 | } |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
723 | printf("unit zero sub %d new %d idx %d\n", SubMenu, New_Loop2, idx); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
724 | break; |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
725 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
726 | case ML2_MQTT: |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
727 | New_Loop2 = ML2_SETUP_MQTT; |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
728 | break; |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
729 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
730 | default: |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
731 | break; |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
732 | } |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
733 | } |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
734 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
735 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
736 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
737 | void task_user(void *pvParameter) |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
738 | { |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
739 | esp_err_t ret; |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
740 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
741 | ESP_LOGI(TAG, "Starting User task"); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
742 | Main_Loop2 = -1; |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
743 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
744 | /* |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
745 | * Setup the OLED display. |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
746 | * See: https://github.com/nkolban/esp32-snippets/blob/master/hardware/displays/U8G2/ |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
747 | */ |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
748 | u8g2_esp32_hal_t u8g2_esp32_hal = U8G2_ESP32_HAL_DEFAULT; |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
749 | u8g2_esp32_hal.sda = PIN_SDA; |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
750 | u8g2_esp32_hal.scl = PIN_SCL; |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
751 | u8g2_esp32_hal_init(u8g2_esp32_hal); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
752 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
753 | u8g2_Setup_sh1106_i2c_128x64_noname_f(&u8g2, U8G2_R0, u8g2_esp32_i2c_byte_cb, u8g2_esp32_gpio_and_delay_cb); // init u8g2 structure |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
754 | u8x8_SetI2CAddress(&u8g2.u8x8, 0x78); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
755 | u8g2_InitDisplay(&u8g2); // send init sequence to the display, display is in sleep mode after this, |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
756 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
757 | /* |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
758 | * Setup the Rotary Encoder. |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
759 | * esp32-rotary-encoder requires that the GPIO ISR service is |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
760 | * installed before calling rotary_encoder_register() |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
761 | */ |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
762 | ESP_ERROR_CHECK(gpio_install_isr_service(0)); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
763 | ESP_ERROR_CHECK(rotary_encoder_init(&rinfo, ROT_ENC_A_GPIO, ROT_ENC_B_GPIO)); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
764 | ESP_ERROR_CHECK(rotary_encoder_enable_half_steps(&rinfo, false)); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
765 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
766 | gpio_config_t io_conf; |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
767 | io_conf.intr_type = GPIO_PIN_INTR_ANYEDGE; |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
768 | io_conf.pin_bit_mask = (1ULL << ROT_ENC_SW_GPIO); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
769 | io_conf.mode = GPIO_MODE_INPUT; |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
770 | gpio_config(&io_conf); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
771 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
772 | gpio_evt_queue = xQueueCreate(10, sizeof(uint32_t)); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
773 | xTaskCreate(gpio_task, "gpio_task", 2048, NULL, 10, NULL); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
774 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
775 | gpio_isr_handler_add(ROT_ENC_SW_GPIO, gpio_isr_handler, (void*) ROT_ENC_SW_GPIO); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
776 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
777 | // Create a queue for events from the rotary encoder driver. |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
778 | // Tasks can read from this queue to receive up to date position information. |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
779 | event_queue = rotary_encoder_create_queue(); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
780 | ESP_ERROR_CHECK(rotary_encoder_set_queue(&rinfo, event_queue)); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
781 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
782 | esp_timer_create_args_t timerSecond = { |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
783 | .callback = &TimerCallback, |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
784 | .name = "SecondsTimer" |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
785 | }; |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
786 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
787 | /* |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
788 | * Create a one second periodic timer. |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
789 | */ |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
790 | ESP_ERROR_CHECK(esp_timer_create(&timerSecond, &timerHandle)); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
791 | ret = esp_timer_start_periodic(timerHandle, 1000000); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
792 | assert(ret == ESP_OK); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
793 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
794 | EventBits_t uxBits; |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
795 | ESP_LOGI(TAG, "User task loop enter"); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
796 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
797 | /* |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
798 | * Task loop forever. |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
799 | */ |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
800 | while (1) { |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
801 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
802 | uxBits = xEventGroupWaitBits(xEventGroupUser, TASK_USER_COLD | TASK_USER_WAKEUP, pdFALSE, pdFALSE, portMAX_DELAY ); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
803 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
804 | if (uxBits & TASK_USER_COLD) { |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
805 | ESP_LOGI(TAG, "User task cold start"); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
806 | screen_splash(); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
807 | xEventGroupClearBits(xEventGroupUser, TASK_USER_COLD); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
808 | UserTimer = 10; |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
809 | } |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
810 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
811 | if (uxBits & TASK_USER_WAKEUP) { |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
812 | ESP_LOGI(TAG, "User task wakeup"); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
813 | xEventGroupSetBits(xEventGroupUser, TASK_USER_BUSY); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
814 | xEventGroupClearBits(xEventGroupUser, TASK_USER_REFRESH); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
815 | screen_main(); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
816 | UserTimer = INACTIVITY; |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
817 | New_Loop2 = ML2_INIT; |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
818 | Main_Loop2 = -1; |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
819 | SubMenu = 0; |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
820 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
821 | while (UserTimer) { |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
822 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
823 | menu_change(); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
824 | if (xQueueReceive(event_queue, &event, 250 / portTICK_PERIOD_MS) == pdTRUE) { |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
825 | UserTimer = INACTIVITY; |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
826 | menu_rotary(); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
827 | } |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
828 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
829 | if (PushDuration) { |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
830 | PushDuration = 0; |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
831 | menu_loop(); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
832 | } |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
833 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
834 | if (xEventGroupGetBits(xEventGroupUser) & TASK_USER_REFRESH) { |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
835 | ESP_LOGI(TAG, "User task refresh"); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
836 | switch (Main_Loop2) { |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
837 | case ML2_USER: screen_main(); break; |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
838 | case ML2_UNIT1: screen_unit(0); break; |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
839 | case ML2_UNIT2: screen_unit(1); break; |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
840 | case ML2_UNIT3: screen_unit(2); break; |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
841 | } |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
842 | xEventGroupClearBits(xEventGroupUser, TASK_USER_REFRESH); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
843 | } |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
844 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
845 | vTaskDelay(10 / portTICK_PERIOD_MS); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
846 | } |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
847 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
848 | xEventGroupClearBits(xEventGroupUser, TASK_USER_WAKEUP); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
849 | } |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
850 | vTaskDelay(10 / portTICK_PERIOD_MS); |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
851 | } |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
852 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
853 | // If not configured, start configure |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
854 | // If configured select first unit |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
855 | // Handle screen (first is show measured values) |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
856 | // Display per unit. Temp + Pressure + state. Press is setup this sensor. |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
857 | // Setup menu: Sensors |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
858 | // WiFi |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
859 | // MQTT |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
860 | // System (timers etc) |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
861 | // Update OTA |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
862 | // Return |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
863 | |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
864 | // Sensors menu: Assignments, turn to choose one. |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
865 | // Sensors setup menu: DS18B20 addr Press is assign |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
866 | // DS18B20 addr |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
867 | } |
043ae27633f8
Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
868 |