21 rotary_encoder_info_t rinfo = { 0 }; ///< Rotary encoder record |
21 rotary_encoder_info_t rinfo = { 0 }; ///< Rotary encoder record |
22 rotary_encoder_event_t event = { 0 }; ///< Rotary encoder events |
22 rotary_encoder_event_t event = { 0 }; ///< Rotary encoder events |
23 QueueHandle_t event_queue; ///< Events queue |
23 QueueHandle_t event_queue; ///< Events queue |
24 QueueHandle_t gpio_evt_queue = NULL; ///< Rotary pushbutton queue |
24 QueueHandle_t gpio_evt_queue = NULL; ///< Rotary pushbutton queue |
25 static int PushDuration = 0; ///< Duration of the pushed button |
25 static int PushDuration = 0; ///< Duration of the pushed button |
26 wifiStation_t APs[10]; ///< List of APs we know |
|
27 int edit_ssid = 0; ///< SSID being edited |
|
28 int num_ssids = 0; ///< Number of SSIDs we know |
|
29 wifiStation_t editAP; ///< Data of station to edit |
|
30 char sensors[DS18B20_MAX][17]; ///< Sensors to select |
26 char sensors[DS18B20_MAX][17]; ///< Sensors to select |
31 uint32_t err_connect = 0; ///< Connect error count |
27 uint32_t err_connect = 0; ///< Connect error count |
32 uint32_t err_alarm = 0; ///< Alarm watchdog error count |
28 uint32_t err_alarm = 0; ///< Alarm watchdog error count |
33 uint32_t err_temp = 0; ///< DS18B20 read errors |
29 uint32_t err_temp = 0; ///< DS18B20 read errors |
34 |
30 |
43 extern SemaphoreHandle_t xSemaphoreWiFi; ///< WiFi lock semaphore |
39 extern SemaphoreHandle_t xSemaphoreWiFi; ///< WiFi lock semaphore |
44 extern int count_pub; ///< Published MQTT messages in transit |
40 extern int count_pub; ///< Published MQTT messages in transit |
45 extern int Main_Loop1; ///< Main measure loop |
41 extern int Main_Loop1; ///< Main measure loop |
46 extern int update_running; ///< If update is running |
42 extern int update_running; ///< If update is running |
47 extern int num_sensors; ///< Detected DS18B20 sensors |
43 extern int num_sensors; ///< Detected DS18B20 sensors |
48 extern wifiStation_t wifiStation; |
|
49 extern char hostname[]; |
44 extern char hostname[]; |
50 |
45 |
51 |
46 |
52 const int TASK_USER_COLD = BIT0; ///< System cold start |
47 const int TASK_USER_COLD = BIT0; ///< System cold start |
53 const int TASK_USER_WAKEUP = BIT1; ///< System wakeup from deepsleep |
48 const int TASK_USER_WAKEUP = BIT1; ///< System wakeup from deepsleep |
73 if (Main_Loop1 == ML1_DONE && update_running == 0) |
68 if (Main_Loop1 == ML1_DONE && update_running == 0) |
74 Main_Loop1 = ML1_INIT; |
69 Main_Loop1 = ML1_INIT; |
75 } |
70 } |
76 |
71 |
77 if (UserTimer == 1) { |
72 if (UserTimer == 1) { |
78 ESP_LOGI(TAG, "User inactivity timeout"); |
73 ESP_LOGI(TAG, "UserTimer timeout"); |
79 xEventGroupClearBits(xEventGroupUser, TASK_USER_BUSY); |
74 xEventGroupClearBits(xEventGroupUser, TASK_USER_BUSY); |
80 u8g2_SetPowerSave(&u8g2, 1); |
75 u8g2_SetPowerSave(&u8g2, 1); |
81 } |
76 } |
82 if (UserTimer) { |
77 if (UserTimer) { |
83 UserTimer--; |
78 UserTimer--; |
84 } |
79 } |
85 |
80 |
86 if (LoopTimer == 1) { |
81 if (LoopTimer == 1) { |
87 ESP_LOGI(TAG, "Alarm Timer timeout"); |
82 ESP_LOGD(TAG, "LoopTimer timeout"); |
88 Main_Loop1 = ML1_INIT; |
83 Main_Loop1 = ML1_INIT; |
89 } |
84 } |
90 |
85 |
91 if (LoopTimer) { |
86 if (LoopTimer) { |
92 LoopTimer--; |
87 LoopTimer--; |
524 u8g2_DrawStr(&u8g2, 1, 43, buf); |
519 u8g2_DrawStr(&u8g2, 1, 43, buf); |
525 snprintf(buf, 65, "Verbonden %s", online ? "Ja":"Nee"); |
520 snprintf(buf, 65, "Verbonden %s", online ? "Ja":"Nee"); |
526 u8g2_DrawStr(&u8g2, 1, 59, buf); |
521 u8g2_DrawStr(&u8g2, 1, 59, buf); |
527 u8g2_SendBuffer(&u8g2); |
522 u8g2_SendBuffer(&u8g2); |
528 } |
523 } |
529 |
|
530 |
|
531 |
|
532 /** |
|
533 * @brief The WiFi setup menu. |
|
534 * @param sub The submenu entry to hilite. |
|
535 */ |
|
536 /*void screen_wifi_setup(int sub) |
|
537 { |
|
538 screen_top("WiFi AP setup"); |
|
539 menu_line(sub == 0, 1, 25, "Lijst AP"); |
|
540 menu_line(sub == 1, 1, 37, "Nieuw AP"); |
|
541 menu_line(sub == 2, 1, 49, "Terug"); |
|
542 u8g2_SendBuffer(&u8g2); |
|
543 }*/ |
|
544 |
|
545 |
|
546 |
|
547 /** |
|
548 * @brief Show the list if WiFi Access Points. |
|
549 * @param sub The sub entry line. |
|
550 * @param offset The offset in the list. |
|
551 */ |
|
552 /*void screen_list_aps(int sub, int offset) |
|
553 { |
|
554 int i; |
|
555 wifiStation_t ap; |
|
556 uint8_t *dst = (uint8_t *)≈ |
|
557 FILE *f; |
|
558 size_t bytes; |
|
559 |
|
560 num_ssids = 0; |
|
561 memset(dst, 0, sizeof(ap)); |
|
562 f = fopen("/spiffs/stations.conf", "r"); |
|
563 if (f) { |
|
564 while (1) { |
|
565 bytes = fread(dst, 1, sizeof(ap), f); |
|
566 if (bytes < sizeof(ap)) { |
|
567 fclose(f); |
|
568 break; |
|
569 } |
|
570 memcpy(APs[num_ssids].SSID, ap.SSID, 32); |
|
571 memcpy(APs[num_ssids].Password, ap.Password, 64); |
|
572 num_ssids++; |
|
573 } |
|
574 } |
|
575 |
|
576 screen_top("WiFi AP lijst"); |
|
577 if (num_ssids == 0) { |
|
578 menu_line(0, 1, 25, "Geen AP's"); |
|
579 } else { |
|
580 for (i = 0; i < num_ssids; i++) { |
|
581 menu_line(sub == i, 1, 25 + (i * 12), APs[i + offset].SSID); |
|
582 if (i == 3) |
|
583 break; |
|
584 } |
|
585 if ((i + offset) == num_ssids) |
|
586 menu_line(sub == i, 1, 25 + (i * 12), "Terug"); |
|
587 } |
|
588 u8g2_SendBuffer(&u8g2); |
|
589 }*/ |
|
590 |
|
591 |
|
592 |
|
593 /** |
|
594 * @brief Edit WiFi AP menu. |
|
595 * @param sub The menu entry to hilite. |
|
596 */ |
|
597 /*void screen_edit_ap(int sub) |
|
598 { |
|
599 screen_top("WiFi wijzig AP"); |
|
600 menu_line(sub == 0, 1, 25, "SSID %s", editAP.SSID); |
|
601 menu_line(sub == 1, 1, 37, "PSK %s", editAP.Password); |
|
602 menu_line(sub == 2, 1, 49, "Opslaan"); |
|
603 if (edit_ssid >= 0) { |
|
604 menu_line(sub == 3, 1, 61, "Verwijder"); |
|
605 } |
|
606 u8g2_SendBuffer(&u8g2); |
|
607 }*/ |
|
608 |
524 |
609 |
525 |
610 |
526 |
611 /** |
527 /** |
612 * @brief The network status screen. |
528 * @brief The network status screen. |