main/task_user.c

Sat, 13 Jun 2020 22:07:22 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Sat, 13 Jun 2020 22:07:22 +0200
changeset 55
43362bb8f3c0
parent 54
3b1834482899
child 56
8c88a3d8ecf2
permissions
-rw-r--r--

Added DS18B20 error counters. Bigger font for the error counters screen and added the DS18B20 counter. Patched the u8g2_esp32_hal to fix the sudden system reboots.

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
51
5035385299f6 Added alarm timer watchdog. This resets the loop if not finished in 30 seconds.
Michiel Broek <mbroek@mbse.eu>
parents: 44
diff changeset
15 uint32_t AlarmTimer = 0; ///< Alarm timer
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
16 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
17 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
18 int SubMenu = 0; ///< Submenu number
32
7717ac1d2f7f Added WiFi list configured APs. Added offset to the menu rotary for large menus.
Michiel Broek <mbroek@mbse.eu>
parents: 30
diff changeset
19 int SubOffset = 0; ///< Submenu offset
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
20 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
21 rotary_encoder_info_t rinfo = { 0 }; ///< Rotary encoder record
41
d327e0aff62f Updated doxygen comments. Removed some development debug logs. Increased user inactivity time to 4 minutes. More Dutch translations in the OTA update screens.
Michiel Broek <mbroek@mbse.eu>
parents: 38
diff changeset
22 rotary_encoder_event_t event = { 0 }; ///< Rotary encoder events
d327e0aff62f Updated doxygen comments. Removed some development debug logs. Increased user inactivity time to 4 minutes. More Dutch translations in the OTA update screens.
Michiel Broek <mbroek@mbse.eu>
parents: 38
diff changeset
23 QueueHandle_t event_queue; ///< Events queue
24
64078aa15512 Finished the editor using the rotary switch. Added editing of the MQTT server parameters.
Michiel Broek <mbroek@mbse.eu>
parents: 23
diff changeset
24 static xQueueHandle gpio_evt_queue = NULL; ///< Rotary pushbutton queue
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
25 static int PushDuration = 0; ///< Duration of the pushed button
33
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
26 struct strStations APs[10]; ///< List of APs we know
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
27 int edit_ssid = 0; ///< SSID being edited
32
7717ac1d2f7f Added WiFi list configured APs. Added offset to the menu rotary for large menus.
Michiel Broek <mbroek@mbse.eu>
parents: 30
diff changeset
28 int num_ssids = 0; ///< Number of SSIDs we know
33
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
29 struct strStations editAP; ///< Data of station to edit
34
495b7eafbf5a Temporary white splash screen. Select DS18B20 sensor per unit. Changed units result logging
Michiel Broek <mbroek@mbse.eu>
parents: 33
diff changeset
30 char sensors[DS18B20_MAX][17]; ///< Sensors to select
52
90a36619b07b Added screen with software error counters.
Michiel Broek <mbroek@mbse.eu>
parents: 51
diff changeset
31 uint32_t err_connect = 0; ///< Connect error count
90a36619b07b Added screen with software error counters.
Michiel Broek <mbroek@mbse.eu>
parents: 51
diff changeset
32 uint32_t err_alarm = 0; ///< Alarm watchdog error count
55
43362bb8f3c0 Added DS18B20 error counters. Bigger font for the error counters screen and added the DS18B20 counter. Patched the u8g2_esp32_hal to fix the sudden system reboots.
Michiel Broek <mbroek@mbse.eu>
parents: 54
diff changeset
33 uint32_t err_temp = 0; ///< DS18B20 read errors
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
34
41
d327e0aff62f Updated doxygen comments. Removed some development debug logs. Increased user inactivity time to 4 minutes. More Dutch translations in the OTA update screens.
Michiel Broek <mbroek@mbse.eu>
parents: 38
diff changeset
35 extern const esp_app_desc_t *app_desc; ///< App description
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
36 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
37 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
38 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
39 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
40 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
41 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
42 extern WIFI_State *wifi_state; ///< WiFi state
24
64078aa15512 Finished the editor using the rotary switch. Added editing of the MQTT server parameters.
Michiel Broek <mbroek@mbse.eu>
parents: 23
diff changeset
43 extern SemaphoreHandle_t xSemaphoreWiFi; ///< WiFi lock semaphore
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
44 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
45 extern int Main_Loop1; ///< Main measure loop
26
8a3696620c0a Increaded stacksize for the user process. Implemented the network update using the proven brewboard code. Reverted the lock release and display sendbuffer lines to the previous code. The networks status screen uses the wifi lock.
Michiel Broek <mbroek@mbse.eu>
parents: 25
diff changeset
46 extern int update_running; ///< If update is running
34
495b7eafbf5a Temporary white splash screen. Select DS18B20 sensor per unit. Changed units result logging
Michiel Broek <mbroek@mbse.eu>
parents: 33
diff changeset
47 extern int num_sensors; ///< Detected DS18B20 sensors
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
48
043ae27633f8 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 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
50 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
51 const int TASK_USER_BUSY = BIT2; ///< User interface is busy doing something.
30
8b630bf52092 Shorter lock times.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
52 const int TASK_USER_REFRESH = BIT3; ///< Refresh requested
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
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 /**
043ae27633f8 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 * @brief Seconds timer callback.
44
e52d11b8f252 Removed dead code. Added more doxygen documentation.
Michiel Broek <mbroek@mbse.eu>
parents: 43
diff changeset
57 * @param arg Arguments for the timer.
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
58 */
043ae27633f8 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 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
60
043ae27633f8 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
043ae27633f8 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
043ae27633f8 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
043ae27633f8 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 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
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 SecsCount++;
54
3b1834482899 Version 0.2.5. Added interval to the NBIRTH json data. Added global define 60 seconds.
Michiel Broek <mbroek@mbse.eu>
parents: 52
diff changeset
69 if ((SecsCount % MAINLOOP_TIMER) == 0) {
26
8a3696620c0a Increaded stacksize for the user process. Implemented the network update using the proven brewboard code. Reverted the lock release and display sendbuffer lines to the previous code. The networks status screen uses the wifi lock.
Michiel Broek <mbroek@mbse.eu>
parents: 25
diff changeset
70 if (Main_Loop1 == ML1_DONE && update_running == 0)
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
71 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
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 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
75 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
76 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
77 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
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 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
80 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
81 }
51
5035385299f6 Added alarm timer watchdog. This resets the loop if not finished in 30 seconds.
Michiel Broek <mbroek@mbse.eu>
parents: 44
diff changeset
82
5035385299f6 Added alarm timer watchdog. This resets the loop if not finished in 30 seconds.
Michiel Broek <mbroek@mbse.eu>
parents: 44
diff changeset
83 if (AlarmTimer == 1) {
5035385299f6 Added alarm timer watchdog. This resets the loop if not finished in 30 seconds.
Michiel Broek <mbroek@mbse.eu>
parents: 44
diff changeset
84 ESP_LOGI(TAG, "Alarm Timer timeout");
5035385299f6 Added alarm timer watchdog. This resets the loop if not finished in 30 seconds.
Michiel Broek <mbroek@mbse.eu>
parents: 44
diff changeset
85 Main_Loop1 = ML1_INIT;
52
90a36619b07b Added screen with software error counters.
Michiel Broek <mbroek@mbse.eu>
parents: 51
diff changeset
86 err_alarm++;
51
5035385299f6 Added alarm timer watchdog. This resets the loop if not finished in 30 seconds.
Michiel Broek <mbroek@mbse.eu>
parents: 44
diff changeset
87 }
5035385299f6 Added alarm timer watchdog. This resets the loop if not finished in 30 seconds.
Michiel Broek <mbroek@mbse.eu>
parents: 44
diff changeset
88
5035385299f6 Added alarm timer watchdog. This resets the loop if not finished in 30 seconds.
Michiel Broek <mbroek@mbse.eu>
parents: 44
diff changeset
89 if (AlarmTimer) {
5035385299f6 Added alarm timer watchdog. This resets the loop if not finished in 30 seconds.
Michiel Broek <mbroek@mbse.eu>
parents: 44
diff changeset
90 AlarmTimer--;
5035385299f6 Added alarm timer watchdog. This resets the loop if not finished in 30 seconds.
Michiel Broek <mbroek@mbse.eu>
parents: 44
diff changeset
91 }
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
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 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
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 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
99 }
043ae27633f8 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
043ae27633f8 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 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
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 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
106 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
107 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
108 }
043ae27633f8 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
043ae27633f8 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
043ae27633f8 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
043ae27633f8 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 /**
043ae27633f8 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 * @brief Get a keyboard character from the rotary encoder.
24
64078aa15512 Finished the editor using the rotary switch. Added editing of the MQTT server parameters.
Michiel Broek <mbroek@mbse.eu>
parents: 23
diff changeset
114 * @param curkey The referenced value if the key being edited.
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
115 * @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
116 * @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
117 * @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
118 * @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
119 */
043ae27633f8 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 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
121 {
24
64078aa15512 Finished the editor using the rotary switch. Added editing of the MQTT server parameters.
Michiel Broek <mbroek@mbse.eu>
parents: 23
diff changeset
122 int key = *curkey;
64078aa15512 Finished the editor using the rotary switch. Added editing of the MQTT server parameters.
Michiel Broek <mbroek@mbse.eu>
parents: 23
diff changeset
123 int rc = 0;
23
58a328e91881 Added error logging for failed locks
Michiel Broek <mbroek@mbse.eu>
parents: 22
diff changeset
124 int8_t ascent = u8g2_GetAscent(&u8g2);
24
64078aa15512 Finished the editor using the rotary switch. Added editing of the MQTT server parameters.
Michiel Broek <mbroek@mbse.eu>
parents: 23
diff changeset
125 int8_t descent = u8g2_GetDescent(&u8g2);
23
58a328e91881 Added error logging for failed locks
Michiel Broek <mbroek@mbse.eu>
parents: 22
diff changeset
126 int8_t charheight = u8g2_GetMaxCharHeight(&u8g2);
58a328e91881 Added error logging for failed locks
Michiel Broek <mbroek@mbse.eu>
parents: 22
diff changeset
127 int8_t charwidth = u8g2_GetMaxCharWidth(&u8g2);
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
128
24
64078aa15512 Finished the editor using the rotary switch. Added editing of the MQTT server parameters.
Michiel Broek <mbroek@mbse.eu>
parents: 23
diff changeset
129 u8g2_DrawGlyph(&u8g2, x, y, key);
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
130 u8g2_DrawHLine(&u8g2, x, y+3, 12);
24
64078aa15512 Finished the editor using the rotary switch. Added editing of the MQTT server parameters.
Michiel Broek <mbroek@mbse.eu>
parents: 23
diff changeset
131 u8g2_UpdateDisplay(&u8g2);
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
132
24
64078aa15512 Finished the editor using the rotary switch. Added editing of the MQTT server parameters.
Michiel Broek <mbroek@mbse.eu>
parents: 23
diff changeset
133 ESP_LOGI(TAG, "getkey(%c, %d, %d, %d) a %d d %d h %d w %d", key, type, x, y, ascent, descent, charheight, charwidth);
23
58a328e91881 Added error logging for failed locks
Michiel Broek <mbroek@mbse.eu>
parents: 22
diff changeset
134
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
135 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
136 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
137 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
138 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
139
24
64078aa15512 Finished the editor using the rotary switch. Added editing of the MQTT server parameters.
Michiel Broek <mbroek@mbse.eu>
parents: 23
diff changeset
140 u8g2_SetDrawColor(&u8g2, 0);
64078aa15512 Finished the editor using the rotary switch. Added editing of the MQTT server parameters.
Michiel Broek <mbroek@mbse.eu>
parents: 23
diff changeset
141 u8g2_DrawBox(&u8g2, x, y - 12, charwidth, charheight);
64078aa15512 Finished the editor using the rotary switch. Added editing of the MQTT server parameters.
Michiel Broek <mbroek@mbse.eu>
parents: 23
diff changeset
142 u8g2_SetDrawColor(&u8g2, 1);
64078aa15512 Finished the editor using the rotary switch. Added editing of the MQTT server parameters.
Michiel Broek <mbroek@mbse.eu>
parents: 23
diff changeset
143 u8g2_DrawHLine(&u8g2, x, y+3, charwidth);
23
58a328e91881 Added error logging for failed locks
Michiel Broek <mbroek@mbse.eu>
parents: 22
diff changeset
144
24
64078aa15512 Finished the editor using the rotary switch. Added editing of the MQTT server parameters.
Michiel Broek <mbroek@mbse.eu>
parents: 23
diff changeset
145 if (event.state.position > 0) {
64078aa15512 Finished the editor using the rotary switch. Added editing of the MQTT server parameters.
Michiel Broek <mbroek@mbse.eu>
parents: 23
diff changeset
146 /*
64078aa15512 Finished the editor using the rotary switch. Added editing of the MQTT server parameters.
Michiel Broek <mbroek@mbse.eu>
parents: 23
diff changeset
147 * If turned fast, the encoder registers multiple steps.
64078aa15512 Finished the editor using the rotary switch. Added editing of the MQTT server parameters.
Michiel Broek <mbroek@mbse.eu>
parents: 23
diff changeset
148 * So follow these steps.
64078aa15512 Finished the editor using the rotary switch. Added editing of the MQTT server parameters.
Michiel Broek <mbroek@mbse.eu>
parents: 23
diff changeset
149 */
64078aa15512 Finished the editor using the rotary switch. Added editing of the MQTT server parameters.
Michiel Broek <mbroek@mbse.eu>
parents: 23
diff changeset
150 for (int i = 0; i < event.state.position; i++) {
64078aa15512 Finished the editor using the rotary switch. Added editing of the MQTT server parameters.
Michiel Broek <mbroek@mbse.eu>
parents: 23
diff changeset
151 if (type == EDIT_TYPE_CAPS) {
64078aa15512 Finished the editor using the rotary switch. Added editing of the MQTT server parameters.
Michiel Broek <mbroek@mbse.eu>
parents: 23
diff changeset
152 if (key < 127)
64078aa15512 Finished the editor using the rotary switch. Added editing of the MQTT server parameters.
Michiel Broek <mbroek@mbse.eu>
parents: 23
diff changeset
153 key++;
64078aa15512 Finished the editor using the rotary switch. Added editing of the MQTT server parameters.
Michiel Broek <mbroek@mbse.eu>
parents: 23
diff changeset
154 if (key > 96 && key < 123)
64078aa15512 Finished the editor using the rotary switch. Added editing of the MQTT server parameters.
Michiel Broek <mbroek@mbse.eu>
parents: 23
diff changeset
155 key = 123;
64078aa15512 Finished the editor using the rotary switch. Added editing of the MQTT server parameters.
Michiel Broek <mbroek@mbse.eu>
parents: 23
diff changeset
156 } else if (type == EDIT_TYPE_INT) {
64078aa15512 Finished the editor using the rotary switch. Added editing of the MQTT server parameters.
Michiel Broek <mbroek@mbse.eu>
parents: 23
diff changeset
157 if (key < 127)
64078aa15512 Finished the editor using the rotary switch. Added editing of the MQTT server parameters.
Michiel Broek <mbroek@mbse.eu>
parents: 23
diff changeset
158 key++;
64078aa15512 Finished the editor using the rotary switch. Added editing of the MQTT server parameters.
Michiel Broek <mbroek@mbse.eu>
parents: 23
diff changeset
159 if (key < 45)
64078aa15512 Finished the editor using the rotary switch. Added editing of the MQTT server parameters.
Michiel Broek <mbroek@mbse.eu>
parents: 23
diff changeset
160 key = 45;
64078aa15512 Finished the editor using the rotary switch. Added editing of the MQTT server parameters.
Michiel Broek <mbroek@mbse.eu>
parents: 23
diff changeset
161 if (key == 46 || key == 47)
64078aa15512 Finished the editor using the rotary switch. Added editing of the MQTT server parameters.
Michiel Broek <mbroek@mbse.eu>
parents: 23
diff changeset
162 key = 48;
64078aa15512 Finished the editor using the rotary switch. Added editing of the MQTT server parameters.
Michiel Broek <mbroek@mbse.eu>
parents: 23
diff changeset
163 if (key > 57)
64078aa15512 Finished the editor using the rotary switch. Added editing of the MQTT server parameters.
Michiel Broek <mbroek@mbse.eu>
parents: 23
diff changeset
164 key = 127;
64078aa15512 Finished the editor using the rotary switch. Added editing of the MQTT server parameters.
Michiel Broek <mbroek@mbse.eu>
parents: 23
diff changeset
165 } else if (type == EDIT_TYPE_FLOAT) {
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
166
24
64078aa15512 Finished the editor using the rotary switch. Added editing of the MQTT server parameters.
Michiel Broek <mbroek@mbse.eu>
parents: 23
diff changeset
167 } else { // EDIT_TYPE_TEXT
64078aa15512 Finished the editor using the rotary switch. Added editing of the MQTT server parameters.
Michiel Broek <mbroek@mbse.eu>
parents: 23
diff changeset
168 if (key < 127)
64078aa15512 Finished the editor using the rotary switch. Added editing of the MQTT server parameters.
Michiel Broek <mbroek@mbse.eu>
parents: 23
diff changeset
169 key++;
64078aa15512 Finished the editor using the rotary switch. Added editing of the MQTT server parameters.
Michiel Broek <mbroek@mbse.eu>
parents: 23
diff changeset
170 }
64078aa15512 Finished the editor using the rotary switch. Added editing of the MQTT server parameters.
Michiel Broek <mbroek@mbse.eu>
parents: 23
diff changeset
171 }
64078aa15512 Finished the editor using the rotary switch. Added editing of the MQTT server parameters.
Michiel Broek <mbroek@mbse.eu>
parents: 23
diff changeset
172 } else if (event.state.position < 0) {
64078aa15512 Finished the editor using the rotary switch. Added editing of the MQTT server parameters.
Michiel Broek <mbroek@mbse.eu>
parents: 23
diff changeset
173 for (int i = 0; i > event.state.position; i--) {
64078aa15512 Finished the editor using the rotary switch. Added editing of the MQTT server parameters.
Michiel Broek <mbroek@mbse.eu>
parents: 23
diff changeset
174 if (type == EDIT_TYPE_CAPS) {
64078aa15512 Finished the editor using the rotary switch. Added editing of the MQTT server parameters.
Michiel Broek <mbroek@mbse.eu>
parents: 23
diff changeset
175 if (key > 32)
64078aa15512 Finished the editor using the rotary switch. Added editing of the MQTT server parameters.
Michiel Broek <mbroek@mbse.eu>
parents: 23
diff changeset
176 key--;
64078aa15512 Finished the editor using the rotary switch. Added editing of the MQTT server parameters.
Michiel Broek <mbroek@mbse.eu>
parents: 23
diff changeset
177 if (key > 96 && key < 123)
64078aa15512 Finished the editor using the rotary switch. Added editing of the MQTT server parameters.
Michiel Broek <mbroek@mbse.eu>
parents: 23
diff changeset
178 key = 96;
64078aa15512 Finished the editor using the rotary switch. Added editing of the MQTT server parameters.
Michiel Broek <mbroek@mbse.eu>
parents: 23
diff changeset
179 } else if (type == EDIT_TYPE_INT) {
64078aa15512 Finished the editor using the rotary switch. Added editing of the MQTT server parameters.
Michiel Broek <mbroek@mbse.eu>
parents: 23
diff changeset
180 if (key > 45)
64078aa15512 Finished the editor using the rotary switch. Added editing of the MQTT server parameters.
Michiel Broek <mbroek@mbse.eu>
parents: 23
diff changeset
181 key--;
64078aa15512 Finished the editor using the rotary switch. Added editing of the MQTT server parameters.
Michiel Broek <mbroek@mbse.eu>
parents: 23
diff changeset
182 if (key > 57)
64078aa15512 Finished the editor using the rotary switch. Added editing of the MQTT server parameters.
Michiel Broek <mbroek@mbse.eu>
parents: 23
diff changeset
183 key = 57;
64078aa15512 Finished the editor using the rotary switch. Added editing of the MQTT server parameters.
Michiel Broek <mbroek@mbse.eu>
parents: 23
diff changeset
184 if (key == 46 || key == 47)
64078aa15512 Finished the editor using the rotary switch. Added editing of the MQTT server parameters.
Michiel Broek <mbroek@mbse.eu>
parents: 23
diff changeset
185 key = 45;
64078aa15512 Finished the editor using the rotary switch. Added editing of the MQTT server parameters.
Michiel Broek <mbroek@mbse.eu>
parents: 23
diff changeset
186 } else if (type == EDIT_TYPE_FLOAT) {
64078aa15512 Finished the editor using the rotary switch. Added editing of the MQTT server parameters.
Michiel Broek <mbroek@mbse.eu>
parents: 23
diff changeset
187
64078aa15512 Finished the editor using the rotary switch. Added editing of the MQTT server parameters.
Michiel Broek <mbroek@mbse.eu>
parents: 23
diff changeset
188 } else { // EDIT_TYPE_TEXT
64078aa15512 Finished the editor using the rotary switch. Added editing of the MQTT server parameters.
Michiel Broek <mbroek@mbse.eu>
parents: 23
diff changeset
189 if (key > 32)
64078aa15512 Finished the editor using the rotary switch. Added editing of the MQTT server parameters.
Michiel Broek <mbroek@mbse.eu>
parents: 23
diff changeset
190 key--;
64078aa15512 Finished the editor using the rotary switch. Added editing of the MQTT server parameters.
Michiel Broek <mbroek@mbse.eu>
parents: 23
diff changeset
191 }
64078aa15512 Finished the editor using the rotary switch. Added editing of the MQTT server parameters.
Michiel Broek <mbroek@mbse.eu>
parents: 23
diff changeset
192 }
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
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
043ae27633f8 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 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
196 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
197 u8g2_SendBuffer(&u8g2);
24
64078aa15512 Finished the editor using the rotary switch. Added editing of the MQTT server parameters.
Michiel Broek <mbroek@mbse.eu>
parents: 23
diff changeset
198 u8g2_UpdateDisplay(&u8g2);
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
199 }
043ae27633f8 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 } 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
201 if (PushDuration) {
24
64078aa15512 Finished the editor using the rotary switch. Added editing of the MQTT server parameters.
Michiel Broek <mbroek@mbse.eu>
parents: 23
diff changeset
202 UserTimer = INACTIVITY;
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
203 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
204 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
205 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
206 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
207 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
208 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
209 }
043ae27633f8 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 }
043ae27633f8 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 u8g2_SetDrawColor(&u8g2, 0);
24
64078aa15512 Finished the editor using the rotary switch. Added editing of the MQTT server parameters.
Michiel Broek <mbroek@mbse.eu>
parents: 23
diff changeset
213 if (key == 127)
64078aa15512 Finished the editor using the rotary switch. Added editing of the MQTT server parameters.
Michiel Broek <mbroek@mbse.eu>
parents: 23
diff changeset
214 u8g2_DrawBox(&u8g2, x, y - 12, charwidth, charheight); // Erase DEL character
64078aa15512 Finished the editor using the rotary switch. Added editing of the MQTT server parameters.
Michiel Broek <mbroek@mbse.eu>
parents: 23
diff changeset
215 u8g2_DrawHLine(&u8g2, x, y+3, charwidth);
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
216 u8g2_SetDrawColor(&u8g2, 1);
24
64078aa15512 Finished the editor using the rotary switch. Added editing of the MQTT server parameters.
Michiel Broek <mbroek@mbse.eu>
parents: 23
diff changeset
217 u8g2_UpdateDisplay(&u8g2);
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
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 *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
220 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
221 }
043ae27633f8 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
043ae27633f8 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
043ae27633f8 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
043ae27633f8 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 /**
043ae27633f8 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 * @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
227 * @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
228 * @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
229 * @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
230 * @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
231 * @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
232 */
043ae27633f8 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 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
234 {
043ae27633f8 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 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
236 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
237
043ae27633f8 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 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
239 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
240 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
241 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
242 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
243 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
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 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
246 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
247 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
248 }
23
58a328e91881 Added error logging for failed locks
Michiel Broek <mbroek@mbse.eu>
parents: 22
diff changeset
249 u8g2_SetFont(&u8g2, u8g2_font_unifont_t_symbols);
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
250 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
251 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
252 u8g2_SendBuffer(&u8g2);
23
58a328e91881 Added error logging for failed locks
Michiel Broek <mbroek@mbse.eu>
parents: 22
diff changeset
253 ESP_LOGI(TAG, "rotary_editer(%s, %s, %s, %d, %d)", label, txt, errmsg, len, type);
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
254
24
64078aa15512 Finished the editor using the rotary switch. Added editing of the MQTT server parameters.
Michiel Broek <mbroek@mbse.eu>
parents: 23
diff changeset
255 /*
64078aa15512 Finished the editor using the rotary switch. Added editing of the MQTT server parameters.
Michiel Broek <mbroek@mbse.eu>
parents: 23
diff changeset
256 * Choose initial edit key
64078aa15512 Finished the editor using the rotary switch. Added editing of the MQTT server parameters.
Michiel Broek <mbroek@mbse.eu>
parents: 23
diff changeset
257 */
64078aa15512 Finished the editor using the rotary switch. Added editing of the MQTT server parameters.
Michiel Broek <mbroek@mbse.eu>
parents: 23
diff changeset
258 if (type == EDIT_TYPE_CAPS)
64078aa15512 Finished the editor using the rotary switch. Added editing of the MQTT server parameters.
Michiel Broek <mbroek@mbse.eu>
parents: 23
diff changeset
259 key = 'A';
64078aa15512 Finished the editor using the rotary switch. Added editing of the MQTT server parameters.
Michiel Broek <mbroek@mbse.eu>
parents: 23
diff changeset
260 else if (type == EDIT_TYPE_INT || type == EDIT_TYPE_FLOAT)
64078aa15512 Finished the editor using the rotary switch. Added editing of the MQTT server parameters.
Michiel Broek <mbroek@mbse.eu>
parents: 23
diff changeset
261 key = '0';
64078aa15512 Finished the editor using the rotary switch. Added editing of the MQTT server parameters.
Michiel Broek <mbroek@mbse.eu>
parents: 23
diff changeset
262 else
64078aa15512 Finished the editor using the rotary switch. Added editing of the MQTT server parameters.
Michiel Broek <mbroek@mbse.eu>
parents: 23
diff changeset
263 key = 'a';
64078aa15512 Finished the editor using the rotary switch. Added editing of the MQTT server parameters.
Michiel Broek <mbroek@mbse.eu>
parents: 23
diff changeset
264
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
265 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
266 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
267 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
268 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
269 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
270 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
271 txt[strlen(txt)] = key;
24
64078aa15512 Finished the editor using the rotary switch. Added editing of the MQTT server parameters.
Michiel Broek <mbroek@mbse.eu>
parents: 23
diff changeset
272 } else if (key == 127 && strlen(txt)) {
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
273 // 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
274 txt[strlen(txt) - 1] = '\0';
24
64078aa15512 Finished the editor using the rotary switch. Added editing of the MQTT server parameters.
Michiel Broek <mbroek@mbse.eu>
parents: 23
diff changeset
275 if (strlen(txt))
64078aa15512 Finished the editor using the rotary switch. Added editing of the MQTT server parameters.
Michiel Broek <mbroek@mbse.eu>
parents: 23
diff changeset
276 key = txt[strlen(txt) - 1];
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
277 }
24
64078aa15512 Finished the editor using the rotary switch. Added editing of the MQTT server parameters.
Michiel Broek <mbroek@mbse.eu>
parents: 23
diff changeset
278 ESP_LOGI(TAG, " strlen %d x %d key %d `%s`", strlen(txt), x, key, txt);
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
279 } 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
280 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
281 }
043ae27633f8 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 }
24
64078aa15512 Finished the editor using the rotary switch. Added editing of the MQTT server parameters.
Michiel Broek <mbroek@mbse.eu>
parents: 23
diff changeset
283 ESP_LOGI(TAG, "rotary_editer() `%s`", txt);
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
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
043ae27633f8 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 * @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
290 * @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
291 * @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
292 * @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
293 * @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
294 */
043ae27633f8 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 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
296 {
043ae27633f8 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 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
298 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
299
043ae27633f8 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 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
301 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
302 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
303 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
304
043ae27633f8 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 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
306 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
307 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
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 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
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
043ae27633f8 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
043ae27633f8 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 * @brief Clear the display and prepare the top of the display.
44
e52d11b8f252 Removed dead code. Added more doxygen documentation.
Michiel Broek <mbroek@mbse.eu>
parents: 43
diff changeset
316 * @param format The formatted data to display at the top.
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
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 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
319 {
043ae27633f8 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 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
321 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
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 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
324 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
325 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
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 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
328 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
329
043ae27633f8 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 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
331 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
332 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
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
043ae27633f8 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
043ae27633f8 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
043ae27633f8 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 * @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
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 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
341 {
36
e2a43e7c4035 Swapped ADC channels 6 and 7. Completed the DS18B20 assign to unit.
Michiel Broek <mbroek@mbse.eu>
parents: 34
diff changeset
342 screen_top("CO2 meter %s", app_desc->version);
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
343
36
e2a43e7c4035 Swapped ADC channels 6 and 7. Completed the DS18B20 assign to unit.
Michiel Broek <mbroek@mbse.eu>
parents: 34
diff changeset
344 u8g2_SetFont(&u8g2, u8g2_font_t0_22b_tf);
e2a43e7c4035 Swapped ADC channels 6 and 7. Completed the DS18B20 assign to unit.
Michiel Broek <mbroek@mbse.eu>
parents: 34
diff changeset
345 u8g2_uint_t w = u8g2_GetUTF8Width(&u8g2, "Welkom");
e2a43e7c4035 Swapped ADC channels 6 and 7. Completed the DS18B20 assign to unit.
Michiel Broek <mbroek@mbse.eu>
parents: 34
diff changeset
346 u8g2_DrawUTF8(&u8g2, (128 - w) / 2,50, "Welkom");
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
347 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
348 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
349 }
043ae27633f8 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
043ae27633f8 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 /**
043ae27633f8 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 * @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
355 */
043ae27633f8 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 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
357 {
043ae27633f8 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 char buf[65];
42
22a0f9810561 In the main screen dim the not active units.
Michiel Broek <mbroek@mbse.eu>
parents: 41
diff changeset
359 int i, mode[3];
30
8b630bf52092 Shorter lock times.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
360 uint32_t temperature = 0, pressure[3];
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
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 if (xSemaphoreTake(xSemaphoreUnits, 25) == pdTRUE) {
30
8b630bf52092 Shorter lock times.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
363 temperature = units[0].temperature;
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
364 for (i = 0; i < 3; i++) {
30
8b630bf52092 Shorter lock times.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
365 pressure[i] = units[i].pressure;
42
22a0f9810561 In the main screen dim the not active units.
Michiel Broek <mbroek@mbse.eu>
parents: 41
diff changeset
366 mode[i] = units[i].mode;
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
367 }
043ae27633f8 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 xSemaphoreGive(xSemaphoreUnits);
23
58a328e91881 Added error logging for failed locks
Michiel Broek <mbroek@mbse.eu>
parents: 22
diff changeset
369 } else {
58a328e91881 Added error logging for failed locks
Michiel Broek <mbroek@mbse.eu>
parents: 22
diff changeset
370 ESP_LOGE(TAG, "screen_main() lock error");
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
371 }
30
8b630bf52092 Shorter lock times.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
372
8b630bf52092 Shorter lock times.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
373 screen_top("CO2 meter %s", app_desc->version);
8b630bf52092 Shorter lock times.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
374 u8g2_SetFont(&u8g2, u8g2_font_t0_22b_tf);
8b630bf52092 Shorter lock times.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
375 sprintf(buf, "%.1f °C", temperature / 1000.0);
8b630bf52092 Shorter lock times.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
376 u8g2_uint_t w = u8g2_GetUTF8Width(&u8g2, buf);
8b630bf52092 Shorter lock times.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
377 u8g2_DrawUTF8(&u8g2, (128 - w) / 2,40, buf);
8b630bf52092 Shorter lock times.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
378
8b630bf52092 Shorter lock times.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
379 for (i = 0; i < 3; i++) {
42
22a0f9810561 In the main screen dim the not active units.
Michiel Broek <mbroek@mbse.eu>
parents: 41
diff changeset
380 if (mode[i])
22a0f9810561 In the main screen dim the not active units.
Michiel Broek <mbroek@mbse.eu>
parents: 41
diff changeset
381 u8g2_SetFont(&u8g2, u8g2_font_t0_18b_tf);
22a0f9810561 In the main screen dim the not active units.
Michiel Broek <mbroek@mbse.eu>
parents: 41
diff changeset
382 else
22a0f9810561 In the main screen dim the not active units.
Michiel Broek <mbroek@mbse.eu>
parents: 41
diff changeset
383 u8g2_SetFont(&u8g2, u8g2_font_t0_18_tf);
30
8b630bf52092 Shorter lock times.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
384 sprintf(buf, "%.1f", pressure[i] / 1000.0);
8b630bf52092 Shorter lock times.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
385 w = u8g2_GetUTF8Width(&u8g2, buf);
8b630bf52092 Shorter lock times.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
386 u8g2_DrawUTF8(&u8g2, ((42 - w) / 2) + i * 43,63, buf);
8b630bf52092 Shorter lock times.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
387 }
8b630bf52092 Shorter lock times.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
388
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
389 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
390 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
391 }
043ae27633f8 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
043ae27633f8 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
043ae27633f8 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
043ae27633f8 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 * @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
397 * @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
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_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
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 char buf[65];
30
8b630bf52092 Shorter lock times.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
402 int mode = 0;
8b630bf52092 Shorter lock times.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
403 uint32_t temperature = 0, pressure = 0;
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
404
24
64078aa15512 Finished the editor using the rotary switch. Added editing of the MQTT server parameters.
Michiel Broek <mbroek@mbse.eu>
parents: 23
diff changeset
405 if (xSemaphoreTake(xSemaphoreUnits, 35) == pdTRUE) {
30
8b630bf52092 Shorter lock times.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
406 mode = units[no].mode;
8b630bf52092 Shorter lock times.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
407 temperature = units[no].temperature;
8b630bf52092 Shorter lock times.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
408 pressure = units[no].pressure;
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
409 xSemaphoreGive(xSemaphoreUnits);
23
58a328e91881 Added error logging for failed locks
Michiel Broek <mbroek@mbse.eu>
parents: 22
diff changeset
410 } else {
58a328e91881 Added error logging for failed locks
Michiel Broek <mbroek@mbse.eu>
parents: 22
diff changeset
411 ESP_LOGE(TAG, "screen_unit(%d) lock error", no);
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
412 }
30
8b630bf52092 Shorter lock times.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
413
8b630bf52092 Shorter lock times.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
414 screen_top("Meter %d %s", no + 1, mode ? "Aan":"Uit");
8b630bf52092 Shorter lock times.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
415
8b630bf52092 Shorter lock times.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
416 u8g2_SetFont(&u8g2, u8g2_font_t0_22b_tf);
8b630bf52092 Shorter lock times.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
417 sprintf(buf, "%.1f °C", temperature / 1000.0);
8b630bf52092 Shorter lock times.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
418 u8g2_uint_t w = u8g2_GetUTF8Width(&u8g2, buf);
8b630bf52092 Shorter lock times.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
419 u8g2_DrawUTF8(&u8g2, (128 - w) / 2,40, buf);
8b630bf52092 Shorter lock times.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
420
8b630bf52092 Shorter lock times.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
421 sprintf(buf, "%.2f bar", pressure / 1000.0);
8b630bf52092 Shorter lock times.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
422 w = u8g2_GetUTF8Width(&u8g2, buf);
8b630bf52092 Shorter lock times.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
423 u8g2_DrawUTF8(&u8g2, (128 - w) / 2,63, buf);
8b630bf52092 Shorter lock times.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
424 u8g2_SendBuffer(&u8g2);
43
70c99c2084dc Version 0.2.1. When wakeup by user push, select the active unit screen if only one unit is active.
Michiel Broek <mbroek@mbse.eu>
parents: 42
diff changeset
425 u8g2_SetPowerSave(&u8g2, 0); // wake up display
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
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
043ae27633f8 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
043ae27633f8 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
043ae27633f8 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 /**
043ae27633f8 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 * @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
432 * @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
433 * @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
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 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
436 {
29
106464d4c727 Dutch translation on the screens.
Michiel Broek <mbroek@mbse.eu>
parents: 28
diff changeset
437 screen_top("Meter %d nulpunt", no + 1);
33
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
438 menu_line( 0, 1, 25, "Huidig %d", units[no].pressure_zero);
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
439 menu_line(sub == 0, 1, 37, "Nieuw %d", units[no].pressure_voltage / (adc_state->Batt_voltage / 1000));
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
440 menu_line(sub == 1, 1, 49, "Terug");
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
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 }
043ae27633f8 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
41
d327e0aff62f Updated doxygen comments. Removed some development debug logs. Increased user inactivity time to 4 minutes. More Dutch translations in the OTA update screens.
Michiel Broek <mbroek@mbse.eu>
parents: 38
diff changeset
446 /**
d327e0aff62f Updated doxygen comments. Removed some development debug logs. Increased user inactivity time to 4 minutes. More Dutch translations in the OTA update screens.
Michiel Broek <mbroek@mbse.eu>
parents: 38
diff changeset
447 * @brief The list of detected DS18B20 sensors.
d327e0aff62f Updated doxygen comments. Removed some development debug logs. Increased user inactivity time to 4 minutes. More Dutch translations in the OTA update screens.
Michiel Broek <mbroek@mbse.eu>
parents: 38
diff changeset
448 * @param no The unit index number.
d327e0aff62f Updated doxygen comments. Removed some development debug logs. Increased user inactivity time to 4 minutes. More Dutch translations in the OTA update screens.
Michiel Broek <mbroek@mbse.eu>
parents: 38
diff changeset
449 * @param sub The submenu index number.
d327e0aff62f Updated doxygen comments. Removed some development debug logs. Increased user inactivity time to 4 minutes. More Dutch translations in the OTA update screens.
Michiel Broek <mbroek@mbse.eu>
parents: 38
diff changeset
450 * @param offset The offset in the list.
d327e0aff62f Updated doxygen comments. Removed some development debug logs. Increased user inactivity time to 4 minutes. More Dutch translations in the OTA update screens.
Michiel Broek <mbroek@mbse.eu>
parents: 38
diff changeset
451 */
d327e0aff62f Updated doxygen comments. Removed some development debug logs. Increased user inactivity time to 4 minutes. More Dutch translations in the OTA update screens.
Michiel Broek <mbroek@mbse.eu>
parents: 38
diff changeset
452
34
495b7eafbf5a Temporary white splash screen. Select DS18B20 sensor per unit. Changed units result logging
Michiel Broek <mbroek@mbse.eu>
parents: 33
diff changeset
453 void screen_list_sensors(int no, int sub, int offset)
495b7eafbf5a Temporary white splash screen. Select DS18B20 sensor per unit. Changed units result logging
Michiel Broek <mbroek@mbse.eu>
parents: 33
diff changeset
454 {
495b7eafbf5a Temporary white splash screen. Select DS18B20 sensor per unit. Changed units result logging
Michiel Broek <mbroek@mbse.eu>
parents: 33
diff changeset
455 int i;
495b7eafbf5a Temporary white splash screen. Select DS18B20 sensor per unit. Changed units result logging
Michiel Broek <mbroek@mbse.eu>
parents: 33
diff changeset
456
495b7eafbf5a Temporary white splash screen. Select DS18B20 sensor per unit. Changed units result logging
Michiel Broek <mbroek@mbse.eu>
parents: 33
diff changeset
457 if (xSemaphoreTake(xSemaphoreDS18B20, 10) == pdTRUE) {
495b7eafbf5a Temporary white splash screen. Select DS18B20 sensor per unit. Changed units result logging
Michiel Broek <mbroek@mbse.eu>
parents: 33
diff changeset
458 for (i = 0; i < ds18b20_state->num_sensors; i++) {
495b7eafbf5a Temporary white splash screen. Select DS18B20 sensor per unit. Changed units result logging
Michiel Broek <mbroek@mbse.eu>
parents: 33
diff changeset
459 strncpy(sensors[i], ds18b20_state->sensor[i].rom_code, 17);
495b7eafbf5a Temporary white splash screen. Select DS18B20 sensor per unit. Changed units result logging
Michiel Broek <mbroek@mbse.eu>
parents: 33
diff changeset
460 sensors[i][16] = '\0';
495b7eafbf5a Temporary white splash screen. Select DS18B20 sensor per unit. Changed units result logging
Michiel Broek <mbroek@mbse.eu>
parents: 33
diff changeset
461 }
495b7eafbf5a Temporary white splash screen. Select DS18B20 sensor per unit. Changed units result logging
Michiel Broek <mbroek@mbse.eu>
parents: 33
diff changeset
462 xSemaphoreGive(xSemaphoreDS18B20);
495b7eafbf5a Temporary white splash screen. Select DS18B20 sensor per unit. Changed units result logging
Michiel Broek <mbroek@mbse.eu>
parents: 33
diff changeset
463 } else {
495b7eafbf5a Temporary white splash screen. Select DS18B20 sensor per unit. Changed units result logging
Michiel Broek <mbroek@mbse.eu>
parents: 33
diff changeset
464 ESP_LOGE(TAG, "screen_list_sensors() DS18B20 lock error");
495b7eafbf5a Temporary white splash screen. Select DS18B20 sensor per unit. Changed units result logging
Michiel Broek <mbroek@mbse.eu>
parents: 33
diff changeset
465 }
495b7eafbf5a Temporary white splash screen. Select DS18B20 sensor per unit. Changed units result logging
Michiel Broek <mbroek@mbse.eu>
parents: 33
diff changeset
466
495b7eafbf5a Temporary white splash screen. Select DS18B20 sensor per unit. Changed units result logging
Michiel Broek <mbroek@mbse.eu>
parents: 33
diff changeset
467 screen_top("DS18B20 lijst");
495b7eafbf5a Temporary white splash screen. Select DS18B20 sensor per unit. Changed units result logging
Michiel Broek <mbroek@mbse.eu>
parents: 33
diff changeset
468 if (num_sensors == 0) {
495b7eafbf5a Temporary white splash screen. Select DS18B20 sensor per unit. Changed units result logging
Michiel Broek <mbroek@mbse.eu>
parents: 33
diff changeset
469 menu_line(0, 1, 25, "Geen sensors");
495b7eafbf5a Temporary white splash screen. Select DS18B20 sensor per unit. Changed units result logging
Michiel Broek <mbroek@mbse.eu>
parents: 33
diff changeset
470 } else {
495b7eafbf5a Temporary white splash screen. Select DS18B20 sensor per unit. Changed units result logging
Michiel Broek <mbroek@mbse.eu>
parents: 33
diff changeset
471 for (i = 0; i < num_sensors; i++) {
495b7eafbf5a Temporary white splash screen. Select DS18B20 sensor per unit. Changed units result logging
Michiel Broek <mbroek@mbse.eu>
parents: 33
diff changeset
472 menu_line(sub == i, 1, 25 + (i * 12), sensors[i + offset]);
495b7eafbf5a Temporary white splash screen. Select DS18B20 sensor per unit. Changed units result logging
Michiel Broek <mbroek@mbse.eu>
parents: 33
diff changeset
473 if (i == 3)
495b7eafbf5a Temporary white splash screen. Select DS18B20 sensor per unit. Changed units result logging
Michiel Broek <mbroek@mbse.eu>
parents: 33
diff changeset
474 break;
495b7eafbf5a Temporary white splash screen. Select DS18B20 sensor per unit. Changed units result logging
Michiel Broek <mbroek@mbse.eu>
parents: 33
diff changeset
475 }
495b7eafbf5a Temporary white splash screen. Select DS18B20 sensor per unit. Changed units result logging
Michiel Broek <mbroek@mbse.eu>
parents: 33
diff changeset
476 if ((i + offset) == num_sensors)
495b7eafbf5a Temporary white splash screen. Select DS18B20 sensor per unit. Changed units result logging
Michiel Broek <mbroek@mbse.eu>
parents: 33
diff changeset
477 menu_line(sub == i, 1, 25 + (i * 12), "Terug");
495b7eafbf5a Temporary white splash screen. Select DS18B20 sensor per unit. Changed units result logging
Michiel Broek <mbroek@mbse.eu>
parents: 33
diff changeset
478 }
495b7eafbf5a Temporary white splash screen. Select DS18B20 sensor per unit. Changed units result logging
Michiel Broek <mbroek@mbse.eu>
parents: 33
diff changeset
479 u8g2_SendBuffer(&u8g2);
495b7eafbf5a Temporary white splash screen. Select DS18B20 sensor per unit. Changed units result logging
Michiel Broek <mbroek@mbse.eu>
parents: 33
diff changeset
480 }
495b7eafbf5a Temporary white splash screen. Select DS18B20 sensor per unit. Changed units result logging
Michiel Broek <mbroek@mbse.eu>
parents: 33
diff changeset
481
495b7eafbf5a Temporary white splash screen. Select DS18B20 sensor per unit. Changed units result logging
Michiel Broek <mbroek@mbse.eu>
parents: 33
diff changeset
482
495b7eafbf5a Temporary white splash screen. Select DS18B20 sensor per unit. Changed units result logging
Michiel Broek <mbroek@mbse.eu>
parents: 33
diff changeset
483
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
484 /**
043ae27633f8 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 * @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
486 * @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
487 * @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
488 */
043ae27633f8 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 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
490 {
29
106464d4c727 Dutch translation on the screens.
Michiel Broek <mbroek@mbse.eu>
parents: 28
diff changeset
491 screen_top("Meter %d setup", no + 1);
33
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
492 menu_line(sub == 0, 1, 25, "Werking %s", units[no].mode ? "Aan":"Uit");
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
493 menu_line(sub == 1, 1, 37, "Nulpunt %d", units[no].pressure_zero);
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
494 menu_line(sub == 2, 1, 49, "DS18B20 %s", units[no].temperature_rom_code);
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
495 menu_line(sub == 3, 1, 61, "Terug");
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
496 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
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
41
d327e0aff62f Updated doxygen comments. Removed some development debug logs. Increased user inactivity time to 4 minutes. More Dutch translations in the OTA update screens.
Michiel Broek <mbroek@mbse.eu>
parents: 38
diff changeset
501 /**
d327e0aff62f Updated doxygen comments. Removed some development debug logs. Increased user inactivity time to 4 minutes. More Dutch translations in the OTA update screens.
Michiel Broek <mbroek@mbse.eu>
parents: 38
diff changeset
502 * @brief The WiFi overview screen.
d327e0aff62f Updated doxygen comments. Removed some development debug logs. Increased user inactivity time to 4 minutes. More Dutch translations in the OTA update screens.
Michiel Broek <mbroek@mbse.eu>
parents: 38
diff changeset
503 */
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
504 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
505 {
043ae27633f8 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 char buf[65];
30
8b630bf52092 Shorter lock times.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
507 int8_t rssi = 0;
8b630bf52092 Shorter lock times.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
508 bool online = false;
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
509
24
64078aa15512 Finished the editor using the rotary switch. Added editing of the MQTT server parameters.
Michiel Broek <mbroek@mbse.eu>
parents: 23
diff changeset
510 if (xSemaphoreTake(xSemaphoreWiFi, 25) == pdTRUE) {
64078aa15512 Finished the editor using the rotary switch. Added editing of the MQTT server parameters.
Michiel Broek <mbroek@mbse.eu>
parents: 23
diff changeset
511 snprintf(buf, 65, "SSID %s", wifi_state->STA_ssid);
30
8b630bf52092 Shorter lock times.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
512 rssi = wifi_state->STA_rssi;
8b630bf52092 Shorter lock times.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
513 online = wifi_state->STA_online;
24
64078aa15512 Finished the editor using the rotary switch. Added editing of the MQTT server parameters.
Michiel Broek <mbroek@mbse.eu>
parents: 23
diff changeset
514 xSemaphoreGive(xSemaphoreWiFi);
64078aa15512 Finished the editor using the rotary switch. Added editing of the MQTT server parameters.
Michiel Broek <mbroek@mbse.eu>
parents: 23
diff changeset
515 } else {
64078aa15512 Finished the editor using the rotary switch. Added editing of the MQTT server parameters.
Michiel Broek <mbroek@mbse.eu>
parents: 23
diff changeset
516 ESP_LOGE(TAG, "screen_wifi() lock error");
64078aa15512 Finished the editor using the rotary switch. Added editing of the MQTT server parameters.
Michiel Broek <mbroek@mbse.eu>
parents: 23
diff changeset
517 }
30
8b630bf52092 Shorter lock times.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
518
8b630bf52092 Shorter lock times.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
519 screen_top("WiFi Status");
8b630bf52092 Shorter lock times.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
520 u8g2_DrawStr(&u8g2, 1, 28, buf);
8b630bf52092 Shorter lock times.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
521 snprintf(buf, 65, "RSSI %d", rssi);
8b630bf52092 Shorter lock times.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
522 u8g2_DrawStr(&u8g2, 1, 43, buf);
8b630bf52092 Shorter lock times.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
523 snprintf(buf, 65, "Verbonden %s", online ? "Ja":"Nee");
8b630bf52092 Shorter lock times.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
524 u8g2_DrawStr(&u8g2, 1, 59, buf);
8b630bf52092 Shorter lock times.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
525 u8g2_SendBuffer(&u8g2);
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
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
043ae27633f8 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
41
d327e0aff62f Updated doxygen comments. Removed some development debug logs. Increased user inactivity time to 4 minutes. More Dutch translations in the OTA update screens.
Michiel Broek <mbroek@mbse.eu>
parents: 38
diff changeset
530 /**
d327e0aff62f Updated doxygen comments. Removed some development debug logs. Increased user inactivity time to 4 minutes. More Dutch translations in the OTA update screens.
Michiel Broek <mbroek@mbse.eu>
parents: 38
diff changeset
531 * @brief The WiFi setup menu.
d327e0aff62f Updated doxygen comments. Removed some development debug logs. Increased user inactivity time to 4 minutes. More Dutch translations in the OTA update screens.
Michiel Broek <mbroek@mbse.eu>
parents: 38
diff changeset
532 * @param sub The submenu entry to hilite.
d327e0aff62f Updated doxygen comments. Removed some development debug logs. Increased user inactivity time to 4 minutes. More Dutch translations in the OTA update screens.
Michiel Broek <mbroek@mbse.eu>
parents: 38
diff changeset
533 */
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
534 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
535 {
32
7717ac1d2f7f Added WiFi list configured APs. Added offset to the menu rotary for large menus.
Michiel Broek <mbroek@mbse.eu>
parents: 30
diff changeset
536 screen_top("WiFi AP setup");
33
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
537 menu_line(sub == 0, 1, 25, "Lijst AP");
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
538 menu_line(sub == 1, 1, 37, "Nieuw AP");
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
539 menu_line(sub == 2, 1, 49, "Terug");
32
7717ac1d2f7f Added WiFi list configured APs. Added offset to the menu rotary for large menus.
Michiel Broek <mbroek@mbse.eu>
parents: 30
diff changeset
540 u8g2_SendBuffer(&u8g2);
7717ac1d2f7f Added WiFi list configured APs. Added offset to the menu rotary for large menus.
Michiel Broek <mbroek@mbse.eu>
parents: 30
diff changeset
541 }
7717ac1d2f7f Added WiFi list configured APs. Added offset to the menu rotary for large menus.
Michiel Broek <mbroek@mbse.eu>
parents: 30
diff changeset
542
7717ac1d2f7f Added WiFi list configured APs. Added offset to the menu rotary for large menus.
Michiel Broek <mbroek@mbse.eu>
parents: 30
diff changeset
543
7717ac1d2f7f Added WiFi list configured APs. Added offset to the menu rotary for large menus.
Michiel Broek <mbroek@mbse.eu>
parents: 30
diff changeset
544
41
d327e0aff62f Updated doxygen comments. Removed some development debug logs. Increased user inactivity time to 4 minutes. More Dutch translations in the OTA update screens.
Michiel Broek <mbroek@mbse.eu>
parents: 38
diff changeset
545 /**
d327e0aff62f Updated doxygen comments. Removed some development debug logs. Increased user inactivity time to 4 minutes. More Dutch translations in the OTA update screens.
Michiel Broek <mbroek@mbse.eu>
parents: 38
diff changeset
546 * @brief Show the list if WiFi Access Points.
d327e0aff62f Updated doxygen comments. Removed some development debug logs. Increased user inactivity time to 4 minutes. More Dutch translations in the OTA update screens.
Michiel Broek <mbroek@mbse.eu>
parents: 38
diff changeset
547 * @param sub The sub entry line.
d327e0aff62f Updated doxygen comments. Removed some development debug logs. Increased user inactivity time to 4 minutes. More Dutch translations in the OTA update screens.
Michiel Broek <mbroek@mbse.eu>
parents: 38
diff changeset
548 * @param offset The offset in the list.
d327e0aff62f Updated doxygen comments. Removed some development debug logs. Increased user inactivity time to 4 minutes. More Dutch translations in the OTA update screens.
Michiel Broek <mbroek@mbse.eu>
parents: 38
diff changeset
549 */
32
7717ac1d2f7f Added WiFi list configured APs. Added offset to the menu rotary for large menus.
Michiel Broek <mbroek@mbse.eu>
parents: 30
diff changeset
550 void screen_list_aps(int sub, int offset)
7717ac1d2f7f Added WiFi list configured APs. Added offset to the menu rotary for large menus.
Michiel Broek <mbroek@mbse.eu>
parents: 30
diff changeset
551 {
7717ac1d2f7f Added WiFi list configured APs. Added offset to the menu rotary for large menus.
Michiel Broek <mbroek@mbse.eu>
parents: 30
diff changeset
552 int i;
7717ac1d2f7f Added WiFi list configured APs. Added offset to the menu rotary for large menus.
Michiel Broek <mbroek@mbse.eu>
parents: 30
diff changeset
553 struct strStations ap;
7717ac1d2f7f Added WiFi list configured APs. Added offset to the menu rotary for large menus.
Michiel Broek <mbroek@mbse.eu>
parents: 30
diff changeset
554 uint8_t *dst = (uint8_t *)&ap;
7717ac1d2f7f Added WiFi list configured APs. Added offset to the menu rotary for large menus.
Michiel Broek <mbroek@mbse.eu>
parents: 30
diff changeset
555 FILE *f;
7717ac1d2f7f Added WiFi list configured APs. Added offset to the menu rotary for large menus.
Michiel Broek <mbroek@mbse.eu>
parents: 30
diff changeset
556 size_t bytes;
7717ac1d2f7f Added WiFi list configured APs. Added offset to the menu rotary for large menus.
Michiel Broek <mbroek@mbse.eu>
parents: 30
diff changeset
557
7717ac1d2f7f Added WiFi list configured APs. Added offset to the menu rotary for large menus.
Michiel Broek <mbroek@mbse.eu>
parents: 30
diff changeset
558 num_ssids = 0;
7717ac1d2f7f Added WiFi list configured APs. Added offset to the menu rotary for large menus.
Michiel Broek <mbroek@mbse.eu>
parents: 30
diff changeset
559 memset(dst, 0, sizeof(ap));
7717ac1d2f7f Added WiFi list configured APs. Added offset to the menu rotary for large menus.
Michiel Broek <mbroek@mbse.eu>
parents: 30
diff changeset
560 f = fopen("/spiffs/etc/stations.conf", "r+");
7717ac1d2f7f Added WiFi list configured APs. Added offset to the menu rotary for large menus.
Michiel Broek <mbroek@mbse.eu>
parents: 30
diff changeset
561 if (f) {
7717ac1d2f7f Added WiFi list configured APs. Added offset to the menu rotary for large menus.
Michiel Broek <mbroek@mbse.eu>
parents: 30
diff changeset
562 while (1) {
7717ac1d2f7f Added WiFi list configured APs. Added offset to the menu rotary for large menus.
Michiel Broek <mbroek@mbse.eu>
parents: 30
diff changeset
563 bytes = fread(dst, 1, sizeof(ap), f);
7717ac1d2f7f Added WiFi list configured APs. Added offset to the menu rotary for large menus.
Michiel Broek <mbroek@mbse.eu>
parents: 30
diff changeset
564 if (bytes < sizeof(ap)) {
7717ac1d2f7f Added WiFi list configured APs. Added offset to the menu rotary for large menus.
Michiel Broek <mbroek@mbse.eu>
parents: 30
diff changeset
565 fclose(f);
7717ac1d2f7f Added WiFi list configured APs. Added offset to the menu rotary for large menus.
Michiel Broek <mbroek@mbse.eu>
parents: 30
diff changeset
566 break;
7717ac1d2f7f Added WiFi list configured APs. Added offset to the menu rotary for large menus.
Michiel Broek <mbroek@mbse.eu>
parents: 30
diff changeset
567 }
33
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
568 memcpy(APs[num_ssids].SSID, ap.SSID, 32);
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
569 memcpy(APs[num_ssids].Password, ap.Password, 64);
32
7717ac1d2f7f Added WiFi list configured APs. Added offset to the menu rotary for large menus.
Michiel Broek <mbroek@mbse.eu>
parents: 30
diff changeset
570 num_ssids++;
7717ac1d2f7f Added WiFi list configured APs. Added offset to the menu rotary for large menus.
Michiel Broek <mbroek@mbse.eu>
parents: 30
diff changeset
571 }
7717ac1d2f7f Added WiFi list configured APs. Added offset to the menu rotary for large menus.
Michiel Broek <mbroek@mbse.eu>
parents: 30
diff changeset
572 }
7717ac1d2f7f Added WiFi list configured APs. Added offset to the menu rotary for large menus.
Michiel Broek <mbroek@mbse.eu>
parents: 30
diff changeset
573
7717ac1d2f7f Added WiFi list configured APs. Added offset to the menu rotary for large menus.
Michiel Broek <mbroek@mbse.eu>
parents: 30
diff changeset
574 screen_top("WiFi AP lijst");
7717ac1d2f7f Added WiFi list configured APs. Added offset to the menu rotary for large menus.
Michiel Broek <mbroek@mbse.eu>
parents: 30
diff changeset
575 if (num_ssids == 0) {
7717ac1d2f7f Added WiFi list configured APs. Added offset to the menu rotary for large menus.
Michiel Broek <mbroek@mbse.eu>
parents: 30
diff changeset
576 menu_line(0, 1, 25, "Geen AP's");
7717ac1d2f7f Added WiFi list configured APs. Added offset to the menu rotary for large menus.
Michiel Broek <mbroek@mbse.eu>
parents: 30
diff changeset
577 } else {
7717ac1d2f7f Added WiFi list configured APs. Added offset to the menu rotary for large menus.
Michiel Broek <mbroek@mbse.eu>
parents: 30
diff changeset
578 for (i = 0; i < num_ssids; i++) {
33
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
579 menu_line(sub == i, 1, 25 + (i * 12), APs[i + offset].SSID);
32
7717ac1d2f7f Added WiFi list configured APs. Added offset to the menu rotary for large menus.
Michiel Broek <mbroek@mbse.eu>
parents: 30
diff changeset
580 if (i == 3)
7717ac1d2f7f Added WiFi list configured APs. Added offset to the menu rotary for large menus.
Michiel Broek <mbroek@mbse.eu>
parents: 30
diff changeset
581 break;
7717ac1d2f7f Added WiFi list configured APs. Added offset to the menu rotary for large menus.
Michiel Broek <mbroek@mbse.eu>
parents: 30
diff changeset
582 }
33
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
583 if ((i + offset) == num_ssids)
32
7717ac1d2f7f Added WiFi list configured APs. Added offset to the menu rotary for large menus.
Michiel Broek <mbroek@mbse.eu>
parents: 30
diff changeset
584 menu_line(sub == i, 1, 25 + (i * 12), "Terug");
7717ac1d2f7f Added WiFi list configured APs. Added offset to the menu rotary for large menus.
Michiel Broek <mbroek@mbse.eu>
parents: 30
diff changeset
585 }
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
586 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
587 }
043ae27633f8 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
043ae27633f8 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
41
d327e0aff62f Updated doxygen comments. Removed some development debug logs. Increased user inactivity time to 4 minutes. More Dutch translations in the OTA update screens.
Michiel Broek <mbroek@mbse.eu>
parents: 38
diff changeset
591 /**
d327e0aff62f Updated doxygen comments. Removed some development debug logs. Increased user inactivity time to 4 minutes. More Dutch translations in the OTA update screens.
Michiel Broek <mbroek@mbse.eu>
parents: 38
diff changeset
592 * @brief Edit WiFi AP menu.
d327e0aff62f Updated doxygen comments. Removed some development debug logs. Increased user inactivity time to 4 minutes. More Dutch translations in the OTA update screens.
Michiel Broek <mbroek@mbse.eu>
parents: 38
diff changeset
593 * @param sub The menu entry to hilite.
d327e0aff62f Updated doxygen comments. Removed some development debug logs. Increased user inactivity time to 4 minutes. More Dutch translations in the OTA update screens.
Michiel Broek <mbroek@mbse.eu>
parents: 38
diff changeset
594 */
33
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
595 void screen_edit_ap(int sub)
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
596 {
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
597 screen_top("WiFi wijzig AP");
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
598 menu_line(sub == 0, 1, 25, "SSID %s", editAP.SSID);
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
599 menu_line(sub == 1, 1, 37, "PSK %s", editAP.Password);
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
600 menu_line(sub == 2, 1, 49, "Opslaan");
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
601 if (edit_ssid >= 0) {
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
602 menu_line(sub == 3, 1, 61, "Verwijder");
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
603 }
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
604 u8g2_SendBuffer(&u8g2);
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
605 }
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
606
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
607
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
608
41
d327e0aff62f Updated doxygen comments. Removed some development debug logs. Increased user inactivity time to 4 minutes. More Dutch translations in the OTA update screens.
Michiel Broek <mbroek@mbse.eu>
parents: 38
diff changeset
609 /**
d327e0aff62f Updated doxygen comments. Removed some development debug logs. Increased user inactivity time to 4 minutes. More Dutch translations in the OTA update screens.
Michiel Broek <mbroek@mbse.eu>
parents: 38
diff changeset
610 * @brief The network status screen.
d327e0aff62f Updated doxygen comments. Removed some development debug logs. Increased user inactivity time to 4 minutes. More Dutch translations in the OTA update screens.
Michiel Broek <mbroek@mbse.eu>
parents: 38
diff changeset
611 */
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
612 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
613 {
30
8b630bf52092 Shorter lock times.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
614 char ip[17], nm[17], gw[17];
8b630bf52092 Shorter lock times.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
615
26
8a3696620c0a Increaded stacksize for the user process. Implemented the network update using the proven brewboard code. Reverted the lock release and display sendbuffer lines to the previous code. The networks status screen uses the wifi lock.
Michiel Broek <mbroek@mbse.eu>
parents: 25
diff changeset
616 if (xSemaphoreTake(xSemaphoreWiFi, 25) == pdTRUE) {
30
8b630bf52092 Shorter lock times.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
617 strcpy(ip, wifi_state->STA_ip);
8b630bf52092 Shorter lock times.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
618 strcpy(nm, wifi_state->STA_nm);
8b630bf52092 Shorter lock times.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
619 strcpy(gw, wifi_state->STA_gw);
26
8a3696620c0a Increaded stacksize for the user process. Implemented the network update using the proven brewboard code. Reverted the lock release and display sendbuffer lines to the previous code. The networks status screen uses the wifi lock.
Michiel Broek <mbroek@mbse.eu>
parents: 25
diff changeset
620 xSemaphoreGive(xSemaphoreWiFi);
8a3696620c0a Increaded stacksize for the user process. Implemented the network update using the proven brewboard code. Reverted the lock release and display sendbuffer lines to the previous code. The networks status screen uses the wifi lock.
Michiel Broek <mbroek@mbse.eu>
parents: 25
diff changeset
621 } else {
8a3696620c0a Increaded stacksize for the user process. Implemented the network update using the proven brewboard code. Reverted the lock release and display sendbuffer lines to the previous code. The networks status screen uses the wifi lock.
Michiel Broek <mbroek@mbse.eu>
parents: 25
diff changeset
622 ESP_LOGE(TAG, "screen_network() lock error");
8a3696620c0a Increaded stacksize for the user process. Implemented the network update using the proven brewboard code. Reverted the lock release and display sendbuffer lines to the previous code. The networks status screen uses the wifi lock.
Michiel Broek <mbroek@mbse.eu>
parents: 25
diff changeset
623 }
30
8b630bf52092 Shorter lock times.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
624
8b630bf52092 Shorter lock times.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
625 screen_top("Netwerk Status");
8b630bf52092 Shorter lock times.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
626 menu_line(0, 1, 25, "IP %s", ip);
8b630bf52092 Shorter lock times.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
627 menu_line(0, 1, 37, "Mask %s", nm);
8b630bf52092 Shorter lock times.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
628 menu_line(0, 1, 49, "GW %s", gw);
8b630bf52092 Shorter lock times.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
629 menu_line(0, 1, 61, "Naam %s", config.hostname);
8b630bf52092 Shorter lock times.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
630 u8g2_SendBuffer(&u8g2);
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
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
41
d327e0aff62f Updated doxygen comments. Removed some development debug logs. Increased user inactivity time to 4 minutes. More Dutch translations in the OTA update screens.
Michiel Broek <mbroek@mbse.eu>
parents: 38
diff changeset
635 /**
d327e0aff62f Updated doxygen comments. Removed some development debug logs. Increased user inactivity time to 4 minutes. More Dutch translations in the OTA update screens.
Michiel Broek <mbroek@mbse.eu>
parents: 38
diff changeset
636 * @brief The network setup menu.
d327e0aff62f Updated doxygen comments. Removed some development debug logs. Increased user inactivity time to 4 minutes. More Dutch translations in the OTA update screens.
Michiel Broek <mbroek@mbse.eu>
parents: 38
diff changeset
637 * @param sub The menu entry to hilite.
d327e0aff62f Updated doxygen comments. Removed some development debug logs. Increased user inactivity time to 4 minutes. More Dutch translations in the OTA update screens.
Michiel Broek <mbroek@mbse.eu>
parents: 38
diff changeset
638 */
25
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
639 void screen_network_setup(int sub)
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
640 {
29
106464d4c727 Dutch translation on the screens.
Michiel Broek <mbroek@mbse.eu>
parents: 28
diff changeset
641 screen_top("Netwerk setup");
33
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
642 menu_line(sub == 0, 1, 25, "Naam %s", config.hostname);
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
643 menu_line(sub == 1, 1, 37, "NTP %s", config.ntp_server);
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
644 menu_line(sub == 2, 1, 49, "Terug");
25
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
645 u8g2_SendBuffer(&u8g2);
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
646 }
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
647
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
648
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
649
41
d327e0aff62f Updated doxygen comments. Removed some development debug logs. Increased user inactivity time to 4 minutes. More Dutch translations in the OTA update screens.
Michiel Broek <mbroek@mbse.eu>
parents: 38
diff changeset
650 /**
d327e0aff62f Updated doxygen comments. Removed some development debug logs. Increased user inactivity time to 4 minutes. More Dutch translations in the OTA update screens.
Michiel Broek <mbroek@mbse.eu>
parents: 38
diff changeset
651 * @brief MQTT status
d327e0aff62f Updated doxygen comments. Removed some development debug logs. Increased user inactivity time to 4 minutes. More Dutch translations in the OTA update screens.
Michiel Broek <mbroek@mbse.eu>
parents: 38
diff changeset
652 */
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
653 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
654 {
043ae27633f8 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 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
656 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
657 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
658 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
659 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
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
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
41
d327e0aff62f Updated doxygen comments. Removed some development debug logs. Increased user inactivity time to 4 minutes. More Dutch translations in the OTA update screens.
Michiel Broek <mbroek@mbse.eu>
parents: 38
diff changeset
664 /**
d327e0aff62f Updated doxygen comments. Removed some development debug logs. Increased user inactivity time to 4 minutes. More Dutch translations in the OTA update screens.
Michiel Broek <mbroek@mbse.eu>
parents: 38
diff changeset
665 * @brief MQTT setup menu.
d327e0aff62f Updated doxygen comments. Removed some development debug logs. Increased user inactivity time to 4 minutes. More Dutch translations in the OTA update screens.
Michiel Broek <mbroek@mbse.eu>
parents: 38
diff changeset
666 * @param sub The submenu entry to hilite.
d327e0aff62f Updated doxygen comments. Removed some development debug logs. Increased user inactivity time to 4 minutes. More Dutch translations in the OTA update screens.
Michiel Broek <mbroek@mbse.eu>
parents: 38
diff changeset
667 */
24
64078aa15512 Finished the editor using the rotary switch. Added editing of the MQTT server parameters.
Michiel Broek <mbroek@mbse.eu>
parents: 23
diff changeset
668 void screen_mqtt_setup(int sub)
64078aa15512 Finished the editor using the rotary switch. Added editing of the MQTT server parameters.
Michiel Broek <mbroek@mbse.eu>
parents: 23
diff changeset
669 {
64078aa15512 Finished the editor using the rotary switch. Added editing of the MQTT server parameters.
Michiel Broek <mbroek@mbse.eu>
parents: 23
diff changeset
670 screen_top("MQTT Setup");
33
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
671 menu_line(sub == 0, 1, 25, "serv %s", config.mqtt_server);
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
672 menu_line(sub == 1, 1, 37, "port %d", config.mqtt_port);
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
673 menu_line(sub == 2, 1, 49, "user %s", config.mqtt_user);
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
674 menu_line(sub == 3, 1, 61, "Terug");
24
64078aa15512 Finished the editor using the rotary switch. Added editing of the MQTT server parameters.
Michiel Broek <mbroek@mbse.eu>
parents: 23
diff changeset
675 u8g2_SendBuffer(&u8g2);
64078aa15512 Finished the editor using the rotary switch. Added editing of the MQTT server parameters.
Michiel Broek <mbroek@mbse.eu>
parents: 23
diff changeset
676 }
64078aa15512 Finished the editor using the rotary switch. Added editing of the MQTT server parameters.
Michiel Broek <mbroek@mbse.eu>
parents: 23
diff changeset
677
64078aa15512 Finished the editor using the rotary switch. Added editing of the MQTT server parameters.
Michiel Broek <mbroek@mbse.eu>
parents: 23
diff changeset
678
64078aa15512 Finished the editor using the rotary switch. Added editing of the MQTT server parameters.
Michiel Broek <mbroek@mbse.eu>
parents: 23
diff changeset
679
41
d327e0aff62f Updated doxygen comments. Removed some development debug logs. Increased user inactivity time to 4 minutes. More Dutch translations in the OTA update screens.
Michiel Broek <mbroek@mbse.eu>
parents: 38
diff changeset
680 /**
d327e0aff62f Updated doxygen comments. Removed some development debug logs. Increased user inactivity time to 4 minutes. More Dutch translations in the OTA update screens.
Michiel Broek <mbroek@mbse.eu>
parents: 38
diff changeset
681 * @brief The OTA update menu.
d327e0aff62f Updated doxygen comments. Removed some development debug logs. Increased user inactivity time to 4 minutes. More Dutch translations in the OTA update screens.
Michiel Broek <mbroek@mbse.eu>
parents: 38
diff changeset
682 */
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
683 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
684 {
29
106464d4c727 Dutch translation on the screens.
Michiel Broek <mbroek@mbse.eu>
parents: 28
diff changeset
685 screen_top("Update software");
106464d4c727 Dutch translation on the screens.
Michiel Broek <mbroek@mbse.eu>
parents: 28
diff changeset
686 menu_line(0, 1, 43, "Druk voor update");
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
687 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
688 }
043ae27633f8 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
043ae27633f8 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
41
d327e0aff62f Updated doxygen comments. Removed some development debug logs. Increased user inactivity time to 4 minutes. More Dutch translations in the OTA update screens.
Michiel Broek <mbroek@mbse.eu>
parents: 38
diff changeset
692 /**
d327e0aff62f Updated doxygen comments. Removed some development debug logs. Increased user inactivity time to 4 minutes. More Dutch translations in the OTA update screens.
Michiel Broek <mbroek@mbse.eu>
parents: 38
diff changeset
693 * @brief The update status screen.
d327e0aff62f Updated doxygen comments. Removed some development debug logs. Increased user inactivity time to 4 minutes. More Dutch translations in the OTA update screens.
Michiel Broek <mbroek@mbse.eu>
parents: 38
diff changeset
694 * @param m1 The first message line or NULL.
d327e0aff62f Updated doxygen comments. Removed some development debug logs. Increased user inactivity time to 4 minutes. More Dutch translations in the OTA update screens.
Michiel Broek <mbroek@mbse.eu>
parents: 38
diff changeset
695 * @param m2 The second message line or NULL.
d327e0aff62f Updated doxygen comments. Removed some development debug logs. Increased user inactivity time to 4 minutes. More Dutch translations in the OTA update screens.
Michiel Broek <mbroek@mbse.eu>
parents: 38
diff changeset
696 */
26
8a3696620c0a Increaded stacksize for the user process. Implemented the network update using the proven brewboard code. Reverted the lock release and display sendbuffer lines to the previous code. The networks status screen uses the wifi lock.
Michiel Broek <mbroek@mbse.eu>
parents: 25
diff changeset
697 void screen_updating(char *m1, char *m2)
8a3696620c0a Increaded stacksize for the user process. Implemented the network update using the proven brewboard code. Reverted the lock release and display sendbuffer lines to the previous code. The networks status screen uses the wifi lock.
Michiel Broek <mbroek@mbse.eu>
parents: 25
diff changeset
698 {
29
106464d4c727 Dutch translation on the screens.
Michiel Broek <mbroek@mbse.eu>
parents: 28
diff changeset
699 screen_top("Bijwerken ...");
26
8a3696620c0a Increaded stacksize for the user process. Implemented the network update using the proven brewboard code. Reverted the lock release and display sendbuffer lines to the previous code. The networks status screen uses the wifi lock.
Michiel Broek <mbroek@mbse.eu>
parents: 25
diff changeset
700 u8g2_SetFont(&u8g2, u8g2_font_unifont_t_symbols);
8a3696620c0a Increaded stacksize for the user process. Implemented the network update using the proven brewboard code. Reverted the lock release and display sendbuffer lines to the previous code. The networks status screen uses the wifi lock.
Michiel Broek <mbroek@mbse.eu>
parents: 25
diff changeset
701 if (m1) {
8a3696620c0a Increaded stacksize for the user process. Implemented the network update using the proven brewboard code. Reverted the lock release and display sendbuffer lines to the previous code. The networks status screen uses the wifi lock.
Michiel Broek <mbroek@mbse.eu>
parents: 25
diff changeset
702 u8g2_DrawUTF8(&u8g2,2,30, m1);
8a3696620c0a Increaded stacksize for the user process. Implemented the network update using the proven brewboard code. Reverted the lock release and display sendbuffer lines to the previous code. The networks status screen uses the wifi lock.
Michiel Broek <mbroek@mbse.eu>
parents: 25
diff changeset
703 }
8a3696620c0a Increaded stacksize for the user process. Implemented the network update using the proven brewboard code. Reverted the lock release and display sendbuffer lines to the previous code. The networks status screen uses the wifi lock.
Michiel Broek <mbroek@mbse.eu>
parents: 25
diff changeset
704 if (m2) {
8a3696620c0a Increaded stacksize for the user process. Implemented the network update using the proven brewboard code. Reverted the lock release and display sendbuffer lines to the previous code. The networks status screen uses the wifi lock.
Michiel Broek <mbroek@mbse.eu>
parents: 25
diff changeset
705 u8g2_DrawUTF8(&u8g2,2,55, m2);
8a3696620c0a Increaded stacksize for the user process. Implemented the network update using the proven brewboard code. Reverted the lock release and display sendbuffer lines to the previous code. The networks status screen uses the wifi lock.
Michiel Broek <mbroek@mbse.eu>
parents: 25
diff changeset
706 }
8a3696620c0a Increaded stacksize for the user process. Implemented the network update using the proven brewboard code. Reverted the lock release and display sendbuffer lines to the previous code. The networks status screen uses the wifi lock.
Michiel Broek <mbroek@mbse.eu>
parents: 25
diff changeset
707 u8g2_SendBuffer(&u8g2);
8a3696620c0a Increaded stacksize for the user process. Implemented the network update using the proven brewboard code. Reverted the lock release and display sendbuffer lines to the previous code. The networks status screen uses the wifi lock.
Michiel Broek <mbroek@mbse.eu>
parents: 25
diff changeset
708 }
8a3696620c0a Increaded stacksize for the user process. Implemented the network update using the proven brewboard code. Reverted the lock release and display sendbuffer lines to the previous code. The networks status screen uses the wifi lock.
Michiel Broek <mbroek@mbse.eu>
parents: 25
diff changeset
709
8a3696620c0a Increaded stacksize for the user process. Implemented the network update using the proven brewboard code. Reverted the lock release and display sendbuffer lines to the previous code. The networks status screen uses the wifi lock.
Michiel Broek <mbroek@mbse.eu>
parents: 25
diff changeset
710
8a3696620c0a Increaded stacksize for the user process. Implemented the network update using the proven brewboard code. Reverted the lock release and display sendbuffer lines to the previous code. The networks status screen uses the wifi lock.
Michiel Broek <mbroek@mbse.eu>
parents: 25
diff changeset
711
52
90a36619b07b Added screen with software error counters.
Michiel Broek <mbroek@mbse.eu>
parents: 51
diff changeset
712 /*
90a36619b07b Added screen with software error counters.
Michiel Broek <mbroek@mbse.eu>
parents: 51
diff changeset
713 * @brief The counters display screen.
90a36619b07b Added screen with software error counters.
Michiel Broek <mbroek@mbse.eu>
parents: 51
diff changeset
714 */
90a36619b07b Added screen with software error counters.
Michiel Broek <mbroek@mbse.eu>
parents: 51
diff changeset
715 void screen_counters()
90a36619b07b Added screen with software error counters.
Michiel Broek <mbroek@mbse.eu>
parents: 51
diff changeset
716 {
55
43362bb8f3c0 Added DS18B20 error counters. Bigger font for the error counters screen and added the DS18B20 counter. Patched the u8g2_esp32_hal to fix the sudden system reboots.
Michiel Broek <mbroek@mbse.eu>
parents: 54
diff changeset
717 char buf[65];
43362bb8f3c0 Added DS18B20 error counters. Bigger font for the error counters screen and added the DS18B20 counter. Patched the u8g2_esp32_hal to fix the sudden system reboots.
Michiel Broek <mbroek@mbse.eu>
parents: 54
diff changeset
718
43362bb8f3c0 Added DS18B20 error counters. Bigger font for the error counters screen and added the DS18B20 counter. Patched the u8g2_esp32_hal to fix the sudden system reboots.
Michiel Broek <mbroek@mbse.eu>
parents: 54
diff changeset
719 screen_top("Software fouten");
43362bb8f3c0 Added DS18B20 error counters. Bigger font for the error counters screen and added the DS18B20 counter. Patched the u8g2_esp32_hal to fix the sudden system reboots.
Michiel Broek <mbroek@mbse.eu>
parents: 54
diff changeset
720 snprintf(buf, 64, "Network %4d", err_connect);
43362bb8f3c0 Added DS18B20 error counters. Bigger font for the error counters screen and added the DS18B20 counter. Patched the u8g2_esp32_hal to fix the sudden system reboots.
Michiel Broek <mbroek@mbse.eu>
parents: 54
diff changeset
721 u8g2_DrawStr(&u8g2, 1, 28, buf);
43362bb8f3c0 Added DS18B20 error counters. Bigger font for the error counters screen and added the DS18B20 counter. Patched the u8g2_esp32_hal to fix the sudden system reboots.
Michiel Broek <mbroek@mbse.eu>
parents: 54
diff changeset
722 snprintf(buf, 64, "Watchdog %4d", err_alarm);
43362bb8f3c0 Added DS18B20 error counters. Bigger font for the error counters screen and added the DS18B20 counter. Patched the u8g2_esp32_hal to fix the sudden system reboots.
Michiel Broek <mbroek@mbse.eu>
parents: 54
diff changeset
723 u8g2_DrawStr(&u8g2, 1, 43, buf);
43362bb8f3c0 Added DS18B20 error counters. Bigger font for the error counters screen and added the DS18B20 counter. Patched the u8g2_esp32_hal to fix the sudden system reboots.
Michiel Broek <mbroek@mbse.eu>
parents: 54
diff changeset
724 snprintf(buf, 64, "DS18B20 %4d", err_temp);
43362bb8f3c0 Added DS18B20 error counters. Bigger font for the error counters screen and added the DS18B20 counter. Patched the u8g2_esp32_hal to fix the sudden system reboots.
Michiel Broek <mbroek@mbse.eu>
parents: 54
diff changeset
725 u8g2_DrawStr(&u8g2, 1, 59, buf);
52
90a36619b07b Added screen with software error counters.
Michiel Broek <mbroek@mbse.eu>
parents: 51
diff changeset
726 u8g2_SendBuffer(&u8g2);
90a36619b07b Added screen with software error counters.
Michiel Broek <mbroek@mbse.eu>
parents: 51
diff changeset
727 }
90a36619b07b Added screen with software error counters.
Michiel Broek <mbroek@mbse.eu>
parents: 51
diff changeset
728
90a36619b07b Added screen with software error counters.
Michiel Broek <mbroek@mbse.eu>
parents: 51
diff changeset
729
90a36619b07b Added screen with software error counters.
Michiel Broek <mbroek@mbse.eu>
parents: 51
diff changeset
730
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
731 /**
043ae27633f8 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 * @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
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 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
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 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
737 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
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
043ae27633f8 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
043ae27633f8 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 /**
043ae27633f8 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 * @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
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 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
746 {
043ae27633f8 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 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
748 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
749
043ae27633f8 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 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
751 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
752 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
753 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
754 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
755 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
756 } 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
757 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
758 ESP_LOGI(TAG, "GPIO rotary button intr, val: %d time: %d", gpio_get_level(io_num), PushDuration);
38
46e2c385e9de Removed all the deepsleep code since there will be no battery operation.
Michiel Broek <mbroek@mbse.eu>
parents: 37
diff changeset
759 if (! user_busy()) {
46e2c385e9de Removed all the deepsleep code since there will be no battery operation.
Michiel Broek <mbroek@mbse.eu>
parents: 37
diff changeset
760 xEventGroupSetBits(xEventGroupUser, TASK_USER_WAKEUP);
46e2c385e9de Removed all the deepsleep code since there will be no battery operation.
Michiel Broek <mbroek@mbse.eu>
parents: 37
diff changeset
761 }
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
762 }
043ae27633f8 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 } 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
764 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
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 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
767 }
043ae27633f8 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 }
043ae27633f8 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 }
043ae27633f8 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
043ae27633f8 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
043ae27633f8 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 /**
043ae27633f8 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 * @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
775 * @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
776 * @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
777 * @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
778 */
043ae27633f8 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 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
780 {
043ae27633f8 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 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
782 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
783 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
784 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
785 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
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
043ae27633f8 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 /**
043ae27633f8 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 * @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
792 * @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
793 * @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
794 * @param cursub The subscreen number by reference. This is updated with the new number.
44
e52d11b8f252 Removed dead code. Added more doxygen documentation.
Michiel Broek <mbroek@mbse.eu>
parents: 43
diff changeset
795 * @param curoffset The offset in the list. This is updated with the new number.
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
796 * @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
797 */
32
7717ac1d2f7f Added WiFi list configured APs. Added offset to the menu rotary for large menus.
Michiel Broek <mbroek@mbse.eu>
parents: 30
diff changeset
798 bool rotate_to_sub(rotary_encoder_position_t pos, int max, int *cursub, int *curoffset)
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
799 {
32
7717ac1d2f7f Added WiFi list configured APs. Added offset to the menu rotary for large menus.
Michiel Broek <mbroek@mbse.eu>
parents: 30
diff changeset
800 int sub = *cursub;
7717ac1d2f7f Added WiFi list configured APs. Added offset to the menu rotary for large menus.
Michiel Broek <mbroek@mbse.eu>
parents: 30
diff changeset
801 int offset = *curoffset;
7717ac1d2f7f Added WiFi list configured APs. Added offset to the menu rotary for large menus.
Michiel Broek <mbroek@mbse.eu>
parents: 30
diff changeset
802 bool rc = false;
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
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 (pos > 0) {
32
7717ac1d2f7f Added WiFi list configured APs. Added offset to the menu rotary for large menus.
Michiel Broek <mbroek@mbse.eu>
parents: 30
diff changeset
805 if ((sub + offset) < max) {
7717ac1d2f7f Added WiFi list configured APs. Added offset to the menu rotary for large menus.
Michiel Broek <mbroek@mbse.eu>
parents: 30
diff changeset
806 if (sub < 3) {
7717ac1d2f7f Added WiFi list configured APs. Added offset to the menu rotary for large menus.
Michiel Broek <mbroek@mbse.eu>
parents: 30
diff changeset
807 sub++;
7717ac1d2f7f Added WiFi list configured APs. Added offset to the menu rotary for large menus.
Michiel Broek <mbroek@mbse.eu>
parents: 30
diff changeset
808 } else {
7717ac1d2f7f Added WiFi list configured APs. Added offset to the menu rotary for large menus.
Michiel Broek <mbroek@mbse.eu>
parents: 30
diff changeset
809 offset++;
7717ac1d2f7f Added WiFi list configured APs. Added offset to the menu rotary for large menus.
Michiel Broek <mbroek@mbse.eu>
parents: 30
diff changeset
810 }
7717ac1d2f7f Added WiFi list configured APs. Added offset to the menu rotary for large menus.
Michiel Broek <mbroek@mbse.eu>
parents: 30
diff changeset
811 } else {
7717ac1d2f7f Added WiFi list configured APs. Added offset to the menu rotary for large menus.
Michiel Broek <mbroek@mbse.eu>
parents: 30
diff changeset
812 sub = offset = 0;
7717ac1d2f7f Added WiFi list configured APs. Added offset to the menu rotary for large menus.
Michiel Broek <mbroek@mbse.eu>
parents: 30
diff changeset
813 }
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
814 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
815 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
816 } else if (pos < 0) {
32
7717ac1d2f7f Added WiFi list configured APs. Added offset to the menu rotary for large menus.
Michiel Broek <mbroek@mbse.eu>
parents: 30
diff changeset
817 if ((sub + offset) > 0) {
7717ac1d2f7f Added WiFi list configured APs. Added offset to the menu rotary for large menus.
Michiel Broek <mbroek@mbse.eu>
parents: 30
diff changeset
818 if (offset > 0) {
7717ac1d2f7f Added WiFi list configured APs. Added offset to the menu rotary for large menus.
Michiel Broek <mbroek@mbse.eu>
parents: 30
diff changeset
819 offset--;
7717ac1d2f7f Added WiFi list configured APs. Added offset to the menu rotary for large menus.
Michiel Broek <mbroek@mbse.eu>
parents: 30
diff changeset
820 } else {
7717ac1d2f7f Added WiFi list configured APs. Added offset to the menu rotary for large menus.
Michiel Broek <mbroek@mbse.eu>
parents: 30
diff changeset
821 sub--;
7717ac1d2f7f Added WiFi list configured APs. Added offset to the menu rotary for large menus.
Michiel Broek <mbroek@mbse.eu>
parents: 30
diff changeset
822 }
7717ac1d2f7f Added WiFi list configured APs. Added offset to the menu rotary for large menus.
Michiel Broek <mbroek@mbse.eu>
parents: 30
diff changeset
823 } else {
7717ac1d2f7f Added WiFi list configured APs. Added offset to the menu rotary for large menus.
Michiel Broek <mbroek@mbse.eu>
parents: 30
diff changeset
824 if (max > 3) {
7717ac1d2f7f Added WiFi list configured APs. Added offset to the menu rotary for large menus.
Michiel Broek <mbroek@mbse.eu>
parents: 30
diff changeset
825 offset = max - 3;
7717ac1d2f7f Added WiFi list configured APs. Added offset to the menu rotary for large menus.
Michiel Broek <mbroek@mbse.eu>
parents: 30
diff changeset
826 sub = 3;
7717ac1d2f7f Added WiFi list configured APs. Added offset to the menu rotary for large menus.
Michiel Broek <mbroek@mbse.eu>
parents: 30
diff changeset
827 } else {
7717ac1d2f7f Added WiFi list configured APs. Added offset to the menu rotary for large menus.
Michiel Broek <mbroek@mbse.eu>
parents: 30
diff changeset
828 sub = max;
7717ac1d2f7f Added WiFi list configured APs. Added offset to the menu rotary for large menus.
Michiel Broek <mbroek@mbse.eu>
parents: 30
diff changeset
829 offset = 0;
7717ac1d2f7f Added WiFi list configured APs. Added offset to the menu rotary for large menus.
Michiel Broek <mbroek@mbse.eu>
parents: 30
diff changeset
830 }
7717ac1d2f7f Added WiFi list configured APs. Added offset to the menu rotary for large menus.
Michiel Broek <mbroek@mbse.eu>
parents: 30
diff changeset
831 }
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
832 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
833 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
834 }
043ae27633f8 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
043ae27633f8 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 *cursub = sub;
32
7717ac1d2f7f Added WiFi list configured APs. Added offset to the menu rotary for large menus.
Michiel Broek <mbroek@mbse.eu>
parents: 30
diff changeset
837 *curoffset = offset;
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
838 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
839 }
043ae27633f8 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
043ae27633f8 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
41
d327e0aff62f Updated doxygen comments. Removed some development debug logs. Increased user inactivity time to 4 minutes. More Dutch translations in the OTA update screens.
Michiel Broek <mbroek@mbse.eu>
parents: 38
diff changeset
843 /**
d327e0aff62f Updated doxygen comments. Removed some development debug logs. Increased user inactivity time to 4 minutes. More Dutch translations in the OTA update screens.
Michiel Broek <mbroek@mbse.eu>
parents: 38
diff changeset
844 * @brief Handle menu changes.
d327e0aff62f Updated doxygen comments. Removed some development debug logs. Increased user inactivity time to 4 minutes. More Dutch translations in the OTA update screens.
Michiel Broek <mbroek@mbse.eu>
parents: 38
diff changeset
845 */
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
846 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
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 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
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 Main_Loop2 = New_Loop2;
25
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
851 switch (Main_Loop2) {
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
852 case ML2_INIT:
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
853 ESP_LOGI(TAG, "Loop user: Init");
43
70c99c2084dc Version 0.2.1. When wakeup by user push, select the active unit screen if only one unit is active.
Michiel Broek <mbroek@mbse.eu>
parents: 42
diff changeset
854 New_Loop2 = -1;
70c99c2084dc Version 0.2.1. When wakeup by user push, select the active unit screen if only one unit is active.
Michiel Broek <mbroek@mbse.eu>
parents: 42
diff changeset
855 if (xSemaphoreTake(xSemaphoreUnits, 25) == pdTRUE) {
70c99c2084dc Version 0.2.1. When wakeup by user push, select the active unit screen if only one unit is active.
Michiel Broek <mbroek@mbse.eu>
parents: 42
diff changeset
856 for (int i = 0; i < 3; i++) {
70c99c2084dc Version 0.2.1. When wakeup by user push, select the active unit screen if only one unit is active.
Michiel Broek <mbroek@mbse.eu>
parents: 42
diff changeset
857 if (units[i].mode) {
70c99c2084dc Version 0.2.1. When wakeup by user push, select the active unit screen if only one unit is active.
Michiel Broek <mbroek@mbse.eu>
parents: 42
diff changeset
858 if (New_Loop2 == -1) { // Not selected yet
70c99c2084dc Version 0.2.1. When wakeup by user push, select the active unit screen if only one unit is active.
Michiel Broek <mbroek@mbse.eu>
parents: 42
diff changeset
859 New_Loop2 = i;
70c99c2084dc Version 0.2.1. When wakeup by user push, select the active unit screen if only one unit is active.
Michiel Broek <mbroek@mbse.eu>
parents: 42
diff changeset
860 } else if (New_Loop2 >= 0) { // One selected
70c99c2084dc Version 0.2.1. When wakeup by user push, select the active unit screen if only one unit is active.
Michiel Broek <mbroek@mbse.eu>
parents: 42
diff changeset
861 New_Loop2 = -2;
70c99c2084dc Version 0.2.1. When wakeup by user push, select the active unit screen if only one unit is active.
Michiel Broek <mbroek@mbse.eu>
parents: 42
diff changeset
862 break; // Multiple units are active
70c99c2084dc Version 0.2.1. When wakeup by user push, select the active unit screen if only one unit is active.
Michiel Broek <mbroek@mbse.eu>
parents: 42
diff changeset
863 }
70c99c2084dc Version 0.2.1. When wakeup by user push, select the active unit screen if only one unit is active.
Michiel Broek <mbroek@mbse.eu>
parents: 42
diff changeset
864 }
70c99c2084dc Version 0.2.1. When wakeup by user push, select the active unit screen if only one unit is active.
Michiel Broek <mbroek@mbse.eu>
parents: 42
diff changeset
865 }
70c99c2084dc Version 0.2.1. When wakeup by user push, select the active unit screen if only one unit is active.
Michiel Broek <mbroek@mbse.eu>
parents: 42
diff changeset
866 xSemaphoreGive(xSemaphoreUnits);
70c99c2084dc Version 0.2.1. When wakeup by user push, select the active unit screen if only one unit is active.
Michiel Broek <mbroek@mbse.eu>
parents: 42
diff changeset
867 } else {
70c99c2084dc Version 0.2.1. When wakeup by user push, select the active unit screen if only one unit is active.
Michiel Broek <mbroek@mbse.eu>
parents: 42
diff changeset
868 ESP_LOGE(TAG, "menu_change() ML2_INIT lock");
70c99c2084dc Version 0.2.1. When wakeup by user push, select the active unit screen if only one unit is active.
Michiel Broek <mbroek@mbse.eu>
parents: 42
diff changeset
869 }
70c99c2084dc Version 0.2.1. When wakeup by user push, select the active unit screen if only one unit is active.
Michiel Broek <mbroek@mbse.eu>
parents: 42
diff changeset
870 if (New_Loop2 < 0)
70c99c2084dc Version 0.2.1. When wakeup by user push, select the active unit screen if only one unit is active.
Michiel Broek <mbroek@mbse.eu>
parents: 42
diff changeset
871 New_Loop2 = ML2_USER;
70c99c2084dc Version 0.2.1. When wakeup by user push, select the active unit screen if only one unit is active.
Michiel Broek <mbroek@mbse.eu>
parents: 42
diff changeset
872 else
70c99c2084dc Version 0.2.1. When wakeup by user push, select the active unit screen if only one unit is active.
Michiel Broek <mbroek@mbse.eu>
parents: 42
diff changeset
873 New_Loop2 += ML2_UNIT1;
25
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
874 break;
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
875
25
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
876 case ML2_USER:
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
877 screen_main();
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
878 break;
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
879
25
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
880 case ML2_UNIT1:
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
881 case ML2_UNIT2:
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
882 case ML2_UNIT3:
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
883 screen_unit(Main_Loop2 - ML2_UNIT1);
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
884 break;
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
885
25
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
886 case ML2_WIFI:
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
887 screen_wifi();
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
888 break;
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
889
32
7717ac1d2f7f Added WiFi list configured APs. Added offset to the menu rotary for large menus.
Michiel Broek <mbroek@mbse.eu>
parents: 30
diff changeset
890 case ML2_SETUP_WIFI:
7717ac1d2f7f Added WiFi list configured APs. Added offset to the menu rotary for large menus.
Michiel Broek <mbroek@mbse.eu>
parents: 30
diff changeset
891 ESP_LOGI(TAG, "Loop user: WiFi setup");
7717ac1d2f7f Added WiFi list configured APs. Added offset to the menu rotary for large menus.
Michiel Broek <mbroek@mbse.eu>
parents: 30
diff changeset
892 screen_wifi_setup(SubMenu);
7717ac1d2f7f Added WiFi list configured APs. Added offset to the menu rotary for large menus.
Michiel Broek <mbroek@mbse.eu>
parents: 30
diff changeset
893 break;
7717ac1d2f7f Added WiFi list configured APs. Added offset to the menu rotary for large menus.
Michiel Broek <mbroek@mbse.eu>
parents: 30
diff changeset
894
7717ac1d2f7f Added WiFi list configured APs. Added offset to the menu rotary for large menus.
Michiel Broek <mbroek@mbse.eu>
parents: 30
diff changeset
895 case ML2_LIST_APS:
7717ac1d2f7f Added WiFi list configured APs. Added offset to the menu rotary for large menus.
Michiel Broek <mbroek@mbse.eu>
parents: 30
diff changeset
896 ESP_LOGI(TAG, "Loop user: WiFi list APs");
7717ac1d2f7f Added WiFi list configured APs. Added offset to the menu rotary for large menus.
Michiel Broek <mbroek@mbse.eu>
parents: 30
diff changeset
897 SubMenu = SubOffset = 0;
7717ac1d2f7f Added WiFi list configured APs. Added offset to the menu rotary for large menus.
Michiel Broek <mbroek@mbse.eu>
parents: 30
diff changeset
898 screen_list_aps(SubMenu, SubOffset);
7717ac1d2f7f Added WiFi list configured APs. Added offset to the menu rotary for large menus.
Michiel Broek <mbroek@mbse.eu>
parents: 30
diff changeset
899 break;
7717ac1d2f7f Added WiFi list configured APs. Added offset to the menu rotary for large menus.
Michiel Broek <mbroek@mbse.eu>
parents: 30
diff changeset
900
33
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
901 case ML2_EDIT_AP:
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
902 ESP_LOGI(TAG, "Loop user: WiFi edit AP");
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
903 screen_edit_ap(0);
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
904 break;
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
905
25
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
906 case ML2_NETWORK:
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
907 screen_network();
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
908 break;
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
909
25
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
910 case ML2_SETUP_NETWORK:
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
911 ESP_LOGI(TAG, "Loop user: Network setup");
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
912 screen_network_setup(SubMenu);
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
913 break;
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
914
25
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
915 case ML2_MQTT:
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
916 screen_mqtt();
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
917 break;
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
918
25
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
919 case ML2_SETUP_MQTT:
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
920 ESP_LOGI(TAG, "Loop user: MQTT setup");
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
921 screen_mqtt_setup(SubMenu);
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
922 break;
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
923
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
924 case ML2_UPDATE:
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
925 screen_update();
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
926 break;
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
927
52
90a36619b07b Added screen with software error counters.
Michiel Broek <mbroek@mbse.eu>
parents: 51
diff changeset
928 case ML2_COUNTERS:
90a36619b07b Added screen with software error counters.
Michiel Broek <mbroek@mbse.eu>
parents: 51
diff changeset
929 screen_counters();
90a36619b07b Added screen with software error counters.
Michiel Broek <mbroek@mbse.eu>
parents: 51
diff changeset
930 break;
90a36619b07b Added screen with software error counters.
Michiel Broek <mbroek@mbse.eu>
parents: 51
diff changeset
931
25
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
932 case ML2_SETUP_UNIT1:
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
933 case ML2_SETUP_UNIT2:
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
934 case ML2_SETUP_UNIT3:
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
935 ESP_LOGI(TAG, "Loop user: Setup Unit %d", Main_Loop2 - ML2_SETUP_UNIT1);
32
7717ac1d2f7f Added WiFi list configured APs. Added offset to the menu rotary for large menus.
Michiel Broek <mbroek@mbse.eu>
parents: 30
diff changeset
936 SubMenu = SubOffset = 0;
25
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
937 screen_unit_setup(Main_Loop2 - ML2_SETUP_UNIT1, SubMenu);
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
938 break;
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
939
25
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
940 case ML2_ZERO_UNIT1:
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
941 case ML2_ZERO_UNIT2:
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
942 case ML2_ZERO_UNIT3:
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
943 ESP_LOGI(TAG, "Loop user: Zero Unit %d", Main_Loop2 - ML2_ZERO_UNIT1);
32
7717ac1d2f7f Added WiFi list configured APs. Added offset to the menu rotary for large menus.
Michiel Broek <mbroek@mbse.eu>
parents: 30
diff changeset
944 SubMenu = SubOffset = 0;
25
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
945 screen_unit_zero(Main_Loop2 - ML2_ZERO_UNIT1, SubMenu);
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
946 break;
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
947
34
495b7eafbf5a Temporary white splash screen. Select DS18B20 sensor per unit. Changed units result logging
Michiel Broek <mbroek@mbse.eu>
parents: 33
diff changeset
948 case ML2_SEL_SENSOR1:
495b7eafbf5a Temporary white splash screen. Select DS18B20 sensor per unit. Changed units result logging
Michiel Broek <mbroek@mbse.eu>
parents: 33
diff changeset
949 case ML2_SEL_SENSOR2:
495b7eafbf5a Temporary white splash screen. Select DS18B20 sensor per unit. Changed units result logging
Michiel Broek <mbroek@mbse.eu>
parents: 33
diff changeset
950 case ML2_SEL_SENSOR3:
495b7eafbf5a Temporary white splash screen. Select DS18B20 sensor per unit. Changed units result logging
Michiel Broek <mbroek@mbse.eu>
parents: 33
diff changeset
951 ESP_LOGI(TAG, "Loop user: Select sensor %d", Main_Loop2 - ML2_SEL_SENSOR1);
495b7eafbf5a Temporary white splash screen. Select DS18B20 sensor per unit. Changed units result logging
Michiel Broek <mbroek@mbse.eu>
parents: 33
diff changeset
952 SubMenu = SubOffset = 0;
495b7eafbf5a Temporary white splash screen. Select DS18B20 sensor per unit. Changed units result logging
Michiel Broek <mbroek@mbse.eu>
parents: 33
diff changeset
953 screen_list_sensors(Main_Loop2 - ML2_SEL_SENSOR1, SubMenu, SubOffset);
495b7eafbf5a Temporary white splash screen. Select DS18B20 sensor per unit. Changed units result logging
Michiel Broek <mbroek@mbse.eu>
parents: 33
diff changeset
954 break;
495b7eafbf5a Temporary white splash screen. Select DS18B20 sensor per unit. Changed units result logging
Michiel Broek <mbroek@mbse.eu>
parents: 33
diff changeset
955
25
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
956 case ML2_INACTIVE:
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
957 ESP_LOGI(TAG, "Loop user: Inactive");
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
958 u8g2_SetPowerSave(&u8g2, 1); // powersave display
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
959 New_Loop2 = ML2_DONE;
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
960 break;
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
961
25
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
962 default:
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
963 break;
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
964 }
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
965 }
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
966 }
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
967
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
968
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
969
41
d327e0aff62f Updated doxygen comments. Removed some development debug logs. Increased user inactivity time to 4 minutes. More Dutch translations in the OTA update screens.
Michiel Broek <mbroek@mbse.eu>
parents: 38
diff changeset
970 /**
d327e0aff62f Updated doxygen comments. Removed some development debug logs. Increased user inactivity time to 4 minutes. More Dutch translations in the OTA update screens.
Michiel Broek <mbroek@mbse.eu>
parents: 38
diff changeset
971 * @brief Handle rotary switch for menu navigation.
d327e0aff62f Updated doxygen comments. Removed some development debug logs. Increased user inactivity time to 4 minutes. More Dutch translations in the OTA update screens.
Michiel Broek <mbroek@mbse.eu>
parents: 38
diff changeset
972 */
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
973 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
974 {
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
975 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
976 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
977 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
978 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
979 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
980 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
981 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
982 case ML2_MQTT: rotate_to_menu(event.state.position, ML2_UPDATE, ML2_NETWORK); break;
52
90a36619b07b Added screen with software error counters.
Michiel Broek <mbroek@mbse.eu>
parents: 51
diff changeset
983 case ML2_UPDATE: rotate_to_menu(event.state.position, ML2_COUNTERS, ML2_MQTT); break;
90a36619b07b Added screen with software error counters.
Michiel Broek <mbroek@mbse.eu>
parents: 51
diff changeset
984 case ML2_COUNTERS: rotate_to_menu(event.state.position, ML2_COUNTERS, ML2_UPDATE); break;
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
985 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
986 case ML2_SETUP_UNIT2:
32
7717ac1d2f7f Added WiFi list configured APs. Added offset to the menu rotary for large menus.
Michiel Broek <mbroek@mbse.eu>
parents: 30
diff changeset
987 case ML2_SETUP_UNIT3: if (rotate_to_sub(event.state.position, 3, &SubMenu, &SubOffset))
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
988 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
989 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
990 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
991 case ML2_ZERO_UNIT2:
32
7717ac1d2f7f Added WiFi list configured APs. Added offset to the menu rotary for large menus.
Michiel Broek <mbroek@mbse.eu>
parents: 30
diff changeset
992 case ML2_ZERO_UNIT3: if (rotate_to_sub(event.state.position, 1, &SubMenu, &SubOffset))
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
993 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
994 break;
34
495b7eafbf5a Temporary white splash screen. Select DS18B20 sensor per unit. Changed units result logging
Michiel Broek <mbroek@mbse.eu>
parents: 33
diff changeset
995 case ML2_SEL_SENSOR1:
495b7eafbf5a Temporary white splash screen. Select DS18B20 sensor per unit. Changed units result logging
Michiel Broek <mbroek@mbse.eu>
parents: 33
diff changeset
996 case ML2_SEL_SENSOR2:
495b7eafbf5a Temporary white splash screen. Select DS18B20 sensor per unit. Changed units result logging
Michiel Broek <mbroek@mbse.eu>
parents: 33
diff changeset
997 case ML2_SEL_SENSOR3: if (rotate_to_sub(event.state.position, num_sensors, &SubMenu, &SubOffset))
495b7eafbf5a Temporary white splash screen. Select DS18B20 sensor per unit. Changed units result logging
Michiel Broek <mbroek@mbse.eu>
parents: 33
diff changeset
998 screen_list_sensors(Main_Loop2 - ML2_SEL_SENSOR1, SubMenu, SubOffset);
495b7eafbf5a Temporary white splash screen. Select DS18B20 sensor per unit. Changed units result logging
Michiel Broek <mbroek@mbse.eu>
parents: 33
diff changeset
999 break;
32
7717ac1d2f7f Added WiFi list configured APs. Added offset to the menu rotary for large menus.
Michiel Broek <mbroek@mbse.eu>
parents: 30
diff changeset
1000 case ML2_SETUP_WIFI: if (rotate_to_sub(event.state.position, 2, &SubMenu, &SubOffset))
7717ac1d2f7f Added WiFi list configured APs. Added offset to the menu rotary for large menus.
Michiel Broek <mbroek@mbse.eu>
parents: 30
diff changeset
1001 screen_wifi_setup(SubMenu);
7717ac1d2f7f Added WiFi list configured APs. Added offset to the menu rotary for large menus.
Michiel Broek <mbroek@mbse.eu>
parents: 30
diff changeset
1002 break;
7717ac1d2f7f Added WiFi list configured APs. Added offset to the menu rotary for large menus.
Michiel Broek <mbroek@mbse.eu>
parents: 30
diff changeset
1003 case ML2_LIST_APS: if (rotate_to_sub(event.state.position, num_ssids, &SubMenu, &SubOffset))
7717ac1d2f7f Added WiFi list configured APs. Added offset to the menu rotary for large menus.
Michiel Broek <mbroek@mbse.eu>
parents: 30
diff changeset
1004 screen_list_aps(SubMenu, SubOffset);
7717ac1d2f7f Added WiFi list configured APs. Added offset to the menu rotary for large menus.
Michiel Broek <mbroek@mbse.eu>
parents: 30
diff changeset
1005 break;
33
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
1006 case ML2_EDIT_AP: if (edit_ssid < 0) {
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
1007 if (rotate_to_sub(event.state.position, 2, &SubMenu, &SubOffset))
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
1008 screen_edit_ap(SubMenu);
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
1009 } else {
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
1010 if (rotate_to_sub(event.state.position, 3, &SubMenu, &SubOffset))
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
1011 screen_edit_ap(SubMenu);
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
1012 }
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
1013 break;
32
7717ac1d2f7f Added WiFi list configured APs. Added offset to the menu rotary for large menus.
Michiel Broek <mbroek@mbse.eu>
parents: 30
diff changeset
1014 case ML2_SETUP_MQTT: if (rotate_to_sub(event.state.position, 3, &SubMenu, &SubOffset))
24
64078aa15512 Finished the editor using the rotary switch. Added editing of the MQTT server parameters.
Michiel Broek <mbroek@mbse.eu>
parents: 23
diff changeset
1015 screen_mqtt_setup(SubMenu);
64078aa15512 Finished the editor using the rotary switch. Added editing of the MQTT server parameters.
Michiel Broek <mbroek@mbse.eu>
parents: 23
diff changeset
1016 break;
32
7717ac1d2f7f Added WiFi list configured APs. Added offset to the menu rotary for large menus.
Michiel Broek <mbroek@mbse.eu>
parents: 30
diff changeset
1017 case ML2_SETUP_NETWORK: if (rotate_to_sub(event.state.position, 2, &SubMenu, &SubOffset))
25
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
1018 screen_network_setup(SubMenu);
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
1019 break;
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
1020 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
1021 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
1022 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
1023 }
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1024 }
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1025
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1026
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1027
22
cceb36fd3a2a Better update of the user screens. Added more internal documentation.
Michiel Broek <mbroek@mbse.eu>
parents: 21
diff changeset
1028 /*
cceb36fd3a2a Better update of the user screens. Added more internal documentation.
Michiel Broek <mbroek@mbse.eu>
parents: 21
diff changeset
1029 * Refresh screens that are in focus. Called by the main measurement loop.
cceb36fd3a2a Better update of the user screens. Added more internal documentation.
Michiel Broek <mbroek@mbse.eu>
parents: 21
diff changeset
1030 */
cceb36fd3a2a Better update of the user screens. Added more internal documentation.
Michiel Broek <mbroek@mbse.eu>
parents: 21
diff changeset
1031 void user_refresh(void)
cceb36fd3a2a Better update of the user screens. Added more internal documentation.
Michiel Broek <mbroek@mbse.eu>
parents: 21
diff changeset
1032 {
30
8b630bf52092 Shorter lock times.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
1033 if (UserTimer)
8b630bf52092 Shorter lock times.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
1034 xEventGroupSetBits(xEventGroupUser, TASK_USER_REFRESH);
22
cceb36fd3a2a Better update of the user screens. Added more internal documentation.
Michiel Broek <mbroek@mbse.eu>
parents: 21
diff changeset
1035 }
cceb36fd3a2a Better update of the user screens. Added more internal documentation.
Michiel Broek <mbroek@mbse.eu>
parents: 21
diff changeset
1036
cceb36fd3a2a Better update of the user screens. Added more internal documentation.
Michiel Broek <mbroek@mbse.eu>
parents: 21
diff changeset
1037
cceb36fd3a2a Better update of the user screens. Added more internal documentation.
Michiel Broek <mbroek@mbse.eu>
parents: 21
diff changeset
1038
41
d327e0aff62f Updated doxygen comments. Removed some development debug logs. Increased user inactivity time to 4 minutes. More Dutch translations in the OTA update screens.
Michiel Broek <mbroek@mbse.eu>
parents: 38
diff changeset
1039 /**
d327e0aff62f Updated doxygen comments. Removed some development debug logs. Increased user inactivity time to 4 minutes. More Dutch translations in the OTA update screens.
Michiel Broek <mbroek@mbse.eu>
parents: 38
diff changeset
1040 * @brief Pressed keys actions
d327e0aff62f Updated doxygen comments. Removed some development debug logs. Increased user inactivity time to 4 minutes. More Dutch translations in the OTA update screens.
Michiel Broek <mbroek@mbse.eu>
parents: 38
diff changeset
1041 */
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
1042 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
1043 {
24
64078aa15512 Finished the editor using the rotary switch. Added editing of the MQTT server parameters.
Michiel Broek <mbroek@mbse.eu>
parents: 23
diff changeset
1044 int idx = 0;
64078aa15512 Finished the editor using the rotary switch. Added editing of the MQTT server parameters.
Michiel Broek <mbroek@mbse.eu>
parents: 23
diff changeset
1045 char txt[32];
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
1046
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1047 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
1048 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
1049 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
1050 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
1051 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
1052 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
1053
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1054 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
1055 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
1056 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
1057 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
1058 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
1059 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
1060 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
1061 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
1062 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
1063 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
1064 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
1065 xSemaphoreGive(xSemaphoreUnits);
24
64078aa15512 Finished the editor using the rotary switch. Added editing of the MQTT server parameters.
Michiel Broek <mbroek@mbse.eu>
parents: 23
diff changeset
1066 } else {
64078aa15512 Finished the editor using the rotary switch. Added editing of the MQTT server parameters.
Michiel Broek <mbroek@mbse.eu>
parents: 23
diff changeset
1067 ESP_LOGE(TAG, "menu_loop() ML2_SETUP_UNIT%d units lock", idx + 1);
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
1068 }
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1069 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
1070 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
1071 Main_Loop1 = ML1_INIT;
34
495b7eafbf5a Temporary white splash screen. Select DS18B20 sensor per unit. Changed units result logging
Michiel Broek <mbroek@mbse.eu>
parents: 33
diff changeset
1072 } else if (SubMenu == 1) {
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
1073 New_Loop2 = ML2_ZERO_UNIT1 + idx;
34
495b7eafbf5a Temporary white splash screen. Select DS18B20 sensor per unit. Changed units result logging
Michiel Broek <mbroek@mbse.eu>
parents: 33
diff changeset
1074 } else if (SubMenu == 2) {
495b7eafbf5a Temporary white splash screen. Select DS18B20 sensor per unit. Changed units result logging
Michiel Broek <mbroek@mbse.eu>
parents: 33
diff changeset
1075 New_Loop2 = ML2_SEL_SENSOR1 + idx;
495b7eafbf5a Temporary white splash screen. Select DS18B20 sensor per unit. Changed units result logging
Michiel Broek <mbroek@mbse.eu>
parents: 33
diff changeset
1076 } else if (SubMenu == 3) {
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
1077 New_Loop2 = ML2_UNIT1 + idx;
34
495b7eafbf5a Temporary white splash screen. Select DS18B20 sensor per unit. Changed units result logging
Michiel Broek <mbroek@mbse.eu>
parents: 33
diff changeset
1078 }
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
1079 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
1080
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1081 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
1082 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
1083 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
1084 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
1085 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
1086 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
1087 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
1088 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
1089 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
1090 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
1091 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
1092 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
1093 xSemaphoreGive(xSemaphoreUnits);
22
cceb36fd3a2a Better update of the user screens. Added more internal documentation.
Michiel Broek <mbroek@mbse.eu>
parents: 21
diff changeset
1094 ESP_LOGI(TAG, "Zero set unit %d, %d mV set %d", idx, adc_state->Pressure[idx].voltage, units[idx].pressure_zero);
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
1095 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
1096 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
1097 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
1098 }
34
495b7eafbf5a Temporary white splash screen. Select DS18B20 sensor per unit. Changed units result logging
Michiel Broek <mbroek@mbse.eu>
parents: 33
diff changeset
1099 } else if (SubMenu == 1) {
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
1100 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
1101 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
1102 }
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1103 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
1104
34
495b7eafbf5a Temporary white splash screen. Select DS18B20 sensor per unit. Changed units result logging
Michiel Broek <mbroek@mbse.eu>
parents: 33
diff changeset
1105 case ML2_SEL_SENSOR1:
495b7eafbf5a Temporary white splash screen. Select DS18B20 sensor per unit. Changed units result logging
Michiel Broek <mbroek@mbse.eu>
parents: 33
diff changeset
1106 case ML2_SEL_SENSOR2:
495b7eafbf5a Temporary white splash screen. Select DS18B20 sensor per unit. Changed units result logging
Michiel Broek <mbroek@mbse.eu>
parents: 33
diff changeset
1107 case ML2_SEL_SENSOR3:
495b7eafbf5a Temporary white splash screen. Select DS18B20 sensor per unit. Changed units result logging
Michiel Broek <mbroek@mbse.eu>
parents: 33
diff changeset
1108 idx = Main_Loop2 - ML2_SEL_SENSOR1;
495b7eafbf5a Temporary white splash screen. Select DS18B20 sensor per unit. Changed units result logging
Michiel Broek <mbroek@mbse.eu>
parents: 33
diff changeset
1109 if ((SubMenu + SubOffset) < num_sensors) {
495b7eafbf5a Temporary white splash screen. Select DS18B20 sensor per unit. Changed units result logging
Michiel Broek <mbroek@mbse.eu>
parents: 33
diff changeset
1110 ESP_LOGI(TAG, "Select sensor %d %s for unit %d", SubMenu + SubOffset, sensors[SubMenu + SubOffset], idx + 1);
36
e2a43e7c4035 Swapped ADC channels 6 and 7. Completed the DS18B20 assign to unit.
Michiel Broek <mbroek@mbse.eu>
parents: 34
diff changeset
1111 if (xSemaphoreTake(xSemaphoreUnits, 25) == pdTRUE) {
e2a43e7c4035 Swapped ADC channels 6 and 7. Completed the DS18B20 assign to unit.
Michiel Broek <mbroek@mbse.eu>
parents: 34
diff changeset
1112 strcpy(units[idx].temperature_rom_code, sensors[SubMenu + SubOffset]);
e2a43e7c4035 Swapped ADC channels 6 and 7. Completed the DS18B20 assign to unit.
Michiel Broek <mbroek@mbse.eu>
parents: 34
diff changeset
1113 write_units();
e2a43e7c4035 Swapped ADC channels 6 and 7. Completed the DS18B20 assign to unit.
Michiel Broek <mbroek@mbse.eu>
parents: 34
diff changeset
1114 xSemaphoreGive(xSemaphoreUnits);
e2a43e7c4035 Swapped ADC channels 6 and 7. Completed the DS18B20 assign to unit.
Michiel Broek <mbroek@mbse.eu>
parents: 34
diff changeset
1115 New_Loop2 = ML2_SETUP_UNIT1 + idx;
e2a43e7c4035 Swapped ADC channels 6 and 7. Completed the DS18B20 assign to unit.
Michiel Broek <mbroek@mbse.eu>
parents: 34
diff changeset
1116 SubMenu = 2;
e2a43e7c4035 Swapped ADC channels 6 and 7. Completed the DS18B20 assign to unit.
Michiel Broek <mbroek@mbse.eu>
parents: 34
diff changeset
1117 SubOffset = 0;
e2a43e7c4035 Swapped ADC channels 6 and 7. Completed the DS18B20 assign to unit.
Michiel Broek <mbroek@mbse.eu>
parents: 34
diff changeset
1118 if (Main_Loop1 == ML1_DONE)
e2a43e7c4035 Swapped ADC channels 6 and 7. Completed the DS18B20 assign to unit.
Michiel Broek <mbroek@mbse.eu>
parents: 34
diff changeset
1119 Main_Loop1 = ML1_INIT;
e2a43e7c4035 Swapped ADC channels 6 and 7. Completed the DS18B20 assign to unit.
Michiel Broek <mbroek@mbse.eu>
parents: 34
diff changeset
1120 } else {
e2a43e7c4035 Swapped ADC channels 6 and 7. Completed the DS18B20 assign to unit.
Michiel Broek <mbroek@mbse.eu>
parents: 34
diff changeset
1121 ESP_LOGE(TAG, "Failed units lock for new romcode");
e2a43e7c4035 Swapped ADC channels 6 and 7. Completed the DS18B20 assign to unit.
Michiel Broek <mbroek@mbse.eu>
parents: 34
diff changeset
1122 }
34
495b7eafbf5a Temporary white splash screen. Select DS18B20 sensor per unit. Changed units result logging
Michiel Broek <mbroek@mbse.eu>
parents: 33
diff changeset
1123 } else {
495b7eafbf5a Temporary white splash screen. Select DS18B20 sensor per unit. Changed units result logging
Michiel Broek <mbroek@mbse.eu>
parents: 33
diff changeset
1124 New_Loop2 = ML2_SETUP_UNIT1 + idx;
495b7eafbf5a Temporary white splash screen. Select DS18B20 sensor per unit. Changed units result logging
Michiel Broek <mbroek@mbse.eu>
parents: 33
diff changeset
1125 SubMenu = 2;
495b7eafbf5a Temporary white splash screen. Select DS18B20 sensor per unit. Changed units result logging
Michiel Broek <mbroek@mbse.eu>
parents: 33
diff changeset
1126 SubOffset = 0;
495b7eafbf5a Temporary white splash screen. Select DS18B20 sensor per unit. Changed units result logging
Michiel Broek <mbroek@mbse.eu>
parents: 33
diff changeset
1127 }
495b7eafbf5a Temporary white splash screen. Select DS18B20 sensor per unit. Changed units result logging
Michiel Broek <mbroek@mbse.eu>
parents: 33
diff changeset
1128 break;
495b7eafbf5a Temporary white splash screen. Select DS18B20 sensor per unit. Changed units result logging
Michiel Broek <mbroek@mbse.eu>
parents: 33
diff changeset
1129
32
7717ac1d2f7f Added WiFi list configured APs. Added offset to the menu rotary for large menus.
Michiel Broek <mbroek@mbse.eu>
parents: 30
diff changeset
1130 case ML2_WIFI:
7717ac1d2f7f Added WiFi list configured APs. Added offset to the menu rotary for large menus.
Michiel Broek <mbroek@mbse.eu>
parents: 30
diff changeset
1131 New_Loop2 = ML2_SETUP_WIFI;
7717ac1d2f7f Added WiFi list configured APs. Added offset to the menu rotary for large menus.
Michiel Broek <mbroek@mbse.eu>
parents: 30
diff changeset
1132 break;
7717ac1d2f7f Added WiFi list configured APs. Added offset to the menu rotary for large menus.
Michiel Broek <mbroek@mbse.eu>
parents: 30
diff changeset
1133
7717ac1d2f7f Added WiFi list configured APs. Added offset to the menu rotary for large menus.
Michiel Broek <mbroek@mbse.eu>
parents: 30
diff changeset
1134 case ML2_SETUP_WIFI:
7717ac1d2f7f Added WiFi list configured APs. Added offset to the menu rotary for large menus.
Michiel Broek <mbroek@mbse.eu>
parents: 30
diff changeset
1135 if (SubMenu == 0) {
7717ac1d2f7f Added WiFi list configured APs. Added offset to the menu rotary for large menus.
Michiel Broek <mbroek@mbse.eu>
parents: 30
diff changeset
1136 New_Loop2 = ML2_LIST_APS;
34
495b7eafbf5a Temporary white splash screen. Select DS18B20 sensor per unit. Changed units result logging
Michiel Broek <mbroek@mbse.eu>
parents: 33
diff changeset
1137 } else if (SubMenu == 1) {
33
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
1138 edit_ssid = -1;
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
1139 editAP.SSID[0] = '\0';
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
1140 editAP.Password[0] = '\0';
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
1141 SubMenu = SubOffset = 0;
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
1142 New_Loop2 = ML2_EDIT_AP;
34
495b7eafbf5a Temporary white splash screen. Select DS18B20 sensor per unit. Changed units result logging
Michiel Broek <mbroek@mbse.eu>
parents: 33
diff changeset
1143 } else if (SubMenu == 2) {
32
7717ac1d2f7f Added WiFi list configured APs. Added offset to the menu rotary for large menus.
Michiel Broek <mbroek@mbse.eu>
parents: 30
diff changeset
1144 New_Loop2 = ML2_WIFI;
7717ac1d2f7f Added WiFi list configured APs. Added offset to the menu rotary for large menus.
Michiel Broek <mbroek@mbse.eu>
parents: 30
diff changeset
1145 }
7717ac1d2f7f Added WiFi list configured APs. Added offset to the menu rotary for large menus.
Michiel Broek <mbroek@mbse.eu>
parents: 30
diff changeset
1146 break;
7717ac1d2f7f Added WiFi list configured APs. Added offset to the menu rotary for large menus.
Michiel Broek <mbroek@mbse.eu>
parents: 30
diff changeset
1147
7717ac1d2f7f Added WiFi list configured APs. Added offset to the menu rotary for large menus.
Michiel Broek <mbroek@mbse.eu>
parents: 30
diff changeset
1148 case ML2_LIST_APS:
7717ac1d2f7f Added WiFi list configured APs. Added offset to the menu rotary for large menus.
Michiel Broek <mbroek@mbse.eu>
parents: 30
diff changeset
1149 if ((SubMenu + SubOffset) < num_ssids) {
33
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
1150 edit_ssid = SubMenu + SubOffset;
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
1151 memcpy(editAP.SSID, APs[edit_ssid].SSID, 32);
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
1152 memcpy(editAP.Password, APs[edit_ssid].Password, 64);
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
1153 SubMenu = SubOffset = 0;
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
1154 New_Loop2 = ML2_EDIT_AP;
32
7717ac1d2f7f Added WiFi list configured APs. Added offset to the menu rotary for large menus.
Michiel Broek <mbroek@mbse.eu>
parents: 30
diff changeset
1155 } else {
7717ac1d2f7f Added WiFi list configured APs. Added offset to the menu rotary for large menus.
Michiel Broek <mbroek@mbse.eu>
parents: 30
diff changeset
1156 New_Loop2 = ML2_SETUP_WIFI;
7717ac1d2f7f Added WiFi list configured APs. Added offset to the menu rotary for large menus.
Michiel Broek <mbroek@mbse.eu>
parents: 30
diff changeset
1157 SubMenu = SubOffset = 0;
7717ac1d2f7f Added WiFi list configured APs. Added offset to the menu rotary for large menus.
Michiel Broek <mbroek@mbse.eu>
parents: 30
diff changeset
1158 }
7717ac1d2f7f Added WiFi list configured APs. Added offset to the menu rotary for large menus.
Michiel Broek <mbroek@mbse.eu>
parents: 30
diff changeset
1159 break;
7717ac1d2f7f Added WiFi list configured APs. Added offset to the menu rotary for large menus.
Michiel Broek <mbroek@mbse.eu>
parents: 30
diff changeset
1160
33
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
1161 case ML2_EDIT_AP:
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
1162 if (SubMenu == 0) {
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
1163 rotary_editer("SSID", editAP.SSID, "", 16, EDIT_TYPE_TEXT);
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
1164 screen_edit_ap(SubMenu);
34
495b7eafbf5a Temporary white splash screen. Select DS18B20 sensor per unit. Changed units result logging
Michiel Broek <mbroek@mbse.eu>
parents: 33
diff changeset
1165 } else if (SubMenu == 1) {
33
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
1166 rotary_editer("PSK", editAP.Password, "", 16, EDIT_TYPE_TEXT);
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
1167 screen_edit_ap(SubMenu);
34
495b7eafbf5a Temporary white splash screen. Select DS18B20 sensor per unit. Changed units result logging
Michiel Broek <mbroek@mbse.eu>
parents: 33
diff changeset
1168 } else if (SubMenu == 2 || SubMenu == 3) {
33
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
1169 update_running = 1; // Block measurements
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
1170 int timeout = 600;
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
1171 if (edit_ssid < 0)
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
1172 New_Loop2 = ML2_SETUP_WIFI;
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
1173 else
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
1174 New_Loop2 = ML2_LIST_APS;
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
1175
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
1176 for (;;) {
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
1177 vTaskDelay(100 / portTICK_PERIOD_MS);
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
1178 if (Main_Loop1 == ML1_DONE)
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
1179 break;
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
1180 if (timeout)
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
1181 timeout--;
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
1182 else {
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
1183 ESP_LOGE(TAG, "Timout request stop");
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
1184 goto saveerr;
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
1185 }
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
1186 }
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
1187 if (edit_ssid >= 0) {
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
1188 ESP_LOGI(TAG, "Remove %s", APs[edit_ssid].SSID);
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
1189 remove_station((uint8_t *)APs[edit_ssid].SSID);
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
1190 }
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
1191 if (SubMenu == 2) {
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
1192 ESP_LOGI(TAG, "Add %s %s", editAP.SSID, editAP.Password);
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
1193 add_station((uint8_t *)editAP.SSID, (uint8_t *)editAP.Password);
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
1194 }
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
1195 }
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
1196 saveerr:
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
1197 update_running = 0;
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
1198 break;
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
1199
25
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
1200 case ML2_NETWORK:
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
1201 New_Loop2 = ML2_SETUP_NETWORK;
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
1202 break;
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
1203
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
1204 case ML2_SETUP_NETWORK:
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
1205 if (SubMenu == 0) {
29
106464d4c727 Dutch translation on the screens.
Michiel Broek <mbroek@mbse.eu>
parents: 28
diff changeset
1206 rotary_editer("Hostnaam", config.hostname, "", 16, EDIT_TYPE_TEXT);
25
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
1207 screen_network_setup(SubMenu);
34
495b7eafbf5a Temporary white splash screen. Select DS18B20 sensor per unit. Changed units result logging
Michiel Broek <mbroek@mbse.eu>
parents: 33
diff changeset
1208 } else if (SubMenu == 1) {
25
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
1209 rotary_editer("NTP server", config.ntp_server, "", 16, EDIT_TYPE_TEXT);
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
1210 screen_network_setup(SubMenu);
34
495b7eafbf5a Temporary white splash screen. Select DS18B20 sensor per unit. Changed units result logging
Michiel Broek <mbroek@mbse.eu>
parents: 33
diff changeset
1211 } else if (SubMenu == 2) {
25
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
1212 ESP_LOGI(TAG, "Hostname `%s`", config.hostname);
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
1213 ESP_LOGI(TAG, "NTP server `%s`", config.ntp_server);
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
1214 write_config();
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
1215 New_Loop2 = ML2_NETWORK;
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
1216 }
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
1217 break;
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
1218
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
1219 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
1220 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
1221 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
1222
24
64078aa15512 Finished the editor using the rotary switch. Added editing of the MQTT server parameters.
Michiel Broek <mbroek@mbse.eu>
parents: 23
diff changeset
1223 case ML2_SETUP_MQTT:
64078aa15512 Finished the editor using the rotary switch. Added editing of the MQTT server parameters.
Michiel Broek <mbroek@mbse.eu>
parents: 23
diff changeset
1224 if (SubMenu == 0) {
64078aa15512 Finished the editor using the rotary switch. Added editing of the MQTT server parameters.
Michiel Broek <mbroek@mbse.eu>
parents: 23
diff changeset
1225 rotary_editer("MQTT server", config.mqtt_server, "", 16, EDIT_TYPE_TEXT);
64078aa15512 Finished the editor using the rotary switch. Added editing of the MQTT server parameters.
Michiel Broek <mbroek@mbse.eu>
parents: 23
diff changeset
1226 screen_mqtt_setup(SubMenu);
34
495b7eafbf5a Temporary white splash screen. Select DS18B20 sensor per unit. Changed units result logging
Michiel Broek <mbroek@mbse.eu>
parents: 33
diff changeset
1227 } else if (SubMenu == 1) {
24
64078aa15512 Finished the editor using the rotary switch. Added editing of the MQTT server parameters.
Michiel Broek <mbroek@mbse.eu>
parents: 23
diff changeset
1228 sprintf(txt, "%d", config.mqtt_port);
64078aa15512 Finished the editor using the rotary switch. Added editing of the MQTT server parameters.
Michiel Broek <mbroek@mbse.eu>
parents: 23
diff changeset
1229 rotary_editer("MQTT server poort", txt, "", 6, EDIT_TYPE_INT);
64078aa15512 Finished the editor using the rotary switch. Added editing of the MQTT server parameters.
Michiel Broek <mbroek@mbse.eu>
parents: 23
diff changeset
1230 config.mqtt_port = atoi(txt);
64078aa15512 Finished the editor using the rotary switch. Added editing of the MQTT server parameters.
Michiel Broek <mbroek@mbse.eu>
parents: 23
diff changeset
1231 screen_mqtt_setup(SubMenu);
34
495b7eafbf5a Temporary white splash screen. Select DS18B20 sensor per unit. Changed units result logging
Michiel Broek <mbroek@mbse.eu>
parents: 33
diff changeset
1232 } else if (SubMenu == 2) {
24
64078aa15512 Finished the editor using the rotary switch. Added editing of the MQTT server parameters.
Michiel Broek <mbroek@mbse.eu>
parents: 23
diff changeset
1233 rotary_editer("MQTT user", config.mqtt_user, "", 16, EDIT_TYPE_TEXT);
64078aa15512 Finished the editor using the rotary switch. Added editing of the MQTT server parameters.
Michiel Broek <mbroek@mbse.eu>
parents: 23
diff changeset
1234 rotary_editer("MQTT password", config.mqtt_pwd, "", 16, EDIT_TYPE_TEXT);
64078aa15512 Finished the editor using the rotary switch. Added editing of the MQTT server parameters.
Michiel Broek <mbroek@mbse.eu>
parents: 23
diff changeset
1235 screen_mqtt_setup(SubMenu);
34
495b7eafbf5a Temporary white splash screen. Select DS18B20 sensor per unit. Changed units result logging
Michiel Broek <mbroek@mbse.eu>
parents: 33
diff changeset
1236 } else if (SubMenu == 3) {
24
64078aa15512 Finished the editor using the rotary switch. Added editing of the MQTT server parameters.
Michiel Broek <mbroek@mbse.eu>
parents: 23
diff changeset
1237 ESP_LOGI(TAG, "mqtt_server %s:%d", config.mqtt_server, config.mqtt_port);
64078aa15512 Finished the editor using the rotary switch. Added editing of the MQTT server parameters.
Michiel Broek <mbroek@mbse.eu>
parents: 23
diff changeset
1238 ESP_LOGI(TAG, "mqtt_user/pass `%s/%s`", config.mqtt_user, config.mqtt_pwd);
64078aa15512 Finished the editor using the rotary switch. Added editing of the MQTT server parameters.
Michiel Broek <mbroek@mbse.eu>
parents: 23
diff changeset
1239 write_config();
64078aa15512 Finished the editor using the rotary switch. Added editing of the MQTT server parameters.
Michiel Broek <mbroek@mbse.eu>
parents: 23
diff changeset
1240 New_Loop2 = ML2_MQTT;
64078aa15512 Finished the editor using the rotary switch. Added editing of the MQTT server parameters.
Michiel Broek <mbroek@mbse.eu>
parents: 23
diff changeset
1241 }
64078aa15512 Finished the editor using the rotary switch. Added editing of the MQTT server parameters.
Michiel Broek <mbroek@mbse.eu>
parents: 23
diff changeset
1242 break;
64078aa15512 Finished the editor using the rotary switch. Added editing of the MQTT server parameters.
Michiel Broek <mbroek@mbse.eu>
parents: 23
diff changeset
1243
26
8a3696620c0a Increaded stacksize for the user process. Implemented the network update using the proven brewboard code. Reverted the lock release and display sendbuffer lines to the previous code. The networks status screen uses the wifi lock.
Michiel Broek <mbroek@mbse.eu>
parents: 25
diff changeset
1244 case ML2_UPDATE:
8a3696620c0a Increaded stacksize for the user process. Implemented the network update using the proven brewboard code. Reverted the lock release and display sendbuffer lines to the previous code. The networks status screen uses the wifi lock.
Michiel Broek <mbroek@mbse.eu>
parents: 25
diff changeset
1245 bin_update();
27
8bb63daa7b46 Increased some lock timeouts. Application CPU speed from 160 to 240 MHz. Added timeout timers to the update process.
Michiel Broek <mbroek@mbse.eu>
parents: 26
diff changeset
1246 screen_update();
26
8a3696620c0a Increaded stacksize for the user process. Implemented the network update using the proven brewboard code. Reverted the lock release and display sendbuffer lines to the previous code. The networks status screen uses the wifi lock.
Michiel Broek <mbroek@mbse.eu>
parents: 25
diff changeset
1247 break;
8a3696620c0a Increaded stacksize for the user process. Implemented the network update using the proven brewboard code. Reverted the lock release and display sendbuffer lines to the previous code. The networks status screen uses the wifi lock.
Michiel Broek <mbroek@mbse.eu>
parents: 25
diff changeset
1248
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
1249 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
1250 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
1251 }
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1252 }
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1253
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1254
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1255
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1256 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
1257 {
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1258 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
1259 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
1260
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1261 /*
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1262 * 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
1263 * 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
1264 */
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1265 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
1266 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
1267 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
1268 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
1269
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1270 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
1271 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
1272 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
1273
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1274 /*
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1275 * 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
1276 * 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
1277 * 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
1278 */
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1279 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
1280 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
1281 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
1282
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1283 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
1284 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
1285 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
1286 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
1287 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
1288
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1289 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
1290 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
1291
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1292 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
1293
37
358bbd5b608e menuconfig settings now work for I2C display setup. Lot's of code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 36
diff changeset
1294 /*
358bbd5b608e menuconfig settings now work for I2C display setup. Lot's of code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 36
diff changeset
1295 * Create a queue for events from the rotary encoder driver.
358bbd5b608e menuconfig settings now work for I2C display setup. Lot's of code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 36
diff changeset
1296 * Tasks can read from this queue to receive up to date position information.
358bbd5b608e menuconfig settings now work for I2C display setup. Lot's of code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 36
diff changeset
1297 */
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
1298 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
1299 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
1300
37
358bbd5b608e menuconfig settings now work for I2C display setup. Lot's of code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 36
diff changeset
1301 /*
358bbd5b608e menuconfig settings now work for I2C display setup. Lot's of code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 36
diff changeset
1302 * Create a one second periodic timer.
358bbd5b608e menuconfig settings now work for I2C display setup. Lot's of code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 36
diff changeset
1303 */
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
1304 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
1305 .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
1306 .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
1307 };
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1308 ESP_ERROR_CHECK(esp_timer_create(&timerSecond, &timerHandle));
37
358bbd5b608e menuconfig settings now work for I2C display setup. Lot's of code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 36
diff changeset
1309 ESP_ERROR_CHECK(esp_timer_start_periodic(timerHandle, 1000000));
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
1310
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1311 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
1312
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1313 /*
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1314 * 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
1315 */
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1316 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
1317
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1318 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
1319
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1320 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
1321 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
1322 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
1323 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
1324 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
1325 }
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1326
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1327 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
1328 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
1329 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
1330 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
1331 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
1332 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
1333 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
1334
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1335 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
1336
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1337 menu_change();
30
8b630bf52092 Shorter lock times.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
1338
8b630bf52092 Shorter lock times.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
1339 if (xEventGroupGetBits(xEventGroupUser) & TASK_USER_REFRESH) {
32
7717ac1d2f7f Added WiFi list configured APs. Added offset to the menu rotary for large menus.
Michiel Broek <mbroek@mbse.eu>
parents: 30
diff changeset
1340 xEventGroupClearBits(xEventGroupUser, TASK_USER_REFRESH);
30
8b630bf52092 Shorter lock times.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
1341 switch (Main_Loop2) {
52
90a36619b07b Added screen with software error counters.
Michiel Broek <mbroek@mbse.eu>
parents: 51
diff changeset
1342 case ML2_USER: screen_main(); break;
90a36619b07b Added screen with software error counters.
Michiel Broek <mbroek@mbse.eu>
parents: 51
diff changeset
1343 case ML2_UNIT1: screen_unit(0); break;
90a36619b07b Added screen with software error counters.
Michiel Broek <mbroek@mbse.eu>
parents: 51
diff changeset
1344 case ML2_UNIT2: screen_unit(1); break;
90a36619b07b Added screen with software error counters.
Michiel Broek <mbroek@mbse.eu>
parents: 51
diff changeset
1345 case ML2_UNIT3: screen_unit(2); break;
90a36619b07b Added screen with software error counters.
Michiel Broek <mbroek@mbse.eu>
parents: 51
diff changeset
1346 case ML2_WIFI: screen_wifi(); break;
90a36619b07b Added screen with software error counters.
Michiel Broek <mbroek@mbse.eu>
parents: 51
diff changeset
1347 case ML2_COUNTERS: screen_counters(); break;
30
8b630bf52092 Shorter lock times.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
1348 }
8b630bf52092 Shorter lock times.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
1349 }
8b630bf52092 Shorter lock times.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
1350
22
cceb36fd3a2a Better update of the user screens. Added more internal documentation.
Michiel Broek <mbroek@mbse.eu>
parents: 21
diff changeset
1351 if (xQueueReceive(event_queue, &event, 100 / portTICK_PERIOD_MS) == pdTRUE) {
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
1352 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
1353 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
1354 }
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1355
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1356 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
1357 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
1358 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
1359 }
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1360 }
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1361
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1362 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
1363 }
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1364 }
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1365 }
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1366

mercurial