Hi,
Ok, I've found something strange - it seems to be something to do with my dmd.begin() line.
The below code will print out the time correctly to the Serial Monitor:
Code: Select all
/*
Countdown on a single DMD display
*/
#include <SPI.h>
#include <DMD2.h>
#include <fonts/SystemFont5x7.h>
#include <SoftI2C.h> // initialise required libraries
#include <DS3232RTC.h>
SoftI2C i2c(A4, A5); // assign pins to SDA and SCL
DS3232RTC rtc(i2c);
const int COUNTDOWN_FROM = 12;
int counter = COUNTDOWN_FROM;
SoftDMD dmd(1,1); // DMD controls the entire display
DMD_TextBox upper_box(dmd, 7, 0); // "box" provides a text box to automatically write to/scroll the display
DMD_TextBox lower_box(dmd, 1, 9);
// the setup routine runs once when you press reset:
void setup() {
Serial.begin(9600);
dmd.setBrightness(255);
dmd.selectFont(SystemFont5x7);
// dmd.begin();
}
// the loop routine runs over and over again forever:
void loop() {
RTCTime time;
rtc.readTime(&time);
Serial.print("Time: ");
printDec2(time.hour);
Serial.print(':');
printDec2(time.minute);
Serial.print(':');
printDec2(time.second);
Serial.println();
Serial.print(time.hour, DEC);
Serial.print(":");
Serial.print(time.minute, DEC);
Serial.print(":");
Serial.print(time.second, DEC);
Serial.print("\n");
delay(1000);
}
void printDec2(int value)
{
Serial.print((char)('0' + (value / 10)));
Serial.print((char)('0' + (value % 10)));
}
Serial Monitor:
Code: Select all
Time4:13
7:4:13
Time: 07:04:14
7:4:14
Time: 07:04:15
7:4:15
Time: 07:04:16
7:4:16
Time: 07:04:17
7:4:17
Time: 07:04:18
7:4:18
Time: 07:04:20
However, when I uncomment the dmd.begin() line in setup(), and upload that, it then prints out the garbage from before:
Code: Select all
Time: 07:05:30
7:5:30
Time: 01:02:02
1:2:2
Time: 00:00:00
0:0:0
Time: 00:81:06
0:81:6
Time: 00:81:06
0:81:6
Time: 16:00:00
16:0:0
Time: 00:00:00
0:0:0
Does that mean there's some kind of incompatibility between the RTC library, and the DMD2 library?
Cheers,
Victor