Turn a Flag On with OR
Mark a repair complete
You have used AND to read a flag. To turn one on, use bitwise OR (|): it produces a 1 wherever either input has a 1. A 1 in the mask sets that position; a 0 leaves the existing bit unchanged. The panel's current low bits are 0001; the completion mask is 0100.
c
#include <stdio.h>
int main(void) {
unsigned int flags = 0x1u;
unsigned int complete = 0x4u;
flags = flags | complete;
printf("Flags: %u\n", flags);
printf("Complete: %u\n", (unsigned int) ((flags & complete) != 0u));
return 0;
}
OR combines 0001 and 0100 into 0101, or 5 in decimal. A second assignment flags = flags | complete; would leave 5 unchanged because that bit is already on. flags |= complete; is the shorter compound-assignment spelling. OR sets selected bits; it does not toggle them.