Lumitronix_Iflex_Pro_Workshop
Library to interact with the iFlexPro
ColumnMajorAlternatingLayout.h
Go to the documentation of this file.
1 /*-------------------------------------------------------------------------
2 ColumnMajorAlternatingLayout 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 07 08 15
46 // 01 06 09 14
47 // 02 05 10 13
48 // 03 04 11 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 = x * height;
56 
57  if (x & 0x0001)
58  {
59  index += ((height - 1) - y);
60  }
61  else
62  {
63  index += y;
64  }
65  return index;
66  }
67 };
68 
69 // layout example of 4x4
70 // 03 02 01 00
71 // 04 05 06 07
72 // 11 10 09 08
73 // 12 13 14 15
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 index = y * width;
81 
82  if (y & 0x0001)
83  {
84  index += x;
85  }
86  else
87  {
88  index += ((width - 1) - x);
89  }
90  return index;
91  }
92 };
93 
94 // layout example of 4x4
95 // 12 11 04 03
96 // 13 10 05 02
97 // 14 09 06 01
98 // 15 08 07 00
99 //
101 {
102 public:
103  static uint16_t Map(uint16_t width, uint16_t height, uint16_t x, uint16_t y)
104  {
105  uint16_t mx = ((width - 1) - x);
106  uint16_t index = mx * height;
107 
108  if (mx & 0x0001)
109  {
110  index += y;
111  }
112  else
113  {
114  index += ((height - 1) - y);
115  }
116  return index;
117  }
118 };
119 
120 // layout example of 4x4
121 // 15 14 13 12
122 // 08 09 10 11
123 // 07 06 05 04
124 // 00 01 02 03
125 //
127 {
128 public:
129  static uint16_t Map(uint16_t width, uint16_t height, uint16_t x, uint16_t y)
130  {
131  uint16_t my = ((height - 1) - y);
132  uint16_t index = my * width;
133 
134  if (my & 0x0001)
135  {
136  index += ((width - 1) - x);
137  }
138  else
139  {
140  index += x;
141  }
142  return index;
143  }
144 };
Definition: ColumnMajorAlternatingLayout.h:101
static uint16_t Map(uint16_t width, uint16_t height, uint16_t x, uint16_t y)
Definition: ColumnMajorAlternatingLayout.h:103
Definition: ColumnMajorAlternatingLayout.h:127
static uint16_t Map(uint16_t width, uint16_t height, uint16_t x, uint16_t y)
Definition: ColumnMajorAlternatingLayout.h:129
Definition: ColumnMajorAlternatingLayout.h:76
static uint16_t Map(uint16_t width, uint16_t, uint16_t x, uint16_t y)
Definition: ColumnMajorAlternatingLayout.h:78
Definition: ColumnMajorAlternatingLayout.h:51
static uint16_t Map(uint16_t, uint16_t height, uint16_t x, uint16_t y)
Definition: ColumnMajorAlternatingLayout.h:53
Definition: ColumnMajorAlternatingLayout.h:36
ColumnMajorAlternating180Layout OddRowEvenColumnLayout
Definition: ColumnMajorAlternatingLayout.h:40
ColumnMajorAlternatingLayout EvenRowOddColumnLayout
Definition: ColumnMajorAlternatingLayout.h:39
ColumnMajorAlternating180Layout OddRowOddColumnLayout
Definition: ColumnMajorAlternatingLayout.h:41
ColumnMajorAlternatingLayout EvenRowEvenColumnLayout
Definition: ColumnMajorAlternatingLayout.h:38