Skip to content

Commit 5855a74

Browse files
committed
pbio/platform/ev3: Disable hard reset by default.
We will be using the back button for normal poweroff, and losing your data is a confusing user experience. It can still be enabled with a config option for developers.
1 parent 700f343 commit 5855a74

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

lib/pbio/platform/ev3/pbdrvconfig.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
#define PBDRV_CONFIG_BUTTON (1)
4646
#define PBDRV_CONFIG_BUTTON_GPIO (1)
4747
#define PBDRV_CONFIG_BUTTON_GPIO_NUM_BUTTON (6)
48+
#define PBDRV_CONFIG_BUTTON_INSTANT_RESET (0)
4849

4950
#define PBDRV_CONFIG_DISPLAY (1)
5051
#define PBDRV_CONFIG_DISPLAY_EV3 (1)

lib/pbio/platform/ev3/platform.c

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,13 @@
5555

5656
#include <umm_malloc.h>
5757

58+
#include <pbio/port_interface.h>
59+
#include <pbio/button.h>
60+
5861
#include <pbdrv/cache.h>
5962
#include <pbdrv/compiler.h>
6063
#include <pbdrv/ioport.h>
61-
#include <pbio/port_interface.h>
64+
#include <pbdrv/reset.h>
6265

6366
#include "exceptionhandler.h"
6467

@@ -852,18 +855,16 @@ void SystemInit(void) {
852855
umm_init_heap(&pb_umm_heap_start, &pb_umm_heap_end - &pb_umm_heap_start);
853856
}
854857

855-
856-
#include <pbio/button.h>
857-
#include <pbdrv/reset.h>
858-
859858
/*
860-
* This is called from the IRQ handler after every systick. This should be
861-
* removed when the final user interface is implemented. For now this serves
862-
* as a very convenient way to power off the EV3 for fast iteration.
859+
* This is called from the IRQ handler after every systick. Can be enabled
860+
* to run emergency poweroff for faster iteration and debugging. User data
861+
* is not saved when powering off this way.
863862
*/
864863
void lazy_poweroff_hook(void) {
864+
#if PBDRV_CONFIG_BUTTON_INSTANT_RESET
865865
if (pbdrv_button_get_pressed() & PBIO_BUTTON_LEFT_UP) {
866866
pbdrv_reset_power_off();
867867
return;
868868
}
869+
#endif
869870
}

0 commit comments

Comments
 (0)