From e8f8f694f03ae5dfc98590521003e4b6348984de Mon Sep 17 00:00:00 2001 From: anschrammh Date: Thu, 19 Oct 2023 08:31:07 +0200 Subject: [PATCH] Updated CodeBlocks LVGL simulator main.c file --- .../lv_port_win_codeblocks/main.c | 35 ++++++++++++++++--- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/src/lvgl_win_sim/lv_port_win_codeblocks/main.c b/src/lvgl_win_sim/lv_port_win_codeblocks/main.c index 1ad164b..2aa2fe5 100644 --- a/src/lvgl_win_sim/lv_port_win_codeblocks/main.c +++ b/src/lvgl_win_sim/lv_port_win_codeblocks/main.c @@ -62,6 +62,30 @@ static void date_time_cb(struct tm * const dateTime) *dateTime = *tm; } +static void compass_screen_on_state_change_cb(CompassScreenState_e compassScreenState) +{ + switch(compassScreenState) + { + case COMPASS_SCREEN_OPENED: + LV_LOG_USER("Compass Screen opened"); + break; + case COMPASS_SCREEN_CLOSED: + default: + LV_LOG_USER("Compass Screen closed"); + break; + } +} + +static void azimuth_and_temperature_cb(uint16_t *azimuth, float *temperature) +{ + static uint16_t _azimuth = 0; + static float _temp = -20; + + *azimuth = _azimuth++; + *temperature = _temp += 0.9; + if(_temp > 120) _temp = -20; +} + static void alti_meas_cb(float * const temperature, float * const pressure, float * const altitude) { static float a = 425.5; @@ -110,21 +134,24 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLi lv_win32_init(hInstance, SW_SHOWNORMAL, 240, 240, NULL); /*Output prompt information to the console, you can also use printf() to print directly*/ - LV_LOG_USER("LVGL initialization completed!"); + LV_LOG_USER("LVGL initialization completed, color size is : %u !", LV_COLOR_SIZE); LV_IMG_DECLARE(watch_mask) /*Run the demo*/ //lv_demo_widgets(); - lv_obj_t *top_layer = lv_layer_top(); + lv_obj_t *sys_layer = lv_layer_sys(); //We apply the mask to simulate what we can see on the watch screen - lv_obj_t *screen_mask = lv_img_create(top_layer); + lv_obj_t *screen_mask = lv_img_create(sys_layer); lv_img_set_src(screen_mask, &watch_mask); watch_face_init(&watchFace); menu_screen_init(&menuScreen); compass_screen_init(&compassScreen); + compass_screen_register_on_state_change_cb(&compassScreen, &(compass_screen_on_state_change_cb)); + compass_screen_register_azimuth_and_temperature_cb(&compassScreen, &(azimuth_and_temperature_cb)); settings_screen_init(&settingsScreen); altimeter_screen_init(&altimeterScreen); + altimeter_screen_register_measurement_cb(&altimeterScreen, &(alti_meas_cb)); notification_screen_init(¬ificationScreen); find_my_phone_screen_init(&findMyPhoneScreen); find_my_phone_screen_register_BLE_command_send_cb(&findMyPhoneScreen, &(sendMyFindPhoneBLECommandCb)); @@ -138,8 +165,6 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLi music_player_screen_set_music_position(&musicPlayerScreen, 2*60+12); music_player_screen_set_music_playing_state(&musicPlayerScreen, MUSIC_CONTROL_PLAY); - altimeter_screen_register_measurement_cb(&altimeterScreen, &(alti_meas_cb)); - watch_face_register_date_time_cb(&watchFace, &(date_time_cb)); watch_face_create(&watchFace);