PROS LCD help

Can someone please show/tell me how using the LCD screen in Pros works, because I only know how to print stuff on the screen, but I am kinda clueless when it comes to detecting which buttons are pressed. I am trying to use the LCD screen to select autons, and I want Right, to de red, Left button to be blue, and middle to be a universal auton, but I’m not sure how to detect the different buttons. Thanks in advance!

1 Like

You’ll want to use

unsigned int lcdReadButtons (FILE * lcdPort )

before starting up autonomous. What you can do is make some loops something like this:

unsigned int recordButton = 0;
bool buttonPressed = false;

while(buttonPressed == false){
recordButton = lcdReadButtons (uart1);
if(recordButton != 0){
delay(20);
recordButton = lcdReadButtons (uart1);
if(recordButton == an acceptable value){
buttonPressed = true;
}
}
delay(20);
}
Do something based on the returned value.
Proceed to take in more values or finish up.

What you’ll get back is buttonPressed is some number represented by the buttons in binary, which will be 0 to 7. No buttons pressed is 0 0 0 = 0. But if buttons are pressed you get the following:
0 0 1 = 1
0 1 0 = 2
0 1 1 = 3
1 0 0 = 4
1 0 1 = 5
1 1 0 = 6
1 1 1 = 7

You might want to turn the check for the button press into a function. The reason for the internal delay and a recheck is that it is unlikely someone will press two buttons at exactly the right time. Sometimes people look for a release before using the value. You still need to consider the release is not likely to be timed perfectly, too.