Smart Camera ESP32
An AI-driven, real-time Sentry Turret platform leveraging asynchronous I/O and computer vision to deliver high-precision autonomous motion tracking on resource-constrained embedded hardware.
Loading...
Searching...
No Matches
move_types.h
1
8#pragma once
9
10#include <stdint.h>
11
16enum class MoveXValue : uint8_t {
17 None = 0,
18 Right = 1,
19 Left = 2
20};
21
26enum class MoveYValue : uint8_t {
27 None = 0,
28 Up = 1,
29 Down = 2
30};
31
37template <typename EnumType> class MoveDirection
38{
39public:
44 constexpr MoveDirection(EnumType v) : _value(v) {}
45
47 bool is_none() const { return static_cast<uint8_t>(_value) == 0; }
48
50 EnumType get_value() const { return _value; }
51
53 bool operator!() const { return is_none(); }
54
56 operator uint8_t() const { return static_cast<uint8_t>(_value); }
57
59 bool operator==(EnumType v) const { return _value == v; }
60
62 bool operator!=(EnumType v) const { return _value != v; }
63
64protected:
65 EnumType _value;
66};
67
72class MoveX : public MoveDirection<MoveXValue>
73{
74public:
76 static constexpr MoveXValue None = MoveXValue::None;
78 static constexpr MoveXValue Right = MoveXValue::Right;
80 static constexpr MoveXValue Left = MoveXValue::Left;
81
83 using MoveDirection<MoveXValue>::MoveDirection;
84
86 constexpr MoveX() : MoveDirection(MoveXValue::None) {}
87
92 const char* to_string() const
93 {
94 switch (this->_value)
95 {
96 case MoveXValue::Right:
97 return "Right";
98 case MoveXValue::Left:
99 return "Left";
100 default:
101 return "None";
102 }
103 }
104};
105
110class MoveY : public MoveDirection<MoveYValue>
111{
112public:
114 static constexpr MoveYValue None = MoveYValue::None;
116 static constexpr MoveYValue Up = MoveYValue::Up;
118 static constexpr MoveYValue Down = MoveYValue::Down;
119
121 using MoveDirection<MoveYValue>::MoveDirection;
122
124 constexpr MoveY() : MoveDirection(MoveYValue::None) {}
125
130 const char* to_string() const
131 {
132 switch (this->_value)
133 {
134 case MoveYValue::Up:
135 return "Up";
136 case MoveYValue::Down:
137 return "Down";
138 default:
139 return "None";
140 }
141 }
142};
Base template providing common logic for movement directions.
Definition move_types.h:38
EnumType _value
Definition move_types.h:65
bool operator==(EnumType v) const
Equality comparison with underlying enum.
Definition move_types.h:59
constexpr MoveDirection(EnumType v)
Construct a new Move Direction object.
Definition move_types.h:44
bool operator!() const
Logical NOT operator.
Definition move_types.h:53
bool operator!=(EnumType v) const
Inequality comparison with underlying enum.
Definition move_types.h:62
bool is_none() const
Checks if the movement state is None (0).
Definition move_types.h:47
EnumType get_value() const
Gets the underlying enum value.
Definition move_types.h:50
Encapsulates horizontal movement states and utility methods.
Definition move_types.h:73
static constexpr MoveXValue None
Local alias for None state.
Definition move_types.h:76
static constexpr MoveXValue Right
Local alias for Right state.
Definition move_types.h:78
constexpr MoveX()
Default constructor initializing to None.
Definition move_types.h:86
static constexpr MoveXValue Left
Local alias for Left state.
Definition move_types.h:80
const char * to_string() const
Converts the state to a human-readable string.
Definition move_types.h:92
Encapsulates vertical movement states and utility methods.
Definition move_types.h:111
static constexpr MoveYValue Up
Local alias for Up state.
Definition move_types.h:116
constexpr MoveY()
Default constructor initializing to None.
Definition move_types.h:124
const char * to_string() const
Converts the state to a human-readable string.
Definition move_types.h:130
static constexpr MoveYValue None
Local alias for None state.
Definition move_types.h:114
static constexpr MoveYValue Down
Local alias for Down state.
Definition move_types.h:118