Go Down

Topic: Scrolling LED matrix display - Parola for Arduino (Read 424702 times) previous topic - next topic

PriSim

Do you understand that the second number parameter here (1500)
Code: [Select]
P.displayText(szBuf, PA_CENTER, 50, 1500, PA_PRINT, PA_NO_EFFECT);
is the delay between the end of PA_PRINT and PA_NO_EFFECT?
If you are trying to update a clock every second then having a 1.5 second delay before the animation is finished does not seem like a good idea.
You should probably just use the .print() method for Parola and then update it again after you have detected that 1000ms have passed (like in blink without delay).
Yes that was the main issue, Pause time , I was using it globally for all of my print routines , But now i am using a different pause and speed time for clock display and different for other text routines.
using:

Code: [Select]

 P.setPause();
    P.setSpeed();


Everything is working fine now. Thanks for the Help :)

Azazel32

Greetings I'm implemented Parola Double Height Displays in 2 rows of 8 with serial communication but I can not make the text show someone could help me please correct me, I ask disuculpas for my English my mother tongue is Spanish

I am trying to display the text in a double matrix with serial communication

Code: [Select]


#include <MD_Parola.h>
#include <MD_MAX72xx.h>
#include <SPI.h>
#include "Font_Data.h"

#if USE_GENERIC_HW || USE_PAROLA_HW
#define INVERT_UPPER_ZONE 1
#endif

// Turn debugging on and off
#define DEBUG 1


#if DEBUG
#define PRINTS(s)   { Serial.print(F(s)); }
#define PRINT(s, v) { Serial.print(F(s)); Serial.print(v); }
#else
#define PRINTS(s)
#define PRINT(s, v)
#endif

// Define the main direction for scrolling double height.
// if 1, scroll left; if 0, scroll right
#define SCROLL_LEFT 1

#if INVERT_UPPER_ZONE

#if SCROLL_LEFT // invert and scroll left
#define SCROLL_UPPER  PA_SCROLL_RIGHT
#define SCROLL_LOWER  PA_SCROLL_LEFT
#else           // invert and scroll right
#define SCROLL_UPPER  PA_SCROLL_LEFT
#define SCROLL_LOWER  PA_SCROLL_RIGHT
#endif

#else // not invert

#if SCROLL_LEFT // not invert and scroll left
#define SCROLL_UPPER  PA_SCROLL_LEFT
#define SCROLL_LOWER  PA_SCROLL_LEFT
#else           // not invert and scroll right
#define SCROLL_UPPER  PA_SCROLL_RIGHT
#define SCROLL_LOWER  PA_SCROLL_RIGHT
#endif

#endif


// Define the number of devices we have in the chain and the hardware interface
// NOTE: These pin numbers may not work with your hardware and may need changing
#define HARDWARE_TYPE MD_MAX72XX::FC16_HW
#define MAX_ZONES 2
#define ZONE_SIZE 8
#define MAX_DEVICES (MAX_ZONES * ZONE_SIZE)

#define ZONE_UPPER  1
#define ZONE_LOWER  0

#define PAUSE_TIME 0
#define SCROLL_SPEED 50

#define CLK_PIN   13
#define DATA_PIN  11
#define CS_PIN    10

// HARDWARE SPI
MD_Parola P = MD_Parola(HARDWARE_TYPE, CS_PIN, MAX_DEVICES);
// SOFTWARE SPI
//MD_Parola P = MD_Parola(HARDWARE_TYPE, DATA_PIN, CLK_PIN, CS_PIN, MAX_DEVICES);

#define ARRAY_SIZE(a) (sizeof(a)/sizeof(a[0]))
char *msgL[] =
{
  //"Double height with custom font & 2 zones",
  "HOLA MUNDO",

 //"abcdefghijklmnopqrstuvwxyz",
 //"0123456789",
// "`!@#$%^&*()_+-={};:'<>\"?,./|\\{}",
};
char *msgH; // allocated memory in setup()

void setup(void)
{
  uint8_t max = 0;

#if DEBUG
  Serial.begin(57600);
  PRINTS("\n[Double_Height_v2]");
#endif

  // work out the size of buffer required
  for (uint8_t i = 0; i<ARRAY_SIZE(msgL); i++)
    if (strlen(msgL[i]) > max) max = strlen(msgL[i]);

  msgH = (char *)malloc(sizeof(char)*(max + 2));

  // initialise the LED display
  P.begin(MAX_ZONES);

  // Set up zones for 2 halves of the display
  P.setZone(ZONE_LOWER, 0, ZONE_SIZE - 1);
  P.setZone(ZONE_UPPER, ZONE_SIZE, MAX_DEVICES-1);
  P.setFont(BigFont);
  P.setCharSpacing(P.getCharSpacing() * 2); // double height --> double spacing
#if INVERT_UPPER_ZONE
  P.setZoneEffect(ZONE_UPPER, true, PA_FLIP_UD);
  P.setZoneEffect(ZONE_UPPER, true, PA_FLIP_LR);
#endif
  PRINT("\nFLIP_UD=", P.getZoneEffect(ZONE_UPPER, PA_FLIP_UD));
  PRINT("\nFLIP_LR=", P.getZoneEffect(ZONE_UPPER, PA_FLIP_LR));
  PRINT("\nSCROLL_LEFT=", SCROLL_LEFT);
}

void createHString(char *pH, char *pL)
{
  for (; *pL != '\0'; pL++)
    *pH++ = *pL | 0x80;   // offset character

  *pH = '\0'; // terminate the string
}

void loop(void)
{
  static uint8_t cycle = 0;
    if (Serial.available())
   {
      uint8_t max = 0;
     msgH = Serial.read();
    Serial.println(msgH);

     // work out the size of buffer required
  for (uint8_t i = 0; i<ARRAY_SIZE(msgL); i++)
    if (strlen(msgL[i]) > max) max = strlen(msgL[i]);

  msgH = (char *)malloc(sizeof(char)*(max + 2));

   }



  P.displayAnimate();

  if (P.getZoneStatus(ZONE_LOWER) && P.getZoneStatus(ZONE_UPPER))
  {
    PRINT("\n", cycle);
    PRINT(": ", msgL[cycle]);

    // set up the string
    createHString(msgH, msgL[cycle]);

    P.displayClear();
#if INVERT_UPPER_ZONE
    P.displayZoneText(ZONE_UPPER, msgH, PA_CENTER, SCROLL_SPEED, PAUSE_TIME, SCROLL_UPPER, SCROLL_UPPER);
    P.displayZoneText(ZONE_LOWER, msgL[cycle], PA_CENTER, SCROLL_SPEED, PAUSE_TIME, SCROLL_LOWER, SCROLL_LOWER);
#else
    P.displayZoneText(ZONE_LOWER, msgL[cycle], PA_LEFT, SCROLL_SPEED, PAUSE_TIME, SCROLL_LOWER, SCROLL_LOWER);
    P.displayZoneText(ZONE_UPPER, msgH, PA_LEFT, SCROLL_SPEED, PAUSE_TIME, SCROLL_UPPER, SCROLL_UPPER);
#endif

    // prepare for next pass
    cycle = (cycle + 1) % ARRAY_SIZE(msgL);

    // synchronise the start and run the display
    P.synchZoneStart();
  }
}

marco_c

Quote
can not make the text show
Have you tried just running the example program without your changes. Does this work?

Also, in this part of the code
Code: [Select]
    if (Serial.available())
   {
      uint8_t max = 0;
     msgH = Serial.read();
    Serial.println(msgH);

     // work out the size of buffer required
  for (uint8_t i = 0; i<ARRAY_SIZE(msgL); i++)
    if (strlen(msgL[i]) > max) max = strlen(msgL[i]);

  msgH = (char *)malloc(sizeof(char)*(max + 2));

   }

You need to free() the string before you allocate a new one, otherwise you get a memory leak. Also, you are measuring the size of msgL, which has not changed from the start of the program.

Also, Serial.available() only tells you if there is ONE (or more) characters at the Serial port. You are not constructing the string as it arrives. Please see the Parola_Scrolling example for how this is done reliably.
Arduino Libraries https://github.com/MajicDesigns?tab=Repositories
Parola for Arduino https://github.com/MajicDesigns/Parola
Arduino++ blog https://arduinoplusplus.wordpress.com

Go Up