8#include "core/competition/initializer.h"
9#include "core/subsystems/odometry/odometry_base.h"
10#include "core/math/controls/pid.h"
11#include "core/math/controls/pidff.h"
12#include "core/utils/graph_drawer.h"
13#include "core/math/geometry/point2d.h"
14#include "core/math/geometry/pose2d.h"
22 Point2d dimensions()
const {
return max - min; }
23 Point2d center()
const {
return Point2d{(min + max).x() / 2, (min + max).y() / 2}; }
24 double width()
const {
return max.
x() - min.x(); }
25 double height()
const {
return max.y() - min.y(); }
26 bool contains(
Point2d p)
const {
27 bool xin = p.
x() > min.x() && p.
x() < max.x();
28 bool yin = p.
y() > min.y() && p.
y() < max.y();
42 : onpress(onpress), rect(rect), name(name) {}
48 : onpress(onpress), rect(rect), name(name) {}
55 bool update(
bool was_pressed,
int x,
int y);
57 void draw(vex::brain::lcd&,
bool first_draw,
unsigned int frame_number);
60 std::function<void(
void)> onpress;
62 std::string name =
"";
63 bool was_pressed_last =
false;
77 : value(val), low(low), high(high), rect(rect), name(name) {}
84 bool update(
bool was_pressed,
int x,
int y);
86 void draw(vex::brain::lcd&,
bool first_draw,
unsigned int frame_number);
95 std::string name =
"";
106 std::function<void()> onclick;
108struct CheckboxConfig {
109 std::function<void(
bool)> onupdate;
116 std::function<std::string()> text;
120 WidgetConfig& widget;
135 std::vector<SizedWidget> widgets;
138 CheckboxConfig checkbox;
158 virtual void update(
bool was_pressed,
int x,
int y);
166 virtual void draw(vex::brain::lcd& screen,
bool first_draw,
unsigned int frame_number);
175void draw_widget(WidgetConfig& widget, ScreenRect rect);
179 WidgetPage(WidgetConfig& cfg) : base_widget(cfg) {}
180 void update(
bool was_pressed,
int x,
int y)
override;
182 void draw(vex::brain::lcd&,
bool first_draw,
unsigned int frame_number)
override {
183 draw_widget(base_widget, {.x1 = 20, .y1 = 0, .x2 = 440, .y2 = 240});
187 WidgetConfig& base_widget;
191using update_func_t = std::function<void(
bool,
int,
int)>;
194using draw_func_t = std::function<void(vex::brain::lcd& screen,
bool,
unsigned int)>;
201 StatsPage(std::map<std::string, vex::motor&> motors);
203 void update(
bool was_pressed,
int x,
int y)
override;
205 void draw(vex::brain::lcd&,
bool first_draw,
unsigned int frame_number)
override;
208 void draw_motor_stats(
209 const std::string& name, vex::motor& mot,
unsigned int frame,
int x,
int y,
213 std::map<std::string, vex::motor&> motors;
214 static const int y_start = 0;
215 static const int per_column = 4;
216 static const int row_height = 20;
217 static const int row_width = 200;
235 void update(
bool was_pressed,
int x,
int y)
override;
237 void draw(vex::brain::lcd&,
bool first_draw,
unsigned int frame_number)
override;
240 static const int path_len = 40;
241 static constexpr char const* field_filename =
"vex_field_240p.png";
246 uint8_t* buf =
nullptr;
251 GraphDrawer velocity_graph;
262 FunctionPage(update_func_t update_f, draw_func_t draw_t);
264 void update(
bool was_pressed,
int x,
int y)
override;
266 void draw(vex::brain::lcd&,
bool first_draw,
unsigned int frame_number)
override;
269 update_func_t update_f;
281 PIDPage(
PID& pid, std::string name, std::function<
void(
void)> onchange = []() {});
282 PIDPage(PIDFF& pidff, std::string name, std::function<
void(
void)> onchange = []() {});
285 void update(
bool was_pressed,
int x,
int y)
override;
287 void draw(vex::brain::lcd&,
bool first_draw,
unsigned int frame_number)
override;
291 void zero_d_f() { pid.kd = 0; }
293 void zero_i_f() { pid.ki = 0; }
296 const std::string name;
297 std::function<void(
void)> onchange;
318 void update(
bool was_pressed,
int x,
int y)
override;
320 void draw(vex::brain::lcd&,
bool first_draw,
unsigned int frame_number)
override;
343 static void cancel(
size_t selected);
353 const size_t starting_index;
356 const static std::array<Rect, 8> buttons;
FunctionPage(update_func_t update_f, draw_func_t draw_t)
Creates a function page.
Definition screen_pages.cpp:32
void update(bool was_pressed, int x, int y) override
update uses the supplied update function to update this page
Definition screen_pages.cpp:35
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_pages.cpp:37
void update(bool was_pressed, int x, int y) override
Definition screen_pages.cpp:333
static size_t selector()
When using InitializerPage to select an Initialization, use this as the raw selector function.
Definition screen_pages.cpp:412
InitializerPage(const Initializer &initializer, size_t starting_index=0)
Creates an InitializerPage.
Definition screen_pages.cpp:313
void draw(vex::brain::lcd &, bool first_draw, unsigned int frame_number) override
Definition screen_pages.cpp:346
static void cancel(size_t selected)
When using a selector function wrapper that may cancel or otherwise cause the InitializerPage's selec...
Definition screen_pages.cpp:422
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 screen_pages.h:334
static const size_t DEFAULT_CANCELATION_INDEX
The default selected index if a cancelation occured during selection.
Definition screen_pages.h:346
static InitializerPage * Next()
Creates an InitializerPage that renders the following Initializations from the last.
Definition screen_pages.cpp:318
Definition initializer.h:194
Definition odometry_base.h:27
void draw(vex::brain::lcd &, bool first_draw, unsigned int frame_number) override
Definition screen_pages.cpp:123
void update(bool was_pressed, int x, int y) override
Definition screen_pages.cpp:197
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_pages.cpp:103
void update(bool was_pressed, int x, int y) override
Definition screen_pages.cpp:281
PIDPage(PID &pid, std::string name, std::function< void(void)> onchange=[]() {})
Create a PIDPage.
Definition screen_pages.cpp:270
void draw(vex::brain::lcd &, bool first_draw, unsigned int frame_number) override
Definition screen_pages.cpp:293
Class representing a lattice point.
Definition point2d.h:7
constexpr int x() const
Gets the X coordinate of the point.
Definition point2d.h:30
constexpr int y() const
Gets the Y coordinate of the point.
Definition point2d.h:36
Page describes one part of the screen slideshow.
Definition screen_pages.h:147
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...
StatsPage(std::map< std::string, vex::motor & > motors)
Creates a stats page.
Definition screen_pages.cpp:41
void draw(vex::brain::lcd &, bool first_draw, unsigned int frame_number) override
Definition screen_pages.cpp:74
void update(bool was_pressed, int x, int y) override
Definition screen_pages.cpp:42
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:102
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:43
Describes a Rectangle with a minimum and maximum point.
Definition screen_pages.h:18