pixled-lib  1.0
mapping.h
1 #ifndef PIXLED_MAPPING_H
2 #define PIXLED_MAPPING_H
3 
4 #include "../mapping.h"
5 
6 namespace pixled {
7 
11  namespace mapping {
18  std::ostream& operator<<(std::ostream& o, const Mapping& m);
19 
26  class TurtleMapping : public Mapping {
27  private:
28  point turtle_position {0, 0};
29  angle turtle_orientation = angle::fromDeg(0.);
30  index_t current_led_index = 0;
31  void moveTo(point p, index_t num_led);
32 
33  public:
37  point position() const;
41  angle orientation() const;
45  index_t ledIndex() const;
46 
47 
72  void forward(coordinate distance, index_t num_led = 0);
78  void turnLeft(angle angle);
84  void turnRight(angle angle);
85 
92  void jump(point p);
93  };
94 
98  class LedStrip : public TurtleMapping {
99  private:
100  std::vector<point> coordinates;
101  index_t length;
102  public:
108  LedStrip(index_t length);
109 
115  index_t getLength() const {
116  return length;
117  }
118  };
119 
129  LEFT_RIGHT_LEFT_RIGHT_FROM_BOTTOM,
130  LEFT_RIGHT_RIGHT_LEFT_FROM_BOTTOM,
131  RIGHT_LEFT_RIGHT_LEFT_FROM_BOTTOM,
132  RIGHT_LEFT_LEFT_RIGHT_FROM_BOTTOM,
133  LEFT_RIGHT_LEFT_RIGHT_FROM_TOP,
134  LEFT_RIGHT_RIGHT_LEFT_FROM_TOP,
135  RIGHT_LEFT_RIGHT_LEFT_FROM_TOP,
136  RIGHT_LEFT_LEFT_RIGHT_FROM_TOP,
137  TOP_DOWN_TOP_DOWN_FROM_LEFT,
138  TOP_DOWN_DOWN_TOP_FROM_LEFT,
139  DOWN_TOP_DOWN_TOP_FROM_LEFT,
140  DOWN_TOP_TOP_DOWN_FROM_LEFT,
141  TOP_DOWN_TOP_DOWN_FROM_RIGHT,
142  TOP_DOWN_DOWN_TOP_FROM_RIGHT,
143  DOWN_TOP_DOWN_TOP_FROM_RIGHT,
144  DOWN_TOP_TOP_DOWN_FROM_RIGHT
145  };
146 
150  class LedPanel : public TurtleMapping {
151  private:
152  index_t _width;
153  index_t _height;
154 
155  void drawLeftRightLeftRightFromBottom(index_t width, index_t height);
156  void drawRightLeftRightLeftFromBottom(index_t width, index_t height);
157  void drawHorizontalSnakeFromBottom(index_t width, index_t height);
158 
159  void drawLeftRightLeftRightFromTop(index_t width, index_t height);
160  void drawRightLeftRightLeftFromTop(index_t width, index_t height);
161  void drawHorizontalSnakeFromTop(index_t width, index_t height);
162 
163  void drawTopDownTopDownFromLeft(index_t width, index_t height);
164  void drawDownTopDownTopFromLeft(index_t width, index_t height);
165  void drawVerticalSnakeFromLeft(index_t width, index_t height);
166 
167  void drawTopDownTopDownFromRight(index_t width, index_t height);
168  void drawDownTopDownTopFromRight(index_t width, index_t height);
169  void drawVerticalSnakeFromRight(index_t width, index_t height);
170  public:
179 
183  index_t width() const {return _width;}
187  index_t height() const {return _height;}
188  };
189  }
190 }
191 #endif
Definition: geometry.h:52
static angle fromDeg(float value)
Definition: geometry.cpp:11
Definition: mapping.h:150
index_t height() const
Definition: mapping.h:187
index_t width() const
Definition: mapping.h:183
LedPanel(index_t width, index_t height, PANEL_LINKING linking)
Definition: mapping.cpp:121
Definition: mapping.h:98
LedStrip(index_t length)
Definition: mapping.cpp:117
index_t getLength() const
Definition: mapping.h:115
Definition: mapping.h:26
point position() const
Definition: mapping.cpp:90
void forward(coordinate distance, index_t num_led=0)
Definition: mapping.cpp:102
void turnRight(angle angle)
Definition: mapping.cpp:113
angle orientation() const
Definition: mapping.cpp:94
void jump(point p)
Definition: mapping.cpp:86
void turnLeft(angle angle)
Definition: mapping.cpp:109
index_t ledIndex() const
Definition: mapping.cpp:98
PANEL_LINKING
Definition: mapping.h:128
std::ostream & operator<<(std::ostream &o, const Mapping &m)
Definition: mapping.cpp:7
Definition: animation.cpp:3
float distance(const point &p1, const point &p2)
Definition: geometry.cpp:4
std::size_t index_t
Definition: mapping.h:11
float coordinate
Definition: geometry.h:18
Definition: mapping.h:70
Definition: geometry.h:23