main/task_user.c

Tue, 26 Nov 2019 11:20:41 +0100

author
Michiel Broek <mbroek@mbse.eu>
date
Tue, 26 Nov 2019 11:20:41 +0100
changeset 42
22a0f9810561
parent 41
d327e0aff62f
child 43
70c99c2084dc
permissions
-rw-r--r--

In the main screen dim the not active units.

21
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1 /**
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2 * @file task_user.c
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3 * @brief co2meter project.
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4 */
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6 #include "config.h"
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8 static const char *TAG = "task_user";
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11 EventGroupHandle_t xEventGroupUser; ///< Events User task
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12 esp_timer_handle_t timerHandle; ///< Seconds timer
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13 uint32_t SecsCount = 0; ///< Seconds counter
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14 uint32_t UserTimer = 0; ///< User inactive timeout
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
15 int Main_Loop2 = -1; ///< Effective menu
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
16 int New_Loop2 = ML2_INIT; ///< New menu
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
17 int SubMenu = 0; ///< Submenu number
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
18 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
19 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
20 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
21 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
22 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
23 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
24 static int PushDuration = 0; ///< Duration of the pushed button
33
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
25 struct strStations APs[10]; ///< List of APs we know
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
26 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
27 int num_ssids = 0; ///< Number of SSIDs we know
33
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
28 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
29 char sensors[DS18B20_MAX][17]; ///< Sensors to select
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
30
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
31 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
32 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
33 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
34 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
35 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
36 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
37 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
38 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
39 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
40 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
41 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
42 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
43 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
44
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
45 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
46 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
47 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
48 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
49
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
50
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
51 /**
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
52 * @brief Seconds timer callback.
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
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 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
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
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
57 /***************************************************************************/
043ae27633f8 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
043ae27633f8 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 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
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 SecsCount++;
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
64 if ((SecsCount % 60) == 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
65 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
66 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
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
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
69 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
70 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
71 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
72 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
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) {
043ae27633f8 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 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
76 }
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
77 }
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
78
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
79
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
80
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
81 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
82 {
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
83 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
84 }
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
85
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
86
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
87
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
88 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
89 {
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
90 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
91 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
92 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
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
043ae27633f8 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 * @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
99 * @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
100 * @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
101 * @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
102 * @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
103 * @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
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 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
106 {
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
107 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
108 int rc = 0;
23
58a328e91881 Added error logging for failed locks
Michiel Broek <mbroek@mbse.eu>
parents: 22
diff changeset
109 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
110 int8_t descent = u8g2_GetDescent(&u8g2);
23
58a328e91881 Added error logging for failed locks
Michiel Broek <mbroek@mbse.eu>
parents: 22
diff changeset
111 int8_t charheight = u8g2_GetMaxCharHeight(&u8g2);
58a328e91881 Added error logging for failed locks
Michiel Broek <mbroek@mbse.eu>
parents: 22
diff changeset
112 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
113
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 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
115 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
116 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
117
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
118 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
119
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
120 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
121 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
122 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
123 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
124
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 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
126 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
127 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
128 u8g2_DrawHLine(&u8g2, x, y+3, charwidth);
23
58a328e91881 Added error logging for failed locks
Michiel Broek <mbroek@mbse.eu>
parents: 22
diff changeset
129
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
130 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
131 /*
64078aa15512 Finished the editor using the rotary switch. Added editing of the MQTT server parameters.
Michiel Broek <mbroek@mbse.eu>
parents: 23
diff changeset
132 * 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
133 * 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
134 */
64078aa15512 Finished the editor using the rotary switch. Added editing of the MQTT server parameters.
Michiel Broek <mbroek@mbse.eu>
parents: 23
diff changeset
135 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
136 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
137 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
138 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
139 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
140 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
141 } 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
142 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
143 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
144 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
145 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
146 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
147 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
148 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
149 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
150 } 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
151
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
152 } 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
153 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
154 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
155 }
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 }
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 } 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
158 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
159 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
160 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
161 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
162 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
163 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
164 } 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
165 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
166 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
167 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
168 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
169 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
170 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
171 } 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
172
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 } 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
174 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
175 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
176 }
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 }
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
178 }
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
179
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
180 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
181 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
182 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
183 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
184 }
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
185 } 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
186 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
187 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
188 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
189 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
190 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
191 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
192 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
193 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
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 }
043ae27633f8 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 }
043ae27633f8 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_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
198 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
199 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
200 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
201 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
202 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
203
043ae27633f8 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 *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
205 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
206 }
043ae27633f8 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
043ae27633f8 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
043ae27633f8 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 * @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
212 * @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
213 * @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
214 * @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
215 * @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
216 * @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
217 */
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
218 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
219 {
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
220 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
221 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
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 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
224 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
225 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
226 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
227 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
228 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
229
043ae27633f8 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 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
231 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
232 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
233 }
23
58a328e91881 Added error logging for failed locks
Michiel Broek <mbroek@mbse.eu>
parents: 22
diff changeset
234 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
235 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
236 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
237 u8g2_SendBuffer(&u8g2);
23
58a328e91881 Added error logging for failed locks
Michiel Broek <mbroek@mbse.eu>
parents: 22
diff changeset
238 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
239
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
240 /*
64078aa15512 Finished the editor using the rotary switch. Added editing of the MQTT server parameters.
Michiel Broek <mbroek@mbse.eu>
parents: 23
diff changeset
241 * 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
242 */
64078aa15512 Finished the editor using the rotary switch. Added editing of the MQTT server parameters.
Michiel Broek <mbroek@mbse.eu>
parents: 23
diff changeset
243 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
244 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
245 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
246 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
247 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
248 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
249
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 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
251 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
252 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
253 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
254 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
255 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
256 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
257 } 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
258 // 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
259 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
260 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
261 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
262 }
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
263 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
264 } 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
265 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
266 }
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
267 }
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
268 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
269 }
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
270
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
271
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
272
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
273 /**
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
274 * @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
275 * @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
276 * @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
277 * @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
278 * @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
279 */
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
280 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
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 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
283 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
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 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
286 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
287 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
288 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
289
043ae27633f8 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 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
291 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
292 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
293
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
294 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
295 }
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
296
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
297
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
298
043ae27633f8 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 * @brief Clear the display and prepare the top of the display.
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
301 * @format The formatted data to display at the top.
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
302 */
043ae27633f8 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 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
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 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
306 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
307
043ae27633f8 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 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
309 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
310 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
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 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
313 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
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 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
316 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
317 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
318 }
043ae27633f8 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
043ae27633f8 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
043ae27633f8 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 * @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
324 */
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
325 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
326 {
36
e2a43e7c4035 Swapped ADC channels 6 and 7. Completed the DS18B20 assign to unit.
Michiel Broek <mbroek@mbse.eu>
parents: 34
diff changeset
327 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
328
36
e2a43e7c4035 Swapped ADC channels 6 and 7. Completed the DS18B20 assign to unit.
Michiel Broek <mbroek@mbse.eu>
parents: 34
diff changeset
329 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
330 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
331 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
332 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
333 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
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 /**
043ae27633f8 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 * @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
340 */
043ae27633f8 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 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
342 {
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
343 char buf[65];
42
22a0f9810561 In the main screen dim the not active units.
Michiel Broek <mbroek@mbse.eu>
parents: 41
diff changeset
344 int i, mode[3];
30
8b630bf52092 Shorter lock times.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
345 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
346
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
347 if (xSemaphoreTake(xSemaphoreUnits, 25) == pdTRUE) {
30
8b630bf52092 Shorter lock times.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
348 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
349 for (i = 0; i < 3; i++) {
30
8b630bf52092 Shorter lock times.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
350 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
351 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
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 xSemaphoreGive(xSemaphoreUnits);
23
58a328e91881 Added error logging for failed locks
Michiel Broek <mbroek@mbse.eu>
parents: 22
diff changeset
354 } else {
58a328e91881 Added error logging for failed locks
Michiel Broek <mbroek@mbse.eu>
parents: 22
diff changeset
355 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
356 }
30
8b630bf52092 Shorter lock times.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
357
8b630bf52092 Shorter lock times.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
358 screen_top("CO2 meter %s", app_desc->version);
8b630bf52092 Shorter lock times.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
359 u8g2_SetFont(&u8g2, u8g2_font_t0_22b_tf);
8b630bf52092 Shorter lock times.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
360 sprintf(buf, "%.1f °C", temperature / 1000.0);
8b630bf52092 Shorter lock times.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
361 u8g2_uint_t w = u8g2_GetUTF8Width(&u8g2, buf);
8b630bf52092 Shorter lock times.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
362 u8g2_DrawUTF8(&u8g2, (128 - w) / 2,40, buf);
8b630bf52092 Shorter lock times.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
363
8b630bf52092 Shorter lock times.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
364 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
365 if (mode[i])
22a0f9810561 In the main screen dim the not active units.
Michiel Broek <mbroek@mbse.eu>
parents: 41
diff changeset
366 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
367 else
22a0f9810561 In the main screen dim the not active units.
Michiel Broek <mbroek@mbse.eu>
parents: 41
diff changeset
368 u8g2_SetFont(&u8g2, u8g2_font_t0_18_tf);
30
8b630bf52092 Shorter lock times.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
369 sprintf(buf, "%.1f", pressure[i] / 1000.0);
8b630bf52092 Shorter lock times.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
370 w = u8g2_GetUTF8Width(&u8g2, buf);
8b630bf52092 Shorter lock times.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
371 u8g2_DrawUTF8(&u8g2, ((42 - w) / 2) + i * 43,63, buf);
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
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
374 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
375 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
376 }
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
377
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
378
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
379
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
380 /**
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
381 * @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
382 * @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
383 */
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
384 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
385 {
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
386 char buf[65];
30
8b630bf52092 Shorter lock times.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
387 int mode = 0;
8b630bf52092 Shorter lock times.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
388 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
389
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
390 if (xSemaphoreTake(xSemaphoreUnits, 35) == pdTRUE) {
30
8b630bf52092 Shorter lock times.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
391 mode = units[no].mode;
8b630bf52092 Shorter lock times.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
392 temperature = units[no].temperature;
8b630bf52092 Shorter lock times.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
393 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
394 xSemaphoreGive(xSemaphoreUnits);
23
58a328e91881 Added error logging for failed locks
Michiel Broek <mbroek@mbse.eu>
parents: 22
diff changeset
395 } else {
58a328e91881 Added error logging for failed locks
Michiel Broek <mbroek@mbse.eu>
parents: 22
diff changeset
396 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
397 }
30
8b630bf52092 Shorter lock times.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
398
8b630bf52092 Shorter lock times.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
399 screen_top("Meter %d %s", no + 1, mode ? "Aan":"Uit");
8b630bf52092 Shorter lock times.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
400
8b630bf52092 Shorter lock times.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
401 u8g2_SetFont(&u8g2, u8g2_font_t0_22b_tf);
8b630bf52092 Shorter lock times.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
402 sprintf(buf, "%.1f °C", temperature / 1000.0);
8b630bf52092 Shorter lock times.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
403 u8g2_uint_t w = u8g2_GetUTF8Width(&u8g2, buf);
8b630bf52092 Shorter lock times.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
404 u8g2_DrawUTF8(&u8g2, (128 - w) / 2,40, buf);
8b630bf52092 Shorter lock times.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
405
8b630bf52092 Shorter lock times.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
406 sprintf(buf, "%.2f bar", pressure / 1000.0);
8b630bf52092 Shorter lock times.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
407 w = u8g2_GetUTF8Width(&u8g2, buf);
8b630bf52092 Shorter lock times.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
408 u8g2_DrawUTF8(&u8g2, (128 - w) / 2,63, buf);
8b630bf52092 Shorter lock times.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
409 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
410 }
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
411
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
412
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
413
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
414 /**
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
415 * @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
416 * @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
417 * @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
418 */
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
419 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
420 {
29
106464d4c727 Dutch translation on the screens.
Michiel Broek <mbroek@mbse.eu>
parents: 28
diff changeset
421 screen_top("Meter %d nulpunt", no + 1);
33
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
422 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
423 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
424 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
425 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
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
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
430 /**
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
431 * @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
432 * @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
433 * @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
434 * @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
435 */
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
436
34
495b7eafbf5a Temporary white splash screen. Select DS18B20 sensor per unit. Changed units result logging
Michiel Broek <mbroek@mbse.eu>
parents: 33
diff changeset
437 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
438 {
495b7eafbf5a Temporary white splash screen. Select DS18B20 sensor per unit. Changed units result logging
Michiel Broek <mbroek@mbse.eu>
parents: 33
diff changeset
439 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
440
495b7eafbf5a Temporary white splash screen. Select DS18B20 sensor per unit. Changed units result logging
Michiel Broek <mbroek@mbse.eu>
parents: 33
diff changeset
441 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
442 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
443 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
444 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
445 }
495b7eafbf5a Temporary white splash screen. Select DS18B20 sensor per unit. Changed units result logging
Michiel Broek <mbroek@mbse.eu>
parents: 33
diff changeset
446 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
447 } else {
495b7eafbf5a Temporary white splash screen. Select DS18B20 sensor per unit. Changed units result logging
Michiel Broek <mbroek@mbse.eu>
parents: 33
diff changeset
448 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
449 }
495b7eafbf5a Temporary white splash screen. Select DS18B20 sensor per unit. Changed units result logging
Michiel Broek <mbroek@mbse.eu>
parents: 33
diff changeset
450
495b7eafbf5a Temporary white splash screen. Select DS18B20 sensor per unit. Changed units result logging
Michiel Broek <mbroek@mbse.eu>
parents: 33
diff changeset
451 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
452 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
453 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
454 } else {
495b7eafbf5a Temporary white splash screen. Select DS18B20 sensor per unit. Changed units result logging
Michiel Broek <mbroek@mbse.eu>
parents: 33
diff changeset
455 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
456 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
457 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
458 break;
495b7eafbf5a Temporary white splash screen. Select DS18B20 sensor per unit. Changed units result logging
Michiel Broek <mbroek@mbse.eu>
parents: 33
diff changeset
459 }
495b7eafbf5a Temporary white splash screen. Select DS18B20 sensor per unit. Changed units result logging
Michiel Broek <mbroek@mbse.eu>
parents: 33
diff changeset
460 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
461 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
462 }
495b7eafbf5a Temporary white splash screen. Select DS18B20 sensor per unit. Changed units result logging
Michiel Broek <mbroek@mbse.eu>
parents: 33
diff changeset
463 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
464 }
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
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
468 /**
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
469 * @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
470 * @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
471 * @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
472 */
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
473 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
474 {
29
106464d4c727 Dutch translation on the screens.
Michiel Broek <mbroek@mbse.eu>
parents: 28
diff changeset
475 screen_top("Meter %d setup", no + 1);
33
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
476 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
477 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
478 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
479 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
480 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
481 }
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
482
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
483
043ae27633f8 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
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
485 /**
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
486 * @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
487 */
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
488 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
489 {
043ae27633f8 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 char buf[65];
30
8b630bf52092 Shorter lock times.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
491 int8_t rssi = 0;
8b630bf52092 Shorter lock times.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
492 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
493
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
494 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
495 snprintf(buf, 65, "SSID %s", wifi_state->STA_ssid);
30
8b630bf52092 Shorter lock times.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
496 rssi = wifi_state->STA_rssi;
8b630bf52092 Shorter lock times.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
497 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
498 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
499 } 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
500 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
501 }
30
8b630bf52092 Shorter lock times.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
502
8b630bf52092 Shorter lock times.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
503 screen_top("WiFi Status");
8b630bf52092 Shorter lock times.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
504 u8g2_DrawStr(&u8g2, 1, 28, buf);
8b630bf52092 Shorter lock times.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
505 snprintf(buf, 65, "RSSI %d", rssi);
8b630bf52092 Shorter lock times.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
506 u8g2_DrawStr(&u8g2, 1, 43, buf);
8b630bf52092 Shorter lock times.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
507 snprintf(buf, 65, "Verbonden %s", online ? "Ja":"Nee");
8b630bf52092 Shorter lock times.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
508 u8g2_DrawStr(&u8g2, 1, 59, buf);
8b630bf52092 Shorter lock times.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
509 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
510 }
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
511
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
512
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
513
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
514 /**
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
515 * @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
516 * @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
517 */
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
518 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
519 {
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
520 screen_top("WiFi AP setup");
33
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
521 menu_line(sub == 0, 1, 25, "Lijst AP");
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
522 menu_line(sub == 1, 1, 37, "Nieuw AP");
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
523 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
524 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
525 }
7717ac1d2f7f Added WiFi list configured APs. Added offset to the menu rotary for large menus.
Michiel Broek <mbroek@mbse.eu>
parents: 30
diff changeset
526
7717ac1d2f7f Added WiFi list configured APs. Added offset to the menu rotary for large menus.
Michiel Broek <mbroek@mbse.eu>
parents: 30
diff changeset
527
7717ac1d2f7f Added WiFi list configured APs. Added offset to the menu rotary for large menus.
Michiel Broek <mbroek@mbse.eu>
parents: 30
diff changeset
528
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
529 /**
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 * @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
531 * @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
532 * @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
533 */
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
534 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
535 {
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 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
537 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
538 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
539 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
540 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
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 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
543 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
544 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
545 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
546 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
547 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
548 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
549 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
550 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
551 }
33
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
552 memcpy(APs[num_ssids].SSID, ap.SSID, 32);
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
553 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
554 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
555 }
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 }
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 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
559 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
560 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
561 } 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
562 for (i = 0; i < num_ssids; i++) {
33
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
563 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
564 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
565 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
566 }
33
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
567 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
568 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
569 }
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
570 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
571 }
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
572
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
573
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
574
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
575 /**
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
576 * @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
577 * @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
578 */
33
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
579 void screen_edit_ap(int sub)
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
580 {
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
581 screen_top("WiFi wijzig AP");
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
582 menu_line(sub == 0, 1, 25, "SSID %s", editAP.SSID);
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
583 menu_line(sub == 1, 1, 37, "PSK %s", editAP.Password);
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
584 menu_line(sub == 2, 1, 49, "Opslaan");
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
585 if (edit_ssid >= 0) {
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
586 menu_line(sub == 3, 1, 61, "Verwijder");
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
587 }
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
588 u8g2_SendBuffer(&u8g2);
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
589 }
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
590
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
591
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
592
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
593 /**
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 * @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
595 */
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
596 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
597 {
30
8b630bf52092 Shorter lock times.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
598 char ip[17], nm[17], gw[17];
8b630bf52092 Shorter lock times.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
599
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
600 if (xSemaphoreTake(xSemaphoreWiFi, 25) == pdTRUE) {
30
8b630bf52092 Shorter lock times.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
601 strcpy(ip, wifi_state->STA_ip);
8b630bf52092 Shorter lock times.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
602 strcpy(nm, wifi_state->STA_nm);
8b630bf52092 Shorter lock times.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
603 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
604 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
605 } 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
606 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
607 }
30
8b630bf52092 Shorter lock times.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
608
8b630bf52092 Shorter lock times.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
609 screen_top("Netwerk Status");
8b630bf52092 Shorter lock times.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
610 menu_line(0, 1, 25, "IP %s", ip);
8b630bf52092 Shorter lock times.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
611 menu_line(0, 1, 37, "Mask %s", nm);
8b630bf52092 Shorter lock times.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
612 menu_line(0, 1, 49, "GW %s", gw);
8b630bf52092 Shorter lock times.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
613 menu_line(0, 1, 61, "Naam %s", config.hostname);
8b630bf52092 Shorter lock times.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
614 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
615 }
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
616
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
617
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
618
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
619 /**
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
620 * @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
621 * @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
622 */
25
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
623 void screen_network_setup(int sub)
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
624 {
29
106464d4c727 Dutch translation on the screens.
Michiel Broek <mbroek@mbse.eu>
parents: 28
diff changeset
625 screen_top("Netwerk setup");
33
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
626 menu_line(sub == 0, 1, 25, "Naam %s", config.hostname);
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
627 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
628 menu_line(sub == 2, 1, 49, "Terug");
25
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
629 u8g2_SendBuffer(&u8g2);
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
630 }
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
631
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
632
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
633
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
634 /**
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 * @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
636 */
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
637 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
638 {
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
639 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
640 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
641 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
642 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
643 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
644 }
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
645
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
646
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
647
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
648 /**
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
649 * @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
650 * @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
651 */
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
652 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
653 {
64078aa15512 Finished the editor using the rotary switch. Added editing of the MQTT server parameters.
Michiel Broek <mbroek@mbse.eu>
parents: 23
diff changeset
654 screen_top("MQTT Setup");
33
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
655 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
656 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
657 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
658 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
659 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
660 }
64078aa15512 Finished the editor using the rotary switch. Added editing of the MQTT server parameters.
Michiel Broek <mbroek@mbse.eu>
parents: 23
diff changeset
661
64078aa15512 Finished the editor using the rotary switch. Added editing of the MQTT server parameters.
Michiel Broek <mbroek@mbse.eu>
parents: 23
diff changeset
662
64078aa15512 Finished the editor using the rotary switch. Added editing of the MQTT server parameters.
Michiel Broek <mbroek@mbse.eu>
parents: 23
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 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
666 */
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
667 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
668 {
29
106464d4c727 Dutch translation on the screens.
Michiel Broek <mbroek@mbse.eu>
parents: 28
diff changeset
669 screen_top("Update software");
106464d4c727 Dutch translation on the screens.
Michiel Broek <mbroek@mbse.eu>
parents: 28
diff changeset
670 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
671 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
672 }
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
673
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
674
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
675
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
676 /**
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
677 * @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
678 * @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
679 * @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
680 */
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
681 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
682 {
29
106464d4c727 Dutch translation on the screens.
Michiel Broek <mbroek@mbse.eu>
parents: 28
diff changeset
683 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
684 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
685 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
686 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
687 }
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
688 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
689 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
690 }
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
691 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
692 }
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
693
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
694
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
695
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
696 /**
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
697 * @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
698 */
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
699 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
700 {
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
701 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
702 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
703 }
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
704
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
705
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
706
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
707 /**
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
708 * @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
709 */
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
710 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
711 {
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
712 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
713 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
714
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
715 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
716 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
717 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
718 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
719 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
720 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
721 } 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
722 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
723 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
724 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
725 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
726 }
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
727 }
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
728 } 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
729 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
730 }
043ae27633f8 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 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
732 }
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
733 }
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
734 }
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
735
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
736
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
737
043ae27633f8 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 * @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
740 * @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
741 * @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
742 * @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
743 */
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
744 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
745 {
043ae27633f8 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 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
747 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
748 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
749 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
750 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
751 }
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
752
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
753
043ae27633f8 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
043ae27633f8 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 /**
043ae27633f8 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 * @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
757 * @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
758 * @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
759 * @param cursub The subscreen number by reference. This is updated with the new number.
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
760 * @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
761 */
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
762 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
763 {
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
764 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
765 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
766 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
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 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
769 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
770 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
771 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
772 } 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
773 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
774 }
7717ac1d2f7f Added WiFi list configured APs. Added offset to the menu rotary for large menus.
Michiel Broek <mbroek@mbse.eu>
parents: 30
diff changeset
775 } 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
776 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
777 }
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
778 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
779 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
780 } 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
781 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
782 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
783 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
784 } 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
785 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
786 }
7717ac1d2f7f Added WiFi list configured APs. Added offset to the menu rotary for large menus.
Michiel Broek <mbroek@mbse.eu>
parents: 30
diff changeset
787 } 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
788 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
789 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
790 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
791 } 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
792 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
793 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
794 }
7717ac1d2f7f Added WiFi list configured APs. Added offset to the menu rotary for large menus.
Michiel Broek <mbroek@mbse.eu>
parents: 30
diff changeset
795 }
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 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
797 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
798 }
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
799
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
800 *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
801 *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
802 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
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
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
805
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
806
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
807 /**
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
808 * @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
809 */
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
810 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
811 {
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
812 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
813
043ae27633f8 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 Main_Loop2 = New_Loop2;
25
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
815 switch (Main_Loop2) {
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
816 case ML2_INIT:
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
817 ESP_LOGI(TAG, "Loop user: Init");
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
818 New_Loop2 = ML2_USER;
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
819 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
820
25
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
821 case ML2_USER:
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
822 screen_main();
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
823 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
824
25
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
825 case ML2_UNIT1:
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
826 case ML2_UNIT2:
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
827 case ML2_UNIT3:
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
828 screen_unit(Main_Loop2 - ML2_UNIT1);
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
829 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
830
25
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
831 case ML2_WIFI:
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
832 screen_wifi();
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
833 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
834
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
835 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
836 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
837 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
838 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
839
7717ac1d2f7f Added WiFi list configured APs. Added offset to the menu rotary for large menus.
Michiel Broek <mbroek@mbse.eu>
parents: 30
diff changeset
840 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
841 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
842 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
843 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
844 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
845
33
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
846 case ML2_EDIT_AP:
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
847 ESP_LOGI(TAG, "Loop user: WiFi edit AP");
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
848 screen_edit_ap(0);
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
849 break;
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
850
25
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
851 case ML2_NETWORK:
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
852 screen_network();
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
853 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
854
25
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
855 case ML2_SETUP_NETWORK:
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
856 ESP_LOGI(TAG, "Loop user: Network setup");
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
857 screen_network_setup(SubMenu);
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
858 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
859
25
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
860 case ML2_MQTT:
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
861 screen_mqtt();
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
862 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
863
25
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
864 case ML2_SETUP_MQTT:
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
865 ESP_LOGI(TAG, "Loop user: MQTT setup");
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
866 screen_mqtt_setup(SubMenu);
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
867 break;
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
868
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
869 case ML2_UPDATE:
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
870 screen_update();
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
871 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
872
25
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
873 case ML2_SETUP_UNIT1:
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
874 case ML2_SETUP_UNIT2:
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
875 case ML2_SETUP_UNIT3:
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
876 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
877 SubMenu = SubOffset = 0;
25
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
878 screen_unit_setup(Main_Loop2 - ML2_SETUP_UNIT1, SubMenu);
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
879 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
880
25
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
881 case ML2_ZERO_UNIT1:
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
882 case ML2_ZERO_UNIT2:
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
883 case ML2_ZERO_UNIT3:
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
884 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
885 SubMenu = SubOffset = 0;
25
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
886 screen_unit_zero(Main_Loop2 - ML2_ZERO_UNIT1, SubMenu);
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
887 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
888
34
495b7eafbf5a Temporary white splash screen. Select DS18B20 sensor per unit. Changed units result logging
Michiel Broek <mbroek@mbse.eu>
parents: 33
diff changeset
889 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
890 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
891 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
892 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
893 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
894 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
895 break;
495b7eafbf5a Temporary white splash screen. Select DS18B20 sensor per unit. Changed units result logging
Michiel Broek <mbroek@mbse.eu>
parents: 33
diff changeset
896
25
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
897 case ML2_INACTIVE:
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
898 ESP_LOGI(TAG, "Loop user: Inactive");
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
899 u8g2_SetPowerSave(&u8g2, 1); // powersave display
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
900 New_Loop2 = ML2_DONE;
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
901 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
902
25
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
903 default:
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
904 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
905 }
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
906 }
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
907 }
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
908
043ae27633f8 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
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
910
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
911 /**
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
912 * @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
913 */
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 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
915 {
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
916 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
917 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
918 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
919 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
920 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
921 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
922 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
923 case ML2_MQTT: rotate_to_menu(event.state.position, ML2_UPDATE, ML2_NETWORK); break;
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
924 case ML2_UPDATE: rotate_to_menu(event.state.position, ML2_UPDATE, ML2_MQTT); break;
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
925 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
926 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
927 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
928 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
929 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
930 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
931 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
932 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
933 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
934 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
935 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
936 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
937 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
938 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
939 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
940 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
941 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
942 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
943 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
944 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
945 break;
33
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
946 case ML2_EDIT_AP: if (edit_ssid < 0) {
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
947 if (rotate_to_sub(event.state.position, 2, &SubMenu, &SubOffset))
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
948 screen_edit_ap(SubMenu);
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
949 } else {
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
950 if (rotate_to_sub(event.state.position, 3, &SubMenu, &SubOffset))
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
951 screen_edit_ap(SubMenu);
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
952 }
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
953 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
954 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
955 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
956 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
957 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
958 screen_network_setup(SubMenu);
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
959 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
960 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
961 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
962 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
963 }
043ae27633f8 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
22
cceb36fd3a2a Better update of the user screens. Added more internal documentation.
Michiel Broek <mbroek@mbse.eu>
parents: 21
diff changeset
968 /*
cceb36fd3a2a Better update of the user screens. Added more internal documentation.
Michiel Broek <mbroek@mbse.eu>
parents: 21
diff changeset
969 * 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
970 */
cceb36fd3a2a Better update of the user screens. Added more internal documentation.
Michiel Broek <mbroek@mbse.eu>
parents: 21
diff changeset
971 void user_refresh(void)
cceb36fd3a2a Better update of the user screens. Added more internal documentation.
Michiel Broek <mbroek@mbse.eu>
parents: 21
diff changeset
972 {
30
8b630bf52092 Shorter lock times.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
973 if (UserTimer)
8b630bf52092 Shorter lock times.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
974 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
975 }
cceb36fd3a2a Better update of the user screens. Added more internal documentation.
Michiel Broek <mbroek@mbse.eu>
parents: 21
diff changeset
976
cceb36fd3a2a Better update of the user screens. Added more internal documentation.
Michiel Broek <mbroek@mbse.eu>
parents: 21
diff changeset
977
cceb36fd3a2a Better update of the user screens. Added more internal documentation.
Michiel Broek <mbroek@mbse.eu>
parents: 21
diff changeset
978
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
979 /**
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
980 * @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
981 */
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
982 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
983 {
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
984 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
985 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
986
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
987 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
988 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
989 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
990 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
991 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
992 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
993
043ae27633f8 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 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
995 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
996 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
997 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
998 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
999 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
1000 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
1001 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
1002 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
1003 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
1004 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
1005 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
1006 } 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
1007 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
1008 }
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1009 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
1010 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
1011 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
1012 } 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
1013 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
1014 } 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
1015 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
1016 } 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
1017 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
1018 }
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
1019 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
1020
043ae27633f8 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 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
1022 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
1023 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
1024 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
1025 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
1026 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
1027 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
1028 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
1029 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
1030 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
1031 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
1032 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
1033 xSemaphoreGive(xSemaphoreUnits);
22
cceb36fd3a2a Better update of the user screens. Added more internal documentation.
Michiel Broek <mbroek@mbse.eu>
parents: 21
diff changeset
1034 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
1035 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
1036 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
1037 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
1038 }
34
495b7eafbf5a Temporary white splash screen. Select DS18B20 sensor per unit. Changed units result logging
Michiel Broek <mbroek@mbse.eu>
parents: 33
diff changeset
1039 } 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
1040 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
1041 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
1042 }
043ae27633f8 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 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
1044
34
495b7eafbf5a Temporary white splash screen. Select DS18B20 sensor per unit. Changed units result logging
Michiel Broek <mbroek@mbse.eu>
parents: 33
diff changeset
1045 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
1046 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
1047 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
1048 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
1049 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
1050 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
1051 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
1052 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
1053 write_units();
e2a43e7c4035 Swapped ADC channels 6 and 7. Completed the DS18B20 assign to unit.
Michiel Broek <mbroek@mbse.eu>
parents: 34
diff changeset
1054 xSemaphoreGive(xSemaphoreUnits);
e2a43e7c4035 Swapped ADC channels 6 and 7. Completed the DS18B20 assign to unit.
Michiel Broek <mbroek@mbse.eu>
parents: 34
diff changeset
1055 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
1056 SubMenu = 2;
e2a43e7c4035 Swapped ADC channels 6 and 7. Completed the DS18B20 assign to unit.
Michiel Broek <mbroek@mbse.eu>
parents: 34
diff changeset
1057 SubOffset = 0;
e2a43e7c4035 Swapped ADC channels 6 and 7. Completed the DS18B20 assign to unit.
Michiel Broek <mbroek@mbse.eu>
parents: 34
diff changeset
1058 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
1059 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
1060 } else {
e2a43e7c4035 Swapped ADC channels 6 and 7. Completed the DS18B20 assign to unit.
Michiel Broek <mbroek@mbse.eu>
parents: 34
diff changeset
1061 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
1062 }
34
495b7eafbf5a Temporary white splash screen. Select DS18B20 sensor per unit. Changed units result logging
Michiel Broek <mbroek@mbse.eu>
parents: 33
diff changeset
1063 } else {
495b7eafbf5a Temporary white splash screen. Select DS18B20 sensor per unit. Changed units result logging
Michiel Broek <mbroek@mbse.eu>
parents: 33
diff changeset
1064 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
1065 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
1066 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
1067 }
495b7eafbf5a Temporary white splash screen. Select DS18B20 sensor per unit. Changed units result logging
Michiel Broek <mbroek@mbse.eu>
parents: 33
diff changeset
1068 break;
495b7eafbf5a Temporary white splash screen. Select DS18B20 sensor per unit. Changed units result logging
Michiel Broek <mbroek@mbse.eu>
parents: 33
diff changeset
1069
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
1070 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
1071 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
1072 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
1073
7717ac1d2f7f Added WiFi list configured APs. Added offset to the menu rotary for large menus.
Michiel Broek <mbroek@mbse.eu>
parents: 30
diff changeset
1074 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
1075 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
1076 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
1077 } else if (SubMenu == 1) {
33
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
1078 edit_ssid = -1;
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
1079 editAP.SSID[0] = '\0';
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
1080 editAP.Password[0] = '\0';
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
1081 SubMenu = SubOffset = 0;
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
1082 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
1083 } 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
1084 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
1085 }
7717ac1d2f7f Added WiFi list configured APs. Added offset to the menu rotary for large menus.
Michiel Broek <mbroek@mbse.eu>
parents: 30
diff changeset
1086 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
1087
7717ac1d2f7f Added WiFi list configured APs. Added offset to the menu rotary for large menus.
Michiel Broek <mbroek@mbse.eu>
parents: 30
diff changeset
1088 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
1089 if ((SubMenu + SubOffset) < num_ssids) {
33
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
1090 edit_ssid = SubMenu + SubOffset;
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
1091 memcpy(editAP.SSID, APs[edit_ssid].SSID, 32);
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
1092 memcpy(editAP.Password, APs[edit_ssid].Password, 64);
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
1093 SubMenu = SubOffset = 0;
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
1094 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
1095 } 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
1096 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
1097 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
1098 }
7717ac1d2f7f Added WiFi list configured APs. Added offset to the menu rotary for large menus.
Michiel Broek <mbroek@mbse.eu>
parents: 30
diff changeset
1099 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
1100
33
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
1101 case ML2_EDIT_AP:
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
1102 if (SubMenu == 0) {
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
1103 rotary_editer("SSID", editAP.SSID, "", 16, EDIT_TYPE_TEXT);
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
1104 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
1105 } else if (SubMenu == 1) {
33
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
1106 rotary_editer("PSK", editAP.Password, "", 16, EDIT_TYPE_TEXT);
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
1107 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
1108 } else if (SubMenu == 2 || SubMenu == 3) {
33
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
1109 update_running = 1; // Block measurements
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
1110 int timeout = 600;
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
1111 if (edit_ssid < 0)
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
1112 New_Loop2 = ML2_SETUP_WIFI;
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
1113 else
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
1114 New_Loop2 = ML2_LIST_APS;
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
1115
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
1116 for (;;) {
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
1117 vTaskDelay(100 / portTICK_PERIOD_MS);
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
1118 if (Main_Loop1 == ML1_DONE)
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
1119 break;
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
1120 if (timeout)
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
1121 timeout--;
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
1122 else {
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
1123 ESP_LOGE(TAG, "Timout request stop");
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
1124 goto saveerr;
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
1125 }
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
1126 }
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
1127 if (edit_ssid >= 0) {
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
1128 ESP_LOGI(TAG, "Remove %s", APs[edit_ssid].SSID);
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
1129 remove_station((uint8_t *)APs[edit_ssid].SSID);
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
1130 }
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
1131 if (SubMenu == 2) {
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
1132 ESP_LOGI(TAG, "Add %s %s", editAP.SSID, editAP.Password);
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
1133 add_station((uint8_t *)editAP.SSID, (uint8_t *)editAP.Password);
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
1134 }
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
1135 }
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
1136 saveerr:
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
1137 update_running = 0;
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
1138 break;
331e7f700971 Added WiFi AP editor.
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
1139
25
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
1140 case ML2_NETWORK:
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
1141 New_Loop2 = ML2_SETUP_NETWORK;
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
1142 break;
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
1143
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
1144 case ML2_SETUP_NETWORK:
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
1145 if (SubMenu == 0) {
29
106464d4c727 Dutch translation on the screens.
Michiel Broek <mbroek@mbse.eu>
parents: 28
diff changeset
1146 rotary_editer("Hostnaam", config.hostname, "", 16, EDIT_TYPE_TEXT);
25
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
1147 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
1148 } else if (SubMenu == 1) {
25
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
1149 rotary_editer("NTP server", config.ntp_server, "", 16, EDIT_TYPE_TEXT);
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
1150 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
1151 } else if (SubMenu == 2) {
25
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
1152 ESP_LOGI(TAG, "Hostname `%s`", config.hostname);
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
1153 ESP_LOGI(TAG, "NTP server `%s`", config.ntp_server);
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
1154 write_config();
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
1155 New_Loop2 = ML2_NETWORK;
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
1156 }
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
1157 break;
cc7c423f03fb Added network setup
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
1158
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
1159 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
1160 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
1161 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
1162
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
1163 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
1164 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
1165 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
1166 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
1167 } 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
1168 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
1169 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
1170 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
1171 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
1172 } 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
1173 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
1174 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
1175 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
1176 } 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
1177 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
1178 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
1179 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
1180 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
1181 }
64078aa15512 Finished the editor using the rotary switch. Added editing of the MQTT server parameters.
Michiel Broek <mbroek@mbse.eu>
parents: 23
diff changeset
1182 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
1183
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
1184 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
1185 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
1186 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
1187 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
1188
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
1189 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
1190 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
1191 }
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1192 }
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1193
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1194
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1195
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1196 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
1197 {
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1198 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
1199 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
1200
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1201 /*
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1202 * 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
1203 * 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
1204 */
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1205 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
1206 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
1207 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
1208 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
1209
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1210 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
1211 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
1212 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
1213
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1214 /*
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1215 * 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
1216 * 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
1217 * 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
1218 */
043ae27633f8 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 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
1220 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
1221 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
1222
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1223 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
1224 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
1225 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
1226 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
1227 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
1228
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1229 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
1230 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
1231
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1232 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
1233
37
358bbd5b608e menuconfig settings now work for I2C display setup. Lot's of code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 36
diff changeset
1234 /*
358bbd5b608e menuconfig settings now work for I2C display setup. Lot's of code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 36
diff changeset
1235 * 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
1236 * 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
1237 */
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
1238 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
1239 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
1240
37
358bbd5b608e menuconfig settings now work for I2C display setup. Lot's of code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 36
diff changeset
1241 /*
358bbd5b608e menuconfig settings now work for I2C display setup. Lot's of code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 36
diff changeset
1242 * 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
1243 */
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
1244 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
1245 .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
1246 .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
1247 };
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1248 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
1249 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
1250
043ae27633f8 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 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
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 * 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
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 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
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 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
1259
043ae27633f8 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 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
1261 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
1262 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
1263 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
1264 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
1265 }
043ae27633f8 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
043ae27633f8 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 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
1268 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
1269 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
1270 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
1271 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
1272 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
1273 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
1274 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
1275
043ae27633f8 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 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
1277
043ae27633f8 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 menu_change();
30
8b630bf52092 Shorter lock times.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
1279
8b630bf52092 Shorter lock times.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
1280 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
1281 xEventGroupClearBits(xEventGroupUser, TASK_USER_REFRESH);
30
8b630bf52092 Shorter lock times.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
1282 switch (Main_Loop2) {
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
1283 case ML2_USER: screen_main(); break;
30
8b630bf52092 Shorter lock times.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
1284 case ML2_UNIT1: screen_unit(0); break;
8b630bf52092 Shorter lock times.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
1285 case ML2_UNIT2: screen_unit(1); break;
8b630bf52092 Shorter lock times.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
1286 case ML2_UNIT3: screen_unit(2); 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
1287 case ML2_WIFI: screen_wifi(); break;
30
8b630bf52092 Shorter lock times.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
1288 }
8b630bf52092 Shorter lock times.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
1289 }
8b630bf52092 Shorter lock times.
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
1290
22
cceb36fd3a2a Better update of the user screens. Added more internal documentation.
Michiel Broek <mbroek@mbse.eu>
parents: 21
diff changeset
1291 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
1292 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
1293 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
1294 }
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1295
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1296 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
1297 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
1298 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
1299 }
043ae27633f8 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 }
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1301
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1302 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
1303 }
043ae27633f8 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 }
043ae27633f8 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 }
043ae27633f8 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

mercurial