Made MD* libraries (Parola, MAX72XX) project specific, to be able to use the newest software version from github.
This commit is contained in:
265
lib/MD_Parola/examples/Parola_Zone_TimeMsg/Font_Data.h
Normal file
265
lib/MD_Parola/examples/Parola_Zone_TimeMsg/Font_Data.h
Normal file
@@ -0,0 +1,265 @@
|
||||
// Data file for user example user defined fonts
|
||||
#ifndef FONTDATA_H
|
||||
#define FONTDATA_H
|
||||
|
||||
MD_MAX72XX::fontType_t numeric7Seg[] 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
|
||||
1, 0, // 32 - 'Space'
|
||||
0, // 33 - '!'
|
||||
0, // 34 - '"'
|
||||
0, // 35 - '#'
|
||||
0, // 36 - '$'
|
||||
0, // 37 - '%'
|
||||
0, // 38 - '&'
|
||||
0, // 39 - '''
|
||||
0, // 40 - '('
|
||||
0, // 41 - ')'
|
||||
0, // 42 - '*'
|
||||
0, // 43 - '+'
|
||||
0, // 44 - ','
|
||||
0, // 45 - '-'
|
||||
1, 64, // 46 - '.'
|
||||
0, // 47 - '/'
|
||||
5, 127, 65, 65, 65, 127, // 48 - '0'
|
||||
5, 0, 0, 127, 0, 0, // 49 - '1'
|
||||
5, 121, 73, 73, 73, 79, // 50 - '2'
|
||||
5, 73, 73, 73, 73, 127, // 51 - '3'
|
||||
5, 15, 8, 8, 8, 127, // 52 - '4'
|
||||
5, 79, 73, 73, 73, 121, // 53 - '5'
|
||||
5, 127, 73, 73, 73, 121, // 54 - '6'
|
||||
5, 1, 1, 1, 1, 127, // 55 - '7'
|
||||
5, 127, 73, 73, 73, 127, // 56 - '8'
|
||||
5, 79, 73, 73, 73, 127, // 57 - '9'
|
||||
1, 20, // 58 - ':'
|
||||
0, // 59 - ';'
|
||||
0, // 60 - '<'
|
||||
0, // 61 - '='
|
||||
0, // 62 - '>'
|
||||
0, // 63 - '?'
|
||||
0, // 64 - '@'
|
||||
5, 127, 9, 9, 9, 127, // 65 - 'A'
|
||||
5, 127, 73, 73, 73, 54, // 66 - 'B'
|
||||
5, 127, 65, 65, 65, 65, // 67 - 'C'
|
||||
5, 127, 65, 65, 65, 62, // 68 - 'D'
|
||||
5, 127, 73, 73, 73, 73, // 69 - 'E'
|
||||
5, 127, 9, 9, 9, 9, // 70 - 'F'
|
||||
0, // 71 - 'G'
|
||||
0, // 72 - 'H'
|
||||
0, // 73 - 'I'
|
||||
0, // 74 - 'J'
|
||||
0, // 75 - 'K'
|
||||
0, // 76 - 'L'
|
||||
0, // 77 - 'M'
|
||||
0, // 78 - 'N'
|
||||
0, // 79 - 'O'
|
||||
0, // 80 - 'P'
|
||||
0, // 81 - 'Q'
|
||||
0, // 82 - 'R'
|
||||
0, // 83 - 'S'
|
||||
0, // 84 - 'T'
|
||||
0, // 85 - 'U'
|
||||
0, // 86 - 'V'
|
||||
0, // 87 - 'W'
|
||||
0, // 88 - 'X'
|
||||
0, // 89 - 'Y'
|
||||
0, // 90 - 'Z'
|
||||
0, // 91 - '['
|
||||
0, // 92 - '\'
|
||||
0, // 93 - ']'
|
||||
0, // 94 - '^'
|
||||
0, // 95 - '_'
|
||||
0, // 96 - '`'
|
||||
5, 127, 9, 9, 9, 127, // 97 - 'a'
|
||||
5, 127, 73, 73, 73, 54, // 98 - 'b'
|
||||
5, 127, 65, 65, 65, 65, // 99 - 'c'
|
||||
5, 127, 65, 65, 65, 62, // 100 - 'd'
|
||||
5, 127, 73, 73, 73, 73, // 101 - 'e'
|
||||
5, 127, 9, 9, 9, 9, // 102 - 'f'
|
||||
0, // 103 - 'g'
|
||||
0, // 104 - 'h'
|
||||
0, // 105 - 'i'
|
||||
0, // 106 - 'j'
|
||||
0, // 107 - 'k'
|
||||
0, // 108 - 'l'
|
||||
0, // 109 - 'm'
|
||||
0, // 110 - 'n'
|
||||
0, // 111 - 'o'
|
||||
0, // 112 - 'p'
|
||||
0, // 113 - 'q'
|
||||
0, // 114 - 'r'
|
||||
0, // 115 - 's'
|
||||
0, // 116 - 't'
|
||||
0, // 117 - 'u'
|
||||
0, // 118 - 'v'
|
||||
0, // 119 - 'w'
|
||||
0, // 120 - 'x'
|
||||
0, // 121 - 'y'
|
||||
0, // 122 - 'z'
|
||||
0, // 123 - '{'
|
||||
1, 127, // 124 - '|'
|
||||
0, // 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
|
@@ -0,0 +1,247 @@
|
||||
// Program to demonstrate the MD_Parola library
|
||||
//
|
||||
// Display the time in one zone and other information scrolling through in
|
||||
// another zone.
|
||||
// - Time is shown in a user defined fixed width font
|
||||
// - Scrolling text uses the default font
|
||||
// - Temperature display uses user defined characters
|
||||
// - Optional use of DS1307 module for time and DHT11 sensor for temp and humidity
|
||||
// - DS1307 library (MD_DS1307) found at https://github.com/MajicDesigns/DS1307
|
||||
// - DHT11 library (DHT11_lib) found at http://arduino.cc/playground/Main/DHT11Lib
|
||||
// - MD_MAX72XX library can be found at https://github.com/MajicDesigns/MD_MAX72XX
|
||||
//
|
||||
|
||||
// Use the DHT11 temp and humidity sensor
|
||||
#define USE_DHT11 0
|
||||
|
||||
// Use the DS1307 clock module
|
||||
#define USE_DS1307 0
|
||||
|
||||
// Header file includes
|
||||
#include <MD_Parola.h>
|
||||
#include <MD_MAX72xx.h>
|
||||
#include <SPI.h>
|
||||
|
||||
#include "Font_Data.h"
|
||||
|
||||
// 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::PAROLA_HW
|
||||
#define MAX_DEVICES 10
|
||||
|
||||
#define CLK_PIN 13
|
||||
#define DATA_PIN 11
|
||||
#define CS_PIN 10
|
||||
|
||||
|
||||
#if USE_DHT11
|
||||
#include <dht11.h>
|
||||
|
||||
#define DHT11_PIN 2
|
||||
|
||||
dht11 DHT11;
|
||||
#endif
|
||||
|
||||
#if USE_DS1307
|
||||
#include <MD_DS1307.h>
|
||||
#include <Wire.h>
|
||||
#endif
|
||||
|
||||
// Hardware SPI connection
|
||||
MD_Parola P = MD_Parola(HARDWARE_TYPE, CS_PIN, MAX_DEVICES);
|
||||
// Arbitrary output pins
|
||||
// MD_Parola P = MD_Parola(HARDWARE_TYPE, DATA_PIN, CLK_PIN, CS_PIN, MAX_DEVICES);
|
||||
|
||||
#define SPEED_TIME 75
|
||||
#define PAUSE_TIME 0
|
||||
|
||||
#define MAX_MESG 20
|
||||
|
||||
// Turn on debug statements to the serial output
|
||||
#define DEBUG 0
|
||||
|
||||
// Global variables
|
||||
char szTime[9]; // mm:ss\0
|
||||
char szMesg[MAX_MESG+1] = "";
|
||||
|
||||
uint8_t degC[] = { 6, 3, 3, 56, 68, 68, 68 }; // Deg C
|
||||
uint8_t degF[] = { 6, 3, 3, 124, 20, 20, 4 }; // Deg F
|
||||
|
||||
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 getTime(char *psz, bool f = true)
|
||||
// Code for reading clock time
|
||||
{
|
||||
#if USE_DS1307
|
||||
RTC.readTime();
|
||||
sprintf(psz, "%02d%c%02d", RTC.h, (f ? ':' : ' '), RTC.m);
|
||||
#else
|
||||
uint16_t h, m, s;
|
||||
|
||||
s = millis()/1000;
|
||||
m = s/60;
|
||||
h = m/60;
|
||||
m %= 60;
|
||||
s %= 60;
|
||||
sprintf(psz, "%02d%c%02d", h, (f ? ':' : ' '), m);
|
||||
#endif
|
||||
}
|
||||
|
||||
void getDate(char *psz)
|
||||
// Code for reading clock date
|
||||
{
|
||||
#if USE_DS1307
|
||||
char szBuf[10];
|
||||
|
||||
RTC.readTime();
|
||||
sprintf(psz, "%d %s %04d", RTC.dd, mon2str(RTC.mm, szBuf, sizeof(szBuf)-1), RTC.yyyy);
|
||||
#else
|
||||
strcpy(szMesg, "29 Feb 2016");
|
||||
#endif
|
||||
}
|
||||
|
||||
void setup(void)
|
||||
{
|
||||
P.begin(2);
|
||||
P.setInvert(false);
|
||||
|
||||
P.setZone(0, 0, MAX_DEVICES-5);
|
||||
P.setZone(1, MAX_DEVICES-4, MAX_DEVICES-1);
|
||||
P.setFont(1, numeric7Seg);
|
||||
|
||||
P.displayZoneText(1, szTime, PA_CENTER, SPEED_TIME, PAUSE_TIME, PA_PRINT, PA_NO_EFFECT);
|
||||
P.displayZoneText(0, szMesg, PA_CENTER, SPEED_TIME, 0, PA_SCROLL_LEFT, PA_SCROLL_LEFT);
|
||||
|
||||
P.addChar('$', degC);
|
||||
P.addChar('&', degF);
|
||||
|
||||
#if USE_DS1307
|
||||
RTC.control(DS1307_CLOCK_HALT, DS1307_OFF);
|
||||
RTC.control(DS1307_12H, DS1307_OFF);
|
||||
#endif
|
||||
|
||||
getTime(szTime);
|
||||
}
|
||||
|
||||
void loop(void)
|
||||
{
|
||||
static uint32_t lastTime = 0; // millis() memory
|
||||
static uint8_t display = 0; // current display mode
|
||||
static bool flasher = false; // seconds passing flasher
|
||||
|
||||
P.displayAnimate();
|
||||
|
||||
if (P.getZoneStatus(0))
|
||||
{
|
||||
switch (display)
|
||||
{
|
||||
case 0: // Temperature deg C
|
||||
P.setTextEffect(0, PA_SCROLL_LEFT, PA_SCROLL_UP_LEFT);
|
||||
display++;
|
||||
#if USE_DHT11
|
||||
if (DHT11.read(DHT11_PIN) == 0)
|
||||
{
|
||||
dtostrf(DHT11.temperature, 3, 1, szMesg);
|
||||
strcat(szMesg, "$");
|
||||
}
|
||||
#else
|
||||
strcpy(szMesg, "22.0$");
|
||||
#endif
|
||||
break;
|
||||
|
||||
case 1: // Temperature deg F
|
||||
P.setTextEffect(0, PA_SCROLL_UP_LEFT, PA_SCROLL_LEFT);
|
||||
display++;
|
||||
#if USE_DHT11
|
||||
if (DHT11.read(DHT11_PIN) == 0)
|
||||
{
|
||||
dtostrf((1.8 * DHT11.temperature)+32, 3, 1, szMesg);
|
||||
strcat(szMesg, "&");
|
||||
}
|
||||
#else
|
||||
strcpy(szMesg, "71.6&");
|
||||
#endif
|
||||
break;
|
||||
|
||||
case 2: // Relative Humidity
|
||||
P.setTextEffect(0, PA_SCROLL_LEFT, PA_SCROLL_LEFT);
|
||||
display++;
|
||||
#if USE_DHT11
|
||||
if (DHT11.read(DHT11_PIN) == 0)
|
||||
{
|
||||
dtostrf(DHT11.humidity, 3, 0, szMesg);
|
||||
strcat(szMesg, "% RH");
|
||||
}
|
||||
#else
|
||||
strcpy(szMesg, "36 % RH");
|
||||
#endif
|
||||
break;
|
||||
|
||||
case 3: // day of week
|
||||
P.setTextEffect(0, PA_SCROLL_LEFT, PA_SCROLL_LEFT);
|
||||
display++;
|
||||
#if USE_DS1307
|
||||
dow2str(RTC.dow, szMesg, MAX_MESG);
|
||||
#else
|
||||
dow2str(4, szMesg, MAX_MESG);
|
||||
#endif
|
||||
break;
|
||||
|
||||
default: // Calendar
|
||||
P.setTextEffect(0, PA_SCROLL_LEFT, PA_SCROLL_LEFT);
|
||||
display = 0;
|
||||
getDate(szMesg);
|
||||
break;
|
||||
}
|
||||
|
||||
P.displayReset(0);
|
||||
}
|
||||
|
||||
// Finally, adjust the time string if we have to
|
||||
if (millis() - lastTime >= 1000)
|
||||
{
|
||||
lastTime = millis();
|
||||
getTime(szTime, flasher);
|
||||
flasher = !flasher;
|
||||
|
||||
P.displayReset(1);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user