From e3e5dab0fc4fd14f8d952963b7e693d2e70277c9 Mon Sep 17 00:00:00 2001 From: CTCaer Date: Tue, 15 Sep 2020 20:14:56 +0300 Subject: [PATCH] nyx: Add USB Charger info --- nyx/nyx_gui/frontend/gui_info.c | 37 ++++++++++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 3 deletions(-) diff --git a/nyx/nyx_gui/frontend/gui_info.c b/nyx/nyx_gui/frontend/gui_info.c index 21f8b06..af91d6c 100644 --- a/nyx/nyx_gui/frontend/gui_info.c +++ b/nyx/nyx_gui/frontend/gui_info.c @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include @@ -1612,7 +1613,11 @@ static lv_res_t _create_window_battery_status(lv_obj_t *btn) "Fast charge current limit:\n" "Charge voltage limit:\n" "Charge status:\n" - "Temperature status:" + "Temperature status:\n\n" + "#00DDFF USB-PD IC Info:#\n" + "Connection status:\n" + "Input Wattage Limit:\n" + "USB-PD Profiles:" ); lv_obj_set_width(lb_desc2, lv_obj_get_width(desc2)); lv_obj_align(desc2, val, LV_ALIGN_OUT_RIGHT_MID, LV_DPI / 2, 0); @@ -1625,8 +1630,9 @@ static lv_res_t _create_window_battery_status(lv_obj_t *btn) bq24193_get_property(BQ24193_InputVoltageLimit, &value); s_printf(txt_buf, "\n%d mV\n", value); - bq24193_get_property(BQ24193_InputCurrentLimit, &value); - s_printf(txt_buf + strlen(txt_buf), "%d mA\n", value); + int iinlim = 0; + bq24193_get_property(BQ24193_InputCurrentLimit, &iinlim); + s_printf(txt_buf + strlen(txt_buf), "%d mA\n", iinlim); bq24193_get_property(BQ24193_SystemMinimumVoltage, &value); s_printf(txt_buf + strlen(txt_buf), "%d mV\n", value); @@ -1680,6 +1686,31 @@ static lv_res_t _create_window_battery_status(lv_obj_t *btn) break; } + bool inserted; + u32 wattage = 0; + u32 max_voltage = 5; + usb_pd_objects_t usb_pd; + bm92t30_get_charger_type(&inserted, &usb_pd); + strcat(txt_buf, "\n\n\n"); + strcat(txt_buf, inserted ? "Connected" : "Disconnected"); + + for (u32 i = 0; i < usb_pd.pdo_no; i++) + if (usb_pd.pdos[i].voltage <= 15) + max_voltage = usb_pd.pdos[i].voltage; + + wattage = iinlim * max_voltage; + + s_printf(txt_buf + strlen(txt_buf), "\n%d.%d W", wattage / 1000, (wattage % 1000) / 100); + + if (!usb_pd.pdo_no) + strcat(txt_buf, "\nNon PD"); + + for (u32 i = 0; i < usb_pd.pdo_no; i++) + { + s_printf(txt_buf + strlen(txt_buf), "\n%d mA, %2d V", + usb_pd.pdos[i].amperage, usb_pd.pdos[i].voltage); + } + lv_label_set_text(lb_val2, txt_buf); lv_obj_set_width(lb_val2, lv_obj_get_width(val2));