mirror of
https://github.com/CTCaer/hekate.git
synced 2024-11-23 02:16:41 +00:00
hekate: gfx: add negative decimals printing
And remove external handling
This commit is contained in:
parent
ebe7b5a603
commit
c2869703af
3 changed files with 20 additions and 19 deletions
|
@ -337,16 +337,10 @@ void print_fuel_gauge_info()
|
||||||
gfx_printf("Capacity (design): %4d mAh\n", value);
|
gfx_printf("Capacity (design): %4d mAh\n", value);
|
||||||
|
|
||||||
max17050_get_property(MAX17050_Current, &value);
|
max17050_get_property(MAX17050_Current, &value);
|
||||||
if (value >= 0)
|
|
||||||
gfx_printf("Current now: %d mA\n", value / 1000);
|
gfx_printf("Current now: %d mA\n", value / 1000);
|
||||||
else
|
|
||||||
gfx_printf("Current now: -%d mA\n", ~value / 1000);
|
|
||||||
|
|
||||||
max17050_get_property(MAX17050_AvgCurrent, &value);
|
max17050_get_property(MAX17050_AvgCurrent, &value);
|
||||||
if (value >= 0)
|
|
||||||
gfx_printf("Current average: %d mA\n", value / 1000);
|
gfx_printf("Current average: %d mA\n", value / 1000);
|
||||||
else
|
|
||||||
gfx_printf("Current average: -%d mA\n", ~value / 1000);
|
|
||||||
|
|
||||||
max17050_get_property(MAX17050_VCELL, &value);
|
max17050_get_property(MAX17050_VCELL, &value);
|
||||||
gfx_printf("Voltage now: %4d mV\n", value);
|
gfx_printf("Voltage now: %4d mV\n", value);
|
||||||
|
@ -364,10 +358,8 @@ void print_fuel_gauge_info()
|
||||||
gfx_printf("Empty voltage (design): %4d mV\n", value);
|
gfx_printf("Empty voltage (design): %4d mV\n", value);
|
||||||
|
|
||||||
max17050_get_property(MAX17050_TEMP, &value);
|
max17050_get_property(MAX17050_TEMP, &value);
|
||||||
if (value >= 0)
|
gfx_printf("Battery temperature: %d.%d oC\n", value / 10,
|
||||||
gfx_printf("Battery temperature: %d.%d oC\n", value / 10, value % 10);
|
(value >= 0 ? value : (~value)) % 10);
|
||||||
else
|
|
||||||
gfx_printf("Battery temperature: -%d.%d oC\n", ~value / 10, (~value) % 10);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void print_battery_charger_info()
|
void print_battery_charger_info()
|
||||||
|
|
|
@ -280,10 +280,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
|
||||||
|
@ -293,9 +302,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--;
|
||||||
|
|
|
@ -51,12 +51,9 @@ void tui_sbar(bool force_update)
|
||||||
|
|
||||||
max17050_get_property(MAX17050_Current, &battVoltCurr);
|
max17050_get_property(MAX17050_Current, &battVoltCurr);
|
||||||
|
|
||||||
if (battVoltCurr >= 0)
|
gfx_printf(" %k%d mA%k%K\n", battVoltCurr >= 0 ? 0xFF008800 : 0xFF880000,
|
||||||
gfx_printf(" %k+%d mA%k%K\n",
|
battVoltCurr / 1000, 0xFFCCCCCC, 0xFF1B1B1B);
|
||||||
0xFF008800, battVoltCurr / 1000, 0xFFCCCCCC, 0xFF1B1B1B);
|
|
||||||
else
|
|
||||||
gfx_printf(" %k-%d mA%k%K\n",
|
|
||||||
0xFF880000, (~battVoltCurr) / 1000, 0xFFCCCCCC, 0xFF1B1B1B);
|
|
||||||
gfx_con.fntsz = prevFontSize;
|
gfx_con.fntsz = prevFontSize;
|
||||||
gfx_con_setpos(cx, cy);
|
gfx_con_setpos(cx, cy);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue