0

Problem: LED Matrix Orientation using DotStarMatrix Library
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Problem: LED Matrix Orientation using DotStarMatrix Library

by GhostStop on Tue Sep 10, 2019 12:07 pm

So, I can't seem to get the orientation to change on a 8x8 LED Matrix display.

From what I gather in the documentation, I should be able to set any corner as the 0 pixel, thereby allowing for setting the orientation of the matrix as we wish. The library says you can change to top/bottom, left/right, rows/columns, etc. But nothing seems to change at all when I adjust this.

I'm using this display: https://www.adafruit.com/product/3444

This is (or should be) done using DS_MATRIX_LEFT or DS_MATRIX_RIGHT as needed. But it's not working for me. What am I doing wrong?

To explain, I'm using this 8x8 display as an indicator for a sensor pointing in the oposite direction. If they were both pointing the same way, it would look great using the default settings. However, when turning the display so the user can see it, naturally, everything is mirrored in the wrong direction. So, I need to swap the orientation of the LEDs.

I hope that explains things well.

CODE below (simplified to narrow down the problem)

Code: Select all | TOGGLE FULL SIZE

#include <SPI.h>
#include <Adafruit_GFX.h>
#include <Adafruit_DotStarMatrix.h>
#include <Adafruit_DotStar.h>

#define DATAPIN  4
#define CLOCKPIN 5

Adafruit_DotStarMatrix matrix = Adafruit_DotStarMatrix(
  8, 8, DATAPIN, CLOCKPIN,
  DS_MATRIX_TOP + DS_MATRIX_LEFT + DS_MATRIX_ROWS + DS_MATRIX_ZIGZAG,
  DOTSTAR_BRG);

  uint32_t MatrixRed = matrix.Color(100, 0, 0);     //GRB

void setup() {
  matrix.begin();

}

void loop() {
 
// TESTING MATRIX STUFF --------------------------------------------------------------
      matrix.setPixelColor(0, MatrixRed);
      matrix.show();
      delay(100);
      matrix.setPixelColor(1, MatrixRed);
      matrix.show();
      delay(100);
      matrix.setPixelColor(2, MatrixRed);
      matrix.show();
      delay(100);
      matrix.setPixelColor(3, MatrixRed);
      matrix.show();
      delay(100);
      matrix.setPixelColor(4, MatrixRed);
      matrix.show();
      delay(100);
      matrix.setPixelColor(5, MatrixRed);
      matrix.show();
      delay(100);
      matrix.setPixelColor(6, MatrixRed);
      matrix.show();
      delay(100);
      matrix.setPixelColor(7, MatrixRed);
      matrix.show();
      delay(100);
      matrix.setPixelColor(8, MatrixRed);
      matrix.show();
      delay(100);
      matrix.setPixelColor(9, MatrixRed);
      matrix.show();
      delay(100);
      matrix.setPixelColor(10, MatrixRed);
      matrix.show();
      delay(100);
      matrix.setPixelColor(11, MatrixRed);
      matrix.show();
      delay(100);
      matrix.setPixelColor(12, MatrixRed);
      matrix.show();
      delay(100);
      matrix.setPixelColor(13, MatrixRed);
      matrix.show();
      delay(100);
      matrix.setPixelColor(14, MatrixRed);
      matrix.show();
      delay(100);
      matrix.setPixelColor(15, MatrixRed);
      matrix.show();
      delay(100);
      matrix.setPixelColor(16, MatrixRed);
      matrix.show();
      delay(100);
      matrix.setPixelColor(17, MatrixRed);
      matrix.show();
      delay(100000000);
               
// ---------------------------------------------------------------------------------------------

}


GhostStop
 
Posts: 2
Joined: Fri Sep 06, 2019 12:33 pm

Re: Problem: LED Matrix Orientation using DotStarMatrix Libr

by dastels on Tue Sep 10, 2019 1:56 pm

The reason you're not seeing any difference is that you are directly accessing specific pixels by using setPixelColor. Using that, pixel 0 is always the first one in the chain, pixel 1 is always the second, etc. The orientation control only effects row/column access using the drawPixel method of the DotStarMatrix class. So if you do something like this (changing the pins as appropriate) you can change the TOP/BOTTOM and LEFT/RIGHT settings and see the difference.

Code: Select all | TOGGLE FULL SIZE
#include <SPI.h>
#include <Adafruit_GFX.h>
#include <Adafruit_DotStarMatrix.h>
#include <Adafruit_DotStar.h>

#define DATAPIN  9
#define CLOCKPIN 7

Adafruit_DotStarMatrix matrix = Adafruit_DotStarMatrix(
                                  8, 8, DATAPIN, CLOCKPIN,
                                  DS_MATRIX_BOTTOM + DS_MATRIX_RIGHT + DS_MATRIX_ROWS,
                                  DOTSTAR_BRG);

uint32_t GREEN = matrix.Color(100, 0, 0);     //GRB
uint32_t BLACK = matrix.Color(0, 0, 0);     //GRB

void setup() {
  matrix.begin();

}

void loop() {

  // TESTING MATRIX STUFF --------------------------------------------------------------
  matrix.fillScreen(BLACK);
  for (int x = 0; x < 8; x++) {
    for (int y = 0; y < 8; y++) {
      matrix.drawPixel(x, y, GREEN);
      matrix.show();
      delay(100);
    }
  }
  // ---------------------------------------------------------------------------------------------

}

dastels
 
Posts: 219
Joined: Tue Oct 20, 2015 3:22 pm

Re: Problem: LED Matrix Orientation using DotStarMatrix Libr

by GhostStop on Tue Sep 10, 2019 4:42 pm

Ah ha! That makes sense. I'll give that a go. Thanks for the quick input!

GhostStop
 
Posts: 2
Joined: Fri Sep 06, 2019 12:33 pm

Please be positive and constructive with your questions and comments.