Lumitronix_Iflex_Pro_Workshop
Library to interact with the iFlexPro
RowMajorLayout.h
Go to the documentation of this file.
1 /*-------------------------------------------------------------------------
2 RowMajorLayout 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 class RowMajorLayout;
32 class RowMajor90Layout;
33 class RowMajor180Layout;
34 class RowMajor270Layout;
35 
37 {
38 public:
43 };
44 
45 // layout example of 4x4
46 // 00 01 02 03
47 // 04 05 06 07
48 // 08 09 10 11
49 // 12 13 14 15
50 //
52 {
53 public:
54  static uint16_t Map(uint16_t width, uint16_t /* height */, uint16_t x, uint16_t y)
55  {
56  return x + y * width;
57  }
58 };
59 
60 // layout example of 4x4
61 // 12 08 04 00
62 // 13 09 05 01
63 // 14 10 06 02
64 // 15 11 07 03
65 //
67 {
68 public:
69  static uint16_t Map(uint16_t width, uint16_t height, uint16_t x, uint16_t y)
70  {
71  return (width - 1 - x) * height + y;
72  }
73 };
74 
75 // layout example of 4x4
76 // 15 14 13 12
77 // 11 10 09 08
78 // 07 06 05 04
79 // 03 02 01 00
80 //
82 {
83 public:
84  static uint16_t Map(uint16_t width, uint16_t height, uint16_t x, uint16_t y)
85  {
86  return (width - 1 - x) + (height - 1 - y) * width;
87  }
88 };
89 
90 // layout example of 4x4
91 // 03 07 11 15
92 // 02 06 10 14
93 // 01 05 09 13
94 // 00 04 08 12
95 //
97 {
98 public:
99  static uint16_t Map(uint16_t /* width */, uint16_t height, uint16_t x, uint16_t y)
100  {
101  return x * height + (height - 1 - y);
102  }
103 };
Definition: RowMajorLayout.h:82
static uint16_t Map(uint16_t width, uint16_t height, uint16_t x, uint16_t y)
Definition: RowMajorLayout.h:84
Definition: RowMajorLayout.h:97
static uint16_t Map(uint16_t, uint16_t height, uint16_t x, uint16_t y)
Definition: RowMajorLayout.h:99
Definition: RowMajorLayout.h:67
static uint16_t Map(uint16_t width, uint16_t height, uint16_t x, uint16_t y)
Definition: RowMajorLayout.h:69
Definition: RowMajorLayout.h:52
static uint16_t Map(uint16_t width, uint16_t, uint16_t x, uint16_t y)
Definition: RowMajorLayout.h:54
Definition: RowMajorLayout.h:37
RowMajor270Layout EvenRowOddColumnLayout
Definition: RowMajorLayout.h:40
RowMajorLayout EvenRowEvenColumnLayout
Definition: RowMajorLayout.h:39
RowMajor90Layout OddRowEvenColumnLayout
Definition: RowMajorLayout.h:41
RowMajor180Layout OddRowOddColumnLayout
Definition: RowMajorLayout.h:42