Skip to content

Commit 8b2e3f5

Browse files
committed
pbio/sys/status: Rename pbio_pybricks_status_t.
The status used to be just flags, but contains other statuses too now. Rename the flag part to pbio_pybricks_status_flags_t to make this a bit clearer.
1 parent 5c4df78 commit 8b2e3f5

File tree

4 files changed

+13
-13
lines changed

4 files changed

+13
-13
lines changed

lib/pbio/include/pbio/protocol.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ typedef enum {
235235
* Status report event.
236236
*
237237
* The payload is one 32-bit little-endian unsigned integer containing
238-
* ::pbio_pybricks_status_t flags and a one byte program identifier
238+
* ::pbio_pybricks_status_flags_t flags and a one byte program identifier
239239
* representing the currently active program if it is running.
240240
*
241241
* @since Pybricks Profile v1.0.0. Program identifier added in Pybricks Profile v1.4.0.
@@ -331,12 +331,12 @@ typedef enum {
331331
PBIO_PYBRICKS_STATUS_BLE_HOST_CONNECTED = 9,
332332
/** Total number of indications. */
333333
NUM_PBIO_PYBRICKS_STATUS,
334-
} pbio_pybricks_status_t;
334+
} pbio_pybricks_status_flags_t;
335335

336336
/**
337337
* Converts a status value to a bit flag.
338338
*
339-
* @param [in] status A ::pbio_pybricks_status_t value.
339+
* @param [in] status A ::pbio_pybricks_status_flags_t value.
340340
* @return A bit flag corresponding to @p status.
341341
*/
342342
#define PBIO_PYBRICKS_STATUS_FLAG(status) (1 << status)

lib/pbio/include/pbsys/status.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@
1717
#define PBSYS_STATUS_REPORT_SIZE 7
1818

1919
void pbsys_status_set_program_id(pbio_pybricks_user_program_id_t program_id);
20-
void pbsys_status_set(pbio_pybricks_status_t status);
21-
void pbsys_status_clear(pbio_pybricks_status_t status);
22-
bool pbsys_status_test(pbio_pybricks_status_t status);
23-
bool pbsys_status_test_debounce(pbio_pybricks_status_t status, bool state, uint32_t ms);
20+
void pbsys_status_set(pbio_pybricks_status_flags_t status);
21+
void pbsys_status_clear(pbio_pybricks_status_flags_t status);
22+
bool pbsys_status_test(pbio_pybricks_status_flags_t status);
23+
bool pbsys_status_test_debounce(pbio_pybricks_status_flags_t status, bool state, uint32_t ms);
2424
uint32_t pbsys_status_get_flags(void);
2525
uint32_t pbsys_status_get_status_report(uint8_t *buf);
2626
void pbsys_status_increment_selected_slot(bool increment);

lib/pbio/sys/status.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ static struct {
2828
pbio_pybricks_user_program_id_t slot;
2929
} pbsys_status;
3030

31-
static void pbsys_status_update_flag(pbio_pybricks_status_t status, bool set) {
31+
static void pbsys_status_update_flag(pbio_pybricks_status_flags_t status, bool set) {
3232
uint32_t new_flags = set ? pbsys_status.flags | PBIO_PYBRICKS_STATUS_FLAG(status) : pbsys_status.flags & ~PBIO_PYBRICKS_STATUS_FLAG(status);
3333

3434
if (pbsys_status.flags == new_flags) {
@@ -112,7 +112,7 @@ void pbsys_status_set_program_id(pbio_pybricks_user_program_id_t program_id) {
112112
* Sets a system status status indication.
113113
* @param [in] status The status indication to set.
114114
*/
115-
void pbsys_status_set(pbio_pybricks_status_t status) {
115+
void pbsys_status_set(pbio_pybricks_status_flags_t status) {
116116
assert(status < NUM_PBIO_PYBRICKS_STATUS);
117117
pbsys_status_update_flag(status, true);
118118
}
@@ -121,7 +121,7 @@ void pbsys_status_set(pbio_pybricks_status_t status) {
121121
* Clears a system status status indication.
122122
* @param [in] status The status indication to clear.
123123
*/
124-
void pbsys_status_clear(pbio_pybricks_status_t status) {
124+
void pbsys_status_clear(pbio_pybricks_status_flags_t status) {
125125
assert(status < NUM_PBIO_PYBRICKS_STATUS);
126126
pbsys_status_update_flag(status, false);
127127
}
@@ -131,7 +131,7 @@ void pbsys_status_clear(pbio_pybricks_status_t status) {
131131
* @param [in] status The status indication to to test.
132132
* @return *true* if @p status is set, otherwise *false*.
133133
*/
134-
bool pbsys_status_test(pbio_pybricks_status_t status) {
134+
bool pbsys_status_test(pbio_pybricks_status_flags_t status) {
135135
assert(status < NUM_PBIO_PYBRICKS_STATUS);
136136
return !!(pbsys_status.flags & PBIO_PYBRICKS_STATUS_FLAG(status));
137137
}
@@ -148,7 +148,7 @@ bool pbsys_status_test(pbio_pybricks_status_t status) {
148148
* @return *true* if @p status has been set to @p state for at
149149
* least @p ms, otherwise *false*.
150150
*/
151-
bool pbsys_status_test_debounce(pbio_pybricks_status_t status, bool state, uint32_t ms) {
151+
bool pbsys_status_test_debounce(pbio_pybricks_status_flags_t status, bool state, uint32_t ms) {
152152
assert(status < NUM_PBIO_PYBRICKS_STATUS);
153153
if (pbsys_status_test(status) != state) {
154154
return false;

lib/pbio/test/sys/test_status.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ static PT_THREAD(test_status(struct pt *pt)) {
3636
process_start(&status_test_process);
3737

3838
// use the last valid flag for edge case
39-
static const pbio_pybricks_status_t test_flag = NUM_PBIO_PYBRICKS_STATUS - 1;
39+
static const pbio_pybricks_status_flags_t test_flag = NUM_PBIO_PYBRICKS_STATUS - 1;
4040

4141
// ensure flags are initialized as unset
4242
tt_want(!pbsys_status_test(test_flag));

0 commit comments

Comments
 (0)