PROS LCD code not working consistently

Our team plans to use LCD buttons in initialize() to select auton routines. However, the LCD code only work intermittently. If we start PROS project, the LCD buttons will shows up on V5 screen about 20% of the time. The other 80% of time, the LCD buttons do not show up on V5 screen at all! Have your team successfully used LCD buttons on V5 brain (consistently)?

Here is our code (the button callback functions are defined somewhere else):

void initialize() {
//initialize LCD buttons and text display on V5
pros::lcd::initialize();
pros::lcd::set_text(1, “Hello PROS User!”);

//set LCD buttons callback functions
pros::lcd::register_btn1_cb(on_center_button);
pros::lcd::register_btn0_cb(on_left_button);
pros::lcd::register_btn2_cb(on_right_button);

//wait for 10 sec to allow time for auton selection
//pros::delay(10000);

//set V5 LCD text display
pros::lcd::set_text(1, "Initialized");
pros::lcd::set_text(2, titles[autonselector]);

//print to controller screen
master.print(0, 0, titles[autonselector]);//"Selected Auton: %d", titles[autonselector]);

}

look at this post and for more info, the rest of the thread.

If this is not the issue, we will need more info from you.

Note that I have not heard of this issue using the build in lcd emulator.

btw, the team I coached last year let me publish there auton selector. its here if your interested (with some updates from me).

4 Likes

Thanks! We tried both solutions and they both worked:

  1. inverse display using V5 setting
  2. insert a delay
1 Like

One more thing we have noticed is if you have tight loop in the code (you shouldn’t!), the LCDEmu won’t update.

This would be quite expectable to me with LCDEmu running in a lower priority task on a real RTOS (priority is a hard constraint on RTOS, if a higher priority task, like main, wants to run, it runs and lower prio won’t get even a jiffy), but it was easy mistake for my students to do.

1 Like