Skip to content

A simplified PROS graphing library for VEX robotics

License

Notifications You must be signed in to change notification settings

jazonshou/Graphy

Repository files navigation

GitHub GitHub all releases

Graphy

Graphy is an open-source PROS library that simplifies graphing data on the v5 brain.

Installation

Use the PROS CLI to install Graphy. If you installed PROS correctly, you should already have the PROS CLI.

  1. Download Graphy@LATEST_VERSION.zip (found here) at the root of your project
  2. Run pros conductor fetch Graphy@LATEST_VERSION.zip at the root of your project
  3. Run pros conductor apply Graphy at the root of your project
  4. Add #include "Graphy/Grapher.hpp" to your header file

Usage

Example code:

#include "Graphy/Grapher.hpp"

// Create grapher
std::shared_ptr<graphy::AsyncGrapher> grapher(new graphy::AsyncGrapher("Flywheel Velocity vs. Time"));

// Add data types
grapher->addDataType("Desired Vel", COLOR_ORANGE);
grapher->addDataType("Actual Vel", COLOR_AQUAMARINE);

// Start grapher task
grapher->startTask();

while(true) {
    // Update data
    grapher->update("Desired Vel", DESIRED_VELOCITY);
    grapher->update("Actual Vel", ACTUAL_VELOCITY);

    pros::delay(10);
}

Documentation:

/**
 * @brief Construct a new Async Grapher object
 *
 * @param title graph title
 * @param rate refresh rate
 */
AsyncGrapher(const std::string &title, const uint rate);

/**
 * @brief Add new graph data type
 *
 * @param name data type name
 * @param color line color
 */
void addDataType(const std::string &name, const uint32_t color);

/**
 * @brief Update graph
 *
 * @param name data type name
 * @param val updated data value
 */
void update(const std::string &name, double val);

/**
 * @brief Set the refresh rate
 *
 * @param rate refresh rate
 */
void setRefreshRate(const uint rate);

/**
 * @brief Get the current refresh rate
 *
 * @return refresh rate
 */
uint getRefreshRate();

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

License

GPL-3.0