summaryrefslogtreecommitdiff
path: root/app/src/display
diff options
context:
space:
mode:
authorPete Johanson <peter@peterjohanson.com>2020-12-10 17:59:51 -0500
committerPete Johanson <peter@peterjohanson.com>2020-12-14 12:41:25 -0500
commit5ec1eefb2cbefdbd944d470c3797a93d9b805d3c (patch)
treebcf0cfbb2ee381da7a3fd948851eb6098e199af6 /app/src/display
parent0d4476d148c71a24398145aafe8fb8adf9df1809 (diff)
refactor(display): Update to new LVGL v7.x API.
PR: #467
Diffstat (limited to 'app/src/display')
-rw-r--r--app/src/display/widgets/Kconfig10
-rw-r--r--app/src/display/widgets/battery_status.c17
-rw-r--r--app/src/display/widgets/output_status.c17
3 files changed, 25 insertions, 19 deletions
diff --git a/app/src/display/widgets/Kconfig b/app/src/display/widgets/Kconfig
index 1dbffb5..000e0dc 100644
--- a/app/src/display/widgets/Kconfig
+++ b/app/src/display/widgets/Kconfig
@@ -5,14 +5,14 @@ config ZMK_WIDGET_BATTERY_STATUS
bool "Widget for battery charge information, using small icons"
depends on BT
default y if BT
- select LVGL_OBJ_LABEL
- select LVGL_BUILD_IN_FONT_ROBOTO_16
+ select LVGL_USE_LABEL
+ select LVGL_FONT_MONTSERRAT_16
config ZMK_WIDGET_OUTPUT_STATUS
bool "Widget for keyboard output status icons"
depends on BT
default y if BT
- select LVGL_OBJ_LABEL
- select LVGL_BUILD_IN_FONT_ROBOTO_16
-
+ select LVGL_USE_LABEL
+ select LVGL_FONT_MONTSERRAT_16
+
endmenu
diff --git a/app/src/display/widgets/battery_status.c b/app/src/display/widgets/battery_status.c
index 748b5a3..b412da2 100644
--- a/app/src/display/widgets/battery_status.c
+++ b/app/src/display/widgets/battery_status.c
@@ -18,16 +18,19 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL);
static sys_slist_t widgets = SYS_SLIST_STATIC_INIT(&widgets);
static lv_style_t label_style;
+static bool style_initialized = false;
+
void battery_status_init() {
- if (label_style.text.font != NULL) {
+ if (style_initialized) {
return;
}
- lv_style_copy(&label_style, &lv_style_plain);
- label_style.text.color = LV_COLOR_BLACK;
- label_style.text.font = &lv_font_roboto_16;
- label_style.text.letter_space = 1;
- label_style.text.line_space = 1;
+ style_initialized = true;
+ lv_style_init(&label_style);
+ lv_style_set_text_color(&label_style, LV_STATE_DEFAULT, LV_COLOR_BLACK);
+ lv_style_set_text_font(&label_style, LV_STATE_DEFAULT, &lv_font_montserrat_16);
+ lv_style_set_text_letter_space(&label_style, LV_STATE_DEFAULT, 1);
+ lv_style_set_text_line_space(&label_style, LV_STATE_DEFAULT, 1);
}
void set_battery_symbol(lv_obj_t *label) {
@@ -57,7 +60,7 @@ void set_battery_symbol(lv_obj_t *label) {
int zmk_widget_battery_status_init(struct zmk_widget_battery_status *widget, lv_obj_t *parent) {
battery_status_init();
widget->obj = lv_label_create(parent, NULL);
- lv_label_set_style(widget->obj, LV_LABEL_STYLE_MAIN, &label_style);
+ lv_obj_add_style(widget->obj, LV_LABEL_PART_MAIN, &label_style);
lv_obj_set_size(widget->obj, 40, 15);
set_battery_symbol(widget->obj);
diff --git a/app/src/display/widgets/output_status.c b/app/src/display/widgets/output_status.c
index 3ee2335..143c778 100644
--- a/app/src/display/widgets/output_status.c
+++ b/app/src/display/widgets/output_status.c
@@ -20,16 +20,19 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL);
static sys_slist_t widgets = SYS_SLIST_STATIC_INIT(&widgets);
static lv_style_t label_style;
+static bool style_initialized = false;
+
void output_status_init() {
- if (label_style.text.font != NULL) {
+ if (style_initialized) {
return;
}
- lv_style_copy(&label_style, &lv_style_plain);
- label_style.text.color = LV_COLOR_BLACK;
- label_style.text.font = &lv_font_roboto_16;
- label_style.text.letter_space = 1;
- label_style.text.line_space = 1;
+ style_initialized = true;
+ lv_style_init(&label_style);
+ lv_style_set_text_color(&label_style, LV_STATE_DEFAULT, LV_COLOR_BLACK);
+ lv_style_set_text_font(&label_style, LV_STATE_DEFAULT, &lv_font_montserrat_16);
+ lv_style_set_text_letter_space(&label_style, LV_STATE_DEFAULT, 1);
+ lv_style_set_text_line_space(&label_style, LV_STATE_DEFAULT, 1);
}
void set_status_symbol(lv_obj_t *label) {
@@ -62,7 +65,7 @@ void set_status_symbol(lv_obj_t *label) {
int zmk_widget_output_status_init(struct zmk_widget_output_status *widget, lv_obj_t *parent) {
output_status_init();
widget->obj = lv_label_create(parent, NULL);
- lv_label_set_style(widget->obj, LV_LABEL_STYLE_MAIN, &label_style);
+ lv_obj_add_style(widget->obj, LV_LABEL_PART_MAIN, &label_style);
lv_obj_set_size(widget->obj, 40, 15);
set_status_symbol(widget->obj);