Mark2020H

using paralo arduino for voidrealms example

Mar 30th, 2020
345
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Program to exercise the MD_Parola library
  2. //
  3. // MD_MAX72XX library can be found at https://github.com/MajicDesigns/MD_MAX72XX
  4. //
  5.  
  6. #include <MD_Parola.h>
  7. #include <MD_MAX72xx.h>
  8. #include <SPI.h>
  9.  
  10. #include "Parola_Fonts_data.h"
  11.  
  12. // Define the number of devices we have in the chain and the hardware interface
  13. // NOTE: These pin numbers will probably not work with your hardware and may
  14. // need to be adapted
  15. #define HARDWARE_TYPE MD_MAX72XX::PAROLA_HW
  16. #define MAX_DEVICES 11
  17.  
  18. #define CLK_PIN   13
  19. #define DATA_PIN  11
  20. #define CS_PIN    10
  21.  
  22. // HARDWARE SPI
  23. MD_Parola P = MD_Parola(HARDWARE_TYPE, CS_PIN, MAX_DEVICES);
  24. // SOFTWARE SPI
  25. //MD_Parola P = MD_Parola(HARDWARE_TYPE, DATA_PIN, CLK_PIN, CS_PIN, MAX_DEVICES);
  26.  
  27. #define PAUSE_TIME  3000
  28.  
  29. // Turn on debug statements to the serial output
  30. #define  DEBUG  0
  31.  
  32. #if  DEBUG
  33. #define PRINT(s, x) { Serial.print(F(s)); Serial.print(x); }
  34. #define PRINTS(x) Serial.print(F(x))
  35. #define PRINTX(s, x) { Serial.print(F(s)); Serial.print(x, HEX); }
  36. #else
  37. #define PRINT(s, x)
  38. #define PRINTS(x)
  39. #define PRINTX(s, x)
  40. #endif
  41.  
  42. // Global variables
  43. typedef struct
  44. {
  45.   char  name[10];
  46.   MD_MAX72XX::fontType_t *pFont;
  47.   textEffect_t effect;
  48.   const char * pMsg;
  49. } message_t;
  50.  
  51. const message_t M[] =
  52. {
  53.   { "Roman",    nullptr,      PA_SCROLL_LEFT,  "Arduino" },
  54.   { "Japanese", fontKatakana, PA_SCROLL_LEFT,  "\x0b1\x0b0\x0c2\x0b2\x0c9" },
  55.   { "Arabic",   fontArabic,   PA_SCROLL_RIGHT, "\x0a9\x0a7\x0ab\x0a9\x090\x0a5\x088" },     // ا ر د و ي ن و
  56.   { "Greek",    fontGreek,    PA_SCROLL_LEFT,  "\x080\x0a8\x09b\x0b2\x0a0\x0a4\x0a6" }
  57. };
  58.  
  59. uint8_t curM = 0;   // current message definition to use
  60.  
  61. void setup(void)
  62. {
  63.   Serial.begin(57600);
  64.   PRINTS("\n[Parola Demo]");
  65.  
  66.   P.begin();
  67.   P.setFont(M[curM].pFont);
  68.   P.displayText(M[curM].pMsg, PA_CENTER, P.getSpeed(), PAUSE_TIME, PA_SCROLL_LEFT, PA_SCROLL_LEFT);
  69. }
  70.  
  71. void loop(void)
  72. {
  73.   if (P.displayAnimate())
  74.   {
  75.     curM = (curM + 1) % ARRAY_SIZE(M);
  76.  
  77.     PRINT("\nChanging font to ", M[curM].name);
  78.     PRINTS(", msg data ");
  79.     for (uint8_t i = 0; i<strlen(M[curM].pMsg); i++)
  80.     {
  81.       PRINTX(" 0x", (uint8_t)M[curM].pMsg[i]);
  82.     }
  83.  
  84.     P.setFont(M[curM].pFont);
  85.     P.setTextBuffer(M[curM].pMsg);
  86.     P.setTextEffect(M[curM].effect, M[curM].effect);
  87.  
  88.     P.displayReset();
  89.   }
  90. }
Add Comment
Please, Sign In to add comment