adding in - void loop

adding #3 is disabling - "process key " functionality.
How to fix it ?

button code

void loop() {
  process_key(digitalRead(phasep), &right);
  process_key(digitalRead(phasen), &left);
  process_key_amp(digitalRead(ampp), &up);
  process_key_amp(digitalRead(ampn), &down);
  delay(100);
}
#3

/////////////////////////////////////////////////////////////////
emon1.calcVI(20, 2000);        // Calculate all. No.of half wavelengths (crossings), time-out
emon1.serialprint();           // Print out all variables (realpower, apparent power, Vrms, Irms, power factor)

float realPower       = emon1.realPower;        //extract Real Power into variable
float apparentPower   = emon1.apparentPower;    //extract Apparent Power into variable
float powerFActor     = emon1.powerFactor;      //extract Power Factor into Variable
float supplyVoltage   = emon1.Vrms;             //extract Vrms into Variable
float Irms            = emon1.Irms;             //extract Irms into Variable

lcd.setCursor(0, 0);
lcd.print("I="); //A, PA7
lcd.print(Irms );  //A

lcd.setCursor(0, 1);
lcd.print("U=");  //B, PA6
lcd.print(supplyVoltage); //B
//////////////////////////////////////////////////////
/*Serial.println(shift);
  EEPROM.write(0, shift);*/


void process_key(int val, struct debounce_info *k)
{
  switch (k->state)
  {
    case DEBOUNCE_IDLE:
      if (val == HIGH)
      {
        k->state = DEBOUNCE_ACTIVE;
        k->start = millis();
      }
      break;

    case DEBOUNCE_ACTIVE:
      if (val == HIGH)
      {
        if (millis() - k->start > DEBOUNCE_DELAY)
        {
          shift += k->shift;
          Serial.println("increasing");
          Serial.println(shift);
          Serial.println(k->shift);
          get_wave(shift);

        }
      }
      else
        k->state = DEBOUNCE_IDLE;
      EEPROM.write(0, shift);
      Serial.println(shift);
      break;
  }
}

void process_key_amp(int val, struct debounce_info *k)
{
  switch (k->state)
  {
    case DEBOUNCE_IDLE:
      if (val == HIGH)
      {
        k->state = DEBOUNCE_ACTIVE;
        k->start = millis();
      }
      break;

    case DEBOUNCE_ACTIVE:
      if (val == HIGH)
      {
        if (millis() - k->start > DEBOUNCE_DELAY)
        {
          amp += (int)k->shift;
          get_wave(shift);
        }
      }
      else
        k->state = DEBOUNCE_IDLE;

      break;
  }
}

to be added - LCD code

void loop()
{
  emon1.calcVI(20, 2000);        // Calculate all. No.of half wavelengths (crossings), time-out
  emon1.serialprint();           // Print out all variables (realpower, apparent power, Vrms, Irms, power factor)

  float realPower       = emon1.realPower;        //extract Real Power into variable
  float apparentPower   = emon1.apparentPower;    //extract Apparent Power into variable
  float powerFActor     = emon1.powerFactor;      //extract Power Factor into Variable
  float supplyVoltage   = emon1.Vrms;             //extract Vrms into Variable
  float Irms            = emon1.Irms;             //extract Irms into Variable

  lcd.setCursor(0, 0);
  lcd.print("I="); //A, PA7
  lcd.print(Irms );  //A

  lcd.setCursor(0, 1);
  lcd.print("U=");  //B, PA6
  lcd.print(supplyVoltage); //B
}

Maybe rephrase the question; it's not completely clear to me.

Maybe the keyword you're looking for is conditional compilation?

The buttons are working ok without what is added between two backslash lines.

ted:
The buttons are working ok without what is added between two backslash lines.

There are no backslashes anywhere on this page.

this is what I did

code A

void loop() {
   //buttons code
  // put your main code here, to run repeatedly:

}

code B

void loop() {
 // LCD code
  // put your main code here, to run repeatedly:

}

combined

void loop() {
  A+B
  buttons code
  LCD code
}

GrooveFlotilla:
There are no backslashes anywhere on this page.

The firs code on the top of page, just under #3

ted:
The firs code on the top of page, just under #3

Those are forward slashes.

I add "void" and error is;

:198: error: expected unqualified-id before '{' token

void loop() {
  process_key(digitalRead(phasep), &right);
  process_key(digitalRead(phasen), &left);
  process_key_amp(digitalRead(ampp), &up);
  process_key_amp(digitalRead(ampn), &down);
  delay(100);
}
//#3

/////////////////////////////////////////////////////////////////
void
{    // line # 198


emon1.calcVI(20, 2000);        // Calculate all. No.of half wavelengths (crossings), time-out
emon1.serialprint();           // Print out all variables (realpower, apparent power, Vrms, Irms, power factor)

float realPower       = emon1.realPower;        //extract Real Power into variable
float apparentPower   = emon1.apparentPower;    //extract Apparent Power into variable
float powerFActor     = emon1.powerFactor;      //extract Power Factor into Variable
float supplyVoltage   = emon1.Vrms;             //extract Vrms into Variable
float Irms            = emon1.Irms;             //extract Irms into Variable

lcd.setCursor(0, 0);
lcd.print("I="); //A, PA7
lcd.print(Irms );  //A

lcd.setCursor(0, 1);
lcd.print("U=");  //B, PA6
lcd.print(supplyVoltage); //B
//////////////////////////////////////////////////////
/*Serial.println(shift);
  EEPROM.write(0, shift);*/

}
void process_key(int val, struct debounce_info *k)
{
  switch (k->state)
  {
    case DEBOUNCE_IDLE:
      if (val == HIGH)
      {
        k->state = DEBOUNCE_ACTIVE;
        k->start = millis();
      }
      break;

    case DEBOUNCE_ACTIVE:
      if (val == HIGH)
      {
        if (millis() - k->start > DEBOUNCE_DELAY)
        {
          shift += k->shift;
          Serial.println("increasing");
          Serial.println(shift);
          Serial.println(k->shift);
          get_wave(shift);

        }
      }
      else
        k->state = DEBOUNCE_IDLE;
      EEPROM.write(0, shift);
      Serial.println(shift);
      break;
  }
}

void process_key_amp(int val, struct debounce_info *k)
{
  switch (k->state)
  {
    case DEBOUNCE_IDLE:
      if (val == HIGH)
      {
        k->state = DEBOUNCE_ACTIVE;
        k->start = millis();
      }
      break;

    case DEBOUNCE_ACTIVE:
      if (val == HIGH)
      {
        if (millis() - k->start > DEBOUNCE_DELAY)
        {
          amp += (int)k->shift;
          get_wave(shift);
        }
      }
      else
        k->state = DEBOUNCE_IDLE;

      break;
  }
}

GrooveFlotilla:
Those are forward slashes.

GrooveFlotilla:
Those are forward slashes.

you right, but problem is not there

Dear God!

When are you going to stop hitting random keys in the increasingly vain hope of getting a working compilable program?

Just work through some basic examples before you get further out of your depth.

I am google for that right now

Google does not have all your answers.

You need to work through the basics - what functions look like, what slashes look like, how code should be structured etc, etc

Yes Boss

Can anyone really be that dim or is ted just trolling, getting some odd pleasure from all this silliness?

After never getting a straight answer to a single one of my questions I rather lost interest in his "problems".

Steve

Harsh - but true.

Ted is learning void loop, ask a specific question and received blah, blah, blah annoying useless answer from guys who do not know the answer.
2+3 = monday

adding #3 is disabling - "process key " functionality.
How to fix it ?
This is my question and your answer is ?
Do you see what I mean.

Look at my answer no blah, blah, blah.
I didn't say to guy - you need to learn basics ..............

https://forum.arduino.cc/index.php?topic=534868.0

Delta_G:
Sorry but,

#3

is not a legal line of code. = I didn't ask for that

If you mean to refer to the code that comes after that line in your code it doesn't work because it is not inside any function. It should be throwing compiler errors. = I didn't ask for that

I asked " how to fix it "

Delta_G:
Are you really too stupid to get that?

Don't do that !!!
I am not here to fight.