Files
OmniNX-Installer-Payload/bdk/libs/lvgl/lv_themes/lv_theme.c
T
niklascfw 1b4a81239b Update BDK to hekate v6.5.5
Replaces the old vendored BDK with the one from hekate v6.5.5 (CTCaer's
2025/2026 refactors: sdmmc, SE, minerva v1.6, display, heap, return
value homogenisation). OmniNX additions re-applied on top:
bq24193_charger_connected() and jc_clear_input(); s_vprintf now ships
with the BDK.

Ported to the new API:
- sd_mount(), sdmmc_storage_* and ini_parse() now return 0 on success.
  The installer checked ini_parse() != 1, which would have made it miss
  manifest.ini and run every install as a clean install.
- SD helpers come from bdk/storage/sd.c (source/nx_sd.* removed),
  ffsystem.c from the BDK, diskio.c/ffconf.h from hekate (ffconf keeps
  the sd:/ volume prefix).
- minerva_init() needs the minerva storage; the installer still drops
  to 800 MHz afterwards.
- Payload launch follows hekate (sd_file_read, hw_deinit); coreboot
  path removed upstream.
- Stack moved to 0x96000000: the old 0x83100000 is inside the new heap.
- GUI/USB/compression parts of the BDK are not built.
2026-11-12 23:17:18 +01:00

113 lines
3.2 KiB
C

/**
* @file lv_theme.c
*
*/
/*********************
* INCLUDES
*********************/
#include "lv_theme.h"
#include "../lv_core/lv_obj.h"
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
/**********************
* STATIC PROTOTYPES
**********************/
/**********************
* STATIC VARIABLES
**********************/
#if LV_THEME_LIVE_UPDATE == 0
static lv_theme_t * current_theme;
#else
/* If live update is used then a big `lv_style_t` array is used to store the real styles of the theme not only pointers.
* On `lv_theme_set_current` the styles of the theme are copied to this array.
* The pointers in `current_theme` are initialized to point to the styles in the array.
* This way the theme styles will always point to the same memory address even after theme is change.
* (The pointers in the theme points to the styles declared by the theme itself) */
/* Store the styles in this array.
* Can't determine the size in compile time because sizeof is not evaluated (should be `sizeof(lv_theme_t) / sizeof(lv_style_t*)`).
* Error will be generated in run time if too small.*/
static lv_style_t th_styles[120];
static bool inited = false;
static lv_theme_t current_theme;
#endif
/**********************
* MACROS
**********************/
/**********************
* GLOBAL FUNCTIONS
**********************/
/**
* Set a theme for the system.
* From now, all the created objects will use styles from this theme by default
* @param th pointer to theme (return value of: 'lv_theme_init_xxx()')
*/
void lv_theme_set_current(lv_theme_t * th)
{
#if LV_THEME_LIVE_UPDATE == 0
current_theme = th;
#else
uint32_t style_num = sizeof(lv_theme_t) / sizeof(lv_style_t *); /*Number of styles in a theme*/
if(!inited) {
/*It's not sure `th_styles` is big enough. Check it now!*/
if(style_num > sizeof(th_styles) / sizeof(lv_style_t)) {
LV_LOG_ERROR("Themes: th_styles array is too small. Increase it's size!");
while(1);
}
/*Initialize the style pointers `current_theme` to point to the `th_styles` style array */
uint16_t i;
lv_style_t ** cur_th_style_p = (lv_style_t **) &current_theme;
for(i = 0; i < style_num; i++) {
uintptr_t adr = (uintptr_t)&th_styles[i];
memcpy(&cur_th_style_p[i], &adr, sizeof(lv_style_t *));
}
inited = true;
}
/*Copy the styles pointed by the new theme to the `th_styles` style array*/
uint16_t i;
lv_style_t ** th_style = (lv_style_t **) th;
for(i = 0; i < style_num; i++) {
uintptr_t s = (uintptr_t)th_style[i];
if(s) memcpy(&th_styles[i], (void *)s, sizeof(lv_style_t));
}
/*Let the object know their style might change*/
lv_obj_report_style_mod(NULL);
#endif
}
/**
* Get the current system theme.
* @return pointer to the current system theme. NULL if not set.
*/
lv_theme_t * lv_theme_get_current(void)
{
#if LV_THEME_LIVE_UPDATE == 0
return current_theme;
#else
if(!inited) return NULL;
else return &current_theme;
#endif
}
/**********************
* STATIC FUNCTIONS
**********************/