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