| 24 | |
| 25 | |
| 26 | uint16_t XY( uint8_t x, uint8_t y) |
| 27 | { |
| 28 | uint16_t i; |
| 29 | |
| 30 | if( kMatrixSerpentineLayout == false) { |
| 31 | i = (y * kMatrixWidth) + x; |
| 32 | } |
| 33 | |
| 34 | if( kMatrixSerpentineLayout == true) { |
| 35 | if( y & 0x01) { |
| 36 | // Odd rows run backwards |
| 37 | uint8_t reverseX = (kMatrixWidth - 1) - x; |
| 38 | i = (y * kMatrixWidth) + reverseX; |
| 39 | } else { |
| 40 | // Even rows run forwards |
| 41 | i = (y * kMatrixWidth) + x; |
| 42 | } |
| 43 | } |
| 44 | |
| 45 | return i; |
| 46 | } |
| 47 | |
| 48 | // The 32bit version of our coordinates |
| 49 | static uint16_t x; |