2#include "core/subsystems/odometry/odometry_base.h"
3#include "core/utils/controls/pid.h"
4#include "core/utils/controls/pidff.h"
5#include "core/utils/graph_drawer.h"
6#include "core/utils/math/geometry/pose2d.h"
7#include "core/utils/math/geometry/translation2d.h"
8#include "core/utils/initializer.h"
15namespace LegacyScreen {
24 : onpress(onpress), rect(rect), name(name) {}
29 ButtonWidget(
void (*onpress)(),
Rect rect, std::string name) : onpress(onpress), rect(rect), name(name) {}
36 bool update(
bool was_pressed,
int x,
int y);
38 void draw(vex::brain::lcd &,
bool first_draw,
unsigned int frame_number);
41 std::function<void(
void)> onpress;
43 std::string name =
"";
44 bool was_pressed_last =
false;
58 : value(val), low(low), high(high), rect(rect), name(name) {}
65 bool update(
bool was_pressed,
int x,
int y);
67 void draw(vex::brain::lcd &,
bool first_draw,
unsigned int frame_number);
76 std::string name =
"";
87 std::function<void()> onclick;
89struct CheckboxConfig {
90 std::function<void(
bool)> onupdate;
97 std::function<std::string()> text;
101 WidgetConfig &widget;
116 std::vector<SizedWidget> widgets;
119 CheckboxConfig checkbox;
130 virtual ~Page() =
default;
139 virtual void update(
bool was_pressed,
int x,
int y);
147 virtual void draw(vex::brain::lcd &screen,
bool first_draw,
unsigned int frame_number);
156void draw_widget(WidgetConfig &widget, ScreenRect rect);
158class WidgetPage :
public Page {
160 WidgetPage(WidgetConfig &cfg) : base_widget(cfg) {}
161 void update(
bool was_pressed,
int x,
int y)
override;
163 void draw(vex::brain::lcd &,
bool first_draw,
unsigned int frame_number)
override {
164 draw_widget(base_widget, {.x1 = 20, .y1 = 0, .x2 = 440, .y2 = 240});
168 WidgetConfig &base_widget;
172using update_func_t = std::function<void(
bool,
int,
int)>;
175using draw_func_t = std::function<void(vex::brain::lcd &screen,
bool,
unsigned int)>;
182 StatsPage(std::map<std::string, vex::motor &> motors);
184 void update(
bool was_pressed,
int x,
int y)
override;
186 void draw(vex::brain::lcd &,
bool first_draw,
unsigned int frame_number)
override;
190 draw_motor_stats(
const std::string &name, vex::motor &mot,
unsigned int frame,
int x,
int y, vex::brain::lcd &scr);
192 std::map<std::string, vex::motor &> motors;
193 static const int y_start = 0;
194 static const int per_column = 4;
195 static const int row_height = 20;
196 static const int row_width = 200;
212 void update(
bool was_pressed,
int x,
int y)
override;
214 void draw(vex::brain::lcd &,
bool first_draw,
unsigned int frame_number)
override;
217 static const int path_len = 40;
218 static constexpr char const *field_filename =
"vex_field_240p.png";
223 uint8_t *buf =
nullptr;
228 GraphDrawer velocity_graph;
238 FunctionPage(update_func_t update_f, draw_func_t draw_t);
240 void update(
bool was_pressed,
int x,
int y)
override;
242 void draw(vex::brain::lcd &,
bool first_draw,
unsigned int frame_number)
override;
245 update_func_t update_f;
257 PIDPage(
PID &pid, std::string name, std::function<
void(
void)> onchange = []() {});
258 PIDPage(PIDFF &pidff, std::string name, std::function<
void(
void)> onchange = []() {});
261 void update(
bool was_pressed,
int x,
int y)
override;
263 void draw(vex::brain::lcd &,
bool first_draw,
unsigned int frame_number)
override;
267 void zero_d_f() { cfg.d = 0; }
269 void zero_i_f() { cfg.i = 0; }
273 const std::string name;
274 std::function<void(
void)> onchange;
294 void update(
bool was_pressed,
int x,
int y)
override;
296 void draw(vex::brain::lcd &,
bool first_draw,
unsigned int frame_number)
override;
314 static void cancel(
size_t selected);
324 const size_t starting_index;
327 const static std::array<Rect, 8> buttons;
Definition initializer.h:195
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 legacy.cpp:37
void update(bool was_pressed, int x, int y) override
update uses the supplied update function to update this page
Definition legacy.cpp:35
FunctionPage(update_func_t update_f, draw_func_t draw_t)
Creates a function page.
Definition legacy.cpp:32
void draw(vex::brain::lcd &, bool first_draw, unsigned int frame_number) override
Definition legacy.cpp:345
static void cancel(size_t selected)
When using a selector function wrapper that may cancel or otherwise cause the InitializerPage's selec...
Definition legacy.cpp:421
static std::function< Selector::selector_t > timed_selector(unsigned int seconds, size_t fallback=DEFAULT_CANCELATION_INDEX)
When using InitializerPage wrapped by a timeout, call this to generate the desired selector function.
Definition legacy.h:308
InitializerPage(const Initializer &initializer, size_t starting_index=0)
Creates an InitializerPage.
Definition legacy.cpp:312
void update(bool was_pressed, int x, int y) override
Definition legacy.cpp:332
static size_t selector()
When using InitializerPage to select an Initialization, use this as the raw selector function.
Definition legacy.cpp:411
static const size_t DEFAULT_CANCELATION_INDEX
The default selected index if a cancelation occured during selection.
Definition legacy.h:317
static InitializerPage * Next()
Creates an InitializerPage that renders the following Initializations from the last.
Definition legacy.cpp:317
OdometryPage(OdometryBase &odom, double robot_width, double robot_height, bool do_trail)
Create an odometry trail. Make sure odometry is initilized before now.
Definition legacy.cpp:103
void update(bool was_pressed, int x, int y) override
Definition legacy.cpp:196
void draw(vex::brain::lcd &, bool first_draw, unsigned int frame_number) override
Definition legacy.cpp:123
void update(bool was_pressed, int x, int y) override
Definition legacy.cpp:280
void draw(vex::brain::lcd &, bool first_draw, unsigned int frame_number) override
Definition legacy.cpp:292
PIDPage(PID &pid, std::string name, std::function< void(void)> onchange=[]() {})
Create a PIDPage.
Definition legacy.cpp:269
Page describes one part of the screen slideshow.
Definition legacy.h:128
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...
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)
void update(bool was_pressed, int x, int y) override
Definition legacy.cpp:42
void draw(vex::brain::lcd &, bool first_draw, unsigned int frame_number) override
Definition legacy.cpp:74
StatsPage(std::map< std::string, vex::motor & > motors)
Creates a stats page.
Definition legacy.cpp:41
Definition odometry_base.h:31
std::function< selector_t > timeout(std::function< selector_t > selector, uint64_t microsec, unsigned int fallback=NO_SELECTION_INDEX, std::function< void(size_t)> cancel=nullptr)
Definition initializer.h:104
constexpr size_t NO_SELECTION_INDEX
A constant index that is used in selector functions to represent when a selection has not yet been ma...
Definition initializer.h:45