Having an issue using multiple 4DButtons to control an external device on an Arduino Mega. I can get the display to communicate and also get the LED's to light up, but I cannot get the LED_DIGITS to display when the 4D Buttons are pressed. I have tried this code years ago and it worked well back in 2016, but now does not work for this application. I am wondering what I am missing. I added some of the code below:

void setup()
{

//Serial communication for 4D Systems Display
Serial1.begin(200000); // Serial1 @ 9600 (9.6K) Baud
genie.Begin(Serial1); // Use Serial1 for talking to the Genie Library, and to the 4D Systems display

//Debugging for 4D System Display
pinMode(RESETLINE, OUTPUT);
digitalWrite(RESETLINE, 0); // Reset the Display via D4
delay(5000);
digitalWrite(RESETLINE, 1); // unReset the Display via D4 genie.WriteContrast(1);
delay(3500);

genie.AttachEventHandler(myGenieEventHandler);


Serial.begin(57600);
Wire.begin();
RTC.begin();



if (! RTC.isrunning())
{
genie.WriteObject(GENIE_OBJ_LED, 0, LOW);

}
else
{
genie.WriteObject(GENIE_OBJ_LED, 0, HIGH);

}

}


void loop()
{

static long waitPeriod = millis();

if (millis() >= waitPeriod)
{
genie.DoEvents();



//Height Buttons
genie.ReadObject(GENIE_OBJ_4DBUTTON, 0);
genie.ReadObject(GENIE_OBJ_4DBUTTON, 1);
genie.ReadObject(GENIE_OBJ_4DBUTTON, 2);
genie.ReadObject(GENIE_OBJ_4DBUTTON, 3);
genie.ReadObject(GENIE_OBJ_4DBUTTON, 4);
genie.ReadObject(GENIE_OBJ_4DBUTTON, 5);

waitPeriod = millis() + 50;
}





}
void myGenieEventHandler(void)
{
static long waitPeriod = millis();

if (millis() >= waitPeriod)
{
genieFrame Event;
genie.DequeueEvent(&Event);

//If the cmd received is from a Reported Object, which occurs if a Read Object (genie.ReadOject) is requested in the main code, reply processed here.
if (Event.reportObject.cmd == GENIE_REPORT_OBJ)
{
if (Event.reportObject.object == GENIE_OBJ_4DBUTTON)
{
int object_index = Event.reportObject.index;
int state = genie.GetEventData(&Event);


switch(object_index)
{
case 0:
button0_process(state);
break;
case 1:
button1_process(state);
break;
case 2:
button2_process(state);
break;
case 3:
button3_process(state);
break;
case 4:
button4_process(state);
break;
case 5:
button5_process(state);
break;

}
}
}

waitPeriod = millis() + 50;
}
}
void button0_process(int Button_val){
if (Button_val == HIGH)
{

// Write a pulse to the HC-SR04 Trigger Pin
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);



// Measure the response from the HC-SR04 Echo Pin
duration = pulseIn(echoPin, HIGH);

// Determine distance from duration
// Use 343 metres per second as speed of sound
distance0= duration*0.0343/2;
distance1= 213 - distance0;
//distance1= 5.07999 - distance;
distance2 = distance1 * 0.39370079;
// Prints "Distance: <value>" on the first line of the LCD


genie.WriteObject(GENIE_OBJ_LED_DIGITS, 0, distance2);
}
}


void button1_process(int Button_val){

if (Button_val == 1)
{
// Write a pulse to the HC-SR04 Trigger Pin
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);



// Measure the response from the HC-SR04 Echo Pin
duration = pulseIn(echoPin, HIGH);

// Determine distance from duration
// Use 343 metres per second as speed of sound
distance00= duration*0.0343/2;
distance11= 213 - distance00 ;
//distance1= 5.07999 - distance;
distance22 = distance11 * 0.39370079;
// Prints "Distance: <value>" on the first line of the LCD



if (distance22 > 100) {
tone (speakerPin, 1000);
genie.WriteObject(GENIE_OBJ_LED_DIGITS, 1, distance22);
} else {
noTone (speakerPin);

}
}
else{


}
}

void button2_process(int Button_val){

if (Button_val == 1)
{
// Write a pulse to the HC-SR04 Trigger Pin
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);



// Measure the response from the HC-SR04 Echo Pin
duration = pulseIn(echoPin, HIGH);

// Determine distance from duration
// Use 343 metres per second as speed of sound
distance000= duration*0.0343/2;
distance111= 213 - distance000 ;
//distance1= 5.07999 - distance;
distance222 = distance111 * 0.39370079;
// Prints "Distance: <value>" on the first line of the LCD



if (distance222 > 100) {
tone (speakerPin, 1000);
genie.WriteObject(GENIE_OBJ_LED_DIGITS, 2, distance222);
} else {
noTone (speakerPin);

}
}
else{


}
}

void button3_process(int Button_val){

if (Button_val == 1)
{
// Write a pulse to the HC-SR04 Trigger Pin
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);



// Measure the response from the HC-SR04 Echo Pin
duration = pulseIn(echoPin, HIGH);

// Determine distance from duration
// Use 343 metres per second as speed of sound
distance0000= duration*0.0343/2;
distance1111= 213 - distance0000;
//distance1= 5.07999 - distance;
distance2222 = distance1111 * 0.39370079;
// Prints "Distance: <value>" on the first line of the LCD



if (distance2222 > 100) {
tone (speakerPin, 1000);
genie.WriteObject(GENIE_OBJ_LED_DIGITS, 3, distance2222);
} else {
noTone (speakerPin);

}
}
else{


}
}
void button4_process(int Button_val){

if (Button_val == 1)
{
// Write a pulse to the HC-SR04 Trigger Pin
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);



// Measure the response from the HC-SR04 Echo Pin
duration = pulseIn(echoPin, HIGH);

// Determine distance from duration
// Use 343 metres per second as speed of sound
distance00000= duration*0.0343/2;
distance11111= 213 - distance00000;
//distance1= 5.07999 - distance;
distance22222 = distance11111 * 0.39370079;
// Prints "Distance: <value>" on the first line of the LCD



if (distance22222 > 100) {
tone (speakerPin, 1000);
genie.WriteObject(GENIE_OBJ_LED_DIGITS, 4, distance22222);
} else {
noTone (speakerPin);

}
}
else{


}
}
void button5_process(int Button_val){

if (Button_val == 1)
{
// Write a pulse to the HC-SR04 Trigger Pin
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);



// Measure the response from the HC-SR04 Echo Pin
duration = pulseIn(echoPin, HIGH);

// Determine distance from duration
// Use 343 metres per second as speed of sound
distance000000= duration*0.0343/2;
distance111111= 213 - distance000000;
//distance1= 5.07999 - distance;
distance222222 = distance111111 * 0.39370079;
// Prints "Distance: <value>" on the first line of the LCD



if (distance222222 > 100) {
tone (speakerPin, 1000);
genie.WriteObject(GENIE_OBJ_LED_DIGITS, 5, distance222222);
} else {
noTone (speakerPin);

}
}
else{


}
}


If you have any question, please et me know.

Thank you,

James