Skip to content
Open
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
1 change: 1 addition & 0 deletions bricks/_common/sources.mk
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ PBIO_SRC_C = $(addprefix lib/pbio/,\
sys/battery.c \
sys/command.c \
sys/core.c \
sys/hmi_buildhat.c \
sys/hmi_ev3.c \
sys/hmi_ev3_ui.c \
sys/hmi_none.c \
Expand Down
2 changes: 1 addition & 1 deletion lib/pbio/platform/build_hat/pbsysconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#define PBSYS_CONFIG_BATTERY_CHARGER (0)
#define PBSYS_CONFIG_HMI (1)
#define PBSYS_CONFIG_HMI_STOP_BUTTON (0) // does not exist but pbsys_main() requires this to be defined
#define PBSYS_CONFIG_HMI_NONE (1)
#define PBSYS_CONFIG_HMI_BUILDHAT (1)
#define PBSYS_CONFIG_HMI_NUM_SLOTS (0)
#define PBSYS_CONFIG_HOST (1)
#define PBSYS_CONFIG_HOST_EVENT_OUT_SIZE (512)
Expand Down
54 changes: 54 additions & 0 deletions lib/pbio/sys/hmi_buildhat.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
// SPDX-License-Identifier: MIT
// Copyright (c) 2018-2026 The Pybricks Authors

// Provides the Human Machine Interface (HMI) for the Build HAT.
// There is nothing to select, so the REPL starts right after boot.

#include <pbsys/config.h>

#if PBSYS_CONFIG_HMI_BUILDHAT

#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>

#include <pbio/button.h>
#include <pbio/light.h>
#include <pbio/os.h>
#include <pbsys/light.h>
#include <pbsys/main.h>
#include <pbsys/status.h>

void pbsys_hmi_init(void) {
}

void pbsys_hmi_deinit(void) {
}

void pbsys_hmi_stop_animation(void) {
}

void pbsys_hmi_connection_changed_handler(void) {
}

pbio_error_t pbsys_hmi_await_program_selection(void) {

do {
if (pbsys_status_test(PBIO_PYBRICKS_STATUS_SHUTDOWN_REQUEST)) {
return PBIO_ERROR_CANCELED;
}
pbio_os_run_processes_and_wait_for_event();
} while (pbdrv_button_get_pressed());

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As Laurens said, we don't have a button on this hub, so we should be able to drop this loop.


// Start the "ready" animation, same as hmi_pup.c does after program
// selection.
#if PBSYS_CONFIG_STATUS_LIGHT_STATE_ANIMATIONS
pbio_color_light_start_breathe_animation(pbsys_status_light_main, PBSYS_CONFIG_STATUS_LIGHT_STATE_ANIMATIONS_HUE);
#elif PBSYS_CONFIG_STATUS_LIGHT
pbio_color_light_off(pbsys_status_light_main);
#endif

return pbsys_main_program_request_start(PBIO_PYBRICKS_USER_PROGRAM_ID_REPL, PBSYS_MAIN_PROGRAM_START_REQUEST_TYPE_BOOT);
}

#endif // PBSYS_CONFIG_HMI_BUILDHAT