Skip to content

Commit 514f360

Browse files
committed
add TRONBYT-CONFIG webp graphic
1 parent 4aa7031 commit 514f360

File tree

8 files changed

+316
-175
lines changed

8 files changed

+316
-175
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ secrets.json
88
build
99
.DS_Store
1010
dependencies.lock
11+
_secrets.json

extra_scripts/webp_to_c.h.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
parser = argparse.ArgumentParser(description='Convert a WebP file to a C header file.')
55
parser.add_argument('input_file', type=str, help='The input WebP file')
66
parser.add_argument('output_file', type=str, help='The output C header file')
7+
parser.add_argument('header_name', type=str, help='The header variable name')
78

89
# Parse arguments
910
args = parser.parse_args()
@@ -17,7 +18,7 @@
1718
binary_data = f.read()
1819

1920
# Create C header file content
20-
header_name = "ASSET_BOOT_WEBP"
21+
header_name = args.header_name
2122
line_length = 16 # Number of bytes per line in the array
2223
hex_lines = []
2324

lib/assets/assets.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,10 @@ extern const size_t ASSET_BOOT_WEBP_LEN;
1010
#include "lib/assets/parrot_c"
1111
#else
1212
#include "lib/assets/tronbyt_c"
13-
#endif
13+
#endif
14+
15+
extern const uint8_t ASSET_CONFIG_WEBP[];
16+
extern const size_t ASSET_CONFIG_WEBP_LEN;
17+
18+
#include "lib/assets/config_c"
19+

lib/assets/config_c

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
// Generated by 'tbt dev firmware-asset', don't edit manually!
2+
#include <stddef.h>
3+
#include <stdint.h>
4+
const size_t ASSET_CONFIG_WEBP_LEN = 1658;
5+
const uint8_t ASSET_CONFIG_WEBP[] =
6+
"\x52\x49\x46\x46\x72\x06\x00\x00\x57\x45\x42\x50\x56\x50\x38\x58"
7+
"\x0A\x00\x00\x00\x20\x00\x00\x00\x3F\x00\x00\x1F\x00\x00\x49\x43"
8+
"\x43\x50\xA0\x02\x00\x00\x00\x00\x02\xA0\x6C\x63\x6D\x73\x04\x30"
9+
"\x00\x00\x6D\x6E\x74\x72\x52\x47\x42\x20\x58\x59\x5A\x20\x07\xE9"
10+
"\x00\x05\x00\x0B\x00\x09\x00\x1B\x00\x39\x61\x63\x73\x70\x41\x50"
11+
"\x50\x4C\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
12+
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xF6\xD6\x00\x01"
13+
"\x00\x00\x00\x00\xD3\x2D\x6C\x63\x6D\x73\x00\x00\x00\x00\x00\x00"
14+
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
15+
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
16+
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0D\x64\x65\x73\x63\x00\x00"
17+
"\x01\x20\x00\x00\x00\x40\x63\x70\x72\x74\x00\x00\x01\x60\x00\x00"
18+
"\x00\x36\x77\x74\x70\x74\x00\x00\x01\x98\x00\x00\x00\x14\x63\x68"
19+
"\x61\x64\x00\x00\x01\xAC\x00\x00\x00\x2C\x72\x58\x59\x5A\x00\x00"
20+
"\x01\xD8\x00\x00\x00\x14\x62\x58\x59\x5A\x00\x00\x01\xEC\x00\x00"
21+
"\x00\x14\x67\x58\x59\x5A\x00\x00\x02\x00\x00\x00\x00\x14\x72\x54"
22+
"\x52\x43\x00\x00\x02\x14\x00\x00\x00\x20\x67\x54\x52\x43\x00\x00"
23+
"\x02\x14\x00\x00\x00\x20\x62\x54\x52\x43\x00\x00\x02\x14\x00\x00"
24+
"\x00\x20\x63\x68\x72\x6D\x00\x00\x02\x34\x00\x00\x00\x24\x64\x6D"
25+
"\x6E\x64\x00\x00\x02\x58\x00\x00\x00\x24\x64\x6D\x64\x64\x00\x00"
26+
"\x02\x7C\x00\x00\x00\x24\x6D\x6C\x75\x63\x00\x00\x00\x00\x00\x00"
27+
"\x00\x01\x00\x00\x00\x0C\x65\x6E\x55\x53\x00\x00\x00\x24\x00\x00"
28+
"\x00\x1C\x00\x47\x00\x49\x00\x4D\x00\x50\x00\x20\x00\x62\x00\x75"
29+
"\x00\x69\x00\x6C\x00\x74\x00\x2D\x00\x69\x00\x6E\x00\x20\x00\x73"
30+
"\x00\x52\x00\x47\x00\x42\x6D\x6C\x75\x63\x00\x00\x00\x00\x00\x00"
31+
"\x00\x01\x00\x00\x00\x0C\x65\x6E\x55\x53\x00\x00\x00\x1A\x00\x00"
32+
"\x00\x1C\x00\x50\x00\x75\x00\x62\x00\x6C\x00\x69\x00\x63\x00\x20"
33+
"\x00\x44\x00\x6F\x00\x6D\x00\x61\x00\x69\x00\x6E\x00\x00\x58\x59"
34+
"\x5A\x20\x00\x00\x00\x00\x00\x00\xF6\xD6\x00\x01\x00\x00\x00\x00"
35+
"\xD3\x2D\x73\x66\x33\x32\x00\x00\x00\x00\x00\x01\x0C\x42\x00\x00"
36+
"\x05\xDE\xFF\xFF\xF3\x25\x00\x00\x07\x93\x00\x00\xFD\x90\xFF\xFF"
37+
"\xFB\xA1\xFF\xFF\xFD\xA2\x00\x00\x03\xDC\x00\x00\xC0\x6E\x58\x59"
38+
"\x5A\x20\x00\x00\x00\x00\x00\x00\x6F\xA0\x00\x00\x38\xF5\x00\x00"
39+
"\x03\x90\x58\x59\x5A\x20\x00\x00\x00\x00\x00\x00\x24\x9F\x00\x00"
40+
"\x0F\x84\x00\x00\xB6\xC4\x58\x59\x5A\x20\x00\x00\x00\x00\x00\x00"
41+
"\x62\x97\x00\x00\xB7\x87\x00\x00\x18\xD9\x70\x61\x72\x61\x00\x00"
42+
"\x00\x00\x00\x03\x00\x00\x00\x02\x66\x66\x00\x00\xF2\xA7\x00\x00"
43+
"\x0D\x59\x00\x00\x13\xD0\x00\x00\x0A\x5B\x63\x68\x72\x6D\x00\x00"
44+
"\x00\x00\x00\x03\x00\x00\x00\x00\xA3\xD7\x00\x00\x54\x7C\x00\x00"
45+
"\x4C\xCD\x00\x00\x99\x9A\x00\x00\x26\x67\x00\x00\x0F\x5C\x6D\x6C"
46+
"\x75\x63\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x0C\x65\x6E"
47+
"\x55\x53\x00\x00\x00\x08\x00\x00\x00\x1C\x00\x47\x00\x49\x00\x4D"
48+
"\x00\x50\x6D\x6C\x75\x63\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00"
49+
"\x00\x0C\x65\x6E\x55\x53\x00\x00\x00\x08\x00\x00\x00\x1C\x00\x73"
50+
"\x00\x52\x00\x47\x00\x42\x56\x50\x38\x4C\xAB\x03\x00\x00\x2F\x3F"
51+
"\xC0\x07\x00\x87\xE3\x38\x92\x24\x47\xA9\x1A\xB4\x56\x3F\x02\x3B"
52+
"\x70\x16\x27\x09\x7E\x27\x98\x76\xC3\x41\x6C\xDB\xAA\xB2\xF7\x37"
53+
"\xDC\xBD\x05\x4D\x08\xCE\x50\x00\x1A\xB8\xBB\x5C\xC7\x91\x6C\xAB"
54+
"\xCA\x9C\xFB\x1D\x77\x59\xB3\xA4\x08\x81\xE8\x89\x83\x08\xDC\x1D"
55+
"\xCE\xFC\x07\x10\x44\x00\x86\x08\x40\x20\x44\x10\x11\x7C\x45\x00"
56+
"\x26\x10\x40\x10\x88\xB4\x00\x09\x7F\x60\x84\x80\x04\x04\x88\x91"
57+
"\xA0\x00\x18\x42\x01\x22\x82\xA2\x50\x51\x59\xFC\xD0\x5F\x4C\x22"
58+
"\x20\x7F\xAB\x2C\x28\x40\xFC\x67\x40\x40\x54\xC8\xBE\x7C\xDA\xB2"
59+
"\x48\x49\xA2\x0C\x78\x33\x16\xE8\xF8\x0A\xD6\x3F\xEB\xF8\x23\xF0"
60+
"\xBF\xFF\x3C\xDA\x13\x31\xAC\x22\x61\x9A\xAB\x65\xAA\x8F\x63\xB5"
61+
"\x7B\x18\xD7\x77\x3D\x3F\x7A\xAE\xBE\x58\x4C\x9D\x2F\x33\xEB\x2C"
62+
"\x97\x48\xAD\xAD\xD9\x96\x0A\x43\x6B\xE3\xF5\x5F\xB0\xF6\xC3\xA1"
63+
"\x6B\x5F\xAA\x79\xB4\xBB\xB6\x69\xAE\x68\x9A\x7E\xB2\x88\xCA\xCA"
64+
"\xBF\x65\x9A\xFB\x3D\xB7\xA6\xB0\xEF\x64\x65\xF8\xBC\xFC\xF9\x78"
65+
"\x4F\x97\x56\xB5\x8B\x5B\x7D\x84\x67\xDB\x65\x90\x20\x79\xE1\xDD"
66+
"\x75\x6C\x85\xE2\xED\xFF\xEB\x38\x56\x73\xFB\xEA\x17\xFF\x86\x53"
67+
"\xB5\x66\x74\xED\x33\x9B\x83\x74\xDB\xB6\xD5\x3C\x59\xD4\x2D\xF5"
68+
"\xD4\x5D\x42\xDD\xDD\x5D\x2E\x5E\x03\x3E\x1C\xEA\x7A\xDE\xFF\x67"
69+
"\x73\xCE\xCD\x65\xF4\x05\x22\xFA\xCF\x40\x92\x14\x27\x50\xA6\x31"
70+
"\xB0\x5C\x2D\x3E\x82\x2E\x92\x17\xE6\xC4\xBC\x30\x4F\xE8\x7A\xC1"
71+
"\x27\xBA\xE9\x8A\x89\x10\x91\x67\x1E\xC3\x33\x17\xCB\x11\xA5\x07"
72+
"\x10\x21\x16\x10\xC5\x05\x25\xC1\xEC\x22\x54\x15\x41\xEB\x4C\xA4"
73+
"\xCB\xCF\x91\x54\x95\x80\x57\x8B\xD2\xE0\x39\xD5\x38\x96\x08\x49"
74+
"\xB9\xDD\x2B\x1D\x92\xEA\x51\x7D\xC6\x5E\x45\x5A\x43\x44\x9C\x72"
75+
"\x8B\xC5\x74\x66\x5F\xD7\x0B\x01\x92\xAA\x12\xF0\xAE\x06\x5D\xE2"
76+
"\x3D\xD5\x18\xD3\x8D\xA7\x92\x60\x22\xF6\x61\x73\xAA\x0A\x64\x63"
77+
"\xDB\x05\x8A\xE3\x2B\x10\xFC\x72\x26\x56\x0F\x18\xAE\x3A\xF5\xE8"
78+
"\x40\x6B\x09\xE7\xFF\xE1\x3B\x22\xFC\xD9\x11\x70\xEA\xC7\x01\x7E"
79+
"\x0E\xCA\x4C\x5D\x0D\x01\xD8\xCF\x6D\x14\xB5\xD1\x44\x3E\x05\x2A"
80+
"\xB2\xC4\x79\xB1\xF5\xB8\xE5\x11\x60\x2D\x60\xEB\x0A\xC6\x6C\x82"
81+
"\x1E\x0B\xE5\xD5\x98\x06\xD5\x8E\xF2\x91\x90\x18\xFF\xF5\x5A\x07"
82+
"\x65\x78\xC5\x08\x13\xD4\x38\x24\xE2\xC1\xCD\xDA\x73\xDE\xB9\x23"
83+
"\x2C\x8C\x30\x81\x58\x29\x51\xB8\x42\x61\x11\xE9\xB2\x0D\x49\x42"
84+
"\xA1\xF1\x7D\xC0\xAE\x0B\xF1\x2C\x8F\xC5\x79\x06\xC7\xD2\xCC\xA0"
85+
"\xF2\x7F\x05\x84\x46\xA4\x06\x31\x26\xD2\xAB\x14\x8E\x3D\x9B\x11"
86+
"\xA0\xCF\xFA\xC4\x2C\x8B\xEE\xA1\xDF\xEF\xBB\xBC\x0C\x4F\x45\x25"
87+
"\x2B\x00\x23\x54\xE3\xCD\x3E\x3D\x12\x5D\xE4\x29\x5E\x60\xFC\x17"
88+
"\xE6\x3B\xF6\x2B\x27\xC7\x27\xA6\x76\xA9\xF1\xC6\xEB\x2C\x71\x9D"
89+
"\x99\x73\xE7\xE5\xA5\xCB\xBB\xBB\x97\x97\x4F\xBB\x07\x6B\x78\x22"
90+
"\x22\x7A\x55\x5B\x59\xD7\xDA\x33\x3A\xDA\x52\x5F\x5E\x91\xD7\x40"
91+
"\x3E\x0D\x6A\x4A\xB3\x9F\x80\x85\x81\x6B\x77\x77\xEE\x96\x13\x2A"
92+
"\x54\x25\xA5\x67\x90\x29\x06\x49\x98\x67\x9A\x41\xBF\xD6\xEC\x59"
93+
"\x86\x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7C\x1A\xF7"
109+
"\xE3\xDB\xB7\xDC\x9F\xA3\x8F\x31\x11\x00";

lib/assets/tronbyt_config.webp

1.62 KB
Binary file not shown.

lib/assets/tronbyt_config.xcf

2.16 MB
Binary file not shown.

src/main.c

Lines changed: 31 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -181,10 +181,6 @@ void app_main(void) {
181181
mac[2], mac[3], mac[4], mac[5]);
182182
}
183183

184-
// Log the AP information
185-
ESP_LOGI(TAG, "WiFi AP started with SSID: Tronbyt-Config");
186-
ESP_LOGI(TAG, "Connect to this network and navigate to http://10.10.0.1 to configure WiFi");
187-
188184
// Wait for WiFi connection (with a 60-second timeout)
189185
// This will block until either connected or timeout
190186
if (!wifi_wait_for_connection(60000)) {
@@ -197,40 +193,54 @@ void app_main(void) {
197193
const char* image_url = wifi_get_image_url();
198194
const char* url_to_use = (image_url != NULL && strlen(image_url) > 0) ? image_url : DEFAULT_URL;
199195

196+
// Load up the config webp so that we don't just loop the boot screen over and over again but show the ap config info webp
197+
ESP_LOGI(TAG,"Loading Config WEBP");
198+
gfx_update(ASSET_CONFIG_WEBP, ASSET_CONFIG_WEBP_LEN);
199+
200+
if (!wifi_is_connected()) {
201+
ESP_LOGW(TAG,"Pausing main task until wifi connected . . . ");
202+
while(!wifi_is_connected()) {
203+
vTaskDelay(pdMS_TO_TICKS(1 * 1000));
204+
}
205+
}
206+
207+
ESP_LOGI(TAG, "WiFi Connected, continuing main task thread . . . ");
208+
200209
// Check for ws:// or wss:// in the URL
201210
if (strstr(url_to_use, "ws://") != NULL) {
202-
ESP_LOGI(TAG,"Using websockets with URL: %s", url_to_use);
211+
ESP_LOGI(TAG, "Using websockets with URL: %s", url_to_use);
203212
use_websocket = true;
204213
// setup ws event handlers
205-
const esp_websocket_client_config_t ws_cfg = {
206-
.uri = url_to_use,
207-
.buffer_size = 10000};
214+
const esp_websocket_client_config_t ws_cfg = {.uri = url_to_use,
215+
.buffer_size = 10000};
208216
ws_handle = esp_websocket_client_init(&ws_cfg);
209217
esp_err_t start_error = esp_websocket_client_start(ws_handle);
210218
if (start_error != ESP_OK) {
211-
ESP_LOGE(TAG, "couldn't connect to websocket url %s with error code %i", url_to_use, start_error);
219+
ESP_LOGE(TAG, "couldn't connect to websocket url %s with error code %i",
220+
url_to_use, start_error);
212221
// display error ?
213222
} else {
214223
// esp_websocket_register_events(ws_handle, RX_EVENT, RX_HANDLER_FUNC,
215224
// void *event_handler_arg)
216-
esp_websocket_register_events(ws_handle, WEBSOCKET_EVENT_ANY, websocket_event_handler, (void *)ws_handle);
225+
esp_websocket_register_events(ws_handle, WEBSOCKET_EVENT_ANY,
226+
websocket_event_handler,
227+
(void *)ws_handle);
217228
esp_websocket_client_start(ws_handle);
218229
}
219-
}
220-
else
221-
{
230+
} else {
222231
// normal http
223232
ESP_LOGW(TAG, "HTTP Loop Start with URL: %s", url_to_use);
224233
for (;;) {
225-
uint8_t* webp;
234+
uint8_t *webp;
226235
size_t len;
227236
static uint8_t brightness_pct = DISPLAY_DEFAULT_BRIGHTNESS;
228237

229238
if (use_websocket) {
230239
// let the events do the work.
231240
} else {
232-
// Check if the image URL has changed (user might have updated it via WiFi manager)
233-
const char* new_image_url = wifi_get_image_url();
241+
// Check if the image URL has changed (user might have updated it via
242+
// WiFi manager)
243+
const char *new_image_url = wifi_get_image_url();
234244
if (new_image_url != NULL && strlen(new_image_url) > 0) {
235245
url_to_use = new_image_url;
236246
} else {
@@ -250,17 +260,19 @@ void app_main(void) {
250260
free(webp);
251261
// Wait for app_dwell_secs to expire (isAnimating will be 0)
252262
ESP_LOGI(TAG, BLUE "isAnimating is %d" RESET, (int)isAnimating);
253-
if (isAnimating > 0) ESP_LOGI(TAG, BLUE "Delay for current webp" RESET);
263+
if (isAnimating > 0)
264+
ESP_LOGI(TAG, BLUE "Delay for current webp" RESET);
254265
while (isAnimating > 0) {
255266
vTaskDelay(pdMS_TO_TICKS(1));
256267
}
257268
ESP_LOGI(TAG, BLUE "Setting isAnimating to %d" RESET,
258269
(int)app_dwell_secs);
259-
isAnimating = app_dwell_secs; // use isAnimating as the container for
260-
// app_dwell_secs
270+
isAnimating = app_dwell_secs; // use isAnimating as the container
271+
// for app_dwell_secs
261272
vTaskDelay(pdMS_TO_TICKS(1000));
262273
}
263274
}
264275
}
265276
}
277+
266278
}

0 commit comments

Comments
 (0)