update to lvgl v8
This commit is contained in:
62
src/main.cpp
62
src/main.cpp
@@ -10,12 +10,16 @@
|
||||
TFT_eSPI tft = TFT_eSPI();
|
||||
FT62XXTouchScreen touchScreen = FT62XXTouchScreen(TFT_WIDTH, PIN_SDA, PIN_SCL);
|
||||
|
||||
|
||||
#include "lvgl.h"
|
||||
#include "widgets/meter/lv_meter.h"
|
||||
#include "esp_freertos_hooks.h"
|
||||
|
||||
static lv_disp_buf_t disp_buf;
|
||||
static lv_color_t buf[LV_HOR_RES_MAX * 10];
|
||||
static const uint16_t screenWidth = 480;
|
||||
static const uint16_t screenHeight = 320;
|
||||
|
||||
static lv_disp_draw_buf_t disp_buf;
|
||||
static lv_color_t buf[screenWidth * 10];
|
||||
|
||||
|
||||
|
||||
@@ -31,7 +35,9 @@ lv_obj_t *tabview;
|
||||
lv_obj_t *meter;
|
||||
|
||||
|
||||
static void event_handler_btn(lv_obj_t * obj, lv_event_t event){
|
||||
static void event_handler_btn(lv_event_t * e){
|
||||
lv_event_code_t event = lv_event_get_code(e);
|
||||
lv_obj_t * obj = lv_event_get_target(e);
|
||||
if(event == LV_EVENT_CLICKED) {
|
||||
if (obj == btn1)
|
||||
lv_label_set_text(label, "Hello");
|
||||
@@ -134,72 +140,46 @@ static void lv_tick_task(void)
|
||||
// lv_anim_start(&a);
|
||||
// }
|
||||
|
||||
void lv_gauge_2(lv_obj_t* par)
|
||||
{
|
||||
/*Describe the color for the needles*/
|
||||
static lv_color_t needle_colors[3];
|
||||
needle_colors[0] = LV_COLOR_BLUE;
|
||||
needle_colors[1] = LV_COLOR_ORANGE;
|
||||
needle_colors[2] = LV_COLOR_PURPLE;
|
||||
|
||||
LV_IMG_DECLARE(img_hand);
|
||||
|
||||
/*Create a gauge*/
|
||||
guage = lv_gauge_create(par, NULL);
|
||||
lv_gauge_set_needle_count(guage, 3, needle_colors);
|
||||
lv_obj_set_size(guage, 200, 200);
|
||||
lv_obj_align(guage, NULL, LV_ALIGN_CENTER, 100, 0);
|
||||
lv_gauge_set_needle_img(guage, &img_hand, 4, 4);
|
||||
/*Allow recoloring of the images according to the needles' color*/
|
||||
lv_obj_set_style_local_image_recolor_opa(guage, LV_GAUGE_PART_NEEDLE, LV_STATE_DEFAULT, LV_OPA_COVER);
|
||||
|
||||
/*Set the values*/
|
||||
lv_gauge_set_value(guage, 0, 10);
|
||||
lv_gauge_set_value(guage, 1, 20);
|
||||
lv_gauge_set_value(guage, 2, 30);
|
||||
}
|
||||
|
||||
void lv_ex_tabview(lv_obj_t* par)
|
||||
{
|
||||
/*Create a Tab view object*/
|
||||
lv_scr_load(par);
|
||||
tabview = lv_tabview_create(lv_scr_act(), NULL);
|
||||
tabview = lv_tabview_create(par);
|
||||
|
||||
/*Add 3 tabs (the tabs are page (lv_page) and can be scrolled*/
|
||||
tab1 = lv_tabview_add_tab(tabview, "Tab 1");
|
||||
tab2 = lv_tabview_add_tab(tabview, "Tab 2");
|
||||
lv_tabview_set_anim_time(tabview,2);
|
||||
}
|
||||
|
||||
void lv_Create_text(lv_obj_t* par)
|
||||
{
|
||||
label = lv_label_create(par, NULL);
|
||||
lv_label_set_long_mode(label, LV_LABEL_LONG_BREAK);
|
||||
label = lv_label_create(par);
|
||||
lv_label_set_long_mode(label, LV_LABEL_LONG_CLIP);
|
||||
lv_label_set_text(label, "Press a button");
|
||||
lv_label_set_align(label, LV_LABEL_ALIGN_CENTER);
|
||||
lv_obj_set_style_text_align(label, LV_TEXT_ALIGN_CENTER,0);
|
||||
lv_obj_set_size(label, 240, 40);
|
||||
lv_obj_set_pos(label, 0, 15);
|
||||
}
|
||||
|
||||
void lv_Create_button1(lv_obj_t* par)
|
||||
{
|
||||
btn1 = lv_btn_create(par, NULL);
|
||||
lv_obj_set_event_cb(btn1, event_handler_btn);
|
||||
btn1 = lv_btn_create(par);
|
||||
lv_obj_add_event_cb(btn1, event_handler_btn,LV_EVENT_ALL);
|
||||
lv_obj_set_width(btn1, 70);
|
||||
lv_obj_set_height(btn1, 32);
|
||||
lv_obj_set_pos(btn1, 32, 100);
|
||||
lv_obj_t * label1 = lv_label_create(btn1, NULL);
|
||||
lv_obj_t * label1 = lv_label_create(btn1);
|
||||
lv_label_set_text(label1, "Hello");
|
||||
}
|
||||
|
||||
void lv_Create_button2(lv_obj_t* par)
|
||||
{
|
||||
btn2 = lv_btn_create(par, NULL);
|
||||
lv_obj_set_event_cb(btn2, event_handler_btn);
|
||||
btn2 = lv_btn_create(par);
|
||||
lv_obj_add_event_cb(btn2, event_handler_btn,LV_EVENT_ALL);
|
||||
lv_obj_set_width(btn2, 70);
|
||||
lv_obj_set_height(btn2, 32);
|
||||
lv_obj_set_pos(btn2, 142, 100);
|
||||
lv_obj_t * label2 = lv_label_create(btn2, NULL);
|
||||
lv_obj_t * label2 = lv_label_create(btn2);
|
||||
lv_label_set_text(label2, "Goodbye");
|
||||
}
|
||||
|
||||
@@ -226,14 +206,14 @@ void setup() {
|
||||
|
||||
|
||||
// Display Buffer
|
||||
lv_disp_buf_init(&disp_buf, buf, NULL, LV_HOR_RES_MAX * 10);
|
||||
lv_disp_draw_buf_init(&disp_buf, buf, NULL, screenWidth * 10);
|
||||
|
||||
// Init Display
|
||||
lv_disp_drv_init(&disp_drv);
|
||||
disp_drv.hor_res = 480;
|
||||
disp_drv.ver_res = 320;
|
||||
disp_drv.flush_cb = my_disp_flush;
|
||||
disp_drv.buffer = &disp_buf;
|
||||
disp_drv.draw_buf = &disp_buf;
|
||||
lv_disp_drv_register(&disp_drv);
|
||||
|
||||
// Init Touchscreen
|
||||
|
||||
Reference in New Issue
Block a user