Skip to content
This repository has been archived by the owner on Jun 30, 2024. It is now read-only.

This repository has all of the necessary code to add your own buttons to the vex v5 Brain!

Notifications You must be signed in to change notification settings

Adam-Salem-Codes/Buttons-for-vexV5

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 

Repository files navigation

Buttons-for-vexV5

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;

Second step


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);

What your file should look like.


#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);
}

Results 😁


Before button click!

Before Click

After button click!

After Click

This is deprecated and no longer supported

You should probably switch to using PROS and LVGL for a better experience.

About

This repository has all of the necessary code to add your own buttons to the vex v5 Brain!

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages