Menu programming problem with nano

Hi,

using software 1.0.6.
I have a programming problem with my menu in my project,
I hooked upp a arduino nano, with tda7439 a sound prosesor, a rtc clock and a tea5767 radio. communicate via ic2 bus.
I also use remote controll and lcd display 16x2. all this goes as preamp for my reciever I build.

When I go inside menu i cant pick my input , as radio or dac etc…
my first menu works, can pick bass, treble, mid and gain,
volume menu works,
but my input selection dont work, when I press that,
it pops back to the clock.
I am not a very good programmer, so
I would appriciate some help here… :slight_smile:
best regards
NIklas.

I include some of the file.

void displayMenu() {
delay(300); // Saves selecting the first option from the original press
lcd.clear();
lcd.print("Menu");
int selected = 0;
int moved = 1;

// display options
lastChange = millis();
while (digitalRead(menuButton) != 0 && IrOKbutton == 0) {
  processIR();
  if (millis() - lastChange < menuTimeout){
    switch (enc){
      case 1:
        if (selected > 0){
          selected--;
          moved = 1;
        }
        enc = 0;
        lastChange = millis();
        break;
      case 2: 
        if (selected < 4){
          selected++;
          moved = 1;
        }
        enc = 0;
        lastChange = millis();
        break;
    }

    if (moved) {
      switch(selected) {
        case 0:
          //lcd.print("Change Units    ");
          lcd.setCursor(0,1);
          lcd.print("Input Select");
          moved = 0;
          break;
        case 1:
          lcd.setCursor(0,1);
          lcd.print("Bass        ");
          moved = 0;
          break;
        case 2:
          lcd.setCursor(0,1);
          lcd.print("Mid        ");
          moved = 0;
          break;
        case 3:
          lcd.setCursor(0,1);
          lcd.print("Treb       ");
          moved = 0;
          break;
        case 4:
          lcd.setCursor(0,1);
          lcd.print("Input Gain  ");
          moved = 0;
          break;
      }
   }
  }else{
   // Timed out
   lcd.clear();
   return;
  } 
}
IrOKbutton = 0;
 switch(selected) {
  case 0:
    changeInput();
    break;
  case 1:
    changeSnd(1);
    break;
  case 2:
    changeSnd(2);
    break;
  case 3:
    changeSnd(3);
    break;
 case 4:
    changeGain();
    break;
}
delay(300); //Saves going back in to menu
}

void changeInput(){
delay(300);
int selected = configuration.activeInput;
int moved = 1;

// display options
lcd.clear();
lcd.print("Input selection");
lastChange = millis();
while (digitalRead(menuButton) != 0 && IrOKbutton == 0) {
  processIR();
  if (millis() - lastChange < menuTimeout){
    switch (enc){
      case 1:
        if (selected > 0){
          selected--;
          moved = 1;
        }
        enc = 0;
        lastChange = millis();
        break;
      case 2: 
        if (selected < 3){
          selected++;
          moved = 1;
        }
        enc = 0;
        lastChange = millis();
        break;
    }

    if (moved) {
      switch(selected) {
        case 0:
          lcd.setCursor(0,2);
          lcd.print("Tuner ");
          break;
        case 1:
          lcd.setCursor(0,2);
          lcd.print("DAC   ");
          break;
        case 2:
          lcd.setCursor(0,2);
          lcd.print("CD    ");
          break;
        case 3:
          lcd.setCursor(0,2);
          lcd.print("AUX   ");
          break;
      }
    moved = 0;
   }
  }else{
   lcd.clear();
   return;
  } 
}
IrOKbutton = 0;
// when button is pressed...
equ.setInput(selected+1);
configuration.activeInput = selected;
EEPROM_writeAnything(0, configuration);
if (selected == 0) {
  lcd.clear();
  radio_on();
  radio_status();
}else{
  delay(500);
  lcd.clear();
}
}

void changeSnd(int band){
int printValue;
delay(300);
lcd.clear();
int selected;
switch (band){
case 1:
  lcd.print("Bass");
  selected = configuration.bassLevel;
  break;
case 2:
  lcd.print("Mid ");
  selected = configuration.midLevel;
  break;
case 3:
  lcd.print("Treb");
  selected = configuration.trebLevel;
  break;
}
if (selected < 0){
  lcd.setCursor(10,0);
  lcd.write(byte(2));
  lcd.setCursor(11,0);
  lcd.write(byte(2));
}else{
  lcd.setCursor(10,0);
  lcd.print("  ");
}
if (selected < 0){
  printValue = selected * -1;
}else{
  printValue = selected;
}
printBigDigit(printValue + 48,13);
//lcd.print(selected);
int moved = 0;

// display options
lastChange = millis();
while (digitalRead(menuButton) != 0 &&   IrOKbutton == 0) {
  processIR();
  if (millis() - lastChange < menuTimeout){
    switch (enc){
      case 1:
        if (selected > -7){
          selected--;
          moved = 1;
        }
        enc = 0;
        lastChange = millis();
        break;
      case 2: 
        if (selected < 7){
          selected++;
          moved = 1;
        }
        enc = 0;
        lastChange = millis();
        break;
    }

    if (moved) {
    if (selected < 0){
      lcd.setCursor(10,0);
      lcd.write(byte(2));
      lcd.setCursor(11,0);
      lcd.write(byte(2));
    }else{
      lcd.setCursor(10,0);
      lcd.print("  ");
    }
    if (selected < 0){
      printValue = selected * -1;
    }else{
      printValue = selected;
    }
    printBigDigit(printValue + 48,13);
    moved = 0;
    equ.setSnd(selected, band);
   }
  }else{
   lcd.clear();
   return;
}

Arduino_Gainclone_1_3.ino (19.5 KB)

I have a problem with my meny in my prosject,

I'm sorry to hear about your meny.

Please use code tags when posting code.

Thank you and I think I got the tag right. :slight_smile:
but hope somebody has an Idea...
that would save christmas...

:slight_smile:

What is a "meny" ?

...R

Meny.. :wink:
is of course = menu

my bad.

solved.. :slight_smile:

on the rows for input selection was
lcd.setCursor it was set for (0,2) and
that was no right whan i has a 16x2 lcd.
0,2 means row 3.

anyway, i used up this nice thusday :slight_smile: