Skip to content

Commit 821b984

Browse files
committed
Factor out duplicate code.
1 parent fd9af91 commit 821b984

File tree

1 file changed

+3
-14
lines changed

1 file changed

+3
-14
lines changed

supervisor/shared/bluetooth/bluetooth.c

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,13 @@
1010

1111
#include "shared-bindings/_bleio/__init__.h"
1212
#include "shared-bindings/_bleio/Adapter.h"
13-
#if defined(CIRCUITPY_BOOT_BUTTON)
14-
#include "shared-bindings/digitalio/DigitalInOut.h"
15-
#include "shared-bindings/time/__init__.h"
16-
#endif
1713
#include "shared-bindings/microcontroller/Processor.h"
1814
#include "shared-bindings/microcontroller/ResetReason.h"
1915
#include "shared-module/storage/__init__.h"
2016

2117
#include "common-hal/_bleio/__init__.h"
2218

19+
#include "supervisor/port.h"
2320
#include "supervisor/shared/serial.h"
2421
#include "supervisor/shared/status_leds.h"
2522
#include "supervisor/shared/tick.h"
@@ -238,18 +235,10 @@ void supervisor_bluetooth_init(void) {
238235
new_status_color(BLACK);
239236
}
240237
#endif
241-
// Init the boot button every time in case it is used for LEDs.
242-
#ifdef CIRCUITPY_BOOT_BUTTON
243-
digitalio_digitalinout_obj_t boot_button;
244-
common_hal_digitalio_digitalinout_construct(&boot_button, CIRCUITPY_BOOT_BUTTON);
245-
common_hal_digitalio_digitalinout_switch_to_input(&boot_button, PULL_UP);
246-
common_hal_time_delay_ms(1);
247-
bool button_pressed = !common_hal_digitalio_digitalinout_get_value(&boot_button);
248-
common_hal_digitalio_digitalinout_deinit(&boot_button);
249-
if (button_pressed) {
238+
if (port_boot_button_pressed()) {
250239
boot_in_discovery_mode = true;
240+
break;
251241
}
252-
#endif
253242
diff = supervisor_ticks_ms64() - start_ticks;
254243
}
255244
if (boot_in_discovery_mode) {

0 commit comments

Comments
 (0)