Remove GPIO error on reboot, change battery % indicator to battery graphics
This commit is contained in:
@@ -47,6 +47,12 @@ void init_screens(void)
|
||||
|
||||
pp2d_load_texture_png(TEXTURE_ARROW, "romfs:/arrow.png");
|
||||
pp2d_load_texture_png(TEXTURE_SHUFFLE, "romfs:/shuffle.png");
|
||||
pp2d_load_texture_png(TEXTURE_BATTERY_1, "romfs:/battery1.png");
|
||||
pp2d_load_texture_png(TEXTURE_BATTERY_2, "romfs:/battery2.png");
|
||||
pp2d_load_texture_png(TEXTURE_BATTERY_3, "romfs:/battery3.png");
|
||||
pp2d_load_texture_png(TEXTURE_BATTERY_4, "romfs:/battery4.png");
|
||||
pp2d_load_texture_png(TEXTURE_BATTERY_5, "romfs:/battery5.png");
|
||||
pp2d_load_texture_png(TEXTURE_BATTERY_CHARGE, "romfs:/charging.png");
|
||||
}
|
||||
|
||||
void exit_screens(void)
|
||||
@@ -54,16 +60,6 @@ void exit_screens(void)
|
||||
pp2d_exit();
|
||||
}
|
||||
|
||||
static Result MCUHWC_GetBatteryLevel(u8 *out) // Code taken from daedreth's fork of lpp-3ds
|
||||
{
|
||||
u32 *cmdbuf = getThreadCommandBuffer();
|
||||
cmdbuf[0] = 0x50000;
|
||||
svcSendSyncRequest(mcuhwc_handle);
|
||||
*out = (u8) cmdbuf[2];
|
||||
svcCloseHandle(mcuhwc_handle);
|
||||
return cmdbuf[1];
|
||||
}
|
||||
|
||||
static int theme_vertical_scroll = 0;
|
||||
static int splash_vertical_scroll = 0;
|
||||
|
||||
@@ -79,12 +75,14 @@ void draw_base_interface(void)
|
||||
pp2d_draw_text(28, 2, 0.6, 0.6, COLOR_WHITE, (tm.tm_sec % 2 == 1) ? ":" : " ");
|
||||
pp2d_draw_textf(34, 2, 0.6, 0.6, COLOR_WHITE, "%.2i", tm.tm_min);
|
||||
|
||||
if (mcuhwc_on)
|
||||
{
|
||||
u8 battery_val = 0;
|
||||
MCUHWC_GetBatteryLevel(&battery_val);
|
||||
pp2d_draw_textf(350, 2, 0.6, 0.6, COLOR_WHITE, "%i%%", battery_val);
|
||||
}
|
||||
u8 battery_charging;
|
||||
PTMU_GetBatteryChargeState(&battery_charging);
|
||||
u8 battery_status;
|
||||
PTMU_GetBatteryLevel(&battery_status);
|
||||
pp2d_draw_texture(2 + battery_status, 357, 2);
|
||||
|
||||
if (battery_charging)
|
||||
pp2d_draw_texture(TEXTURE_BATTERY_CHARGE, 357, 2);
|
||||
|
||||
pp2d_draw_on(GFX_BOTTOM);
|
||||
pp2d_draw_rectangle(0, 0, 320, 24, COLOR_ACCENT);
|
||||
|
||||
@@ -33,12 +33,8 @@
|
||||
int init_services(void)
|
||||
{
|
||||
cfguInit();
|
||||
ptmuInit();
|
||||
open_archives();
|
||||
if (R_FAILED(srvGetServiceHandle(&mcuhwc_handle, "mcu::HWC")))
|
||||
{
|
||||
mcuhwc_on = false;
|
||||
ptmuInit();
|
||||
} else mcuhwc_on = true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -46,8 +42,7 @@ int exit_services(void)
|
||||
{
|
||||
close_archives();
|
||||
cfguExit();
|
||||
if (mcuhwc_on) svcCloseHandle(mcuhwc_handle);
|
||||
else ptmuExit();
|
||||
ptmuExit();
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -93,14 +88,7 @@ int main(void)
|
||||
|
||||
if (kDown & KEY_START)
|
||||
{
|
||||
if(!envIsHomebrew())
|
||||
{
|
||||
srvPublishToSubscriber(0x202, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
APT_HardwareResetAsync();
|
||||
}
|
||||
else if (kDown & KEY_L)
|
||||
{
|
||||
@@ -243,8 +231,4 @@ int main(void)
|
||||
previously_selected = selected_theme;
|
||||
}
|
||||
}
|
||||
|
||||
free(themes_list);
|
||||
exit_services();
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -87,7 +87,7 @@ void load_theme_preview(Theme_s *theme)
|
||||
free(preview_buffer);
|
||||
}
|
||||
|
||||
static void parse_smdh(Theme_s *theme, ssize_t textureID)
|
||||
static void parse_smdh(Theme_s *theme, ssize_t textureID, u16 *dir_name)
|
||||
{
|
||||
char *info_buffer = NULL;
|
||||
u64 size = 0;
|
||||
@@ -105,6 +105,9 @@ static void parse_smdh(Theme_s *theme, ssize_t textureID)
|
||||
if (!size)
|
||||
{
|
||||
free(info_buffer);
|
||||
memcpy(theme->name, dir_name, 0x106);
|
||||
utf8_to_utf16(theme->desc, (u8*)"No description", 0x106);
|
||||
utf8_to_utf16(theme->author, (u8*)"Unknown author", 0x106);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -181,7 +184,7 @@ Result get_themes(Theme_s **themes_list, int *theme_count)
|
||||
current_theme->is_zip = !strcmp(entry.shortExt, "ZIP");
|
||||
|
||||
ssize_t iconID = TEXTURE_PREVIEW + *theme_count;
|
||||
parse_smdh(current_theme, iconID);
|
||||
parse_smdh(current_theme, iconID, entry.name);
|
||||
}
|
||||
|
||||
FSDIR_Close(dir_handle);
|
||||
|
||||
Reference in New Issue
Block a user