Did some renaming
This commit is contained in:
parent
fdc8eb4c99
commit
dba1a5182d
191
src/W800_SDK_v1.00.10/app/gfx/find_my_phone_screen.c
Normal file
191
src/W800_SDK_v1.00.10/app/gfx/find_my_phone_screen.c
Normal file
@ -0,0 +1,191 @@
|
||||
#include "find_my_phone_screen.h"
|
||||
#include "menu_screen.h"
|
||||
#include "translation.h"
|
||||
|
||||
static void gesture_event_cb(lv_event_t *e)
|
||||
{
|
||||
FindMyPhoneScreen_t *findMyPhoneScreen = 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 check if we were finding our phone ?
|
||||
if(findMyPhoneScreen->finding_phone)
|
||||
if(findMyPhoneScreen->sendFindMyPhoneBLECommandCb)findMyPhoneScreen->sendFindMyPhoneBLECommandCb(false);
|
||||
// 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)
|
||||
{
|
||||
FindMyPhoneScreen_t *findMyPhoneScreen = e->user_data;
|
||||
find_my_phone_screen_destroy(findMyPhoneScreen);
|
||||
LV_LOG_USER("cleanup");
|
||||
}
|
||||
|
||||
static void button_click_event_cb(lv_event_t *e)
|
||||
{
|
||||
FindMyPhoneScreen_t *findMyPhoneScreen = e->user_data;
|
||||
|
||||
if(!findMyPhoneScreen->finding_phone)
|
||||
{
|
||||
lv_obj_set_style_border_color(findMyPhoneScreen->innerCircle, lv_color_make(238, 17, 133), LV_PART_MAIN);
|
||||
lv_label_set_text_static(findMyPhoneScreen->findMyPhoneButton.label, translation_get_word(TRANSLATION_FOUND_MY_PHONE_BTN));
|
||||
if(findMyPhoneScreen->sendFindMyPhoneBLECommandCb)findMyPhoneScreen->sendFindMyPhoneBLECommandCb(true);
|
||||
findMyPhoneScreen->finding_phone = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
lv_obj_set_style_border_color(findMyPhoneScreen->innerCircle, lv_color_make(67, 160, 71), LV_PART_MAIN);
|
||||
lv_label_set_text_static(findMyPhoneScreen->findMyPhoneButton.label, translation_get_word(TRANSLATION_FIND_MY_PHONE_BTN));
|
||||
if(findMyPhoneScreen->sendFindMyPhoneBLECommandCb)findMyPhoneScreen->sendFindMyPhoneBLECommandCb(false);
|
||||
findMyPhoneScreen->finding_phone = false;
|
||||
}
|
||||
|
||||
LV_LOG_USER("find my phone button clicked");
|
||||
}
|
||||
|
||||
static void _disable_btn_no_ble_connection(FindMyPhoneScreen_t * const findMyPhoneScreen, bool connected)
|
||||
{
|
||||
if(connected)
|
||||
{
|
||||
lv_obj_set_style_border_color(findMyPhoneScreen->innerCircle, lv_color_make(67, 160, 71), LV_PART_MAIN);
|
||||
lv_label_set_text_static(findMyPhoneScreen->findMyPhoneButton.label, translation_get_word(TRANSLATION_FIND_MY_PHONE_BTN));
|
||||
lv_obj_clear_state(findMyPhoneScreen->findMyPhoneButton.button, LV_STATE_DISABLED);
|
||||
}
|
||||
else
|
||||
{
|
||||
lv_obj_set_style_border_color(findMyPhoneScreen->innerCircle, lv_color_make(96, 125, 139), LV_PART_MAIN);
|
||||
lv_label_set_text_static(findMyPhoneScreen->findMyPhoneButton.label, translation_get_word(TRANSLATION_PHONE_NOT_CONNECTED));
|
||||
lv_obj_add_state(findMyPhoneScreen->findMyPhoneButton.button, LV_STATE_DISABLED);
|
||||
}
|
||||
}
|
||||
|
||||
void find_my_phone_screen_init(FindMyPhoneScreen_t * const findMyPhoneScreen)
|
||||
{
|
||||
if(!findMyPhoneScreen)
|
||||
{
|
||||
LV_LOG_ERROR("NULL pointer given !");
|
||||
return;
|
||||
}
|
||||
|
||||
memset(findMyPhoneScreen, 0, sizeof(FindMyPhoneScreen_t));
|
||||
}
|
||||
|
||||
void find_my_phone_screen_register_BLE_command_send_cb(FindMyPhoneScreen_t * const findMyPhoneScreen, SendFindMyPhoneBLECommandCb_t sendFindMyPhoneBLECommandCb)
|
||||
{
|
||||
if(!findMyPhoneScreen)
|
||||
{
|
||||
LV_LOG_ERROR("NULL pointer given !");
|
||||
return;
|
||||
}
|
||||
|
||||
findMyPhoneScreen->sendFindMyPhoneBLECommandCb = sendFindMyPhoneBLECommandCb;
|
||||
}
|
||||
|
||||
void find_my_phone_screen_notify_BLE_connection_state(FindMyPhoneScreen_t * const findMyPhoneScreen, bool connected)
|
||||
{
|
||||
if(!findMyPhoneScreen)
|
||||
{
|
||||
LV_LOG_ERROR("NULL pointer given !");
|
||||
return;
|
||||
}
|
||||
|
||||
if(findMyPhoneScreen->ble_connection_state != connected)
|
||||
{
|
||||
findMyPhoneScreen->ble_connection_state = connected;
|
||||
if(findMyPhoneScreen->display != NULL)
|
||||
_disable_btn_no_ble_connection(findMyPhoneScreen, findMyPhoneScreen->ble_connection_state);
|
||||
}
|
||||
}
|
||||
|
||||
void find_my_phone_screen_create(FindMyPhoneScreen_t * const findMyPhoneScreen)
|
||||
{
|
||||
if(!findMyPhoneScreen)
|
||||
{
|
||||
LV_LOG_ERROR("NULL pointer given !");
|
||||
return;
|
||||
}
|
||||
|
||||
if(findMyPhoneScreen->display)
|
||||
{
|
||||
LV_LOG_ERROR("display should be NULL here !");
|
||||
lv_obj_del(findMyPhoneScreen->display);
|
||||
findMyPhoneScreen->display = NULL;
|
||||
}
|
||||
findMyPhoneScreen->display = lv_obj_create(NULL);
|
||||
lv_obj_set_style_bg_color(findMyPhoneScreen->display, lv_color_make(0xFF,0xFF,0xFF), LV_PART_MAIN);
|
||||
|
||||
if(findMyPhoneScreen->innerCircle)
|
||||
{
|
||||
LV_LOG_ERROR("innerCircle should be NULL here !");
|
||||
lv_obj_del(findMyPhoneScreen->innerCircle);
|
||||
findMyPhoneScreen->innerCircle = NULL;
|
||||
}
|
||||
findMyPhoneScreen->innerCircle = lv_obj_create(findMyPhoneScreen->display);
|
||||
lv_obj_center(findMyPhoneScreen->innerCircle);
|
||||
lv_obj_set_size(findMyPhoneScreen->innerCircle, 240, 240);
|
||||
lv_obj_set_style_bg_color(findMyPhoneScreen->innerCircle, lv_color_make(0xFF,0xFF,0xFF), LV_PART_MAIN);
|
||||
lv_obj_set_style_radius(findMyPhoneScreen->innerCircle, LV_RADIUS_CIRCLE, LV_PART_MAIN);
|
||||
lv_obj_set_style_border_width(findMyPhoneScreen->innerCircle, 15, LV_PART_MAIN);
|
||||
|
||||
if(findMyPhoneScreen->findMyPhoneButton.button)
|
||||
{
|
||||
LV_LOG_ERROR("button should be NULL here !");
|
||||
lv_obj_del(findMyPhoneScreen->findMyPhoneButton.button);
|
||||
findMyPhoneScreen->findMyPhoneButton.button = NULL;
|
||||
}
|
||||
findMyPhoneScreen->findMyPhoneButton.button = lv_btn_create(findMyPhoneScreen->innerCircle);
|
||||
lv_obj_center(findMyPhoneScreen->findMyPhoneButton.button);
|
||||
lv_obj_set_size(findMyPhoneScreen->findMyPhoneButton.button, 155, 155);
|
||||
lv_obj_set_style_radius(findMyPhoneScreen->findMyPhoneButton.button, LV_RADIUS_CIRCLE, LV_PART_MAIN);
|
||||
lv_obj_set_style_shadow_spread(findMyPhoneScreen->findMyPhoneButton.button, 2, LV_PART_MAIN);
|
||||
lv_obj_add_event_cb(findMyPhoneScreen->findMyPhoneButton.button, &(button_click_event_cb), LV_EVENT_CLICKED, findMyPhoneScreen);
|
||||
|
||||
if(findMyPhoneScreen->findMyPhoneButton.label)
|
||||
{
|
||||
LV_LOG_ERROR("label should be NULL here !");
|
||||
lv_obj_del(findMyPhoneScreen->findMyPhoneButton.label);
|
||||
findMyPhoneScreen->findMyPhoneButton.label = NULL;
|
||||
}
|
||||
findMyPhoneScreen->findMyPhoneButton.label = lv_label_create(findMyPhoneScreen->findMyPhoneButton.button);
|
||||
lv_obj_center(findMyPhoneScreen->findMyPhoneButton.label);
|
||||
lv_obj_set_style_text_align(findMyPhoneScreen->findMyPhoneButton.label, LV_TEXT_ALIGN_CENTER, LV_PART_MAIN);
|
||||
lv_obj_set_style_text_font(findMyPhoneScreen->findMyPhoneButton.label, &lv_font_montserrat_28, LV_PART_MAIN);
|
||||
|
||||
_disable_btn_no_ble_connection(findMyPhoneScreen, findMyPhoneScreen->ble_connection_state);
|
||||
|
||||
|
||||
//We register the event callback to handle gestures
|
||||
lv_obj_add_event_cb(findMyPhoneScreen->display, &(gesture_event_cb), LV_EVENT_GESTURE, findMyPhoneScreen);
|
||||
//We register the event callback to handle the cleanup
|
||||
lv_obj_add_event_cb(findMyPhoneScreen->display, &(cleanup_event_cb), LV_EVENT_DELETE, findMyPhoneScreen);
|
||||
}
|
||||
|
||||
void find_my_phone_screen_destroy(FindMyPhoneScreen_t * const findMyPhoneScreen)
|
||||
{
|
||||
if(!findMyPhoneScreen)
|
||||
{
|
||||
LV_LOG_ERROR("NULL pointer given !");
|
||||
return;
|
||||
}
|
||||
|
||||
memset(findMyPhoneScreen, 0, offsetof(FindMyPhoneScreen_t, sendFindMyPhoneBLECommandCb));
|
||||
}
|
36
src/W800_SDK_v1.00.10/app/gfx/find_my_phone_screen.h
Normal file
36
src/W800_SDK_v1.00.10/app/gfx/find_my_phone_screen.h
Normal file
@ -0,0 +1,36 @@
|
||||
#ifndef FIND_MY_PHONE_SCREEN_H
|
||||
#define FIND_MY_PHONE_SCREEN_H
|
||||
|
||||
#include "lvgl.h"
|
||||
|
||||
typedef void (*SendFindMyPhoneBLECommandCb_t)(bool findMyPhone);
|
||||
|
||||
typedef struct FindMyPhoneButton
|
||||
{
|
||||
lv_obj_t *button;
|
||||
lv_obj_t *label;
|
||||
} FindMyPhoneButton_t;
|
||||
|
||||
typedef struct FindMyPhoneScreen
|
||||
{
|
||||
//Can be erased attributes
|
||||
lv_obj_t *display;
|
||||
lv_obj_t *innerCircle;
|
||||
FindMyPhoneButton_t findMyPhoneButton;
|
||||
bool finding_phone;
|
||||
//Should not be erased attributes
|
||||
SendFindMyPhoneBLECommandCb_t sendFindMyPhoneBLECommandCb;
|
||||
bool ble_connection_state;
|
||||
} FindMyPhoneScreen_t;
|
||||
|
||||
void find_my_phone_screen_init(FindMyPhoneScreen_t * const findMyPhoneScreen);
|
||||
|
||||
void find_my_phone_screen_register_BLE_command_send_cb(FindMyPhoneScreen_t * const findMyPhoneScreen, SendFindMyPhoneBLECommandCb_t sendFindMyPhoneBLECommandCb);
|
||||
|
||||
void find_my_phone_screen_notify_BLE_connection_state(FindMyPhoneScreen_t * const findMyPhoneScreen, bool connected);
|
||||
|
||||
void find_my_phone_screen_create(FindMyPhoneScreen_t * const findMyPhoneScreen);
|
||||
|
||||
void find_my_phone_screen_destroy(FindMyPhoneScreen_t * const findMyPhoneScreen);
|
||||
|
||||
#endif //FIND_MY_PHONE_SCREEN_H
|
@ -1,191 +0,0 @@
|
||||
#include "find_phone_screen.h"
|
||||
#include "menu_screen.h"
|
||||
#include "translation.h"
|
||||
|
||||
static void gesture_event_cb(lv_event_t *e)
|
||||
{
|
||||
FindPhoneScreen_t *findPhoneScreen = 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 check if we were finding our phone ?
|
||||
if(findPhoneScreen->finding_phone)
|
||||
if(findPhoneScreen->sendFindPhoneBLECommandCb)findPhoneScreen->sendFindPhoneBLECommandCb(false);
|
||||
// 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)
|
||||
{
|
||||
FindPhoneScreen_t *findPhoneScreen = e->user_data;
|
||||
find_phone_screen_destroy(findPhoneScreen);
|
||||
LV_LOG_USER("cleanup");
|
||||
}
|
||||
|
||||
static void button_click_event_cb(lv_event_t *e)
|
||||
{
|
||||
FindPhoneScreen_t *findPhoneScreen = e->user_data;
|
||||
|
||||
if(!findPhoneScreen->finding_phone)
|
||||
{
|
||||
lv_obj_set_style_border_color(findPhoneScreen->innerCircle, lv_color_make(238, 17, 133), LV_PART_MAIN);
|
||||
lv_label_set_text_static(findPhoneScreen->findPhoneButton.label, translation_get_word(TRANSLATION_FOUND_MY_PHONE_BTN));
|
||||
if(findPhoneScreen->sendFindPhoneBLECommandCb)findPhoneScreen->sendFindPhoneBLECommandCb(true);
|
||||
findPhoneScreen->finding_phone = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
lv_obj_set_style_border_color(findPhoneScreen->innerCircle, lv_color_make(67, 160, 71), LV_PART_MAIN);
|
||||
lv_label_set_text_static(findPhoneScreen->findPhoneButton.label, translation_get_word(TRANSLATION_FIND_MY_PHONE_BTN));
|
||||
if(findPhoneScreen->sendFindPhoneBLECommandCb)findPhoneScreen->sendFindPhoneBLECommandCb(false);
|
||||
findPhoneScreen->finding_phone = false;
|
||||
}
|
||||
|
||||
LV_LOG_USER("find my phone button clicked");
|
||||
}
|
||||
|
||||
static void _disable_btn_no_ble_connection(FindPhoneScreen_t * const findPhoneScreen, bool connected)
|
||||
{
|
||||
if(connected)
|
||||
{
|
||||
lv_obj_set_style_border_color(findPhoneScreen->innerCircle, lv_color_make(67, 160, 71), LV_PART_MAIN);
|
||||
lv_label_set_text_static(findPhoneScreen->findPhoneButton.label, translation_get_word(TRANSLATION_FIND_MY_PHONE_BTN));
|
||||
lv_obj_clear_state(findPhoneScreen->findPhoneButton.button, LV_STATE_DISABLED);
|
||||
}
|
||||
else
|
||||
{
|
||||
lv_obj_set_style_border_color(findPhoneScreen->innerCircle, lv_color_make(96, 125, 139), LV_PART_MAIN);
|
||||
lv_label_set_text_static(findPhoneScreen->findPhoneButton.label, translation_get_word(TRANSLATION_PHONE_NOT_CONNECTED));
|
||||
lv_obj_add_state(findPhoneScreen->findPhoneButton.button, LV_STATE_DISABLED);
|
||||
}
|
||||
}
|
||||
|
||||
void find_phone_screen_init(FindPhoneScreen_t * const findPhoneScreen)
|
||||
{
|
||||
if(!findPhoneScreen)
|
||||
{
|
||||
LV_LOG_ERROR("NULL pointer given !");
|
||||
return;
|
||||
}
|
||||
|
||||
memset(findPhoneScreen, 0, sizeof(FindPhoneScreen_t));
|
||||
}
|
||||
|
||||
void find_phone_screen_register_BLE_command_send_cb(FindPhoneScreen_t * const findPhoneScreen, SendFindPhoneBLECommandCb_t sendFindPhoneBLECommandCb)
|
||||
{
|
||||
if(!findPhoneScreen)
|
||||
{
|
||||
LV_LOG_ERROR("NULL pointer given !");
|
||||
return;
|
||||
}
|
||||
|
||||
findPhoneScreen->sendFindPhoneBLECommandCb = sendFindPhoneBLECommandCb;
|
||||
}
|
||||
|
||||
void find_phone_screen_notify_BLE_connection_state(FindPhoneScreen_t * const findPhoneScreen, bool connected)
|
||||
{
|
||||
if(!findPhoneScreen)
|
||||
{
|
||||
LV_LOG_ERROR("NULL pointer given !");
|
||||
return;
|
||||
}
|
||||
|
||||
if(findPhoneScreen->ble_connection_state != connected)
|
||||
{
|
||||
findPhoneScreen->ble_connection_state = connected;
|
||||
if(findPhoneScreen->display != NULL)
|
||||
_disable_btn_no_ble_connection(findPhoneScreen, findPhoneScreen->ble_connection_state);
|
||||
}
|
||||
}
|
||||
|
||||
void find_phone_screen_create(FindPhoneScreen_t * const findPhoneScreen)
|
||||
{
|
||||
if(!findPhoneScreen)
|
||||
{
|
||||
LV_LOG_ERROR("NULL pointer given !");
|
||||
return;
|
||||
}
|
||||
|
||||
if(findPhoneScreen->display)
|
||||
{
|
||||
LV_LOG_ERROR("display should be NULL here !");
|
||||
lv_obj_del(findPhoneScreen->display);
|
||||
findPhoneScreen->display = NULL;
|
||||
}
|
||||
findPhoneScreen->display = lv_obj_create(NULL);
|
||||
lv_obj_set_style_bg_color(findPhoneScreen->display, lv_color_make(0xFF,0xFF,0xFF), LV_PART_MAIN);
|
||||
|
||||
if(findPhoneScreen->innerCircle)
|
||||
{
|
||||
LV_LOG_ERROR("innerCircle should be NULL here !");
|
||||
lv_obj_del(findPhoneScreen->innerCircle);
|
||||
findPhoneScreen->innerCircle = NULL;
|
||||
}
|
||||
findPhoneScreen->innerCircle = lv_obj_create(findPhoneScreen->display);
|
||||
lv_obj_center(findPhoneScreen->innerCircle);
|
||||
lv_obj_set_size(findPhoneScreen->innerCircle, 240, 240);
|
||||
lv_obj_set_style_bg_color(findPhoneScreen->innerCircle, lv_color_make(0xFF,0xFF,0xFF), LV_PART_MAIN);
|
||||
lv_obj_set_style_radius(findPhoneScreen->innerCircle, LV_RADIUS_CIRCLE, LV_PART_MAIN);
|
||||
lv_obj_set_style_border_width(findPhoneScreen->innerCircle, 15, LV_PART_MAIN);
|
||||
|
||||
if(findPhoneScreen->findPhoneButton.button)
|
||||
{
|
||||
LV_LOG_ERROR("button should be NULL here !");
|
||||
lv_obj_del(findPhoneScreen->findPhoneButton.button);
|
||||
findPhoneScreen->findPhoneButton.button = NULL;
|
||||
}
|
||||
findPhoneScreen->findPhoneButton.button = lv_btn_create(findPhoneScreen->innerCircle);
|
||||
lv_obj_center(findPhoneScreen->findPhoneButton.button);
|
||||
lv_obj_set_size(findPhoneScreen->findPhoneButton.button, 155, 155);
|
||||
lv_obj_set_style_radius(findPhoneScreen->findPhoneButton.button, LV_RADIUS_CIRCLE, LV_PART_MAIN);
|
||||
lv_obj_set_style_shadow_spread(findPhoneScreen->findPhoneButton.button, 2, LV_PART_MAIN);
|
||||
lv_obj_add_event_cb(findPhoneScreen->findPhoneButton.button, &(button_click_event_cb), LV_EVENT_CLICKED, findPhoneScreen);
|
||||
|
||||
if(findPhoneScreen->findPhoneButton.label)
|
||||
{
|
||||
LV_LOG_ERROR("label should be NULL here !");
|
||||
lv_obj_del(findPhoneScreen->findPhoneButton.label);
|
||||
findPhoneScreen->findPhoneButton.label = NULL;
|
||||
}
|
||||
findPhoneScreen->findPhoneButton.label = lv_label_create(findPhoneScreen->findPhoneButton.button);
|
||||
lv_obj_center(findPhoneScreen->findPhoneButton.label);
|
||||
lv_obj_set_style_text_align(findPhoneScreen->findPhoneButton.label, LV_TEXT_ALIGN_CENTER, LV_PART_MAIN);
|
||||
lv_obj_set_style_text_font(findPhoneScreen->findPhoneButton.label, &lv_font_montserrat_28, LV_PART_MAIN);
|
||||
|
||||
_disable_btn_no_ble_connection(findPhoneScreen, findPhoneScreen->ble_connection_state);
|
||||
|
||||
|
||||
//We register the event callback to handle gestures
|
||||
lv_obj_add_event_cb(findPhoneScreen->display, &(gesture_event_cb), LV_EVENT_GESTURE, findPhoneScreen);
|
||||
//We register the event callback to handle the cleanup
|
||||
lv_obj_add_event_cb(findPhoneScreen->display, &(cleanup_event_cb), LV_EVENT_DELETE, findPhoneScreen);
|
||||
}
|
||||
|
||||
void find_phone_screen_destroy(FindPhoneScreen_t * const findPhoneScreen)
|
||||
{
|
||||
if(!findPhoneScreen)
|
||||
{
|
||||
LV_LOG_ERROR("NULL pointer given !");
|
||||
return;
|
||||
}
|
||||
|
||||
memset(findPhoneScreen, 0, offsetof(FindPhoneScreen_t, sendFindPhoneBLECommandCb));
|
||||
}
|
@ -1,36 +0,0 @@
|
||||
#ifndef FIND_PHONE_SCREEN_H
|
||||
#define FIND_PHONE_SCREEN_H
|
||||
|
||||
#include "lvgl.h"
|
||||
|
||||
typedef void (*SendFindPhoneBLECommandCb_t)(bool findPhone);
|
||||
|
||||
typedef struct FindPhoneButton
|
||||
{
|
||||
lv_obj_t *button;
|
||||
lv_obj_t *label;
|
||||
} FindPhoneButton_t;
|
||||
|
||||
typedef struct FindPhoneScreen
|
||||
{
|
||||
//Can be erased attributes
|
||||
lv_obj_t *display;
|
||||
lv_obj_t *innerCircle;
|
||||
FindPhoneButton_t findPhoneButton;
|
||||
bool finding_phone;
|
||||
//Should not be erased attributes
|
||||
SendFindPhoneBLECommandCb_t sendFindPhoneBLECommandCb;
|
||||
bool ble_connection_state;
|
||||
} FindPhoneScreen_t;
|
||||
|
||||
void find_phone_screen_init(FindPhoneScreen_t * const findPhoneScreen);
|
||||
|
||||
void find_phone_screen_register_BLE_command_send_cb(FindPhoneScreen_t * const findPhoneScreen, SendFindPhoneBLECommandCb_t sendFindPhoneBLECommandCb);
|
||||
|
||||
void find_phone_screen_notify_BLE_connection_state(FindPhoneScreen_t * const findPhoneScreen, bool connected);
|
||||
|
||||
void find_phone_screen_create(FindPhoneScreen_t * const findPhoneScreen);
|
||||
|
||||
void find_phone_screen_destroy(FindPhoneScreen_t * const findPhoneScreen);
|
||||
|
||||
#endif //FIND_PHONE_SCREEN_H
|
@ -10,7 +10,7 @@
|
||||
#include "watch_face.h"
|
||||
#include "menu_screen.h"
|
||||
#include "compass_screen.h"
|
||||
#include "find_phone_screen.h"
|
||||
#include "find_my_phone_screen.h"
|
||||
#include "settings_screen.h"
|
||||
#include "watch_peripherals.h"
|
||||
#include "watch_settings.h"
|
||||
@ -34,7 +34,7 @@ static void _perform_deferred_display_wake_up(uint8_t deferred_time_in_ms);
|
||||
WatchFace_t watchFace;
|
||||
MenuScreen_t menuScreen;
|
||||
CompassScreen_t compassScreen;
|
||||
FindPhoneScreen_t findPhoneScreen;
|
||||
FindMyPhoneScreen_t findMyPhoneScreen;
|
||||
SettingsScreen_t settingsScreen;
|
||||
|
||||
static struct
|
||||
@ -238,7 +238,7 @@ static void setBLEEnabledCb(bool *enabled, SettingMode_e mode)
|
||||
else
|
||||
{
|
||||
watch_face_set_bluetooth_indicator(&watchFace, BLUETOOTH_STATE_OFF);
|
||||
find_phone_screen_notify_BLE_connection_state(&findPhoneScreen, false);
|
||||
find_my_phone_screen_notify_BLE_connection_state(&findMyPhoneScreen, false);
|
||||
}
|
||||
|
||||
}
|
||||
@ -398,11 +398,11 @@ static void ble_service_state_change_cb(ble_service_state_e ble_service_state)
|
||||
{
|
||||
case BLE_SERVICE_MODE_CONNECTED:
|
||||
watch_face_set_bluetooth_indicator(&watchFace, BLUETOOTH_STATE_CONNECTED);
|
||||
find_phone_screen_notify_BLE_connection_state(&findPhoneScreen, true);
|
||||
find_my_phone_screen_notify_BLE_connection_state(&findMyPhoneScreen, true);
|
||||
break;
|
||||
case BLE_SERVICE_MODE_ADVERTISING:
|
||||
watch_face_set_bluetooth_indicator(&watchFace, BLUETOOTH_STATE_ON);
|
||||
find_phone_screen_notify_BLE_connection_state(&findPhoneScreen, false);
|
||||
find_my_phone_screen_notify_BLE_connection_state(&findMyPhoneScreen, false);
|
||||
break;
|
||||
case BLE_SERVICE_MODE_SUBSCRIBED:
|
||||
_is_ble_device_subscribed = true;
|
||||
@ -456,9 +456,9 @@ static void scan_result_cb(void)
|
||||
tls_mem_free(buffer);
|
||||
}
|
||||
|
||||
static void sendFindPhoneBLECommandCb(bool findPhone)
|
||||
static void sendFindMyPhoneBLECommandCb(bool findMyPhone)
|
||||
{
|
||||
gadget_bridge_send_find_phone(findPhone);
|
||||
gadget_bridge_send_find_phone(findMyPhone);
|
||||
}
|
||||
|
||||
extern LCDConfig_t LCDConfig;
|
||||
@ -519,8 +519,8 @@ void gfx_task(void *param)
|
||||
menu_screen_init(&menuScreen);
|
||||
compass_screen_init(&compassScreen);
|
||||
|
||||
find_phone_screen_init(&findPhoneScreen);
|
||||
find_phone_screen_register_BLE_command_send_cb(&findPhoneScreen, &(sendFindPhoneBLECommandCb));
|
||||
find_my_phone_screen_init(&findMyPhoneScreen);
|
||||
find_my_phone_screen_register_BLE_command_send_cb(&findMyPhoneScreen, &(sendFindMyPhoneBLECommandCb));
|
||||
|
||||
settings_screen_init(&settingsScreen);
|
||||
settings_screen_register_API_interface(&settingsScreen, &settingsScreenAPIInterface);
|
||||
|
@ -4,7 +4,7 @@
|
||||
#include "settings_screen.h"
|
||||
#include "watch_face.h"
|
||||
#include "compass_screen.h"
|
||||
#include "find_phone_screen.h"
|
||||
#include "find_my_phone_screen.h"
|
||||
#include "translation.h"
|
||||
|
||||
#define array_size(array) (sizeof(array)/sizeof(array[0]))
|
||||
@ -32,9 +32,9 @@ static void menu_item_cb(lv_event_t *e)
|
||||
break;
|
||||
case 3:
|
||||
{
|
||||
extern FindPhoneScreen_t findPhoneScreen;
|
||||
find_phone_screen_create(&findPhoneScreen);
|
||||
lv_scr_load_anim(findPhoneScreen.display, LV_SCR_LOAD_ANIM_MOVE_LEFT, 400, 0, true);
|
||||
extern FindMyPhoneScreen_t findMyPhoneScreen;
|
||||
find_my_phone_screen_create(&findMyPhoneScreen);
|
||||
lv_scr_load_anim(findMyPhoneScreen.display, LV_SCR_LOAD_ANIM_MOVE_LEFT, 400, 0, true);
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
|
Loading…
Reference in New Issue
Block a user