Lumitronix_Iflex_Pro_Workshop
Library to interact with the iFlexPro
RowMajorAlternatingLayout.h
Go to the documentation of this file.
1 /*-------------------------------------------------------------------------
2 RowMajorAlternatingLayout provides a collection of class objects that are used with NeoTopology
3 object.
4 They define the specific layout of pixels and do the math to change the 2d
5 cordinate space to 1d cordinate space
6 
7 Written by Michael C. Miller.
8 
9 I invest time and resources providing this open source code,
10 please support me by dontating (see https://github.com/Makuna)
11 
12 -------------------------------------------------------------------------
13 This file is part of the LUMITRONIX_iFlex_Workshop library.
14 
15 LumitronixIFlexBus is free software: you can redistribute it and/or modify
16 it under the terms of the GNU Lesser General Public License as
17 published by the Free Software Foundation, either version 3 of
18 the License, or (at your option) any later version.
19 
20 LumitronixIFlexBus is distributed in the hope that it will be useful,
21 but WITHOUT ANY WARRANTY; without even the implied warranty of
22 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 GNU Lesser General Public License for more details.
24 
25 You should have received a copy of the GNU Lesser General Public
26 License along with LumitronixIFlex. If not, see
27 <http://www.gnu.org/licenses/>.
28 -------------------------------------------------------------------------*/
29 #pragma once
30 
31 
34 
36 {
37 public:
42 };
43 
44 // layout example of 4x4
45 // 00 01 02 03
46 // 07 06 05 04
47 // 08 09 10 11
48 // 15 14 13 12
49 //
51 {
52 public:
53  static uint16_t Map(uint16_t width, uint16_t /* height */, uint16_t x, uint16_t y)
54  {
55  uint16_t index = y * width;
56 
57  if (y & 0x0001)
58  {
59  index += ((width - 1) - x);
60  }
61  else
62  {
63  index += x;
64  }
65  return index;
66  }
67 };
68 
69 // layout example of 4x4
70 // 15 08 07 00
71 // 14 09 06 01
72 // 13 10 05 02
73 // 12 11 04 03
74 //
76 {
77 public:
78  static uint16_t Map(uint16_t width, uint16_t height, uint16_t x, uint16_t y)
79  {
80  uint16_t mx = ((width - 1) - x);
81  uint16_t index = mx * height;
82 
83  if (mx & 0x0001)
84  {
85  index += ((height - 1) - y);
86  }
87  else
88  {
89  index += y;
90  }
91  return index;
92  }
93 };
94 
95 // layout example of 4x4
96 // 12 13 14 15
97 // 11 10 09 08
98 // 04 05 06 07
99 // 03 02 01 00
100 //
102 {
103 public:
104  static uint16_t Map(uint16_t width, uint16_t height, uint16_t x, uint16_t y)
105  {
106  uint16_t my = ((height - 1) - y);
107  uint16_t index = my * width;
108 
109  if (my & 0x0001)
110  {
111  index += x;
112  }
113  else
114  {
115  index += ((width - 1) - x);
116  }
117  return index;
118  }
119 };
120 
121 // layout example of 4x4
122 // 03 04 11 12
123 // 02 05 10 13
124 // 01 06 09 14
125 // 00 07 08 15
126 //
128 {
129 public:
130  static uint16_t Map(uint16_t /* width */, uint16_t height, uint16_t x, uint16_t y)
131  {
132  uint16_t index = x * height;
133 
134  if (x & 0x0001)
135  {
136  index += y;
137  }
138  else
139  {
140  index += ((height - 1) - y);
141  }
142  return index;
143  }
144 };
Definition: RowMajorAlternatingLayout.h:102
static uint16_t Map(uint16_t width, uint16_t height, uint16_t x, uint16_t y)
Definition: RowMajorAlternatingLayout.h:104
Definition: RowMajorAlternatingLayout.h:128
static uint16_t Map(uint16_t, uint16_t height, uint16_t x, uint16_t y)
Definition: RowMajorAlternatingLayout.h:130
Definition: RowMajorAlternatingLayout.h:76
static uint16_t Map(uint16_t width, uint16_t height, uint16_t x, uint16_t y)
Definition: RowMajorAlternatingLayout.h:78
Definition: RowMajorAlternatingLayout.h:51
static uint16_t Map(uint16_t width, uint16_t, uint16_t x, uint16_t y)
Definition: RowMajorAlternatingLayout.h:53
Definition: RowMajorAlternatingLayout.h:36
RowMajorAlternating270Layout EvenRowEvenColumnLayout
Definition: RowMajorAlternatingLayout.h:38
RowMajorAlternating90Layout OddRowEvenColumnLayout
Definition: RowMajorAlternatingLayout.h:40
RowMajorAlternating90Layout OddRowOddColumnLayout
Definition: RowMajorAlternatingLayout.h:41
RowMajorAlternating270Layout EvenRowOddColumnLayout
Definition: RowMajorAlternatingLayout.h:39