fix(boards): Initial CiZ v2 display code clean up.
This commit is contained in:
parent
8af4bfa723
commit
ac95ef0442
9 changed files with 71 additions and 357 deletions
|
@ -59,9 +59,10 @@ lv_obj_t *zmk_display_status_screen() {
|
|||
#endif
|
||||
|
||||
#if IS_ENABLED(CONFIG_CUSTOM_WIDGET_LAYER_STATUS)
|
||||
//lv_style_set_pad_inner(&layerstyle, LV_STATE_DEFAULT, 12);
|
||||
//lv_obj_add_style(&layer_status_widget, LV_WIDGET_PART_MAIN, &layerstyle);
|
||||
zmk_widget_layer_status_init(&layer_status_widget, screen);
|
||||
lv_obj_set_style_local_text_font(zmk_widget_layer_status_obj(&layer_status_widget),
|
||||
LV_LABEL_PART_MAIN, LV_STATE_DEFAULT,
|
||||
lv_theme_get_font_small());
|
||||
lv_obj_align(zmk_widget_layer_status_obj(&layer_status_widget), NULL, LV_ALIGN_IN_BOTTOM_MID, 0,
|
||||
-5);
|
||||
#endif
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/*
|
||||
*
|
||||
* Copyright (c) 2021 Darryl deHaan
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
*
|
||||
* Copyright (c) 2021 Darryl deHaan
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include <kernel.h>
|
||||
#include <bluetooth/services/bas.h>
|
||||
|
@ -28,8 +28,6 @@ struct battery_status_state {
|
|||
#endif
|
||||
};
|
||||
|
||||
static lv_style_t label_style;
|
||||
|
||||
LV_IMG_DECLARE(batt_100);
|
||||
LV_IMG_DECLARE(batt_100_chg);
|
||||
LV_IMG_DECLARE(batt_75);
|
||||
|
@ -43,78 +41,24 @@ LV_IMG_DECLARE(batt_5_chg);
|
|||
LV_IMG_DECLARE(batt_0);
|
||||
LV_IMG_DECLARE(batt_0_chg);
|
||||
|
||||
//static bool style_initialized = false;
|
||||
|
||||
void battery_status_init() {
|
||||
|
||||
// if (style_initialized) {
|
||||
// return;
|
||||
// }
|
||||
|
||||
//style_initialized = true;
|
||||
lv_style_init(&label_style);
|
||||
lv_style_set_text_font(&label_style, LV_STATE_DEFAULT, &lv_font_montserrat_26);
|
||||
lv_style_set_text_letter_space(&label_style, LV_STATE_DEFAULT, 1);
|
||||
lv_style_set_text_line_space(&label_style, LV_STATE_DEFAULT, 1);
|
||||
lv_style_set_text_color(&label_style, LV_STATE_DEFAULT, LV_COLOR_BLACK);
|
||||
lv_style_set_bg_color(&label_style, LV_STATE_DEFAULT, LV_COLOR_WHITE);
|
||||
|
||||
//lv_obj_t * batt_full_chg_icon = lv_img_create(lv_scr_act(), NULL);
|
||||
//lv_img_set_src(batt_full_chg_icon, &batt_full_chg);
|
||||
}
|
||||
|
||||
//K_MUTEX_DEFINE(battery_status_mutex);
|
||||
|
||||
static void set_battery_symbol(lv_obj_t *icon, struct battery_status_state state) {
|
||||
//void set_battery_symbol(lv_obj_t *icon) {
|
||||
|
||||
//k_mutex_lock(&battery_status_mutex, K_FOREVER);
|
||||
|
||||
uint8_t level = state.level;
|
||||
|
||||
#if IS_ENABLED(CONFIG_USB_DEVICE_STACK)
|
||||
if (level > 95) {
|
||||
if (state.usb_present) {
|
||||
lv_img_set_src(icon, &batt_100_chg);
|
||||
}else{
|
||||
lv_img_set_src(icon, &batt_100);
|
||||
}
|
||||
lv_img_set_src(icon, state.usb_present ? &batt_100_chg : &batt_100);
|
||||
} else if (level > 74) {
|
||||
if (state.usb_present) {
|
||||
lv_img_set_src(icon, &batt_75_chg);
|
||||
}else{
|
||||
lv_img_set_src(icon, &batt_75);
|
||||
}
|
||||
lv_img_set_src(icon, state.usb_present ? &batt_75_chg : &batt_75);
|
||||
} else if (level > 49) {
|
||||
if (state.usb_present) {
|
||||
lv_img_set_src(icon, &batt_50_chg);
|
||||
}else{
|
||||
lv_img_set_src(icon, &batt_50);
|
||||
}
|
||||
lv_img_set_src(icon, state.usb_present ? &batt_50_chg : &batt_50);
|
||||
} else if (level > 24) {
|
||||
if (state.usb_present) {
|
||||
lv_img_set_src(icon, &batt_25_chg);
|
||||
}else{
|
||||
lv_img_set_src(icon, &batt_25);
|
||||
}
|
||||
lv_img_set_src(icon, state.usb_present ? &batt_25_chg : &batt_25);
|
||||
} else if (level > 5) {
|
||||
if (state.usb_present) {
|
||||
lv_img_set_src(icon, &batt_5_chg);
|
||||
}else{
|
||||
lv_img_set_src(icon, &batt_5);
|
||||
}
|
||||
lv_img_set_src(icon, state.usb_present ? &batt_5_chg : &batt_5);
|
||||
} else {
|
||||
if (state.usb_present) {
|
||||
lv_img_set_src(icon, &batt_0_chg);
|
||||
}else{
|
||||
lv_img_set_src(icon, &batt_0);
|
||||
}
|
||||
lv_img_set_src(icon, state.usb_present ? &batt_0_chg : &batt_0);
|
||||
}
|
||||
|
||||
#endif /* IS_ENABLED(CONFIG_USB_DEVICE_STACK) */
|
||||
|
||||
//k_mutex_unlock(&battery_status_mutex);
|
||||
|
||||
}
|
||||
|
||||
void battery_status_update_cb(struct battery_status_state state) {
|
||||
|
@ -139,18 +83,9 @@ ZMK_SUBSCRIPTION(widget_battery_status, zmk_battery_state_changed);
|
|||
ZMK_SUBSCRIPTION(widget_battery_status, zmk_usb_conn_state_changed);
|
||||
#endif /* IS_ENABLED(CONFIG_USB_DEVICE_STACK) */
|
||||
|
||||
|
||||
|
||||
int zmk_widget_battery_status_init(struct zmk_widget_battery_status *widget, lv_obj_t *parent) {
|
||||
battery_status_init();
|
||||
|
||||
widget->obj = lv_img_create(parent, NULL);
|
||||
|
||||
lv_obj_add_style(widget->obj, LV_LABEL_PART_MAIN, &label_style);
|
||||
|
||||
|
||||
//set_battery_symbol(widget->obj);
|
||||
|
||||
sys_slist_append(&widgets, &widget->node);
|
||||
widget_battery_status_init();
|
||||
|
||||
|
@ -160,29 +95,3 @@ int zmk_widget_battery_status_init(struct zmk_widget_battery_status *widget, lv_
|
|||
lv_obj_t *zmk_widget_battery_status_obj(struct zmk_widget_battery_status *widget) {
|
||||
return widget->obj;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
K_WORK_DEFINE(battery_status_update_work, battery_status_update_cb);
|
||||
|
||||
int battery_status_listener(const zmk_event_t *eh) {
|
||||
k_mutex_lock(&battery_status_mutex, K_FOREVER);
|
||||
|
||||
battery_status_state.level = bt_bas_get_battery_level();
|
||||
|
||||
#if IS_ENABLED(CONFIG_USB)
|
||||
battery_status_state.usb_present = zmk_usb_is_powered();
|
||||
#endif IS_ENABLED(CONFIG_USB)
|
||||
|
||||
k_mutex_unlock(&battery_status_mutex);
|
||||
|
||||
k_work_submit_to_queue(zmk_display_work_q(), &battery_status_update_work);
|
||||
return ZMK_EV_EVENT_BUBBLE;
|
||||
}
|
||||
|
||||
ZMK_LISTENER(widget_battery_status, battery_status_listener)
|
||||
ZMK_SUBSCRIPTION(widget_battery_status, zmk_battery_state_changed);
|
||||
#if IS_ENABLED(CONFIG_USB)
|
||||
ZMK_SUBSCRIPTION(widget_battery_status, zmk_usb_conn_state_changed);
|
||||
#endif IS_ENABLED(CONFIG_USB)
|
||||
*/
|
|
@ -1,9 +1,9 @@
|
|||
/*
|
||||
*
|
||||
* Copyright (c) 2021 Darryl deHaan
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
*
|
||||
* Copyright (c) 2021 Darryl deHaan
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/*
|
||||
*
|
||||
* Copyright (c) 2021 Darryl deHaan
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
*
|
||||
* Copyright (c) 2021 Darryl deHaan
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include <kernel.h>
|
||||
#include <logging/log.h>
|
||||
|
@ -17,37 +17,16 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL);
|
|||
#include <zmk/keymap.h>
|
||||
|
||||
static sys_slist_t widgets = SYS_SLIST_STATIC_INIT(&widgets);
|
||||
static lv_style_t label_style;
|
||||
|
||||
static bool style_initialized = false;
|
||||
|
||||
K_MUTEX_DEFINE(layer_status_mutex);
|
||||
|
||||
struct layer_status_state {
|
||||
uint8_t index;
|
||||
const char *label;
|
||||
};
|
||||
|
||||
void layer_status_init() {
|
||||
if (style_initialized) {
|
||||
return;
|
||||
}
|
||||
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);
|
||||
|
||||
}
|
||||
|
||||
static void set_layer_symbol(lv_obj_t *label, struct layer_status_state state) {
|
||||
|
||||
//k_mutex_lock(&layer_status_mutex, K_FOREVER);
|
||||
const char *layer_label = state.label;
|
||||
uint8_t active_layer_index = state.index;
|
||||
//k_mutex_unlock(&layer_status_mutex);
|
||||
|
||||
|
||||
if (layer_label == NULL) {
|
||||
char text[6] = {};
|
||||
|
||||
|
@ -59,7 +38,6 @@ static void set_layer_symbol(lv_obj_t *label, struct layer_status_state state) {
|
|||
}
|
||||
}
|
||||
|
||||
//void layer_status_update_cb(struct k_work *work) {
|
||||
static void layer_status_update_cb(struct layer_status_state state) {
|
||||
struct zmk_widget_layer_status *widget;
|
||||
SYS_SLIST_FOR_EACH_CONTAINER(&widgets, widget, node) { set_layer_symbol(widget->obj, state); }
|
||||
|
@ -75,14 +53,9 @@ ZMK_DISPLAY_WIDGET_LISTENER(widget_layer_status, struct layer_status_state, laye
|
|||
|
||||
ZMK_SUBSCRIPTION(widget_layer_status, zmk_layer_state_changed);
|
||||
|
||||
|
||||
|
||||
int zmk_widget_layer_status_init(struct zmk_widget_layer_status *widget, lv_obj_t *parent) {
|
||||
layer_status_init();
|
||||
widget->obj = lv_label_create(parent, NULL);
|
||||
|
||||
lv_obj_add_style(widget->obj, LV_LABEL_PART_MAIN, &label_style);
|
||||
|
||||
sys_slist_append(&widgets, &widget->node);
|
||||
|
||||
widget_layer_status_init();
|
||||
|
@ -91,29 +64,4 @@ int zmk_widget_layer_status_init(struct zmk_widget_layer_status *widget, lv_obj_
|
|||
|
||||
lv_obj_t *zmk_widget_layer_status_obj(struct zmk_widget_layer_status *widget) {
|
||||
return widget->obj;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
static void update_state() {
|
||||
k_mutex_lock(&layer_status_mutex, K_FOREVER);
|
||||
layer_status_state.index = zmk_keymap_highest_layer_active();
|
||||
layer_status_state.label = zmk_keymap_layer_label(layer_status_state.index);
|
||||
LOG_DBG("Layer changed to %i", layer_status_state.index);
|
||||
|
||||
k_mutex_unlock(&layer_status_mutex);
|
||||
}
|
||||
|
||||
|
||||
K_WORK_DEFINE(layer_status_update_work, layer_status_update_cb);
|
||||
|
||||
int layer_status_listener(const zmk_event_t *eh) {
|
||||
update_state();;
|
||||
|
||||
k_work_submit_to_queue(zmk_display_work_q(), &layer_status_update_work);
|
||||
return 0;
|
||||
}
|
||||
*/
|
||||
}
|
|
@ -1,9 +1,9 @@
|
|||
/*
|
||||
*
|
||||
* Copyright (c) 2021 Darryl deHaan
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
*
|
||||
* Copyright (c) 2021 Darryl deHaan
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/*
|
||||
*
|
||||
* Copyright (c) 2021 Darryl deHaan
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
*
|
||||
* Copyright (c) 2021 Darryl deHaan
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include <kernel.h>
|
||||
#include <bluetooth/services/bas.h>
|
||||
|
@ -37,32 +37,12 @@ LV_IMG_DECLARE(bluetooth_advertising_5);
|
|||
LV_IMG_DECLARE(USB_connected);
|
||||
|
||||
static sys_slist_t widgets = SYS_SLIST_STATIC_INIT(&widgets);
|
||||
static lv_style_t label_style;
|
||||
|
||||
static bool style_initialized = false;
|
||||
|
||||
//K_MUTEX_DEFINE(output_status_mutex);
|
||||
|
||||
void output_status_init() {
|
||||
if (style_initialized) {
|
||||
return;
|
||||
}
|
||||
|
||||
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_26);
|
||||
lv_style_set_text_letter_space(&label_style, LV_STATE_DEFAULT, 1);
|
||||
lv_style_set_text_line_space(&label_style, LV_STATE_DEFAULT, 1);
|
||||
}
|
||||
|
||||
struct output_status_state {
|
||||
//k_mutex_lock(&output_status_mutex, K_FOREVER);
|
||||
enum zmk_endpoint selected_endpoint;
|
||||
bool active_profile_connected;
|
||||
bool active_profile_bonded;
|
||||
uint8_t active_profile_index;
|
||||
//k_mutex_unlock(&output_status_mutex);
|
||||
};
|
||||
|
||||
static struct output_status_state get_state(const zmk_event_t *_eh) {
|
||||
|
@ -75,14 +55,6 @@ static struct output_status_state get_state(const zmk_event_t *_eh) {
|
|||
}
|
||||
|
||||
static void set_status_symbol(lv_obj_t *icon, struct output_status_state state) {
|
||||
|
||||
/*k_mutex_lock(&output_status_mutex, K_FOREVER);
|
||||
enum zmk_endpoint selected_endpoint = output_status_state.selected_endpoint;
|
||||
bool active_profile_connected = output_status_state.active_profile_connected;
|
||||
bool active_profie_bonded = output_status_state.active_profile_bonded;
|
||||
uint8_t active_profile_index = output_status_state.active_profile_index;
|
||||
k_mutex_unlock(&output_status_mutex); */
|
||||
|
||||
switch (state.selected_endpoint) {
|
||||
case ZMK_ENDPOINT_USB:
|
||||
lv_img_set_src(icon, &USB_connected);
|
||||
|
@ -90,14 +62,10 @@ static void set_status_symbol(lv_obj_t *icon, struct output_status_state state)
|
|||
case ZMK_ENDPOINT_BLE:
|
||||
if (state.active_profile_bonded) {
|
||||
if (state.active_profile_connected) {
|
||||
//sprintf(text, LV_SYMBOL_BLUETOOTH "%i " LV_SYMBOL_OK, active_profile_index);
|
||||
// sprintf(text, LV_SYMBOL_BLUETOOTH "%i " LV_SYMBOL_OK, active_profile_index);
|
||||
switch (state.active_profile_index) {
|
||||
case 0:
|
||||
//#if CONFIG_BOARD_CORNEISH_ZEN_RIGHT
|
||||
// lv_img_set_src(icon, &bluetooth_connected_right);
|
||||
//#else
|
||||
lv_img_set_src(icon, &bluetooth_connected_1);
|
||||
//#endif
|
||||
break;
|
||||
case 1:
|
||||
lv_img_set_src(icon, &bluetooth_connected_2);
|
||||
|
@ -117,34 +85,27 @@ static void set_status_symbol(lv_obj_t *icon, struct output_status_state state)
|
|||
}
|
||||
} else {
|
||||
switch (state.active_profile_index) {
|
||||
case 0:
|
||||
lv_img_set_src(icon, &bluetooth_advertising_1);
|
||||
break;
|
||||
case 1:
|
||||
lv_img_set_src(icon, &bluetooth_advertising_2);
|
||||
break;
|
||||
case 2:
|
||||
lv_img_set_src(icon, &bluetooth_advertising_3);
|
||||
break;
|
||||
case 3:
|
||||
lv_img_set_src(icon, &bluetooth_advertising_4);
|
||||
break;
|
||||
case 4:
|
||||
lv_img_set_src(icon, &bluetooth_advertising_5);
|
||||
break;
|
||||
}
|
||||
case 0:
|
||||
lv_img_set_src(icon, &bluetooth_advertising_1);
|
||||
break;
|
||||
case 1:
|
||||
lv_img_set_src(icon, &bluetooth_advertising_2);
|
||||
break;
|
||||
case 2:
|
||||
lv_img_set_src(icon, &bluetooth_advertising_3);
|
||||
break;
|
||||
case 3:
|
||||
lv_img_set_src(icon, &bluetooth_advertising_4);
|
||||
break;
|
||||
case 4:
|
||||
lv_img_set_src(icon, &bluetooth_advertising_5);
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
//lv_label_set_text(label, text);
|
||||
}
|
||||
|
||||
/*
|
||||
void output_status_update_cb(struct k_work *work) {
|
||||
struct zmk_widget_output_status *widget;
|
||||
SYS_SLIST_FOR_EACH_CONTAINER(&widgets, widget, node) { set_status_symbol(widget->obj); }
|
||||
} */
|
||||
static void output_status_update_cb(struct output_status_state state) {
|
||||
struct zmk_widget_output_status *widget;
|
||||
SYS_SLIST_FOR_EACH_CONTAINER(&widgets, widget, node) { set_status_symbol(widget->obj, state); }
|
||||
|
@ -162,8 +123,6 @@ ZMK_SUBSCRIPTION(widget_output_status, zmk_ble_active_profile_changed);
|
|||
#endif
|
||||
|
||||
int zmk_widget_output_status_init(struct zmk_widget_output_status *widget, lv_obj_t *parent) {
|
||||
|
||||
output_status_init();
|
||||
widget->obj = lv_img_create(parent, NULL);
|
||||
|
||||
lv_obj_set_size(widget->obj, 40, 15);
|
||||
|
@ -177,38 +136,3 @@ int zmk_widget_output_status_init(struct zmk_widget_output_status *widget, lv_ob
|
|||
lv_obj_t *zmk_widget_output_status_obj(struct zmk_widget_output_status *widget) {
|
||||
return widget->obj;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
|
||||
static void update_state() {
|
||||
k_mutex_lock(&output_status_mutex, K_FOREVER);
|
||||
output_status_state.selected_endpoint = zmk_endpoints_selected();
|
||||
output_status_state.active_profile_connected = zmk_ble_active_profile_is_connected();
|
||||
output_status_state.active_profile_bonded = !zmk_ble_active_profile_is_open();
|
||||
output_status_state.active_profile_index = zmk_ble_active_profile_index();
|
||||
k_mutex_unlock(&output_status_mutex);
|
||||
}
|
||||
|
||||
|
||||
K_WORK_DEFINE(output_status_update_work, output_status_update_cb);
|
||||
|
||||
int output_status_listener(const zmk_event_t *eh) {
|
||||
|
||||
|
||||
// Be sure we have widgets initialized before doing any work,
|
||||
// since the status event can fire before display code inits.
|
||||
if (!style_initialized) {
|
||||
return ZMK_EV_EVENT_BUBBLE;
|
||||
}
|
||||
|
||||
//update_state();
|
||||
|
||||
k_work_submit_to_queue(zmk_display_work_q(), &output_status_update_work);
|
||||
return ZMK_EV_EVENT_BUBBLE;
|
||||
}
|
||||
*/
|
|
@ -1,9 +1,9 @@
|
|||
/*
|
||||
*
|
||||
* Copyright (c) 2021 Darryl deHaan
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
*
|
||||
* Copyright (c) 2021 Darryl deHaan
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/*
|
||||
*
|
||||
* Copyright (c) 2021 Darryl deHaan
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
*
|
||||
* Copyright (c) 2021 Darryl deHaan
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include <kernel.h>
|
||||
#include <bluetooth/services/bas.h>
|
||||
|
@ -21,31 +21,20 @@ LV_IMG_DECLARE(bluetooth_connected_right);
|
|||
LV_IMG_DECLARE(bluetooth_disconnected_right);
|
||||
|
||||
static sys_slist_t widgets = SYS_SLIST_STATIC_INIT(&widgets);
|
||||
static lv_style_t label_style;
|
||||
|
||||
static bool style_initialized = false;
|
||||
|
||||
struct peripheral_status_state {
|
||||
bool connected;
|
||||
};
|
||||
|
||||
//K_MUTEX_DEFINE(output_status_mutex);
|
||||
|
||||
static struct peripheral_status_state get_state(const zmk_event_t *_eh) {
|
||||
return (struct peripheral_status_state){.connected = zmk_split_bt_peripheral_is_connected()};
|
||||
}
|
||||
|
||||
static void set_status_symbol(lv_obj_t *icon, struct peripheral_status_state state) {
|
||||
|
||||
if (state.connected) {
|
||||
LOG_WRN("peripheral connected");
|
||||
lv_img_set_src(icon, &bluetooth_connected_right);
|
||||
}else{
|
||||
LOG_WRN("peripheral disconnected");
|
||||
lv_img_set_src(icon, &bluetooth_disconnected_right);
|
||||
}
|
||||
|
||||
LOG_DBG("halves connected? %s", state.connected ? "true" : "false");
|
||||
|
||||
lv_img_set_src(icon,
|
||||
state.connected ? &bluetooth_connected_right : &bluetooth_disconnected_right);
|
||||
}
|
||||
|
||||
static void output_status_update_cb(struct peripheral_status_state state) {
|
||||
|
@ -57,29 +46,8 @@ ZMK_DISPLAY_WIDGET_LISTENER(widget_peripheral_status, struct peripheral_status_s
|
|||
output_status_update_cb, get_state)
|
||||
ZMK_SUBSCRIPTION(widget_peripheral_status, zmk_split_peripheral_status_changed);
|
||||
|
||||
void output_status_init() {
|
||||
if (style_initialized) {
|
||||
return;
|
||||
}
|
||||
|
||||
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_26);
|
||||
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 output_status_update_cb(struct k_work *work) {
|
||||
struct zmk_widget_output_status *widget;
|
||||
SYS_SLIST_FOR_EACH_CONTAINER(&widgets, widget, node) { set_status_symbol(widget->obj); }
|
||||
} */
|
||||
|
||||
int zmk_widget_peripheral_status_init(struct zmk_widget_peripheral_status *widget,
|
||||
lv_obj_t *parent) {
|
||||
output_status_init();
|
||||
|
||||
widget->obj = lv_img_create(parent, NULL);
|
||||
|
||||
sys_slist_append(&widgets, &widget->node);
|
||||
|
@ -88,42 +56,6 @@ int zmk_widget_peripheral_status_init(struct zmk_widget_peripheral_status *widge
|
|||
return 0;
|
||||
}
|
||||
|
||||
|
||||
lv_obj_t *zmk_widget_peripheral_status_obj(struct zmk_widget_peripheral_status *widget) {
|
||||
return widget->obj;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
|
||||
static void update_state() {
|
||||
k_mutex_lock(&output_status_mutex, K_FOREVER);
|
||||
output_status_state.selected_endpoint = zmk_endpoints_selected();
|
||||
output_status_state.active_profile_connected = zmk_ble_active_profile_is_connected();
|
||||
output_status_state.active_profile_bonded = !zmk_ble_active_profile_is_open();
|
||||
output_status_state.active_profile_index = zmk_ble_active_profile_index();
|
||||
k_mutex_unlock(&output_status_mutex);
|
||||
}
|
||||
|
||||
|
||||
K_WORK_DEFINE(output_status_update_work, output_status_update_cb);
|
||||
|
||||
int output_status_listener(const zmk_event_t *eh) {
|
||||
|
||||
|
||||
// Be sure we have widgets initialized before doing any work,
|
||||
// since the status event can fire before display code inits.
|
||||
if (!style_initialized) {
|
||||
return ZMK_EV_EVENT_BUBBLE;
|
||||
}
|
||||
|
||||
//update_state();
|
||||
|
||||
k_work_submit_to_queue(zmk_display_work_q(), &output_status_update_work);
|
||||
return ZMK_EV_EVENT_BUBBLE;
|
||||
}
|
||||
*/
|
|
@ -1,9 +1,9 @@
|
|||
/*
|
||||
*
|
||||
* Copyright (c) 2021 Darryl deHaan
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
*
|
||||
* Copyright (c) 2021 Darryl deHaan
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue