[SOLVED] Time increment not showing on screen??

Hi.

Just wanted to know if anyone can see why this is not working. This section of my program has the capability of inputting two times which are saved to EEPROM for use later.

The problem is when I click a particular button for the first time, even moving from one button to another, it is supposed to increase or decline the value by 1. However, the first click doesn’t do this. I have the output both displayed to serial monitor and the screen and the serial monitor shows it as increasing and decreasing as it should, but it doesn’t display on the screen until another button is clicked and then the original number shifts to where it should, and the issue then starts with the new button pressed.

I know it is something simple like there is a line in the wrong place but I have had a fiddle and can’t see why it isn’t working. The serial print is right above the screen print so don’t see why one is working and the other isn’t.

case 13:                 // LIGHT SCHEDULE LUNAR --> LOW SUN
          
          sprintf(bufL_LSstart, "%02d:%02d", lunartolowsunH, lunartolowsunM);
          sprintf(bufL_LSdur, "%02d:%02d", lunartolowsundurH, lunartolowsundurM);
          myGLCD.setFont(Ubuntu);
          myGLCD.setBackColor(0,0,0);   
      
          if ((x>=185) && (x<=214) && (y>=206) && (y<=235))                   // Return button
            {
              Serial.println("Return button pressed"); 
              myGLCD.setColor(255,255,255);
              myGLCD.drawRoundRect(185,206,214,235);
              delay(500);
              menu3();   
            }
            
          if ((x>=100) && (x<=130) && (y>=70) && (y<=100))     // Lunar to low sun -  start H up     
            { 
              lunartolowsunH = EEPROM.read(18);                // Read previous HOUR value
              lunartolowsunH = lunartolowsunH + 1;             // Add 1 to previous value
                if (lunartolowsunH > 23)                       // Checks to see if hour selected is over 24
                  {
                    lunartolowsunH = 0;                        // Resets 24 back to 0
                  }
              EEPROM.write(18, lunartolowsunH);               // Write new hour to EEPROM
                myGLCD.print(bufL_LSstart,94,115);
                Serial.println("Data as follows:");
                Serial.print("lunartolowsunH = ");
                Serial.println(lunartolowsunH);
                Serial.print("lunartolowsunM = ");
                Serial.println(lunartolowsunM);
              delay(250); 
            }
      
          if ((x>=100) && (x<=130) && (y>=160) && (y<=190))    // Lunar to low sun -  start H down        
            { 
              lunartolowsunH = EEPROM.read(18);                // Read previous HOUR value
              lunartolowsunH = lunartolowsunH - 1;             // Subtract 1 to previous value
                if (lunartolowsunH < 0)                        // Checks to see if hour selected is under 0
                  {
                    lunartolowsunH = 23;                       // Resets 24 back to 0
                  }
              EEPROM.write(18, lunartolowsunH);                // Write new hour to EEPROM
                myGLCD.print(bufL_LSstart,94,115);
                Serial.println("Data as follows:");
                Serial.print("lunartolowsunH = ");
                Serial.println(lunartolowsunH);
                Serial.print("lunartolowsunM = ");
                Serial.println(lunartolowsunM);
              delay(250); 
            }
                   
          if ((x>=175) && (x<=205) && (y>=70) && (y<=100))      // Lunar to low sun -  start M up       
            { 
              lunartolowsunM = EEPROM.read(19);                // Read previous MINUTE value
              lunartolowsunM = lunartolowsunM + 1;             // Add 1 to previous value
                if (lunartolowsunM > 59)                       // Checks to see if hour selected is over 60
                  {
                    lunartolowsunM = 0;                        // Resets 24 back to 0
                  }
              EEPROM.write(19, lunartolowsunM);                // Write new hour to EEPROM
                myGLCD.print(bufL_LSstart,94,115);
                Serial.println("Data as follows:");
                Serial.print("lunartolowsunH = ");
                Serial.println(lunartolowsunH);
                Serial.print("lunartolowsunM = ");
                Serial.println(lunartolowsunM);
              delay(250); 
            }
            
          if ((x>=175) && (x<=205) && (y>=160) && (y<=190))      // Lunar to low sun -  start M down        
            { 
              lunartolowsunM = EEPROM.read(19);                  // Read previous MINUTE value
              lunartolowsunM = lunartolowsunM - 1;               // Add 1 to previous value
                if (lunartolowsunM < 0)                          // Checks to see if hour selected is over 60
                  {
                    lunartolowsunM = 59;                         // Resets 24 back to 0
                  }
              EEPROM.write(19, lunartolowsunM);                  // Write new hour to EEPROM
                myGLCD.print(bufL_LSstart,94,115);
                Serial.println("Data as follows:");
                Serial.print("lunartolowsunH = ");
                Serial.println(lunartolowsunH);
                Serial.print("lunartolowsunM = ");
                Serial.println(lunartolowsunM);
              delay(250); 
            }
                 
          break;

The code is too long so only copied one of the time inputs.

I look forward to your replies.
Thanks, Steve.

Its ok, I’ve solved it.

If it can be to any use to anyone in the future, the relevant line below needs to go just before each print command so it can work out what it needs to write…

sprintf(bufL_LSstart, "%02d:%02d", lunartolowsunH, lunartolowsunM);
sprintf(bufL_LSdur, "%02d:%02d", lunartolowsundurH, lunartolowsundurM);

ie:

if ((x>=100) && (x<=130) && (y>=70) && (y<=100))     // Lunar to low sun -  start H up     
            { 
              lunartolowsunH = EEPROM.read(18);                // Read previous HOUR value
              lunartolowsunH = lunartolowsunH + 1;             // Add 1 to previous value
                if (lunartolowsunH > 23)                       // Checks to see if hour selected is over 24
                  {
                    lunartolowsunH = 0;                        // Resets 24 back to 0
                  }
              EEPROM.write(18, lunartolowsunH);              // Write new hour to EEPROM
                sprintf(bufL_LSstart, "%02d:%02d", lunartolowsunH, lunartolowsunM);
                myGLCD.print(bufL_LSstart,94,115);
                Serial.println("Data as follows:");
                Serial.print("lunartolowsunH = ");
                Serial.println(lunartolowsunH);
                Serial.print("lunartolowsunM = ");
                Serial.println(lunartolowsunM);
              delay(250); 
            }