V5 Brain Screen Programming

I’m currently using Robot Mesh C++ for V5 and am a mediocre programmer. I was just wondering how I could program my V5 Brain screen with a logo for my team that would remain on the screen throughout the autonomous and match. How would I program this in C++ for Robot Mesh on my V5 screen?

If you have a micro SD card with a .png image on it, you can load the image and display it by calling Brain.Screen.drawImageFromFile, giving it the file name as a string along with an x and y position to position the image (top left corner). This works well if you only plan to draw the image once.

If you are using the screen for other things throughout the match, you would instead want to load the image into memory with the bitmap class then draw it with Brain.Screen.drawBitmap. This makes it so that it doesn’t have to read from the SD card every time you want to draw the image, which is much faster than stopping to read from the card.

I plan on only having the image on the screen during matches. So all I need to do is get the image on a micro and card and upload it?

Yep. Name the image properly, slap it on a micro SD card, plug it into the Brain, then your programs can read it from there with the methods I talked about.

Do I put the code eg) bool vex::brain::lcd::drawImageFromFile (const char * name, int x, int y) within my While loop? And do I leave the Micro SD in the brain as long as I want to have the image, or does it save to the brain?

You just need to call the


function once, outside your main while loop. Loading the image data from the SD card takes a few milliseconds (not noticeable if you do it once, but too slow to have inside your main while loop).

The call to drawImageFromFile will load the image from the SD card every time. It doesn’t copy it to the brain’s internal flash.

So where within my competition template would be the best place to put this? In my driver control before the while loop? Or is it too slow to load the image to be displayed during every match.

Simply place it in pre_auton() if you want it displayed for the whole match.

Awesome, thanks for the help! I’ll let you know if I get it to work.

Ok, so I tried plugging everything into the program and everything compiles except for a small area in the code. What am I doing wrong?
void pre_auton() {
bool vex::brain::lcd::drawImageFromFile ( const char * Bluejay.png,
0 x,
272 y)
It’s giving me an error code that says main.cpp(25:45): error xxx: qualified-id in declaration before ‘(’ token. I don’t know what this error code means.

I do not see a ; after your bool call.


Righto, looks like your problem is that you didn’t know what the function prototype on the doc page was trying to tell you. Let me paste it in so we can see it, and I’ll explain what the parts mean, then what you have to do to use it. (This will also be useful information for reading other function prototypes in the future!)

bool vex::brain::lcd::drawImageFromFile ( const char * name, int x, int y)

This is a function prototype. It gives you information about what the function returns, and what it asks for.

The first thing is the type it returns: bool. Bool is short for Boolean, which is the data type of true/false values. (Named after the mathematician George Boole, who did a lot of work with true/false logic.) This means that you can use this function anywhere you could use a true/false value, like in the conditional of an


statement. Other functions might return numbers (int, double), an object of a complex class (e.g. vex::motor), or nothing at all (void).

The next part is the name of the function or method (a method is a function associated with a class) and what class it is associated with, if any. In this case, the name is drawImageFromFile, and it is associated with the class vex::brain::lcd. This means that every object of the type vex::brain::lcd has a method called drawImageFromFile that you can use. For this method, we do need an actual object, so we are going to use Brain.Screen, as that’s what we setup earlier in the program (on the line which reads

vex::brain Brain;

). So to call this function, we write Brain.Screen.drawImageFromFile, then provide any arguments in parentheses ( ).

Inside the parentheses, the function prototype lists the arguments. Each argument also has a type and a name. The name is just there to help tell us what the argument is for. We won’t use it in our code. The type tells us what type of data we should put in that slot. The arguments for this method are a char* that names the file, along with two integers that define the x and y position to draw the image at. (The const keyword is a promise by the function that it won’t change whatever you give it for the name. We can ignore it.) A char* in this case is asking for a string containing the file name. For your file, Bluejay.png, you would give it


. x and y are satisfied with two numbers, for which you were trying to put in 0 and 272 (this will display off the bottom of the screen, so try 0, 0 to start instead).

Putting it all together, the final method call should look like this:

Brain.Screen.drawImageFromFile("Bluejay.png", 0, 0);

1 Like

Ok, this is starting to make a whole lot more sense. How do I declare bluejaypng in the scope? Because when I use bluejaypng, it says it isn’t declared in the scope with the brain, motors, etc.

You don’t need to declare it. Put quotes around it like I did in that last line.

It worked! I just forgot to end the statement with a semicolon. Thanks for the help!