Parola - Scrolling animations across 4 zones

OK here is my code (and it works fine) however at the very end of my code is "if (token == 0)" .
I want to run scrolling text (a list of animations) across all 4 zones if the "if" is true.

SoftwareSerial SUART(9, 5);  //SRX = 10, STX = 11
char myData[20];
char *token;

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

#define HARDWARE_TYPE MD_MAX72XX::FC16_HW
#define MAX_DEVICES 12
#define NUM_ZONES 4
#define CLK_PIN 13
#define DATA_PIN 11
#define CS_PIN 10
MD_Parola P = MD_Parola(HARDWARE_TYPE, CS_PIN, MAX_DEVICES);

int P1Total = 0;  // Stores Player 1 Total Games Won
int P2Total = 0;  // Stores Player 2 Total Games Won

void setup() {

  Serial.begin(9600);
  SUART.begin(38400);  //38400 for scoreboard "Slave 4"

  P.begin(NUM_ZONES);
  P.setZone(0, 0, 3);
  P.setZone(1, 4, 5);
  P.setZone(2, 6, 7);
  P.setZone(3, 8, 11);

  P.setIntensity(2);
}

void loop() {

  byte n = SUART.available();
  if (n != 0) {
    char ch = SUART.read();
    if (ch == '<')  //start mark found
    {
      byte m = SUART.readBytesUntil('>', myData, sizeof myData - 1);
      myData[m] = '\0';  //null-charcater
      Serial.println(myData);
      //--------------------------
      token = strtok(myData, ",");
      char BTLed1 = *token;
      Serial.println(BTLed1);  // LED1
      //-------------------------
      token = strtok(NULL, ",");
      char BTLed2 = *token;
      Serial.println(token);  // LED2
      //-------------------------
      token = strtok(NULL, ",");
      int BTScore1 = atoi(token);
      Serial.println(BTScore1, DEC);  // Player 1 Score
      //-------------------------
      token = strtok(NULL, ",");
      int BTScore2 = atoi(token);
      Serial.println(BTScore2, DEC);  // Player 2 Score
      //-------------------------

      if (BTScore1 == 0) {
        P.displayClear(3);
        P.displayZoneText(3, ("-PEG-"), PA_CENTER, 0, 0, PA_PRINT, PA_NO_EFFECT);
        P.displayAnimate();

      } else if (BTScore2 == 0) {
        P.displayClear(0);
        P.displayZoneText(0, ("-PEG-"), PA_CENTER, 0, 0, PA_PRINT, PA_NO_EFFECT);
        P.displayAnimate();
      }

      else {

        String score1Str = String(BTScore1);
        String score2Str = String(BTScore2);

        P.displayZoneText(0, score2Str.c_str(), PA_CENTER, 0, 0, PA_PRINT, PA_NO_EFFECT);
        P.displayZoneText(3, score1Str.c_str(), PA_CENTER, 0, 0, PA_PRINT, PA_NO_EFFECT);
        P.displayAnimate();
      }
      //-------------------------

      if (BTLed1 == 'A') {
        P.displayClear(1);
        P.displayZoneText(2, ("<-"), PA_CENTER, 0, 0, PA_PRINT, PA_NO_EFFECT);
        P.displayAnimate();
      }

      if (BTLed2 == 'C') {
        P.displayClear(2);
        P.displayZoneText(1, ("->"), PA_CENTER, 0, 0, PA_PRINT, PA_NO_EFFECT);
        P.displayAnimate();
      }

      if (BTScore1 == 0) P1Total = P1Total + 1;
      {
        Serial.println(P1Total, DEC);
      }

      if (BTScore2 == 0) P2Total = P2Total + 1;
      {
        Serial.println(P2Total, DEC);
      }

      if (BTScore1 == 0 || BTScore2 == 0) {
        P.displayClear(1);
        P.displayClear(2);
        String total1Str = String(P1Total);
        String total2Str = String(P2Total);

        P.displayZoneText(1, total2Str.c_str(), PA_CENTER, 0, 0, PA_PRINT, PA_NO_EFFECT);
        P.displayZoneText(2, total1Str.c_str(), PA_CENTER, 0, 0, PA_PRINT, PA_NO_EFFECT);
        P.displayAnimate();
      }
    }
  }
  if (token == 0) {
    P.displayZoneText(0, ("--=={}"), PA_CENTER, 0, 0, PA_PRINT, PA_NO_EFFECT);
    P.displayZoneText(1, ("={}"), PA_CENTER, 0, 0, PA_PRINT, PA_NO_EFFECT);
    P.displayZoneText(2, ("--="), PA_RIGHT, 0, 0, PA_PRINT, PA_NO_EFFECT);
    P.displayZoneText(3, ("--=={}"), PA_CENTER, 0, 0, PA_PRINT, PA_NO_EFFECT);
    P.displayAnimate();
  }
}

I also have this code that works on its own but i cant get them to work together .


#include <MD_Parola.h>
#include <MD_MAX72xx.h>

#define HARDWARE_TYPE MD_MAX72XX::FC16_HW
#define MAX_DEVICES 12
#define CLK_PIN 13
#define DATA_PIN 11
#define CS_PIN 10

MD_Parola P = MD_Parola(HARDWARE_TYPE, CS_PIN, MAX_DEVICES);

struct animations {
  textEffect_t anim_in;   // Animation type
  textEffect_t anim_out;  // Animation type
  const char* textOut;    // Text to display
  uint16_t speed;         // Animation   speed (multiplier for library default)
  uint16_t pause;         // pause   (multiplier for library default)
  textPosition_t just;
};


animations animList[] = {
  { PA_SCROLL_LEFT, PA_SCROLL_UP_RIGHT, "--=={} --=={} --=={}", 1, 6, PA_LEFT },
  { PA_RANDOM, PA_RANDOM, "Glen's   Darts   Comp ", 1, 8, PA_LEFT },
  { PA_SCROLL_LEFT, PA_SCROLL_UP_RIGHT, "--=={} --=={} --=={}", 1, 6, PA_LEFT },
  { PA_SCROLL_LEFT, PA_SCROLL_LEFT, "Lets  throw  some  Darts!", 2, 0, PA_LEFT },
};


void setup() {
  P.begin();

  for (uint8_t i = 0; i < ARRAY_SIZE(animList); i++) {
    animList[i].speed *= P.getSpeed();
    animList[i].pause *= 500;
  }
}


void loop() {
  static uint8_t i = 0;  // text effect index

  if (P.displayAnimate())  //   animates and returns true when an animation is completed
  {
    if (i == ARRAY_SIZE(animList)) i = 0;  // reset loop index

    P.displayText(animList[i].textOut, animList[i].just, animList[i].speed,
                  animList[i].pause, animList[i].anim_in, animList[i].anim_out);
    delay(1000);
    i++;  // then set up for next   text effect
  }
}

What does it do now? I just tried... It does not compile because it is incomplete (missing #include).

I got it to work after adding the missing part. It shows a static form of the text field near "token =="

 P.displayZoneText(0, ("--=={}"), PA_CENTER, 0, 0, PA_PRINT, PA_NO_EFFECT);

How did you intend for it to work?

Sorry try putting on line 1 of the first code

#include <SoftwareSerial.h>

I have just put static text (graphics) after "token==0" but i want it to display scrolling text (and graphics) that is on the second lot of code

I see the "NO_EFFECT" in that same group of statements. Take a look at the scrolling text on this simulation...

Not quite
I want the first part of the code to work just as is (using 4 zones to display 4 lots of info)
but if I don't have any bluetooth input the "token==0" becomes true - so then run scrolling text across all 4 zones (is in use use the 4 zones as 1 zone)
this will only be used when i first power the unit on - when I have received a bluetooth input then the program runs 4 zones.
not sure if I am explaining it properly?

You give no drawings, no description of the 12 panel configuration, 3x4, 4x3, wrap, serpentine, no first panel... and "Not quite." Whut-ev, bruh.

where did that come from??
I meant no disrespect - in my ignorance I thought we where trying to find a solution.

@Glen_Lewis

Hi,
You simply need to set a fifth zone.

So set NUM_ZONES to 5

Then add...

P.setZone(4, 0, 11); then scroll what you want across that. Obviously you can't use the other
zones at the same time :slightly_smiling_face:

1 Like

That's great - I will have a play around with it :slight_smile:
Thank you indev2

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.