AP_Common: added setonoff() method for bitmask

This commit is contained in:
Andrew Tridgell 2022-10-10 11:37:30 +11:00
parent 4157ad5c5c
commit 23405811b8
1 changed files with 9 additions and 0 deletions

View File

@ -81,6 +81,15 @@ public:
bits[word] &= ~(1U << ofs);
}
// set given bitnumber to on/off
void setonoff(uint16_t bit, bool onoff) {
if (onoff) {
set(bit);
} else {
clear(bit);
}
}
// clear all bits
void clearall(void) {
memset(bits, 0, numwords*sizeof(bits[0]));