2 * This file is part of INAV.
4 * INAV is free software. You can redistribute this software
5 * and/or modify this software under the terms of the
6 * GNU General Public License as published by the Free Software
7 * Foundation, either version 3 of the License, or (at your option)
10 * INAV is distributed in the hope that they will be
11 * useful, but WITHOUT ANY WARRANTY; without even the implied
12 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 * See the GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this software.
18 * If not, see <http://www.gnu.org/licenses/>.
25 // tristate_e represents something that can take a default AUTO
26 // value and two explicit ON and OFF values. To ease the transition
27 // from boolean settings (0 = OFF, 1 = ON), the 1 value has
28 // been picked as ON while OFF is represented by 2. AUTO is represented
36 // tristateWithDefaultOnIsActive returns false is tristate is TRISTATE_OFF
37 // and true otherwise.
38 static inline bool tristateWithDefaultOnIsActive(tristate_e tristate
)
40 return tristate
!= TRISTATE_OFF
;
43 // tristateWithDefaultOffIsActive returns true is tristate is TRISTATE_ON
44 // and false otherwise.
45 static inline bool tristateWithDefaultOffIsActive(tristate_e tristate
)
47 return tristate
== TRISTATE_ON
;
50 // tristateWithDefaultIsActive() calls tristateWithDefaultOnIsActive() when
51 // def is true, and tristateWithDefaultOffIsActive() otherwise.
52 // See tristateWithDefaultOnIsActive() and tristateWithDefaultOffIsActive()
53 static inline bool tristateWithDefaultIsActive(tristate_e tristate
, bool def
)
55 return def
? tristateWithDefaultOnIsActive(tristate
) : tristateWithDefaultOffIsActive(tristate
);