MajicDesigns / MD_Parola

Library for modular scrolling LED matrix text displays
GNU Lesser General Public License v2.1
428 stars 135 forks source link

Pixel errors and display reset #117

Closed cjjaeckson closed 9 months ago

cjjaeckson commented 10 months ago

Subject of the issue

Problems with pixel errors after an undefined period of time.

Your Environment

Library Version:3.7.1 Arduino IDE version:1.8.19 Host OS and Version:? CPU Hardware model/type: MEGA 2560

Steps to Reproduce

Display works without problems at first. After a longer time, there are pixel artifacts. Mostly in the lower rows. I have attached a picture.

20231023_112528

Expected Behaviour

The present code reads a lidar sensor and shows the result on the display. The values of the sensor are intended for level determination of a ton. If the signal of the lidar is too low, "Signal!" is displayed; if the signal is good, the fill level of the ton is displayed as a percentage value. If the ton is overfilled, "Error!" and every second LED flashes alternately.

Actual Behaviour

After a undefined period of time random leds are shining. Mostly last row. I've tried several things to avoid that behaviour. When the microcontroller is reset, the pixel errors are gone. Therefore I tried to find a way to reset the display in a certain time interval in the code. The function for this is attached.

Code Demonstrating the Issue

// Percentage
void displayMessage(int inpPercentage) {
  static char message[BUF_SIZE];
  static char lastMessage[BUF_SIZE] = "";

  itoa(inpPercentage, message, 10);
  strcat(message, " %");

  if (strcmp(message, lastMessage) != 0) {  
    mx.displayClear();
    mx.setTextAlignment(PA_CENTER);
    mx.write(message);
    strcpy(lastMessage, message);    
    Serial.print("Schreibe Wert: ");
    Serial.println(inpPercentage);
  }

// Signal
mx.displayClear();
mx.setTextAlignment(PA_CENTER);
mx.write("Signal!");

// Error (blinkstate is changed every second by timer interrupt
mx.displayClear();
if (blinkstate) {
        mx.setTextAlignment(PA_CENTER);
        mx.write("Fehler!");
 } else {
        //to light all the LEDs
        for (uint8_t device = 0; device < MAX_DEVICES; device++) {
          for (uint8_t row = 0; row < 8; row++) {
            for (uint8_t col = (row % 2 == 0) ? 0 : 1; col < 8; col += 2) {
              mx.getGraphicObject()->setPoint(row, device * 8 + col, true);
            }
          }
        }
      }
}

// Display reset (every minute)
void resetDisplay(){
  mx.displayShutdown(true);
  delay(100);
  mx.displayShutdown(false);
}

I hope someone can help! Thanks a lot! :)

MajicDesigns commented 10 months ago

displayShutdopwn() does not do what you think it does. Try just clearing the display.

These kinds of problems are usually caused by wiring problems. Have you got the pull up/down resistor (can't remember which) on the comms control signals (just google this and there are lots of references). Other issues are voltage fluctuations for the display supply (eg, electromechanical devices being powered by the same power supply).