Made MD* libraries (Parola, MAX72XX) project specific, to be able to use the newest software version from github.
This commit is contained in:
264
lib/MD_Parola/examples/Parola_Double_Height_Clock/Font_Data.h
Normal file
264
lib/MD_Parola/examples/Parola_Double_Height_Clock/Font_Data.h
Normal file
@@ -0,0 +1,264 @@
|
||||
// Data file for user example user defined fonts
|
||||
#ifndef FONTDATA_H
|
||||
#define FONTDATA_H
|
||||
|
||||
MD_MAX72XX::fontType_t numeric7SegDouble[] 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
|
||||
2, 0, 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 - '-'
|
||||
2, 48, 48, // 46 - '.'
|
||||
0, // 47 - '/'
|
||||
10, 62, 127, 192, 192, 192, 192, 192, 192, 127, 62, // 48 - '0'
|
||||
10, 0, 0, 0, 0, 0, 0, 0, 0, 127, 62, // 49 - '1'
|
||||
10, 62, 127, 193, 193, 193, 193, 193, 193, 64, 0, // 50 - '2'
|
||||
10, 0, 65, 193, 193, 193, 193, 193, 193, 127, 62, // 51 - '3'
|
||||
10, 0, 0, 1, 1, 1, 1, 1, 1, 127, 62, // 52 - '4'
|
||||
10, 0, 64, 193, 193, 193, 193, 193, 193, 127, 62, // 53 - '5'
|
||||
10, 62, 127, 193, 193, 193, 193, 193, 193, 127, 62, // 54 - '6'
|
||||
10, 0, 0, 0, 0, 0, 0, 0, 0, 127, 62, // 55 - '7'
|
||||
10, 62, 127, 193, 193, 193, 193, 193, 193, 127, 62, // 56 - '8'
|
||||
10, 0, 64, 193, 193, 193, 193, 193, 193, 127, 62, // 57 - '9'
|
||||
2, 6, 6, // 58 - ':'
|
||||
0, // 59 - ';'
|
||||
0, // 60 - '<'
|
||||
0, // 61 - '='
|
||||
0, // 62 - '>'
|
||||
0, // 63 - '?'
|
||||
0, // 64 - '@'
|
||||
10, 62, 127, 1, 1, 1, 1, 1, 1, 127, 62, // 65 - 'A'
|
||||
10, 62, 127, 193, 193, 193, 193, 193, 193, 127, 62, // 66 - 'B'
|
||||
10, 62, 127, 193, 193, 193, 193, 193, 193, 65, 0, // 67 - 'C'
|
||||
10, 62, 127, 193, 193, 193, 193, 193, 193, 127, 62, // 68 - 'D'
|
||||
10, 62, 127, 193, 193, 193, 193, 193, 193, 65, 0, // 69 - 'E'
|
||||
10, 62, 127, 1, 1, 1, 1, 1, 1, 1, 0, // 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 - '`'
|
||||
10, 62, 127, 1, 1, 1, 1, 1, 1, 127, 62, // 97 - 'a'
|
||||
10, 62, 127, 193, 193, 193, 193, 193, 193, 127, 62, // 98 - 'b'
|
||||
10, 62, 127, 193, 193, 193, 193, 193, 193, 65, 0, // 99 - 'c'
|
||||
10, 62, 127, 193, 193, 193, 193, 193, 193, 127, 62, // 100 - 'd'
|
||||
10, 62, 127, 193, 193, 193, 193, 193, 193, 65, 0, // 101 - 'e'
|
||||
10, 62, 127, 1, 1, 1, 1, 1, 1, 1, 0, // 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 - '{'
|
||||
2, 255, 255, // 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
|
||||
2, 0, 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
|
||||
2, 0, 0, // 174
|
||||
0, // 175
|
||||
10, 124, 254, 3, 3, 3, 3, 3, 3, 254, 124, // 176
|
||||
10, 0, 0, 0, 0, 0, 0, 0, 0, 254, 124, // 177
|
||||
10, 0, 2, 131, 131, 131, 131, 131, 131, 254, 124, // 178
|
||||
10, 0, 130, 131, 131, 131, 131, 131, 131, 254, 124, // 179
|
||||
10, 124, 254, 128, 128, 128, 128, 128, 128, 254, 124, // 180
|
||||
10, 124, 254, 131, 131, 131, 131, 131, 131, 2, 0, // 181
|
||||
10, 124, 254, 131, 131, 131, 131, 131, 131, 2, 0, // 182
|
||||
10, 0, 2, 3, 3, 3, 3, 3, 3, 254, 124, // 183
|
||||
10, 124, 254, 131, 131, 131, 131, 131, 131, 254, 124, // 184
|
||||
10, 124, 254, 131, 131, 131, 131, 131, 131, 254, 124, // 185
|
||||
2, 96, 96, // 186
|
||||
0, // 187
|
||||
0, // 188
|
||||
0, // 189
|
||||
0, // 190
|
||||
0, // 191
|
||||
0, // 192
|
||||
10, 124, 254, 131, 131, 131, 131, 131, 131, 254, 124, // 193
|
||||
10, 124, 254, 128, 128, 128, 128, 128, 128, 0, 0, // 194
|
||||
10, 0, 0, 128, 128, 128, 128, 128, 128, 0, 0, // 195
|
||||
10, 0, 0, 128, 128, 128, 128, 128, 128, 254, 124, // 196
|
||||
10, 124, 254, 131, 131, 131, 131, 131, 131, 130, 0, // 197
|
||||
10, 124, 254, 131, 131, 131, 131, 131, 131, 130, 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
|
||||
10, 124, 254, 131, 131, 131, 131, 131, 131, 254, 124, // 225
|
||||
10, 124, 254, 128, 128, 128, 128, 128, 128, 0, 0, // 226
|
||||
10, 0, 0, 128, 128, 128, 128, 128, 128, 0, 0, // 227
|
||||
10, 0, 0, 128, 128, 128, 128, 128, 128, 254, 124, // 228
|
||||
10, 124, 254, 131, 131, 131, 131, 131, 131, 130, 0, // 229
|
||||
10, 124, 254, 131, 131, 131, 131, 131, 131, 130, 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
|
||||
2, 255, 255, // 252
|
||||
0, // 253
|
||||
0, // 254
|
||||
0, // 255
|
||||
};
|
||||
|
||||
#endif
|
@@ -0,0 +1,158 @@
|
||||
// Program to demonstrate the MD_Parola library
|
||||
//
|
||||
// Display the time in a double height display with a fixed width font.
|
||||
// - Time is shown in a user defined seven segment font
|
||||
// - Optional use of DS1307 module for time
|
||||
// - DS1307 library (MD_DS1307) found at https://github.com/MajicDesigns/DS1307
|
||||
// - MD_MAX72XX library can be found at https://github.com/MajicDesigns/MD_MAX72XX
|
||||
//
|
||||
// Each font file has the lower part of a character as ASCII codes 0-127 and the
|
||||
// upper part of the character in ASCII code 128-255. Adding 128 to each lower
|
||||
// character creates the correct index for the upper character.
|
||||
// The upper and lower portions are managed as 2 zones 'stacked' on top of each other
|
||||
// so that the module numbers are in the sequence shown below:
|
||||
//
|
||||
// * Modules (like FC-16) that can fit over each other with no gap
|
||||
// n n-1 n-2 ... n/2+1 <- this direction top row
|
||||
// n/2 ... 3 2 1 0 <- this direction bottom row
|
||||
//
|
||||
// * Modules (like Generic and Parola) that cannot fit over each other with no gap
|
||||
// n/2+1 ... n-2 n-1 n -> this direction top row
|
||||
// n/2 ... 3 2 1 0 <- this direction bottom row
|
||||
//
|
||||
// Sending the original string to the lower zone and the modified (+128) string to the
|
||||
// upper zone creates the complete message on the display.
|
||||
//
|
||||
|
||||
// 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_ZONES 2
|
||||
#define ZONE_SIZE 7
|
||||
#define MAX_DEVICES (MAX_ZONES * ZONE_SIZE)
|
||||
|
||||
#define ZONE_UPPER 1
|
||||
#define ZONE_LOWER 0
|
||||
|
||||
#define CLK_PIN 13
|
||||
#define DATA_PIN 11
|
||||
#define CS_PIN 10
|
||||
|
||||
#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 6
|
||||
|
||||
// Hardware adaptation parameters for scrolling
|
||||
bool invertUpperZone = false;
|
||||
|
||||
// Turn on debug statements to the serial output
|
||||
#define DEBUG 0
|
||||
|
||||
// Global variables
|
||||
char szTimeL[MAX_MESG]; // mm:ss\0
|
||||
char szTimeH[MAX_MESG];
|
||||
|
||||
void getTime(char *psz, bool f = true)
|
||||
// Code for reading clock time
|
||||
// Simulated clock runs 1 minute every seond
|
||||
{
|
||||
#if USE_DS1307
|
||||
RTC.readTime();
|
||||
sprintf(psz, "%02d%c%02d", RTC.h, (f ? ':' : ' '), RTC.m);
|
||||
#else
|
||||
uint16_t h, m, s;
|
||||
|
||||
m = millis()/1000;
|
||||
h = (m/60) % 24;
|
||||
m %= 60;
|
||||
sprintf(psz, "%02d%c%02d", h, (f ? ':' : ' '), m);
|
||||
#endif
|
||||
}
|
||||
|
||||
void createHString(char *pH, char *pL)
|
||||
{
|
||||
for (; *pL != '\0'; pL++)
|
||||
*pH++ = *pL | 0x80; // offset character
|
||||
|
||||
*pH = '\0'; // terminate the string
|
||||
}
|
||||
|
||||
void setup(void)
|
||||
{
|
||||
invertUpperZone = (HARDWARE_TYPE == MD_MAX72XX::GENERIC_HW || HARDWARE_TYPE == MD_MAX72XX::PAROLA_HW);
|
||||
|
||||
// initialise the LED display
|
||||
P.begin(MAX_ZONES);
|
||||
|
||||
// Set up zones for 2 halves of the display
|
||||
P.setZone(ZONE_LOWER, 0, ZONE_SIZE - 1);
|
||||
P.setZone(ZONE_UPPER, ZONE_SIZE, MAX_DEVICES - 1);
|
||||
P.setFont(numeric7SegDouble);
|
||||
|
||||
P.setCharSpacing(P.getCharSpacing() * 2); // double height --> double spacing
|
||||
|
||||
if (invertUpperZone)
|
||||
{
|
||||
P.setZoneEffect(ZONE_UPPER, true, PA_FLIP_UD);
|
||||
P.setZoneEffect(ZONE_UPPER, true, PA_FLIP_LR);
|
||||
|
||||
P.displayZoneText(ZONE_LOWER, szTimeL, PA_RIGHT, SPEED_TIME, PAUSE_TIME, PA_PRINT, PA_NO_EFFECT);
|
||||
P.displayZoneText(ZONE_UPPER, szTimeH, PA_LEFT, SPEED_TIME, PAUSE_TIME, PA_PRINT, PA_NO_EFFECT);
|
||||
}
|
||||
else
|
||||
{
|
||||
P.displayZoneText(ZONE_LOWER, szTimeL, PA_CENTER, SPEED_TIME, PAUSE_TIME, PA_PRINT, PA_NO_EFFECT);
|
||||
P.displayZoneText(ZONE_UPPER, szTimeH, PA_CENTER, SPEED_TIME, PAUSE_TIME, PA_PRINT, PA_NO_EFFECT);
|
||||
}
|
||||
|
||||
#if USE_DS1307
|
||||
RTC.control(DS1307_CLOCK_HALT, DS1307_OFF);
|
||||
RTC.control(DS1307_12H, DS1307_OFF);
|
||||
#endif
|
||||
}
|
||||
|
||||
void loop(void)
|
||||
{
|
||||
static uint32_t lastTime = 0; // millis() memory
|
||||
static bool flasher = false; // seconds passing flasher
|
||||
|
||||
P.displayAnimate();
|
||||
if (P.getZoneStatus(ZONE_LOWER) && P.getZoneStatus(ZONE_UPPER))
|
||||
{
|
||||
// Adjust the time string if we have to. It will be adjusted
|
||||
// every second at least for the flashing colon separator.
|
||||
if (millis() - lastTime >= 1000)
|
||||
{
|
||||
lastTime = millis();
|
||||
getTime(szTimeL, flasher);
|
||||
createHString(szTimeH, szTimeL);
|
||||
flasher = !flasher;
|
||||
|
||||
P.displayReset();
|
||||
|
||||
// synchronise the start
|
||||
P.synchZoneStart();
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user