Wanted: PROS V5 example code for auton selector

I’m looking for an example of how to set up an autonomous selector using PROS on the V5. For years, we used the LCD on the old Cortex, but trying to shift that over to the V5 is causing some problems.

Anyone have an example they would like to share? Thanks.

A quick solution would be jumpers. They aren’t as flashy as creating a display using LVGL but they don’t take much time and they persist though downloads/power cycles.

#include "main.h"
pros::ADIPort auto1(1); // Port A
pros::ADIPort auto2(2); // Port B
void autonomous(void) {
    if (auto1.get_value()) {
        /** Auton 1 Code Here **/
    } else if (auto2.get_value()) {
        /** Auton 2 Code Here **/

This is a simple example of how you could implement a jumper system. If you eventually create an LVGL display, I recommend you use a hybrid jumper auton selection. It will make testing the autonomous easier as the jumper values will be persistent.

1 Like

This example shows how to make buttons that call a function when pressed. The function receives the button pressed as a number that can be used in a switch statement for calling an auton function.

1 Like

Ok, both of these suggestions seem like reasonable approaches. I think they were trying to emulate the old LCD.


Have you seen @jpearman 's code for buttons on the V5 brain? My students started with that and modified it. For example, they took two buttons for red v. blue, started one as true, and make pressing either one swap with the other. Another possibility would be to use one button and have it always red or blue instead of nothing or colored. They’re making another button that exits the pre-autonomous loop, replacing the while(1) with while(!buttons[7].state) and killing off the extra threads; at the end of the pre-autonomous loop the information on the choices is stored in the various button states. With the exit button they’re able to go back and change their minds on autonomous selection until they intentionally exit.

I recommend trying the same. Download @jpearman 's code. Load it onto a brain. Work with just that until you have the set of things you want identified. Then copy the whole code into your regular program and check the button states at the beginning of autonomous.

I have’t seen that. I’m still in the early stages of learning PROS myself, so I’m having trouble helping the kids. Do you happen to have a link to it?

You should be able to adapt your existing LCD code to use the LLEMU (Legacy LCD Emulator).
Here’s the docs: https://pros.cs.purdue.edu/v5/api/c/llemu.html

Aside from that you can either go the simple route and use a potentiometer with a switch to choose an auton depending on the position of the potentiometer (I do this), or go the conplex route and use LVGL to create a selection screen on the brain. Here’s a link to the docs for lvgl: https://pros.cs.purdue.edu/v5/tutorials/topical/display.html


Just to add onto @sazrocks’s excellent answer: LLEMU was designed to be fully compatible with legacy code written for PROS 2 using the UART LCD module. I recognize that this may not be helpful in this specific situation, but others reading this thread may be interested :slight_smile: