rebase: Phase C — main.cpp wires OLED + PS+Mute reboot combo
Three additions on top of upstream's v0.6.0-hotfix main.cpp: - #include "oled.h" + oled_init() after audio_init/state_init, oled_loop() in the main while(1). - PS + Mute hold-2-seconds combo at the top of interrupt_loop() for headless soft-reboot via watchdog_reboot(0,0,0). Bit pattern (interrupt_in_data[9] & 0x05) is rare in normal gameplay so the long hold prevents accidental triggers. Upstream's state_init() call sits right between audio_init() and our new oled_init() — preserved as-is. The state_mgr → 0x31 output report flow in tud_hid_set_report_cb is upstream's rumble path; not touched. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.7
parent
4b6a72b70a
commit
41c89ebcfd
@@ -21,6 +21,7 @@
|
|||||||
#if ENABLE_BATT_LED
|
#if ENABLE_BATT_LED
|
||||||
#include "battery_led.h"
|
#include "battery_led.h"
|
||||||
#endif
|
#endif
|
||||||
|
#include "oled.h"
|
||||||
|
|
||||||
// Pico SDK speciifically for waiting on conditions
|
// Pico SDK speciifically for waiting on conditions
|
||||||
#include "pico/critical_section.h"
|
#include "pico/critical_section.h"
|
||||||
@@ -44,6 +45,23 @@ critical_section_t report_cs;
|
|||||||
volatile bool report_dirty = false;
|
volatile bool report_dirty = false;
|
||||||
|
|
||||||
void interrupt_loop() {
|
void interrupt_loop() {
|
||||||
|
// OLED Edition: hold PS + Mute for 2 seconds to soft-reboot the dongle.
|
||||||
|
// Works whether or not the OLED add-on is present. PS+Mute is uncommon
|
||||||
|
// during gameplay and the long hold avoids accidental triggers.
|
||||||
|
{
|
||||||
|
static uint32_t combo_first_us = 0;
|
||||||
|
constexpr uint8_t kComboBits = 0x05; // byte 9: PS (bit 0) + Mute (bit 2)
|
||||||
|
constexpr uint32_t kComboHoldUs = 2000000; // 2 seconds
|
||||||
|
const bool held = (interrupt_in_data[9] & kComboBits) == kComboBits;
|
||||||
|
if (held) {
|
||||||
|
const uint32_t now = time_us_32();
|
||||||
|
if (combo_first_us == 0) combo_first_us = now;
|
||||||
|
else if ((now - combo_first_us) > kComboHoldUs) watchdog_reboot(0, 0, 0);
|
||||||
|
} else {
|
||||||
|
combo_first_us = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!tud_hid_ready()) return;
|
if (!tud_hid_ready()) return;
|
||||||
|
|
||||||
// TODO: Refactor for better code reuse
|
// TODO: Refactor for better code reuse
|
||||||
@@ -252,6 +270,7 @@ int main() {
|
|||||||
|
|
||||||
audio_init();
|
audio_init();
|
||||||
state_init();
|
state_init();
|
||||||
|
oled_init();
|
||||||
|
|
||||||
#if !ENABLE_SERIAL
|
#if !ENABLE_SERIAL
|
||||||
watchdog_enable(1000, true);
|
watchdog_enable(1000, true);
|
||||||
@@ -265,6 +284,7 @@ int main() {
|
|||||||
tud_task();
|
tud_task();
|
||||||
audio_loop();
|
audio_loop();
|
||||||
interrupt_loop();
|
interrupt_loop();
|
||||||
|
oled_loop();
|
||||||
#if ENABLE_BATT_LED
|
#if ENABLE_BATT_LED
|
||||||
battery_led_tick();
|
battery_led_tick();
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user