/*
 * MD_Parola Transitions
 * Author: Abran DRozario
 */
#include <MD_Parola.h>
#include <MD_MAX72xx.h>

#define HARDWARE_TYPE MD_MAX72XX::PAROLA_HW
#define MAX_DEVICES 8
#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_MESH, PA_BLINDS, "Mini Golf", 2, 2, PA_CENTER },
  { PA_SLICE, PA_PRINT, "Gardens", 0, 5, PA_CENTER },
  { PA_SCROLL_LEFT, PA_SCROLL_LEFT, "2 Colonnade Rd, Nepean, ON K2E 7M6", 5, 0, PA_LEFT },
  { PA_SCROLL_LEFT, PA_SCROLL_LEFT, "Welcome to Mini Golf Gardens", 5, 0, PA_LEFT },
  { PA_SCROLL_LEFT, PA_SCROLL_LEFT, "Voted Ottawa is the #1 Best Miniature Golf Course", 5, 0, PA_LEFT },
  { PA_SCROLL_LEFT, PA_SCROLL_LEFT, "An Oasis on Merivale at Colonnade Road, we offer two beautifully landscaped 18 hole miniature golf courses, complete with water features and manicured gardens, which provide fun for all ages and skill levels.", 5, 0, PA_LEFT },
  { PA_SCROLL_LEFT, PA_SCROLL_LEFT, "A great place for group outings and parties with a large sitting area and plenty of free parking.", 5, 0, PA_LEFT },
  { PA_SCROLL_LEFT, PA_SCROLL_LEFT, "We are easily accessible in the city, at the west end (Merivale and Colonnade).", 5, 0, PA_LEFT },
  { PA_SCROLL_LEFT, PA_SCROLL_LEFT, "Open until midnight during the summer (last tee-off is 45 minutes before closing). Snack Bar offering drinks, chips and ice cream products.", 5, 0, PA_LEFT },
  { PA_SCROLL_LEFT, PA_SCROLL_LEFT, "Hours of Operation", 5, 0, PA_LEFT },
  { PA_SCROLL_LEFT, PA_SCROLL_LEFT, "May, Sunday to Thursday 10am -10pm Friday to Saturday 10am - midnight", 5, 0, PA_LEFT },
  { PA_SCROLL_LEFT, PA_SCROLL_LEFT, "June through August 7 days a week 10am - midnight", 5, 0, PA_LEFT },
  { PA_SCROLL_LEFT, PA_SCROLL_LEFT, "September Sunday to Thursday 10am -10pm Friday to Saturday 10am - midnight", 5, 0, PA_LEFT },
  { PA_SCROLL_LEFT, PA_SCROLL_LEFT, "October Friday to Sunday 10am to 10pm", 5, 0, PA_LEFT },
  { PA_SCROLL_LEFT, PA_SCROLL_LEFT, "Final day of the season", 5, 0, PA_LEFT },
  { PA_SCROLL_LEFT, PA_SCROLL_LEFT, "Thanksgiving Monday: 10AM-5PM", 5, 0, PA_LEFT },
  { PA_SCROLL_LEFT, PA_SCROLL_LEFT, "For more info, Call (613) 723-5359", 5, 0, PA_LEFT },
};

void setup() {
  P.begin();
  Serial.begin(9600);
  Serial.println("Loading...");
  Serial.println("Loaded.");
  Serial.println("Welcome to Mini Golf Gardens!");
  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(500);
    i++;   // then set up for next text effect
  }    

}