1#include "screen/selector.h"
10selector_screen::selector_screen()
23void selector_screen::auton_ui_update(lv_event_t *e)
25 lv_obj_t *tab1 = lv_event_get_current_target(e);
26 lv_obj_t *event_obj = lv_event_get_target(e);
27 lv_obj_t *autonLabel = lv_obj_get_child(tab1, 2);
28 lv_obj_t *allianceSwitch = lv_obj_get_child(tab1, 3);
29 lv_obj_t *skillSwitch = lv_obj_get_child(tab1, 4);
30 lv_obj_t *auton_dd = lv_obj_get_child(tab1, 5);
36 if (event_obj == auton_dd) {
41 int currentAutonIndex = lv_dropdown_get_selected(auton_dd) + 1;
42 bool currentAlliance = lv_obj_has_state(allianceSwitch, LV_STATE_CHECKED);
43 int autonNum = currentAlliance ? currentAutonIndex * -1 : currentAutonIndex;
50 else if (event_obj == allianceSwitch) {
51 if (lv_obj_has_state(allianceSwitch, LV_STATE_CHECKED)) {
52 lv_dropdown_clear_options(auton_dd);
53 lv_dropdown_set_options(auton_dd, selector_screen::blueAutons);
54 lv_obj_set_style_border_color(auton_dd, lv_color_hex(0x0077c8), 0);
56 lv_dropdown_clear_options(auton_dd);
57 lv_dropdown_set_options(auton_dd, selector_screen::redAutons);
58 lv_obj_set_style_border_color(auton_dd, lv_color_hex(0xd22730), 0);
64 if (lv_obj_has_state(skillSwitch, LV_STATE_CHECKED)) {
70 lv_obj_add_state(allianceSwitch, LV_STATE_DISABLED);
71 lv_obj_add_state(auton_dd, LV_STATE_DISABLED);
74 lv_obj_clear_state(allianceSwitch, LV_STATE_DISABLED);
75 lv_obj_clear_state(auton_dd, LV_STATE_DISABLED);
92void selector_screen::drive_update(lv_event_t *e)
94 lv_obj_t *tab1 = lv_event_get_current_target(e);
95 lv_obj_t *drive_roller = lv_obj_get_child(tab1, -1);
96 lv_obj_t *driveLabel = lv_obj_get_child(tab1, -2);
98 int rollerIndex = lv_roller_get_selected(drive_roller);
101 lv_label_set_text_fmt(driveLabel,
"Current drive mode: %s", driveMode.c_str());
113void selector_screen::selector()
117 tabview = lv_tabview_create(lv_scr_act(), LV_DIR_TOP, 35);
120 lv_obj_t *tab1 = lv_tabview_add_tab(tabview,
"Autonomous select");
121 lv_obj_t *tab2 = lv_tabview_add_tab(tabview,
"Drive select");
127 lv_obj_add_event_cb(tab1, auton_ui_update, LV_EVENT_VALUE_CHANGED, NULL);
128 lv_obj_add_event_cb(tab2, drive_update, LV_EVENT_VALUE_CHANGED, NULL);
129 lv_obj_t *tabButtons = lv_tabview_get_tab_btns(tabview);
130 lv_obj_set_style_bg_color(tabButtons, lv_color_hex(0x4d0000), 0);
131 lv_obj_set_style_text_font(tabButtons, &lv_font_montserrat_18, 0);
133 lv_obj_t *label1 = lv_label_create(tab1);
134 lv_obj_t *label2 = lv_label_create(tab1);
135 lv_obj_t *autonName = lv_label_create(tab1);
136 lv_label_set_text(label1,
"Alliance");
137 lv_label_set_text(label2,
"Enable Skills");
139 lv_obj_align(label1, LV_ALIGN_TOP_LEFT, 0, 10);
140 lv_obj_align(label2, LV_ALIGN_LEFT_MID, 0, 0);
141 lv_obj_align(autonName, LV_ALIGN_BOTTOM_MID, 0, 0);
142 lv_obj_set_style_text_font(label1, &lv_font_montserrat_20, 0);
143 lv_obj_set_style_text_font(label2, &lv_font_montserrat_20, 0);
144 lv_obj_set_style_text_font(autonName, &lv_font_montserrat_16, 0);
147 lv_obj_t *matchSwitch = lv_switch_create(tab1);
148 lv_obj_add_flag(matchSwitch, LV_OBJ_FLAG_EVENT_BUBBLE);
149 lv_obj_set_style_bg_color(matchSwitch, lv_palette_main(LV_PALETTE_RED), LV_STATE_DEFAULT);
150 lv_obj_set_size(matchSwitch, lv_pct(21), lv_pct(27));
151 lv_obj_set_style_pad_all(matchSwitch, -5, LV_PART_KNOB);
152 lv_obj_align(matchSwitch, LV_ALIGN_TOP_MID, 0, 0);
155 lv_obj_t *skillSwitch = lv_switch_create(tab1);
156 lv_obj_add_flag(skillSwitch, LV_OBJ_FLAG_EVENT_BUBBLE);
157 lv_obj_set_size(skillSwitch, lv_pct(21), lv_pct(27));
158 lv_obj_set_style_pad_all(skillSwitch, -5, LV_PART_KNOB);
159 lv_obj_align(skillSwitch, LV_ALIGN_CENTER, 0, 0);
162 lv_obj_t *auton_dd = lv_dropdown_create(tab1);
163 lv_obj_add_flag(auton_dd, LV_OBJ_FLAG_EVENT_BUBBLE);
164 lv_dropdown_set_options(auton_dd, selector_screen::redAutons);
165 lv_obj_set_style_max_height(auton_dd, 50, 0);
166 lv_obj_set_size(auton_dd, lv_pct(35), lv_pct(35));
167 lv_obj_set_style_pad_top(auton_dd, 10, 0);
168 lv_obj_set_style_pad_bottom(auton_dd, 10, 0);
169 lv_obj_set_style_border_width(auton_dd, 4, 0);
170 lv_obj_set_style_border_color(auton_dd, lv_color_hex(0xd22730), 0);
171 lv_obj_set_style_border_color(auton_dd, lv_color_hex(0x7a7a7a), LV_STATE_DISABLED);
172 lv_obj_align(auton_dd, LV_ALIGN_TOP_RIGHT, 0, 0);
175 lv_obj_t *driveName = lv_label_create(tab2);
176 lv_label_set_text_fmt(driveName,
"Current drive mode:");
177 lv_obj_align(driveName, LV_ALIGN_BOTTOM_MID, 0, 0);
178 lv_obj_set_style_text_font(driveName, &lv_font_montserrat_18, 0);
180 lv_obj_t *drive_roller = lv_roller_create(tab2);
181 lv_obj_add_flag(drive_roller, LV_OBJ_FLAG_EVENT_BUBBLE);
182 lv_roller_set_options(drive_roller, selector_screen::driveModes, LV_ROLLER_MODE_INFINITE);
185 lv_obj_set_style_bg_color(drive_roller, lv_color_hex(0xf97e2c), LV_PART_SELECTED);
186 lv_obj_set_style_text_font(drive_roller, &lv_font_montserrat_24, LV_PART_SELECTED);
187 lv_roller_set_visible_row_count(drive_roller, 3);
188 lv_obj_center(drive_roller);
189 lv_obj_align(drive_roller, LV_ALIGN_TOP_MID, 0, 0);
static std::string autonName
The name of the autonomous program.
static AUTON_ROUTINE auton
Sets the number of the autonomous program to use.
static void AutonSwitcher(int autonNum)
Switches the autonomous program.
static std::string SwitchDrive(int driveMode)
Switches the DriveTrain mode between arcade and tank drive.