PS2Keyboard MAX7219 DHT11 DS1307 Arduino Mega
VIDEO
Arduino tutorial : LED Matrix red 16x64 1024 Led driven by MAX7219 PS2Keyboard DS-1307 DHT-11 and Arduino Mega
VCC→5V GND→GND DIN→11 CS →10 CLK→13
Code
// Program to demonstrate the MD_Parola library
// - Optional use of DS1307 module for time and DHT11 sensor for temp and humidity
// - DHT11 library (DHT11) found at https://github.com/RobTillaart/Arduino
// - Optional use of DS1307 module for time
// - DS1307 library (MD_DS1307) found at https://github.com/MajicDesigns/DS1307
// - PS/2 Keyboard library (Keyboard) found at https://github.com/PaulStoffregen/PS2Keyboard
// NOTE: MD_MAX72xx library must be installed and configured for the LED
// matrix type being used. Refer documentation included in the MD_MAX72xx
// library or see this link:
// https://github.com/MajicDesigns/MD_Parola
// https://github.com/MajicDesigns/MD_MAX72XX
// Find All "Great Projects" Videos : https://www.youtube.com/channel/UCCC8DuqicBtP3A_aC53HYDQ/videos
// Use the DS1307 clock module
#define USE_DS1307 0
#include <MD_Parola.h>
#include <MD_MAX72xx.h>
#include <SPI.h>
#include "Font_Data.h"
#include <MD_DS1307.h>
#include <Wire.h>
#include <PS2Keyboard.h>
const int DataPin = 8;
const int IRQpin = 3;
PS2Keyboard keyboard;
// Use the DHT11 temp and humidity sensor
#include <dht.h>
dht DHT;
#define DHT11_PIN 2
float h = 0;
float t = 0;
float f = 0;
static bool flasher = false; // seconds passing flasher
uint8_t scrollSpeed = 0; // default frame delay value
int contrast = 0;
// 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 HARDWARE_TYPE MD_MAX72XX::FC16_HW
#define MAX_DEVICES 16
#define CLK_PIN 13
#define DATA_PIN 11
#define CS_PIN 10
// HARDWARE SPI
//MD_Parola P = MD_Parola(HARDWARE_TYPE, CLK_PIN, CS_PIN, 16);
// SOFTWARE SPI
MD_Parola P = MD_Parola(HARDWARE_TYPE, DATA_PIN, CLK_PIN, CS_PIN, MAX_DEVICES);
// Global message buffers shared by Serial and Scrolling functions
#define BUF_SIZE 75
#define MAX_MESG 75
char curMessage[BUF_SIZE] = { "" };
char newMessage[BUF_SIZE] = { "Hello! Enter new message?" };
bool curMessageAvailable = false;
bool newMessageAvailable = true;
bool ModeAAvailable = true;
bool ModeBAvailable = false;
bool ModeCAvailable = false;
bool ModeHAvailable = false;
bool ModeMAvailable = false;
bool ModeSAvailable = false;
bool ModeDowAvailable = false;
bool ModeDayAvailable = false;
bool ModeMonAvailable = false;
bool ModeYerAvailable = false;
// Global variables
char szTime[9]; // mm:ss\0
char szMesg[MAX_MESG+1] = "";
char szMes[MAX_MESG+1] = "";
char szMeD[MAX_MESG+1] = "";
char szMeM[MAX_MESG+1] = "";
char szMeY[MAX_MESG+1] = "";
char szsecond[4]; // ss
uint8_t degC[] = { 6, 3, 3, 56, 68, 68, 68 }; // Deg C
uint8_t degF[] = { 6, 3, 3, 124, 20, 20, 4 }; // Deg F
void(* resetFunc) (void) = 0;//declare reset function at address 0
char *mon2str(uint8_t mon, char *psz, uint8_t len)
// Get a label from PROGMEM into a char array
{
static const char str[][4] PROGMEM =
{
"Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
};
*psz = '\0';
mon--;
if (mon < 12)
{
strncpy_P(psz, str[mon], len);
psz[len] = '\0';
}
return(psz);
}
char *dow2str(uint8_t code, char *psz, uint8_t len)
{
static const char str[][10] PROGMEM =
{
"Sunday", "Monday", "Tuesday", "Wednesday",
"Thursday", "Friday", "Saturday"
};
*psz = '\0';
code--;
if (code < 7)
{
strncpy_P(psz, str[code], len);
psz[len] = '\0';
}
return(psz);
}
void getHour(char *psz, bool f = true)
// Code for reading clock time
{
if (flasher) {
sprintf(psz, "@@%c%02d", (f ? ':' : ' '), RTC.m);
}
else {
sprintf(psz, "%02d%c%02d", RTC.h, (f ? ':' : ' '), RTC.m);
}
}
void getMinute(char *psz, bool f = true)
// Code for reading clock time
{
if (flasher) {
sprintf(psz, "%02d%c%@@", RTC.h, (f ? ':' : ' '));
}
else {
sprintf(psz, "%02d%c%02d", RTC.h, (f ? ':' : ' '), RTC.m);
}
}
void getSec(char *psz)
// Code for reading clock date
{
if (flasher) {
sprintf(psz, " ");
}
else {
sprintf(psz, "%02d", RTC.s);
}
}
void getTime(char *psz, bool f = true)
// Code for reading clock time
{
RTC.readTime();
sprintf(psz, "%02d%c%02d", RTC.h, (f ? ':' : ' '), RTC.m);
}
void getsecond(char *psz)
// Code for reading clock date
{
sprintf(psz, "%02d", RTC.s);
}
void getDate(char *psz)
// Code for reading clock date
{
char szBuf[10];
sprintf(psz, "%0d %s %04d", RTC.dd, mon2str(RTC.mm, szBuf, sizeof(szBuf)-1), RTC.yyyy);
}
void getTemperature()
{
DHT.read11(DHT11_PIN);
h = DHT.humidity;
t = DHT.temperature;
// Read temperature as Fahrenheit
f = (1.8 * DHT.temperature)+32;
}
void getDow(char *psz)
// Code for reading clock date
{
if (ModeDowAvailable) {
if (flasher) {
sprintf(psz, " ");
}
else {
dow2str(RTC.dow, szMes, MAX_MESG);
}
}
else {
dow2str(RTC.dow, szMes, MAX_MESG);
}
}
void getDay(char *psz)
// Code for reading clock date
{
if (ModeDayAvailable) {
if (flasher) {
sprintf(psz, " ");
}
else {
sprintf(psz, "%02d", RTC.dd);
}
}
else {
sprintf(psz, "%02d", RTC.dd);
}
}
void getMon(char *psz)
// Code for reading clock date
{
if (ModeMonAvailable) {
if (flasher) {
sprintf(psz, " ");
}
else {
char szBuf[4];
sprintf(psz, "%s", mon2str(RTC.mm, szBuf, sizeof(szBuf)-1));
}
}
else {
char szBuf[4];
sprintf(psz, "%s", mon2str(RTC.mm, szBuf, sizeof(szBuf)-1));
}
}
void getYer(char *psz)
// Code for reading clock date
{
if (ModeYerAvailable) {
if (flasher) {
sprintf(psz, " ");
}
else {
sprintf(psz, "%04d", RTC.yyyy);
}
}
else {
sprintf(psz, "%04d", RTC.yyyy);
}
}
void getmodea()
{
// initialise the LED display
P.begin(4);
// Set up zones for 4 halves of the display
// Each zone gets a different font, making up the top
// and bottom half of each letter
P.setZone(0, 0, 1);
P.setZone(1, 2, 7);
P.setZone(2, 10, 15);
P.setZone(3, 8, 9);
P.setFont(0, NULL);
P.setFont(1, BigFontLower);
P.setFont(2, BigFontUpper);
P.setFont(3, NULL);
P.displayZoneText(0, szsecond, PA_CENTER, 0, 0, PA_PRINT, PA_NO_EFFECT);
P.displayZoneText(1, szTime, PA_LEFT, 0, 0, PA_PRINT, PA_NO_EFFECT);
P.displayZoneText(2, szTime, PA_LEFT, 0, 0, PA_PRINT, PA_NO_EFFECT);
P.displayZoneText(3, szMesg, PA_CENTER, scrollSpeed, 0, PA_SCROLL_LEFT, PA_SCROLL_LEFT);
P.addChar('^', degC);
P.addChar('_', degF);
}
void getmodeb()
{
P.begin(2);
// Set up zones for 4 halves of the display
// Each zone gets a different font, making up the top
// and bottom half of each letter
P.setZone(0, 0, 7);
P.setZone(1, 8, 15);
P.setFont(0, BigFontLower);
P.setFont(1, BigFontUpper);
}
void getmodec()
{
P.begin(2);
P.setZone(0, 0, 7);
P.setZone(1, 8, 15);
P.setFont(0, BigFontLower);
P.setFont(1, BigFontUpper);
P.displayZoneText(0, newMessage, PA_LEFT, scrollSpeed, 0, PA_SCROLL_LEFT, PA_SCROLL_LEFT);
P.displayZoneText(1, newMessage, PA_LEFT, scrollSpeed, 0, PA_SCROLL_LEFT, PA_SCROLL_LEFT);
P.displayReset(0);
P.displayReset(1);
}
void getmoded()
{
P.begin(1);
P.setZone(0, 0, 15);
P.setFont(0, NULL);
P.displayZoneText(0, curMessage, PA_LEFT, 0, 0, PA_PRINT, PA_NO_EFFECT);
P.displayReset(0);
}
void getmodee()
{
P.begin(1);
P.setZone(0, 0, 15);
P.setFont(0, NULL);
P.displayZoneText(0, newMessage, PA_LEFT, scrollSpeed, 0, PA_SCROLL_LEFT, PA_SCROLL_LEFT);
P.displayReset(0);
}
void getmodef()
{
// initialise the LED display
P.begin(4);
// Set up zones for 4 halves of the display
// Each zone gets a different font, making up the top
// and bottom half of each letter
P.setZone(0, 0, 2);
P.setZone(1, 3, 5);
P.setZone(2, 6, 7);
P.setZone(3, 8, 15);
P.setFont(0, NULL);
P.setFont(1, NULL);
P.setFont(2, NULL);
P.setFont(3, NULL);
P.displayZoneText(3, szMes, PA_CENTER, 0, 0, PA_PRINT, PA_NO_EFFECT);
P.displayZoneText(0, szMeY, PA_CENTER, 0, 0, PA_PRINT, PA_NO_EFFECT);
P.displayZoneText(2, szMeD, PA_CENTER, 0, 0, PA_PRINT, PA_NO_EFFECT);
P.displayZoneText(1, szMeM, PA_CENTER, 0, 0, PA_PRINT, PA_NO_EFFECT);
}
void readkeyboard(void)
{
if (ModeAAvailable)
{
while (keyboard.available())
{
char c = keyboard.read();
if (c == PS2_ENTER) {
ModeAAvailable = false;
ModeBAvailable = true;
getmodeb();
}
else if (c == PS2_ESC) {
resetFunc();
}
else if (c == PS2_PAGEUP) {
ModeAAvailable = false;
curMessageAvailable = false;
ModeCAvailable = true;
newMessageAvailable = true;
getmodec();
}
else if (c == PS2_PAGEDOWN) {
ModeAAvailable = false;
ModeHAvailable = true;
}
else if (c == PS2_RIGHTARROW) {
scrollSpeed++;
if (scrollSpeed >= 100 ) {
scrollSpeed = 100;
}
P.setSpeed(scrollSpeed);
}
else if (c == PS2_LEFTARROW) {
scrollSpeed--;
if (scrollSpeed <= 0 ) {
scrollSpeed = 0;
}
P.setSpeed(scrollSpeed);
}
else if (c == PS2_UPARROW) {
contrast++;
if (contrast >= 51 ) {
contrast = 50;
}
P.setIntensity(contrast);
}
else if (c == PS2_DOWNARROW) {
contrast--;
if (contrast <= 0 ) {
contrast = 0;
}
P.setIntensity(contrast);
}
}
}
else if (ModeBAvailable)
{
while (keyboard.available())
{
char c = keyboard.read();
if (c == PS2_ENTER) {
ModeBAvailable = false;
ModeAAvailable = true;
getmodea();
}
else if (c == PS2_ESC) {
resetFunc();
}
else if (c == PS2_PAGEUP) {
ModeBAvailable = false;
curMessageAvailable = false;
ModeCAvailable = true;
newMessageAvailable = true;
getmodec();
}
else if (c == PS2_PAGEDOWN) {
ModeBAvailable = false;
ModeHAvailable = true;
getmodea();
}
else if (c == PS2_RIGHTARROW) {
scrollSpeed++;
if (scrollSpeed >= 100 ) {
scrollSpeed = 100;
}
P.setSpeed(scrollSpeed);
}
else if (c == PS2_LEFTARROW) {
scrollSpeed--;
if (scrollSpeed <= 0 ) {
scrollSpeed = 0;
}
P.setSpeed(scrollSpeed);
}
else if (c == PS2_UPARROW) {
contrast++;
if (contrast >= 51 ) {
contrast = 50;
}
P.setIntensity(contrast);
}
else if (c == PS2_DOWNARROW) {
contrast--;
if (contrast <= 0 ) {
contrast = 0;
}
P.setIntensity(contrast);
}
}
}
else if (ModeCAvailable)
{
static char *cp = curMessage;
while (keyboard.available())
{
*cp = (char)keyboard.read();
if (*cp == PS2_ENTER)
{
*cp = '\0'; // end the string
cp = curMessage;
strcpy(newMessage, curMessage);
newMessageAvailable = true;
} else if (*cp == PS2_ESC) {
resetFunc();
} else if (*cp == PS2_PAGEUP) {
ModeCAvailable = false;
newMessageAvailable = false;
curMessageAvailable = false;
ModeBAvailable = false;
ModeAAvailable = true;
getmodea();
} else if (*cp == PS2_PAGEDOWN) {
ModeCAvailable = false;
newMessageAvailable = false;
curMessageAvailable = false;
ModeAAvailable = false;
ModeBAvailable = true;
getmodeb();
} else if (*cp == PS2_TAB) {
curMessageAvailable = true;
} else if (*cp == PS2_DELETE) {
newMessageAvailable = true;
}
else // move char pointer to next position
cp++;
getmoded();
}
}
else if (ModeHAvailable)
{
while (keyboard.available())
{
char c = keyboard.read();
if (c == PS2_ENTER) {
ModeHAvailable = false;
ModeAAvailable = true;
}
else if (c == PS2_RIGHTARROW) {
ModeHAvailable = false;
ModeMAvailable = true;
}
else if (c == PS2_LEFTARROW) {
ModeHAvailable = false;
ModeYerAvailable = true;
getmodef();
}
else if (c == PS2_UPARROW) {
RTC.h++;
if (RTC.h >= 24 ) {
RTC.h = 0;
}
RTC.writeTime();
}
else if (c == PS2_DOWNARROW) {
RTC.h--;
if (RTC.h <= 0 ) {
RTC.h = 23;
}
RTC.writeTime();
}
}
}
else if (ModeMAvailable)
{
while (keyboard.available())
{
char c = keyboard.read();
if (c == PS2_ENTER) {
ModeMAvailable = false;
ModeAAvailable = true;
}
else if (c == PS2_RIGHTARROW) {
ModeMAvailable = false;
ModeSAvailable = true;
}
else if (c == PS2_LEFTARROW) {
ModeMAvailable = false;
ModeHAvailable = true;
}
else if (c == PS2_UPARROW) {
RTC.m++;
if (RTC.m >= 60 ) {
RTC.m = 0;
}
RTC.writeTime();
}
else if (c == PS2_DOWNARROW) {
RTC.m--;
if (RTC.m <= 0 ) {
RTC.m = 59;
}
RTC.writeTime();
}
}
}
else if (ModeSAvailable)
{
while (keyboard.available())
{
char c = keyboard.read();
if (c == PS2_ENTER) {
ModeSAvailable = false;
ModeAAvailable = true;
getmodea();
}
else if (c == PS2_RIGHTARROW) {
ModeSAvailable = false;
ModeDowAvailable = true;
getmodef();
}
else if (c == PS2_LEFTARROW) {
ModeSAvailable = false;
ModeMAvailable = true;
getmodea();
}
else if (c == PS2_UPARROW) {
RTC.s = 0;
RTC.writeTime();
}
else if (c == PS2_DOWNARROW) {
RTC.s = 0;
RTC.writeTime();
}
}
}
else if (ModeDowAvailable)
{
while (keyboard.available())
{
char c = keyboard.read();
if (c == PS2_ENTER) {
ModeDowAvailable = false;
ModeAAvailable = true;
getmodea();
}
else if (c == PS2_RIGHTARROW) {
ModeDowAvailable = false;
ModeDayAvailable = true;
}
else if (c == PS2_LEFTARROW) {
ModeDowAvailable = false;
ModeSAvailable = true;
getmodea();
}
else if (c == PS2_UPARROW) {
RTC.dow++;
if (RTC.dow >= 8 ) {
RTC.dow = 1;
}
RTC.writeTime();
}
else if (c == PS2_DOWNARROW) {
RTC.dow--;
if (RTC.dow <= 0 ) {
RTC.dow = 7;
}
RTC.writeTime();
}
}
}
else if (ModeDayAvailable)
{
while (keyboard.available())
{
char c = keyboard.read();
if (c == PS2_ENTER) {
ModeDayAvailable = false;
ModeAAvailable = true;
getmodea();
}
else if (c == PS2_RIGHTARROW) {
ModeDayAvailable = false;
ModeMonAvailable = true;
}
else if (c == PS2_LEFTARROW) {
ModeDayAvailable = false;
ModeDowAvailable = true;
}
else if (c == PS2_UPARROW) {
RTC.dd++;
if (RTC.dd >= 32 ) {
RTC.dd = 1;
}
RTC.writeTime();
}
else if (c == PS2_DOWNARROW) {
RTC.dd--;
if (RTC.dd <= 0 ) {
RTC.dd = 31;
}
RTC.writeTime();
}
}
}
else if (ModeMonAvailable)
{
while (keyboard.available())
{
char c = keyboard.read();
if (c == PS2_ENTER) {
ModeMonAvailable = false;
ModeAAvailable = true;
getmodea();
}
else if (c == PS2_RIGHTARROW) {
ModeMonAvailable = false;
ModeYerAvailable = true;
}
else if (c == PS2_LEFTARROW) {
ModeMonAvailable = false;
ModeDayAvailable = true;
}
else if (c == PS2_UPARROW) {
RTC.mm++;
if (RTC.mm >= 13 ) {
RTC.mm = 1;
}
RTC.writeTime();
}
else if (c == PS2_DOWNARROW) {
RTC.mm--;
if (RTC.mm <= 0 ) {
RTC.mm = 12;
}
RTC.writeTime();
}
}
}
else if (ModeYerAvailable)
{
while (keyboard.available())
{
char c = keyboard.read();
if (c == PS2_ENTER) {
ModeYerAvailable = false;
ModeAAvailable = true;
getmodea();
}
else if (c == PS2_RIGHTARROW) {
ModeYerAvailable = false;
ModeHAvailable = true;
getmodea();
}
else if (c == PS2_LEFTARROW) {
ModeYerAvailable = false;
ModeMonAvailable = true;
}
else if (c == PS2_UPARROW) {
RTC.yyyy++;
if (RTC.yyyy >= 2035 ) {
RTC.yyyy = 2015;
}
RTC.writeTime();
}
else if (c == PS2_DOWNARROW) {
RTC.yyyy--;
if (RTC.yyyy <= 2010 ) {
RTC.yyyy = 2025;
}
RTC.writeTime();
}
}
}
}
void setup()
{
keyboard.begin(DataPin, IRQpin, PS2Keymap_French);
RTC.control(DS1307_CLOCK_HALT, DS1307_OFF);
RTC.control(DS1307_12H, DS1307_OFF);
RTC.readTime();
getmodea();
P.setIntensity(contrast);
}
void loop()
{
static uint32_t lastTime = 0; // millis() memory
static uint8_t display = 0; // current display mode
static uint8_t cycle = 0; // current display mode
P.displayAnimate();
if (ModeAAvailable)
{
//adjust the time string if we have to
if (millis() - lastTime >= 1000)
{
lastTime = millis();
getsecond(szsecond);
getTime(szTime, flasher);
flasher = !flasher;
P.displayReset(0);
P.displayReset(1);
P.displayReset(2);
}
if (P.getZoneStatus(3))
{
switch (display)
{
case 0: // day of week
P.setTextEffect(3, PA_SCROLL_LEFT, PA_SCROLL_LEFT);
display++;
dow2str(RTC.dow, szMesg, MAX_MESG);
break;
case 1: // Calendar
P.setTextEffect(3, PA_SCROLL_LEFT, PA_SCROLL_LEFT);
display++;
getDate(szMesg);
break;
case 2: // Temperature deg °C
P.setTextEffect(3, PA_SCROLL_LEFT, PA_SCROLL_LEFT);
display++;
getTemperature();
dtostrf(t, 3, 1, szMesg);
strcat(szMesg, "^");
break;
case 3: // Temperature deg °F
P.setTextEffect(3, PA_SCROLL_LEFT, PA_SCROLL_LEFT);
display++;
dtostrf(f, 3, 1, szMesg);
strcat(szMesg, "_");
break;
case 4: // Relative Humidity
P.setTextEffect(3, PA_SCROLL_LEFT, PA_SCROLL_LEFT);
display = 0;
dtostrf(h, 3, 0, szMesg);
strcat(szMesg, "% RH");
break;
}
P.displayReset(3);
}
}
else if (ModeBAvailable)
{
if (P.getZoneStatus(0) && P.getZoneStatus(1))
{
switch (cycle)
{
case 0: // day of week
P.setFont(0, BigFontLower);
P.setFont(1, BigFontUpper);
P.displayZoneText(0, szMesg, PA_CENTER, scrollSpeed, 3000, PA_SCROLL_UP, PA_SCROLL_DOWN);
P.displayZoneText(1, szMesg, PA_CENTER, scrollSpeed, 3000, PA_SCROLL_DOWN, PA_SCROLL_UP);
cycle++;
getTime(szMesg);
break;
case 1: // day of week
P.setFont(0, BigFontLower);
P.setFont(1, BigFontUpper);
P.displayZoneText(0, szMesg, PA_RIGHT, scrollSpeed, 0, PA_SCROLL_LEFT, PA_SCROLL_LEFT);
P.displayZoneText(1, szMesg, PA_LEFT, scrollSpeed, 0, PA_SCROLL_LEFT, PA_SCROLL_LEFT);
cycle++;
dow2str(RTC.dow, szMesg, MAX_MESG);
break;
case 2: // Calendar
P.setFont(0, BigFontLower);
P.setFont(1, BigFontUpper);
P.displayZoneText(0, szMesg, PA_RIGHT, scrollSpeed, 0, PA_SCROLL_LEFT, PA_SCROLL_LEFT);
P.displayZoneText(1, szMesg, PA_LEFT, scrollSpeed, 0, PA_SCROLL_LEFT, PA_SCROLL_LEFT);
cycle++;
getDate(szMesg);
break;
case 3: // day of week
P.setFont(0, BigFontLower);
P.setFont(1, BigFontUpper);
P.displayZoneText(0, szMesg, PA_CENTER, scrollSpeed, 3000, PA_SCROLL_UP, PA_SCROLL_DOWN);
P.displayZoneText(1, szMesg, PA_CENTER, scrollSpeed, 3000, PA_SCROLL_DOWN, PA_SCROLL_UP);
cycle++;
getTime(szMesg);
break;
case 4: // Temperature deg °C
P.setFont(0, BigFontLower);
P.setFont(1, BigFontUpper);
P.displayZoneText(0, szMesg, PA_CENTER, scrollSpeed, 3000, PA_SCROLL_UP, PA_SCROLL_UP);
P.displayZoneText(1, szMesg, PA_CENTER, scrollSpeed, 3000, PA_SCROLL_DOWN, PA_SCROLL_DOWN);
cycle++;
getTemperature();
dtostrf(t, 3, 1, szMesg);
strcat(szMesg, "$");
break;
case 5: // Temperature deg °F
P.setFont(0, BigFontLower);
P.setFont(1, BigFontUpper);
P.displayZoneText(0, szMesg, PA_CENTER, scrollSpeed, 3000, PA_SCROLL_DOWN, PA_SCROLL_DOWN);
P.displayZoneText(1, szMesg, PA_CENTER, scrollSpeed, 3000, PA_SCROLL_UP, PA_SCROLL_UP);
cycle++;
dtostrf(f, 3, 1, szMesg);
strcat(szMesg, "&");
break;
case 6: // Temperature deg RH
P.setFont(0, BigFontLower);
P.setFont(1, BigFontUpper);
P.displayZoneText(0, szMesg, PA_CENTER, scrollSpeed, 0, PA_SCROLL_LEFT, PA_SCROLL_LEFT);
P.displayZoneText(1, szMesg, PA_CENTER, scrollSpeed, 0, PA_SCROLL_LEFT, PA_SCROLL_LEFT);
cycle = 0;
dtostrf(h, 3, 1, szMesg);
strcat(szMesg, "% RH");
break;
}
P.displayReset(0);
P.displayReset(1);
}
}
else if (ModeHAvailable)
{
if (millis() - lastTime >= 250)
{
RTC.readTime();
lastTime = millis();
getsecond(szsecond);
getHour(szTime, flasher);
flasher = !flasher;
P.displayReset(0);
P.displayReset(1);
P.displayReset(2);
}
}
else if (ModeMAvailable)
{
if (millis() - lastTime >= 250)
{
RTC.readTime();
lastTime = millis();
getsecond(szsecond);
getMinute(szTime, flasher);
flasher = !flasher;
P.displayReset(0);
P.displayReset(1);
P.displayReset(2);
}
}
else if (ModeSAvailable)
{
if (millis() - lastTime >= 250)
{
RTC.readTime();
lastTime = millis();
getSec(szsecond);
flasher = !flasher;
P.displayReset(0);
P.displayReset(1);
P.displayReset(2);
}
}
else if (ModeDowAvailable)
{
if (millis() - lastTime >= 250)
{
RTC.readTime();
lastTime = millis();
getDow(szMes);
getYer(szMeY);
getMon(szMeM);
getDay(szMeD);
flasher = !flasher;
P.displayReset(0);
P.displayReset(1);
P.displayReset(2);
P.displayReset(3);
}
}
else if (ModeDayAvailable)
{
if (millis() - lastTime >= 250)
{
RTC.readTime();
lastTime = millis();
getYer(szMeY);
getMon(szMeM);
getDay(szMeD);
getDow(szMes);
flasher = !flasher;
P.displayReset(0);
P.displayReset(1);
P.displayReset(2);
P.displayReset(3);
}
}
else if (ModeMonAvailable)
{
if (millis() - lastTime >= 250)
{
RTC.readTime();
lastTime = millis();
getYer(szMeY);
getMon(szMeM);
getDay(szMeD);
getDow(szMes);
flasher = !flasher;
P.displayReset(0);
P.displayReset(1);
P.displayReset(2);
P.displayReset(3);
}
}
else if (ModeYerAvailable)
{
if (millis() - lastTime >= 250)
{
RTC.readTime();
lastTime = millis();
getYer(szMeY);
getMon(szMeM);
getDay(szMeD);
getDow(szMes);
flasher = !flasher;
P.displayReset(0);
P.displayReset(1);
P.displayReset(2);
P.displayReset(3);
}
}
else if (ModeCAvailable)
{
if (P.displayAnimate())
{
if (newMessageAvailable)
{
getmodec();
newMessageAvailable = false;
}
else if (curMessageAvailable)
{
getmodee();
curMessageAvailable = false;
}
P.displayReset();
}
}
readkeyboard();
}
Font_Data.h
// Data file for user example user defined fonts
#ifndef FONTDATA_H
#define FONTDATA_H
MD_MAX72XX::fontType_t BigFontLower[] PROGMEM =
{
0, // 0
0, // 1
0, // 2
0, // 3
0, // 4
0, // 5
0, // 6
0, // 7
0, // 8
0, // 9
0, // 10
0, // 11
0, // 12
0, // 13
0, // 14
0, // 15
0, // 16
0, // 17
0, // 18
0, // 19
0, // 20
0, // 21
0, // 22
0, // 23
0, // 24
0, // 25
0, // 26
0, // 27
0, // 28
0, // 29
0, // 30
0, // 31
4,0,0,0,0, // 32 - 'Space'
2,103,103, // 33 - '!'
6,0,0,0,0,0,0, // 34 - '"'
10,6,6,127,127,6,6,127,127,6,6, // 35 - '#'
6,0,0,0,0,0,0, // 36 - '$'
10,0,96,120,30,7,1,48,120,120,48, // 37 - '%'
6,0,0,0,0,0,0, // 38 - '&'
2,0,0, // 39 - '''
5,7,31,60,112,96, // 40 - '('
5,96,112,60,31,7, // 41 - ')'
10,3,3,1,0,15,15,0,1,3,3, // 42 - '*'
10,1,1,1,1,31,31,1,1,1,1, // 43 - '+'
2,96,224, // 44 - ','
10,1,1,1,1,1,1,1,1,1,1, // 45 - '-'
2,96,96, // 46 - '.'
8,96,120,30,7,1,0,0,0, // 47 - '/'
10,31,63,112,96,96,96,96,112,63,31, // 48 - '0'
10,0,0,96,96,127,127,96,96,0,0, // 49 - '1'
10,96,112,120,124,110,103,99,97,96,96, // 50 - '2'
10,24,56,112,96,96,97,97,113,63,30, // 51 - '3'
10,7,7,6,6,6,6,127,127,6,6, // 52 - '4'
10,24,56,112,96,96,96,96,112,63,31, // 53 - '5'
10,31,63,112,96,96,96,96,113,63,31, // 54 - '6'
10,0,0,0,127,127,1,0,0,0,0, // 55 - '7'
10,30,63,115,97,97,97,97,115,63,30, // 56 - '8'
10,0,0,97,97,113,57,29,15,7,3, // 57 - '9'
4,0,12,12,0, // 58 - ':'
2, 97,225, // 59 - ';'
8,1,3,7,14,28,56,112,96, // 60 - '<'
10,12,12,12,12,12,12,12,12,12,12, // 61 - '='
8,96,112,56,28,14,7,3,1, // 62 - '>'
10,0,0,0,0,111,111,1,0,0,0, // 63 - '?'
10,0,0,0,0,0,0,0,0,0,0, // 64 - '@'
10,127,127,6,6,6,6,6,6,127,127, // 65 - 'A'
10,127,127,97,97,97,97,97,115,63,30, // 66 - 'B'
10,31,63,96,96,96,96,96,112,56,24, // 67 - 'C'
10,127,127,96,96,96,96,96,112,63,31, // 68 - 'D'
10,127,127,97,97,97,97,97,97,96,96, // 69 - 'E'
10,127,127,1,1,1,1,1,1,0,0, // 70 - 'F'
10,31,63,112,96,96,96,97,113,63,31, // 71 - 'G'
10,127,127,1,1,1,1,1,1,127,127, // 72 - 'H'
6,96,96,127,127,96,96, // 73 - 'I'
8,24,56,112,96,96,112,63,31, // 74 - 'J'
10,127,127,3,3,7,14,28,56,112,96, // 75 - 'K'
10,127,127,96,96,96,96,96,96,96,96, // 76 - 'L'
10,127,127,0,0,0,0,0,0,127,127, // 77 - 'M'
10,127,127,0,0,1,7,28,48,127,127, // 78 - 'N'
10,31,63,112,96,96,96,96,112,63,31, // 79 - 'O'
10,127,127,1,1,1,1,1,1,0,0, // 80 - 'P'
10,31,63,112,96,96,108,124,56,127,111, // 81 - 'Q'
10,127,127,1,3,7,15,29,57,112,96, // 82 - 'R'
10,48,112,97,97,97,97,97,115,63,30, // 83 - 'S'
10,0,0,0,0,127,127,0,0,0,0, // 84 - 'T'
10,31,63,112,96,96,96,96,112,63,31, // 85 - 'U'
10,7,15,28,56,112,112,56,28,15,7, // 86 - 'V'
10,31,63,112,120,62,62,120,112,63,31, // 87 - 'W'
10,120,124,14,7,3,3,7,14,124,120, // 88 - 'X'
10,0,0,0,0,127,127,0,0,0,0, // 89 - 'Y'
10,120,124,110,103,99,97,96,96,96,96, // 90 - 'Z'
4,127,127,96,96, // 91 - '['
8,0,0,0,1,7,30,120,96, // 92 - '\'
4,96,96,127,127, // 93 - ']'
10,0,0,0,0,0,0,0,0,0,0, // 94 - '^'
10,192,192,192,192,192,192,192,192,192,192, // 95 - '_'
3,0,0,0, // 96 - '`'
10,24,60,102,102,102,102,102,102,127,63, // 97 - 'a'
10,127,127,96,96,96,96,96,112,63,31, // 98 - 'b'
10,31,63,112,96,96,96,96,112,57,25, // 99 - 'c'
10,31,63,112,96,96,96,96,96,127,127, // 100 - 'd'
10,31,63,118,102,102,102,102,118,55,19, // 101 - 'e'
7,1,127,127,1,1,0,0, // 102 - 'f'
10,35,103,238,204,204,204,204,236,127,63, // 103 - 'g'
10,127,127,0,0,0,0,0,0,127,127, // 104 - 'h'
2,127,127, // 105 - 'i'
8,24,56,112,96,96,112,63,31, // 106 - 'j'
8,127,127,14,15,31,57,112,96, // 107 - 'k'
6,96,96,127,127,96,96, // 108 - 'l'
10,127,127,0,0,127,127,0,0,127,127, // 109 - 'm'
10,127,127,1,1,0,0,0,0,127,127, // 110 - 'n'
10,31,63,112,96,96,96,96,112,63,31, // 111 - 'o'
10,255,255,24,24,24,24,24,28,15,7, // 112 - 'p'
10,7,15,28,24,24,24,24,24,255,255, // 113 - 'q'
10,127,127,3,1,0,0,0,0,1,1, // 114 - 'r'
10,49,115,102,102,102,102,102,126,60,24, // 115 - 's'
8,0,0,31,63,112,112,56,24, // 116 - 't'
10,31,63,112,96,96,96,96,112,63,31, // 117 - 'u'
10,7,15,28,56,112,112,56,28,15,7, // 118 - 'v'
10,31,63,112,112,62,62,112,112,63,31, // 119 - 'w'
10,96,112,57,31,15,15,31,57,112,96, // 120 - 'x'
10,3,7,206,204,204,204,204,236,127,63, // 121 - 'y'
10,96,112,120,124,110,103,99,97,96,96, // 122 - 'z'
6,1,3,31,62,112,96, // 123 - '{'
2,255,255, // 124 - '|'
6,96,112,62,31,3,1, // 125 - '}'
0, // 126
0, // 127
0, // 128
0, // 129
0, // 130
0, // 131
0, // 132
0, // 133
0, // 134
0, // 135
0, // 136
0, // 137
0, // 138
0, // 139
0, // 140
0, // 141
0, // 142
0, // 143
0, // 144
0, // 145
0, // 146
0, // 147
0, // 148
0, // 149
0, // 150
0, // 151
0, // 152
0, // 153
0, // 154
0, // 155
0, // 156
0, // 157
0, // 158
0, // 159
0, // 160
0, // 161
0, // 162
0, // 163
0, // 164
0, // 165
0, // 166
0, // 167
0, // 168
0, // 169
0, // 170
0, // 171
0, // 172
0, // 173
0, // 174
0, // 175
0, // 176
0, // 177
0, // 178
0, // 179
0, // 180
0, // 181
0, // 182
0, // 183
0, // 184
0, // 185
0, // 186
0, // 187
0, // 188
0, // 189
0, // 190
0, // 191
0, // 192
0, // 193
0, // 194
0, // 195
0, // 196
0, // 197
0, // 198
0, // 199
0, // 200
0, // 201
0, // 202
0, // 203
0, // 204
0, // 205
0, // 206
0, // 207
0, // 208
0, // 209
0, // 210
0, // 211
0, // 212
0, // 213
0, // 214
0, // 215
0, // 216
0, // 217
0, // 218
0, // 219
0, // 220
0, // 221
0, // 222
0, // 223
0, // 224
0, // 225
0, // 226
0, // 227
0, // 228
0, // 229
0, // 230
0, // 231
0, // 232
0, // 233
0, // 234
0, // 235
0, // 236
0, // 237
0, // 238
0, // 239
0, // 240
0, // 241
0, // 242
0, // 243
0, // 244
0, // 245
0, // 246
0, // 247
0, // 248
0, // 249
0, // 250
0, // 251
0, // 252
0, // 253
0, // 254
0, // 255
};
MD_MAX72XX::fontType_t BigFontUpper[] PROGMEM =
{
0, // 0
0, // 1
0, // 2
0, // 3
0, // 4
0, // 5
0, // 6
0, // 7
0, // 8
0, // 9
0, // 10
0, // 11
0, // 12
0, // 13
0, // 14
0, // 15
0, // 16
0, // 17
0, // 18
0, // 19
0, // 20
0, // 21
0, // 22
0, // 23
0, // 24
0, // 25
0, // 26
0, // 27
0, // 28
0, // 29
0, // 30
0, // 31
4,0,0,0,0, // 32 - 'Space'
2,254,254, // 33 - '!'
6,14,14,0,0,14,14, // 34 - '"'
10,96,96,254,254,96,96,254,254,96,96, // 35 - '#'
6,3,3,56,68,68,68, // 36 - '$'
10,12,30,30,12,128,224,120,30,6,0, // 37 - '%'
6,3,3,124,20,20,4, // 38 - '&'
2,14,14, // 39 - '''
5,224,248,60,14,6, // 40 - '('
5,6,14,60,248,224, // 41 - ')'
10,24,184,240,224,254,254,224,240,184,24, // 42 - '*'
10,128,128,128,128,248,248,128,128,128,128, // 43 - '+'
2,0,0, // 44 - ','
10,128,128,128,128,128,128,128,128,128,128, // 45 - '-'
2,0,0, // 46 - '.'
8,0,0,0,128,224,120,30,6, // 47 - '/'
10,248,252,14,6,6,6,6,14,252,248, // 48 - '0'
10,0,0,24,28,254,254,0,0,0,0, // 49 - '1'
10,24,28,14,6,6,6,134,206,252,120, // 50 - '2'
10,24,28,14,6,6,134,134,142,252,120, // 51 - '3'
10,128,192,224,112,56,28,254,254,0,0, // 52 - '4'
10,126,126,102,102,102,102,102,230,198,134, // 53 - '5'
10,248,252,198,198,198,198,198,198,140,8, // 54 - '6'
10,6,6,6,6,134,198,230,118,62,30, // 55 - '7'
10,56,124,206,134,134,134,134,206,124,56, // 56 - '8'
10,120,252,206,134,134,134,134,206,252,248, // 57 - '9'
4,0,48,48,0, // 58 - ':'
2,128,128, // 59 - ';'
8,128,192,224,112,56,28,14,6, // 60 - '<'
10,48,48,48,48,48,48,48,48,48,48, // 61 - '='
8,6,14,28,56,112,224,192,128, // 62 - '>'
10,24,28,14,6,6,134,134,206,252,120, // 63 - '?'
10,0,0,0,0,0,0,0,0,0,0, // 64 - '@'
10,248,252,14,6,6,6,6,14,252,248, // 65 - 'A'
10,254,254,134,134,134,134,134,206,252,120, // 66 - 'B'
10,248,252,6,6,6,6,6,14,28,24, // 67 - 'C'
10,254,254,6,6,6,6,6,14,252,248, // 68 - 'D'
10,254,254,134,134,134,134,134,134,6,6, // 69 - 'E'
10,254,254,134,134,134,134,134,134,6,6, // 70 - 'F'
10,248,252,14,6,6,6,134,142,156,152, // 71 - 'G'
10,254,254,128,128,128,128,128,128,254,254, // 72 - 'H'
6,6,6,254,254,6,6, // 73 - 'I'
8,6,6,6,6,6,6,254,254, // 74 - 'J'
10,254,254,192,192,224,112,56,28,14,6, // 75 - 'K'
10,254,254,0,0,0,0,0,0,0,0, // 76 - 'L'
10,254,254,28,56,240,240,56,28,254,254, // 77 - 'M'
10,254,254,28,112,192,0,0,0,254,254, // 78 - 'N'
10,248,252,14,6,6,6,6,14,252,248, // 79 - 'O'
10,254,254,134,134,134,134,134,206,252,120, // 80 - 'P'
10,248,252,14,6,6,6,6,14,252,248, // 81 - 'Q'
10,254,254,134,134,134,134,134,206,252,120, // 82 - 'R'
10,120,252,206,134,134,134,134,134,14,12, // 83 - 'S'
10,6,6,6,6,254,254,6,6,6,6, // 84 - 'T'
10,254,254,0,0,0,0,0,0,254,254, // 85 - 'U'
10,254,254,0,0,0,0,0,0,254,254, // 86 - 'V'
10,254,254,0,0,0,0,0,0,254,254, // 87 - 'W'
10,30,62,48,224,192,192,224,112,62,30, // 88 - 'X'
10,30,62,112,224,192,192,224,112,62,30, // 89 - 'Y'
10,6,6,6,6,134,198,230,118,62,30, // 90 - 'Z'
4,254,254,6,6, // 91 - '['
8,6,30,120,224,128,0,0,0, // 92 - '\'
4,6,6,254,254, // 93 - ']'
10,96,112,56,28,14,14,28,56,112,96, // 94 - '^'
10,0,0,0,0,0,0,0,0,0,0, // 95 - '_'
3,6,30,24, // 96 - '`'
10,0,192,224,96,96,96,96,224,192,128, // 97 - 'a'
10,254,254,96,96,96,96,96,224,192,128, // 98 - 'b'
10,128,192,224,96,96,96,96,224,192,128, // 99 - 'c'
10,128,192,224,96,96,96,96,96,254,254, // 100 - 'd'
10,128,192,224,96,96,96,96,224,192,128, // 101 - 'e'
7,128,248,252,142,142,28,24, // 102 - 'f'
10,128,192,224,96,96,96,96,96,224,224, // 103 - 'g'
10,254,254,96,96,96,96,96,224,192,128, // 104 - 'h'
2,236,236, // 105 - 'i'
8,0,0,0,0,0,0,230,230, // 106 - 'j'
8,254,254,0,0,128,192,224,96, // 107 - 'k'
6,6,6,254,254,0,0, // 108 - 'l'
10,224,224,96,96,224,224,96,96,224,192, // 109 - 'm'
10,224,224,128,192,224,96,96,224,192,128, // 110 - 'n'
10,128,192,224,96,96,96,96,224,192,128, // 111 - 'o'
10,224,224,96,96,96,96,96,224,192,128, // 112 - 'p'
10,128,192,224,96,96,96,96,96,224,224, // 113 - 'q'
10,224,224,128,192,224,96,96,224,192,128, // 114 - 'r'
10,128,192,96,96,96,96,96,96,192,192, // 115 - 's'
8,96,96,254,254,96,96,96,96, // 116 - 't'
10,224,224,0,0,0,0,0,0,224,224, // 117 - 'u'
10,224,224,0,0,0,0,0,0,224,224, // 118 - 'v'
10,224,224,0,0,0,0,0,0,224,224, // 119 - 'w'
10,96,224,192,128,0,0,128,192,224,96, // 120 - 'x'
10,224,224,0,0,0,0,0,0,224,224, // 121 - 'y'
10,96,96,96,96,96,96,224,224,224,96, // 122 - 'z'
6,128,192,248,124,14,6, // 123 - '{'
2,255,255, // 124 - '|'
6,6,14,124,248,192,128, // 125 - '}'
0, // 126
0, // 127
0, // 128
0, // 129
0, // 130
0, // 131
0, // 132
0, // 133
0, // 134
0, // 135
0, // 136
0, // 137
0, // 138
0, // 139
0, // 140
0, // 141
0, // 142
0, // 143
0, // 144
0, // 145
0, // 146
0, // 147
0, // 148
0, // 149
0, // 150
0, // 151
0, // 152
0, // 153
0, // 154
0, // 155
0, // 156
0, // 157
0, // 158
0, // 159
0, // 160
0, // 161
0, // 162
0, // 163
0, // 164
0, // 165
0, // 166
0, // 167
0, // 168
0, // 169
0, // 170
0, // 171
0, // 172
0, // 173
0, // 174
0, // 175
0, // 176
0, // 177
0, // 178
0, // 179
0, // 180
0, // 181
0, // 182
0, // 183
0, // 184
0, // 185
0, // 186
0, // 187
0, // 188
0, // 189
0, // 190
0, // 191
0, // 192
0, // 193
0, // 194
0, // 195
0, // 196
0, // 197
0, // 198
0, // 199
0, // 200
0, // 201
0, // 202
0, // 203
0, // 204
0, // 205
0, // 206
0, // 207
0, // 208
0, // 209
0, // 210
0, // 211
0, // 212
0, // 213
0, // 214
0, // 215
0, // 216
0, // 217
0, // 218
0, // 219
0, // 220
0, // 221
0, // 222
0, // 223
0, // 224
0, // 225
0, // 226
0, // 227
0, // 228
0, // 229
0, // 230
0, // 231
0, // 232
0, // 233
0, // 234
0, // 235
0, // 236
0, // 237
0, // 238
0, // 239
0, // 240
0, // 241
0, // 242
0, // 243
0, // 244
0, // 245
0, // 246
0, // 247
0, // 248
0, // 249
0, // 250
0, // 251
0, // 252
0, // 253
0, // 254
0, // 255
};
#endif