System: Display headphone connection status

This commit is contained in:
joel16 2023-06-18 15:50:31 -04:00
parent 8892836e58
commit 57c75634e6
4 changed files with 24 additions and 0 deletions

View File

@ -76,6 +76,7 @@ namespace SwitchIdent {
u32 GetClock(PcvModule module);
SetCalBdAddress GetBluetoothBdAddress(void);
SetCalMacAddress GetWirelessLanMacAddress(void);
const char *GetHeadphoneStatus(void);
// Wlan
u32 GetWlanState(void);

View File

@ -6,6 +6,7 @@
namespace Services {
void Exit(void) {
gpioExit();
hiddbgExit();
tsExit();
wlaninfExit();
@ -103,6 +104,10 @@ namespace Services {
if (R_FAILED(ret = hiddbgInitialize())) {
std::printf("hiddbgInitialize() failed: 0x%x.\n\n", ret);
}
if (R_FAILED(ret = gpioInitialize())) {
std::printf("gpioInitialize() failed: 0x%x.\n\n", ret);
}
GUI::Init();
}

View File

@ -78,6 +78,7 @@ namespace Menus {
Menus::DrawItem(g_start_x, g_start_y + ((g_item_dist - g_item_height) / 2) + 420, "NFC:", SwitchIdent::GetNfcEnableFlag()? "Enabled" : "Disabled");
Menus::DrawItemf(g_start_x, g_start_y + ((g_item_dist - g_item_height) / 2) + 480, "Internal (PCB) temperature:", "%d °C (%d °F)", int_temp, ((int_temp * 9/5) + 32));
Menus::DrawItemf(g_start_x, g_start_y + ((g_item_dist - g_item_height) / 2) + 540, "External (SoC) temperature:", "%d °C (%d °F)", ext_temp, ((ext_temp * 9/5) + 32));
Menus::DrawItem(g_start_x, g_start_y + ((g_item_dist - g_item_height) / 2) + 600, "Headphone Status:", SwitchIdent::GetHeadphoneStatus());
}
void BatteryInfo(void) {

View File

@ -87,4 +87,21 @@ namespace SwitchIdent {
return mac_addr;
}
const char *GetHeadphoneStatus(void) {
Result ret = 0;
GpioPadSession button;
GpioValue value;
if (R_FAILED(ret = gpioOpenSession(&button, static_cast<GpioPadName>(21)))) {
std::printf("gpioOpenSession() failed: 0x%x.\n\n", ret);
}
if (R_FAILED(ret = gpioPadGetValue(&button, &value))) {
std::printf("gpioPadGetValue() failed: 0x%x.\n\n", ret);
}
gpioPadClose(&button);
return (value == GpioValue_Low)? "Inserted": "Not inserted";
}
}