From 23405811b82279f902f2cc7b168466f101d17edc Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 10 Oct 2022 11:37:30 +1100 Subject: [PATCH] AP_Common: added setonoff() method for bitmask --- libraries/AP_Common/Bitmask.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/libraries/AP_Common/Bitmask.h b/libraries/AP_Common/Bitmask.h index 32f9f79012..233d1b3e26 100644 --- a/libraries/AP_Common/Bitmask.h +++ b/libraries/AP_Common/Bitmask.h @@ -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]));