LSH-Core
Deterministic firmware core for Controllino-based Labo Smart Home nodes
 
Loading...
Searching...
No Matches
click_detection.hpp
Go to the documentation of this file.
1
21#ifndef LSH_CORE_UTIL_CONSTANTS_CLICK_DETECTION_HPP
22#define LSH_CORE_UTIL_CONSTANTS_CLICK_DETECTION_HPP
23
24#include <stdint.h>
25
26namespace constants
27{
28namespace clickDetection
29{
30static constexpr uint8_t SHORT_ENABLED = 0x01U;
31static constexpr uint8_t LONG_ENABLED = 0x02U;
32static constexpr uint8_t SUPER_LONG_ENABLED = 0x04U;
33static constexpr uint8_t QUICK_SHORT = 0x08U;
34
35[[nodiscard]] constexpr inline auto hasFlag(uint8_t flags, uint8_t flag) noexcept -> bool
36{
37 return (flags & flag) != 0U;
38}
39
40[[nodiscard]] constexpr inline auto makeFlags(bool shortEnabled, bool longEnabled, bool superLongEnabled) noexcept -> uint8_t
41{
42 return static_cast<uint8_t>((shortEnabled ? SHORT_ENABLED : 0U) | (longEnabled ? LONG_ENABLED : 0U) |
43 (superLongEnabled ? SUPER_LONG_ENABLED : 0U) |
44 ((shortEnabled && !longEnabled && !superLongEnabled) ? QUICK_SHORT : 0U));
45}
46} // namespace clickDetection
47} // namespace constants
48
49#endif // LSH_CORE_UTIL_CONSTANTS_CLICK_DETECTION_HPP
Namespace that groups compile-time constants.
Definition config.hpp:33