Have you ever wanted to put a simple gif on the brain but can’t since the brain doesn’t support it? I have a solution, and I’ll show it to you in five simple steps.
Step one: Find a gif
Find a gif you want to display on the brain, preferably one with a low frame count and loops.
Step two: Getting the frames
Take a screenshot of every frame of the gif, and make sure to save them as ‘.png’ or ‘.bmp’ and that it is 480 X 240 pixels.
Step three: SD card
Add all of your frames to an SD card that’s formatted to be in FAT32. Also, make sure that you remember what you named each frame.
Step four: Coding
Now time to code it, the example I will show is in Visual Studio Code.
// Make a function for it first
int CustGif(){
while(true){
}
}
/* Using the 'drawImageFromFile("name.file", x, y);' function make one for every frame in order. Use the wait function to adjust how fast you want it to move.
*/
int CustGif(){
while(true){
Brain.Screen.drawImageFromFile("Frame1.png", 0, 0);
wait(50, msec);
Brain.Screen.drawImageFromFile("Frame2.png", 0, 0);
wait(50, msec);
Brain.Screen.drawImageFromFile("Frame3.png", 0, 0);
wait(50, msec); //To make the gif properly loop.
}
}
//Finally in your user control, use 'vex::task' to call back on the func, place it at the beginning.
void usercontrol(void) {
vex::task Task(CustGif);
while (1) {
//Your code here
}
}
Step five: Profit
Then it should be as simple as inserting the SD card into the brain and running the code. Leave any questions below.
How it should look(https://youtu.be/ssOlq2k3N0k?si=w46z_Pb0dqFKY8iz)