So, I’m trying to implement a GUI for my Vex V5 Brain and one of the screens is a window with 3 buttons (Arduino, ADI, Smart Port) inside the window, alongside a back button that’s included in the window.
But for some reason when I create the lv_obj_t * btn
objects in the window, I can move the buttons horizontally, but I can’t vertically. Here’s the code I got so far:
#include "gui_global.hpp"
#pragma once
inline static lv_res_t sensorSelect_back_click_action(lv_obj_t * btn){
if(sensor_state){
sensor_destroy();
sensor_state = false;
debugMode_init();
}
return LV_RES_OK;
}
inline static lv_res_t sensors_click_action(lv_obj_t * btn){
uint8_t id = lv_obj_get_free_num(btn);
if(id == 0){ //arduino
//add code here
}
if(id == 1){//adi
//add code here
}
if(id == 2){//smart port
//add code here
}
// REFERENCE
// if(state){
// state_destroy();
// state = false;
// state2_init();
// }
return LV_RES_OK;
}
inline void sensor_init(){
lv_obj_set_hidden(driveMode_button,true);
lv_obj_set_hidden(debugMode_button,true);
lv_obj_set_hidden(competitionMode_button,true);
if(sensor_main_page_set)
lv_obj_set_hidden(sensor_main_page, false);
else{
sensor_main_page = lv_win_create(lv_scr_act(), NULL);
lv_win_set_title(sensor_main_page, "Sensor Selector BACK:");
lv_win_add_btn(sensor_main_page, SYMBOL_PREV, sensorSelect_back_click_action);
sensor_main_page_set = true;
/*THESE ARE THE BUTTONS THAT I CAN'T MOVE VERTICALLY*///////////////
arduinoSensor_button = lv_btn_create(sensor_main_page, NULL);
lv_obj_set_free_num(arduinoSensor_button, 0);
lv_btn_set_action(arduinoSensor_button, LV_BTN_ACTION_CLICK, sensors_click_action); //set function to be called on button click
lv_btn_set_style(arduinoSensor_button, LV_BTN_STYLE_REL, &buttonStyleREL);
lv_btn_set_style(arduinoSensor_button, LV_BTN_STYLE_PR, &buttonStylePR);
lv_obj_set_size(arduinoSensor_button, 150, 50);
lv_obj_align(arduinoSensor_button, NULL, LV_ALIGN_OUT_BOTTOM_MID, 0, 150);
arduinoSensor_label = lv_label_create(arduinoSensor_button, NULL);
lv_label_set_text(arduinoSensor_label, "Arduino");
adi_button = lv_btn_create(sensor_main_page, NULL);
lv_obj_set_free_num(adi_button, 1);
lv_btn_set_action(adi_button, LV_BTN_ACTION_CLICK, sensors_click_action); //set function to be called on button click
lv_btn_set_style(adi_button, LV_BTN_STYLE_REL, &buttonStyleREL);
lv_btn_set_style(adi_button, LV_BTN_STYLE_PR, &buttonStylePR);
lv_obj_set_size(adi_button, 150, 50);
lv_obj_align(adi_button, NULL, LV_ALIGN_CENTER, 0, 0);
adi_label = lv_label_create(adi_button, NULL);
lv_label_set_text(adi_label, "ADI");
smartPort_button = lv_btn_create(sensor_main_page, NULL);
lv_obj_set_free_num(smartPort_button, 2);
lv_btn_set_action(smartPort_button, LV_BTN_ACTION_CLICK, sensors_click_action); //set function to be called on button click
lv_btn_set_style(smartPort_button, LV_BTN_STYLE_REL, &buttonStyleREL);
lv_btn_set_style(smartPort_button, LV_BTN_STYLE_PR, &buttonStylePR);
lv_obj_set_size(smartPort_button, 150, 50);
lv_obj_align(smartPort_button, NULL, LV_ALIGN_CENTER, 0, 0);
smartPort_label = lv_label_create(smartPort_button, NULL);
lv_label_set_text(smartPort_label, "Smart Port");
}
}
inline void sensor_destroy(){
lv_obj_set_hidden(sensor_main_page, true);
lv_obj_set_hidden(driveMode_button,false);
lv_obj_set_hidden(debugMode_button,false);
lv_obj_set_hidden(competitionMode_button,false);
}
All the definitions are included in the gui_global.hpp
file I included at the top
I’ve tried manipulating the parameters in lv_obj_align(btn, NULL, LV_ALIGN_****, x, y);
, especially the LV_ALIGN
& the x
and y
parameters. But for some reason only the x
parameter works, the other 2 don’t.