With shell closed, use the LED to signal finished operations

This commit is contained in:
d0k3 2019-05-01 02:38:31 +02:00
parent 85a189b3b6
commit ff9fde1561

View File

@ -1,6 +1,7 @@
#include "hid.h" #include "hid.h"
#include "i2c.h" #include "i2c.h"
#include "timer.h" #include "timer.h"
#include "colors.h"
#include "screenshot.h" // for screenshots #include "screenshot.h" // for screenshots
#include "arm.h" #include "arm.h"
@ -11,6 +12,14 @@
#define HID_TOUCH_MIDPOINT (HID_TOUCH_MAXPOINT / 2) #define HID_TOUCH_MIDPOINT (HID_TOUCH_MAXPOINT / 2)
static void SetNotificationLED(u32 period_ms, u32 bgr_color)
{
u32 rgb_color =
((bgr_color >> 16) & 0xFF) | (bgr_color & 0xFF00) | ((bgr_color & 0xFF) << 16);
u32 args[] = {period_ms, rgb_color};
PXI_DoCMD(PXI_NOTIFY_LED, args, 2);
}
// there's some weird thing going on when reading this // there's some weird thing going on when reading this
// with an LDRD instruction so for now they'll be two // with an LDRD instruction so for now they'll be two
// separate things - hopefully LTO won't get in the way // separate things - hopefully LTO won't get in the way
@ -105,6 +114,13 @@ u32 InputWait(u32 timeout_sec) {
u32 oldcart = CART_STATE; u32 oldcart = CART_STATE;
u32 oldsd = SD_STATE; u32 oldsd = SD_STATE;
// enable notification LED if shell is closed
// (this means we're waiting for user input)
if (oldpad & SHELL_CLOSED) {
SetNotificationLED(1000, COLOR_GREEN);
while (HID_ReadState() & SHELL_CLOSED);
}
delay = delay ? 72 : 128; delay = delay ? 72 : 128;
do { do {
@ -133,6 +149,12 @@ u32 InputWait(u32 timeout_sec) {
(delay && (timer_msec(timer) < delay)))) (delay && (timer_msec(timer) < delay))))
continue; continue;
// handle closed shell (wait for open)
if (newpad & SHELL_CLOSED) {
while (HID_ReadState() & SHELL_CLOSED);
continue;
}
u32 t_pressed = 0; u32 t_pressed = 0;
while((t_pressed++ < 0x13000) && (newpad == HID_ReadState())); while((t_pressed++ < 0x13000) && (newpad == HID_ReadState()));
if (t_pressed >= 0x13000) { if (t_pressed >= 0x13000) {