So I reduced the size of my project. Short description: I have two rows of LED displays and control them with the LedControl library.
When commenting out the "printClockDesc(1, 0, hours);" line in the loop() function I have 1006 bytes (49%) of dynamic memory used. If I leave the comment out, 2224 bytes (108%) are used.
printClockDesc() can be found in OUTPUT tab.
MAIN TAB
#include <LedControl.h>
// Emulate Serial1 on pins 5/6 if not present
#ifndef HAVE_HWSERIAL1
#include "SoftwareSerial.h"
SoftwareSerial Serial1(5, 6); // RX, TX
#endif
// 1. DISPLAY GLOBES
int DIN1 = 10;
int CS1 = 9;
int CLK1 = 8;
LedControl lc1 = LedControl(DIN1, CLK1, CS1, 8);
// 2. DISPLAY GLOBES
int DIN2 = 13;
int CS2 = 12;
int CLK2 = 11;
int numberOfDisplays = 8;
LedControl lc2 = LedControl(DIN2, CLK2, CS2, 8);
// WEATHER GLOBES
char temperature = "27";
char weatherConditionGerman = "klarer Himmel";
char hours = "12";
void setup() {
// initialize serial for debugging
Serial.begin(115200);
setupWholeDisplay();
}
unsigned int startTimeCheck;
unsigned int myCheckDelay = 500;
void loop() {
if (millis() - startTimeCheck > myCheckDelay) {
printClock(1, 0, hours);
//printClockDesc(1, 0, hours);
printWord(2, "Temp: " + String(temperature) + " Himmel: " + weatherConditionGerman);
startTimeCheck = millis();
}
}
ALPHABET TAB
const int IMAGES[76][8] = {
{
// 0
B01111100,
B11000110,
B11001110,
B11011110,
B11110110,
B11100110,
B01111100,
B00000000
}, {
// 9
B01111000,
B11001100,
B11001100,
B01111100,
B00001100,
B00011000,
B01110000,
B00000000
}, {
// a
B00000000,
B00000000,
B01111000,
B00001100,
B01111100,
B11001100,
B01110110,
B00000000
}, {
// z
B00000000,
B00000000,
B11111100,
B10011000,
B00110000,
B01100100,
B11111100,
B00000000
}, {
// clock1
B00111100,
B01001110,
B10001111,
B10001111,
B10000001,
B10000001,
B01000010,
B00111100
}, {
// clock2
B00111100,
B01000010,
B10000001,
B10000001,
B10001111,
B10001111,
B01001110,
B00111100
}, {
// clock3
B00111100,
B01000010,
B10000001,
B10000001,
B11110001,
B11110001,
B01110010,
B00111100
}, {
// clock4
B00111100,
B01110010,
B11110001,
B11110001,
B10000001,
B10000001,
B01000010,
B00111100
}
};
const int IMAGES_LEN = sizeof(IMAGES) / 8;
void getCharacter(byte byteArray[], char character) {
switch (character) {
case ' ':
for (int i = 0; i < 8; i++) {
byteArray[i] = B00000000;
}
break;
case '0':
for (int i = 0; i < 8; i++) {
byteArray[i] = IMAGES[0][i];
}
break;
[...MORE NUMEBRS...]
case '9':
for (int i = 0; i < 8; i++) {
byteArray[i] = IMAGES[9][i];
}
break;
case 'a':
for (int i = 0; i < 8; i++) {
byteArray[i] = IMAGES[36][i];
}
break;
[...MORE CHARACTERS...]
case 'z':
for (int i = 0; i < 8; i++) {
byteArray[i] = IMAGES[61][i];
}
break;
default:
break;
}
}
void getClock(byte byteArray[], int hour) {
int clockQuarter = 0;
if (hour == 12 || hour == 0) {
for (int i = 0; i < 8; i++) {
byteArray[i] = IMAGES[72][i];
}
} else if (hour == 15 || hour == 3) {
for (int i = 0; i < 8; i++) {
byteArray[i] = IMAGES[73][i];
}
} else if (hour == 18 || hour == 6) {
for (int i = 0; i < 8; i++) {
byteArray[i] = IMAGES[74][i];
}
} else if (hours == 21 || hour == 9) {
for (int i = 0; i < 8; i++) {
byteArray[i] = IMAGES[75][i];
}
}
}
OUTPUT TAB
byte matrixMemory1[8][8];
byte matrixMemory2[50][8];
void printClock(byte line, byte pos, char* hour) {
byte myChar[8];
getClock(myChar, atoi(hour));
printDisplay(line, pos, myChar);
}
void printClockDesc(byte line, byte pos, char* hour) {
byte myChar[8];
String m = "m";
getCharacter(myChar, m.charAt(0));
printDisplay(line, pos+2, myChar);
if(atoi(hour) >= 12) {
getCharacter(myChar, 'p');
printDisplay(line, pos+1, myChar);
} else {
getCharacter(myChar, 'a');
printDisplay(line, pos+1, myChar);
}
}
void printWord (byte line, String wordToPrint) {
for (int i = 0; i < wordToPrint.length(); i++) {
byte myChar[8];
getCharacter(myChar, wordToPrint.charAt(i));
printDisplay(line, i, myChar);
}
}
void printDisplay(byte line, int disNr, char* content) {
for (int j = 0; j < 8; j++) {
if (line == 1) {
matrixMemory1[disNr][j] = content[j];
}
else if (line == 2) {
matrixMemory2[disNr][j] = content[j];
}
}
if (line == 1) {
if (disNr < lc1.getDeviceCount()) {
printByte(1, matrixMemory1[disNr], disNr);
}
}
else if (line == 2) {
if (disNr < lc2.getDeviceCount()) {
printByte(2, matrixMemory2[disNr], disNr);
}
}
}
DISPLAY TAB
void setupWholeDisplay () {
int i;
// 1.
for (i = 0; i < lc1.getDeviceCount(); i++) {
lc1.shutdown(i, false); //The MAX72XX is in power-saving mode on startup
lc1.setIntensity(i, 15); // Set the brightness to maximum value
lc1.clearDisplay(i); // and clear the display
}
// 2.
for (i = 0; i < lc2.getDeviceCount(); i++) {
lc2.shutdown(i, false); //The MAX72XX is in power-saving mode on startup
lc2.setIntensity(i, 15); // Set the brightness to maximum value
lc2.clearDisplay(i); // and clear the display
}
}
void printByte(byte line, byte character [], int disAddr)
{
int i = 0;
for (i = 0; i < 8; i++)
{
if(line == 1) {
lc1.setRow(disAddr, i, reverse(character[7 - i]));
} else if(line == 2) {
lc2.setRow(disAddr, i, reverse(character[7 - i]));
}
}
}
byte reverse(byte in) {
byte out = 0;
for (int i = 0; i < 8; i++)
out |= ((in >> i) & 1) << (7 - i);
return out;
}
I hope it's not too much code now 