FastLED 3.10.8
Loading...
Searching...
No Matches

◆ XY()

uint16_t XY ( uint8_t x,
uint8_t y )

Definition at line 100 of file XYMatrix.ino.

101{
102 uint16_t i;
103
104 if( kMatrixSerpentineLayout == false) {
105 if (kMatrixVertical == false) {
106 i = (y * kMatrixWidth) + x;
107 } else {
108 i = kMatrixHeight * (kMatrixWidth - (x+1))+y;
109 }
110 }
111
112 if( kMatrixSerpentineLayout == true) {
113 if (kMatrixVertical == false) {
114 if( y & 0x01) {
115 // Odd rows run backwards
116 uint8_t reverseX = (kMatrixWidth - 1) - x;
117 i = (y * kMatrixWidth) + reverseX;
118 } else {
119 // Even rows run forwards
120 i = (y * kMatrixWidth) + x;
121 }
122 } else { // vertical positioning
123 if ( x & 0x01) {
124 i = kMatrixHeight * (kMatrixWidth - (x+1))+y;
125 } else {
126 i = kMatrixHeight * (kMatrixWidth - x) - (y+1);
127 }
128 }
129 }
130
131 return i;
132}
int y
Definition simple.h:93
int x
Definition simple.h:92
#define kMatrixSerpentineLayout
#define kMatrixHeight
#define kMatrixWidth
const bool kMatrixVertical
Definition XYMatrix.ino:45
unsigned char uint8_t
Definition stdint.h:208
fl::u16 uint16_t
Definition stdint.h:213

References kMatrixHeight, kMatrixSerpentineLayout, kMatrixVertical, kMatrixWidth, x, and y.