Skip to content

Commit

Permalink
Revert "Adding batter/connection widgets zmkfirmware#3"
Browse files Browse the repository at this point in the history
This reverts commit 3066b46.
  • Loading branch information
AakashDabas committed Jul 2, 2023
1 parent 3066b46 commit e3e5843
Showing 1 changed file with 19 additions and 13 deletions.
32 changes: 19 additions & 13 deletions app/boards/shields/nice_view/widgets/peripheral_status.c
Original file line number Diff line number Diff line change
Expand Up @@ -413,11 +413,16 @@ const void *rocket_rush_images[] = {

static sys_slist_t widgets = SYS_SLIST_STATIC_INIT(&widgets);

void set_img_src(void *var, int32_t val) {
lv_obj_t *img = (lv_obj_t *)var;
lv_img_set_src(img, images[val]);
}

struct peripheral_status_state {
bool connected;
}currentState;
};

static void draw_top(lv_obj_t *widget) {
static void draw_top(lv_obj_t *widget, lv_color_t cbuf[], struct status_state state) {
lv_obj_t *canvas = lv_obj_get_child(widget, 0);

lv_draw_label_dsc_t label_dsc;
Expand All @@ -429,20 +434,25 @@ static void draw_top(lv_obj_t *widget) {
lv_canvas_draw_rect(canvas, 0, 0, CANVAS_SIZE, CANVAS_SIZE, &rect_black_dsc);

// Draw battery
draw_battery(canvas, currentState);
draw_battery(canvas, state);

// Draw output status
lv_canvas_draw_text(canvas, 0, 0, CANVAS_SIZE, &label_dsc,
currentState.connected ? LV_SYMBOL_WIFI : LV_SYMBOL_CLOSE);
state.connected ? LV_SYMBOL_WIFI : LV_SYMBOL_CLOSE);

// Rotate canvas
rotate_canvas(canvas, cbuf);
}

static void set_battery_status(struct zmk_widget_status *widget,
struct battery_status_state state) {
#if IS_ENABLED(CONFIG_USB_DEVICE_STACK)
currentState.charging = state.usb_present;
widget->state.charging = state.usb_present;
#endif /* IS_ENABLED(CONFIG_USB_DEVICE_STACK) */

currentState.battery = state.level;
widget->state.battery = state.level;

draw_top(widget->obj, widget->cbuf, widget->state);
}

static void battery_status_update_cb(struct battery_status_state state) {
Expand Down Expand Up @@ -473,7 +483,9 @@ static struct peripheral_status_state get_state(const zmk_event_t *_eh) {

static void set_connection_status(struct zmk_widget_status *widget,
struct peripheral_status_state state) {
currentState.connected = state.connected;
widget->state.connected = state.connected;

draw_top(widget->obj, widget->cbuf, widget->state);
}

static void output_status_update_cb(struct peripheral_status_state state) {
Expand All @@ -485,12 +497,6 @@ 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 set_img_src(void *var, int32_t val) {
lv_obj_t *img = (lv_obj_t *)var;
lv_img_set_src(img, images[val]);
draw_top(img);
}

int zmk_widget_status_init(struct zmk_widget_status *widget, lv_obj_t *parent) {
widget->obj = lv_img_create(parent);
// lv_obj_set_size(widget->obj, 160, 68);
Expand Down

0 comments on commit e3e5843

Please sign in to comment.