FastLED 3.9.15
Loading...
Searching...
No Matches

◆ XY()

uint16_t XY ( uint8_t x,
uint8_t y )

Definition at line 94 of file XYMatrix.ino.

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

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