Hi there,
Im repurposing an older sketch for a new project, Its basically is a timer that activates a servo at regular intervals during the timer and prints the timer and other information on a standard 20x4 ic2 lcd.
In the new project I would like to use a 7 segment display (4 digit) for the timer, in addition to having it on the LCD screen.
What I'm struggling with though is what commands to put to update the 7segment display with the time. Obviously its a little bit more involved than typing lcd.print lol.
Im using the tm1637 library, and in test countdown scripts its working fine, but I cant get the timer to output on the 7segment as well as the lcd, just the LCD.
Ive included the timer section of my script. It is self contained as I didnt want to use the loop function for the timer. Ive excluded my earlier attempts at adding the 7segment sections as it was turning into a right mess.
void c41DevCycle() {
uint8_t c41Devcountdown = 180;
uint8_t c41relayCountdown = 15;
bool runningc41Dev = true;
bool updateDisplayc41Dev = true;
uint32_t countdownTimec41Dev = millis();
uint32_t relayOnTimec41Dev = 5;
uint32_t relayOffTimec41Dev = 25;
bool relayStatec41Dev = true;
functionOn();
while (runningc41Dev) {
if (updateDisplayc41Dev) {
updateDisplayc41Dev = false;
lcd.setCursor(0, 2);
char m[3];
char s[3];
sprintf(m, "%02d", int(c41Devcountdown / 60));
sprintf(s, "%02d", c41Devcountdown % 60);
lcd.print(m);
lcd.print(":");
lcd.print(s);
if (relayStatec41Dev) {
lcd.print(" Agitating");
}
else {
lcd.print(" Standing");
}
lcd.setCursor(0, 4);
if (relayStatec41Dev) {
lcd.print("AGI stops in ");
}
else {
lcd.print("Next AGI in ");
}
sprintf(s, "%02d", c41relayCountdown);
lcd.print(s);
}
// Every second: count down.
if (millis() - countdownTimec41Dev > 1000) {
if (c41Devcountdown == 0) { // Finished! (this happens after the last second has passed).
runningc41Dev = false;
}
c41Devcountdown--;
c41relayCountdown--;
countdownTimec41Dev += 1000;
updateDisplayc41Dev = true;
if (c41relayCountdown == 0) { // Switch the relay.
if (relayStatec41Dev) {
functionOff();
relayStatec41Dev = false;
c41relayCountdown = relayOffTimec41Dev;
}
else {
functionOn();
relayStatec41Dev = true;
c41relayCountdown = relayOnTimec41Dev;
}
}
}
}
lcd.clear();
}
functionOn and Off are my servo scripts.
Any idea what commands I can use to output to the 7segment?, or any starters?, Its only the overall timer Im trying to output to the 7segment