Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/FastLED/FastLED.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormwhch <manuel.weiss@protonmail.ch>2020-09-12 05:32:16 +0300
committermwhch <manuel.weiss@protonmail.ch>2020-09-12 05:32:16 +0300
commit51683f97738ea10e40ab5df0d728da3ee13bb89c (patch)
treec6956ea05a84cc1697928301589d876c54e977f0 /examples
parent3a1d880fb7abe5308950358cc1493c5b9e97e3eb (diff)
implemented the option to place the matrix vertically
Diffstat (limited to 'examples')
-rw-r--r--examples/XYMatrix/XYMatrix.ino29
1 files changed, 21 insertions, 8 deletions
diff --git a/examples/XYMatrix/XYMatrix.ino b/examples/XYMatrix/XYMatrix.ino
index 53c21411..010ffe7c 100644
--- a/examples/XYMatrix/XYMatrix.ino
+++ b/examples/XYMatrix/XYMatrix.ino
@@ -30,6 +30,7 @@ const uint8_t kMatrixHeight = 16;
// Param for different pixel layouts
const bool kMatrixSerpentineLayout = true;
+const bool kMatrixVertical = false;
// Set 'kMatrixSerpentineLayout' to false if your pixels are
// laid out all running the same way, like this:
//
@@ -88,17 +89,29 @@ uint16_t XY( uint8_t x, uint8_t y)
uint16_t i;
if( kMatrixSerpentineLayout == false) {
- i = (y * kMatrixWidth) + x;
+ if (kMatrixVertical == false) {
+ i = (y * kMatrixWidth) + x;
+ } else {
+ i = kMatrixHeight * (kMatrixWidth - (x+1))+y;
+ }
}
if( kMatrixSerpentineLayout == true) {
- if( y & 0x01) {
- // Odd rows run backwards
- uint8_t reverseX = (kMatrixWidth - 1) - x;
- i = (y * kMatrixWidth) + reverseX;
- } else {
- // Even rows run forwards
- i = (y * kMatrixWidth) + x;
+ if (kMatrixVertical == false) {
+ if( y & 0x01) {
+ // Odd rows run backwards
+ uint8_t reverseX = (kMatrixWidth - 1) - x;
+ i = (y * kMatrixWidth) + reverseX;
+ } else {
+ // Even rows run forwards
+ i = (y * kMatrixWidth) + x;
+ }
+ } else { // vertical positioning
+ if ( x & 0x01) {
+ i = kMatrixHeight * (kMatrixWidth - (x+1))+y;
+ } else {
+ i = kMatrixHeight * (kMatrixWidth - x) - (y+1);
+ }
}
}