Hello, LCD problem, cursor position dublicates

The problem is when i set up time everything is fine, but when i do that my days change whitch are in different menu place, kinda strange problem, im pretty sure it’s simple, what i did wrong, can somebody look at this? :slight_smile:

byte vh, vmi, vh1, vm1 = 0;
#define Hour() vh
#define Minute() vmi
#define Hour1() vh1
#define Minute1() vm1

#define settime(h, m,h1, m1)vh=h; vmi= m; vh1=h1; vm1= m1;
byte _pos = 0;


/*******************************Laikas***********************/
/*
  //EEPROM
  int eepromMin = 0;
  int eepromHour = 0;

  int eepromHourON = 0;
  int eepromHourOF = 0;
  int eepromMinON = 0;
  int eepromMinOf = 0;
  int mode = 1;
  //EEPROM adress
  #define adr1ON    2
  #define adr1OF    4
  #define adr2ON    6
  #define adr2OF    8
*/
void HELP_FUNC_set_time(char l_i)
{
  switch (_pos)
  {
    case 0: settime(Hour() + l_i, Minute(), Hour1(), Minute1()); break;
    case 1: settime(Hour(), Minute() + l_i, Hour1(), Minute1()); break;
    case 2: settime(Hour(), Minute(), Hour1() + l_i, Minute1()); break;
    case 3: settime(Hour(), Minute(), Hour1(), Minute1() + l_i); break;
  }
}
void TimerDiplay() {
  lcd.setCursor(0, 0);
  lcd.print("Pradzia:");
  lcd.setCursor(10, 0);
  if (_pos == 0) {
    lcd.print("^");
  }
  printDigits(Hour());
  lcd.print(":");
  if (_pos == 1) {
    lcd.print("^");
  }
  printDigits(Minute());
  lcd.setCursor(0, 1);
  lcd.print("Pabaiga:");
  lcd.setCursor(10, 1);
  if (_pos == 2) {
    lcd.print("^");
  }
  printDigits(Hour1());
  lcd.print(":");
  if (_pos == 3) {
    lcd.print("^");
  }
  printDigits(Minute1());




  //set cursor
  switch (_pos) {
    case 0: lcd.setCursor(10, 0); lcd.blink();  break;
    case 1: lcd.setCursor(13, 0); lcd.blink();  break;
    case 2: lcd.setCursor(10, 1); lcd.blink(); break;
    case 3: lcd.setCursor(13, 1); lcd.blink(); break;
    default: lcd.noBlink(); break;;
  }
}
void printDigits(int digits) {
  if (digits < 10) {
    lcd.print('0');
  }
  lcd.print(digits);
}

void LCDML_DISP_setup(LCDML_FUNC_timersetup1)
// *********************************************************************
{
  TimerDiplay();
}

void LCDML_DISP_loop(LCDML_FUNC_timersetup1) {

  if (LCDML_BUTTON_checkAny()) { // check if any button is presed (enter, up, down, left, right)
    // LCDML_DISP_funcend calls the loop_end function

    if (LCDML_BUTTON_checkUp())    {
      HELP_FUNC_set_time(+1);
      if (Hour() > 23) {
        Hour() = 0;
      }

      if (Hour1() > 23) {
        Hour1() = 0;
      }
      if (Minute() > 59) {
        Minute() = 0;
      }
      if (Minute1() > 59) {
        Minute1() = 0;
      }
      LCDML_BUTTON_resetUp();
    }
    if (LCDML_BUTTON_checkDown())  {
      HELP_FUNC_set_time(-1);
      if (Hour() > 23) {
        Hour() = 0;
      }
      if (Hour1() > 23) {
        Hour1() = 0;
      }
      if (Minute() > 59) {
        Minute() = 0;
      }
      if (Minute1() > 59) {
        Minute1() = 0;
      }
      LCDML_BUTTON_resetDown();
    }
    if (LCDML_BUTTON_checkRight()) {
      _pos = (_pos + 1) % 5;
      LCDML_BUTTON_resetRight();
    }
    if (LCDML_BUTTON_checkLeft()) {
      _pos = (_pos - 1) % 5;
      LCDML_BUTTON_resetLeft();
    }
    lcd.clear();
    TimerDiplay();
  }
  if (LCDML_BUTTON_checkEnter()) {
    lcd.clear();
    lcd.print("Ijungta");
    delay(1000);
    LCDML_BUTTON_resetEnter();

    lcd.clear();
    TimerDiplay();

  }
}

void LCDML_DISP_loop_end(LCDML_FUNC_timersetup1)
{
  LCDML_DISP_funcend();
  lcd.noBlink();
}

/********************************DIenos*************************************/
byte day0, day1, day2, day3, day4, day5, day6 = 0;
#define Days0() day0
#define Days1() day1
#define Days2() day2
#define Days3() day3
#define Days4() day4
#define Days5() day5
#define Days6() day6


#define setday(d0, d1, d2, d3, d4, d5, d6)day0 = d0; day1 = d1; day2 = d2; day3 = d3; day4 = d4; day5 = d5; day6 = d6;
byte _pos1 = 0;
void HELP_FUNC_set_day(int8_t l_i)
{
  switch (_pos1)
  {
    case 0: setday(Days0() + l_i, Days1(), Days2(), Days3(), Days4(), Days5(), Days6()); break;
    case 1: setday(Days0() + l_i, Days1() + l_i, Days2(), Days3(), Days4(), Days5(), Days6()); break;
    case 2: setday(Days0() + l_i, Days1(), Days2() + l_i, Days3(), Days4(), Days5(), Days6()); break;
    case 3: setday(Days0() + l_i, Days1(), Days2(), Days3() + l_i, Days4(), Days5(), Days6()); break;
    case 4: setday(Days0() + l_i, Days1(), Days2(), Days3(), Days4() + l_i, Days5(), Days6()); break;
    case 5: setday(Days0() + l_i, Days1(), Days2(), Days3(), Days4(), Days5() + l_i, Days6()); break;
    case 6: setday(Days0() + l_i, Days1(), Days2(), Days3(), Days4(), Days5(), Days6() + l_i); break;
  }
}

void daysDisplay() {

  if (_pos1 == 0) {
    lcd.print("^");
  }
  lcd.setCursor(1, 0);
  printDigits(Days0());
  lcd.print(" ");

  if (_pos1 == 1) {
    lcd.print("^");
  }
  printDigits(Days1());
  lcd.print(" ");

  if (_pos1 == 2) {
    lcd.print("^");
  }
  printDigits(Days2());
  lcd.print(" ");

  if (_pos1 == 3) {
    lcd.print("^");
  }
  printDigits(Days3());
  lcd.print(" ");

  if (_pos1 == 4) {
    lcd.print("^");
  }
  printDigits(Days4());
  lcd.print(" ");

  if (_pos1 == 5) {
    lcd.print("^");
  }
  printDigits(Days5());
  lcd.print(" ");

  if (_pos1 == 6) {
    lcd.print("^");
  }
  printDigits(Days6());

  //set cursor
  switch (_pos1) {
    case 0: lcd.setCursor(0, 0); lcd.blink();  break;
    case 1: lcd.setCursor(2, 0); lcd.blink();  break;
    case 2: lcd.setCursor(4, 0); lcd.blink(); break;
    case 3: lcd.setCursor(6, 0); lcd.blink(); break;
    case 4: lcd.setCursor(8, 0); lcd.blink(); break;
    case 5: lcd.setCursor(10, 0); lcd.blink(); break;
    case 6: lcd.setCursor(12, 0); lcd.blink(); break;
    default: lcd.noBlink(); break;;
  }
}
void LCDML_DISP_setup(LCDML_FUNC_daySetup)
{ daysDisplay();
}
void LCDML_DISP_loop(LCDML_FUNC_daySetup)
{
  if (LCDML_BUTTON_checkAny()) { // check if any button is presed (enter, up, down, left, right)
    // LCDML_DISP_funcend calls the loop_end function

    if (LCDML_BUTTON_checkUp())    {
      HELP_FUNC_set_day(+1);
      LCDML_BUTTON_resetUp();
    }
    if (LCDML_BUTTON_checkDown())    {
      HELP_FUNC_set_day(-1);
      LCDML_BUTTON_resetDown();
    }

    if (LCDML_BUTTON_checkRight()) {
      _pos1 = (_pos1 + 1) % 5;
      LCDML_BUTTON_resetRight();
    }
  }
}

I didn't try to understand your program, but I don't see where you blank any part of the display when you write something that may be shorter than what was there before. Could that be the problem?

Paul

artazzs1:

void HELP_FUNC_set_time(char l_i)

{
 switch (_pos)
 {
   case 0: settime(Hour() + l_i, Minute(), Hour1(), Minute1()); break;
   case 1: settime(Hour(), Minute() + l_i, Hour1(), Minute1()); break;
   case 2: settime(Hour(), Minute(), Hour1() + l_i, Minute1()); break;
   case 3: settime(Hour(), Minute(), Hour1(), Minute1() + l_i); break;
 }
}
void TimerDiplay() {
 //set cursor
 switch (_pos) {
   case 0: lcd.setCursor(10, 0); lcd.blink();  break;
   case 1: lcd.setCursor(13, 0); lcd.blink();  break;
   case 2: lcd.setCursor(10, 1); lcd.blink(); break;
   case 3: lcd.setCursor(13, 1); lcd.blink(); break;
   default: lcd.noBlink(); break;;
 }
}

void HELP_FUNC_set_day(int8_t l_i)
{
 switch (_pos1)
 {
   case 0: setday(Days0() + l_i, Days1(), Days2(), Days3(), Days4(), Days5(), Days6()); break;
   case 1: setday(Days0() + l_i, Days1() + l_i, Days2(), Days3(), Days4(), Days5(), Days6()); break;
   case 2: setday(Days0() + l_i, Days1(), Days2() + l_i, Days3(), Days4(), Days5(), Days6()); break;
   case 3: setday(Days0() + l_i, Days1(), Days2(), Days3() + l_i, Days4(), Days5(), Days6()); break;
   case 4: setday(Days0() + l_i, Days1(), Days2(), Days3(), Days4() + l_i, Days5(), Days6()); break;
   case 5: setday(Days0() + l_i, Days1(), Days2(), Days3(), Days4(), Days5() + l_i, Days6()); break;
   case 6: setday(Days0() + l_i, Days1(), Days2(), Days3(), Days4(), Days5(), Days6() + l_i); break;
 }
}

void daysDisplay() {
 //set cursor
 switch (_pos1) {
   case 0: lcd.setCursor(0, 0); lcd.blink();  break;
   case 1: lcd.setCursor(2, 0); lcd.blink();  break;
   case 2: lcd.setCursor(4, 0); lcd.blink(); break;
   case 3: lcd.setCursor(6, 0); lcd.blink(); break;
   case 4: lcd.setCursor(8, 0); lcd.blink(); break;
   case 5: lcd.setCursor(10, 0); lcd.blink(); break;
   case 6: lcd.setCursor(12, 0); lcd.blink(); break;
   default: lcd.noBlink(); break;;
 }
}

Your code as written doesn't make it easy to read.
But, from what I gather, you have 2 colums and 2 rows in the time setup and 7 columns and 1 row in the timer setup.
Your question is unclear.
Perhaps you can provide a couple of screenshots for context?

I kind of figure out what is the problem, but im not sure how to fix it. The problem is that when I set up Timer1 , Timer2 also reacts and sets up but in different section of menu it's like If i press button UP both menus react and presses that button actualy whole program does it, i have to somehow localize it i was thinking about boolean function, but im not sure where to put it exactly the program is watering automation based on RTC So 1 timer is like 1 green house 2 timer is 2 green house

void LCDML_DISP_loop(LCDML_FUNC_timersetup1) {

  if (LCDML_BUTTON_checkAny()) { // check if any button is presed (enter, up, down, left, right)
    // LCDML_DISP_funcend calls the loop_end function

    if (LCDML_BUTTON_checkUp())    {
      HELP_FUNC_set_time(+1);
      (s == 1);
      if (Hour() > 23) {
        Hour() = 0;
      }

      if (Hour1() > 23) {
        Hour1() = 0;
      }
      if (Minute() > 59) {
        Minute() = 0;
      }
      if (Minute1() > 59) {
        Minute1() = 0;
      }
     if LCDML_BUTTON_resetUp(); {
      (s == 0);
     }
    }
    if (LCDML_BUTTON_checkDown())  {
      HELP_FUNC_set_time(-1);
      if (Hour() > 23) {
        Hour() = 0;
      }
      if (Hour1() > 23) {
        Hour1() = 0;
      }
      if (Minute() > 59) {
        Minute() = 0;
      }
      if (Minute1() > 59) {
        Minute1() = 0;
      }
      LCDML_BUTTON_resetDown();
    }
    if (LCDML_BUTTON_checkRight()) {
      _pos = (_pos + 1) % 5;
      LCDML_BUTTON_resetRight();
    }
    if (LCDML_BUTTON_checkLeft()) {
      _pos = (_pos - 1) % 5;
      LCDML_BUTTON_resetLeft();
    }
    lcd.clear();
    TimerDiplay();
  }
  if (LCDML_BUTTON_checkEnter()) {
    LCDML_DISP_funcend();
    lcd.clear();
    lcd.print("Ijungta");
    delay(1000);
    LCDML_BUTTON_resetEnter();
    lcd.setCursor(0, 0);
    lcd.clear();
    TimerDiplay();

  }
}

Timer2:

void LCDML_DISP_setup(LCDML_FUNC_timersetup2)
// *********************************************************************
{

  TimerDiplay2();

}
void LCDML_DISP_loop(LCDML_FUNC_timersetup2) {


  if (LCDML_BUTTON_checkAny()) { // check if any button is presed (enter, up, down, left, right)
    // LCDML_DISP_funcend calls the loop_end function

    if (LCDML_BUTTON_checkUp())    {
      (a == 0);
     Hour2()++;
      (a == 1);
      if (Hour2() > 23) {
        Hour2() = 0;
      }

      if (Hour1() > 23) {
        Hour3() = 0;
      }
      if (Minute() > 59) {
        Minute2() = 0;
      }
      if (Minute1() > 59) {
        Minute3() = 0;
      }
     if LCDML_BUTTON_resetUp(); {
      (a == 0);
     }
    }
    if (LCDML_BUTTON_checkDown())  {
      HELP_FUNC_set_time2(-1);
      if (Hour2() > 23) {
        Hour2() = 0;
      }
      if (Hour3() > 23) {
        Hour3() = 0;
      }
      if (Minute2() > 59) {
        Minute2() = 0;
      }
      if (Minute3() > 59) {
        Minute3() = 0;
      }
      LCDML_BUTTON_resetDown();
    }
    if (LCDML_BUTTON_checkRight()) {
      _pos2 = (_pos2 + 1) % 5;
      LCDML_BUTTON_resetRight();
    }
    if (LCDML_BUTTON_checkLeft()) {
      _pos2 = (_pos2 - 1) % 5;
      LCDML_BUTTON_resetLeft();
    }

I'll attach my video link with the problem, i guess not only these values are connected it's like everything is on a same page i need to split it some how appreaciate any help :slight_smile:
My problem

Can you post your main ino code?