I have read the other threads on this particular issue but they did not help me, so I figured it’d be better to just show the code and get some specific help.
#include "main.h"
#if LV_USE_IMG
#define POTENTIOMETER_PORT 'A'
lv_obj_t * Auto1;
lv_obj_t * Auto2;
lv_obj_t * Auto3;
lv_obj_t * Auto4;
lv_obj_t * AutoLBL1;
lv_obj_t * AutoLBL2;
lv_obj_t * AutoLBL3;
lv_obj_t * AutoLBL4;
lv_obj_t * WarningMSG1;
lv_obj_t * WarningMSG2;
static lv_obj_t * Logo;
LV_IMG_DECLARE(ConvertedDQ2);
lv_style_t myButtonStyleREL; //released style
lv_style_t myButtonStylePR; //pressed style
static lv_res_t btn_click_action(lv_obj_t * btn)
{
uint8_t id = lv_obj_get_free_num(btn); //id usefull when there are multiple
buttons
/* if(id == 0)
{
char buffer[100];
sprintf(buffer, "button was clicked %i milliseconds from start", pros::millis());
lv_label_set_text(AutoLBL1, buffer);
}
*/
return LV_RES_OK;
}
/**
* Runs initialization code. This occurs as soon as the program is started.
*
* All other competition modes are blocked by initialize; it is recommended
* to keep execution time for this mode under a few seconds.
*/
void initialize()
{
}
void disabled() {
}
void competition_initialize() {
// auton selector HERE
lv_style_copy(&myButtonStyleREL, &lv_style_plain);
myButtonStyleREL.body.main_color = lv_color_hex(0x804000); //%25
myButtonStyleREL.body.grad_color = lv_color_hex(0x003d66); //%25
myButtonStyleREL.body.radius = 10;
myButtonStyleREL.text.color = lv_color_hex(0x999999);
lv_style_copy(&myButtonStylePR, &lv_style_plain);
myButtonStylePR.body.main_color = lv_color_hex(0xff9933); //%60
myButtonStylePR.body.grad_color = lv_color_hex(0x006bb3); //%60
myButtonStylePR.body.radius = 10;
myButtonStylePR.text.color = LV_COLOR_MAKE(255, 255, 255);
//auto1
Auto1 = lv_btn_create(lv_scr_act(), NULL); //create button, lv_scr_act() is deafult
screen object
lv_obj_set_free_num(Auto1, 0); //set button is to 0
//auto2
Auto2 = lv_btn_create(lv_scr_act(), NULL); //create button, lv_scr_act() is deafult
screen object
lv_obj_set_free_num(Auto2, 1); //set button is to 0
//auto3
Auto3 = lv_btn_create(lv_scr_act(), NULL); //create button, lv_scr_act() is deafult
screen object
lv_obj_set_free_num(Auto3, 2); //set button is to 0
//auto4
Auto4 = lv_btn_create(lv_scr_act(), NULL); //create button, lv_scr_act() is deafult
screen object
lv_obj_set_free_num(Auto4, 3); //set button is to 0
//auto1
lv_btn_set_action(Auto1, LV_BTN_ACTION_CLICK, btn_click_action); //set function
to be called on button click
lv_btn_set_style(Auto1, LV_BTN_STYLE_REL, &myButtonStyleREL); //set the
released style
lv_btn_set_style(Auto1, LV_BTN_STYLE_PR, &myButtonStylePR); //set the pressed
style
lv_obj_set_size(Auto1, 250, 30); //set the button size (acceptable default: 200,50)
lv_obj_align(Auto1, NULL, LV_ALIGN_CENTER, 0, -85); //set the position to CENTER
//auto2
lv_btn_set_action(Auto2, LV_BTN_ACTION_CLICK, btn_click_action); //set function
to be called on button click
lv_btn_set_style(Auto2, LV_BTN_STYLE_REL, &myButtonStyleREL); //set the
released style
lv_btn_set_style(Auto2, LV_BTN_STYLE_PR, &myButtonStylePR); //set the pressed
style
lv_obj_set_size(Auto2, 250, 30); //set the button size (acceptable default: 200,50)
lv_obj_align(Auto2, NULL, LV_ALIGN_CENTER, 0, -40); //set the position to CENTER
//auto3
lv_btn_set_action(Auto3, LV_BTN_ACTION_CLICK, btn_click_action); //set function
to be called on button click
lv_btn_set_style(Auto3, LV_BTN_STYLE_REL, &myButtonStyleREL); //set the released style
lv_btn_set_style(Auto3, LV_BTN_STYLE_PR, &myButtonStylePR); //set the pressed
style
lv_obj_set_size(Auto3, 250, 30); //set the button size (acceptable default: 200,50)
lv_obj_align(Auto3, NULL, LV_ALIGN_CENTER, 0, 5); //set the position to CENTER
//auto4
lv_btn_set_action(Auto4, LV_BTN_ACTION_CLICK, btn_click_action); //set function
to be called on button click
lv_btn_set_style(Auto4, LV_BTN_STYLE_REL, &myButtonStyleREL); //set the
released style
lv_btn_set_style(Auto4, LV_BTN_STYLE_PR, &myButtonStylePR); //set the pressed
style
lv_obj_set_size(Auto4, 250, 30); //set the button size (acceptable default: 200,50)
lv_obj_align(Auto4, NULL, LV_ALIGN_CENTER, 0, 50); //set the position to CENTER
//auto1
AutoLBL1 = lv_label_create(Auto1, NULL); //create label and puts it inside of the
button
lv_label_set_text(AutoLBL1, "Routine 1"); //sets label text
//auto2
AutoLBL2 = lv_label_create(Auto2, NULL); //create label and puts it inside of the
button
lv_label_set_text(AutoLBL2, "Routine 2"); //sets label text
//auto3
AutoLBL3 = lv_label_create(Auto3, NULL); //create label and puts it inside of the
button
lv_label_set_text(AutoLBL3, "Routine 3"); //sets label text
//auto4
AutoLBL4 = lv_label_create(Auto4, NULL); //create label and puts it inside of the
button
lv_label_set_text(AutoLBL4, "Routine 4"); //sets label text
WarningMSG1 = lv_label_create(lv_scr_act(), NULL); //create label and puts it on the
screen
lv_label_set_text(WarningMSG1, "Please check that the selected"); //sets label text
lv_obj_align(WarningMSG1, NULL, LV_ALIGN_CENTER, 0, 80);
WarningMSG2 = lv_label_create(lv_scr_act(), NULL); //create label and puts it on the
screen
lv_label_set_text(WarningMSG2, "autonomous routine is correct!!"); //sets label text
lv_obj_align(WarningMSG2, NULL, LV_ALIGN_CENTER, 00, 100);
//lv_img_set_auto_size(Logo, true);
Logo = lv_img_create(lv_scr_act(), NULL);
lv_img_set_src(Logo, &ConvertedDQ2);
lv_obj_align(Logo, NULL, LV_ALIGN_CENTER, 0, 0);
}
#endif
void autonomous() {}
void opcontrol() {
}