mirror of
https://github.com/daveallie/crosspoint-reader.git
synced 2026-02-04 14:47:37 +03:00
fix: hard reset via RTS pin after flashing firmware (#437)
## Summary * Disables going to sleep after uploading new firmware * Makes developer experience easier --- ### AI Usage While CrossPoint doesn't have restrictions on AI tools in contributing, please be transparent about their usage as it helps set the right context for reviewers. Did you use AI tools to help write this code? _**< NO >**_ --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
parent
1e95a353bf
commit
8cbd72bdae
25
src/main.cpp
25
src/main.cpp
@ -276,13 +276,30 @@ void setupDisplayAndFonts() {
|
|||||||
Serial.printf("[%lu] [ ] Fonts setup\n", millis());
|
Serial.printf("[%lu] [ ] Fonts setup\n", millis());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool isUsbConnected() {
|
||||||
|
// U0RXD/GPIO20 reads HIGH when USB is connected
|
||||||
|
return digitalRead(UART0_RXD) == HIGH;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isWakeupAfterFlashing() {
|
||||||
|
const auto wakeupCause = esp_sleep_get_wakeup_cause();
|
||||||
|
const auto resetReason = esp_reset_reason();
|
||||||
|
|
||||||
|
return isUsbConnected() && (wakeupCause == ESP_SLEEP_WAKEUP_UNDEFINED) && (resetReason == ESP_RST_UNKNOWN);
|
||||||
|
}
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
t1 = millis();
|
t1 = millis();
|
||||||
|
|
||||||
// Only start serial if USB connected
|
// Only start serial if USB connected
|
||||||
pinMode(UART0_RXD, INPUT);
|
pinMode(UART0_RXD, INPUT);
|
||||||
if (digitalRead(UART0_RXD) == HIGH) {
|
if (isUsbConnected()) {
|
||||||
Serial.begin(115200);
|
Serial.begin(115200);
|
||||||
|
// Wait up to 3 seconds for Serial to be ready to catch early logs
|
||||||
|
unsigned long start = millis();
|
||||||
|
while (!Serial && (millis() - start) < 3000) {
|
||||||
|
delay(10);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
inputManager.begin();
|
inputManager.begin();
|
||||||
@ -305,8 +322,10 @@ void setup() {
|
|||||||
SETTINGS.loadFromFile();
|
SETTINGS.loadFromFile();
|
||||||
KOREADER_STORE.loadFromFile();
|
KOREADER_STORE.loadFromFile();
|
||||||
|
|
||||||
// verify power button press duration after we've read settings.
|
if (!isWakeupAfterFlashing()) {
|
||||||
verifyWakeupLongPress();
|
// For normal wakeups (not immediately after flashing), verify long press
|
||||||
|
verifyWakeupLongPress();
|
||||||
|
}
|
||||||
|
|
||||||
// First serial output only here to avoid timing inconsistencies for power button press duration verification
|
// First serial output only here to avoid timing inconsistencies for power button press duration verification
|
||||||
Serial.printf("[%lu] [ ] Starting CrossPoint version " CROSSPOINT_VERSION "\n", millis());
|
Serial.printf("[%lu] [ ] Starting CrossPoint version " CROSSPOINT_VERSION "\n", millis());
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user