Compare commits

...

8 Commits

24 changed files with 2795 additions and 3617 deletions

View File

@ -22,6 +22,19 @@
#define HARDWARE_PLATFORM SMART_WATCH_PCB_RELEASE
/**
* @brief Defines which watch face to use :
*
* SMART_WATCH_CASIO_FACE : this is the first watch face ported to the watch based on a casio edifice watch.
* SMART_WATCH_CARBON_FACE : a watch face designed from the ground up using a carbon fiber vibe.
*
*/
#define SMART_WATCH_CASIO_FACE (0)
#define SMART_WATCH_CARBON_FACE (1)
#define SMART_WATCH_FACE SMART_WATCH_CARBON_FACE
/**
* @brief Define which kind of logs to display :
*

View File

@ -78,7 +78,7 @@ uint32_t random_gen_6_digit(void)
unsigned char random_buf[6] = {0};
uint32_t output_num = 0;
tls_crypto_random_init(0x19031998, CRYPTO_RNG_SWITCH_16);
tls_crypto_random_init(elapsed_ms(), CRYPTO_RNG_SWITCH_16);
tls_crypto_random_bytes(random_buf, sizeof random_buf);
tls_crypto_random_stop();

View File

@ -7,9 +7,9 @@
* @date 2023-04-05
* Updated : 2023-10-15, fixed potential memory leak.
* Updated : 2023-10-17, fixed potential issue where a double quote is added at the start of a parsed string.
*
*
* @copyright MIT
*
*
*/
#include "gadget_bridge.h"
@ -93,6 +93,7 @@ static time_t _unix_timestamp = 0;
/* Internal function definition */
static const char *_gadget_bridge_toast_type_2_str(gadget_bridge_toast_type_e toast_type);
static const char *_gadget_bridge_music_control_2_str(gadget_bridge_music_control_e music_control);
static const char *_gadget_bridge_notification_action_2_str(gadget_bridge_notification_action_e notification_action);
static const char *_gadget_bridge_http_request_method_2_str(gadget_bridge_http_request_method_e http_request_method);
static void _parser_free_buffer(uint16_t length);
static void _free_event_data(void);
@ -138,8 +139,8 @@ bool gadget_bridge_send_battery_status(uint8_t battery_level_in_percent, float b
bool to_return = true;
char num_2_str[30] = "";
to_return &= ble_service_send_nus_data((const uint8_t *)"{\"t\":\"status\",\"bat\":", 20);
sprintf(num_2_str, "%u,\"chg\":%u,\"volt\":%.3f} \n", battery_level_in_percent, is_charging, battery_level_in_V);
to_return &= ble_service_send_nus_data((const uint8_t *)num_2_str, strlen(num_2_str));
int length = sprintf(num_2_str, "%u,\"chg\":%u,\"volt\":%.3f} \n", battery_level_in_percent, is_charging, battery_level_in_V);
to_return &= ble_service_send_nus_data((const uint8_t *)num_2_str, length);
return to_return;
}
@ -166,6 +167,41 @@ bool gadget_bridge_send_music_control(gadget_bridge_music_control_e music_contro
return to_return;
}
bool gadget_bridge_send_notification_action(gadget_bridge_notification_action_e notification_action, uint32_t handle, const char *phone_number, const char *message)
{
bool to_return = true;
char num_2_str[11] = "";
// There is no point sending a reply without an actual message
if(notification_action == GADGET_BRIDGE_NOTIFICATION_ACTION_REPLY && !message)
return false;
to_return &= ble_service_send_nus_data((const uint8_t *)"{\"t\":\"notify\",\"n\":\"", 19);
to_return &= ble_service_send_nus_data((const uint8_t *)_gadget_bridge_notification_action_2_str(notification_action), strlen(_gadget_bridge_notification_action_2_str(notification_action)));
to_return &= ble_service_send_nus_data((const uint8_t *)"\",\"id\":", 7);
int length = sprintf(num_2_str, "%u", handle);
to_return &= ble_service_send_nus_data((const uint8_t *)num_2_str, length);
if(notification_action == GADGET_BRIDGE_NOTIFICATION_ACTION_REPLY)
{
if(phone_number)
{
to_return &= ble_service_send_nus_data((const uint8_t *)",\"tel\":\"", 8);
to_return &= ble_service_send_nus_data((const uint8_t *)phone_number, strlen(phone_number));
to_return &= ble_service_send_nus_data((const uint8_t *)"\"", 1);
}
to_return &= ble_service_send_nus_data((const uint8_t *)",\"msg\":\"", 8);
to_return &= ble_service_send_nus_data((const uint8_t *)message, strlen(message));
to_return &= ble_service_send_nus_data((const uint8_t *)"\"", 1);
}
to_return &= ble_service_send_nus_data((const uint8_t *)"} \n", 3);
return to_return;
}
bool gadget_bridge_send_activity_data(uint16_t heart_rate_in_bpm, uint32_t step_count)
{
bool to_return = true;
@ -173,13 +209,13 @@ bool gadget_bridge_send_activity_data(uint16_t heart_rate_in_bpm, uint32_t step_
//{\"t\":\"act\",\"hrm\":%s,\"stp\":%s} \n
to_return &= ble_service_send_nus_data((const uint8_t *)"{\"t\":\"act\",\"hrm\":", 17);
sprintf(num_2_str, "%u", heart_rate_in_bpm);
to_return &= ble_service_send_nus_data((const uint8_t *)num_2_str, strlen(num_2_str));
int length = sprintf(num_2_str, "%u", heart_rate_in_bpm);
to_return &= ble_service_send_nus_data((const uint8_t *)num_2_str, length);
to_return &= ble_service_send_nus_data((const uint8_t *)",\"stp\":", 7);
sprintf(num_2_str, "%u", step_count);
to_return &= ble_service_send_nus_data((const uint8_t *)num_2_str, strlen(num_2_str));
length = sprintf(num_2_str, "%u", step_count);
to_return &= ble_service_send_nus_data((const uint8_t *)num_2_str, length);
to_return &= ble_service_send_nus_data((const uint8_t *)"} \n", 3);
@ -190,10 +226,10 @@ bool gadget_bridge_send_http_request(uint32_t id, const char *url, gadget_bridge
{
bool to_return = true;
char num_2_str[11] = "";
sprintf(num_2_str, "%u", id);
int length = sprintf(num_2_str, "%u", id);
to_return &= ble_service_send_nus_data((const uint8_t *)"{\"t\":\"http\",\"id\":\"", 18);
to_return &= ble_service_send_nus_data((const uint8_t *)num_2_str, strlen(num_2_str));
to_return &= ble_service_send_nus_data((const uint8_t *)num_2_str, length);
to_return &= ble_service_send_nus_data((const uint8_t *)"\",\"url\":\"", 9);
to_return &= ble_service_send_nus_data((const uint8_t *)url, strlen(url));
to_return &= ble_service_send_nus_data((const uint8_t *)"\",\"method\":\"", 12);
@ -1318,6 +1354,24 @@ static const char *_gadget_bridge_music_control_2_str(gadget_bridge_music_contro
}
}
static const char *_gadget_bridge_notification_action_2_str(gadget_bridge_notification_action_e notification_action)
{
switch(notification_action)
{
case GADGET_BRIDGE_NOTIFICATION_ACTION_DISMISS_ALL:
return "dismiss_all";
case GADGET_BRIDGE_NOTIFICATION_ACTION_OPEN:
return "open";
case GADGET_BRIDGE_NOTIFICATION_ACTION_MUTE:
return "mute";
case GADGET_BRIDGE_NOTIFICATION_ACTION_REPLY:
return "reply";
case GADGET_BRIDGE_NOTIFICATION_ACTION_DISMISS:
default :
return "dismiss";
}
}
static const char *_gadget_bridge_http_request_method_2_str(gadget_bridge_http_request_method_e http_request_method)
{
switch(http_request_method)

View File

@ -5,9 +5,9 @@
* over BLE.
* @version 0.1
* @date 2023-04-04
*
*
* @copyright MIT
*
*
*/
#ifndef GADGET_BRIDGE_H
@ -19,7 +19,7 @@
/**
* @brief GADGET_BRIDGE_PARSER_BUFFER_SIZE allows to set the size of the buffer
* which is internally used by the parser to do it's job.
*
*
*/
#define GADGET_BRIDGE_PARSER_BUFFER_SIZE (300)
@ -27,21 +27,21 @@
* @brief GADGET_BRIDGE_PARSER_BUFFER_THRESHOLD permits to set a size threshold used to free up
* some space in the parser's internal buffer when the threshold is reached.
* This ensures that we can keep on feeding new data and not get stuck.
*
*
*/
#define GADGET_BRIDGE_PARSER_BUFFER_THRESHOLD (100)
/**
* @brief GADGET_BRIDGE_PARSER_MAX_BODY_SIZE defines the max body size that will be saved in the event_data
* structure when parsing the body of a notification.
*
*
*/
#define GADGET_BRIDGE_PARSER_MAX_BODY_SIZE (200)
/**
* @brief GADGET_BRIDGE_PARSER_MAX_TITLE_SIZE defines the max title size that will be saved in the event_data
* structure when parsing the title of a notification.
*
*
*/
#define GADGET_BRIDGE_PARSER_MAX_TITLE_SIZE (100)
@ -205,7 +205,7 @@ typedef void (*parser_event_callback_t)(gadget_bridge_event_data_t *gadget_bridg
/**
* @brief Sends an Android toast to GadgetBridge to be displayed on the phone.
*
*
* @param toast_type the type of the toast (INFO, WARN or ERROR).
* @param message a string representing the message to display.
* @return true if the command was successfully sent.
@ -216,7 +216,7 @@ bool gadget_bridge_send_toast(gadget_bridge_toast_type_e toast_type, const char
/**
* @brief Sends up to two firmwares version to GadgetBridge.
* These are displayed in the display details section of the watch in GadgetBridge.
*
*
* @param fw1 a string representing the first firmware version.
* @param fw2 a string representing the second firmware version.
* @return true if the command was successfully sent.
@ -226,7 +226,7 @@ bool gadget_bridge_send_firmware_version(const char *fw1, const char *fw2);
/**
* @brief Sends the current battery status to GadgetBridge.
*
*
* @param battery_level_in_percent the current battery level from 0 to 100%.
* @param battery_level_in_V the current battery voltage in volts (3.942 for example).
* @param is_charging a boolean which indicates if the battery is currently charging or not.
@ -238,7 +238,7 @@ bool gadget_bridge_send_battery_status(uint8_t battery_level_in_percent, float b
/**
* @brief Sends the find phone command to GagdetBridge, this will make the phone ring and vibrate
* so that you can locate it.
*
*
* @param find_phone a boolean which indicates to make the phone rind and vibrate or not.
* @return true if the command was successfully sent.
* @return false otherwise.
@ -247,22 +247,33 @@ bool gadget_bridge_send_find_phone(bool find_phone);
/**
* @brief Sends a command to control the music playback of the phone through GadgetBridge.
*
* @param music_control an enumeration value indicating the action to perform:
*
* @param music_control an enumeration value indicating the action to perform :
* PLAY, PAUSE, NEXT, PREVIOUS, VOLUMEUP etc..
* @return true if the command was successfully sent.
* @return false otherwise.
*/
bool gadget_bridge_send_music_control(gadget_bridge_music_control_e music_control);
/**
* @brief Sends a command to perform an action to the specified received notification.
*
* @param notification_action an enumeration value indicating the action to perform on the notification :
* DISMISS, DISMISS_ALL, OPEN, MUTE and REPLY.
* @param handle the notification's handle.
* @param phone_number a string containing a phone number to send the REPLY to or NULL to use the same number as the notification.
* @param message a string containing the message to send to a REPLY action, can be NULL if the action is different.
* @return true if the command was successfully sent.
* @return false otherwise.
*/
bool gadget_bridge_send_notification_action(gadget_bridge_notification_action_e notification_action, uint32_t handle, const char *phone_number, const char *message);
bool gadget_bridge_handle_call(gadget_bridge_call_action_e call_action);
bool gadget_bridge_handle_notification(gadget_bridge_call_action_e notification_action, uint32_t handle, const char *phone_number, const char *message);
/**
* @brief Sends the provided activity data to GadgetBridge. This will then be displayed
* @brief Sends the provided activity data to GadgetBridge. This will then be displayed
* on the app in the activity section.
*
*
* @param heart_rate_in_bpm the current heart rate in beat per minute
* @param step_count the number of new steps since the last time the count was sent.
* @return true if the command was successfully sent.
@ -273,7 +284,7 @@ bool gadget_bridge_send_activity_data(uint16_t heart_rate_in_bpm, uint32_t step_
/**
* @brief Tells GadgetBridge to perform an HTTP request for us.
* @note THIS DOES NOT WORK as GadgetBridge don't and will never have network permission... what a pitty !
*
*
* @param id an unsigned integer representing the ID of the http request
* @param url a string representing the URL to fetch
* @param http_request_method a enumeration value specifying the http verb to use : GET, POST, PATCH etc..
@ -288,14 +299,14 @@ bool gadget_bridge_send_http_request(uint32_t id, const char *url, gadget_bridge
/**
* @brief Registers a callback function used to listen for GadgetBridge events.
*
* @param parser_event_callback
*
* @param parser_event_callback
*/
void gadget_bridge_parser_register_event_callback(parser_event_callback_t parser_event_callback);
/**
* @brief Feeds new data to the GadgetBridge parser.
*
*
* @param data the new chunk of data to parse, it will be copied to the parser's internal buffer,
* so you can free the memory containing the string after calling the function.
* @param length the length in bytes of the new chunk.
@ -306,7 +317,7 @@ gadget_bridge_parser_code_e gadget_bridge_parser_feed(const char *data, uint16_t
/**
* @brief Call this function to run the parser.
* It should be safe to call if in a loop like : while((code = gadget_bridge_parser_run()) == GADGET_BRIDGE_PARSER_CODE_PARSING);
*
*
* @return gadget_bridge_parser_code_e the parser's execution status code.
*/
gadget_bridge_parser_code_e gadget_bridge_parser_run(void);

File diff suppressed because one or more lines are too long

View File

@ -524,7 +524,7 @@ static void ble_service_nus_data_rx_cb(const uint8_t *data, uint16_t length)
gadget_bridge_parser_feed((const char *)data, length);
while(gadget_bridge_parser_run() == GADGET_BRIDGE_PARSER_CODE_PARSING);
}
static uint32_t bt_ctrl_sleep_ms = 0;
static void ble_service_state_change_cb(ble_service_state_e ble_service_state)
{
switch(ble_service_state)
@ -537,7 +537,7 @@ static void ble_service_state_change_cb(ble_service_state_e ble_service_state)
ble_service_update_connection_parameters(
84, // itvl_min 105 ms
120, // itvl_max 150 ms
5, // latency 5
2, // latency 2
1000, // supervision timeout 10 s
0x0010, // min connection event length 10 ms
0x0300 // max connection event length 480 ms
@ -656,7 +656,7 @@ static void sendMusicPlaybackBLECommandCb(MusicPlaybackCtrlAction_e musicPlaybac
gadget_bridge_send_music_control(musicPlaybackCtrlAction);
}
static void notification_on_state_change_cb(NotificationState_e notificationState)
static void notification_on_state_change_cb(NotificationState_e notificationState, uint32_t notification_handle)
{
switch (notificationState)
{
@ -669,6 +669,9 @@ static void notification_on_state_change_cb(NotificationState_e notificationStat
case NOTIFICATION_STATE_CLEARED:
// Let's restore MCU clocks to it's default
watch_power_management_restore_default_cpu_clocks(true, true);
// Don't forget to tell GadgetBridge that the notification was dismissed
gadget_bridge_send_notification_action(GADGET_BRIDGE_NOTIFICATION_ACTION_DISMISS, notification_handle, NULL, NULL);
default:
break;
}

View File

@ -38,7 +38,7 @@ static void notification_scrolled_event_cb(lv_event_t *e)
_notification_popup_destroy(notificationScreen);
notificationScreen->new_notification_available = false;
notification->read = true;
if(notificationScreen->notificationOnStateChangeCb) notificationScreen->notificationOnStateChangeCb(NOTIFICATION_STATE_CLEARED);
if(notificationScreen->notificationOnStateChangeCb) notificationScreen->notificationOnStateChangeCb(NOTIFICATION_STATE_CLEARED, notification->handle);
}
}
@ -120,7 +120,7 @@ void notification_screen_notify(NotificationScreen_t * const notificationScreen,
case NOTIFICATION_TYPE_CALL:
break;
default:
if(notificationScreen->notificationOnStateChangeCb) notificationScreen->notificationOnStateChangeCb(NOTIFICATION_STATE_DISPLAYED);
if(notificationScreen->notificationOnStateChangeCb) notificationScreen->notificationOnStateChangeCb(NOTIFICATION_STATE_DISPLAYED, notification->handle);
_display_message_notification(notificationScreen, notification);
}
}
@ -309,7 +309,7 @@ void _display_message_notification(NotificationScreen_t * const notificationScre
lv_label_set_long_mode(notificationScreen->type_label, LV_LABEL_LONG_SCROLL_CIRCULAR);
lv_obj_set_style_anim_speed(notificationScreen->type_label, 10, LV_PART_MAIN);
lv_obj_set_width(notificationScreen->type_label, lv_pct(27));
lv_label_set_text(notificationScreen->type_label, _notification_type_to_char(notification->type));
lv_label_set_text_static(notificationScreen->type_label, _notification_type_to_char(notification->type));
if(notificationScreen->title_label)
{

View File

@ -38,7 +38,7 @@ typedef struct NotificationData
} NotificationData_t, *NotificationDataList_t;
typedef void (*NotificationOnStateChangeCb_t)(NotificationState_e notificationState);
typedef void (*NotificationOnStateChangeCb_t)(NotificationState_e notificationState, uint32_t notification_handle);
typedef struct NotificationScreen
{
@ -59,7 +59,6 @@ typedef struct NotificationScreen
// Miscellaneous
bool new_notification_available : 1;
bool notification_hour_24H_format : 1;
} NotificationScreen_t;
void notification_screen_init(NotificationScreen_t * const notificationScreen);

View File

@ -3,11 +3,70 @@
#include "menu_screen.h"
#include <stdio.h>
#include "app_log.h"
#include "app_config.h"
LV_IMG_DECLARE(battery_low_icon)
LV_IMG_DECLARE(battery_charging_icon)
LV_IMG_DECLARE(battery_charged_icon)
#if SMART_WATCH_FACE == SMART_WATCH_CASIO_FACE
//We declare the needed assets for the casio watch face:
LV_IMG_DECLARE(watch_casio_face_asset)
LV_IMG_DECLARE(watch_casio_hour_hand_asset)
LV_IMG_DECLARE(watch_casio_minute_hand_asset)
LV_IMG_DECLARE(watch_casio_second_hand_asset)
LV_IMG_DECLARE(watch_casio_medium_hand_asset)
static const void *watch_face_img = &watch_casio_face_asset;
static const void *watch_hour_hand_img = &watch_casio_hour_hand_asset;
#define HOUR_HAND_POS 112, 60
#define HOUR_HAND_PIVOT 8, 60
static const void *watch_minute_hand_img = &watch_casio_minute_hand_asset;
#define MINUTE_HAND_POS 112, 28
#define MINUTE_HAND_PIVOT 7, 92
static const void *watch_second_hand_img = &watch_casio_second_hand_asset;
#define SECOND_HAND_POS 115, 28
#define SECOND_HAND_PIVOT 5, 92
static const void *watch_medium_hand_img = &watch_casio_medium_hand_asset;
#define MEDIUM_HAND_POS 115, 48
#define MEDIUM_HAND_PIVOT 4, 25
#define BATTERY_ARC_OFFSETS -1, 45
#define BATTERY_ICON_OFFSETS 0, -9
#define STEP_COUNTER_LABEL_POS 63, 111
#define DATE_WINDOW_POS 180, 111
#define DATE_LABEL_COLOR lv_color_black()
#elif SMART_WATCH_FACE == SMART_WATCH_CARBON_FACE
//We declare the needed assets for the carbon watch face:
LV_IMG_DECLARE(watch_carbon_face_asset)
LV_IMG_DECLARE(watch_carbon_hour_hand_asset)
LV_IMG_DECLARE(watch_carbon_minute_hand_asset)
LV_IMG_DECLARE(watch_carbon_second_hand_asset)
LV_IMG_DECLARE(watch_carbon_medium_hand_asset)
static const void *watch_face_img = &watch_carbon_face_asset;
static const void *watch_hour_hand_img = &watch_carbon_hour_hand_asset;
#define HOUR_HAND_POS 113, 57
#define HOUR_HAND_PIVOT 6, 62
static const void *watch_minute_hand_img = &watch_carbon_minute_hand_asset;
#define MINUTE_HAND_POS 113, 14
#define MINUTE_HAND_PIVOT 6, 105
static const void *watch_second_hand_img = &watch_carbon_second_hand_asset;
#define SECOND_HAND_POS 115, -1
#define SECOND_HAND_PIVOT 4, 120
static const void *watch_medium_hand_img = &watch_carbon_medium_hand_asset;
#define MEDIUM_HAND_POS 115, 50
#define MEDIUM_HAND_PIVOT 4, 26
#define BATTERY_ARC_OFFSETS 0, 44
#define BATTERY_ICON_OFFSETS 0, -12
#define STEP_COUNTER_LABEL_POS 50, 111
#define DATE_WINDOW_POS 168, 111
#define DATE_LABEL_COLOR lv_color_white()
#else
#error "Bad app_config.h configuration for the selected watch face"
#endif //SMART_WATCH_FACE
static void _set_bluetooth_indicator(WatchFace_t * const watchFace)
{
switch(watchFace->bluetoothIndicator.bluetoothState)
@ -238,11 +297,6 @@ void watch_face_create(WatchFace_t * const watchFace)
}
//We declare the needed assets for the watch face:
LV_IMG_DECLARE(watch_carbon_face_asset)
LV_IMG_DECLARE(watch_carbon_hour_hand_asset)
LV_IMG_DECLARE(watch_carbon_minute_hand_asset)
LV_IMG_DECLARE(watch_carbon_second_hand_asset)
LV_IMG_DECLARE(watch_carbon_medium_hand_asset)
LV_IMG_DECLARE(bluetooth_icon)
//We create our parent screen :
@ -254,16 +308,10 @@ void watch_face_create(WatchFace_t * const watchFace)
}
//Our display is the watch face image :
watchFace->display = lv_img_create(NULL);
lv_img_set_src(watchFace->display, &watch_carbon_face_asset);
lv_img_set_src(watchFace->display, watch_face_img);
lv_obj_set_style_bg_color(watchFace->display, lv_color_black(), LV_PART_MAIN);
lv_obj_add_event_cb(watchFace->display, &(hide_hour_and_minutes_hand_cb), LV_EVENT_LONG_PRESSED, watchFace);
//We load our other assets :
/*lv_obj_t *smallHandImg = lv_img_create(watchFace->display);
lv_img_set_src(smallHandImg, &watch_casio_small_hand_asset);
lv_obj_set_pos(smallHandImg, 69, 98);
lv_img_set_pivot(smallHandImg, 4, 20);*/
//Battery arc is created here
if(watchFace->batteryIndicator.batteryArc)
{
@ -276,7 +324,7 @@ void watch_face_create(WatchFace_t * const watchFace)
lv_obj_remove_style(watchFace->batteryIndicator.batteryArc, NULL, LV_PART_KNOB);
lv_obj_clear_flag(watchFace->batteryIndicator.batteryArc, LV_OBJ_FLAG_CLICKABLE);
lv_obj_set_size(watchFace->batteryIndicator.batteryArc, 60, 60);
lv_obj_align(watchFace->batteryIndicator.batteryArc, LV_ALIGN_CENTER, 0, 44);
lv_obj_align(watchFace->batteryIndicator.batteryArc, LV_ALIGN_CENTER, BATTERY_ARC_OFFSETS);
lv_obj_set_style_arc_width(watchFace->batteryIndicator.batteryArc, 5, LV_PART_INDICATOR);
lv_obj_set_style_arc_width(watchFace->batteryIndicator.batteryArc, 0, LV_PART_MAIN);
lv_obj_set_style_arc_color(watchFace->batteryIndicator.batteryArc, lv_color_make(228, 233, 236), LV_PART_INDICATOR);
@ -317,7 +365,7 @@ void watch_face_create(WatchFace_t * const watchFace)
// 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, -12);
lv_obj_align_to(watchFace->batteryIndicator.batteryIcon, watchFace->batteryIndicator.label, LV_ALIGN_OUT_BOTTOM_MID, BATTERY_ICON_OFFSETS);
// Bluetooth status icon is created here
if(watchFace->bluetoothIndicator.bluetoothIcon)
@ -345,7 +393,7 @@ void watch_face_create(WatchFace_t * const watchFace)
watchFace->stepCounter.label = lv_label_create(watchFace->display);
lv_label_set_text_static(watchFace->stepCounter.label, watchFace->stepCounter.text);
lv_obj_set_style_text_color(watchFace->stepCounter.label, lv_color_white(), LV_PART_MAIN);
lv_obj_set_pos(watchFace->stepCounter.label, 50, 111);
lv_obj_set_pos(watchFace->stepCounter.label, STEP_COUNTER_LABEL_POS);
if(watchFace->mediumHand24h.handImg)
{
@ -355,9 +403,9 @@ void watch_face_create(WatchFace_t * const watchFace)
}
watchFace->mediumHand24h.handImg = lv_img_create(watchFace->display);
lv_img_set_src(watchFace->mediumHand24h.handImg, &watch_carbon_medium_hand_asset);
lv_obj_set_pos(watchFace->mediumHand24h.handImg, 115, 50);
lv_img_set_pivot(watchFace->mediumHand24h.handImg, 4, 26);
lv_img_set_src(watchFace->mediumHand24h.handImg, watch_medium_hand_img);
lv_obj_set_pos(watchFace->mediumHand24h.handImg, MEDIUM_HAND_POS);
lv_img_set_pivot(watchFace->mediumHand24h.handImg, MEDIUM_HAND_PIVOT);
/*lv_obj_t *mediumHandChronoImg = lv_img_create(watchFace->display);
lv_img_set_src(mediumHandChronoImg, &watch_casio_medium_hand_asset);
@ -373,10 +421,10 @@ void watch_face_create(WatchFace_t * const watchFace)
}
watchFace->dateWindow.dateWindowWidget = lv_label_create(watchFace->display);
lv_label_set_text_static(watchFace->dateWindow.dateWindowWidget, watchFace->dateWindow.dateWindowText);
lv_obj_set_pos(watchFace->dateWindow.dateWindowWidget, 168,111);
lv_obj_set_pos(watchFace->dateWindow.dateWindowWidget, DATE_WINDOW_POS);
lv_obj_set_width(watchFace->dateWindow.dateWindowWidget, 20);
lv_obj_set_style_text_align(watchFace->dateWindow.dateWindowWidget, LV_TEXT_ALIGN_CENTER, LV_PART_MAIN);
lv_obj_set_style_text_color(watchFace->dateWindow.dateWindowWidget, lv_color_white(), LV_PART_MAIN);
lv_obj_set_style_text_color(watchFace->dateWindow.dateWindowWidget, DATE_LABEL_COLOR, LV_PART_MAIN);
if(watchFace->hourHand.handImg)
{
@ -386,9 +434,9 @@ void watch_face_create(WatchFace_t * const watchFace)
}
watchFace->hourHand.handImg = lv_img_create(watchFace->display);
lv_img_set_src(watchFace->hourHand.handImg, &watch_carbon_hour_hand_asset);
lv_obj_set_pos(watchFace->hourHand.handImg, 113, 57);
lv_img_set_pivot(watchFace->hourHand.handImg, 6, 62);
lv_img_set_src(watchFace->hourHand.handImg, watch_hour_hand_img);
lv_obj_set_pos(watchFace->hourHand.handImg, HOUR_HAND_POS);
lv_img_set_pivot(watchFace->hourHand.handImg, HOUR_HAND_PIVOT);
if(watchFace->minuteHand.handImg)
{
@ -398,9 +446,9 @@ void watch_face_create(WatchFace_t * const watchFace)
}
watchFace->minuteHand.handImg = lv_img_create(watchFace->display);
lv_img_set_src(watchFace->minuteHand.handImg, &watch_carbon_minute_hand_asset);
lv_obj_set_pos(watchFace->minuteHand.handImg, 113, 14);
lv_img_set_pivot(watchFace->minuteHand.handImg, 6, 105);
lv_img_set_src(watchFace->minuteHand.handImg, watch_minute_hand_img);
lv_obj_set_pos(watchFace->minuteHand.handImg, MINUTE_HAND_POS);
lv_img_set_pivot(watchFace->minuteHand.handImg, MINUTE_HAND_PIVOT);
if(watchFace->secondHand.handImg)
{
@ -410,9 +458,9 @@ void watch_face_create(WatchFace_t * const watchFace)
}
watchFace->secondHand.handImg = lv_img_create(watchFace->display);
lv_img_set_src(watchFace->secondHand.handImg, &watch_carbon_second_hand_asset);
lv_obj_set_pos(watchFace->secondHand.handImg, 115, -1);
lv_img_set_pivot(watchFace->secondHand.handImg, 4, 120);
lv_img_set_src(watchFace->secondHand.handImg, watch_second_hand_img);
lv_obj_set_pos(watchFace->secondHand.handImg, SECOND_HAND_POS);
lv_img_set_pivot(watchFace->secondHand.handImg, SECOND_HAND_PIVOT);
//We set the appropriate angles to each of the hands
update_watch_hands_angles(watchFace, 0);

View File

@ -1,575 +0,0 @@
#include "lvgl.h"
#include "watch_face.h"
#include "menu_screen.h"
#include <stdio.h>
#include "app_log.h"
LV_IMG_DECLARE(battery_low_icon)
LV_IMG_DECLARE(battery_charging_icon)
LV_IMG_DECLARE(battery_charged_icon)
static void _set_bluetooth_indicator(WatchFace_t * const watchFace)
{
switch(watchFace->bluetoothIndicator.bluetoothState)
{
case BLUETOOTH_STATE_ON:
lv_obj_set_style_img_recolor_opa(watchFace->bluetoothIndicator.bluetoothIcon, 185, LV_PART_MAIN);
lv_obj_clear_flag(watchFace->bluetoothIndicator.bluetoothIcon, LV_OBJ_FLAG_HIDDEN);
break;
case BLUETOOTH_STATE_CONNECTED:
lv_obj_set_style_img_recolor_opa(watchFace->bluetoothIndicator.bluetoothIcon, 0, LV_PART_MAIN);
lv_obj_clear_flag(watchFace->bluetoothIndicator.bluetoothIcon, LV_OBJ_FLAG_HIDDEN);
break;
default:
lv_obj_add_flag(watchFace->bluetoothIndicator.bluetoothIcon, LV_OBJ_FLAG_HIDDEN);
}
}
static void gesture_event_cb(lv_event_t *e)
{
WatchFace_t *watchFace = lv_event_get_user_data(e);
lv_dir_t gesture;
switch(gesture = lv_indev_get_gesture_dir(lv_indev_get_act()))
{
case LV_DIR_LEFT:
LV_LOG_USER("GESTURE : LEFT");
break;
case LV_DIR_RIGHT:
LV_LOG_USER("GESTURE : RIGHT");
// We delete the timer
lv_timer_del(watchFace->batteryIndicator.lowBatteryAnimationTimer);
lv_timer_del(watchFace->handAnimationTimer);
lv_timer_del(watchFace->stepCounterRefreshTimer);
// We create the menu screen and switch to it
extern MenuScreen_t menuScreen;
menu_screen_create(&menuScreen);
lv_scr_load_anim(menuScreen.display, LV_SCR_LOAD_ANIM_MOVE_RIGHT, 400, 0, true);
break;
case LV_DIR_TOP:
LV_LOG_USER("GESTURE : TOP");
break;
case LV_DIR_BOTTOM:
LV_LOG_USER("GESTURE : BOTTOM");
break;
default:
LV_LOG_USER("GESTURE : %u", gesture);
}
}
static void cleanup_event_cb(lv_event_t *e)
{
WatchFace_t *watchFace = lv_event_get_user_data(e);
watch_face_destroy(watchFace);
LV_LOG_USER("cleanup");
}
static void update_watch_hands_angles(WatchFace_t * const watchFace, uint8_t increment)
{
if(!watchFace)
{
LV_LOG_ERROR("NULL pointer given !");
return;
}
//We retrieve the current time:
if(watchFace->dateTimeCb)
{
//We compute each hand angle
if(!increment || watchFace->secondHand.handAngle >= 3660)
{
watchFace->dateTimeCb(&watchFace->dateTime);
watchFace->secondHand.handAngle = 60 * watchFace->dateTime.tm_sec;
//Don't forget to update the day date window
sprintf(watchFace->dateWindow.dateWindowText, "%d", watchFace->dateTime.tm_mday);
lv_label_set_text_static(watchFace->dateWindow.dateWindowWidget, watchFace->dateWindow.dateWindowText);
APP_LOG_DEBUG("Syncing time");
if(watchFace->batteryIndicatorCb)
{
uint8_t levelInPercent = 0;
BatteryState_e batteryState = BATTERY_STATE_DISCHARGING;
watchFace->batteryIndicatorCb(&levelInPercent, &batteryState);
watch_face_set_battery_indicator(watchFace, levelInPercent, batteryState);
}
}
else
{
watchFace->secondHand.handAngle += increment;
}
watchFace->minuteHand.handAngle = 60 * watchFace->dateTime.tm_min + watchFace->secondHand.handAngle / 60;
watchFace->hourHand.handAngle = 300 * watchFace->dateTime.tm_hour + watchFace->minuteHand.handAngle / 12;
watchFace->mediumHand24h.handAngle = watchFace->hourHand.handAngle / 2;
//LV_LOG_USER("angle : %f", watchFace->secondHand.handAngle);
//We update the angle
lv_img_set_angle(watchFace->secondHand.handImg, (uint16_t) watchFace->secondHand.handAngle % 3600);
lv_img_set_angle(watchFace->minuteHand.handImg, (uint16_t) watchFace->minuteHand.handAngle % 3600);
lv_img_set_angle(watchFace->hourHand.handImg, (uint16_t) watchFace->hourHand.handAngle % 3600);
lv_img_set_angle(watchFace->mediumHand24h.handImg, (uint16_t) watchFace->mediumHand24h.handAngle % 3600);
}
else
{
LV_LOG_USER("DateTimeCb is NULL, be sure to register a callback !");
}
}
static void hand_timer_anim_cb(lv_timer_t *timer)
{
WatchFace_t *watchFace = timer->user_data;
update_watch_hands_angles(watchFace, 12);
}
static void battery_timer_anim_cb(lv_timer_t *timer)
{
WatchFace_t *watchFace = timer->user_data;
if(lv_obj_has_flag(watchFace->batteryIndicator.batteryIcon, LV_OBJ_FLAG_HIDDEN))
{
lv_obj_clear_flag(watchFace->batteryIndicator.batteryIcon, LV_OBJ_FLAG_HIDDEN);
}
else
{
lv_obj_add_flag(watchFace->batteryIndicator.batteryIcon, LV_OBJ_FLAG_HIDDEN);
}
}
static void step_counter_refresh_cb(lv_timer_t *timer)
{
WatchFace_t *watchFace = timer->user_data;
if(watchFace->stepCounterIndicatorCb)
{
uint32_t steps = 0;
watchFace->stepCounterIndicatorCb(&steps);
watch_face_set_step_count_indicator(watchFace, steps);
}
}
static void set_battery_state_icon(WatchFace_t * const watchFace)
{
switch(watchFace->batteryIndicator.batteryState)
{
case BATTERY_STATE_CHARGING:
lv_timer_pause(watchFace->batteryIndicator.lowBatteryAnimationTimer);
lv_obj_clear_flag(watchFace->batteryIndicator.batteryIcon, LV_OBJ_FLAG_HIDDEN);
lv_img_set_src(watchFace->batteryIndicator.batteryIcon, &battery_charging_icon);
break;
case BATTERY_STATE_CHARGED:
lv_timer_pause(watchFace->batteryIndicator.lowBatteryAnimationTimer);
lv_obj_clear_flag(watchFace->batteryIndicator.batteryIcon, LV_OBJ_FLAG_HIDDEN);
lv_img_set_src(watchFace->batteryIndicator.batteryIcon, &battery_charged_icon);
break;
default:
lv_obj_add_flag(watchFace->batteryIndicator.batteryIcon, LV_OBJ_FLAG_HIDDEN);
lv_img_set_src(watchFace->batteryIndicator.batteryIcon, &battery_low_icon);
break;
}
}
static void hide_hour_and_minutes_hand_cb(lv_event_t *e)
{
WatchFace_t *watchFace = lv_event_get_user_data(e);
if(lv_obj_has_flag(watchFace->hourHand.handImg, LV_OBJ_FLAG_HIDDEN))
{
lv_obj_clear_flag(watchFace->hourHand.handImg, LV_OBJ_FLAG_HIDDEN);
lv_obj_clear_flag(watchFace->minuteHand.handImg, LV_OBJ_FLAG_HIDDEN);
}
else
{
lv_obj_add_flag(watchFace->hourHand.handImg, LV_OBJ_FLAG_HIDDEN);
lv_obj_add_flag(watchFace->minuteHand.handImg, LV_OBJ_FLAG_HIDDEN);
}
}
void watch_face_init(WatchFace_t * const watchFace)
{
if(!watchFace)
{
LV_LOG_ERROR("NULL pointer given !");
return;
}
memset(watchFace, 0, sizeof(WatchFace_t));
strcpy(watchFace->stepCounter.text, "0");
}
void watch_face_register_date_time_cb(WatchFace_t * const watchFace, DateTimeCb_t dateTimeCb)
{
if(!watchFace)
{
LV_LOG_ERROR("NULL pointer given !");
return;
}
watchFace->dateTimeCb = dateTimeCb;
}
void watch_face_register_battery_indicator_cb(WatchFace_t *const watchFace, BatteryIndicatorCb_t batteryIndicatorCb)
{
if(!watchFace)
{
LV_LOG_ERROR("NULL pointer given !");
return;
}
watchFace->batteryIndicatorCb = batteryIndicatorCb;
}
void watch_face_register_step_counter_indicator_cb(WatchFace_t * const watchFace, StepCounterIndicatorCb_t stepCounterIndicatorCb)
{
if(!watchFace)
{
LV_LOG_ERROR("NULL pointer given !");
return;
}
watchFace->stepCounterIndicatorCb = stepCounterIndicatorCb;
}
void watch_face_create(WatchFace_t * const watchFace)
{
if(!watchFace)
{
LV_LOG_ERROR("NULL pointer given !");
return;
}
//We declare the needed assets for the watch face:
LV_IMG_DECLARE(watch_casio_face_asset)
LV_IMG_DECLARE(watch_casio_hour_hand_asset)
LV_IMG_DECLARE(watch_casio_minute_hand_asset)
LV_IMG_DECLARE(watch_casio_second_hand_asset)
LV_IMG_DECLARE(watch_casio_medium_hand_asset)
//LV_IMG_DECLARE(watch_casio_small_hand_asset)
LV_IMG_DECLARE(bluetooth_icon)
//We create our parent screen :
if(watchFace->display)
{
LV_LOG_ERROR("display should be NULL here !");
lv_obj_del(watchFace->display);
watchFace->display = NULL;
}
//Our display is the watch face image :
watchFace->display = lv_img_create(NULL);
lv_img_set_src(watchFace->display, &watch_casio_face_asset);
lv_obj_set_style_bg_color(watchFace->display, lv_color_black(), LV_PART_MAIN);
lv_obj_add_event_cb(watchFace->display, &(hide_hour_and_minutes_hand_cb), LV_EVENT_LONG_PRESSED, watchFace);
//We load our other assets :
/*lv_obj_t *smallHandImg = lv_img_create(watchFace->display);
lv_img_set_src(smallHandImg, &watch_casio_small_hand_asset);
lv_obj_set_pos(smallHandImg, 69, 98);
lv_img_set_pivot(smallHandImg, 4, 20);*/
//Battery arc is created here
if(watchFace->batteryIndicator.batteryArc)
{
LV_LOG_ERROR("batteryArc should be NULL here !");
lv_obj_del(watchFace->batteryIndicator.batteryArc);
watchFace->batteryIndicator.batteryArc = NULL;
}
watchFace->batteryIndicator.batteryArc = lv_arc_create(watchFace->display);
lv_obj_remove_style(watchFace->batteryIndicator.batteryArc, NULL, LV_PART_KNOB);
lv_obj_clear_flag(watchFace->batteryIndicator.batteryArc, LV_OBJ_FLAG_CLICKABLE);
lv_obj_set_size(watchFace->batteryIndicator.batteryArc, 60, 60);
lv_obj_align(watchFace->batteryIndicator.batteryArc, LV_ALIGN_CENTER, -1, 45);
lv_obj_set_style_arc_width(watchFace->batteryIndicator.batteryArc, 5, LV_PART_INDICATOR);
lv_obj_set_style_arc_width(watchFace->batteryIndicator.batteryArc, 0, LV_PART_MAIN);
lv_obj_set_style_arc_color(watchFace->batteryIndicator.batteryArc, lv_color_make(228, 233, 236), LV_PART_INDICATOR);
lv_arc_set_value(watchFace->batteryIndicator.batteryArc, 100);
if(watchFace->batteryIndicator.label)
{
LV_LOG_ERROR("battery_label should be NULL here !");
lv_obj_del(watchFace->batteryIndicator.label);
watchFace->batteryIndicator.label = NULL;
}
watchFace->batteryIndicator.label = lv_label_create(watchFace->display);
strcpy(watchFace->batteryIndicator.text, "100 %");
lv_label_set_text_static(watchFace->batteryIndicator.label, watchFace->batteryIndicator.text);
lv_obj_set_style_text_color(watchFace->batteryIndicator.label, lv_color_white(), LV_PART_MAIN);
lv_obj_align_to(watchFace->batteryIndicator.label, watchFace->batteryIndicator.batteryArc, LV_ALIGN_CENTER, 0, -5);
// Battery icon is created here
if(watchFace->batteryIndicator.batteryIcon)
{
LV_LOG_ERROR("batteryIcon should be NULL here !");
lv_obj_del(watchFace->batteryIndicator.batteryIcon);
watchFace->batteryIndicator.batteryIcon = NULL;
}
watchFace->batteryIndicator.batteryIcon = lv_img_create(watchFace->display);
if(watchFace->batteryIndicator.lowBatteryAnimationTimer)
{
LV_LOG_ERROR("battery animation timer should be NULL here !");
lv_timer_del(watchFace->batteryIndicator.lowBatteryAnimationTimer);
watchFace->batteryIndicator.lowBatteryAnimationTimer = NULL;
}
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)
{
LV_LOG_ERROR("bluetoothIcon be NULL here !");
lv_obj_del(watchFace->bluetoothIndicator.bluetoothIcon);
watchFace->bluetoothIndicator.bluetoothIcon = NULL;
}
watchFace->bluetoothIndicator.bluetoothIcon = lv_img_create(watchFace->display);
lv_img_set_src(watchFace->bluetoothIndicator.bluetoothIcon, &bluetooth_icon);
lv_img_set_zoom(watchFace->bluetoothIndicator.bluetoothIcon, 128);
lv_obj_add_flag(watchFace->bluetoothIndicator.bluetoothIcon, LV_OBJ_FLAG_HIDDEN);
lv_obj_set_style_img_recolor(watchFace->bluetoothIndicator.bluetoothIcon, lv_palette_main(LV_PALETTE_GREY), LV_PART_MAIN);
lv_obj_align_to(watchFace->bluetoothIndicator.bluetoothIcon, watchFace->batteryIndicator.batteryArc, LV_ALIGN_OUT_LEFT_BOTTOM, -9, 0);
_set_bluetooth_indicator(watchFace);
// StepCounter label is created here
if(watchFace->stepCounter.label)
{
LV_LOG_ERROR("stepCounter should be NULL here !");
lv_obj_del(watchFace->stepCounter.label);
watchFace->stepCounter.label = NULL;
}
watchFace->stepCounter.label = lv_label_create(watchFace->display);
lv_label_set_text_static(watchFace->stepCounter.label, watchFace->stepCounter.text);
lv_obj_set_style_text_color(watchFace->stepCounter.label, lv_color_white(), LV_PART_MAIN);
lv_obj_set_pos(watchFace->stepCounter.label, 63, 111);
if(watchFace->mediumHand24h.handImg)
{
LV_LOG_ERROR("mediumHand24hImg should be NULL here !");
lv_obj_del(watchFace->mediumHand24h.handImg);
watchFace->mediumHand24h.handImg = NULL;
}
watchFace->mediumHand24h.handImg = lv_img_create(watchFace->display);
lv_img_set_src(watchFace->mediumHand24h.handImg, &watch_casio_medium_hand_asset);
lv_obj_set_pos(watchFace->mediumHand24h.handImg, 115, 48);
lv_img_set_pivot(watchFace->mediumHand24h.handImg, 4, 25);
/*lv_obj_t *mediumHandChronoImg = lv_img_create(watchFace->display);
lv_img_set_src(mediumHandChronoImg, &watch_casio_medium_hand_asset);
lv_obj_set_pos(mediumHandChronoImg, 115, 140);
lv_img_set_pivot(mediumHandChronoImg, 4, 25);*/
//Date window is created here
if(watchFace->dateWindow.dateWindowWidget)
{
LV_LOG_ERROR("dateWindowWidget should be NULL here !");
lv_obj_del(watchFace->dateWindow.dateWindowWidget);
watchFace->dateWindow.dateWindowWidget = NULL;
}
watchFace->dateWindow.dateWindowWidget = lv_label_create(watchFace->display);
lv_label_set_text_static(watchFace->dateWindow.dateWindowWidget, watchFace->dateWindow.dateWindowText);
lv_obj_set_pos(watchFace->dateWindow.dateWindowWidget, 180,111);
lv_obj_set_width(watchFace->dateWindow.dateWindowWidget, 20);
lv_obj_set_style_text_align(watchFace->dateWindow.dateWindowWidget, LV_TEXT_ALIGN_CENTER, LV_PART_MAIN);
if(watchFace->hourHand.handImg)
{
LV_LOG_ERROR("hourHandImg should be NULL here !");
lv_obj_del(watchFace->hourHand.handImg);
watchFace->hourHand.handImg = NULL;
}
watchFace->hourHand.handImg = lv_img_create(watchFace->display);
lv_img_set_src(watchFace->hourHand.handImg, &watch_casio_hour_hand_asset);
lv_obj_set_pos(watchFace->hourHand.handImg, 112, 60);
lv_img_set_pivot(watchFace->hourHand.handImg, 8, 60);
if(watchFace->minuteHand.handImg)
{
LV_LOG_ERROR("minuteHandImg should be NULL here !");
lv_obj_del(watchFace->minuteHand.handImg);
watchFace->minuteHand.handImg = NULL;
}
watchFace->minuteHand.handImg = lv_img_create(watchFace->display);
lv_img_set_src(watchFace->minuteHand.handImg, &watch_casio_minute_hand_asset);
lv_obj_set_pos(watchFace->minuteHand.handImg, 112, 28);
lv_img_set_pivot(watchFace->minuteHand.handImg, 7, 92);
if(watchFace->secondHand.handImg)
{
LV_LOG_ERROR("secondHandImg should be NULL here !");
lv_obj_del(watchFace->secondHand.handImg);
watchFace->secondHand.handImg = NULL;
}
watchFace->secondHand.handImg = lv_img_create(watchFace->display);
lv_img_set_src(watchFace->secondHand.handImg, &watch_casio_second_hand_asset);
lv_obj_set_pos(watchFace->secondHand.handImg, 115, 28);
lv_img_set_pivot(watchFace->secondHand.handImg, 5, 92);
//We set the appropriate angles to each of the hands
update_watch_hands_angles(watchFace, 0);
//Don't forget to make the background image clickable to be able to use gestures on it.
lv_obj_add_flag(watchFace->display, LV_OBJ_FLAG_CLICKABLE);
//We register the event callback to handle gestures
lv_obj_add_event_cb(watchFace->display, &(gesture_event_cb), LV_EVENT_GESTURE, watchFace);
//We register the event callback to handle the cleanup
lv_obj_add_event_cb(watchFace->display, &(cleanup_event_cb), LV_EVENT_DELETE, watchFace);
//We create the timer to run the watch animations
if(watchFace->handAnimationTimer)
{
LV_LOG_ERROR("handAnimationTimer should be NULL here !");
lv_timer_del(watchFace->handAnimationTimer);
watchFace->handAnimationTimer = NULL;
}
watchFace->handAnimationTimer = lv_timer_create(&(hand_timer_anim_cb), 199, watchFace);
//We create the timer which refreshes the step counter indicator
if(watchFace->stepCounterRefreshTimer)
{
LV_LOG_ERROR("stepCounterRefreshTimer should be NULL here !");
lv_timer_del(watchFace->stepCounterRefreshTimer);
watchFace->stepCounterRefreshTimer = NULL;
}
watchFace->stepCounterRefreshTimer = lv_timer_create(&(step_counter_refresh_cb), 300, watchFace);
}
void watch_face_set_battery_indicator(WatchFace_t * const watchFace, uint8_t levelInPercent, BatteryState_e batteryState)
{
if(!watchFace)
{
LV_LOG_ERROR("NULL pointer given !");
return;
}
if(!watchFace->display) return;
lv_color_t arc_color = lv_color_make(228, 233, 236);
if(levelInPercent <= 10)
arc_color = lv_color_make(228, 33, 81);
else if(levelInPercent <= 30)
arc_color = lv_color_make(247, 148, 29);
else if(levelInPercent <= 50)
arc_color = lv_color_make(226, 175, 58);
lv_arc_set_value(watchFace->batteryIndicator.batteryArc, levelInPercent);
lv_obj_set_style_arc_color(watchFace->batteryIndicator.batteryArc, arc_color, LV_PART_INDICATOR);
sprintf(watchFace->batteryIndicator.text, "%u %%", levelInPercent);
lv_label_set_text_static(watchFace->batteryIndicator.label, watchFace->batteryIndicator.text);
lv_obj_align_to(watchFace->batteryIndicator.label, watchFace->batteryIndicator.batteryArc, LV_ALIGN_CENTER, 0, -5);
//We save the new battery state only if it's different, this allows to have a trigger when it changes :
if(watchFace->batteryIndicator.batteryState != batteryState)
{
watchFace->batteryIndicator.batteryState = batteryState;
set_battery_state_icon(watchFace);
}
//Finally we check if it's time to show the battery low indicator by enabling it's timer
if(levelInPercent <= 10 && watchFace->batteryIndicator.batteryState == BATTERY_STATE_DISCHARGING)
{
lv_timer_resume(watchFace->batteryIndicator.lowBatteryAnimationTimer);
}
else if(watchFace->batteryIndicator.batteryState == BATTERY_STATE_DISCHARGING)
{
lv_timer_pause(watchFace->batteryIndicator.lowBatteryAnimationTimer);
lv_obj_add_flag(watchFace->batteryIndicator.batteryIcon, LV_OBJ_FLAG_HIDDEN);
}
}
void watch_face_set_bluetooth_indicator(WatchFace_t * const watchFace, BluetoothState_e bluetoothState)
{
if(!watchFace)
{
LV_LOG_ERROR("NULL pointer given !");
return;
}
if(watchFace->bluetoothIndicator.bluetoothState == bluetoothState) return;
watchFace->bluetoothIndicator.bluetoothState = bluetoothState;
if(!watchFace->display) return;
_set_bluetooth_indicator(watchFace);
}
void watch_face_set_step_count_indicator(WatchFace_t * const watchFace, uint32_t stepCount)
{
if(!watchFace)
{
LV_LOG_ERROR("NULL pointer given !");
return;
}
if(stepCount < 1000)
sprintf(watchFace->stepCounter.text, "%u", stepCount);
else if(stepCount < 9996)
sprintf(watchFace->stepCounter.text, "%.2fk", stepCount/1000.0);
else
sprintf(watchFace->stepCounter.text, "%.1fk", stepCount/1000.0);
if(!watchFace->display) return;
lv_label_set_text_static(watchFace->stepCounter.label, watchFace->stepCounter.text);
}
void watch_face_destroy(WatchFace_t * const watchFace)
{
if(!watchFace)
{
LV_LOG_ERROR("NULL pointer given !");
return;
}
watchFace->display = NULL;
watchFace->handAnimationTimer = NULL;
watchFace->stepCounterRefreshTimer = NULL;
watchFace->dateWindow.dateWindowWidget = NULL;
watchFace->hourHand.handImg = NULL;
watchFace->minuteHand.handImg = NULL;
watchFace->secondHand.handImg = NULL;
watchFace->mediumHand24h.handImg = NULL;
watchFace->batteryIndicator.batteryArc = NULL;
watchFace->batteryIndicator.label = NULL;
watchFace->batteryIndicator.batteryIcon = NULL;
watchFace->batteryIndicator.lowBatteryAnimationTimer = NULL;
watchFace->stepCounter.label = NULL;
watchFace->bluetoothIndicator.bluetoothIcon = NULL;
}
void watch_face_force_sync(WatchFace_t *const watchFace)
{
if(!watchFace)
{
LV_LOG_ERROR("NULL pointer given !");
return;
}
if(!watchFace->display) return;
update_watch_hands_angles(watchFace, 0);
}
bool watch_face_is_in_use(WatchFace_t * const watchFace)
{
if(!watchFace)
{
LV_LOG_ERROR("NULL pointer given !");
return false;
}
return watchFace->display != NULL;
}

View File

@ -21,6 +21,12 @@
bool ble_service_send_nus_data(const uint8_t *data, uint16_t length)
{
printf("Sent nus data :#");
for(uint16_t i = 0; i < length; i++)
{
putchar(data[i]);
}
printf("#\n");
return true;
}
@ -97,6 +103,7 @@ static time_t _unix_timestamp = 0;
/* Internal function definition */
static const char *_gadget_bridge_toast_type_2_str(gadget_bridge_toast_type_e toast_type);
static const char *_gadget_bridge_music_control_2_str(gadget_bridge_music_control_e music_control);
static const char *_gadget_bridge_notification_action_2_str(gadget_bridge_notification_action_e notification_action);
static const char *_gadget_bridge_http_request_method_2_str(gadget_bridge_http_request_method_e http_request_method);
static void _parser_free_buffer(uint16_t length);
static void _free_event_data(void);
@ -142,8 +149,8 @@ bool gadget_bridge_send_battery_status(uint8_t battery_level_in_percent, float b
bool to_return = true;
char num_2_str[30] = "";
to_return &= ble_service_send_nus_data((const uint8_t *)"{\"t\":\"status\",\"bat\":", 20);
sprintf(num_2_str, "%u,\"chg\":%u,\"volt\":%.3f} \n", battery_level_in_percent, is_charging, battery_level_in_V);
to_return &= ble_service_send_nus_data((const uint8_t *)num_2_str, strlen(num_2_str));
int length = sprintf(num_2_str, "%u,\"chg\":%u,\"volt\":%.3f} \n", battery_level_in_percent, is_charging, battery_level_in_V);
to_return &= ble_service_send_nus_data((const uint8_t *)num_2_str, length);
return to_return;
}
@ -170,6 +177,41 @@ bool gadget_bridge_send_music_control(gadget_bridge_music_control_e music_contro
return to_return;
}
bool gadget_bridge_send_notification_action(gadget_bridge_notification_action_e notification_action, uint32_t handle, const char *phone_number, const char *message)
{
bool to_return = true;
char num_2_str[11] = "";
// There is no point sending a reply without an actual message
if(notification_action == GADGET_BRIDGE_NOTIFICATION_ACTION_REPLY && !message)
return false;
to_return &= ble_service_send_nus_data((const uint8_t *)"{\"t\":\"notify\",\"n\":\"", 19);
to_return &= ble_service_send_nus_data((const uint8_t *)_gadget_bridge_notification_action_2_str(notification_action), strlen(_gadget_bridge_notification_action_2_str(notification_action)));
to_return &= ble_service_send_nus_data((const uint8_t *)"\",\"id\":", 7);
int length = sprintf(num_2_str, "%u", handle);
to_return &= ble_service_send_nus_data((const uint8_t *)num_2_str, length);
if(notification_action == GADGET_BRIDGE_NOTIFICATION_ACTION_REPLY)
{
if(phone_number)
{
to_return &= ble_service_send_nus_data((const uint8_t *)",\"tel\":\"", 8);
to_return &= ble_service_send_nus_data((const uint8_t *)phone_number, strlen(phone_number));
to_return &= ble_service_send_nus_data((const uint8_t *)"\"", 1);
}
to_return &= ble_service_send_nus_data((const uint8_t *)",\"msg\":\"", 8);
to_return &= ble_service_send_nus_data((const uint8_t *)message, strlen(message));
to_return &= ble_service_send_nus_data((const uint8_t *)"\"", 1);
}
to_return &= ble_service_send_nus_data((const uint8_t *)"} \n", 3);
return to_return;
}
bool gadget_bridge_send_activity_data(uint16_t heart_rate_in_bpm, uint32_t step_count)
{
bool to_return = true;
@ -177,13 +219,13 @@ bool gadget_bridge_send_activity_data(uint16_t heart_rate_in_bpm, uint32_t step_
//{\"t\":\"act\",\"hrm\":%s,\"stp\":%s} \n
to_return &= ble_service_send_nus_data((const uint8_t *)"{\"t\":\"act\",\"hrm\":", 17);
sprintf(num_2_str, "%u", heart_rate_in_bpm);
to_return &= ble_service_send_nus_data((const uint8_t *)num_2_str, strlen(num_2_str));
int length = sprintf(num_2_str, "%u", heart_rate_in_bpm);
to_return &= ble_service_send_nus_data((const uint8_t *)num_2_str, length);
to_return &= ble_service_send_nus_data((const uint8_t *)",\"stp\":", 7);
sprintf(num_2_str, "%u", step_count);
to_return &= ble_service_send_nus_data((const uint8_t *)num_2_str, strlen(num_2_str));
length = sprintf(num_2_str, "%u", step_count);
to_return &= ble_service_send_nus_data((const uint8_t *)num_2_str, length);
to_return &= ble_service_send_nus_data((const uint8_t *)"} \n", 3);
@ -194,10 +236,10 @@ bool gadget_bridge_send_http_request(uint32_t id, const char *url, gadget_bridge
{
bool to_return = true;
char num_2_str[11] = "";
sprintf(num_2_str, "%u", id);
int length = sprintf(num_2_str, "%u", id);
to_return &= ble_service_send_nus_data((const uint8_t *)"{\"t\":\"http\",\"id\":\"", 18);
to_return &= ble_service_send_nus_data((const uint8_t *)num_2_str, strlen(num_2_str));
to_return &= ble_service_send_nus_data((const uint8_t *)num_2_str, length);
to_return &= ble_service_send_nus_data((const uint8_t *)"\",\"url\":\"", 9);
to_return &= ble_service_send_nus_data((const uint8_t *)url, strlen(url));
to_return &= ble_service_send_nus_data((const uint8_t *)"\",\"method\":\"", 12);
@ -1313,6 +1355,24 @@ static const char *_gadget_bridge_music_control_2_str(gadget_bridge_music_contro
}
}
static const char *_gadget_bridge_notification_action_2_str(gadget_bridge_notification_action_e notification_action)
{
switch(notification_action)
{
case GADGET_BRIDGE_NOTIFICATION_ACTION_DISMISS_ALL:
return "dismiss_all";
case GADGET_BRIDGE_NOTIFICATION_ACTION_OPEN:
return "open";
case GADGET_BRIDGE_NOTIFICATION_ACTION_MUTE:
return "mute";
case GADGET_BRIDGE_NOTIFICATION_ACTION_REPLY:
return "reply";
case GADGET_BRIDGE_NOTIFICATION_ACTION_DISMISS:
default :
return "dismiss";
}
}
static const char *_gadget_bridge_http_request_method_2_str(gadget_bridge_http_request_method_e http_request_method)
{
switch(http_request_method)

View File

@ -249,16 +249,27 @@ bool gadget_bridge_send_find_phone(bool find_phone);
/**
* @brief Sends a command to control the music playback of the phone through GadgetBridge.
*
* @param music_control an enumeration value indicating the action to perform:
* @param music_control an enumeration value indicating the action to perform :
* PLAY, PAUSE, NEXT, PREVIOUS, VOLUMEUP etc..
* @return true if the command was successfully sent.
* @return false otherwise.
*/
bool gadget_bridge_send_music_control(gadget_bridge_music_control_e music_control);
bool gadget_bridge_handle_call(gadget_bridge_call_action_e call_action);
/**
* @brief Sends a command to perform an action to the specified received notification.
*
* @param notification_action an enumeration value indicating the action to perform on the notification :
* DISMISS, DISMISS_ALL, OPEN, MUTE and REPLY.
* @param handle the notification's handle.
* @param phone_number a string containing a phone number to send the REPLY to or NULL to use the same number as the notification.
* @param message a string containing the message to send to a REPLY action, can be NULL if the action is different.
* @return true if the command was successfully sent.
* @return false otherwise.
*/
bool gadget_bridge_send_notification_action(gadget_bridge_notification_action_e notification_action, uint32_t handle, const char *phone_number, const char *message);
bool gadget_bridge_handle_notification(gadget_bridge_call_action_e notification_action, uint32_t handle, const char *phone_number, const char *message);
bool gadget_bridge_handle_call(gadget_bridge_call_action_e call_action);
/**
* @brief Sends the provided activity data to GadgetBridge. This will then be displayed

View File

@ -50,19 +50,19 @@
<stdlib.h>
<string.h>
1697540423 source:d:\users\think\documents\w800_smart_watch\src\gadget_bridge_parser\gadget_bridge.c
1701721954 source:d:\users\think\documents\w800_smart_watch\src\gadget_bridge_parser\gadget_bridge.c
"gadget_bridge.h"
<stdio.h>
<stdlib.h>
<string.h>
<assert.h>
1696487243 d:\users\think\documents\w800_smart_watch\src\gadget_bridge_parser\gadget_bridge.h
1701721690 d:\users\think\documents\w800_smart_watch\src\gadget_bridge_parser\gadget_bridge.h
<stdint.h>
<stdbool.h>
<time.h>
1697572727 source:d:\users\think\documents\w800_smart_watch\src\gadget_bridge_parser\main.c
1701722229 source:d:\users\think\documents\w800_smart_watch\src\gadget_bridge_parser\main.c
<stdio.h>
<stdlib.h>
<string.h>

View File

@ -2,19 +2,19 @@
<CodeBlocks_layout_file>
<FileVersion major="1" minor="0" />
<ActiveTarget name="Debug" />
<File name="gadget_bridge.h" open="1" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="gadget_bridge.c" open="0" top="0" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="4496" topLine="288" />
<Cursor1 position="784" topLine="6" />
</Cursor>
</File>
<File name="gadget_bridge.c" open="1" top="0" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="gadget_bridge.h" open="0" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="35064" topLine="963" />
<Cursor1 position="4496" topLine="118" />
</Cursor>
</File>
<File name="main.c" open="1" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="main.c" open="0" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="11548" topLine="333" />
<Cursor1 position="12856" topLine="343" />
</Cursor>
</File>
</CodeBlocks_layout_file>

View File

@ -379,5 +379,12 @@ int main()
//gadget_bridge_parser_debug();
}
gadget_bridge_send_notification_action(GADGET_BRIDGE_NOTIFICATION_ACTION_DISMISS, 1, NULL, NULL);
gadget_bridge_send_notification_action(GADGET_BRIDGE_NOTIFICATION_ACTION_DISMISS_ALL, 2, NULL, NULL);
gadget_bridge_send_notification_action(GADGET_BRIDGE_NOTIFICATION_ACTION_MUTE, 3, NULL, NULL);
gadget_bridge_send_notification_action(GADGET_BRIDGE_NOTIFICATION_ACTION_OPEN, 4, NULL, NULL);
gadget_bridge_send_notification_action(GADGET_BRIDGE_NOTIFICATION_ACTION_REPLY, 5, NULL, "Salut mon bichon");
gadget_bridge_send_notification_action(GADGET_BRIDGE_NOTIFICATION_ACTION_REPLY, 6, "0601020304", "Salut mon bichon");
return 0;
}

View File

@ -1661,7 +1661,6 @@
<Option compilerVar="CC" />
</Unit>
<Unit filename="notification_screen.h" />
<Unit filename="rsrc/hour_hand.png" />
<Unit filename="settings_screen.c">
<Option compilerVar="CC" />
</Unit>
@ -1675,11 +1674,6 @@
<Unit filename="watch_face.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="watch_face.c.bck">
<Option compilerVar="CC" />
<Option compile="1" />
<Option link="1" />
</Unit>
<Unit filename="watch_face.h" />
<Unit filename="watch_face_carbon.c">
<Option compilerVar="CC" />

View File

@ -2,9 +2,19 @@
<CodeBlocks_layout_file>
<FileVersion major="1" minor="0" />
<ActiveTarget name="Debug" />
<File name="lv_drivers\display\SSD1963.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="menu_screen.c" open="0" top="0" tabpos="6" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="1563" topLine="27" />
<Cursor1 position="527" topLine="0" />
</Cursor>
</File>
<File name="lvgl\src\core\lv_obj_style_gen.h" open="0" top="0" tabpos="11" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="29532" topLine="611" />
</Cursor>
</File>
<File name="lvgl\src\core\lv_obj_scroll.c" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="9479" topLine="300" />
</Cursor>
</File>
<File name="lvgl\src\widgets\roller\lv_roller.h" open="0" top="0" tabpos="6" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
@ -12,64 +22,9 @@
<Cursor1 position="715" topLine="26" />
</Cursor>
</File>
<File name="watch_casio_assets.c" open="1" top="0" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="watch_face_carbon.c" open="1" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="99" topLine="968" />
</Cursor>
</File>
<File name="lvgl\src\font\lv_font_fmt_txt.c" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="0" topLine="24" />
</Cursor>
</File>
<File name="lvgl\src\font\lv_symbol_def.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="1135" topLine="14" />
</Cursor>
</File>
<File name="find_my_phone_screen.c" open="0" top="0" tabpos="10" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="1081" topLine="138" />
</Cursor>
</File>
<File name="music_player_screen.c" open="0" top="0" tabpos="4" split="0" active="1" splitpos="0" zoom_1="1" zoom_2="0">
<Cursor>
<Cursor1 position="22334" topLine="0" />
</Cursor>
</File>
<File name="lvgl\src\core\lv_disp.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="6135" topLine="182" />
</Cursor>
</File>
<File name="common_screen_components.h" open="0" top="0" tabpos="7" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="517" topLine="0" />
</Cursor>
</File>
<File name="lvgl\src\misc\lv_color.h" open="0" top="0" tabpos="5" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="1102" topLine="35" />
</Cursor>
</File>
<File name="find_my_phone_screen.h" open="0" top="0" tabpos="9" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="1078" topLine="3" />
</Cursor>
</File>
<File name="lvgl\src\core\lv_obj_tree.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="1234" topLine="30" />
</Cursor>
</File>
<File name="lvgl\src\draw\lv_img_buf.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="6210" topLine="113" />
</Cursor>
</File>
<File name="lvgl\src\core\lv_indev_scroll.c" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="14405" topLine="323" />
<Cursor1 position="0" topLine="239" />
</Cursor>
</File>
<File name="lvgl\src\draw\lv_draw_img.c" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
@ -77,19 +32,84 @@
<Cursor1 position="5230" topLine="191" />
</Cursor>
</File>
<File name="lvgl\src\font\lv_font.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="5535" topLine="120" />
</Cursor>
</File>
<File name="lvgl\src\widgets\list\lv_list.h" open="0" top="0" tabpos="7" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="721" topLine="16" />
</Cursor>
</File>
<File name="lvgl\src\misc\lv_color.h" open="0" top="0" tabpos="5" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="1102" topLine="35" />
</Cursor>
</File>
<File name="lvgl\src\core\lv_disp.c" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="7126" topLine="230" />
</Cursor>
</File>
<File name="music_player_screen.h" open="0" top="0" tabpos="15" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="1263" topLine="38" />
</Cursor>
</File>
<File name="lvgl\src\core\lv_obj_pos.c" open="0" top="0" tabpos="12" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="10562" topLine="336" />
</Cursor>
</File>
<File name="altimeter_screen.c" open="0" top="0" tabpos="6" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="2832" topLine="27" />
</Cursor>
</File>
<File name="lvgl\src\misc\lv_timer.c" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="5053" topLine="144" />
</Cursor>
</File>
<File name="lvgl\src\core\lv_obj_tree.c" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="2082" topLine="62" />
</Cursor>
</File>
<File name="lvgl\src\font\lv_font_montserrat_14.c" open="0" top="0" tabpos="8" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="2108" topLine="21" />
</Cursor>
</File>
<File name="lvgl\src\widgets\imgbtn\lv_imgbtn.c" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="2184" topLine="61" />
</Cursor>
</File>
<File name="lvgl\src\core\lv_obj_style_gen.c" open="0" top="0" tabpos="11" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="lvgl\src\hal\lv_hal_disp.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="20039" topLine="604" />
<Cursor1 position="10233" topLine="226" />
</Cursor>
</File>
<File name="lvgl\src\layouts\grid\lv_grid.h" open="0" top="0" tabpos="13" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="settings_screen.h" open="0" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="579" topLine="17" />
<Cursor1 position="551" topLine="12" />
</Cursor>
</File>
<File name="lvgl\src\core\lv_indev_scroll.c" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="14405" topLine="323" />
</Cursor>
</File>
<File name="lv_drivers\indev\keyboard.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="440" topLine="14" />
</Cursor>
</File>
<File name="watch_face.h" open="0" top="0" tabpos="14" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="225" topLine="44" />
</Cursor>
</File>
<File name="lvgl\src\core\lv_refr.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
@ -97,9 +117,114 @@
<Cursor1 position="2447" topLine="75" />
</Cursor>
</File>
<File name="lvgl\src\widgets\list\lv_list.h" open="0" top="0" tabpos="7" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="lvgl\src\font\lv_font_montserrat_12.c" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="721" topLine="16" />
<Cursor1 position="0" topLine="22" />
</Cursor>
</File>
<File name="lv_conf.h" open="0" top="0" tabpos="7" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="572" topLine="0" />
</Cursor>
</File>
<File name="lv_drivers\win32drv\win32drv.c" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="524" topLine="954" />
</Cursor>
</File>
<File name="lvgl\src\widgets\menu\lv_menu.c" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="3321" topLine="109" />
</Cursor>
</File>
<File name="lvgl\src\draw\lv_draw_rect.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="539" topLine="9" />
</Cursor>
</File>
<File name="lvgl\src\hal\lv_hal_indev.c" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="3566" topLine="102" />
</Cursor>
</File>
<File name="lvgl\demos\widgets\lv_demo_widgets.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="456" topLine="6" />
</Cursor>
</File>
<File name="altimeter_screen_assets.c" open="0" top="0" tabpos="19" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="96342" topLine="161" />
</Cursor>
</File>
<File name="lvgl\src\widgets\spinbox\lv_spinbox.h" open="0" top="0" tabpos="18" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="4262" topLine="120" />
</Cursor>
</File>
<File name="lvgl\src\misc\lv_anim.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="749" topLine="34" />
</Cursor>
</File>
<File name="common_screen_components.h" open="0" top="0" tabpos="7" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="517" topLine="0" />
</Cursor>
</File>
<File name="lvgl\src\misc\lv_style.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="9059" topLine="242" />
</Cursor>
</File>
<File name="watch_casio_assets.c" open="1" top="0" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="99" topLine="968" />
</Cursor>
</File>
<File name="notification_screen.h" open="1" top="0" tabpos="6" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="655" topLine="0" />
</Cursor>
</File>
<File name="lvgl\src\layouts\flex\lv_flex.h" open="0" top="0" tabpos="7" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="950" topLine="43" />
</Cursor>
</File>
<File name="lv_drivers\win_drv.h" open="0" top="0" tabpos="10" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="585" topLine="0" />
</Cursor>
</File>
<File name="lvgl\src\core\lv_event.h" open="0" top="0" tabpos="6" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="2085" topLine="26" />
</Cursor>
</File>
<File name="lvgl\src\font\lv_symbol_def.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="1135" topLine="14" />
</Cursor>
</File>
<File name="lvgl\src\widgets\img\lv_img.h" open="0" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="6960" topLine="203" />
</Cursor>
</File>
<File name="compass_screen.c" open="0" top="0" tabpos="7" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="1480" topLine="179" />
</Cursor>
</File>
<File name="lvgl\src\core\lv_obj_scroll.h" open="0" top="0" tabpos="7" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="4372" topLine="104" />
</Cursor>
</File>
<File name="lvgl\src\misc\lv_log.c" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="1509" topLine="59" />
</Cursor>
</File>
<File name="watch_menu_icons.c" open="0" top="0" tabpos="18" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
@ -127,149 +252,19 @@
<Collapse line="1729" />
</Folding>
</File>
<File name="lvgl\src\core\lv_obj_scroll.c" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="lvgl\src\core\lv_obj_style_gen.c" open="0" top="0" tabpos="11" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="9479" topLine="300" />
<Cursor1 position="20039" topLine="604" />
</Cursor>
</File>
<File name="music_player_screen.h" open="0" top="0" tabpos="15" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="lvgl\src\font\lv_font_montserrat_30.c" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="1263" topLine="38" />
<Cursor1 position="869" topLine="0" />
</Cursor>
</File>
<File name="lvgl\src\core\lv_obj_class.c" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="lvgl\src\core\lv_disp.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="3011" topLine="100" />
</Cursor>
</File>
<File name="lvgl\src\layouts\flex\lv_flex.c" open="0" top="0" tabpos="8" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="3097" topLine="74" />
</Cursor>
</File>
<File name="common_screen_components.c" open="0" top="0" tabpos="8" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="496" topLine="3" />
</Cursor>
</File>
<File name="lvgl\src\misc\lv_timer.h" open="0" top="0" tabpos="10" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="2886" topLine="90" />
</Cursor>
</File>
<File name="lvgl\src\layouts\flex\lv_flex.h" open="0" top="0" tabpos="7" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="950" topLine="43" />
</Cursor>
</File>
<File name="notification_screen.c" open="0" top="0" tabpos="5" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="15816" topLine="373" />
</Cursor>
</File>
<File name="lvgl\src\core\lv_obj_style.c" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="7273" topLine="217" />
</Cursor>
</File>
<File name="lv_drivers\win32drv\win32drv.c" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="524" topLine="954" />
</Cursor>
</File>
<File name="lvgl\src\core\lv_obj_style_gen.h" open="0" top="0" tabpos="11" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="29532" topLine="611" />
</Cursor>
</File>
<File name="lvgl\src\lv_api_map.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="722" topLine="32" />
</Cursor>
</File>
<File name="lvgl\src\core\lv_event.c" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="5365" topLine="214" />
</Cursor>
</File>
<File name="lv_drivers\display\monitor.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="289" topLine="31" />
</Cursor>
</File>
<File name="lvgl\demos\widgets\lv_demo_widgets.c" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="2825" topLine="122" />
</Cursor>
</File>
<File name="lvgl\src\widgets\chart\lv_chart.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="11658" topLine="336" />
</Cursor>
</File>
<File name="lvgl\src\font\lv_font_montserrat_14.c" open="0" top="0" tabpos="8" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="2108" topLine="21" />
</Cursor>
</File>
<File name="lvgl\src\core\lv_obj_pos.h" open="0" top="0" tabpos="4" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="11878" topLine="258" />
</Cursor>
</File>
<File name="altimeter_screen.h" open="0" top="0" tabpos="7" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="971" topLine="3" />
</Cursor>
</File>
<File name="menu_screen.h" open="0" top="0" tabpos="12" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="350" topLine="0" />
</Cursor>
</File>
<File name="watch_carbon_assets.c" open="1" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="3114203" topLine="961" />
</Cursor>
</File>
<File name="lvgl\src\widgets\list\lv_list.c" open="0" top="0" tabpos="6" split="0" active="1" splitpos="0" zoom_1="2" zoom_2="0">
<Cursor>
<Cursor1 position="2391" topLine="53" />
</Cursor>
</File>
<File name="watch_face_carbon.c" open="1" top="1" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="0" topLine="239" />
</Cursor>
</File>
<File name="lv_drivers\indev\keyboard.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="440" topLine="14" />
</Cursor>
</File>
<File name="settings_screen.h" open="0" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="551" topLine="12" />
</Cursor>
</File>
<File name="lvgl\src\widgets\label\lv_label.h" open="0" top="0" tabpos="9" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="969" topLine="39" />
</Cursor>
</File>
<File name="firmware_version.h" open="0" top="0" tabpos="9" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="160" topLine="0" />
</Cursor>
</File>
<File name="menu_screen.c" open="0" top="0" tabpos="6" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="527" topLine="0" />
</Cursor>
</File>
<File name="lvgl\src\widgets\spinbox\lv_spinbox.h" open="0" top="0" tabpos="18" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="4262" topLine="120" />
<Cursor1 position="6135" topLine="182" />
</Cursor>
</File>
<File name="compass_screen.h" open="0" top="0" tabpos="8" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
@ -277,14 +272,163 @@
<Cursor1 position="3981" topLine="81" />
</Cursor>
</File>
<File name="lv_drivers\win_drv.h" open="0" top="0" tabpos="10" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="lvgl\demos\widgets\lv_demo_widgets.c" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="585" topLine="0" />
<Cursor1 position="2825" topLine="122" />
</Cursor>
</File>
<File name="lvgl\src\widgets\img\lv_img.h" open="0" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="lvgl\src\hal\lv_hal_disp.c" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="6960" topLine="203" />
<Cursor1 position="11123" topLine="327" />
</Cursor>
</File>
<File name="music_player_screen.c" open="0" top="0" tabpos="4" split="0" active="1" splitpos="0" zoom_1="1" zoom_2="0">
<Cursor>
<Cursor1 position="22334" topLine="0" />
</Cursor>
</File>
<File name="lvgl\src\draw\lv_img_buf.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="6210" topLine="113" />
</Cursor>
</File>
<File name="lvgl\examples\widgets\menu\lv_example_menu_5.c" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="7631" topLine="141" />
</Cursor>
</File>
<File name="find_my_phone_screen.h" open="0" top="0" tabpos="9" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="1078" topLine="3" />
</Cursor>
</File>
<File name="watch_carbon_assets.c" open="1" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="3114203" topLine="961" />
</Cursor>
</File>
<File name="lvgl\src\core\lv_obj_class.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="1857" topLine="35" />
</Cursor>
</File>
<File name="lvgl\src\widgets\chart\lv_chart.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="11658" topLine="336" />
</Cursor>
</File>
<File name="lvgl\src\core\lv_obj.c" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="7842" topLine="283" />
</Cursor>
</File>
<File name="main.c" open="1" top="1" tabpos="8" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="4911" topLine="160" />
</Cursor>
</File>
<File name="altimeter_screen.h" open="0" top="0" tabpos="7" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="971" topLine="3" />
</Cursor>
</File>
<File name="lvgl\src\core\lv_obj.h" open="0" top="0" tabpos="10" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="10348" topLine="265" />
</Cursor>
</File>
<File name="lvgl\src\widgets\label\lv_label.c" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="5010" topLine="164" />
</Cursor>
</File>
<File name="menu_screen.h" open="0" top="0" tabpos="12" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="350" topLine="0" />
</Cursor>
</File>
<File name="lvgl\src\font\lv_font_fmt_txt.c" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="0" topLine="24" />
</Cursor>
</File>
<File name="lvgl\src\misc\lv_area.h" open="0" top="0" tabpos="15" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="1489" topLine="74" />
</Cursor>
</File>
<File name="lv_drivers\display\SSD1963.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="1563" topLine="27" />
</Cursor>
</File>
<File name="lvgl\src\core\lv_obj_style.c" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="7273" topLine="217" />
</Cursor>
</File>
<File name="lvgl\src\widgets\list\lv_list.c" open="0" top="0" tabpos="6" split="0" active="1" splitpos="0" zoom_1="2" zoom_2="0">
<Cursor>
<Cursor1 position="2391" topLine="53" />
</Cursor>
</File>
<File name="firmware_version.h" open="0" top="0" tabpos="9" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="160" topLine="0" />
</Cursor>
</File>
<File name="lvgl\src\widgets\tileview\lv_tileview.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="1055" topLine="40" />
</Cursor>
<Folding>
<Collapse line="8" />
<Collapse line="995" />
</Folding>
</File>
<File name="lvgl\src\libs\ffmpeg\lv_ffmpeg.c" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="5784" topLine="170" />
</Cursor>
</File>
<File name="lv_drv_conf.h" open="0" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="6602" topLine="208" />
</Cursor>
</File>
<File name="lvgl\src\core\lv_indev.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="3034" topLine="107" />
</Cursor>
</File>
<File name="compass_assets.c" open="0" top="0" tabpos="13" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="0" topLine="143" />
</Cursor>
</File>
<File name="lv_drivers\win32drv\win32drv.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="0" topLine="15" />
</Cursor>
</File>
<File name="lvgl\src\misc\lv_timer.h" open="0" top="0" tabpos="10" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="2886" topLine="90" />
</Cursor>
</File>
<File name="lvgl\src\widgets\label\lv_label.h" open="0" top="0" tabpos="9" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="969" topLine="39" />
</Cursor>
</File>
<File name="lvgl\src\core\lv_obj_class.c" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="3011" topLine="100" />
</Cursor>
</File>
<File name="lvgl\src\core\lv_obj_tree.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="1234" topLine="30" />
</Cursor>
</File>
<File name="lvgl\lv_conf_template.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
@ -292,24 +436,59 @@
<Cursor1 position="0" topLine="56" />
</Cursor>
</File>
<File name="lvgl\src\misc\lv_anim.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="notification_screen.c" open="1" top="0" tabpos="5" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="749" topLine="34" />
<Cursor1 position="4989" topLine="92" />
</Cursor>
</File>
<File name="lvgl\src\core\lv_obj_pos.c" open="0" top="0" tabpos="12" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="lvgl\src\layouts\flex\lv_flex.c" open="0" top="0" tabpos="8" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="10562" topLine="336" />
<Cursor1 position="3097" topLine="74" />
</Cursor>
</File>
<File name="compass_screen.c" open="0" top="0" tabpos="7" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="find_my_phone_screen.c" open="0" top="0" tabpos="10" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="1480" topLine="179" />
<Cursor1 position="1081" topLine="138" />
</Cursor>
</File>
<File name="lv_drivers\win32drv\win32drv.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="lvgl\lvgl.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="0" topLine="15" />
<Cursor1 position="0" topLine="138" />
</Cursor>
</File>
<File name="settings_screen.c" open="0" top="0" tabpos="1" split="0" active="1" splitpos="513" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="38468" topLine="687" />
</Cursor>
</File>
<File name="lvgl\src\lv_api_map.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="722" topLine="32" />
</Cursor>
</File>
<File name="lv_drivers\display\monitor.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="289" topLine="31" />
</Cursor>
</File>
<File name="lvgl\src\layouts\grid\lv_grid.h" open="0" top="0" tabpos="13" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="579" topLine="17" />
</Cursor>
</File>
<File name="lvgl\src\widgets\imgbtn\lv_imgbtn.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="2129" topLine="53" />
</Cursor>
</File>
<File name="lvgl\src\misc\lv_color.c" open="0" top="0" tabpos="6" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="10782" topLine="316" />
</Cursor>
</File>
<File name="lvgl\src\misc\lv_log.h" open="0" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="2557" topLine="68" />
</Cursor>
</File>
<File name="lvgl\src\misc\lv_types.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
@ -322,228 +501,49 @@
<Cursor1 position="3706" topLine="117" />
</Cursor>
</File>
<File name="lvgl\src\core\lv_obj.h" open="0" top="0" tabpos="10" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="10348" topLine="265" />
</Cursor>
</File>
<File name="lvgl\src\misc\lv_log.h" open="0" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="2557" topLine="68" />
</Cursor>
</File>
<File name="lvgl\src\widgets\imgbtn\lv_imgbtn.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="2129" topLine="53" />
</Cursor>
</File>
<File name="lvgl\src\core\lv_obj_tree.c" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="2082" topLine="62" />
</Cursor>
</File>
<File name="altimeter_screen.c" open="0" top="0" tabpos="6" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="2832" topLine="27" />
</Cursor>
</File>
<File name="watch_face.h" open="0" top="0" tabpos="14" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="225" topLine="44" />
</Cursor>
</File>
<File name="lvgl\src\widgets\label\lv_label.c" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="5010" topLine="164" />
</Cursor>
</File>
<File name="lvgl\src\font\lv_font_montserrat_30.c" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="869" topLine="0" />
</Cursor>
</File>
<File name="lvgl\src\font\lv_font_montserrat_12.c" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="0" topLine="22" />
</Cursor>
</File>
<File name="lvgl\examples\widgets\bar\lv_example_bar_6.c" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="181" topLine="0" />
</Cursor>
</File>
<File name="lvgl\src\misc\lv_log.c" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="1509" topLine="59" />
</Cursor>
</File>
<File name="altimeter_screen_assets.c" open="0" top="0" tabpos="19" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="96342" topLine="161" />
</Cursor>
</File>
<File name="lvgl\src\hal\lv_hal_disp.c" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="11123" topLine="327" />
</Cursor>
</File>
<File name="settings_screen.c" open="0" top="0" tabpos="1" split="0" active="1" splitpos="513" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="38468" topLine="687" />
</Cursor>
</File>
<File name="lvgl\src\misc\lv_timer.c" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="5053" topLine="144" />
</Cursor>
</File>
<File name="lvgl\demos\widgets\assets\img_demo_widgets_avatar.c" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="1282774" topLine="472" />
</Cursor>
</File>
<File name="lvgl\lvgl.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="0" topLine="138" />
</Cursor>
</File>
<File name="lvgl\src\core\lv_disp.c" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="7126" topLine="230" />
</Cursor>
</File>
<File name="compass_assets.c" open="0" top="0" tabpos="13" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="0" topLine="143" />
</Cursor>
</File>
<File name="notification_screen.h" open="0" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="2362" topLine="39" />
</Cursor>
</File>
<File name="lv_drivers\lv_drv_conf_template.h" open="0" top="0" tabpos="11" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="10670" topLine="390" />
</Cursor>
</File>
<File name="lvgl\src\widgets\img\lv_img.c" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="1863" topLine="59" />
</Cursor>
</File>
<File name="lvgl\src\core\lv_event.h" open="0" top="0" tabpos="6" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="2085" topLine="26" />
</Cursor>
</File>
<File name="lvgl\src\misc\lv_area.h" open="0" top="0" tabpos="15" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="1489" topLine="74" />
</Cursor>
</File>
<File name="lv_conf.h" open="0" top="0" tabpos="7" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="572" topLine="0" />
</Cursor>
</File>
<File name="lv_drv_conf.h" open="0" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="6602" topLine="208" />
</Cursor>
</File>
<File name="lvgl\src\widgets\menu\lv_menu.c" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="3321" topLine="109" />
</Cursor>
</File>
<File name="watch_face.c.bck" open="0" top="0" tabpos="4" split="0" active="1" splitpos="702" zoom_1="0" zoom_2="-1">
<Cursor>
<Cursor1 position="678" topLine="0" />
</Cursor>
</File>
<File name="lvgl\src\font\lv_font.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="5535" topLine="120" />
</Cursor>
</File>
<File name="lvgl\src\hal\lv_hal_indev.c" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="3566" topLine="102" />
</Cursor>
</File>
<File name="lvgl\src\core\lv_obj.c" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="7842" topLine="283" />
</Cursor>
</File>
<File name="lvgl\src\hal\lv_hal_indev.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="5065" topLine="123" />
</Cursor>
</File>
<File name="lvgl\src\misc\lv_style.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="common_screen_components.c" open="1" top="0" tabpos="4" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="9059" topLine="242" />
<Cursor1 position="496" topLine="0" />
</Cursor>
</File>
<File name="lvgl\src\draw\lv_draw_rect.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="lvgl\src\core\lv_event.c" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="539" topLine="9" />
<Cursor1 position="5365" topLine="214" />
</Cursor>
</File>
<File name="main.c" open="0" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="lvgl\src\core\lv_obj_pos.h" open="0" top="0" tabpos="4" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="2731" topLine="141" />
<Cursor1 position="11878" topLine="258" />
</Cursor>
</File>
<File name="lvgl\src\widgets\tileview\lv_tileview.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="lv_drivers\lv_drv_conf_template.h" open="0" top="0" tabpos="11" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="1055" topLine="40" />
</Cursor>
<Folding>
<Collapse line="8" />
<Collapse line="995" />
</Folding>
</File>
<File name="lvgl\src\core\lv_indev.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="3034" topLine="107" />
<Cursor1 position="10670" topLine="390" />
</Cursor>
</File>
<File name="lvgl\src\hal\lv_hal_disp.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="watch_face.c" open="1" top="0" tabpos="7" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="10233" topLine="226" />
<Cursor1 position="388" topLine="204" />
</Cursor>
</File>
<File name="lvgl\demos\widgets\lv_demo_widgets.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="lvgl\examples\widgets\bar\lv_example_bar_6.c" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="456" topLine="6" />
<Cursor1 position="181" topLine="0" />
</Cursor>
</File>
<File name="lvgl\examples\widgets\menu\lv_example_menu_5.c" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="lvgl\src\widgets\img\lv_img.c" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="7631" topLine="141" />
</Cursor>
</File>
<File name="lvgl\src\core\lv_obj_class.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="1857" topLine="35" />
</Cursor>
</File>
<File name="lvgl\src\misc\lv_color.c" open="0" top="0" tabpos="6" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="10782" topLine="316" />
</Cursor>
</File>
<File name="lvgl\src\libs\ffmpeg\lv_ffmpeg.c" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="5784" topLine="170" />
</Cursor>
</File>
<File name="lvgl\src\core\lv_obj_scroll.h" open="0" top="0" tabpos="7" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="4372" topLine="104" />
<Cursor1 position="1863" topLine="59" />
</Cursor>
</File>
</CodeBlocks_layout_file>

View File

@ -76,6 +76,19 @@ static void compass_screen_on_state_change_cb(CompassScreenState_e compassScreen
}
}
static void notification_screen_on_state_change_cb(NotificationState_e notificationState, uint32_t notification_handle)
{
switch(notificationState)
{
case NOTIFICATION_STATE_CLEARED:
LV_LOG_USER("Notification %u cleared !", notification_handle);
break;
case NOTIFICATION_STATE_DISPLAYED:
LV_LOG_USER("Notification %u displayed !", notification_handle);
break;
}
}
static void azimuth_and_temperature_cb(uint16_t *azimuth, float *temperature)
{
static uint16_t _azimuth = 0;
@ -153,6 +166,8 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLi
altimeter_screen_init(&altimeterScreen);
altimeter_screen_register_measurement_cb(&altimeterScreen, &(alti_meas_cb));
notification_screen_init(&notificationScreen);
notification_screen_register_on_state_change_cb(&notificationScreen, &(notification_screen_on_state_change_cb));
notification_screen_set_displayed_hour_format(&notificationScreen, true);
find_my_phone_screen_init(&findMyPhoneScreen);
find_my_phone_screen_register_BLE_command_send_cb(&findMyPhoneScreen, &(sendMyFindPhoneBLECommandCb));
find_my_phone_screen_notify_BLE_connection_state(&findMyPhoneScreen, true);
@ -170,7 +185,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLi
lv_scr_load(watchFace.display);
watch_face_set_step_count(&watchFace, 10258);
watch_face_set_step_count_indicator(&watchFace, 10258);
//settings_screen();

View File

@ -15,7 +15,7 @@ void _notification_list_debug(NotificationDataList_t notificationList);
void _display_message_notification(NotificationScreen_t * const notificationScreen, NotificationData_t *notification);
void _notification_popup_destroy(NotificationScreen_t * const notificationScreen);
const char *_notification_type_to_char(NotificationType_e notificationType);
const char *_notification_timestamp_to_date(time_t timestamp);
const char *_notification_timestamp_to_date(time_t timestamp, bool hour_24H_format);
static void notification_scrolled_event_cb(lv_event_t *e)
{
@ -37,7 +37,7 @@ static void notification_scrolled_event_cb(lv_event_t *e)
_notification_popup_destroy(notificationScreen);
notificationScreen->new_notification_available = false;
notification->read = true;
if(notificationScreen->notificationOnStateChangeCb) notificationScreen->notificationOnStateChangeCb(NOTIFICATION_STATE_CLEARED);
if(notificationScreen->notificationOnStateChangeCb) notificationScreen->notificationOnStateChangeCb(NOTIFICATION_STATE_CLEARED, notification->handle);
}
}
@ -67,6 +67,17 @@ void notification_screen_register_on_state_change_cb(NotificationScreen_t * cons
notificationScreen->notificationOnStateChangeCb = notificationOnStateChangeCb;
}
void notification_screen_set_displayed_hour_format(NotificationScreen_t * const notificationScreen, bool hour_24H_format)
{
if(!notificationScreen)
{
LV_LOG_ERROR("NULL pointer given !");
return;
}
notificationScreen->notification_hour_24H_format = hour_24H_format;
}
void notification_screen_notify(NotificationScreen_t * const notificationScreen, uint32_t handle, time_t dateOfArrival, NotificationType_e notificationType, char * title, char * body)
{
if(!notificationScreen)
@ -108,7 +119,7 @@ void notification_screen_notify(NotificationScreen_t * const notificationScreen,
case NOTIFICATION_TYPE_CALL:
break;
default:
if(notificationScreen->notificationOnStateChangeCb) notificationScreen->notificationOnStateChangeCb(NOTIFICATION_STATE_DISPLAYED);
if(notificationScreen->notificationOnStateChangeCb) notificationScreen->notificationOnStateChangeCb(NOTIFICATION_STATE_DISPLAYED, notification->handle);
_display_message_notification(notificationScreen, notification);
}
}
@ -323,7 +334,7 @@ void _display_message_notification(NotificationScreen_t * const notificationScre
lv_obj_set_style_pad_right(notificationScreen->date_label, 10, LV_PART_MAIN);
lv_obj_set_style_text_color(notificationScreen->date_label, lv_color_white(), LV_PART_MAIN);
lv_obj_align(notificationScreen->date_label, LV_ALIGN_TOP_RIGHT, 0, 0);
lv_label_set_text(notificationScreen->date_label, _notification_timestamp_to_date(notification->dateOfArrival));
lv_label_set_text_static(notificationScreen->date_label, _notification_timestamp_to_date(notification->dateOfArrival, notificationScreen->notification_hour_24H_format));
//Create the sub-area in the notification
lv_obj_t *sub_area = lv_obj_create(main_notification);
@ -358,7 +369,7 @@ void _display_message_notification(NotificationScreen_t * const notificationScre
//We just have to update the notification content
lv_label_set_text_static(notificationScreen->type_label, _notification_type_to_char(notification->type));
lv_label_set_text_static(notificationScreen->title_label, notification->title);
lv_label_set_text_static(notificationScreen->date_label, _notification_timestamp_to_date(notification->dateOfArrival));
lv_label_set_text_static(notificationScreen->date_label, _notification_timestamp_to_date(notification->dateOfArrival, notificationScreen->notification_hour_24H_format));
lv_label_set_text_static(notificationScreen->body_label, notification->body);
}
}
@ -391,12 +402,24 @@ const char *_notification_type_to_char(NotificationType_e notificationType)
}
}
const char *_notification_timestamp_to_date(time_t timestamp)
const char *_notification_timestamp_to_date(time_t timestamp, bool hour_24H_format)
{
static char date[9]; //Ex 7:23PM
struct tm *time = gmtime(&timestamp);
sprintf(date, "%s%d:%s%d", time->tm_hour < 10 ? "0" : "", time->tm_hour, time->tm_min < 10 ? "0" : "", time->tm_min);
if(hour_24H_format)
sprintf(date, "%s%d:%s%d", time->tm_hour < 10 ? "0" : "", time->tm_hour, time->tm_min < 10 ? "0" : "", time->tm_min);
else
{
// Intermediate hour var to set it on a 12H format
uint8_t hour = time->tm_hour;
if(hour > 12)hour -= 12;
sprintf(date, "%d:%s%d%s", hour,
time->tm_min < 10 ? "0" : "", time->tm_min,
time->tm_hour < 13 ? "AM" : "PM");
}
return date;
}

View File

@ -38,7 +38,7 @@ typedef struct NotificationData
} NotificationData_t, *NotificationDataList_t;
typedef void (*NotificationOnStateChangeCb_t)(NotificationState_e notificationState);
typedef void (*NotificationOnStateChangeCb_t)(NotificationState_e notificationState, uint32_t notification_handle);
typedef struct NotificationScreen
{
@ -57,13 +57,16 @@ typedef struct NotificationScreen
NotificationDataList_t notificationList; // Actual notifications
NotificationDataList_t freeNotificationList; // Free notification object pool
// Miscellaneous
bool new_notification_available;
bool new_notification_available : 1;
bool notification_hour_24H_format : 1;
} NotificationScreen_t;
void notification_screen_init(NotificationScreen_t * const notificationScreen);
void notification_screen_register_on_state_change_cb(NotificationScreen_t * const notificationScreen, NotificationOnStateChangeCb_t notificationOnStateChangeCb);
void notification_screen_set_displayed_hour_format(NotificationScreen_t * const notificationScreen, bool hour_24H_format);
void notification_screen_notify(NotificationScreen_t * const notificationScreen, uint32_t handle, time_t dateOfArrival, NotificationType_e notificationType, char * title, char * body);
bool notification_screen_new_notification_available(NotificationScreen_t * const notificationScreen);

File diff suppressed because one or more lines are too long

View File

@ -5,10 +5,73 @@
#include <stdio.h>
#include <stdlib.h>
#define SMART_WATCH_CASIO_FACE (0)
#define SMART_WATCH_CARBON_FACE (1)
#define SMART_WATCH_FACE SMART_WATCH_CARBON_FACE
LV_IMG_DECLARE(battery_low_icon)
LV_IMG_DECLARE(battery_charging_icon)
LV_IMG_DECLARE(battery_charged_icon)
#if SMART_WATCH_FACE == SMART_WATCH_CASIO_FACE
//We declare the needed assets for the casio watch face:
LV_IMG_DECLARE(watch_casio_face_asset)
LV_IMG_DECLARE(watch_casio_hour_hand_asset)
LV_IMG_DECLARE(watch_casio_minute_hand_asset)
LV_IMG_DECLARE(watch_casio_second_hand_asset)
LV_IMG_DECLARE(watch_casio_medium_hand_asset)
static const void *watch_face_img = &watch_casio_face_asset;
static const void *watch_hour_hand_img = &watch_casio_hour_hand_asset;
#define HOUR_HAND_POS 112, 60
#define HOUR_HAND_PIVOT 8, 60
static const void *watch_minute_hand_img = &watch_casio_minute_hand_asset;
#define MINUTE_HAND_POS 112, 28
#define MINUTE_HAND_PIVOT 7, 92
static const void *watch_second_hand_img = &watch_casio_second_hand_asset;
#define SECOND_HAND_POS 115, 28
#define SECOND_HAND_PIVOT 5, 92
static const void *watch_medium_hand_img = &watch_casio_medium_hand_asset;
#define MEDIUM_HAND_POS 115, 48
#define MEDIUM_HAND_PIVOT 4, 25
#define BATTERY_ARC_OFFSETS -1, 45
#define BATTERY_ICON_OFFSETS 0, -9
#define STEP_COUNTER_LABEL_POS 63, 111
#define DATE_WINDOW_POS 180, 111
#define DATE_LABEL_COLOR lv_color_black()
#elif SMART_WATCH_FACE == SMART_WATCH_CARBON_FACE
//We declare the needed assets for the carbon watch face:
LV_IMG_DECLARE(watch_carbon_face_asset)
LV_IMG_DECLARE(watch_carbon_hour_hand_asset)
LV_IMG_DECLARE(watch_carbon_minute_hand_asset)
LV_IMG_DECLARE(watch_carbon_second_hand_asset)
LV_IMG_DECLARE(watch_carbon_medium_hand_asset)
static const void *watch_face_img = &watch_carbon_face_asset;
static const void *watch_hour_hand_img = &watch_carbon_hour_hand_asset;
#define HOUR_HAND_POS 113, 57
#define HOUR_HAND_PIVOT 6, 62
static const void *watch_minute_hand_img = &watch_carbon_minute_hand_asset;
#define MINUTE_HAND_POS 113, 14
#define MINUTE_HAND_PIVOT 6, 105
static const void *watch_second_hand_img = &watch_carbon_second_hand_asset;
#define SECOND_HAND_POS 115, -1
#define SECOND_HAND_PIVOT 4, 120
static const void *watch_medium_hand_img = &watch_carbon_medium_hand_asset;
#define MEDIUM_HAND_POS 115, 50
#define MEDIUM_HAND_PIVOT 4, 26
#define BATTERY_ARC_OFFSETS 0, 44
#define BATTERY_ICON_OFFSETS 0, -12
#define STEP_COUNTER_LABEL_POS 50, 111
#define DATE_WINDOW_POS 168, 111
#define DATE_LABEL_COLOR lv_color_white()
#else
#error "Bad app_config.h configuration for the selected watch face"
#endif //SMART_WATCH_FACE
static void _set_bluetooth_indicator(WatchFace_t * const watchFace)
{
switch(watchFace->bluetoothIndicator.bluetoothState)
@ -76,7 +139,7 @@ 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(0)//(!increment || watchFace->secondHand.handAngle >= 3660 /*|| (int)watchFace->secondHand.handAngle % 100 > 50*/)
{
watchFace->dateTimeCb(&watchFace->dateTime);
watchFace->secondHand.handAngle = 60 * watchFace->dateTime.tm_sec;
@ -95,7 +158,7 @@ static void update_watch_hands_angles(WatchFace_t * const watchFace, uint8_t inc
}
else
{
watchFace->secondHand.handAngle += increment;
watchFace->secondHand.handAngle += (uint32_t)increment*15;//increment;//
}
watchFace->minuteHand.handAngle = 60 * watchFace->dateTime.tm_min + watchFace->secondHand.handAngle / 60;
watchFace->hourHand.handAngle = 300 * watchFace->dateTime.tm_hour + watchFace->minuteHand.handAngle / 12;
@ -140,7 +203,7 @@ static void update_watch_hands_angles(WatchFace_t * const watchFace, uint8_t inc
static void hand_timer_anim_cb(lv_timer_t *timer)
{
WatchFace_t *watchFace = timer->user_data;
update_watch_hands_angles(watchFace, 12);
update_watch_hands_angles(watchFace, 255/*12*/);
}
static void battery_timer_anim_cb(lv_timer_t *timer)
@ -180,7 +243,7 @@ static void set_battery_state_icon(WatchFace_t * const watchFace)
static void hide_hour_and_minutes_hand_cb(lv_event_t *e)
{
WatchFace_t *watchFace = e->user_data;
WatchFace_t *watchFace = lv_event_get_user_data(e);
if(255 == lv_obj_get_style_opa(watchFace->hourHand.handImg, LV_PART_MAIN))
{
@ -251,12 +314,6 @@ void watch_face_create(WatchFace_t * const watchFace)
}
//We declare the needed assets for the watch face:
LV_IMG_DECLARE(watch_casio_face_asset)
LV_IMG_DECLARE(watch_casio_hour_hand_asset)
LV_IMG_DECLARE(watch_casio_minute_hand_asset)
LV_IMG_DECLARE(watch_casio_second_hand_asset)
LV_IMG_DECLARE(watch_casio_medium_hand_asset)
LV_IMG_DECLARE(watch_casio_small_hand_asset)
LV_IMG_DECLARE(bluetooth_icon)
//We create our parent screen :
@ -268,16 +325,10 @@ void watch_face_create(WatchFace_t * const watchFace)
}
//Our display is the watch face image :
watchFace->display = lv_img_create(NULL);
lv_img_set_src(watchFace->display, &watch_casio_face_asset);
lv_img_set_src(watchFace->display, watch_face_img);
lv_obj_set_style_bg_color(watchFace->display, lv_color_black(), LV_PART_MAIN);
lv_obj_add_event_cb(watchFace->display, &(hide_hour_and_minutes_hand_cb), LV_EVENT_LONG_PRESSED, watchFace);
//We load our other assets :
/*lv_obj_t *smallHandImg = lv_img_create(watchFace->display);
lv_img_set_src(smallHandImg, &watch_casio_small_hand_asset);
lv_obj_set_pos(smallHandImg, 69, 98);
lv_img_set_pivot(smallHandImg, 4, 20);*/
//Battery arc is created here
if(watchFace->batteryIndicator.batteryArc)
{
@ -290,7 +341,7 @@ void watch_face_create(WatchFace_t * const watchFace)
lv_obj_remove_style(watchFace->batteryIndicator.batteryArc, NULL, LV_PART_KNOB);
lv_obj_clear_flag(watchFace->batteryIndicator.batteryArc, LV_OBJ_FLAG_CLICKABLE);
lv_obj_set_size(watchFace->batteryIndicator.batteryArc, 60, 60);
lv_obj_align(watchFace->batteryIndicator.batteryArc, LV_ALIGN_CENTER, -1, 45);
lv_obj_align(watchFace->batteryIndicator.batteryArc, LV_ALIGN_CENTER, BATTERY_ARC_OFFSETS);
lv_obj_set_style_arc_width(watchFace->batteryIndicator.batteryArc, 5, LV_PART_INDICATOR);
lv_obj_set_style_arc_width(watchFace->batteryIndicator.batteryArc, 0, LV_PART_MAIN);
lv_obj_set_style_arc_color(watchFace->batteryIndicator.batteryArc, lv_color_make(228, 233, 236), LV_PART_INDICATOR);
@ -331,7 +382,7 @@ void watch_face_create(WatchFace_t * const watchFace)
// 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);
lv_obj_align_to(watchFace->batteryIndicator.batteryIcon, watchFace->batteryIndicator.label, LV_ALIGN_OUT_BOTTOM_MID, BATTERY_ICON_OFFSETS);
// Bluetooth status icon is created here
if(watchFace->bluetoothIndicator.bluetoothIcon)
@ -359,7 +410,7 @@ void watch_face_create(WatchFace_t * const watchFace)
watchFace->stepCounter.label = lv_label_create(watchFace->display);
lv_label_set_text_static(watchFace->stepCounter.label, watchFace->stepCounter.text);
lv_obj_set_style_text_color(watchFace->stepCounter.label, lv_color_white(), LV_PART_MAIN);
lv_obj_set_pos(watchFace->stepCounter.label, 63, 111);
lv_obj_set_pos(watchFace->stepCounter.label, STEP_COUNTER_LABEL_POS);
if(watchFace->mediumHand24h.handImg)
{
@ -369,9 +420,9 @@ void watch_face_create(WatchFace_t * const watchFace)
}
watchFace->mediumHand24h.handImg = lv_img_create(watchFace->display);
lv_img_set_src(watchFace->mediumHand24h.handImg, &watch_casio_medium_hand_asset);
lv_obj_set_pos(watchFace->mediumHand24h.handImg, 115, 48);
lv_img_set_pivot(watchFace->mediumHand24h.handImg, 4, 25);
lv_img_set_src(watchFace->mediumHand24h.handImg, watch_medium_hand_img);
lv_obj_set_pos(watchFace->mediumHand24h.handImg, MEDIUM_HAND_POS);
lv_img_set_pivot(watchFace->mediumHand24h.handImg, MEDIUM_HAND_PIVOT);
/*lv_obj_t *mediumHandChronoImg = lv_img_create(watchFace->display);
lv_img_set_src(mediumHandChronoImg, &watch_casio_medium_hand_asset);
@ -387,9 +438,10 @@ void watch_face_create(WatchFace_t * const watchFace)
}
watchFace->dateWindow.dateWindowWidget = lv_label_create(watchFace->display);
lv_label_set_text_static(watchFace->dateWindow.dateWindowWidget, watchFace->dateWindow.dateWindowText);
lv_obj_set_pos(watchFace->dateWindow.dateWindowWidget, 180,111);
lv_obj_set_pos(watchFace->dateWindow.dateWindowWidget, DATE_WINDOW_POS);
lv_obj_set_width(watchFace->dateWindow.dateWindowWidget, 20);
lv_obj_set_style_text_align(watchFace->dateWindow.dateWindowWidget, LV_TEXT_ALIGN_CENTER, LV_PART_MAIN);
lv_obj_set_style_text_color(watchFace->dateWindow.dateWindowWidget, DATE_LABEL_COLOR, LV_PART_MAIN);
if(watchFace->hourHand.handImg)
{
@ -399,9 +451,9 @@ void watch_face_create(WatchFace_t * const watchFace)
}
watchFace->hourHand.handImg = lv_img_create(watchFace->display);
lv_img_set_src(watchFace->hourHand.handImg, &watch_casio_hour_hand_asset);
lv_obj_set_pos(watchFace->hourHand.handImg, 112, 60);
lv_img_set_pivot(watchFace->hourHand.handImg, 8, 60);
lv_img_set_src(watchFace->hourHand.handImg, watch_hour_hand_img);
lv_obj_set_pos(watchFace->hourHand.handImg, HOUR_HAND_POS);
lv_img_set_pivot(watchFace->hourHand.handImg, HOUR_HAND_PIVOT);
if(watchFace->minuteHand.handImg)
{
@ -411,9 +463,9 @@ void watch_face_create(WatchFace_t * const watchFace)
}
watchFace->minuteHand.handImg = lv_img_create(watchFace->display);
lv_img_set_src(watchFace->minuteHand.handImg, &watch_casio_minute_hand_asset);
lv_obj_set_pos(watchFace->minuteHand.handImg, 112, 28);
lv_img_set_pivot(watchFace->minuteHand.handImg, 7, 92);
lv_img_set_src(watchFace->minuteHand.handImg, watch_minute_hand_img);
lv_obj_set_pos(watchFace->minuteHand.handImg, MINUTE_HAND_POS);
lv_img_set_pivot(watchFace->minuteHand.handImg, MINUTE_HAND_PIVOT);
if(watchFace->secondHand.handImg)
{
@ -423,9 +475,9 @@ void watch_face_create(WatchFace_t * const watchFace)
}
watchFace->secondHand.handImg = lv_img_create(watchFace->display);
lv_img_set_src(watchFace->secondHand.handImg, &watch_casio_second_hand_asset);
lv_obj_set_pos(watchFace->secondHand.handImg, 115, 28);
lv_img_set_pivot(watchFace->secondHand.handImg, 5, 92);
lv_img_set_src(watchFace->secondHand.handImg, watch_second_hand_img);
lv_obj_set_pos(watchFace->secondHand.handImg, SECOND_HAND_POS);
lv_img_set_pivot(watchFace->secondHand.handImg, SECOND_HAND_PIVOT);
//We set the appropriate angles to each of the hands
update_watch_hands_angles(watchFace, 0);
@ -446,7 +498,7 @@ void watch_face_create(WatchFace_t * const watchFace)
watchFace->handAnimationTimer = NULL;
}
watchFace->handAnimationTimer = lv_timer_create(&(hand_timer_anim_cb), 200, watchFace);
watchFace->handAnimationTimer = lv_timer_create(&(hand_timer_anim_cb), /*200*/1, watchFace);
}
void watch_face_set_battery_indicator(WatchFace_t * const watchFace, uint8_t levelInPercent, BatteryState_e batteryState)
@ -510,7 +562,7 @@ void watch_face_set_bluetooth_indicator(WatchFace_t * const watchFace, Bluetooth
_set_bluetooth_indicator(watchFace);
}
void watch_face_set_step_count(WatchFace_t * const watchFace, uint32_t step_count)
void watch_face_set_step_count_indicator(WatchFace_t * const watchFace, uint32_t stepCount)
{
if(!watchFace)
{
@ -518,12 +570,12 @@ void watch_face_set_step_count(WatchFace_t * const watchFace, uint32_t step_coun
return;
}
if(step_count < 1000)
sprintf(watchFace->stepCounter.text, "%u", step_count);
else if(step_count < 9996)
sprintf(watchFace->stepCounter.text, "%.2fk", step_count/1000.0);
if(stepCount < 1000)
sprintf(watchFace->stepCounter.text, "%u", stepCount);
else if(stepCount < 9996)
sprintf(watchFace->stepCounter.text, "%.2fk", stepCount/1000.0);
else
sprintf(watchFace->stepCounter.text, "%.1fk", step_count/1000.0);
sprintf(watchFace->stepCounter.text, "%.1fk", stepCount/1000.0);
if(!watchFace->display) return;
@ -565,3 +617,14 @@ void watch_face_force_sync(WatchFace_t *const watchFace)
update_watch_hands_angles(watchFace, 0);
}
bool watch_face_is_in_use(WatchFace_t * const watchFace)
{
if(!watchFace)
{
LV_LOG_ERROR("NULL pointer given !");
return false;
}
return watchFace->display != NULL;
}

View File

@ -22,6 +22,8 @@ typedef void (*DateTimeCb_t)(struct tm * const dateTime);
typedef void (*BatteryIndicatorCb_t)(uint8_t *levelInPercent, BatteryState_e *batteryState);
typedef void (*StepCounterIndicatorCb_t)(uint32_t *stepCount);
typedef struct DateWindow
{
lv_obj_t *dateWindowWidget;
@ -125,7 +127,13 @@ void watch_face_set_battery_indicator(WatchFace_t * const watchFace, uint8_t lev
*/
void watch_face_set_bluetooth_indicator(WatchFace_t * const watchFace, BluetoothState_e bluetoothState);
void watch_face_set_step_count(WatchFace_t * const watchFace, uint32_t step_count);
/**
* @brief Shows the current step count passed as parameter on the watch face.
*
* @param watchFace a pointer to the watch face context structure.
* @param step_count the step count to show on the watch face.
*/
void watch_face_set_step_count_indicator(WatchFace_t * const watchFace, uint32_t stepCount);
/**
* @brief Forces the watch face to sync up with the RTC by calling the provided date_time_cb
@ -135,8 +143,17 @@ void watch_face_set_step_count(WatchFace_t * const watchFace, uint32_t step_coun
void watch_face_force_sync(WatchFace_t * const watchFace);
/**
* @brief Frees all resources used by the WatchFace object
*
* @brief Returns true if the watch face screen is currently being used and displayed.
*
* @param watchFace a pointer to the watch face context structure.
* @return true if the watch face screen is being used
* @return false if the watch face screen is not being used/currently displayed
*/
bool watch_face_is_in_use(WatchFace_t * const watchFace);
/**
* @brief Frees all resources used by the WatchFace object.
*
* @param watchFace a pointer to the watch face context structure.
*/
void watch_face_destroy(WatchFace_t * const watchFace);

View File

@ -1,568 +0,0 @@
#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)
LV_IMG_DECLARE(battery_charged_icon)
static void _set_bluetooth_indicator(WatchFace_t * const watchFace)
{
switch(watchFace->bluetoothIndicator.bluetoothState)
{
case BLUETOOTH_STATE_ON:
lv_obj_set_style_img_recolor_opa(watchFace->bluetoothIndicator.bluetoothIcon, 185, LV_PART_MAIN);
lv_obj_clear_flag(watchFace->bluetoothIndicator.bluetoothIcon, LV_OBJ_FLAG_HIDDEN);
break;
case BLUETOOTH_STATE_CONNECTED:
lv_obj_set_style_img_recolor_opa(watchFace->bluetoothIndicator.bluetoothIcon, 0, LV_PART_MAIN);
lv_obj_clear_flag(watchFace->bluetoothIndicator.bluetoothIcon, LV_OBJ_FLAG_HIDDEN);
break;
default:
lv_obj_add_flag(watchFace->bluetoothIndicator.bluetoothIcon, LV_OBJ_FLAG_HIDDEN);
}
}
static void gesture_event_cb(lv_event_t * e)
{
WatchFace_t *watchFace = e->user_data;
lv_dir_t gesture;
switch(gesture = lv_indev_get_gesture_dir(lv_indev_get_act()))
{
case LV_DIR_LEFT:
LV_LOG_USER("GESTURE : LEFT");
break;
case LV_DIR_RIGHT:
LV_LOG_USER("GESTURE : RIGHT");
// We delete the timer
lv_timer_del(watchFace->batteryIndicator.lowBatteryAnimationTimer);
lv_timer_del(watchFace->handAnimationTimer);
// We create the menu screen and switch to it
extern MenuScreen_t menuScreen;
menu_screen_create(&menuScreen);
lv_scr_load_anim(menuScreen.display, LV_SCR_LOAD_ANIM_MOVE_RIGHT, 400, 0, true);
break;
case LV_DIR_TOP:
LV_LOG_USER("GESTURE : TOP");
break;
case LV_DIR_BOTTOM:
LV_LOG_USER("GESTURE : BOTTOM");
break;
default:
LV_LOG_USER("GESTURE : %u", gesture);
}
}
static void cleanup_event_cb(lv_event_t * e)
{
WatchFace_t *watchFace = e->user_data;
watch_face_destroy(watchFace);
LV_LOG_USER("cleanup");
}
static void update_watch_hands_angles(WatchFace_t * const watchFace, uint8_t increment)
{
if(!watchFace)
{
LV_LOG_ERROR("NULL pointer given !");
return;
}
//We retrieve the current time:
if(watchFace->dateTimeCb)
{
//We compute each hand angle
if(0)//(!increment || watchFace->secondHand.handAngle >= 3660 /*|| (int)watchFace->secondHand.handAngle % 100 > 50*/)
{
watchFace->dateTimeCb(&watchFace->dateTime);
watchFace->secondHand.handAngle = 60 * watchFace->dateTime.tm_sec;
//Don't forget to update the day date window
sprintf(watchFace->dateWindow.dateWindowText, "%d", watchFace->dateTime.tm_mday);
lv_label_set_text_static(watchFace->dateWindow.dateWindowWidget, watchFace->dateWindow.dateWindowText);
if(watchFace->batteryIndicatorCb)
{
uint8_t levelInPercent = 0;
BatteryState_e batteryState = BATTERY_STATE_DISCHARGING;
watchFace->batteryIndicatorCb(&levelInPercent, &batteryState);
watch_face_set_battery_indicator(watchFace, levelInPercent, batteryState);
}
}
else
{
watchFace->secondHand.handAngle += (uint32_t)increment*15;//increment;//
}
watchFace->minuteHand.handAngle = 60 * watchFace->dateTime.tm_min + watchFace->secondHand.handAngle / 60;
watchFace->hourHand.handAngle = 300 * watchFace->dateTime.tm_hour + watchFace->minuteHand.handAngle / 12;
watchFace->mediumHand24h.handAngle = watchFace->hourHand.handAngle / 2;
LV_LOG_USER("angle : %f", watchFace->secondHand.handAngle);
//We update the angle
lv_img_set_angle(watchFace->secondHand.handImg, (uint16_t) watchFace->secondHand.handAngle % 3600);
lv_img_set_angle(watchFace->minuteHand.handImg, (uint16_t) watchFace->minuteHand.handAngle % 3600);
lv_img_set_angle(watchFace->hourHand.handImg, (uint16_t) watchFace->hourHand.handAngle % 3600);
lv_img_set_angle(watchFace->mediumHand24h.handImg, (uint16_t) watchFace->mediumHand24h.handAngle % 3600);
/** To delete just for the preview **/
static uint8_t percentage = 0;
BatteryState_e batteryState = BATTERY_STATE_DISCHARGING;
if(percentage % 101 < 30)
{
batteryState = BATTERY_STATE_DISCHARGING;
watch_face_set_bluetooth_indicator(watchFace, BLUETOOTH_STATE_OFF);
}
else if(percentage % 101 < 70)
{
batteryState = BATTERY_STATE_CHARGING;
watch_face_set_bluetooth_indicator(watchFace, BLUETOOTH_STATE_ON);
}
else
{
batteryState = BATTERY_STATE_CHARGED;
watch_face_set_bluetooth_indicator(watchFace, BLUETOOTH_STATE_CONNECTED);
}
watch_face_set_battery_indicator(watchFace, percentage++ % 101, batteryState);
/** END OF DELETE SECTION **/
}
else
{
LV_LOG_USER("DateTimeCb is NULL, be sure to register a callback !");
}
}
static void hand_timer_anim_cb(lv_timer_t *timer)
{
WatchFace_t *watchFace = timer->user_data;
update_watch_hands_angles(watchFace, 255/*12*/);
}
static void battery_timer_anim_cb(lv_timer_t *timer)
{
WatchFace_t *watchFace = timer->user_data;
if(lv_obj_has_flag(watchFace->batteryIndicator.batteryIcon, LV_OBJ_FLAG_HIDDEN))
{
lv_obj_clear_flag(watchFace->batteryIndicator.batteryIcon, LV_OBJ_FLAG_HIDDEN);
}
else
{
lv_obj_add_flag(watchFace->batteryIndicator.batteryIcon, LV_OBJ_FLAG_HIDDEN);
}
}
static void set_battery_state_icon(WatchFace_t * const watchFace)
{
switch(watchFace->batteryIndicator.batteryState)
{
case BATTERY_STATE_CHARGING:
lv_timer_pause(watchFace->batteryIndicator.lowBatteryAnimationTimer);
lv_obj_clear_flag(watchFace->batteryIndicator.batteryIcon, LV_OBJ_FLAG_HIDDEN);
lv_img_set_src(watchFace->batteryIndicator.batteryIcon, &battery_charging_icon);
break;
case BATTERY_STATE_CHARGED:
lv_timer_pause(watchFace->batteryIndicator.lowBatteryAnimationTimer);
lv_obj_clear_flag(watchFace->batteryIndicator.batteryIcon, LV_OBJ_FLAG_HIDDEN);
lv_img_set_src(watchFace->batteryIndicator.batteryIcon, &battery_charged_icon);
break;
default:
lv_obj_add_flag(watchFace->batteryIndicator.batteryIcon, LV_OBJ_FLAG_HIDDEN);
lv_img_set_src(watchFace->batteryIndicator.batteryIcon, &battery_low_icon);
break;
}
}
static void hide_hour_and_minutes_hand_cb(lv_event_t *e)
{
WatchFace_t *watchFace = e->user_data;
if(255 == lv_obj_get_style_opa(watchFace->hourHand.handImg, LV_PART_MAIN))
{
lv_obj_set_style_opa(watchFace->hourHand.handImg, 120, LV_PART_MAIN);
lv_obj_set_style_opa(watchFace->minuteHand.handImg, 120, LV_PART_MAIN);
}
else
{
lv_obj_set_style_opa(watchFace->hourHand.handImg, 255, LV_PART_MAIN);
lv_obj_set_style_opa(watchFace->minuteHand.handImg, 255, LV_PART_MAIN);
}
/*if(lv_obj_has_flag(watchFace->hourHand.handImg, LV_OBJ_FLAG_HIDDEN))
{
lv_obj_clear_flag(watchFace->hourHand.handImg, LV_OBJ_FLAG_HIDDEN);
lv_obj_clear_flag(watchFace->minuteHand.handImg, LV_OBJ_FLAG_HIDDEN);
}
else
{
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);
char test[] = "aéb";
strcpy(body, "Héy 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(&notificationScreen, 1696358171, time(NULL) + 3600*2, NOTIFICATION_TYPE_GADGET_BRIDGE, title, body);
LV_LOG_USER("unread(%u)/ total(%u)", notification_screen_unread_notification_count(&notificationScreen), notification_screen_notification_count(&notificationScreen));
}
void watch_face_init(WatchFace_t * const watchFace)
{
if(!watchFace)
{
LV_LOG_ERROR("NULL pointer given !");
return;
}
memset(watchFace, 0, sizeof(WatchFace_t));
strcpy(watchFace->stepCounter.text, "0");
}
void watch_face_register_date_time_cb(WatchFace_t * const watchFace, DateTimeCb_t dateTimeCb)
{
if(!watchFace)
{
LV_LOG_ERROR("NULL pointer given !");
return;
}
watchFace->dateTimeCb = dateTimeCb;
}
void watch_face_create(WatchFace_t * const watchFace)
{
if(!watchFace)
{
LV_LOG_ERROR("NULL pointer given !");
return;
}
//We declare the needed assets for the watch face:
LV_IMG_DECLARE(watch_carbon_face_asset)
LV_IMG_DECLARE(watch_carbon_hour_hand_asset)
LV_IMG_DECLARE(watch_carbon_minute_hand_asset)
LV_IMG_DECLARE(watch_carbon_second_hand_asset)
LV_IMG_DECLARE(watch_carbon_medium_hand_asset)
LV_IMG_DECLARE(watch_casio_small_hand_asset)
LV_IMG_DECLARE(bluetooth_icon)
//We create our parent screen :
if(watchFace->display)
{
LV_LOG_ERROR("display should be NULL here !");
lv_obj_del(watchFace->display);
watchFace->display = NULL;
}
//Our display is the watch face image :
watchFace->display = lv_img_create(NULL);
lv_img_set_src(watchFace->display, &watch_carbon_face_asset);
lv_obj_set_style_bg_color(watchFace->display, lv_color_black(), LV_PART_MAIN);
lv_obj_add_event_cb(watchFace->display, &(hide_hour_and_minutes_hand_cb), LV_EVENT_LONG_PRESSED, watchFace);
//We load our other assets :
/*lv_obj_t *smallHandImg = lv_img_create(watchFace->display);
lv_img_set_src(smallHandImg, &watch_casio_small_hand_asset);
lv_obj_set_pos(smallHandImg, 69, 98);
lv_img_set_pivot(smallHandImg, 4, 20);*/
//Battery arc is created here
if(watchFace->batteryIndicator.batteryArc)
{
LV_LOG_ERROR("batteryArc should be NULL here !");
lv_obj_del(watchFace->batteryIndicator.batteryArc);
watchFace->batteryIndicator.batteryArc = NULL;
}
watchFace->batteryIndicator.batteryArc = lv_arc_create(watchFace->display);
lv_obj_remove_style(watchFace->batteryIndicator.batteryArc, NULL, LV_PART_KNOB);
lv_obj_clear_flag(watchFace->batteryIndicator.batteryArc, LV_OBJ_FLAG_CLICKABLE);
lv_obj_set_size(watchFace->batteryIndicator.batteryArc, 60, 60);
lv_obj_align(watchFace->batteryIndicator.batteryArc, LV_ALIGN_CENTER, 0, 44);
lv_obj_set_style_arc_width(watchFace->batteryIndicator.batteryArc, 5, LV_PART_INDICATOR);
lv_obj_set_style_arc_width(watchFace->batteryIndicator.batteryArc, 0, LV_PART_MAIN);
lv_obj_set_style_arc_color(watchFace->batteryIndicator.batteryArc, lv_color_make(228, 233, 236), LV_PART_INDICATOR);
lv_arc_set_value(watchFace->batteryIndicator.batteryArc, 100);
if(watchFace->batteryIndicator.label)
{
LV_LOG_ERROR("battery_label should be NULL here !");
lv_obj_del(watchFace->batteryIndicator.label);
watchFace->batteryIndicator.label = NULL;
}
watchFace->batteryIndicator.label = lv_label_create(watchFace->display);
strcpy(watchFace->batteryIndicator.text, "100 %");
lv_label_set_text_static(watchFace->batteryIndicator.label, watchFace->batteryIndicator.text);
lv_obj_set_style_text_color(watchFace->batteryIndicator.label, lv_color_white(), LV_PART_MAIN);
lv_obj_align_to(watchFace->batteryIndicator.label, watchFace->batteryIndicator.batteryArc, LV_ALIGN_CENTER, 0, -5);
// Battery icon is created here
if(watchFace->batteryIndicator.batteryIcon)
{
LV_LOG_ERROR("batteryIcon should be NULL here !");
lv_obj_del(watchFace->batteryIndicator.batteryIcon);
watchFace->batteryIndicator.batteryIcon = NULL;
}
watchFace->batteryIndicator.batteryIcon = lv_img_create(watchFace->display);
if(watchFace->batteryIndicator.lowBatteryAnimationTimer)
{
LV_LOG_ERROR("battery animation timer should be NULL here !");
lv_timer_del(watchFace->batteryIndicator.lowBatteryAnimationTimer);
watchFace->batteryIndicator.lowBatteryAnimationTimer = NULL;
}
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, -12);
// Bluetooth status icon is created here
if(watchFace->bluetoothIndicator.bluetoothIcon)
{
LV_LOG_ERROR("bluetoothIcon be NULL here !");
lv_obj_del(watchFace->bluetoothIndicator.bluetoothIcon);
watchFace->bluetoothIndicator.bluetoothIcon = NULL;
}
watchFace->bluetoothIndicator.bluetoothIcon = lv_img_create(watchFace->display);
lv_img_set_src(watchFace->bluetoothIndicator.bluetoothIcon, &bluetooth_icon);
lv_img_set_zoom(watchFace->bluetoothIndicator.bluetoothIcon, 128);
lv_obj_add_flag(watchFace->bluetoothIndicator.bluetoothIcon, LV_OBJ_FLAG_HIDDEN);
lv_obj_set_style_img_recolor(watchFace->bluetoothIndicator.bluetoothIcon, lv_palette_main(LV_PALETTE_GREY), LV_PART_MAIN);
lv_obj_align_to(watchFace->bluetoothIndicator.bluetoothIcon, watchFace->batteryIndicator.batteryArc, LV_ALIGN_OUT_LEFT_BOTTOM, -9, 0);
_set_bluetooth_indicator(watchFace);
// StepCounter label is created here
if(watchFace->stepCounter.label)
{
LV_LOG_ERROR("stepCounter should be NULL here !");
lv_obj_del(watchFace->stepCounter.label);
watchFace->stepCounter.label = NULL;
}
watchFace->stepCounter.label = lv_label_create(watchFace->display);
lv_label_set_text_static(watchFace->stepCounter.label, watchFace->stepCounter.text);
lv_obj_set_style_text_color(watchFace->stepCounter.label, lv_color_white(), LV_PART_MAIN);
lv_obj_set_pos(watchFace->stepCounter.label, 50, 111);
if(watchFace->mediumHand24h.handImg)
{
LV_LOG_ERROR("mediumHand24hImg should be NULL here !");
lv_obj_del(watchFace->mediumHand24h.handImg);
watchFace->mediumHand24h.handImg = NULL;
}
watchFace->mediumHand24h.handImg = lv_img_create(watchFace->display);
lv_img_set_src(watchFace->mediumHand24h.handImg, &watch_carbon_medium_hand_asset);
lv_obj_set_pos(watchFace->mediumHand24h.handImg, 115, 51);
lv_img_set_pivot(watchFace->mediumHand24h.handImg, 4, 26);
/*lv_obj_t *mediumHandChronoImg = lv_img_create(watchFace->display);
lv_img_set_src(mediumHandChronoImg, &watch_casio_medium_hand_asset);
lv_obj_set_pos(mediumHandChronoImg, 115, 140);
lv_img_set_pivot(mediumHandChronoImg, 4, 25);*/
//Date window is created here
if(watchFace->dateWindow.dateWindowWidget)
{
LV_LOG_ERROR("dateWindowWidget should be NULL here !");
lv_obj_del(watchFace->dateWindow.dateWindowWidget);
watchFace->dateWindow.dateWindowWidget = NULL;
}
watchFace->dateWindow.dateWindowWidget = lv_label_create(watchFace->display);
lv_label_set_text_static(watchFace->dateWindow.dateWindowWidget, watchFace->dateWindow.dateWindowText);
lv_obj_set_pos(watchFace->dateWindow.dateWindowWidget, 168,111);
lv_obj_set_width(watchFace->dateWindow.dateWindowWidget, 20);
lv_obj_set_style_text_align(watchFace->dateWindow.dateWindowWidget, LV_TEXT_ALIGN_CENTER, LV_PART_MAIN);
lv_obj_set_style_text_color(watchFace->dateWindow.dateWindowWidget, lv_color_white(), LV_PART_MAIN);
if(watchFace->hourHand.handImg)
{
LV_LOG_ERROR("hourHandImg should be NULL here !");
lv_obj_del(watchFace->hourHand.handImg);
watchFace->hourHand.handImg = NULL;
}
watchFace->hourHand.handImg = lv_img_create(watchFace->display);
lv_img_set_src(watchFace->hourHand.handImg, &watch_carbon_hour_hand_asset);
lv_obj_set_pos(watchFace->hourHand.handImg, 113, 57);
lv_img_set_pivot(watchFace->hourHand.handImg, 6, 62);
if(watchFace->minuteHand.handImg)
{
LV_LOG_ERROR("minuteHandImg should be NULL here !");
lv_obj_del(watchFace->minuteHand.handImg);
watchFace->minuteHand.handImg = NULL;
}
watchFace->minuteHand.handImg = lv_img_create(watchFace->display);
lv_img_set_src(watchFace->minuteHand.handImg, &watch_carbon_minute_hand_asset);
lv_obj_set_pos(watchFace->minuteHand.handImg, 113, 14);
lv_img_set_pivot(watchFace->minuteHand.handImg, 6, 105);
if(watchFace->secondHand.handImg)
{
LV_LOG_ERROR("secondHandImg should be NULL here !");
lv_obj_del(watchFace->secondHand.handImg);
watchFace->secondHand.handImg = NULL;
}
watchFace->secondHand.handImg = lv_img_create(watchFace->display);
lv_img_set_src(watchFace->secondHand.handImg, &watch_carbon_second_hand_asset);
lv_obj_set_pos(watchFace->secondHand.handImg, 115, -1);
lv_img_set_pivot(watchFace->secondHand.handImg, 4, 120);
//We set the appropriate angles to each of the hands
update_watch_hands_angles(watchFace, 0);
//Don't forget to make the background image clickable to be able to use gestures on it.
lv_obj_add_flag(watchFace->display, LV_OBJ_FLAG_CLICKABLE);
//We register the event callback to handle gestures
lv_obj_add_event_cb(watchFace->display, &(gesture_event_cb), LV_EVENT_GESTURE, watchFace);
//We register the event callback to handle the cleanup
lv_obj_add_event_cb(watchFace->display, &(cleanup_event_cb), LV_EVENT_DELETE, watchFace);
//We create the timer to run the watch animations
if(watchFace->handAnimationTimer)
{
LV_LOG_ERROR("handAnimationTimer should be NULL here !");
lv_timer_del(watchFace->handAnimationTimer);
watchFace->handAnimationTimer = NULL;
}
watchFace->handAnimationTimer = lv_timer_create(&(hand_timer_anim_cb), /*200*/1, watchFace);
}
void watch_face_set_battery_indicator(WatchFace_t * const watchFace, uint8_t levelInPercent, BatteryState_e batteryState)
{
if(!watchFace)
{
LV_LOG_ERROR("NULL pointer given !");
return;
}
if(!watchFace->display) return;
lv_color_t arc_color = lv_color_make(228, 233, 236);
if(levelInPercent <= 10)
arc_color = lv_color_make(228, 33, 81);
else if(levelInPercent <= 30)
arc_color = lv_color_make(247, 148, 29);
else if(levelInPercent <= 50)
arc_color = lv_color_make(226, 175, 58);
lv_arc_set_value(watchFace->batteryIndicator.batteryArc, levelInPercent);
lv_obj_set_style_arc_color(watchFace->batteryIndicator.batteryArc, arc_color, LV_PART_INDICATOR);
sprintf(watchFace->batteryIndicator.text, "%u %%", levelInPercent);
lv_label_set_text_static(watchFace->batteryIndicator.label, watchFace->batteryIndicator.text);
lv_obj_align_to(watchFace->batteryIndicator.label, watchFace->batteryIndicator.batteryArc, LV_ALIGN_CENTER, 0, -5);
//We save the new battery state only if it's different, this allows to have a trigger when it changes :
if(watchFace->batteryIndicator.batteryState != batteryState)
{
watchFace->batteryIndicator.batteryState = batteryState;
set_battery_state_icon(watchFace);
}
//Finally we check if it's time to show the battery low indicator by enabling it's timer
if(levelInPercent <= 10 && watchFace->batteryIndicator.batteryState == BATTERY_STATE_DISCHARGING)
{
lv_timer_resume(watchFace->batteryIndicator.lowBatteryAnimationTimer);
}
else if(watchFace->batteryIndicator.batteryState == BATTERY_STATE_DISCHARGING)
{
lv_timer_pause(watchFace->batteryIndicator.lowBatteryAnimationTimer);
lv_obj_add_flag(watchFace->batteryIndicator.batteryIcon, LV_OBJ_FLAG_HIDDEN);
}
}
void watch_face_set_bluetooth_indicator(WatchFace_t * const watchFace, BluetoothState_e bluetoothState)
{
if(!watchFace)
{
LV_LOG_ERROR("NULL pointer given !");
return;
}
if(watchFace->bluetoothIndicator.bluetoothState == bluetoothState) return;
watchFace->bluetoothIndicator.bluetoothState = bluetoothState;
if(!watchFace->display) return;
_set_bluetooth_indicator(watchFace);
}
void watch_face_set_step_count(WatchFace_t * const watchFace, uint32_t step_count)
{
if(!watchFace)
{
LV_LOG_ERROR("NULL pointer given !");
return;
}
if(step_count < 1000)
sprintf(watchFace->stepCounter.text, "%u", step_count);
else if(step_count < 9996)
sprintf(watchFace->stepCounter.text, "%.2fk", step_count/1000.0);
else
sprintf(watchFace->stepCounter.text, "%.1fk", step_count/1000.0);
if(!watchFace->display) return;
lv_label_set_text_static(watchFace->stepCounter.label, watchFace->stepCounter.text);
}
void watch_face_destroy(WatchFace_t * const watchFace)
{
if(!watchFace)
{
LV_LOG_ERROR("NULL pointer given !");
return;
}
watchFace->display = NULL;
watchFace->handAnimationTimer = NULL;
watchFace->dateWindow.dateWindowWidget = NULL;
watchFace->hourHand.handImg = NULL;
watchFace->minuteHand.handImg = NULL;
watchFace->secondHand.handImg = NULL;
watchFace->mediumHand24h.handImg = NULL;
watchFace->batteryIndicator.batteryArc = NULL;
watchFace->batteryIndicator.label = NULL;
watchFace->batteryIndicator.batteryIcon = NULL;
watchFace->batteryIndicator.lowBatteryAnimationTimer = NULL;
watchFace->stepCounter.label = NULL;
watchFace->bluetoothIndicator.bluetoothIcon = NULL;
}
void watch_face_force_sync(WatchFace_t *const watchFace)
{
if(!watchFace)
{
LV_LOG_ERROR("NULL pointer given !");
return;
}
if(!watchFace->display) return;
update_watch_hands_angles(watchFace, 0);
}