File tree Expand file tree Collapse file tree 2 files changed +15
-15
lines changed Expand file tree Collapse file tree 2 files changed +15
-15
lines changed Original file line number Diff line number Diff line change @@ -176,18 +176,6 @@ void pbsys_hmi_init(void) {
176176void pbsys_hmi_handle_status_change (pbsys_status_change_t event , pbio_pybricks_status_t data ) {
177177 pbsys_status_light_handle_status_change (event , data );
178178 pbsys_hub_light_matrix_handle_status_change (event , data );
179-
180- #if PBSYS_CONFIG_BATTERY_CHARGER
181- // On the Technic Large hub, USB can keep the power on even though we are
182- // "shutdown", so if the button is pressed again, we reset to turn back on
183- if (
184- pbsys_status_test (PBIO_PYBRICKS_STATUS_SHUTDOWN )
185- && event == PBSYS_STATUS_CHANGE_SET
186- && data == PBIO_PYBRICKS_STATUS_POWER_BUTTON_PRESSED
187- ) {
188- pbdrv_reset (PBDRV_RESET_ACTION_RESET );
189- }
190- #endif // PBSYS_CONFIG_BATTERY_CHARGER
191179}
192180
193181/**
Original file line number Diff line number Diff line change @@ -133,12 +133,24 @@ int main(int argc, char **argv) {
133133 pbsys_status_set (PBIO_PYBRICKS_STATUS_SHUTDOWN );
134134
135135 // The power could be held on due to someone pressing the center button
136- // or USB being plugged in, so we have this loop to keep pumping events
137- // to turn off most of the peripherals and keep the battery charger running .
138- while (pbsys_status_test (PBIO_PYBRICKS_STATUS_POWER_BUTTON_PRESSED ) || pbdrv_usb_get_bcd () != PBDRV_USB_BCD_NONE ) {
136+ // so we have this loop to keep handling events to drive processes that
137+ // turn off some of the peripherals.
138+ while (pbsys_status_test (PBIO_PYBRICKS_STATUS_POWER_BUTTON_PRESSED )) {
139139 pbio_os_run_processes_and_wait_for_event ();
140140 }
141141
142+ #if PBSYS_CONFIG_BATTERY_CHARGER
143+ // Similarly, run events to keep charging while the hub is "off".
144+ while (pbdrv_usb_get_bcd () != PBDRV_USB_BCD_NONE ) {
145+ pbio_os_run_processes_and_wait_for_event ();
146+ // If the button is pressed again, the user wants to turn the hub
147+ // "back on". We are still on, so do a full reset instead.
148+ if (pbsys_status_test (PBIO_PYBRICKS_STATUS_POWER_BUTTON_PRESSED )) {
149+ pbdrv_reset (PBDRV_RESET_ACTION_RESET );
150+ }
151+ }
152+ #endif
153+
142154 // Platform-specific power off.
143155 pbdrv_reset_power_off ();
144156}
You can’t perform that action at this time.
0 commit comments