view.h
class View
{
public:
/***** Obj Container /
lv_obj_t ui_Container1;
lv_obj_t ui_Container2;
/ Obj Rolller ***/
lv_obj_t ui_RollerHrsDez;
lv_obj_t ui_RollerHrsUni;
lv_obj_t ui_RollerMinDez;
lv_obj_t ui_RollerMinUni;
view.c
#include <view.h>
const char nameButton[5][10] = {“Start”, “Abort”, “Home”, “Back”, “back”};
uint32_t colorButton[4][10] = {0xf7a21b,0xe45635,0xd60257,0x59a87d};
static void event_handler(lv_event_t * e);
View views;
void View::teste(void){
int x = 20;
}
void View::lv_Screen_01(void)
{
lv_obj_set_style_bg_color(lv_screen_active(), lv_color_hex(0x474843), LV_PART_MAIN);//background
ui_Container1 = lv_obj_create(lv_screen_active());
lv_obj_remove_style_all(ui_Container1);
lv_obj_set_width(ui_Container1, 319);
lv_obj_set_height(ui_Container1, 190);
lv_obj_align(ui_Container1, LV_ALIGN_TOP_MID, 0, 1);
//lv_obj_clear_flag(ui_Container1, LV_OBJ_FLAG_CLICKABLE | LV_OBJ_FLAG_SCROLLABLE); /// Flags
lv_obj_set_style_bg_color(ui_Container1, lv_color_hex(0xF44336), LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_bg_opa(ui_Container1, 255, LV_PART_MAIN | LV_STATE_DEFAULT);
ui_LabelRelogio = lv_label_create(ui_Container1);
lv_obj_set_width(ui_LabelRelogio, LV_SIZE_CONTENT); /// 1
lv_obj_set_height(ui_LabelRelogio, LV_SIZE_CONTENT); /// 1
lv_obj_set_x(ui_LabelRelogio, 10);
lv_obj_set_y(ui_LabelRelogio, 2);
lv_obj_set_align(ui_LabelRelogio, LV_ALIGN_TOP_LEFT);
lv_label_set_text(ui_LabelRelogio, “07:58”);
lv_obj_set_style_text_color(ui_LabelRelogio, lv_color_hex(0xEBF3F4), LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_text_opa(ui_LabelRelogio, 255, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_text_font(ui_LabelRelogio, &lv_font_montserrat_26, LV_PART_MAIN | LV_STATE_DEFAULT);
ui_RollerHrsDez = lv_roller_create(ui_Container1);
lv_roller_set_options(ui_RollerHrsDez,“0\n1\n2”,LV_ROLLER_MODE_INFINITE);
lv_obj_set_width(ui_RollerHrsDez, 60);
lv_obj_set_height(ui_RollerHrsDez, 90);
lv_obj_set_x(ui_RollerHrsDez, -118);
lv_obj_set_y(ui_RollerHrsDez, 4);
lv_obj_set_align(ui_RollerHrsDez, LV_ALIGN_CENTER);
lv_obj_add_event_cb(ui_RollerHrsDez, event_roller, LV_EVENT_VALUE_CHANGED, NULL);
ui_RollerHrsUni = lv_roller_create(ui_Container1);
lv_roller_set_options(ui_RollerHrsUni, “0\n1\n2\n3\n4\n5\n6\n7\n8\n9”, LV_ROLLER_MODE_INFINITE);
lv_obj_set_width(ui_RollerHrsUni, 60);
lv_obj_set_height(ui_RollerHrsUni, 90);
lv_obj_set_x(ui_RollerHrsUni, -46);
lv_obj_set_y(ui_RollerHrsUni, 4);
lv_obj_set_align(ui_RollerHrsUni, LV_ALIGN_CENTER);
ui_RollerMinDez = lv_roller_create(ui_Container1);
lv_roller_set_options(ui_RollerMinDez, “0\n1\n2\n3\n4\n5”, LV_ROLLER_MODE_INFINITE);
lv_obj_set_width(ui_RollerMinDez, 60);
lv_obj_set_height(ui_RollerMinDez, 90);
lv_obj_set_x(ui_RollerMinDez, 44);
lv_obj_set_y(ui_RollerMinDez, 4);
lv_obj_set_align(ui_RollerMinDez, LV_ALIGN_CENTER);
ui_RollerMinUni = lv_roller_create(ui_Container1);
lv_roller_set_options(ui_RollerMinUni, “0\n1\n2\n3\n4\n5\n6\n7\n8\n9”, LV_ROLLER_MODE_INFINITE);
lv_obj_set_width(ui_RollerMinUni, 60);
lv_obj_set_height(ui_RollerMinUni, 90);
lv_obj_set_x(ui_RollerMinUni, 118);
lv_obj_set_y(ui_RollerMinUni, 4);
lv_obj_set_align(ui_RollerMinUni, LV_ALIGN_CENTER);
ui_Label9 = lv_label_create(ui_Container1);
lv_obj_set_width(ui_Label9, LV_SIZE_CONTENT); /// 1
lv_obj_set_height(ui_Label9, LV_SIZE_CONTENT); /// 1
lv_obj_set_x(ui_Label9, -3);
lv_obj_set_y(ui_Label9, -11);
lv_obj_set_align(ui_Label9, LV_ALIGN_CENTER);
lv_label_set_text(ui_Label9, “.”);
lv_obj_set_style_text_color(ui_Label9, lv_color_hex(0xEBF3F4), LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_text_opa(ui_Label9, 255, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_text_font(ui_Label9, &lv_font_montserrat_24, LV_PART_MAIN | LV_STATE_DEFAULT);
ui_Label8 = lv_label_create(ui_Container1);
lv_obj_set_width(ui_Label8, LV_SIZE_CONTENT); /// 1
lv_obj_set_height(ui_Label8, LV_SIZE_CONTENT); /// 1
lv_obj_set_x(ui_Label8, -3);
lv_obj_set_y(ui_Label8, 7);
lv_obj_set_align(ui_Label8, LV_ALIGN_CENTER);
lv_label_set_text(ui_Label8, “.”);
lv_obj_set_style_text_color(ui_Label8, lv_color_hex(0xFAFAFA), LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_text_opa(ui_Label8, 255, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_text_font(ui_Label8, &lv_font_montserrat_24, LV_PART_MAIN | LV_STATE_DEFAULT);
/******* Create a container button with ROW flex direction *****/
ui_Container2 = lv_obj_create(lv_screen_active());
lv_obj_set_size(ui_Container2, 295, 80);
//lv_obj_set_size(cont_row, 310, LV_PCT(90));
lv_obj_align(ui_Container2, LV_ALIGN_TOP_MID, 0, 160);
lv_obj_set_flex_flow(ui_Container2, LV_FLEX_FLOW_ROW);
lv_obj_set_style_bg_color(ui_Container2, lv_color_hex(0x0d242c), LV_PART_MAIN);
/ FINISH Create a container with ROW flex direction ************/
for(uint32_t i = 0; i < 4; i++) {
/*Add items to the row */
obj_btn = lv_button_create(ui_Container2);
lv_obj_set_size(obj_btn, 60, LV_PCT(100));
label = lv_label_create(obj_btn);
//lv_label_set_text_fmt(label, "Item: %“LV_PRIu32"”, i);
lv_label_set_text(label, nameButton[i]);// add o nome correto no botao
lv_obj_center(label);
lv_obj_set_style_bg_color(obj_btn,lv_color_hex(colorButton[0][i]),0);
lv_obj_add_event_cb(obj_btn, event_handler, LV_EVENT_CLICKED , NULL);// add 01/0
static lv_style_t style_text_label;
lv_style_init(&style_text_label);
lv_style_set_text_font(&style_text_label, &lv_font_montserrat_18);
lv_style_set_text_color(&style_text_label, lv_color_hex(0x0018F9));//lv_color_black()); // text color
lv_obj_add_style(label, &style_text_label, 0);
}
}
// Callback that is triggered when btn1 is clicked
static void event_handler(lv_event_t * e)
{
lv_event_code_t code = lv_event_get_code(e);
lv_obj_t * btn = (lv_obj_t )lv_event_get_target(e); // Cast void to lv_obj_t*
if(code == LV_EVENT_CLICKED) {
lv_obj_t * label = lv_obj_get_child(btn, 0);
const char * text = lv_label_get_text(label);
if((0 == lv_strcmp(nameButton[0],text))){
LV_LOG_USER("Start label is equal ? -> %s", text);
}
else if((0 == lv_strcmp(nameButton[1],text)))
LV_LOG_USER("Abort label is equal ? -> %s", text);
else if((0 == lv_strcmp(nameButton[2] ,text)))
LV_LOG_USER("Home label is equal ? -> %s", text);
else if((0 == strcmp(nameButton[3], text)))//const char nameButton[5][10] = {"Start", "Abort", "Home", "Back", "Back"};
LV_LOG_USER("Back label is equal ? -> %s", text);
else
LV_LOG_USER("Unknow ! -> %s", text);
}
}
static void event_roller(lv_event_t* e2)
{
lv_event_code_t code = lv_event_get_code(e2);
lv_obj_t* obj2 = (lv_obj_t*)lv_event_get_target(e2);
if (code == LV_EVENT_VALUE_CHANGED) {
char buf[32];
lv_roller_get_selected_str(obj2, buf, sizeof(buf));
LV_LOG_USER(“Selected roller: %s\n”, buf);
if(buf[0] == ‘2’)
{
LV_LOG_USER(“Selected ok: %s\n”, buf);
lv_roller_set_options(views.ui_RollerHrsUni, “0\n1\n2\n3”,
LV_ROLLER_MODE_INFINITE);
}
}
}
reset here ( line 153 )
lv_roller_set_options(views.ui_RollerHrsUni, “0\n1\n2\n3”, LV_ROLLER_MODE_INFINITE);
log:
[User] (310.830, +310830) event_roller: Selected roller: 2
view.cpp:149
[User] (310.830, +310830) event_roller: Selected roller: 2
view.cpp:149
[User] (310.830, +0) event_roller: Selected ok: 2
view.cpp:152
[User] (310.830, +0) event_roller: Selected ok: 2
view.cpp:152
Guru Meditation Error: Core 1 panic’ed (LoadProhibited). Exception was unhandled.
Core 1 register dump:
PC : 0x4019720f PS : 0x00060a30 A0 : 0x800fa70d A1 : 0x3ffb1ec0
A2 : 0x00000000 A3 : 0x00000000 A4 : 0x3f401f73 A5 : 0x3ffb1ba0
A6 : 0x3ffb1b70 A7 : 0x00000041 A8 : 0x801063a8 A9 : 0x3ffb1b60
A10 : 0x3ffbdcc8 A11 : 0x3ffb1d2c A12 : 0x00000200 A13 : 0x3f401f73
A14 : 0x3ffb6b50 A15 : 0x3ffc7a88 SAR : 0x00000004 EXCCAUSE: 0x0000001c
EXCVADDR: 0x00000008 LBEG : 0x4008a155 LEND : 0x4008a165 LCOUNT : 0xffffffff
Backtrace: 0x4019720c:0x3ffb1ec0 0x400fa70a:0x3ffb1ee0 0x400faddb:0x3ffb1f00 0x400d2965:0x3ffb1f50 0x400ee759:0x3ffb1fa0 0x400d4694:0x3ffb1fc0 0x400d4712:0x3ffb1fe0 0x400fb135:0x3ffb2020 0x40197109:0x3ffb2060 0x400d4682:0x3ffb2080 0x400d4712:0x3ffb20a0 0x400e93a9:0x3ffb20e0 0x400e98ab:0x3ffb2100 0x400e9c54:0x3ffb2190 0x400ea261:0x3ffb21e0 0x400f051e:0x3ffb2200 0x400d2776:0x3ffb2230 0x40109a5c:0x3ffb2270 0x4008d0ee:0x3ffb2290
ELF file SHA256: 141877da9
Rebooting…
ets Jul 29 2019 12:21:46
rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0030,len:4888
load:0x40078000,len:16516
load:0x40080400,len:4
load:0x40080404,len:3476
entry 0x400805b4
LVGL Library Version: 9.2.2