Skip to content

Commit 1503fcc

Browse files
committed
pbio/sys/light: Don't pass unused status data around.
This was passed to the light status update function, but it does the same regardless of setting or clearing. This is not related to the pbsys_status_set function, which takes a bool for set/clear. So pbsys_status_change_t made things a bit confusing now that it is no longer used.
1 parent e4936a5 commit 1503fcc

File tree

6 files changed

+6
-26
lines changed

6 files changed

+6
-26
lines changed

lib/pbio/include/pbsys/status.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,6 @@
1616

1717
#define PBSYS_STATUS_REPORT_SIZE 7
1818

19-
/**
20-
* Status flag change.
21-
*/
22-
typedef enum {
23-
/** System status indicator was set. */
24-
PBSYS_STATUS_CHANGE_SET,
25-
/** System status indicator was cleared. */
26-
PBSYS_STATUS_CHANGE_CLEARED,
27-
} pbsys_status_change_t;
28-
2919
void pbsys_status_set_program_id(pbio_pybricks_user_program_id_t program_id);
3020
void pbsys_status_set(pbio_pybricks_status_t status);
3121
void pbsys_status_clear(pbio_pybricks_status_t status);

lib/pbio/sys/hmi.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,6 @@ void pbsys_hmi_init(void) {
4242
pbsys_hub_light_matrix_init();
4343
}
4444

45-
void pbsys_hmi_handle_status_change(pbsys_status_change_t event, pbio_pybricks_status_t data) {
46-
pbsys_status_light_handle_status_change(event, data);
47-
}
48-
4945
/**
5046
* Polls the HMI.
5147
*

lib/pbio/sys/hmi.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
#include <pbsys/status.h>
99

1010
void pbsys_hmi_init(void);
11-
void pbsys_hmi_handle_status_change(pbsys_status_change_t event, pbio_pybricks_status_t data);
1211
void pbsys_hmi_poll(void);
1312
pbio_error_t pbsys_hmi_await_program_selection(void);
1413

lib/pbio/sys/light.c

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ void pbsys_status_light_init(void) {
182182
#endif
183183
}
184184

185-
static void pbsys_status_light_update_patterns(void) {
185+
void pbsys_status_light_handle_status_change(void) {
186186

187187
// Warning pattern precedence.
188188
pbsys_status_light_indication_warning_t warning_indication = PBSYS_STATUS_LIGHT_INDICATION_WARNING_NONE;
@@ -222,12 +222,6 @@ static void pbsys_status_light_update_patterns(void) {
222222
}
223223
}
224224

225-
void pbsys_status_light_handle_status_change(pbsys_status_change_t event, pbio_pybricks_status_t data) {
226-
if (event == PBSYS_STATUS_CHANGE_SET || event == PBSYS_STATUS_CHANGE_CLEARED) {
227-
pbsys_status_light_update_patterns();
228-
}
229-
}
230-
231225
/**
232226
* Advances the light to the next state in the pattern.
233227
*

lib/pbio/sys/light.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@
1111

1212
#if PBSYS_CONFIG_STATUS_LIGHT
1313
void pbsys_status_light_init(void);
14-
void pbsys_status_light_handle_status_change(pbsys_status_change_t event, pbio_pybricks_status_t data);
14+
void pbsys_status_light_handle_status_change(void);
1515
void pbsys_status_light_poll(void);
1616
#else
1717
#define pbsys_status_light_init()
18-
#define pbsys_status_light_handle_status_change(event, data)
18+
#define pbsys_status_light_handle_status_change()
1919
#define pbsys_status_light_poll()
2020
#endif
2121

lib/pbio/sys/status.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include <pbsys/status.h>
1616

1717
#include "hmi.h"
18+
#include "light.h"
1819

1920
static struct {
2021
/** Status indications as bit flags */
@@ -38,10 +39,10 @@ static void pbsys_status_update_flag(pbio_pybricks_status_t status, bool set) {
3839
pbsys_status.flags = new_flags;
3940
pbsys_status.changed_time[status] = pbdrv_clock_get_ms();
4041

41-
// hmi is the only subscriber to status changes, so call its handler
42+
// status light is the only subscriber to status changes, so call its handler
4243
// directly. All other processes just poll the status as needed. If we ever
4344
// need more subscribers, we could register callbacks and call them here.
44-
pbsys_hmi_handle_status_change(set ? PBSYS_STATUS_CHANGE_SET : PBSYS_STATUS_CHANGE_CLEARED, status);
45+
pbsys_status_light_handle_status_change();
4546

4647
// Other processes may be awaiting status changes, so poll.
4748
pbio_os_request_poll();

0 commit comments

Comments
 (0)