Skip to content

Commit

Permalink
Replace gadget bridge on iOS
Browse files Browse the repository at this point in the history
  • Loading branch information
ldab committed Aug 6, 2024
1 parent f7347e1 commit 72fe1b4
Show file tree
Hide file tree
Showing 7 changed files with 201 additions and 5 deletions.
1 change: 1 addition & 0 deletions app/src/applications/notification/ui_export/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ SET(SOURCES
images/ui_img_call_png.c
images/ui_img_mail_png.c
images/ui_img_gadget_png.c
images/ui_img_apple.c
images/ui_img_youtube_png.c
images/ui_img_homeassistant_png.c
images/ui_img_whatsapp_png.c
Expand Down
174 changes: 174 additions & 0 deletions app/src/applications/notification/ui_export/images/ui_img_apple.c

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions app/src/ble/ble_ancs.c
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,11 @@ static int gattp_init(void)
return bt_gattp_init(&gattp);
}

bool ble_ancs_present(void)
{
return atomic_test_bit(&discovery_flags, DISCOVERY_ANCS_SUCCEEDED);
}

int ble_ancs_init(void)
{
int err = bt_ancs_client_init(&ancs_c);
Expand Down
12 changes: 11 additions & 1 deletion app/src/ble/ble_ancs.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,14 @@
#include <zephyr/kernel.h>
#include "ble/ble_comm.h"

int ble_ancs_init(void);
/**
* @brief Init Apple Notification Center Service, ANCS
*/
int ble_ancs_init(void);

/**
* @brief Check if ANCS service is present on the device connected to the watch
*
* @return true if ANCS is present
*/
bool ble_ancs_present(void);
4 changes: 2 additions & 2 deletions app/src/images/binaries/README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# External SPI Flash resource storage
Normally try to put all resources in external flash as they quickly fill up the internal flash. This is however
only possible on ZSWatch v4 and later which have external flash on QSPI (fast).
only possible on ZSWatch v3 and later. It can be disabled by `CONFIG_STORE_IMAGES_EXTERNAL_FLASH=n` configuration.
To be compatible with both with and without QSPI flash the code need to use the following macros for declaring images:

Use `ZSW_LV_IMG_DECLARE(file_name)` instead of LVGL's `LV_IMG_DECLARE(file_name)`.<br>
Use `ZSW_LV_IMG_USE(file_name)` instead of `lv_img_set_src(img, &file_name)`.

Those two macros will automatically pick the file from internal flash if no QSPI flash and from QSPI flash if ZSWatch version supports it.
Those two macros will automatically pick the file from internal flash if ZSWatch version supports it.
You do however need to convert the image both to `.c` and `.bin` to use this approach right now and place the `.c` in `app/src/images/` folder and the .`bin` in `app/src/images/binaries/lvgl_lfs`

If the resource is big and always shall be in external flash just do `lv_img_set_src(img, "/lvgl_lfs/filename.bin")`
Expand Down
Binary file added app/src/images/binaries/S/ui_img_apple.bin
Binary file not shown.
10 changes: 8 additions & 2 deletions app/src/ui/utils/zsw_ui_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#include <lvgl.h>
#include "utils/zsw_ui_utils.h"
#include "ble/ble_ancs.h"
#include "managers/zsw_notification_manager.h"
#include <lvgl.h>

#if CONFIG_WATCHFACE_BACKGROUND_SPACE
ZSW_LV_IMG_DECLARE(space_blur_bg);
Expand All @@ -44,6 +45,7 @@ LV_IMG_DECLARE(unknown);

ZSW_LV_IMG_DECLARE(ui_img_call_png);
ZSW_LV_IMG_DECLARE(ui_img_gadget_png);
ZSW_LV_IMG_DECLARE(ui_img_apple);
ZSW_LV_IMG_DECLARE(ui_img_mail_png);
ZSW_LV_IMG_DECLARE(ui_img_whatsapp_png);
ZSW_LV_IMG_DECLARE(ui_img_trash_png);
Expand Down Expand Up @@ -333,7 +335,11 @@ const void *zsw_ui_utils_icon_from_notification(zsw_notification_src_t src)
case NOTIFICATION_SRC_CALENDAR:
return ZSW_LV_IMG_USE(google_calendar_icon);
default:
return ZSW_LV_IMG_USE(ui_img_gadget_png);
if (ble_ancs_present()) {
return ZSW_LV_IMG_USE(ui_img_apple);
} else {
return ZSW_LV_IMG_USE(ui_img_gadget_png);
}
}
}

Expand Down

0 comments on commit 72fe1b4

Please sign in to comment.