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

◆ XY()

uint16_t XY ( uint8_t x,
uint8_t y )

Definition at line 92 of file XYMatrix.ino.

93{
94 uint16_t i;
95
96 if( kMatrixSerpentineLayout == false) {
97 if (kMatrixVertical == false) {
98 i = (y * kMatrixWidth) + x;
99 } else {
100 i = kMatrixHeight * (kMatrixWidth - (x+1))+y;
101 }
102 }
103
104 if( kMatrixSerpentineLayout == true) {
105 if (kMatrixVertical == false) {
106 if( y & 0x01) {
107 // Odd rows run backwards
108 uint8_t reverseX = (kMatrixWidth - 1) - x;
109 i = (y * kMatrixWidth) + reverseX;
110 } else {
111 // Even rows run forwards
112 i = (y * kMatrixWidth) + x;
113 }
114 } else { // vertical positioning
115 if ( x & 0x01) {
116 i = kMatrixHeight * (kMatrixWidth - (x+1))+y;
117 } else {
118 i = kMatrixHeight * (kMatrixWidth - x) - (y+1);
119 }
120 }
121 }
122
123 return i;
124}
uint32_t x[NUM_LAYERS]
Definition Fire2023.ino:80
uint32_t y[NUM_LAYERS]
Definition Fire2023.ino:81
#define kMatrixSerpentineLayout
#define kMatrixHeight
#define kMatrixWidth
const bool kMatrixVertical
Definition XYMatrix.ino:37

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