AP_Common: added setonoff() method for bitmask

This commit is contained in:
Andrew Tridgell 2022-10-10 11:37:30 +11:00 committed by Randy Mackay
parent 04fb0b8ebc
commit 1a49c33a4a
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]));