Wanted: PROS V5 example code for auton selector


#1

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.


#2

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.


#3

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.


#4

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

Thanks!


#5

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.


#6

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?


#7

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
https://pros.cs.purdue.edu/v5/tutorials/topical/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
https://docs.littlevgl.com


#8

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: