Fixed a bug where on watch screen creation, depending on the current battery state, I paused a timer which was not yet created...
This commit is contained in:
parent
b19c7defc7
commit
d796c4c0fa
@ -303,11 +303,7 @@ void watch_face_create(WatchFace_t * const watchFace)
|
||||
lv_obj_del(watchFace->batteryIndicator.batteryIcon);
|
||||
watchFace->batteryIndicator.batteryIcon = NULL;
|
||||
}
|
||||
|
||||
watchFace->batteryIndicator.batteryIcon = lv_img_create(watchFace->display);
|
||||
set_battery_state_icon(watchFace);
|
||||
lv_img_set_zoom(watchFace->batteryIndicator.batteryIcon, 141);
|
||||
lv_obj_align_to(watchFace->batteryIndicator.batteryIcon, watchFace->batteryIndicator.label, LV_ALIGN_OUT_BOTTOM_MID, 0, -9);
|
||||
|
||||
if(watchFace->batteryIndicator.lowBatteryAnimationTimer)
|
||||
{
|
||||
@ -318,6 +314,12 @@ void watch_face_create(WatchFace_t * const watchFace)
|
||||
watchFace->batteryIndicator.lowBatteryAnimationTimer = lv_timer_create(&(battery_timer_anim_cb), 500, watchFace);
|
||||
lv_timer_pause(watchFace->batteryIndicator.lowBatteryAnimationTimer);
|
||||
|
||||
// set_battery_state_icon internally needs to interact with the lowBatteryAnimationTimer,
|
||||
// this is why we call the function after the timer has been created
|
||||
set_battery_state_icon(watchFace);
|
||||
lv_img_set_zoom(watchFace->batteryIndicator.batteryIcon, 141);
|
||||
lv_obj_align_to(watchFace->batteryIndicator.batteryIcon, watchFace->batteryIndicator.label, LV_ALIGN_OUT_BOTTOM_MID, 0, -9);
|
||||
|
||||
// Bluetooth status icon is created here
|
||||
if(watchFace->bluetoothIndicator.bluetoothIcon)
|
||||
{
|
||||
|
@ -1,7 +1,9 @@
|
||||
#include "lvgl.h"
|
||||
#include "watch_face.h"
|
||||
#include "menu_screen.h"
|
||||
#include "notification_screen.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
LV_IMG_DECLARE(battery_low_icon)
|
||||
LV_IMG_DECLARE(battery_charging_icon)
|
||||
@ -64,8 +66,6 @@ static void cleanup_event_cb(lv_event_t * e)
|
||||
|
||||
static void update_watch_hands_angles(WatchFace_t * const watchFace, uint8_t increment)
|
||||
{
|
||||
|
||||
static uint8_t dateNum = 1;
|
||||
if(!watchFace)
|
||||
{
|
||||
LV_LOG_ERROR("NULL pointer given !");
|
||||
@ -76,16 +76,13 @@ static void update_watch_hands_angles(WatchFace_t * const watchFace, uint8_t inc
|
||||
if(watchFace->dateTimeCb)
|
||||
{
|
||||
//We compute each hand angle
|
||||
if(!increment || watchFace->secondHand.handAngle >= 3660 || (int)watchFace->secondHand.handAngle % 100 > 50)
|
||||
if(!increment || watchFace->secondHand.handAngle >= 3660 /*|| (int)watchFace->secondHand.handAngle % 100 > 50*/)
|
||||
{
|
||||
watchFace->dateTimeCb(&watchFace->dateTime);
|
||||
watchFace->secondHand.handAngle = 60 * watchFace->dateTime.tm_sec;
|
||||
|
||||
dateNum++;
|
||||
dateNum %= 31;
|
||||
|
||||
//Don't forget to update the day date window
|
||||
sprintf(watchFace->dateWindow.dateWindowText, "%d", /*watchFace->dateTime.tm_mday*/ dateNum);
|
||||
sprintf(watchFace->dateWindow.dateWindowText, "%d", watchFace->dateTime.tm_mday);
|
||||
lv_label_set_text_static(watchFace->dateWindow.dateWindowWidget, watchFace->dateWindow.dateWindowText);
|
||||
|
||||
if(watchFace->batteryIndicatorCb)
|
||||
@ -206,6 +203,20 @@ static void hide_hour_and_minutes_hand_cb(lv_event_t *e)
|
||||
lv_obj_add_flag(watchFace->hourHand.handImg, LV_OBJ_FLAG_HIDDEN);
|
||||
lv_obj_add_flag(watchFace->minuteHand.handImg, LV_OBJ_FLAG_HIDDEN);
|
||||
}*/
|
||||
|
||||
//Just for testing purposes, create a new notification
|
||||
char *title = malloc(strlen("JoeJohny John")+1);
|
||||
strcpy(title, "JoeJohny John");
|
||||
|
||||
char *body = malloc(300+1);
|
||||
strcpy(body, "Hey what's up dude ? What are you doing tonight ?\
|
||||
Wanna go to the fair with me ?\
|
||||
This is a quite long message I agree, but it is important\
|
||||
to let you know what I do for me and you bro !");
|
||||
|
||||
extern NotificationScreen_t notificationScreen;
|
||||
notification_screen_notify(¬ificationScreen, 1696358171, time(NULL) + 3600*2, NOTIFICATION_TYPE_GADGET_BRIDGE, title, body);
|
||||
LV_LOG_USER("unread(%u)/ total(%u)", notification_screen_unread_notification_count(¬ificationScreen), notification_screen_notification_count(¬ificationScreen));
|
||||
}
|
||||
|
||||
void watch_face_init(WatchFace_t * const watchFace)
|
||||
@ -304,11 +315,7 @@ void watch_face_create(WatchFace_t * const watchFace)
|
||||
lv_obj_del(watchFace->batteryIndicator.batteryIcon);
|
||||
watchFace->batteryIndicator.batteryIcon = NULL;
|
||||
}
|
||||
|
||||
watchFace->batteryIndicator.batteryIcon = lv_img_create(watchFace->display);
|
||||
set_battery_state_icon(watchFace);
|
||||
lv_img_set_zoom(watchFace->batteryIndicator.batteryIcon, 141);
|
||||
lv_obj_align_to(watchFace->batteryIndicator.batteryIcon, watchFace->batteryIndicator.label, LV_ALIGN_OUT_BOTTOM_MID, 0, -9);
|
||||
|
||||
if(watchFace->batteryIndicator.lowBatteryAnimationTimer)
|
||||
{
|
||||
@ -319,6 +326,12 @@ void watch_face_create(WatchFace_t * const watchFace)
|
||||
watchFace->batteryIndicator.lowBatteryAnimationTimer = lv_timer_create(&(battery_timer_anim_cb), 500, watchFace);
|
||||
lv_timer_pause(watchFace->batteryIndicator.lowBatteryAnimationTimer);
|
||||
|
||||
// set_battery_state_icon internally needs to interact with the lowBatteryAnimationTimer,
|
||||
// this is why we call the function after the timer has been created
|
||||
set_battery_state_icon(watchFace);
|
||||
lv_img_set_zoom(watchFace->batteryIndicator.batteryIcon, 141);
|
||||
lv_obj_align_to(watchFace->batteryIndicator.batteryIcon, watchFace->batteryIndicator.label, LV_ALIGN_OUT_BOTTOM_MID, 0, -9);
|
||||
|
||||
// Bluetooth status icon is created here
|
||||
if(watchFace->bluetoothIndicator.bluetoothIcon)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user