Professional Documents
Culture Documents
Use The Parola Library To Scroll Text On The Display
Use The Parola Library To Scroll Text On The Display
//
//
// User can enter text on the serial monitor and this will display as a
//
//
#include <MD_Parola.h>
#include <MD_MAX72xx.h>
#include <SPI.h>
#define USE_UI_CONTROL 0
#if USE_UI_CONTROL
#include <MD_UISwitch.h>
#endif
#if DEBUG
#else
#define PRINT(s, x)
#define PRINTS(x)
#define PRINTX(x)
#endif
// Define the number of devices we have in the chain and the hardware interface
// NOTE: These pin numbers will probably not work with your hardware and may
// need to be adapted
#define MAX_DEVICES 4
#define CLK_PIN 13
#define DATA_PIN 11
#define CS_PIN 10
// HARDWARE SPI
// SOFTWARE SPI
// Scrolling parameters
#if USE_UI_CONTROL
#endif // USE_UI_CONTROL
uint8_t scrollSpeed = 40
#define BUF_SIZE 75
#if USE_UI_CONTROL
MD_UISwitch_Digital uiDirection(DIRECTION_SET);
MD_UISwitch_Digital uiInvert(INVERT_SET);
void doUI(void)
{
// set the speed if it has changed
P.setSpeed(speed);
scrollSpeed = speed;
P.setTextEffect(scrollEffect, scrollEffect);
P.displayClear();
P.displayReset();
P.setInvert(!P.getInvert());
}
}
#endif // USE_UI_CONTROL
void readSerial(void)
while (Serial.available())
*cp = (char)Serial.read();
if ((*cp == '\n') || (cp - newMessage >= BUF_SIZE-2)) // end of message character or full buffer
// restart the index for next filling spree and flag we have a message waiting
cp = newMessage;
newMessageAvailable = true;
cp++;
void setup()
Serial.begin(57600);
uiDirection.begin();
uiInvert.begin();
pinMode(SPEED_IN, INPUT);
doUI();
#endif // USE_UI_CONTROL
P.begin();
void loop()
#if USE_UI_CONTROL
doUI();
#endif // USE_UI_CONTROL
if (P.displayAnimate())
if (newMessageAvailable)
strcpy(curMessage, newMessage);
newMessageAvailable = false;
P.displayReset();
}
readSerial();