需要安装lvgl、ESP32_Display_Panel,具体可参考:
打开案例库出现错误:
根据提示需要打开官方教程:
打开官方案例库可以发现相应指导说明:
如何使用:
选择配置开发板:
根据开发板类型选择和驱动参数:
提示需要安装LVGL版本不超过8.3.9
需要手动配置相关库文件:
配置完成即可打开案例库进行编程:
添加代码:
代码如下:
lv_obj_t* chart;
chart = lv_chart_create(lv_scr_act()); // 创建Chart对象
lv_obj_set_size(chart, 300, 300); // 设置大小
lv_obj_center(chart); //居中显示
lv_chart_set_type(chart, LV_CHART_TYPE_LINE); /*Show lines and points too*/
/*Add two data series*/
lv_chart_series_t* ser1 = lv_chart_add_series(chart, lv_palette_main(LV_PALETTE_RED), LV_CHART_AXIS_PRIMARY_Y); // 创建第1条chart series,设置红色
lv_chart_series_t* ser2 = lv_chart_add_series(chart, lv_palette_main(LV_PALETTE_GREEN), LV_CHART_AXIS_SECONDARY_Y); // 创建第1条chart series,设置绿色
/*Set the next points on 'ser1'*/
lv_chart_set_next_value(chart, ser1, 10);
lv_chart_set_next_value(chart, ser1, 10);
lv_chart_set_next_value(chart, ser1, 10);
lv_chart_set_next_value(chart, ser1, 10);
lv_chart_set_next_value(chart, ser1, 10);
lv_chart_set_next_value(chart, ser1, 10);
lv_chart_set_next_value(chart, ser1, 10);
lv_chart_set_next_value(chart, ser1, 30);
lv_chart_set_next_value(chart, ser1, 70);
lv_chart_set_next_value(chart, ser1, 90);
/*Directly set points on 'ser2'*/
ser2->y_points[0] = 90;
ser2->y_points[1] = 70;
ser2->y_points[2] = 65;
ser2->y_points[3] = 65;
ser2->y_points[4] = 65;
ser2->y_points[5] = 65;
ser2->y_points[6] = 65;
ser2->y_points[7] = 65;
ser2->y_points[8] = 65;
ser2->y_points[9] = 65;
lv_chart_set_axis_tick(chart, LV_CHART_AXIS_PRIMARY_Y, 5, 2,3 ,2, true, 40); // y轴tick显示,显示3个刻度值
lv_chart_refresh(chart); /*Required after direct set*/
项目文件:
仿真界面:
实物照片:
项目代码:
本帖最后由 Maker_kun 于 2024-10-30 22:26 编辑