Skip to content

Commit 0c4f67d

Browse files
committed
pbio/sys/hmi: Make default stop button configurable.
It's always been the center button, but we use the top left back button on EV3. It will be the dark gray button on NXT.
1 parent 5855a74 commit 0c4f67d

File tree

10 files changed

+14
-7
lines changed

10 files changed

+14
-7
lines changed

lib/pbio/platform/city_hub/pbsysconfig.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#define PBSYS_CONFIG_BATTERY_CHARGER (0)
1212
#define PBSYS_CONFIG_BLUETOOTH (1)
1313
#define PBSYS_CONFIG_HMI (1)
14+
#define PBSYS_CONFIG_HMI_STOP_BUTTON (1 << 5) // center
1415
#define PBSYS_CONFIG_HMI_PUP (1)
1516
#define PBSYS_CONFIG_HMI_NUM_SLOTS (0)
1617
#define PBSYS_CONFIG_HUB_LIGHT_MATRIX (0)

lib/pbio/platform/essential_hub/pbsysconfig.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#define PBSYS_CONFIG_BATTERY_CHARGER (1)
1010
#define PBSYS_CONFIG_BLUETOOTH (1)
1111
#define PBSYS_CONFIG_HMI (1)
12+
#define PBSYS_CONFIG_HMI_STOP_BUTTON (1 << 5) // center
1213
#define PBSYS_CONFIG_HMI_PUP (1)
1314
#define PBSYS_CONFIG_HMI_NUM_SLOTS (0)
1415
#define PBSYS_CONFIG_HUB_LIGHT_MATRIX (0)

lib/pbio/platform/ev3/pbsysconfig.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#define PBSYS_CONFIG_FEATURE_PROGRAM_FORMAT_MULTI_MPY_V6_3_NATIVE (0)
99
#define PBSYS_CONFIG_BATTERY_TEMP_ESTIMATION (1)
1010
#define PBSYS_CONFIG_HMI (1)
11+
#define PBSYS_CONFIG_HMI_STOP_BUTTON (1 << 7) // top left, back button
1112
#define PBSYS_CONFIG_HMI_LCD (1)
1213
#define PBSYS_CONFIG_HMI_NUM_SLOTS (5)
1314
#define PBSYS_CONFIG_HOST (1)

lib/pbio/platform/move_hub/pbsysconfig.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#define PBSYS_CONFIG_BATTERY_CHARGER (0)
1212
#define PBSYS_CONFIG_BLUETOOTH (1)
1313
#define PBSYS_CONFIG_HMI (1)
14+
#define PBSYS_CONFIG_HMI_STOP_BUTTON (1 << 5) // center
1415
#define PBSYS_CONFIG_HMI_PUP (1)
1516
#define PBSYS_CONFIG_HMI_NUM_SLOTS (0)
1617
#define PBSYS_CONFIG_HUB_LIGHT_MATRIX (0)

lib/pbio/platform/nxt/pbsysconfig.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#define PBSYS_CONFIG_FEATURE_PROGRAM_FORMAT_MULTI_MPY_V6 (1)
88
#define PBSYS_CONFIG_FEATURE_PROGRAM_FORMAT_MULTI_MPY_V6_3_NATIVE (0)
99
#define PBSYS_CONFIG_HMI (1)
10+
#define PBSYS_CONFIG_HMI_STOP_BUTTON (1 << 2) // down
1011
#define PBSYS_CONFIG_HMI_NONE (1)
1112
#define PBSYS_CONFIG_HMI_NUM_SLOTS (0)
1213
#define PBSYS_CONFIG_HOST (1)

lib/pbio/platform/prime_hub/pbsysconfig.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,11 @@
1010
#define PBSYS_CONFIG_BLUETOOTH (1)
1111
#define PBSYS_CONFIG_BLUETOOTH_TOGGLE (1)
1212
#define PBSYS_CONFIG_HMI (1)
13+
#define PBSYS_CONFIG_HMI_STOP_BUTTON (1 << 5) // center
1314
#define PBSYS_CONFIG_HMI_NUM_SLOTS (5)
1415
#define PBSYS_CONFIG_HMI_PUP (1)
15-
#define PBSYS_CONFIG_HMI_PUP_LEFT_RIGHT_BUTTONS (1)
16-
#define PBSYS_CONFIG_HMI_PUP_BLUETOOTH_BUTTON (512) // PBIO_BUTTON_RIGHT_UP, but enum value cannot be used here.
16+
#define PBSYS_CONFIG_HMI_PUP_BLUETOOTH_BUTTON (1 << 9) // right up
17+
#define PBSYS_CONFIG_HMI_PUP_LEFT_RIGHT_ENABLE (1)
1718
#define PBSYS_CONFIG_HUB_LIGHT_MATRIX (1)
1819
#define PBSYS_CONFIG_HUB_LIGHT_MATRIX_LED_ARRAY (1)
1920
#define PBSYS_CONFIG_HOST (1)

lib/pbio/platform/technic_hub/pbsysconfig.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#define PBSYS_CONFIG_BATTERY_CHARGER (0)
1212
#define PBSYS_CONFIG_BLUETOOTH (1)
1313
#define PBSYS_CONFIG_HMI (1)
14+
#define PBSYS_CONFIG_HMI_STOP_BUTTON (1 << 5) // center
1415
#define PBSYS_CONFIG_HMI_PUP (1)
1516
#define PBSYS_CONFIG_HMI_NUM_SLOTS (0)
1617
#define PBSYS_CONFIG_HUB_LIGHT_MATRIX (0)

lib/pbio/sys/hmi_pup.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ static pbio_error_t run_ui(pbio_os_state_t *state, pbio_os_timer_t *timer) {
164164
}
165165
#endif // PBSYS_CONFIG_HMI_PUP_BLUETOOTH_BUTTON
166166

167-
#if PBSYS_CONFIG_HMI_PUP_LEFT_RIGHT_BUTTONS
167+
#if PBSYS_CONFIG_HMI_PUP_LEFT_RIGHT_ENABLE
168168
// On right, increment slot when possible, then start waiting on new inputs.
169169
if (pbdrv_button_get_pressed() & PBIO_BUTTON_RIGHT) {
170170
pbsys_status_increment_selected_slot(true);
@@ -175,7 +175,7 @@ static pbio_error_t run_ui(pbio_os_state_t *state, pbio_os_timer_t *timer) {
175175
pbsys_status_increment_selected_slot(false);
176176
continue;
177177
}
178-
#endif // PBSYS_CONFIG_HMI_PUP_LEFT_RIGHT_BUTTONS
178+
#endif // PBSYS_CONFIG_HMI_PUP_LEFT_RIGHT_ENABLE
179179

180180
// On center, attempt to start program.
181181
if (pbdrv_button_get_pressed() & PBIO_BUTTON_CENTER) {

lib/pbio/sys/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ int main(int argc, char **argv) {
120120
// Get system back in idle state.
121121
pbsys_status_clear(PBIO_PYBRICKS_STATUS_USER_PROGRAM_RUNNING);
122122
pbsys_host_stdin_set_callback(NULL);
123-
pbsys_program_stop_set_buttons(PBIO_BUTTON_CENTER);
123+
pbsys_program_stop_set_buttons(PBSYS_CONFIG_HMI_STOP_BUTTON);
124124
program.start_request_type = PBSYS_MAIN_PROGRAM_START_REQUEST_TYPE_NONE;
125125

126126
// Handle pending events triggered by the status change, such as

lib/pbio/sys/program_stop.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
#include <pbsys/program_stop.h>
1717

1818
// Button combination that will trigger user program stop callback
19-
static pbio_button_flags_t stop_buttons = PBIO_BUTTON_CENTER;
19+
static pbio_button_flags_t stop_buttons = PBSYS_CONFIG_HMI_STOP_BUTTON;
2020
// State for button press one-shot
2121
static bool stop_button_pressed;
2222

@@ -59,7 +59,7 @@ void pbsys_program_stop_poll(void) {
5959

6060
pbio_button_flags_t btn = pbdrv_button_get_pressed();
6161

62-
if (btn & PBIO_BUTTON_CENTER) {
62+
if (btn & PBSYS_CONFIG_HMI_STOP_BUTTON) {
6363
pbsys_status_set(PBIO_PYBRICKS_STATUS_POWER_BUTTON_PRESSED);
6464

6565
// power off when button is held down for 2 seconds

0 commit comments

Comments
 (0)