mirror of
https://github.com/CTCaer/hekate.git
synced 2024-11-10 04:21:45 +00:00
nyx: remove negative decimal external handling
This commit is contained in:
parent
c2869703af
commit
ae394d9f37
3 changed files with 24 additions and 20 deletions
|
@ -1321,10 +1321,7 @@ static void _update_status_bar(void *params)
|
|||
lv_obj_realign(status_bar.battery);
|
||||
|
||||
// Set battery current draw and voltage.
|
||||
if (batt_curr >= 0)
|
||||
s_printf(label, "#96FF00 +%d", batt_curr / 1000);
|
||||
else
|
||||
s_printf(label, "#FF3C28 -%d", (~batt_curr + 1) / 1000);
|
||||
s_printf(label, "#%s%d", batt_curr >= 0 ? "96FF00 +" : "FF3C28 ", batt_curr / 1000);
|
||||
|
||||
bool voltage_empty = batt_volt < 3200;
|
||||
s_printf(label + strlen(label), " mA# (%s%d mV%s)",
|
||||
|
|
|
@ -2162,16 +2162,10 @@ static lv_res_t _create_window_battery_status(lv_obj_t *btn)
|
|||
s_printf(txt_buf + strlen(txt_buf), "%d mAh\n", value);
|
||||
|
||||
max17050_get_property(MAX17050_Current, &value);
|
||||
if (value >= 0)
|
||||
s_printf(txt_buf + strlen(txt_buf), "%d mA\n", value / 1000);
|
||||
else
|
||||
s_printf(txt_buf + strlen(txt_buf), "-%d mA\n", (~value + 1) / 1000);
|
||||
s_printf(txt_buf + strlen(txt_buf), "%d mA\n", value / 1000);
|
||||
|
||||
max17050_get_property(MAX17050_AvgCurrent, &value);
|
||||
if (value >= 0)
|
||||
s_printf(txt_buf + strlen(txt_buf), "%d mA\n", value / 1000);
|
||||
else
|
||||
s_printf(txt_buf + strlen(txt_buf), "-%d mA\n", (~value + 1) / 1000);
|
||||
s_printf(txt_buf + strlen(txt_buf), "%d mA\n", value / 1000);
|
||||
|
||||
max17050_get_property(MAX17050_VCELL, &value);
|
||||
bool voltage_empty = value < 3200;
|
||||
|
@ -2191,10 +2185,7 @@ static lv_res_t _create_window_battery_status(lv_obj_t *btn)
|
|||
s_printf(txt_buf + strlen(txt_buf), "%d mV\n", value);
|
||||
|
||||
max17050_get_property(MAX17050_TEMP, &value);
|
||||
if (value >= 0)
|
||||
s_printf(txt_buf + strlen(txt_buf), "%d.%d oC\n\n\n", value / 10, value % 10);
|
||||
else
|
||||
s_printf(txt_buf + strlen(txt_buf), "-%d.%d oC\n\n\n", (~value + 1) / 10, (~value + 1) % 10);
|
||||
s_printf(txt_buf + strlen(txt_buf), "%d.%d oC\n\n\n", value / 10, (value >= 0 ? value : (~value + 1)) % 10);
|
||||
|
||||
value = i2c_recv_byte(I2C_5, MAX77620_I2C_ADDR, MAX77620_REG_CID4);
|
||||
u32 main_pmic_version = i2c_recv_byte(I2C_5, MAX77620_I2C_ADDR, MAX77620_REG_CID3) & 0xF;
|
||||
|
|
|
@ -23,6 +23,8 @@
|
|||
gfx_ctxt_t gfx_ctxt;
|
||||
gfx_con_t gfx_con;
|
||||
|
||||
static bool gfx_con_init_done = false;
|
||||
|
||||
static const u8 _gfx_font[] = {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Char 032 ( )
|
||||
0x00, 0x30, 0x30, 0x18, 0x18, 0x00, 0x0C, 0x00, // Char 033 (!)
|
||||
|
@ -154,6 +156,8 @@ void gfx_con_init()
|
|||
gfx_con.fillbg = 1;
|
||||
gfx_con.bgcol = 0xFF000000;
|
||||
gfx_con.mute = 0;
|
||||
|
||||
gfx_con_init_done = true;
|
||||
}
|
||||
|
||||
void gfx_con_setcol(u32 fgcol, int fillbg, u32 bgcol)
|
||||
|
@ -295,7 +299,7 @@ void gfx_putc(char c)
|
|||
|
||||
void gfx_puts(char *s)
|
||||
{
|
||||
if (!s || gfx_con.mute)
|
||||
if (!s || !gfx_con_init_done || gfx_con.mute)
|
||||
return;
|
||||
|
||||
for (; *s; s++)
|
||||
|
@ -308,10 +312,19 @@ static void _gfx_putn(u32 v, int base, char fill, int fcnt)
|
|||
static const char digits[] = "0123456789ABCDEFghijklmnopqrstuvwxyz";
|
||||
char *p;
|
||||
int c = fcnt;
|
||||
bool negative = false;
|
||||
|
||||
if (base > 36)
|
||||
return;
|
||||
|
||||
// Account for negative numbers.
|
||||
if (base == 10 && v & 0x80000000)
|
||||
{
|
||||
negative = true;
|
||||
v = (int)v * -1;
|
||||
c--;
|
||||
}
|
||||
|
||||
p = buf + 64;
|
||||
*p = 0;
|
||||
do
|
||||
|
@ -321,9 +334,12 @@ static void _gfx_putn(u32 v, int base, char fill, int fcnt)
|
|||
v /= base;
|
||||
} while (v);
|
||||
|
||||
if (negative)
|
||||
*--p = '-';
|
||||
|
||||
if (fill != 0)
|
||||
{
|
||||
while (c > 0)
|
||||
while (c > 0 && p > buf)
|
||||
{
|
||||
*--p = fill;
|
||||
c--;
|
||||
|
@ -335,7 +351,7 @@ static void _gfx_putn(u32 v, int base, char fill, int fcnt)
|
|||
|
||||
void gfx_printf(const char *fmt, ...)
|
||||
{
|
||||
if (gfx_con.mute)
|
||||
if (!gfx_con_init_done || gfx_con.mute)
|
||||
return;
|
||||
|
||||
va_list ap;
|
||||
|
@ -411,7 +427,7 @@ void gfx_printf(const char *fmt, ...)
|
|||
|
||||
void gfx_hexdump(u32 base, const void *buf, u32 len)
|
||||
{
|
||||
if (gfx_con.mute)
|
||||
if (!gfx_con_init_done || gfx_con.mute)
|
||||
return;
|
||||
|
||||
u8 *buff = (u8 *)buf;
|
||||
|
|
Loading…
Reference in a new issue