/
nicodim4
/
EncButton
Обзор
Документация
Войти
/
nicodim4
/
EncButton
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/core/flags.h
33 строки
841 B
AlexGyver
upd
01 июл 2026, 16:52
01 июл 2026, 16:52
93c307d
Код
Авторство
О чём код?
#pragma once #include <Arduino.h> namespace encb { template <typename T> struct Flags { volatile T flags = 0; inline T mask(const T x) __attribute__((always_inline)) { return flags & x; } inline void set(const T x) __attribute__((always_inline)) { flags |= x; } inline void clear(const T x) __attribute__((always_inline)) { flags &= ~x; } inline bool read(const T x) __attribute__((always_inline)) { return flags & x; } inline void write(const T x, const bool v) __attribute__((always_inline)) { v ? set(x) : clear(x); } inline bool eq(const T x, const T y) __attribute__((always_inline)) { return (flags & x) == y; } inline bool all(const T x) __attribute__((always_inline)) { return eq(x, x); } }; } // namespace encb