This repository has all of the necessary code to add your own buttons to the vex v5 Brain!
The first thing you are going to want to do to set up the buttons is downloading and including button.h. Note button.h will not work if you do not have button.cpp installed.
Now you have the required files installed this step doesn't matter as much but, your file structure should look something like this.
include/
robot-config.h
vex.h
button.h
src/
main.cpp
robot-config.cpp
button.cpp
Note: you don't have to use the namespace vex but it's recommended.
#include "vex.h"
#include <button.h>
using namespace vex;
Your beginning main function should look something like this, in main.cpp.
int main() {
// Initializing Robot Configuration. DO NOT REMOVE!
vexcodeInit();
}
Jump to the top of your file and add this.
button b; // Making the button.
// Struct square, x, y, width, height.
square button =
{
480 / 2,
240 / 2,
155,
50
};
The first argument in the struct square is the x coordinate, then the y, then the width, and height.
The second to last step is to add functionallity to your button!
int buttonCollsions()
{
b.CheckCollisions();
return 0;
}
void buttonFunctionallity()
{
Brain.Screen.clearScreen();
}
then the final step in main,
b.setup(button, "example code.", buttonFunctionallity); // void setup(square s, string text, void (*ptr)(void));
task check(buttonCollsions);
#include "vex.h"
#include <button.h>
using namespace vex;
button b;
square button =
{
480 / 2,
240 / 2,
155,
50
};
int buttonCollsions()
{
b.CheckCollisions();
return 0;
}
void buttonFunctionallity()
{
Brain.Screen.clearScreen();
}
int main() {
// Initializing Robot Configuration. DO NOT REMOVE!
vexcodeInit();
b.setup(button, "example code.", buttonFunctionallity); // void setup(square s, string text, void (*ptr)(void));
task check(buttonCollsions);
}
You should probably switch to using PROS and LVGL for a better experience.