diff options
| Commit | 67973c031918ac8da62c8e58145876cdfc72cb19 (patch) | |
|---|---|---|
| Author | 2024-05-25 13:42:33 +0300 | |
| Committer | 2024-05-25 13:42:33 +0300 | |
| Files | 90940477c475aefd3d783a8fd691d71e13cac402 | |
| uni-projects-67973c031918ac8da62c8e58145876cdfc72cb19.tar uni-projects-67973c031918ac8da62c8e58145876cdfc72cb19.tar.gz uni-projects-67973c031918ac8da62c8e58145876cdfc72cb19.zip | ||
| Parent | e8a765c5587ba7cef532660a3d5ba7553bb3c520 (diff) | |
[iot/goam] Added wifi characters
4 files changed, 50 insertions, 5 deletions
| -rw-r--r-- | Year 3/Internet of things/goam/ibm-vga-8x16.xcf | bin | 100663 -> 100612 bytes | |||
| -rw-r--r-- | Year 3/Internet of things/goam/main/display.h | 4 | ||||
| -rw-r--r-- | Year 3/Internet of things/goam/main/ibm-vga-8x16.c | 33 | ||||
| -rw-r--r-- | Year 3/Internet of things/goam/main/wifi.c | 18 |
diff --git a/Year 3/Internet of things/goam/ibm-vga-8x16.xcf b/Year 3/Internet of things/goam/ibm-vga-8x16.xcf Binary files differindex 0f74db2..40f177a 100644 --- a/Year 3/Internet of things/goam/ibm-vga-8x16.xcf +++ b/Year 3/Internet of things/goam/ibm-vga-8x16.xcf diff --git a/Year 3/Internet of things/goam/main/display.h b/Year 3/Internet of things/goam/main/display.h index 112ee87..84f1e96 100644 --- a/Year 3/Internet of things/goam/main/display.h +++ b/Year 3/Internet of things/goam/main/display.h @@ -11,6 +11,10 @@ void display_invertion(enum Inversion inv_byte); void display_println(const char* str); void display_printon(const char* str, unsigned char line); +#define CHAR_WIFI "\5" +#define CHAR_NOWIFI "\7" +#define CHAR_WIFI_EXCLAM "\6" + /* Double-width characters */ #define DCHAR_CAMERA "\1\2" diff --git a/Year 3/Internet of things/goam/main/ibm-vga-8x16.c b/Year 3/Internet of things/goam/main/ibm-vga-8x16.c index f623d2c..cb47e3b 100644 --- a/Year 3/Internet of things/goam/main/ibm-vga-8x16.c +++ b/Year 3/Internet of things/goam/main/ibm-vga-8x16.c @@ -190,6 +190,39 @@ const uint8_t bitpixel_chars[256][16] = { COL(0000111111110010) COL(0000000000000000) }, + + ['\5'] = { + COL(0000000000110000) + COL(0000000110011000) + COL(0000110011011000) + COL(0010011011011000) + COL(0000110011011000) + COL(0000000110011000) + COL(0000000000110000) + COL(0000000000000000) + }, + + ['\6'] = { + COL(0000000000110000) + COL(0000000110011000) + COL(0000110011011000) + COL(0010011011011000) + COL(0000110011011000) + COL(0000000110011000) + COL(0010111000110000) + COL(0000000000000000) + }, + + ['\7'] = { + COL(0000011000110000) + COL(0000001110011000) + COL(0000110111011000) + COL(0010011011011000) + COL(0000110011111000) + COL(0000000110111000) + COL(0000000000111000) + COL(0000000000001100) + }, }; const uint8_t template[16] = { diff --git a/Year 3/Internet of things/goam/main/wifi.c b/Year 3/Internet of things/goam/main/wifi.c index 1fd6ac8..0bbbcf7 100644 --- a/Year 3/Internet of things/goam/main/wifi.c +++ b/Year 3/Internet of things/goam/main/wifi.c @@ -10,6 +10,8 @@ #include "wifi.h" #include "display.h" +#define IP_LINE 2 + #define ESP_WIFI_SCAN_AUTH_MODE_THRESHOLD WIFI_AUTH_WPA2_PSK #define ESP_MAXIMUM_RETRY 3 @@ -55,7 +57,7 @@ static unsigned short MAX_AP = 16; static TaskHandle_t launcher_handle = NULL; static void scan_and_connect_task() { - display_printon("---.---.---.---", 2); + display_printon(CHAR_NOWIFI "---.---.---.---", IP_LINE); ESP_ERROR_CHECK(esp_wifi_scan_start(NULL, true)); wifi_ap_record_t ap_info[MAX_AP]; @@ -120,12 +122,17 @@ static void launcher_scan_and_connect_task(void*) { static int connect_tries = 0; +static void sta_connected_handler(void* arg, esp_event_base_t event_base, int32_t event_id, void* event_data) { + display_printon(CHAR_WIFI, IP_LINE); +} + static void sta_disconnect_handler(void* arg, esp_event_base_t event_base, int32_t event_id, void* event_data) { if (connect_tries < ESP_MAXIMUM_RETRY) { esp_wifi_connect(); + display_printon(CHAR_WIFI_EXCLAM, IP_LINE); connect_tries++; ESP_LOGW(TAG, "Retrying to connect... Try %d/%d", connect_tries, ESP_MAXIMUM_RETRY); - vTaskDelay(100 / portTICK_PERIOD_MS); + vTaskDelay(200 / portTICK_PERIOD_MS); } else { ESP_LOGW(TAG, "Failed to connect to SSID:%s, password:%s, rescanning connections", ESP_WIFI_SSID, ESP_WIFI_PASS); @@ -139,12 +146,13 @@ static void ip_got_handler(void* arg, esp_event_base_t event_base, int32_t event ip_event_got_ip_t* event = (ip_event_got_ip_t*) event_data; ESP_LOGI(TAG, "Connected to SSID:%s password:%s, got ip:" IPSTR, ESP_WIFI_SSID, ESP_WIFI_PASS, IP2STR(&event->ip_info.ip)); - char ip[16]; - sprintf(ip, IPSTR, IP2STR(&event->ip_info.ip)); - display_printon(ip, 2); + char ip[17]; + sprintf(ip, CHAR_WIFI IPSTR, IP2STR(&event->ip_info.ip)); + display_printon(ip, IP_LINE); } static void wifi_init_events() { + ESP_ERROR_CHECK(esp_event_handler_instance_register(WIFI_EVENT, WIFI_EVENT_STA_CONNECTED, &sta_connected_handler, NULL, NULL)); ESP_ERROR_CHECK(esp_event_handler_instance_register(WIFI_EVENT, WIFI_EVENT_STA_DISCONNECTED, &sta_disconnect_handler, NULL, NULL)); ESP_ERROR_CHECK(esp_event_handler_instance_register(IP_EVENT, IP_EVENT_STA_GOT_IP, &ip_got_handler, NULL, NULL)); } |
