Skip to content

Commit

Permalink
ui: watchface: Add new watchface options. Digital and minimal.
Browse files Browse the repository at this point in the history
  • Loading branch information
jakkra committed Aug 10, 2023
1 parent 693ae2b commit 7c5b8a7
Show file tree
Hide file tree
Showing 16 changed files with 1,680 additions and 6 deletions.
Binary file added .github/watchfaces.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ I have received quite some requests regarding building or getting the ZSWatch, t
- [Enclosure/Casing](#enclosurecasing)
- [Software Features](#software-features)
* [Larger not yet implemented SW Features and TODOs](#larger-not-yet-implemented-sw-features-and-todos)
- [Watchfaces](#watchfaces)
- [Android phone communication](#android-phone-communication)
* [Pairing](#pairing)
- [PCB](#pcb)
Expand Down Expand Up @@ -102,6 +103,19 @@ Built in debugger. Will be an option without debugger also (requires licence).
### Features and progress
There are almost endless of posiblities for features that could be implemented, see [here for full progress](https://github.com/users/jakkra/projects/1) and my current ideas.

## Watchfaces
Alternative watch faces can be chosen by selecting the appropriate Kconfig.

`CONFIG_WATCHFACE_ANALOG`

`CONFIG_WATCHFACE_DIGITAL`

`CONFIG_WATCHFACE_MINIMAL`

<p float="center">
<img src=".github/watchfaces.png" width="65%"/>
</p>

## Android phone communication
Fortunately there is a great Android app called [GadgetBridge](https://codeberg.org/Freeyourgadget) which handles everything needed on the phone side, such as notifications management, music control and so much more... The ZSWatch right now pretends to be one of the supported Smart Watches in Gadgetbridge, following the same API as it does. In future there may be a point adding native support, we'll see.

Expand Down
5 changes: 4 additions & 1 deletion app/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,14 @@ endif()
FILE(GLOB img_sources src/images/*.c)
target_sources(app PRIVATE ${img_sources})

FILE(GLOB font_sources src/images/fonts/*.c)
target_sources(app PRIVATE ${font_sources})

FILE(GLOB ui_sources src/ui/*.c)
target_sources(app PRIVATE ${ui_sources})

zephyr_sources_ifdef(CONFIG_WATCHFACE_ANALOG src/ui/watchfaces/zsw_watchface_analog_ui.c)
zephyr_sources_ifdef(CONFIG_WATCHFACE_DIITAL src/ui/watchfaces/zsw_watchface_digital_ui.c)
zephyr_sources_ifdef(CONFIG_WATCHFACE_DIGITAL src/ui/watchfaces/zsw_watchface_digital_ui.c)

FILE(GLOB events_sources src/events/*.c)
target_sources(app PRIVATE ${events_sources})
Expand Down
6 changes: 6 additions & 0 deletions app/prj.conf
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,12 @@ CONFIG_REGULATOR_FIXED=y

CONFIG_LVGL=y
CONFIG_LV_MEM_CUSTOM=y
CONFIG_LV_FONT_MONTSERRAT_10=y
CONFIG_LV_FONT_MONTSERRAT_12=y
CONFIG_LV_FONT_MONTSERRAT_14=y
CONFIG_LV_FONT_MONTSERRAT_16=y
CONFIG_LV_FONT_MONTSERRAT_18=y
CONFIG_LV_FONT_MONTSERRAT_20=y

# Comment out to show FPS counter
#CONFIG_LV_USE_PERF_MONITOR=y
Expand Down Expand Up @@ -181,3 +185,5 @@ CONFIG_ZBUS_OBSERVER_NAME=y
CONFIG_DISPLAY_FAST_WAKEUP=y
# Disable this to exclude flash intensive apps mean for demo only
CONFIG_DEMO_BUILD=n

CONFIG_WATCHFACE_DIGITAL=y
143 changes: 143 additions & 0 deletions app/src/images/charging.c

Large diffs are not rendered by default.

242 changes: 242 additions & 0 deletions app/src/images/fonts/ui_font_aliean_25.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,242 @@
/*******************************************************************************
* Size: 25 px
* Bpp: 2
* Opts: --bpp 2 --size 25 --font /home/jakkra/SquareLine/assets/AlienInvader-PKnPm.ttf -o /home/jakkra/SquareLine/assets/ui_font_aliean_25.c --format lvgl --symbols 0123456789: --no-compress --no-prefilter
******************************************************************************/

#if defined(LV_LVGL_H_INCLUDE_SIMPLE)
#include "lvgl.h"
#else
#include "lvgl/lvgl.h"
#endif

#ifndef UI_FONT_ALIEAN_25
#define UI_FONT_ALIEAN_25 1
#endif

#if UI_FONT_ALIEAN_25

/*-----------------
* BITMAPS
*----------------*/

/*Store the image of the glyphs*/
static LV_ATTRIBUTE_LARGE_CONST const uint8_t glyph_bitmap[] = {
/* U+0030 "0" */
0xb, 0xff, 0xff, 0xff, 0xd0, 0x3f, 0xff, 0xff,
0xff, 0xf8, 0xbf, 0xff, 0xff, 0xff, 0xfc, 0xff,
0xff, 0xff, 0xff, 0xfd, 0xff, 0xff, 0xff, 0xff,
0xfe, 0xff, 0xc0, 0x0, 0x7, 0xfe, 0xff, 0xc0,
0x0, 0x7, 0xfe, 0xff, 0xc0, 0x0, 0x7, 0xfe,
0xff, 0xc0, 0x0, 0x7, 0xfe, 0xff, 0xc0, 0x0,
0x7, 0xfe, 0xff, 0xc0, 0x0, 0x7, 0xfe, 0xff,
0xc0, 0x0, 0x7, 0xfe, 0xff, 0xff, 0xff, 0xff,
0xfe, 0xff, 0xff, 0xff, 0xff, 0xfd, 0xbf, 0xff,
0xff, 0xff, 0xfc, 0x3f, 0xff, 0xff, 0xff, 0xf8,
0xb, 0xff, 0xff, 0xff, 0xd0,

/* U+0031 "1" */
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xc0,

/* U+0032 "2" */
0xff, 0xff, 0xff, 0xff, 0xd0, 0xff, 0xff, 0xff,
0xff, 0xf8, 0xff, 0xff, 0xff, 0xff, 0xfc, 0xff,
0xff, 0xff, 0xff, 0xfd, 0xff, 0xff, 0xff, 0xff,
0xfe, 0x0, 0x0, 0x0, 0x7, 0xfe, 0x6, 0xff,
0xff, 0xff, 0xfe, 0x3f, 0xff, 0xff, 0xff, 0xfd,
0xbf, 0xff, 0xff, 0xff, 0xfc, 0xff, 0xff, 0xff,
0xff, 0xf8, 0xff, 0xff, 0xff, 0xff, 0xd0, 0xff,
0xc0, 0x0, 0x0, 0x0, 0xff, 0xff, 0xff, 0xff,
0xfd, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xff, 0xff,
0xff, 0xff, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xfe,
0xff, 0xff, 0xff, 0xff, 0xfe,

/* U+0033 "3" */
0xff, 0xff, 0xff, 0xff, 0xd0, 0xff, 0xff, 0xff,
0xff, 0xf8, 0xff, 0xff, 0xff, 0xff, 0xfc, 0xff,
0xff, 0xff, 0xff, 0xfd, 0xff, 0xff, 0xff, 0xff,
0xfe, 0x0, 0x0, 0x0, 0x7, 0xfe, 0xff, 0xff,
0xff, 0xff, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xfe,
0xff, 0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xff,
0xff, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x0,
0x0, 0x0, 0x7, 0xfe, 0xff, 0xff, 0xff, 0xff,
0xfe, 0xff, 0xff, 0xff, 0xff, 0xfd, 0xff, 0xff,
0xff, 0xff, 0xfc, 0xff, 0xff, 0xff, 0xff, 0xf8,
0xff, 0xff, 0xff, 0xff, 0xd0,

/* U+0034 "4" */
0xff, 0xc0, 0x0, 0x7, 0xfe, 0xff, 0xc0, 0x0,
0x7, 0xfe, 0xff, 0xc0, 0x0, 0x7, 0xfe, 0xff,
0xc0, 0x0, 0x7, 0xfe, 0xff, 0xc0, 0x0, 0x7,
0xfe, 0xff, 0xc0, 0x0, 0x7, 0xfe, 0xff, 0xff,
0xff, 0xff, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xfe,
0xbf, 0xff, 0xff, 0xff, 0xfe, 0x3f, 0xff, 0xff,
0xff, 0xfe, 0xb, 0xff, 0xff, 0xff, 0xfe, 0x0,
0x0, 0x0, 0x7, 0xfe, 0x0, 0x0, 0x0, 0x7,
0xfe, 0x0, 0x0, 0x0, 0x7, 0xfe, 0x0, 0x0,
0x0, 0x7, 0xfe, 0x0, 0x0, 0x0, 0x7, 0xfe,
0x0, 0x0, 0x0, 0x7, 0xfe,

/* U+0035 "5" */
0xff, 0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xff,
0xff, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xff,
0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xff, 0xff,
0xfd, 0xff, 0xc0, 0x0, 0x0, 0x0, 0xff, 0xff,
0xff, 0xff, 0x80, 0xff, 0xff, 0xff, 0xff, 0xf4,
0xbf, 0xff, 0xff, 0xff, 0xfc, 0x3f, 0xff, 0xff,
0xff, 0xfd, 0xb, 0xff, 0xff, 0xff, 0xfd, 0x0,
0x0, 0x0, 0x7, 0xfe, 0xff, 0xff, 0xff, 0xff,
0xfe, 0xff, 0xff, 0xff, 0xff, 0xfd, 0xff, 0xff,
0xff, 0xff, 0xfc, 0xff, 0xff, 0xff, 0xff, 0xf8,
0xff, 0xff, 0xff, 0xff, 0xd0,

/* U+0036 "6" */
0xb, 0xff, 0xff, 0xff, 0xf4, 0x3f, 0xff, 0xff,
0xff, 0xf4, 0xbf, 0xff, 0xff, 0xff, 0xf4, 0xff,
0xff, 0xff, 0xff, 0xf4, 0xff, 0xff, 0xff, 0xff,
0xf4, 0xff, 0xc0, 0x0, 0x0, 0x0, 0xff, 0xff,
0xff, 0xff, 0x80, 0xff, 0xff, 0xff, 0xff, 0xf4,
0xff, 0xff, 0xff, 0xff, 0xfc, 0xff, 0xff, 0xff,
0xff, 0xfd, 0xff, 0xff, 0xff, 0xff, 0xfd, 0xff,
0xc0, 0x0, 0x7, 0xfe, 0xff, 0xff, 0xff, 0xff,
0xfe, 0xff, 0xff, 0xff, 0xff, 0xfd, 0xbf, 0xff,
0xff, 0xff, 0xfc, 0x3f, 0xff, 0xff, 0xff, 0xf8,
0xb, 0xff, 0xff, 0xff, 0xd0,

/* U+0037 "7" */
0xff, 0xff, 0xff, 0xff, 0xfd, 0xff, 0xff, 0xff,
0xff, 0xfc, 0xff, 0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, 0xff,
0xff, 0xff, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xfe,
0xbf, 0xff, 0xff, 0xff, 0xfe, 0x3f, 0xff, 0xff,
0xff, 0xfe, 0xb, 0xff, 0xff, 0xff, 0xfe, 0x0,
0x0, 0x0, 0x7, 0xfe, 0x2f, 0xff, 0xff, 0xff,
0xfe, 0x3f, 0xff, 0xff, 0xff, 0xfd, 0x3f, 0xff,
0xff, 0xff, 0xfc, 0x3f, 0xff, 0xff, 0xff, 0xf8,
0x3f, 0xff, 0xff, 0xff, 0xd0,

/* U+003A ":" */
0x2e, 0x2f, 0xef, 0xff, 0xfe, 0x3e, 0x0, 0x2,
0xe2, 0xfe, 0xff, 0xff, 0xe3, 0xe0
};


/*---------------------
* GLYPH DESCRIPTION
*--------------------*/

static const lv_font_fmt_txt_glyph_dsc_t glyph_dsc[] = {
{.bitmap_index = 0, .adv_w = 0, .box_w = 0, .box_h = 0, .ofs_x = 0, .ofs_y = 0} /* id = 0 reserved */,
{.bitmap_index = 0, .adv_w = 332, .box_w = 20, .box_h = 17, .ofs_x = 0, .ofs_y = 0},
{.bitmap_index = 85, .adv_w = 98, .box_w = 5, .box_h = 17, .ofs_x = 0, .ofs_y = 0},
{.bitmap_index = 107, .adv_w = 332, .box_w = 20, .box_h = 17, .ofs_x = 0, .ofs_y = 0},
{.bitmap_index = 192, .adv_w = 332, .box_w = 20, .box_h = 17, .ofs_x = 0, .ofs_y = 0},
{.bitmap_index = 277, .adv_w = 332, .box_w = 20, .box_h = 17, .ofs_x = 0, .ofs_y = 0},
{.bitmap_index = 362, .adv_w = 332, .box_w = 20, .box_h = 17, .ofs_x = 0, .ofs_y = 0},
{.bitmap_index = 447, .adv_w = 332, .box_w = 20, .box_h = 17, .ofs_x = 0, .ofs_y = 0},
{.bitmap_index = 532, .adv_w = 332, .box_w = 20, .box_h = 17, .ofs_x = 0, .ofs_y = 0},
{.bitmap_index = 617, .adv_w = 332, .box_w = 20, .box_h = 17, .ofs_x = 0, .ofs_y = 0},
{.bitmap_index = 702, .adv_w = 332, .box_w = 20, .box_h = 17, .ofs_x = 0, .ofs_y = 0},
{.bitmap_index = 787, .adv_w = 98, .box_w = 5, .box_h = 11, .ofs_x = 0, .ofs_y = 0}
};

/*---------------------
* CHARACTER MAPPING
*--------------------*/



/*Collect the unicode lists and glyph_id offsets*/
static const lv_font_fmt_txt_cmap_t cmaps[] =
{
{
.range_start = 48, .range_length = 11, .glyph_id_start = 1,
.unicode_list = NULL, .glyph_id_ofs_list = NULL, .list_length = 0, .type = LV_FONT_FMT_TXT_CMAP_FORMAT0_TINY
}
};



/*--------------------
* ALL CUSTOM DATA
*--------------------*/

#if LV_VERSION_CHECK(8, 0, 0)
/*Store all the custom data of the font*/
static lv_font_fmt_txt_glyph_cache_t cache;
static const lv_font_fmt_txt_dsc_t font_dsc = {
#else
static lv_font_fmt_txt_dsc_t font_dsc = {
#endif
.glyph_bitmap = glyph_bitmap,
.glyph_dsc = glyph_dsc,
.cmaps = cmaps,
.kern_dsc = NULL,
.kern_scale = 0,
.cmap_num = 1,
.bpp = 2,
.kern_classes = 0,
.bitmap_format = 0,
#if LV_VERSION_CHECK(8, 0, 0)
.cache = &cache
#endif
};


/*-----------------
* PUBLIC FONT
*----------------*/

/*Initialize a public general font descriptor*/
#if LV_VERSION_CHECK(8, 0, 0)
const lv_font_t ui_font_aliean_25 = {
#else
lv_font_t ui_font_aliean_25 = {
#endif
.get_glyph_dsc = lv_font_get_glyph_dsc_fmt_txt, /*Function pointer to get glyph's data*/
.get_glyph_bitmap = lv_font_get_bitmap_fmt_txt, /*Function pointer to get glyph's bitmap*/
.line_height = 17, /*The maximum line height required by the font*/
.base_line = 0, /*Baseline measured from the bottom of the line*/
#if !(LVGL_VERSION_MAJOR == 6 && LVGL_VERSION_MINOR == 0)
.subpx = LV_FONT_SUBPX_NONE,
#endif
#if LV_VERSION_CHECK(7, 4, 0) || LVGL_VERSION_MAJOR >= 8
.underline_position = -3,
.underline_thickness = 2,
#endif
.dsc = &font_dsc /*The custom font data. Will be accessed by `get_glyph_bitmap/dsc` */
};



#endif /*#if UI_FONT_ALIEAN_25*/

Loading

0 comments on commit 7c5b8a7

Please sign in to comment.