Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions supervisor/shared/bluetooth/bluetooth.c
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,11 @@ void supervisor_bluetooth_init(void) {
}
#endif // !CIRCUITPY_USB_DEVICE

// A press must begin inside this interval. The safe mode interval just before
// this one also uses the boot button, and a press meant for safe mode can
// still be held down when this interval starts; entering discovery mode from
// it would erase bonding unasked. Require a release first.
bool button_released = !port_boot_button_pressed();
while (diff < 1000) {
#if CIRCUITPY_STATUS_LED
// Blink on for 50 and off for 100
Expand All @@ -262,9 +267,14 @@ void supervisor_bluetooth_init(void) {
new_status_color(BLACK);
}
#endif
if (port_boot_button_pressed()) {
if (!port_boot_button_pressed()) {
button_released = true;
} else if (button_released && !boot_in_discovery_mode) {
boot_in_discovery_mode = true;
break;
// Restart the interval so the LED shows solid blue for the full
// 1000 ms, as feedback that the press was accepted and bonding
// will be erased.
start_ticks = supervisor_ticks_ms64();
}
diff = supervisor_ticks_ms64() - start_ticks;
}
Expand Down
19 changes: 12 additions & 7 deletions supervisor/shared/safe_mode.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,13 @@ safe_mode_t wait_for_safe_mode_reset(void) {
status_led_init();
#endif

uint32_t safe_mode_delay_msecs = 1000;
#define DEFAULT_SAFE_MODE_DELAY_MSECS (1000)
#define DEFAULT_SAFE_MODE_DELAY_SECS (((mp_float_t)DEFAULT_SAFE_MODE_DELAY_MSECS) / 1000.0f)
uint32_t safe_mode_delay_msecs = DEFAULT_SAFE_MODE_DELAY_MSECS;

#if CIRCUITPY_SETTINGS_TOML
mp_float_t safe_mode_delay_secs = 1.0f;
// Will update delay_secs if setting is present.
mp_float_t safe_mode_delay_secs = DEFAULT_SAFE_MODE_DELAY_SECS;
// Will update safe_mode_delay_secs if setting is present.
settings_get_float("CIRCUITPY_SAFE_MODE_DELAY", &safe_mode_delay_secs);
if (safe_mode_delay_secs >= 0.0f && safe_mode_delay_secs <= (mp_float_t)UINT32_MAX) {
safe_mode_delay_msecs = safe_mode_delay_secs * 1000;
Expand All @@ -86,17 +88,20 @@ safe_mode_t wait_for_safe_mode_reset(void) {
bool boot_in_safe_mode = false;
while (diff < safe_mode_delay_msecs) {
#if CIRCUITPY_STATUS_LED
// Blink on for 100, off for 100
bool led_on = (diff % 250) < 125;
// Blink on for 125, off for 125
bool led_on = boot_in_safe_mode || (diff % 250) < 125;
if (led_on) {
new_status_color(SAFE_MODE);
} else {
new_status_color(BLACK);
}
#endif
if (port_boot_button_pressed()) {
if (!boot_in_safe_mode && port_boot_button_pressed()) {
boot_in_safe_mode = true;
break;
// Show solid yellow as feedback that the press was accepted, for the
// default duration.
start_ticks = supervisor_ticks_ms64();
safe_mode_delay_msecs = DEFAULT_SAFE_MODE_DELAY_MSECS;
}
diff = supervisor_ticks_ms64() - start_ticks;
}
Expand Down
Loading