Skip to content

Commit 0cc1fed

Browse files
authored
Merge pull request #174 from baba-dev/codex/locate-references-to-png-backgrounds
chore: remove wallpaper png lookups
2 parents 6b437f8 + e7f2d79 commit 0cc1fed

3 files changed

Lines changed: 2 additions & 100 deletions

File tree

custom/assets/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ firmware consumes at startup.
66

77
| id | Source file | Mounted path |
88
| --- | --- | --- |
9-
| *(example)* `bg_default` | `bg/default.png` | `/spiffs/custom/assets/bg/default.png` |
9+
| *(example)* `icon_play` | `icons/play.webp` | `/spiffs/custom/assets/icons/play.webp` |
1010

1111
Add or update rows when you introduce new images or fonts so UI code can reference the
1212
correct mount paths. Keep the filenames stable; bots only touch generated outputs under

custom/assets/asset_mount.c

Lines changed: 1 addition & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -188,93 +188,9 @@ static void lv_fs_if_init(void)
188188
#define ASSET_LOGW(tag, fmt, ...) LV_LOG_WARN(fmt, ##__VA_ARGS__)
189189
#endif
190190

191-
#define SD_ASSET_ROOT "/sdcard/custom/assets"
192-
#if !defined(ESP_PLATFORM) && defined(LV_FS_IF_POSIX) && (LV_FS_IF_POSIX != '\0')
193-
#define INTERNAL_ASSET_ROOT "./custom/assets"
194-
#else
195-
#define INTERNAL_ASSET_ROOT "/custom/assets"
196-
#endif
197-
#define BG_RELATIVE "/bg"
198-
199191
static const char *k_tag = "assets";
200192

201193
static bool s_fs_initialized = false;
202-
static bool s_sd_ok = false;
203-
static bool s_warned_missing = false;
204-
205-
static const char *drive_prefix(void)
206-
{
207-
#if defined(LV_FS_IF_POSIX) && (LV_FS_IF_POSIX != '\0')
208-
static const char prefix[] = {LV_FS_IF_POSIX, ':', '\0'};
209-
return prefix;
210-
#elif defined(LV_FS_MEMFS_LETTER) && (LV_FS_MEMFS_LETTER != '\0')
211-
static const char prefix[] = {LV_FS_MEMFS_LETTER, ':', '\0'};
212-
return prefix;
213-
#else
214-
return "";
215-
#endif
216-
}
217-
218-
static bool path_exists(const char *path)
219-
{
220-
if (path == NULL) {
221-
return false;
222-
}
223-
224-
lv_fs_file_t file;
225-
lv_fs_res_t res = lv_fs_open(&file, path, LV_FS_MODE_RD);
226-
if (res == LV_FS_RES_OK) {
227-
lv_fs_close(&file);
228-
return true;
229-
}
230-
return false;
231-
}
232-
233-
static bool format_path(char *buffer, size_t size, const char *root, const char *relative)
234-
{
235-
const char *prefix = drive_prefix();
236-
int length = snprintf(buffer, size, "%s%s%s/%s", prefix, root, BG_RELATIVE, relative);
237-
return length > 0 && length < (int)size;
238-
}
239-
240-
static const char *pick_file(const char *relative, char *buffer, size_t size)
241-
{
242-
if (buffer == NULL || size == 0) {
243-
return NULL;
244-
}
245-
246-
if (s_sd_ok && format_path(buffer, size, SD_ASSET_ROOT, relative) && path_exists(buffer)) {
247-
return buffer;
248-
}
249-
250-
static const char *const k_internal_roots[] = {
251-
#if defined(CONFIG_BSP_SPIFFS_MOUNT_POINT)
252-
CONFIG_BSP_SPIFFS_MOUNT_POINT "/custom/assets",
253-
#endif
254-
INTERNAL_ASSET_ROOT,
255-
};
256-
257-
for (size_t i = 0; i < (sizeof(k_internal_roots) / sizeof(k_internal_roots[0])); i++) {
258-
const char *root = k_internal_roots[i];
259-
if (root == NULL || root[0] == '\0') {
260-
continue;
261-
}
262-
if (!format_path(buffer, size, root, relative)) {
263-
continue;
264-
}
265-
if (path_exists(buffer)) {
266-
return buffer;
267-
}
268-
}
269-
270-
if (!s_warned_missing && format_path(buffer, size, INTERNAL_ASSET_ROOT, relative)) {
271-
s_warned_missing = true;
272-
ASSET_LOGW(k_tag, "Falling back to built-in wallpaper path: %s", buffer);
273-
return buffer;
274-
}
275-
276-
return NULL;
277-
}
278194

279195
void assets_fs_init(void)
280196
{
@@ -286,7 +202,7 @@ void assets_fs_init(void)
286202
#if LV_USE_FS_IF
287203
lv_fs_if_init();
288204
#else
289-
LV_LOG_WARN("LV_USE_FS_IF disabled; wallpaper loading from FS unavailable");
205+
LV_LOG_WARN("LV_USE_FS_IF disabled; asset loading from FS unavailable");
290206
#endif
291207

292208
#if defined(ESP_PLATFORM)
@@ -295,15 +211,3 @@ void assets_fs_init(void)
295211
ASSET_LOGI(k_tag, "Desktop build: using host filesystem without SD mount");
296212
#endif
297213
}
298-
299-
const char *assets_path_1(void)
300-
{
301-
static char path_buffer[128];
302-
return pick_file("1.png", path_buffer, sizeof(path_buffer));
303-
}
304-
305-
const char *assets_path_2(void)
306-
{
307-
static char path_buffer[128];
308-
return pick_file("2.png", path_buffer, sizeof(path_buffer));
309-
}

custom/assets/asset_mount.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ extern "C" {
1010
#endif
1111

1212
void assets_fs_init(void);
13-
const char *assets_path_1(void);
14-
const char *assets_path_2(void);
1513

1614
#ifdef __cplusplus
1715
}

0 commit comments

Comments
 (0)