hiii
i m a beginner in the display development
i developed a graphics and touch with ILI9341 320x240 display using spi interface using mcc configuration.
used a MPLAB IDE and PIC32 microcontroller
i use a adafruit gfx library for ili9341 display simple graphics and touch
now i add a littlevgl graphics on it but my display working very slow and behave irritating
video link is given below
my setup code given below
bool my_touchpad_read(lv_indev_drv_t * indev_driver, lv_indev_data_t * data) {
static lv_coord_t last_x = 0;
static lv_coord_t last_y = 0;
/*Save the state and save the pressed coordinate*/
data->state = (isTouching() == 0) ? LV_INDEV_STATE_PR : LV_INDEV_STATE_REL;
if (data->state == LV_INDEV_STATE_PR)getPosition(&last_x, &last_y, 1, 0x10);
lv_tick_inc(1);
/*Set the coordinates (if released use the last pressed coordinates)*/
data->point.x = last_x + 13;
data->point.y = last_y + 4;
return false; /*Return `false` because we are not buffering and no more data to read*/
}
void setup() {
static lv_disp_buf_t disp_buf;
static lv_color_t buf1[LV_HOR_RES_MAX * 10]; /*Declare a buffer for 10 lines*/
static lv_color_t buf2[LV_HOR_RES_MAX * 10]; /*Declare a buffer for 10 lines*/
lv_disp_buf_init(&disp_buf, buf1,buf2, LV_HOR_RES_MAX * 10);
lv_disp_drv_t disp_drv; /*Descriptor of a display driver*/
lv_disp_drv_init(&disp_drv); /*Basic initialization*/
disp_drv.flush_cb = my_disp_flush;
disp_drv.buffer = &disp_buf; /*Assign the buffer to the display*/
lv_disp_t * disp;
disp = lv_disp_drv_register(&disp_drv); /*Finally register the driver*/
lv_indev_drv_t indev_drv;
lv_indev_drv_init(&indev_drv); /*Descriptor of a input device driver*/
indev_drv.type = LV_INDEV_TYPE_POINTER; /*Touch pad is a pointer-like device*/
// indev_drv.type = LV_INDEV_TYPE_NONE;
// indev_drv.read_cb = xpt2046_read; /Set your driver function/
indev_drv.read_cb = my_touchpad_read; /Set your driver function/
lv_indev_drv_register(&indev_drv); /Finally register the driver/
}
void lv_ex_slider_1(void) {
/Create styles/
static lv_style_t style_bg;
static lv_style_t style_indic;
static lv_style_t style_knob;
lv_style_copy(&style_bg, &lv_style_pretty);
style_bg.body.main_color = LV_COLOR_YELLOW;
style_bg.body.grad_color = LV_COLOR_BLACK;
style_bg.body.radius = LV_RADIUS_CIRCLE;
style_bg.body.border.color = LV_COLOR_BLACK;
lv_style_copy(&style_indic, &lv_style_pretty_color);
style_indic.body.radius = LV_RADIUS_CIRCLE;
style_indic.body.shadow.width = 8;
style_indic.body.shadow.color = style_indic.body.main_color;
style_indic.body.padding.left = 3;
style_indic.body.padding.right = 3;
style_indic.body.padding.top = 3;
style_indic.body.padding.bottom = 3;
lv_style_copy(&style_knob, &lv_style_pretty);
style_knob.body.radius = LV_RADIUS_CIRCLE;
style_knob.body.opa = LV_OPA_70;
style_knob.body.padding.top = 10;
style_knob.body.padding.bottom = 10;
/*Create a slider*/
lv_obj_t * slider = lv_slider_create(lv_scr_act(), NULL);
lv_slider_set_style(slider, LV_SLIDER_STYLE_BG, &style_bg);
lv_slider_set_style(slider, LV_SLIDER_STYLE_INDIC, &style_indic);
lv_slider_set_style(slider, LV_SLIDER_STYLE_KNOB, &style_knob);
lv_obj_align(slider, NULL, LV_ALIGN_CENTER, 0, 0);
// lv_obj_set_event_cb(slider, event_handler1);
}
int main(void) {
SYSTEM_Initialize();
tft_begin();
fillScreen(ILI9341_BLACK);
begin(ILI9341_TFTWIDTH, ILI9341_TFTHEIGHT);
setCalibration(1952, 325, 176, 1696);
lv_init();
setup();
lv_ex_slider_1();
while (1) {
lv_task_handler();
lv_tick_inc(10);
}
return 1;
}