Skip to content

Commit

Permalink
feat(esp-brookesia): update to v0.4.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Lzw655 committed Oct 27, 2024
1 parent 5b7c4e3 commit d236328
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 27 deletions.
2 changes: 1 addition & 1 deletion components/esp-brookesia
Submodule esp-brookesia updated 327 files
12 changes: 11 additions & 1 deletion components/esp_brookesia_conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,16 @@
#define ESP_BROOKESIA_SQ1_4_1_LV8_3_11 // | 1.4.1 | 8.3.11 |
#endif /* ESP_BROOKESIA_SQUARELINE_USE_INTERNAL_UI_HELPERS */

/**
* Use the internal general APIs of "ui_comp.c" and "ui_comp.h" instead of the ones exported from Squareline Studio.
* 1: enable, 0: disable
*
* This configuration is to avoid function redefinition errors caused by multiple UIs exported from Squareline Studio
* that include duplicate APIs of "ui_comp.c" and "ui_comp.h".
*
*/
#define ESP_BROOKESIA_SQUARELINE_USE_INTERNAL_UI_COMP (1)

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////// File Version ///////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Expand All @@ -116,5 +126,5 @@
*
*/
#define ESP_BROOKESIA_CONF_FILE_VER_MAJOR 0
#define ESP_BROOKESIA_CONF_FILE_VER_MINOR 1
#define ESP_BROOKESIA_CONF_FILE_VER_MINOR 2
#define ESP_BROOKESIA_CONF_FILE_VER_PATCH 0
62 changes: 37 additions & 25 deletions main/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,20 @@
/*********************
* DEFINES
*********************/
#if (DISP_HOR_RES == 1024) && (DISP_VER_RES == 600)
#define EXAMPLE_ESP_BROOKESIA_PHONE_DARK_STYLESHEET() ESP_BROOKESIA_PHONE_1024_600_DARK_STYLESHEET()
#elif (DISP_HOR_RES == 800) && (DISP_VER_RES == 480)
#define EXAMPLE_ESP_BROOKESIA_PHONE_DARK_STYLESHEET() ESP_BROOKESIA_PHONE_800_480_DARK_STYLESHEET()
#if (DISP_HOR_RES == 320) && (DISP_VER_RES == 240)
#define EXAMPLE_ESP_BROOKESIA_PHONE_DARK_STYLESHEET() ESP_BROOKESIA_PHONE_320_240_DARK_STYLESHEET()
#elif (DISP_HOR_RES == 320) && (DISP_VER_RES == 480)
#define EXAMPLE_ESP_BROOKESIA_PHONE_DARK_STYLESHEET() ESP_BROOKESIA_PHONE_320_480_DARK_STYLESHEET()
#elif (DISP_HOR_RES == 480) && (DISP_VER_RES == 480)
#define EXAMPLE_ESP_BROOKESIA_PHONE_DARK_STYLESHEET() ESP_BROOKESIA_PHONE_480_480_DARK_STYLESHEET()
#elif (DISP_HOR_RES == 320) && (DISP_VER_RES == 240)
#define EXAMPLE_ESP_BROOKESIA_PHONE_DARK_STYLESHEET() ESP_BROOKESIA_PHONE_320_240_DARK_STYLESHEET()
#elif (DISP_HOR_RES == 800) && (DISP_VER_RES == 480)
#define EXAMPLE_ESP_BROOKESIA_PHONE_DARK_STYLESHEET() ESP_BROOKESIA_PHONE_800_480_DARK_STYLESHEET()
#elif (DISP_HOR_RES == 800) && (DISP_VER_RES == 1280)
#define EXAMPLE_ESP_BROOKESIA_PHONE_DARK_STYLESHEET() ESP_BROOKESIA_PHONE_800_1280_DARK_STYLESHEET()
#elif (DISP_HOR_RES == 1024) && (DISP_VER_RES == 600)
#define EXAMPLE_ESP_BROOKESIA_PHONE_DARK_STYLESHEET() ESP_BROOKESIA_PHONE_1024_600_DARK_STYLESHEET()
#elif (DISP_HOR_RES == 1280) && (DISP_VER_RES == 800)
#define EXAMPLE_ESP_BROOKESIA_PHONE_DARK_STYLESHEET() ESP_BROOKESIA_PHONE_1280_800_DARK_STYLESHEET()
#endif

/**********************
Expand Down Expand Up @@ -115,11 +121,13 @@ int main(int argc, char **argv)

#ifdef EXAMPLE_ESP_BROOKESIA_PHONE_DARK_STYLESHEET
/* Add external stylesheet and activate it */
ESP_Brookesia_PhoneStylesheet_t *phone_stylesheet = new ESP_Brookesia_PhoneStylesheet_t EXAMPLE_ESP_BROOKESIA_PHONE_DARK_STYLESHEET();
ESP_BROOKESIA_CHECK_NULL_RETURN(phone_stylesheet, 1, "Create phone stylesheet failed");
ESP_BROOKESIA_CHECK_FALSE_RETURN(phone->addStylesheet(phone_stylesheet), 1, "Add phone stylesheet failed");
ESP_BROOKESIA_CHECK_FALSE_RETURN(phone->activateStylesheet(phone_stylesheet), 1, "Activate phone stylesheet failed");
delete phone_stylesheet;
ESP_Brookesia_PhoneStylesheet_t *stylesheet = new ESP_Brookesia_PhoneStylesheet_t EXAMPLE_ESP_BROOKESIA_PHONE_DARK_STYLESHEET();
ESP_BROOKESIA_CHECK_NULL_RETURN(stylesheet, 1, "Create phone stylesheet failed");

printf("Using stylesheet (%s)", stylesheet->core.name);
ESP_BROOKESIA_CHECK_FALSE_RETURN(phone->addStylesheet(stylesheet), 1, "Add phone stylesheet failed");
ESP_BROOKESIA_CHECK_FALSE_RETURN(phone->activateStylesheet(stylesheet), 1, "Activate phone stylesheet failed");
delete stylesheet;
#endif

/* Configure and begin the phone */
Expand All @@ -128,18 +136,18 @@ int main(int argc, char **argv)
// ESP_BROOKESIA_CHECK_FALSE_RETURN(phone->getCoreHome().showContainerBorder(), 1, "Show container border failed");

/* Install apps */
PhoneAppSimpleConf *phone_app_simple_conf = new PhoneAppSimpleConf(true, true);
ESP_BROOKESIA_CHECK_NULL_RETURN(phone_app_simple_conf, 1, "Create phone app simple conf failed");
ESP_BROOKESIA_CHECK_FALSE_RETURN((phone->installApp(phone_app_simple_conf) >= 0), 1, "Install phone app simple conf failed");
PhoneAppComplexConf *phone_app_complex_conf = new PhoneAppComplexConf(true, true);
ESP_BROOKESIA_CHECK_NULL_RETURN(phone_app_complex_conf, 1, "Create phone app complex conf failed");
ESP_BROOKESIA_CHECK_FALSE_RETURN((phone->installApp(phone_app_complex_conf) >= 0), 1, "Install phone app complex conf failed");
PhoneAppSquareline *phone_app_squareline = new PhoneAppSquareline(true, true);
ESP_BROOKESIA_CHECK_NULL_RETURN(phone_app_squareline, 1, "Create phone app squareline failed");
ESP_BROOKESIA_CHECK_FALSE_RETURN((phone->installApp(phone_app_squareline) >= 0), 1, "Install phone app squareline failed");
PhoneAppSimpleConf *app_simple_conf = new PhoneAppSimpleConf();
ESP_BROOKESIA_CHECK_NULL_RETURN(app_simple_conf, 1, "Create app simple conf failed");
ESP_BROOKESIA_CHECK_FALSE_RETURN((phone->installApp(app_simple_conf) >= 0), 1, "Install app simple conf failed");
PhoneAppComplexConf *app_complex_conf = new PhoneAppComplexConf();
ESP_BROOKESIA_CHECK_NULL_RETURN(app_complex_conf, 1, "Create app complex conf failed");
ESP_BROOKESIA_CHECK_FALSE_RETURN((phone->installApp(app_complex_conf) >= 0), 1, "Install app complex conf failed");
PhoneAppSquareline *app_squareline = new PhoneAppSquareline();
ESP_BROOKESIA_CHECK_NULL_RETURN(app_squareline, 1, "Create app squareline failed");
ESP_BROOKESIA_CHECK_FALSE_RETURN((phone->installApp(app_squareline) >= 0), 1, "Install app squareline failed");

/* Create a timer to update the clock */
ESP_BROOKESIA_CHECK_NULL_RETURN(lv_timer_create(on_clock_update_timer_cb, 1000, phone), 1, "Create clock update timer failed");
// ESP_BROOKESIA_CHECK_NULL_RETURN(lv_timer_create(on_clock_update_timer_cb, 1000, phone), 1, "Create clock update timer failed");

while(1) {
/* Periodically call the lv_task handler.
Expand All @@ -165,15 +173,19 @@ static void on_clock_update_timer_cb(struct _lv_timer_t *t)
time(&now);
get_local_time(&timeinfo, &now);
is_time_pm = (timeinfo.tm_hour >= 12);
ESP_BROOKESIA_CHECK_FALSE_EXIT(phone->getHome().getStatusBar()->setClock(timeinfo.tm_hour, timeinfo.tm_min, is_time_pm),
"Refresh status bar failed");
ESP_BROOKESIA_CHECK_FALSE_EXIT(
phone->getHome().getStatusBar()->setClock(timeinfo.tm_hour, timeinfo.tm_min, is_time_pm),
"Refresh status bar failed"
);

lv_mem_monitor_t mon;
lv_mem_monitor(&mon);
uint32_t free_kb = mon.free_size / 1024;
uint32_t total_kb = mon.total_size / 1024;
ESP_BROOKESIA_CHECK_FALSE_EXIT(phone->getHome().getRecentsScreen()->setMemoryLabel(free_kb, total_kb, 0, 0),
"Refresh memory label failed");
ESP_BROOKESIA_CHECK_FALSE_EXIT(
phone->getHome().getRecentsScreen()->setMemoryLabel(free_kb, total_kb, 0, 0),
"Refresh memory label failed"
);
}

/**
Expand Down

0 comments on commit d236328

Please sign in to comment.