mirror of
https://github.com/CTCaer/hekate
synced 2024-12-22 11:21:23 +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);
|
lv_obj_realign(status_bar.battery);
|
||||||
|
|
||||||
// Set battery current draw and voltage.
|
// Set battery current draw and voltage.
|
||||||
if (batt_curr >= 0)
|
s_printf(label, "#%s%d", batt_curr >= 0 ? "96FF00 +" : "FF3C28 ", batt_curr / 1000);
|
||||||
s_printf(label, "#96FF00 +%d", batt_curr / 1000);
|
|
||||||
else
|
|
||||||
s_printf(label, "#FF3C28 -%d", (~batt_curr + 1) / 1000);
|
|
||||||
|
|
||||||
bool voltage_empty = batt_volt < 3200;
|
bool voltage_empty = batt_volt < 3200;
|
||||||
s_printf(label + strlen(label), " mA# (%s%d mV%s)",
|
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);
|
s_printf(txt_buf + strlen(txt_buf), "%d mAh\n", value);
|
||||||
|
|
||||||
max17050_get_property(MAX17050_Current, &value);
|
max17050_get_property(MAX17050_Current, &value);
|
||||||
if (value >= 0)
|
|
||||||
s_printf(txt_buf + strlen(txt_buf), "%d mA\n", value / 1000);
|
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);
|
|
||||||
|
|
||||||
max17050_get_property(MAX17050_AvgCurrent, &value);
|
max17050_get_property(MAX17050_AvgCurrent, &value);
|
||||||
if (value >= 0)
|
|
||||||
s_printf(txt_buf + strlen(txt_buf), "%d mA\n", value / 1000);
|
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);
|
|
||||||
|
|
||||||
max17050_get_property(MAX17050_VCELL, &value);
|
max17050_get_property(MAX17050_VCELL, &value);
|
||||||
bool voltage_empty = value < 3200;
|
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);
|
s_printf(txt_buf + strlen(txt_buf), "%d mV\n", value);
|
||||||
|
|
||||||
max17050_get_property(MAX17050_TEMP, &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 >= 0 ? value : (~value + 1)) % 10);
|
||||||
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);
|
|
||||||
|
|
||||||
value = i2c_recv_byte(I2C_5, MAX77620_I2C_ADDR, MAX77620_REG_CID4);
|
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;
|
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_ctxt_t gfx_ctxt;
|
||||||
gfx_con_t gfx_con;
|
gfx_con_t gfx_con;
|
||||||
|
|
||||||
|
static bool gfx_con_init_done = false;
|
||||||
|
|
||||||
static const u8 _gfx_font[] = {
|
static const u8 _gfx_font[] = {
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Char 032 ( )
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Char 032 ( )
|
||||||
0x00, 0x30, 0x30, 0x18, 0x18, 0x00, 0x0C, 0x00, // Char 033 (!)
|
0x00, 0x30, 0x30, 0x18, 0x18, 0x00, 0x0C, 0x00, // Char 033 (!)
|
||||||
|
@ -154,6 +156,8 @@ void gfx_con_init()
|
||||||
gfx_con.fillbg = 1;
|
gfx_con.fillbg = 1;
|
||||||
gfx_con.bgcol = 0xFF000000;
|
gfx_con.bgcol = 0xFF000000;
|
||||||
gfx_con.mute = 0;
|
gfx_con.mute = 0;
|
||||||
|
|
||||||
|
gfx_con_init_done = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void gfx_con_setcol(u32 fgcol, int fillbg, u32 bgcol)
|
void gfx_con_setcol(u32 fgcol, int fillbg, u32 bgcol)
|
||||||
|
@ -295,7 +299,7 @@ void gfx_putc(char c)
|
||||||
|
|
||||||
void gfx_puts(char *s)
|
void gfx_puts(char *s)
|
||||||
{
|
{
|
||||||
if (!s || gfx_con.mute)
|
if (!s || !gfx_con_init_done || gfx_con.mute)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (; *s; s++)
|
for (; *s; s++)
|
||||||
|
@ -308,10 +312,19 @@ static void _gfx_putn(u32 v, int base, char fill, int fcnt)
|
||||||
static const char digits[] = "0123456789ABCDEFghijklmnopqrstuvwxyz";
|
static const char digits[] = "0123456789ABCDEFghijklmnopqrstuvwxyz";
|
||||||
char *p;
|
char *p;
|
||||||
int c = fcnt;
|
int c = fcnt;
|
||||||
|
bool negative = false;
|
||||||
|
|
||||||
if (base > 36)
|
if (base > 36)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
// Account for negative numbers.
|
||||||
|
if (base == 10 && v & 0x80000000)
|
||||||
|
{
|
||||||
|
negative = true;
|
||||||
|
v = (int)v * -1;
|
||||||
|
c--;
|
||||||
|
}
|
||||||
|
|
||||||
p = buf + 64;
|
p = buf + 64;
|
||||||
*p = 0;
|
*p = 0;
|
||||||
do
|
do
|
||||||
|
@ -321,9 +334,12 @@ static void _gfx_putn(u32 v, int base, char fill, int fcnt)
|
||||||
v /= base;
|
v /= base;
|
||||||
} while (v);
|
} while (v);
|
||||||
|
|
||||||
|
if (negative)
|
||||||
|
*--p = '-';
|
||||||
|
|
||||||
if (fill != 0)
|
if (fill != 0)
|
||||||
{
|
{
|
||||||
while (c > 0)
|
while (c > 0 && p > buf)
|
||||||
{
|
{
|
||||||
*--p = fill;
|
*--p = fill;
|
||||||
c--;
|
c--;
|
||||||
|
@ -335,7 +351,7 @@ static void _gfx_putn(u32 v, int base, char fill, int fcnt)
|
||||||
|
|
||||||
void gfx_printf(const char *fmt, ...)
|
void gfx_printf(const char *fmt, ...)
|
||||||
{
|
{
|
||||||
if (gfx_con.mute)
|
if (!gfx_con_init_done || gfx_con.mute)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
@ -411,7 +427,7 @@ void gfx_printf(const char *fmt, ...)
|
||||||
|
|
||||||
void gfx_hexdump(u32 base, const void *buf, u32 len)
|
void gfx_hexdump(u32 base, const void *buf, u32 len)
|
||||||
{
|
{
|
||||||
if (gfx_con.mute)
|
if (!gfx_con_init_done || gfx_con.mute)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
u8 *buff = (u8 *)buf;
|
u8 *buff = (u8 *)buf;
|
||||||
|
|
Loading…
Reference in a new issue