Skip to content

Commit 7426d0b

Browse files
committed
pbio/sys/status: Add setter for slot.
1 parent 759ad58 commit 7426d0b

2 files changed

Lines changed: 19 additions & 0 deletions

File tree

lib/pbio/include/pbsys/status.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ bool pbsys_status_test_debounce(pbio_pybricks_status_flags_t status, bool state,
2222
uint32_t pbsys_status_get_flags(void);
2323
uint32_t pbsys_status_get_status_report(uint8_t *buf);
2424
void pbsys_status_increment_selected_slot(bool increment);
25+
void pbsys_status_set_selected_slot(uint8_t slot);
2526
pbio_pybricks_user_program_id_t pbsys_status_get_selected_slot(void);
2627

2728
#endif // _PBSYS_STATUS_H_

lib/pbio/sys/status.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,24 @@ void pbsys_status_increment_selected_slot(bool increment) {
9898
#endif
9999
}
100100

101+
/**
102+
* Sets the currently active slot if it is valid.
103+
*
104+
* @param [in] slot Slot id to set.
105+
*/
106+
void pbsys_status_set_selected_slot(uint8_t slot) {
107+
#if PBSYS_CONFIG_HMI_NUM_SLOTS
108+
if (pbsys_status_test(PBIO_PYBRICKS_STATUS_FILE_IO_IN_PROGRESS)) {
109+
return;
110+
}
111+
112+
if (slot < PBSYS_CONFIG_HMI_NUM_SLOTS) {
113+
pbsys_status.slot = slot;
114+
pbsys_status_update_emit();
115+
}
116+
#endif
117+
}
118+
101119
/**
102120
* Gets the currently selected program slot.
103121
*

0 commit comments

Comments
 (0)