2dom / PxMatrix

Adafruit GFX compatible graphics driver for LED matrix panels
BSD 3-Clause "New" or "Revised" License
849 stars 172 forks source link

P10 32x16 1/4 Scan, 3535 - Text has flipped upper half #317

Closed intelviper closed 1 year ago

intelviper commented 1 year ago

I connected P10 1/4 Scan 3535 RGB LED Matrix as per connection diagram.

When I print text, the top half gets rotated in ZIGZAG Mode and is then pushed into display. Attached Pic/Pattern test video.

Any help would be much appreciated. Thanks!

Rules

  1. Post your code
#include <PxMatrix.h>

// Pins for LED MATRIX
#define P_LAT 22
#define P_A 19
#define P_B 23
#define P_C 18
#define P_D 5
#define P_E 15
#define P_OE 16
hw_timer_t* timer = NULL;
portMUX_TYPE timerMux = portMUX_INITIALIZER_UNLOCKED;

#define MATRIX_WIDTH 32
#define MATRIX_HEIGHT 16

// This defines the 'on' time of the display is us. The larger this number,
// the brighter the display. If too large the ESP will crash
uint8_t display_draw_time = 10;  //30-60 is usually fine

PxMATRIX display(32, 16, P_LAT, P_OE, P_A, P_B, P_C);

// Some standard colors
uint16_t myRED = display.color565(255, 0, 0);
uint16_t myGREEN = display.color565(0, 255, 0);
uint16_t myBLUE = display.color565(0, 0, 255);
uint16_t myWHITE = display.color565(255, 255, 255);
uint16_t myYELLOW = display.color565(255, 255, 0);
uint16_t myCYAN = display.color565(0, 255, 255);
uint16_t myMAGENTA = display.color565(255, 0, 255);
uint16_t myBLACK = display.color565(0, 0, 0);

uint16_t myCOLORS[8] = { myRED, myGREEN, myBLUE, myWHITE, myYELLOW, myCYAN, myMAGENTA, myBLACK };

void IRAM_ATTR display_updater() {
  // Increment the counter and set the time of ISR
  portENTER_CRITICAL_ISR(&timerMux);
  display.display(display_draw_time);
  portEXIT_CRITICAL_ISR(&timerMux);
}

void display_update_enable(bool is_enable) {
  if (is_enable) {
    timer = timerBegin(0, 80, true);
    timerAttachInterrupt(timer, &display_updater, true);
    timerAlarmWrite(timer, 2000, true);
    timerAlarmEnable(timer);
  } else {
    timerDetachInterrupt(timer);
    timerAlarmDisable(timer);
  }
}

void setup() {

  Serial.begin(9600);
  // Define your display layout here, e.g. 1/8 step, and optional SPI pins begin(row_pattern, CLK, MOSI, MISO, SS)
  display.begin(4);
  display.setFastUpdate(true);

  // Set the multiplex pattern {LINE, ZIGZAG,ZZAGG, ZAGGIZ, WZAGZIG, VZAG, ZAGZIG} (default is LINE)
  display.setScanPattern(ZIGZAG);
  display.clearDisplay();
  display.setTextColor(myGREEN);
  display.setCursor(2, 0);
  display.print("ABCDE");
  display.setTextColor(myMAGENTA);
  display.setCursor(2, 8);
  display.print("FGHIJ");
  display_update_enable(true);
  yield();
}

void loop() {
  delay(100);
}
  1. Post a picture of the problem and describe what you expect to see P10-3535-Display

  2. Run the pattern test and post the result as gif/video (need to have a bit more than one full RED/YELLOW/WHITE cycle)

https://user-images.githubusercontent.com/27574370/227803845-302df194-88a0-4af0-be6b-dc546c294ba2.mp4

  1. State what version of PxMatrix you are running and what MicroController you use Version 1.8.2 on ESP32 Wroom Chipset.
intelviper commented 1 year ago

Solved this by adding below code in line #856

if (_scan_pattern==ZIGZAG)
      bit_select = 7-bit_select;

This solved the flipped first row. And now all examples and code are working fine.

I even managed to use this library in https://github.com/donnersm/FFT_ESP32_Analyzer and made it to work with this.