2#include "../core/include/subsystems/odometry/odometry_base.h"
3#include "../core/include/utils/controls/pid.h"
4#include "../core/include/utils/controls/pidff.h"
5#include "../core/include/utils/graph_drawer.h"
20 ButtonWidget(std::function<
void(
void)> onpress, Rect rect, std::string name)
21 : onpress(onpress), rect(rect), name(name) {}
26 ButtonWidget(
void (*onpress)(), Rect rect, std::string name) : onpress(onpress), rect(rect), name(name) {}
33 bool update(
bool was_pressed,
int x,
int y);
35 void draw(vex::brain::lcd &,
bool first_draw,
unsigned int frame_number);
38 std::function<void(
void)> onpress;
40 std::string name =
"";
41 bool was_pressed_last =
false;
54 SliderWidget(
double &val,
double low,
double high, Rect rect, std::string name)
55 : value(val), low(low), high(high), rect(rect), name(name) {}
62 bool update(
bool was_pressed,
int x,
int y);
64 void draw(vex::brain::lcd &,
bool first_draw,
unsigned int frame_number);
73 std::string name =
"";
84 std::function<void()> onclick;
86struct CheckboxConfig {
87 std::function<void(
bool)> onupdate;
94 std::function<std::string()> text;
113 std::vector<SizedWidget> widgets;
116 CheckboxConfig checkbox;
135 virtual void update(
bool was_pressed,
int x,
int y);
143 virtual void draw(vex::brain::lcd &screen,
bool first_draw,
unsigned int frame_number);
152void draw_widget(WidgetConfig &widget, ScreenRect rect);
154class WidgetPage :
public Page {
156 WidgetPage(WidgetConfig &cfg) : base_widget(cfg) {}
157 void update(
bool was_pressed,
int x,
int y)
override;
159 void draw(vex::brain::lcd &,
bool first_draw,
unsigned int frame_number)
override {
160 draw_widget(base_widget, {.x1 = 20, .y1 = 0, .x2 = 440, .y2 = 240});
164 WidgetConfig &base_widget;
173void start_screen(vex::brain::lcd &screen, std::vector<Page *> pages,
int first_page = 0);
177void goto_page(
size_t page);
183using update_func_t = std::function<void(
bool,
int,
int)>;
186using draw_func_t = std::function<void(vex::brain::lcd &screen,
bool,
unsigned int)>;
193 StatsPage(std::map<std::string, vex::motor &> motors);
195 void update(
bool was_pressed,
int x,
int y)
override;
197 void draw(vex::brain::lcd &,
bool first_draw,
unsigned int frame_number)
override;
200 void draw_motor_stats(
const std::string &name, vex::motor &mot,
unsigned int frame,
int x,
int y,
201 vex::brain::lcd &scr);
203 std::map<std::string, vex::motor &> motors;
204 static const int y_start = 0;
205 static const int per_column = 4;
206 static const int row_height = 20;
207 static const int row_width = 200;
223 void update(
bool was_pressed,
int x,
int y)
override;
225 void draw(vex::brain::lcd &,
bool first_draw,
unsigned int frame_number)
override;
228 static const int path_len = 40;
229 static constexpr char const *field_filename =
"vex_field_240p.png";
234 uint8_t *buf =
nullptr;
239 GraphDrawer velocity_graph;
249 FunctionPage(update_func_t update_f, draw_func_t draw_t);
251 void update(
bool was_pressed,
int x,
int y)
override;
253 void draw(vex::brain::lcd &,
bool first_draw,
unsigned int frame_number)
override;
256 update_func_t update_f;
269 PID &pid, std::string name, std::function<
void(
void)> onchange = []() {});
271 PIDFF &pidff, std::string name, std::function<
void(
void)> onchange = []() {});
274 void update(
bool was_pressed,
int x,
int y)
override;
276 void draw(vex::brain::lcd &,
bool first_draw,
unsigned int frame_number)
override;
280 void zero_d_f() { cfg.
d = 0; }
282 void zero_i_f() { cfg.
i = 0; }
286 const std::string name;
287 std::function<void(
void)> onchange;
Definition odometry_base.h:24
Simple page that stores no internal data. the draw and update functions use only global data rather t...
Definition screen.h:244
void draw(vex::brain::lcd &, bool first_draw, unsigned int frame_number) override
draw uses the supplied draw function to draw to the screen
Definition screen.cpp:171
FunctionPage(update_func_t update_f, draw_func_t draw_t)
Creates a function page.
Definition screen.cpp:166
void update(bool was_pressed, int x, int y) override
update uses the supplied update function to update this page
Definition screen.cpp:169
a page that shows odometry position and rotation and a map (if an sd card with the file is on)
Definition screen.h:213
void update(bool was_pressed, int x, int y) override
Definition screen.cpp:321
void draw(vex::brain::lcd &, bool first_draw, unsigned int frame_number) override
Definition screen.cpp:255
OdometryPage(OdometryBase &odom, double robot_width, double robot_height, bool do_trail)
Create an odometry trail. Make sure odometry is initilized before now.
Definition screen.cpp:235
PIDPage provides a way to tune a pid controller on the screen.
Definition screen.h:261
void update(bool was_pressed, int x, int y) override
Definition screen.cpp:405
PIDPage(PID &pid, std::string name, std::function< void(void)> onchange=[]() {})
Create a PIDPage.
Definition screen.cpp:394
void draw(vex::brain::lcd &, bool first_draw, unsigned int frame_number) override
Definition screen.cpp:417
Page describes one part of the screen slideshow.
Definition screen.h:125
virtual void draw(vex::brain::lcd &screen, bool first_draw, unsigned int frame_number)
draw stored data to the screen (runs at 10 hz and only runs if this page is in front)
virtual void update(bool was_pressed, int x, int y)
collect data, respond to screen input, do fast things (runs at 50hz even if you're not focused on thi...
Draws motor stats and battery stats to the screen.
Definition screen.h:189
StatsPage(std::map< std::string, vex::motor & > motors)
Creates a stats page.
Definition screen.cpp:175
void draw(vex::brain::lcd &, bool first_draw, unsigned int frame_number) override
Definition screen.cpp:207
void update(bool was_pressed, int x, int y) override
Definition screen.cpp:176
double d
derivitave coeffecient d * derivative(error)
Definition pid.h:46
double i
integral coeffecient i * integral(error)
Definition pid.h:45