Hmm das ist nicht so einfach.
Also meine Anzeigen und Funktionen liegen in einem eigenem Tab:
// ##################################### mainScreen #####################################
void mainScreen(){
clearLCD();
goTo(1);
LCD.print(weekdayNames[weekday()-1]);
goTo(12);
lcdDigits(temp);
LCD.print('"');
goTo(16);
LCD.print("KW:");
lcdDigits(WN);
goTo(22);
lcdDigits(day());
LCD.print(".");
lcdDigits((month()));
LCD.print(".");
LCD.print(year());
}
// #################################### statusScreen ##################################
void statusScreen(){
clearLCD();
if (DCF77Status==1){
goTo(0);
LCD.print("Sync laeuft");
goTo(16);
LCD.print("Versuche: ");
lcdDigits(DCF77versuche);
LCD.print("/");
lcdDigits(maxVersuche);
}
if (DCF77Status==0 && DCF77Abbruch==0){
goTo(0);
LCD.print("Sync erfolgreich");
goTo(16);
LCD.print("Strom aus!");
}
if (DCF77Status==0 && DCF77Abbruch==1){
goTo(0);
LCD.print("Sync Fehler!");
goTo(16);
LCD.print("Abgebrochen");
}
if (DCF77Status==0 && DCF77Abbruch==2){
goTo(0);
LCD.print("Sync Fehler!");
goTo(16);
LCD.print("Datenmuell");
}
}
// #################################### discoScreen ###################################
void discoScreen(){
clearLCD();
goTo(2);
LCD.print("Disco-Modus");
if (discomode==0){
goTo(20);
LCD.print("auto (");
LCD.print(randiscomode);
LCD.print(")");
}else{
goTo(20);
LCD.print("Modus: ");
LCD.print(discomode);
}
}
// ######################## 0 vor einstelligen Ziffern einfügen ########################
void lcdDigits(int digits){
// Einstellige Werte mit führender Null versehen
if(digits < 10) {
LCD.print("0");
}
LCD.print(digits);
}
// ###################### Displayfunktionen ##########################
void selectLineOne(){ //puts the cursor at line 0 char 0.
LCD.print(0xFE, BYTE); //command flag
LCD.print(128, BYTE); //position
}
void selectLineTwo(){ //puts the cursor at line 0 char 0.
LCD.print(0xFE, BYTE); //command flag
LCD.print(192, BYTE); //position
}
void goTo(int position) { //position = line 1: 0-15, line 2: 16-31, 31+ defaults back to 0
if (position<16){ LCD.print(0xFE, BYTE); //command flag
LCD.print((position+128), BYTE); //position
}else if (position<32){LCD.print(0xFE, BYTE); //command flag
LCD.print((position+48+128), BYTE); //position
} else { goTo(0); }
}
void clearLCD(){
LCD.print(0xFE, BYTE); //command flag
LCD.print(0x01, BYTE); //clear command.
}
void backlightOn(){ //turns on the backlight
LCD.print(0x7C, BYTE); //command flag for backlight stuff
LCD.print(157, BYTE); //light level.
}
void backlightOff(){ //turns off the backlight
LCD.print(0x7C, BYTE); //command flag for backlight stuff
LCD.print(128, BYTE); //light level for off.
}
void serCommand(){ //a general function to call the command flag for issuing all other commands
LCD.print(0xFE, BYTE);
}
Und aufgerufen wird immer durch den kram:
// ################## serLCD initialisieren ###############################
SoftwareSerial LCD = SoftwareSerial(0, txPin); // init mit txPin (rx wird nicht benötigt)
...
pinMode(txPin, OUTPUT); // serLCD PIN als OUTPUT einrichten
LCD.begin(9600); // Serielle Übertragung zum LCD starten
delay(100);
clearLCD(); // LCD löschen
delay(100);
backlightOn(); // Hintergrund anschalten
delay(100);
...
Hierdurch:
attachInterrupt(1, secTakt, FALLING); // Pin3 Sekunden Interrupt
und im zusammenhang mit:
void secTakt() {
Takt = 1; // Setze Takt auf 1 damit Auswertung weiss es ist eine Sekunde rum
}
und:
if (Takt == 1){
// // in die einzelnen Zeitfunktionen springen
if (previousTime[0]!=hour()) newHour();
if (previousTime[1]!=minute()) newMinute();
if (previousTime[2]!=second()) newSecond();
if (previousTime[3]!=day()) newDay();
if (previousTime[4]!=month()) newMonth();
if (previousTime[5]!=year()) newYear();
// // Letze Zeit setzen als neuen vergleichswert
previousTime[0] = hour();
previousTime[1] = minute();
previousTime[2] = second();
previousTime[3] = day();
previousTime[4] = month();
previousTime[5] = year();
Takt = 0;
}
wird dies aufgerufen:
void newSecond(){
tempRead();
if (ButtonValue == 1){
// Button Auswertung mit lang und kurz drücken
}
switch(screen) {
case 1: // Hauptanzeige
mainScreen();
if (DCF77Status == 0){
rainbowSecond();
}
break;
case 2: // Statusanzeige
statusScreen();
if (DCF77Status == 0){
rainbowSecond();
}
break;
case 3: // Disco
discoScreen();
// rainbowDisco wird im loop aufgerufen (Sekundentakt reicht nicht
break;
default:
mainScreen();
if (DCF77Status == 0){
rainbowSecond();
}
screen= 1;
break;
}
}
Schau mal ob es dir was bringt.