镜花水月000

  • 2024-11-09
  • 回复了主题帖: [X-NUCLEO-53L4A3 TOF评估板]1.测试和代码移植

    秦天qintian0303 发表于 2024-11-9 08:39 这次带的开发板不是可以直接下载使用吗?   上位机不好用,看波形不灵活

  • 2024-11-07
  • 发表了主题帖: [X-NUCLEO-53L4A3 TOF评估板]3.精度测试

    今天进行简单的精度实验测试。 由于传感器的精度和测量频率过很大关系,所以本次实验看看同一位置下、不同频率对测量精度的影响。 下面为不同频率下测距的具体数据结果图(注:匿名助手上位机有FPS统计,在图片左下角) 频率 误差 100Hz 12mm 50Hz 5mm 10Hz 4mm 5Hz 2mm 从数据来看同一目标、同一距离条件下,频率越低精度越高,后期对数据进行滤波处理的话精度会比目前高一些,在不太考虑实时性的情况下精度应该能达到2mm内,当然,测距的精度与环境光、目标属性、测量距离都有很大的关系。由于板子不是非常好固定,所以先进行本次简单的测距精度测试。从测量结果来看,与我手头上的相位式测距仪(优利德LM50A)相比,即使是在最慢频率下的测量,53L4A3精度的重复性还是不如毫米级的相位激光测距仪,但53L4A3的优势是速度可以比较快,体积很小,易于集成,总之两者的原理和应用场景还是有很大不同的。

  • 回复了主题帖: [X-NUCLEO-53L4A3 TOF评估板]2.传感器光谱、激光功率、温度测试

    lugl4313820 发表于 2024-11-6 10:41 第一次见这么专业的设备,您是专业做这方面的吗? 不算是专业做这方面的,用的这些都是业余设备

  • 2024-11-05
  • 加入了学习《2022 Digi-Key KOL 系列: 开源 | 四翼扑翼机(仿生鸟)原理及设计解析》,观看 开源 | 四翼扑翼机(仿生鸟)原理及设计解析

  • 2024-11-04
  • 发表了主题帖: [X-NUCLEO-53L4A3 TOF评估板]2.传感器光谱、激光功率、温度测试

    下面分别从板子功率、激光功率、温度、光谱进行测试。 首先进行板子的功率测试,使用USB功率测试仪,板子的工作电压5V,电流0.1A,总功耗0.5W左右。 然后进行激光高功率测试,测试结果:正常工作时约2mW左右。 接下来进行光谱测试,由测试结果可知激光的波长约940nm左右,这与官方参数基本一致。 最后进行温度测试,使用后外热成像分辨率160*120,工作时单片机温度约为32℃左右,传感器温度约为27℃左右。 总结: 测试项目 结果 板子功率 0.5W(5V,0.1A) 激光功率 ~2mW 激光波长 940nm 传感器工作温度 ~27℃

  • 发表了主题帖: [X-NUCLEO-53L4A3 TOF评估板]1.测试和代码移植

    首先感谢EEWORLD以及得捷电子给予这次测评的机会。 先了解一下VL53L4ED官方参数特性 首先运行一下官方例程,让传感器先工作起来,打开STM32CUBEMX,安装TOF扩展包 安装完成后在本地磁盘找到软件包后打开VL53L4A3的例程 例程有3个分别为多传感器测距、单传感器测距、阈值检测,由于本次测评的硬件只有1个中间传感器,所以打开第二个例程编译下载即可体验简单的测距功能。需要注意例程的波特率是460800 接下来体验一下官方的VL53L4ED_GUI软件,软件地址STSW-IMG045 - P-NUCLEO-53L4A3 pack graphical user interface (GUI) - 意法半导体STMicroelectronics 先升级STLink模式为VCP+U盘模式 然后打开VL53L4ED_GUI后点击Flash FW烧录固件等待绿灯亮起 点击开始测试 官方的软件波形图局限性能比较大,不能看更多的历史数据,还不能放大缩小,很不方便,所以接下来进行程序驱动的移植,并使用匿名助手上位机软件进行传感器的测试。 本次程序移植以官方的SimpleRangning例程为参考,并加入匿名助手的通讯协议代码,移植过程此处省略,移植后的代码结构如下 本次测试代码中使用的通讯帧是灵活格式帧(具体可以查看上位机说明书) 通讯函数定义如下 匿名助手上位机的灵活数据帧配置如下 打开数据波形控件,添加相关变量 配置完成后进行测试即可,不得不说匿名助手的波形显示功能非常的灵活方便 传感器初始化程序如下,传感器工作过程可以参考手册(UM3177)和注释 void bsp_tof_init(void) { uint32_t Id; /* reset XSHUT (XSDN) pin */ HAL_GPIO_WritePin(VL53L4A3_XSHUT_C_PORT, VL53L4A3_XSHUT_C_PIN, GPIO_PIN_RESET); HAL_Delay(2); HAL_GPIO_WritePin(VL53L4A3_XSHUT_C_PORT, VL53L4A3_XSHUT_C_PIN, GPIO_PIN_SET); HAL_Delay(2); printf("53L4A3 Simple Ranging demo application\r\n"); status = VL53L4A3_RANGING_SENSOR_Init(VL53L4A3_DEV_CENTER); if (status != BSP_ERROR_NONE) { printf("VL53L4A3_RANGING_SENSOR_Init failed\r\n"); while (1); } /*- 读取传感器ID -*/ VL53L4A3_RANGING_SENSOR_ReadID(VL53L4A3_DEV_CENTER, &Id); VL53L4A3_RANGING_SENSOR_GetCapabilities(VL53L4A3_DEV_CENTER, &Cap); /*-- 测量模式 --*/ Profile.RangingProfile = VL53L4ED_PROFILE_CONTINUOUS; /*-- 测量时间 10 ms < TimingBudget < 200 ms --*/ Profile.TimingBudget = TIMING_BUDGET; Profile.Frequency = 0; /* Induces intermeasurement period, NOT USED for normal ranging */ /*-- 测量噪声输出使能 --*/ Profile.EnableAmbient = 1; /* Enable: 1, Disable: 0 */ /*-- 测量信号强度输出使能 --*/ Profile.EnableSignal = 1; /* Enable: 1, Disable: 0 */ /* set the profile if different from default one */ VL53L4A3_RANGING_SENSOR_ConfigProfile(VL53L4A3_DEV_CENTER, &Profile); /* 阻塞模式 */ // status = VL53L4A3_RANGING_SENSOR_Start(VL53L4A3_DEV_CENTER, RS_MODE_BLOCKING_CONTINUOUS); /* 同步模式 */ status = VL53L4A3_RANGING_SENSOR_Start(VL53L4A3_DEV_CENTER, RS_MODE_ASYNC_CONTINUOUS); if (status != BSP_ERROR_NONE) { printf("VL53L4A3_RANGING_SENSOR_Start failed\r\n"); while (1); } }   Main函数 int main(void) { int32_t i = 0, status; RANGING_SENSOR_Result_t Result; bsp_init(); init_cycle_counter(true); bsp_tof_init(); while(1) { // int64_t time_stamp = get_system_ms(); VL53L4A3_RANGING_SENSOR_GetDistance(VL53L4A3_DEV_CENTER, &Result); /* polling mode status = */ while(ToF_EventDetected == 0) { } // printf("time_stamp = %lldms\r\n", get_system_ms() - time_stamp); ToF_EventDetected = 0; ano_send_custom1(Result.ZoneResult[0].Distance[0], Result.ZoneResult[0].Status[0], Result.ZoneResult[0].Ambient[0], Result.ZoneResult[0].Signal[0]); } }   在程序中我们可以通过TIMING_BUDGET参数进行测量时间的设定,其中10 ms < TimingBudget < 200 ms 通过VL53L4A3_RANGING_SENSOR_Start()函数设置模式,有四种模式可选(如下),前两个是阻塞模式,后面两个是中断模式 通过RANGING_SENSOR_INSTANCES_NBR可以配种传感器的个数,例程中配置的是3,即默认为3个传感器,本次测评板只有1个,为了节约内存我们可以定义为1,但VL53L4A3_DEV_CENTER需要重新定义为0 接下来进行精度等方面的测试。

  • 2024-11-01
  • 发表了主题帖: 《智能驾驶之激光雷达算法详解》5.多传感器SLAM

    本书第13章是关于多传感器融合SLAM算法的相关讲解,主要介绍了多传感器融合在智能车辆定位中的应用。由于单一传感器存在工作特性和局限性,处理不了复杂路况,因此多传感器融合实现高精度、稳定、实时的定位成为学术界和工业界的热点之一。多传感器融合 SLAM 有松耦合和紧耦合两种方式,紧耦合方式精度和稳定性较高,是目前研究重点,如 LIC-Fusion 算法、基于因子图框架的算法、R2LIVE 算法及 LVI-SAM 算法等。此外,一些学者结合事先构建的高精点云地图提供全局定位信息,如百度的相关研究及图森未来的研究。 本章主要讲解了视觉、激光雷达、IMU融合的R2LIVE 算法和融合点云地图的TMFL算法。其中R2LIVE 算法由里程计模块和因子图优化模块两部分组成。里程计模块基于迭代误差状态卡尔曼滤波框架实现激光雷达、相机和 IMU 三种观测数据紧耦合,得到系统位姿状态初步估计并按各自传感器频率输出。该框架采用误差状态卡尔曼滤波器思想在误差状态空间进行状态传播,结合迭代误差状态卡尔曼滤波器更新方式,转换为最大化后验估计问题并用高斯牛顿法求解。在激光雷达侧位姿初步估计时使用基于平面特征点提取和运动补偿的方法;在相机侧位姿初步估计时使用快速角点提取和 KLT 光流跟踪的方式。因子图优化模块使用基于动态滑窗的因子图方法实现对视觉路标、关键帧位姿以及相机相对激光雷达和 IMU 时间偏差的优化。 在 L4 级智能驾驶任务中,为保证定位算法的精度、实时性和鲁棒性,一些学者考虑引入高精地图实现长距离绝对定位。图森未来的 L. Pan 等在 ICRA 2021 会议上提出基于激光雷达特征地图辅助的多传感器紧耦合定位(TMFL)算法,该算法基于因子图优化框架实现 IMU、轮速计与激光点云地图之间的紧耦合,将车辆位姿估计问题转化为优化问题,用固定延迟平滑方式在动态滑窗内求解。在 TMFL 算法中,当前帧激光点云和激光雷达特征地图的匹配实现全局位姿估计,基于车辆运动学模型和 IMU / 轮速计数据得到局部相对位姿变化,二者联合构成对车辆状态的最终约束。 其中R2LIVE 算法在github中有开源代码可以供查阅: https://github.com/hku-mars/r2live

  • 2024-10-12
  • 回复了主题帖: 测评入围名单: X-NUCLEO-53L4A3 飞行时间 (ToF) 传感器评估板,配套NUCLEO-F401RE

    确认无误,可以按计划完成

  • 2024-10-10
  • 回复了主题帖: 《智能驾驶之激光雷达算法详解》4.激光雷达与IMU组合定位

    Jacktang 发表于 2024-10-10 07:27 LIO-SAM算法书中有详细的推导,这本书值得好好读读 是的

  • 2024-10-09
  • 发表了主题帖: 《智能驾驶之激光雷达算法详解》4.激光雷达与IMU组合定位

    IMU惯性测量单元目前是无人机、机器人、汽车领域等常用的测量运行状态的传感器,主要包含加速度计和陀螺仪,通过各种融合算法如互补滤波、卡尔曼滤波等计算车辆的实时姿态,但IMU在航向角存在积分误差,而激光里程计主要通过对环境的感知来来实现对自身的定位估计,通过激光里程计和IMU的互补性进行车辆的组合实时精确姿态计算。 根据组合方式和原理业界通常将LiDAR+IMU分为松耦合和紧耦合两个方向。LiDAR+IMU松耦合定位算法通常使激光里程计和IMU航位推算相互独立运行,并基于卡尔曼滤波框架、粒子滤波框架等实现二者信息的融合,最终输出定位估计结果。LiDAR+IMU紧耦合定位算法为对同一姿态优化问题结合激光雷达数据和IMU数据来求解。 <智能驾驶之激光雷达算法详解>中提到的具有代表性的组合定位算法有IMU-AHFLO算法和LIO-SAM算法。IMU-AHFLO算法相对比较简单,书中的推导非常的详尽,非常具有学习价值。 LIO-SAM算法书中也有详细的推导,感兴趣的小伙伴可以自己查阅研究一下。 LiDAR与IMU组合定位的松耦合和紧耦合两种技术路线各有优势,松耦合计算相对简单,但伴随着IMU的累计误差还是会导致算法精度降低;紧耦合方式通过基于因子图优化、IMU预积分等方法实现LiDAR和IMU的紧耦合,进而实现鲁棒、精确的融合定位。  

  • 2024-09-28
  • 回复了主题帖: 《智能驾驶之激光雷达算法详解》3.基于3D激光点云的目标检测

    Jacktang 发表于 2024-9-28 07:48 3D点云的目标检测感觉好难,主要还是算法 是的 数学基础很重要啊

  • 2024-09-27
  • 发表了主题帖: 《智能驾驶之激光雷达算法详解》3.基于3D激光点云的目标检测

    基于激光雷达3D点云的目标检测、多目标跟踪等算法是利用深度学习相关算法进行解决相应问题的,本书的第七章对深度学习进行了基础的讲解,主要是人工神经网络、卷积神经网络、ViT模型等进行了介绍,对于我这种深度学习小白来说,无疑撬开了我对深度学习相关基础的认知,。 激光点云的3D目标检测通常是指在点云中识别车辆、行人等目标,并给出其尺寸、位置和朝向等信息。雷达目标检测的分类方法如下所示: 本书介绍的常用的具有代表性的3D目标检测算法有MLP架构的PointNET网络算法、PointNET++网络算法、PointRCNN网络算法、基于体素的VoxelNet网络算法、PointPillars网络算法、基于深度图的RangeDet网络算法、多视角特征融合的MVF网络算法等。 每种算法有各自的优势和不足,例如: PointRCNN网络是将基于原始点云进行特征提取的方式嵌入二阶段检测架构的一次成功尝试,且该网络模型背后的将车辆位置和朝向问题等效为“分类+回归”问题的思想也被后续许多算法借鉴。但是该网络模型的流程相对比较复杂,在KITTI数据集中,该网络模型对每帧点云进行推理的耗时为0.1秒左右,较难达到实时性要求。 VoxelNet网络结构清晰,且检测性能也有较大提升,然而,由于其引入了3D卷积,VoxelNet 网络模型的推理速度较慢,很难满足智能驾驶感知模块的实时性要求。而PointPillars网络却有较好的实时性和检测性能。 总之,通过对个网络算法的公式、原理推导和图形化说明,让我对这些深度学习网络算法及在3D激光点云的应用有了了解和认识。  

  • 发表了主题帖: 《智能驾驶之激光雷达算法详解》2.外参标定

    本书的第三章、第四章是对标定算法的讲解,第三章着重讲解了激光雷达相对于车体的外参标定算法,将激光雷达外参算法初步分为了三类,①基于道路、标定物特征的雷达动态外参标定。②基于手眼模型的雷达外参标定③基于积累点云特征化的雷达外参标定算法。本章对分别这三个方向选取了比较有代表性的算法分析,如SSAC算法、使用Navy算法求解手眼模型、AESC-MMS算法、DyLESC算法等,让我了解了各算法的原理、概念、流程、公式推导。 第四章是基于激光雷达和相机数据相互融合的外参标定算法的讲解,基于激光雷达数据和相机视觉数据的强互补性进行精确的外参标定,3D雷达和2D相机之间的外参标定分类如下 本章分析的具有代表性的算法分别时基于标定物的L-C静态标定-ILCC算法、无标定物的L-C静态标定-PESC算法、无标定物的L-C动态在线标定-AOCCL算法。总的来说,静态、有标定物的离线标定方法通常可在高精度的标定件中使用;而动态、无标定物的在线标定方法可在自然驾驶场景中使用,并根据离线标定的结果、车辆运动等信息, 实现对离线标定结果的全部参数或部分参数的修正。  

  • 2024-08-30
  • 发表了主题帖: 《智能驾驶之激光雷达算法详解》1.全书质量和目录简要评价

    首先非常荣幸能够参与《智能驾驶之激光雷达算法详解》这本书的阅读体验,收到书后第一感觉是本书的分量很足,本书全书均为彩印纸质,文字与图案印刷得极为精细,墨迹均匀饱满,即便是细小的文字也能清晰可辨,阅读体验极佳。 阅读本书目录可知,前两章是激光雷达的基础介绍和空间变换数学基础,三四章是激光雷达的标定讲解,五六章是3D激光点云分割算法讲解,第七章是关于深度学习算法的基础内容,接下面的几章是关于基于3D激光点云的目标检测、路沿检测、多目标跟踪的算法内容,最后几章是干预激光里程计、激光雷达IMU组合定位、SLAM等算法的讲解。从目录的编排和标题的提炼来看,本书层次结构清晰,每章都围绕本章主题讲解了很多相关算法。 每章末尾都有详细的参考文献,更值得一提的是部分算法直接给出了算法源码地址,我们可以对感兴趣的算法直接进行下载学习,能够大大节省读者查找资料的时间。 激光雷达作为现代感知技术的重要组成部分,其算法的发展不仅推动了自动驾驶、机器人导航、三维重建等多个领域的进步,也为我们理解世界提供了新的视角和工具,希望通过接下来的阅读让我对激光雷达算法在智能驾驶方面的应用中有个充分的学习和了解。

  • 2024-08-15
  • 发表了主题帖: 【瑞萨RA8D1开发板,基于M85内核的图形MCU测评】5.基于LVGL实现PWM占空比,控制电机等

    上次已经完成LVGL9.1的移植,本次实现基于LVGL库的电机PWM调制。 本次实验使用LVGL的slider控件,实现比较简单,基于官方例程的仿真效果如下图所示 关键代码如下 static lv_obj_t * label; static void slider_event_cb(lv_event_t * e) { lv_obj_t * slider = lv_event_get_target(e); /*Refresh the text*/ lv_label_set_text_fmt(label, "%"LV_PRId32, lv_slider_get_value(slider)); lv_obj_align_to(label, slider, LV_ALIGN_OUT_TOP_MID, 0, -15); /*Align top of the slider*/ } /** * Create a slider and write its value on a label. */ void lv_example_get_started_4(void) { /*Create a slider in the center of the display*/ lv_obj_t * slider = lv_slider_create(lv_screen_active()); lv_obj_set_width(slider, 200); /*Set the width*/ lv_obj_center(slider); /*Align to the center of the parent (screen)*/ lv_obj_add_event_cb(slider, slider_event_cb, LV_EVENT_VALUE_CHANGED, NULL); /*Assign an event function*/ /*Create a label above the slider*/ label = lv_label_create(lv_screen_active()); lv_label_set_text(label, "0"); lv_obj_align_to(label, slider, LV_ALIGN_OUT_TOP_MID, 0, -15); /*Align top of the slider*/ }   本次控制的电机为空心杯有刷电机 电机的控制电路原理图为 电机的速度采用进行PWM的调制驱动,PWM的驱动控制和液晶背光控制是一样的,由于手头没有mos管了没法搭建驱动电路,此处采用液晶背光亮度表征电机转速。 在slider_event_cb函数中实现PWM的可调 static void slider_event_cb(lv_event_t * e) { lv_obj_t * slider = lv_event_get_target(e); uint8_t pwm = lv_slider_get_value(slider); /*Refresh the text*/ lv_label_set_text_fmt(label, "%"LV_PRId32, lv_slider_get_value(slider)); lv_obj_align_to(label, slider, LV_ALIGN_OUT_TOP_MID, 0, -15); /*Align top of the slider*/ /* 避免背光不显示*/ if(pwm<20) pwm=20; lcd_set_brightness(pwm); }   效果如下图,滑动实现屏幕亮度或电机速度的调节

  • 2024-08-13
  • 回复了主题帖: 共读入围名单: 《智能驾驶之激光雷达算法详解》

    个人信息无误,确认可以完成评测计划

  • 2024-07-27
  • 发表了主题帖: 【瑞萨RA8D1开发板,基于M85内核的图形MCU测评】4.LVGL移植

    本帖最后由 镜花水月000 于 2024-7-27 10:48 编辑 本次LVGL移植版本为V9.1 下载地址https://github.com/lvgl/lvgl/releases/tag/v9.1.0 首先将LVGL源文件添加到工程中 添加定时器驱动为lvgl提供时基 配置为1ms中断一次 在回调函数中添加lv_tick_inc(1) 在led_thread中初始化定时器 fsp_err_t err; err = R_GPT_Open(&g_timer0_ctrl, &g_timer0_cfg); if (FSP_SUCCESS != err) { __BKPT(0); } err = R_GPT_Start(&g_timer0_ctrl); if (FSP_SUCCESS != err) { __BKPT(0); }   添加lvgl线程 线程内存需要给的大一些 添加lv_port_disp.c,主要是LVGL的图形缓存和屏幕的打点函数 /** * [url=home.php?mod=space&uid=1307177]@File[/url] lv_port_disp_templ.c * */ /*Copy this file as "lv_port_disp.c" and set this value to "1" to enable content*/ #if 1 /********************* * INCLUDES *********************/ #include "lv_port_disp.h" #include <stdbool.h> #include "hal_data.h" #include "bsp_lcd.h" #include "hal_data.h" /********************** * TYPEDEFS **********************/ /********************** * STATIC PROTOTYPES **********************/ static void disp_init(void); static void disp_flush(lv_display_t * disp, const lv_area_t * area, uint8_t * px_map); static lv_color_t buf_3_1[MY_DISP_HOR_RES * MY_DISP_VER_RES] BSP_ALIGN_VARIABLE(64) BSP_PLACE_IN_SECTION(".sdram"); static lv_color_t buf_3_2[MY_DISP_HOR_RES * MY_DISP_VER_RES] BSP_ALIGN_VARIABLE(64) BSP_PLACE_IN_SECTION(".sdram"); //static lv_color_t buf_3_1[MY_DISP_HOR_RES * 10] ; //static lv_color_t buf_3_2[MY_DISP_HOR_RES * 10] ; /********************** * STATIC VARIABLES **********************/ /********************** * MACROS **********************/ static lv_display_t * disp_drv; /********************** * GLOBAL FUNCTIONS **********************/ void lv_port_disp_init(void) { /*------------------------- * Initialize your display * -----------------------*/ disp_init(); /*------------------------------------ * Create a display and set a flush_cb * -----------------------------------*/ disp_drv = lv_display_create(MY_DISP_HOR_RES, MY_DISP_VER_RES); lv_display_set_flush_cb(disp_drv, disp_flush); /* Example 1 * One buffer for partial rendering*/ // static lv_color_t buf_1_1[MY_DISP_HOR_RES * 10]; /*A buffer for 10 rows*/ // lv_display_set_buffers(disp, buf_1_1, NULL, sizeof(buf_1_1), LV_DISPLAY_RENDER_MODE_PARTIAL); /* Example 2 * Two buffers for partial rendering * In flush_cb DMA or similar hardware should be used to update the display in the background.*/ // static lv_color_t buf_2_1[MY_DISP_HOR_RES * 10]; // static lv_color_t buf_2_2[MY_DISP_HOR_RES * 10]; // lv_display_set_buffers(disp, buf_2_1, buf_2_2, sizeof(buf_2_1), LV_DISPLAY_RENDER_MODE_PARTIAL); /* Example 3 * Two buffers screen sized buffer for double buffering. * Both LV_DISPLAY_RENDER_MODE_DIRECT and LV_DISPLAY_RENDER_MODE_FULL works, see their comments*/ lv_display_set_buffers(disp_drv, buf_3_1, buf_3_2, sizeof(buf_3_1), LV_DISPLAY_RENDER_MODE_DIRECT); } /********************** * STATIC FUNCTIONS **********************/ /*Initialize your display and the required peripherals.*/ static void disp_init(void) { /*You code here*/ } volatile bool disp_flush_enabled = true; /* Enable updating the screen (the flushing process) when disp_flush() is called by LVGL */ void disp_enable_update(void) { disp_flush_enabled = true; } /* Disable updating the screen (the flushing process) when disp_flush() is called by LVGL */ void disp_disable_update(void) { disp_flush_enabled = false; } /*Flush the content of the internal buffer the specific area on the display. *`px_map` contains the rendered image as raw pixel map and it should be copied to `area` on the display. *You can use DMA or any hardware acceleration to do this operation in the background but *'lv_display_flush_ready()' has to be called when it's finished.*/ static void disp_flush(lv_display_t * disp_drv, const lv_area_t * area, uint8_t * px_map) { #if defined(RENESAS_CORTEX_M85) #if (BSP_CFG_DCACHE_ENABLED) int32_t size; /* Invalidate cache - so the HW can access any data written by the CPU */ size = sizeof(fb_background[0]); SCB_CleanInvalidateDCache_by_Addr(px_map, size); #endif #endif R_GLCDC_BufferChange(&g_display0_ctrl, (uint8_t *) px_map, (display_frame_layer_t) 0); /*IMPORTANT!!! *Inform the graphics library that you are ready with the flushing*/ lv_display_flush_ready(disp_drv); } #else /*Enable this file at the top*/ /*This dummy typedef exists purely to silence -Wpedantic.*/ typedef int keep_pedantic_happy; #endif   在lv_port_indev.c中添加触摸屏驱动 /** * @file lv_port_indev_templ.c * */ /*Copy this file as "lv_port_indev.c" and set this value to "1" to enable content*/ #if 1 /********************* * INCLUDES *********************/ #include "lv_port_indev.h" #include "bsp_touch.h" /********************* * DEFINES *********************/ /********************** * TYPEDEFS **********************/ /********************** * STATIC PROTOTYPES **********************/ static void touchpad_init(void); static void touchpad_read(lv_indev_t * indev, lv_indev_data_t * data); static bool touchpad_is_pressed(void); static void touchpad_get_xy(int32_t * x, int32_t * y); static void mouse_init(void); static void mouse_read(lv_indev_t * indev, lv_indev_data_t * data); static bool mouse_is_pressed(void); static void mouse_get_xy(int32_t * x, int32_t * y); static void keypad_init(void); static void keypad_read(lv_indev_t * indev, lv_indev_data_t * data); static uint32_t keypad_get_key(void); static void encoder_init(void); static void encoder_read(lv_indev_t * indev, lv_indev_data_t * data); static void encoder_handler(void); static void button_init(void); static void button_read(lv_indev_t * indev, lv_indev_data_t * data); static int8_t button_get_pressed_id(void); static bool button_is_pressed(uint8_t id); /********************** * STATIC VARIABLES **********************/ lv_indev_t * indev_touchpad; lv_indev_t * indev_mouse; lv_indev_t * indev_keypad; lv_indev_t * indev_encoder; lv_indev_t * indev_button; static int32_t encoder_diff; static lv_indev_state_t encoder_state; /********************** * MACROS **********************/ /********************** * GLOBAL FUNCTIONS **********************/ void lv_port_indev_init(void) { /** * Here you will find example implementation of input devices supported by LittelvGL: * - Touchpad * - Mouse (with cursor support) * - Keypad (supports GUI usage only with key) * - Encoder (supports GUI usage only with: left, right, push) * - Button (external buttons to press points on the screen) * * The `..._read()` function are only examples. * You should shape them according to your hardware */ /*------------------ * Touchpad * -----------------*/ /*Initialize your touchpad if you have*/ touchpad_init(); /*Register a touchpad input device*/ indev_touchpad = lv_indev_create(); lv_indev_set_type(indev_touchpad, LV_INDEV_TYPE_POINTER); lv_indev_set_read_cb(indev_touchpad, touchpad_read); // /*------------------ // * Mouse // * -----------------*/ // /*Initialize your mouse if you have*/ // mouse_init(); // /*Register a mouse input device*/ // indev_mouse = lv_indev_create(); // lv_indev_set_type(indev_mouse, LV_INDEV_TYPE_POINTER); // lv_indev_set_read_cb(indev_mouse, mouse_read); // /*Set cursor. For simplicity set a HOME symbol now.*/ // lv_obj_t * mouse_cursor = lv_image_create(lv_screen_active()); // lv_image_set_src(mouse_cursor, LV_SYMBOL_HOME); // lv_indev_set_cursor(indev_mouse, mouse_cursor); // /*------------------ // * Keypad // * -----------------*/ // /*Initialize your keypad or keyboard if you have*/ // keypad_init(); // /*Register a keypad input device*/ // indev_keypad = lv_indev_create(); // lv_indev_set_type(indev_keypad, LV_INDEV_TYPE_KEYPAD); // lv_indev_set_read_cb(indev_keypad, keypad_read); // /*Later you should create group(s) with `lv_group_t * group = lv_group_create()`, // *add objects to the group with `lv_group_add_obj(group, obj)` // *and assign this input device to group to navigate in it: // *`lv_indev_set_group(indev_keypad, group);`*/ // /*------------------ // * Encoder // * -----------------*/ // /*Initialize your encoder if you have*/ // encoder_init(); // /*Register a encoder input device*/ // indev_encoder = lv_indev_create(); // lv_indev_set_type(indev_encoder, LV_INDEV_TYPE_ENCODER); // lv_indev_set_read_cb(indev_touchpad, encoder_read); // /*Later you should create group(s) with `lv_group_t * group = lv_group_create()`, // *add objects to the group with `lv_group_add_obj(group, obj)` // *and assign this input device to group to navigate in it: // *`lv_indev_set_group(indev_encoder, group);`*/ // /*------------------ // * Button // * -----------------*/ // /*Initialize your button if you have*/ // button_init(); // /*Register a button input device*/ // indev_button = lv_indev_create(); // lv_indev_set_type(indev_button, LV_INDEV_TYPE_BUTTON); // lv_indev_set_read_cb(indev_button, button_read); // /*Assign buttons to points on the screen*/ // static const lv_point_t btn_points[2] = { // {10, 10}, /*Button 0 -> x:10; y:10*/ // {40, 100}, /*Button 1 -> x:40; y:100*/ // }; // lv_indev_set_button_points(indev_button, btn_points); } /********************** * STATIC FUNCTIONS **********************/ /*------------------ * Touchpad * -----------------*/ /*Initialize your touchpad*/ static void touchpad_init(void) { /*Your code comes here*/ } /*Will be called by the library to read the touchpad*/ static void touchpad_read(lv_indev_t * indev_drv, lv_indev_data_t * data) { static int32_t last_x = 0; static int32_t last_y = 0; /*Save the pressed coordinates and the state*/ if(touchpad_is_pressed()) { // touchpad_get_xy(&last_x, &last_y); last_x=touchInfo.x[0]; last_y=touchInfo.y[0]; data->state = LV_INDEV_STATE_PR; } else { data->state = LV_INDEV_STATE_REL; } /*Set the last pressed coordinates*/ data->point.x = last_x; data->point.y = last_y; } /*Return true is the touchpad is pressed*/ static bool touchpad_is_pressed(void) { /*Your code comes here*/ /*Your code comes here*/ if(touchInfo.flag == 1) return true; else return false; } /*Get the x and y coordinates if the touchpad is pressed*/ static void touchpad_get_xy(int32_t * x, int32_t * y) { /*Your code comes here*/ (*x) = 0; (*y) = 0; } /*------------------ * Mouse * -----------------*/ /*Initialize your mouse*/ static void mouse_init(void) { /*Your code comes here*/ } /*Will be called by the library to read the mouse*/ static void mouse_read(lv_indev_t * indev_drv, lv_indev_data_t * data) { /*Get the current x and y coordinates*/ mouse_get_xy(&data->point.x, &data->point.y); /*Get whether the mouse button is pressed or released*/ if(mouse_is_pressed()) { data->state = LV_INDEV_STATE_PR; } else { data->state = LV_INDEV_STATE_REL; } } /*Return true is the mouse button is pressed*/ static bool mouse_is_pressed(void) { /*Your code comes here*/ return false; } /*Get the x and y coordinates if the mouse is pressed*/ static void mouse_get_xy(int32_t * x, int32_t * y) { /*Your code comes here*/ (*x) = 0; (*y) = 0; } /*------------------ * Keypad * -----------------*/ /*Initialize your keypad*/ static void keypad_init(void) { /*Your code comes here*/ } /*Will be called by the library to read the mouse*/ static void keypad_read(lv_indev_t * indev_drv, lv_indev_data_t * data) { static uint32_t last_key = 0; /*Get the current x and y coordinates*/ mouse_get_xy(&data->point.x, &data->point.y); /*Get whether the a key is pressed and save the pressed key*/ uint32_t act_key = keypad_get_key(); if(act_key != 0) { data->state = LV_INDEV_STATE_PR; /*Translate the keys to LVGL control characters according to your key definitions*/ switch(act_key) { case 1: act_key = LV_KEY_NEXT; break; case 2: act_key = LV_KEY_PREV; break; case 3: act_key = LV_KEY_LEFT; break; case 4: act_key = LV_KEY_RIGHT; break; case 5: act_key = LV_KEY_ENTER; break; } last_key = act_key; } else { data->state = LV_INDEV_STATE_REL; } data->key = last_key; } /*Get the currently being pressed key. 0 if no key is pressed*/ static uint32_t keypad_get_key(void) { /*Your code comes here*/ return 0; } /*------------------ * Encoder * -----------------*/ /*Initialize your encoder*/ static void encoder_init(void) { /*Your code comes here*/ } /*Will be called by the library to read the encoder*/ static void encoder_read(lv_indev_t * indev_drv, lv_indev_data_t * data) { data->enc_diff = encoder_diff; data->state = encoder_state; } /*Call this function in an interrupt to process encoder events (turn, press)*/ static void encoder_handler(void) { /*Your code comes here*/ encoder_diff += 0; encoder_state = LV_INDEV_STATE_REL; } /*------------------ * Button * -----------------*/ /*Initialize your buttons*/ static void button_init(void) { /*Your code comes here*/ } /*Will be called by the library to read the button*/ static void button_read(lv_indev_t * indev_drv, lv_indev_data_t * data) { static uint8_t last_btn = 0; /*Get the pressed button's ID*/ int8_t btn_act = button_get_pressed_id(); if(btn_act >= 0) { data->state = LV_INDEV_STATE_PR; last_btn = btn_act; } else { data->state = LV_INDEV_STATE_REL; } /*Save the last pressed button's ID*/ data->btn_id = last_btn; } /*Get ID (0, 1, 2 ..) of the pressed button*/ static int8_t button_get_pressed_id(void) { uint8_t i; /*Check to buttons see which is being pressed (assume there are 2 buttons)*/ for(i = 0; i < 2; i++) { /*Return the pressed button's ID*/ if(button_is_pressed(i)) { return i; } } /*No button pressed*/ return -1; } /*Test if `id` button is pressed or not*/ static bool button_is_pressed(uint8_t id) { /*Your code comes here*/ return false; } #else /*Enable this file at the top*/ /*This dummy typedef exists purely to silence -Wpedantic.*/ typedef int keep_pedantic_happy; #endif   添加lv_conf.h配置LVGL /** * @file lv_conf.h * Configuration file for v9.1.0 */ /* * Copy this file as `lv_conf.h` * 1. simply next to the `lvgl` folder * 2. or any other places and * - define `LV_CONF_INCLUDE_SIMPLE` * - add the path as include path */ /* clang-format off */ #if 1 /*Set it to "1" to enable content*/ #ifndef LV_CONF_H #define LV_CONF_H /*If you need to include anything here, do it inside the `__ASSEMBLY__` guard */ #if 0 && defined(__ASSEMBLY__) #include "my_include.h" #endif /*==================== COLOR SETTINGS *====================*/ #define MY_DISP_HOR_RES 800 #define MY_DISP_VER_RES 480 /*Color depth: 8 (A8), 16 (RGB565), 24 (RGB888), 32 (XRGB8888)*/ #define LV_COLOR_DEPTH 16 /*========================= STDLIB WRAPPER SETTINGS *=========================*/ /* Possible values * - LV_STDLIB_BUILTIN: LVGL's built in implementation * - LV_STDLIB_CLIB: Standard C functions, like malloc, strlen, etc * - LV_STDLIB_MICROPYTHON: MicroPython implementation * - LV_STDLIB_RTTHREAD: RT-Thread implementation * - LV_STDLIB_CUSTOM: Implement the functions externally */ #define LV_USE_STDLIB_MALLOC LV_STDLIB_BUILTIN #define LV_USE_STDLIB_STRING LV_STDLIB_BUILTIN #define LV_USE_STDLIB_SPRINTF LV_STDLIB_BUILTIN #if LV_USE_STDLIB_MALLOC == LV_STDLIB_BUILTIN /*Size of the memory available for `lv_malloc()` in bytes (>= 2kB)*/ #define LV_MEM_SIZE (128 * 1024U) /*[bytes]*/ /*Size of the memory expand for `lv_malloc()` in bytes*/ #define LV_MEM_POOL_EXPAND_SIZE 0 /*Set an address for the memory pool instead of allocating it as a normal array. Can be in external SRAM too.*/ #define LV_MEM_ADR 0 /*0: unused*/ /*Instead of an address give a memory allocator that will be called to get a memory pool for LVGL. E.g. my_malloc*/ #if LV_MEM_ADR == 0 #undef LV_MEM_POOL_INCLUDE #undef LV_MEM_POOL_ALLOC #endif #endif /*LV_USE_STDLIB_MALLOC == LV_STDLIB_BUILTIN*/ /*==================== HAL SETTINGS *====================*/ /*Default display refresh, input device read and animation step period.*/ #define LV_DEF_REFR_PERIOD 33 /*[ms]*/ /*Default Dot Per Inch. Used to initialize default sizes such as widgets sized, style paddings. *(Not so important, you can adjust it to modify default sizes and spaces)*/ #define LV_DPI_DEF 130 /*[px/inch]*/ /*customize tick-get */ //#if defined(__PERF_COUNTER__) && __PERF_COUNTER__ // #define LV_GLOBAL_INIT(__GLOBAL_PTR) \ // do { \ // lv_global_init((lv_global_t *)(__GLOBAL_PTR)); \ // extern uint32_t perfc_tick_get(void); \ // (__GLOBAL_PTR)->tick_state.tick_get_cb = perfc_tick_get; \ // } while(0) //#endif /*================= * OPERATING SYSTEM *=================*/ /*Select an operating system to use. Possible options: * - LV_OS_NONE * - LV_OS_PTHREAD * - LV_OS_FREERTOS * - LV_OS_CMSIS_RTOS2 * - LV_OS_RTTHREAD * - LV_OS_WINDOWS * - LV_OS_CUSTOM */ #define LV_USE_OS LV_OS_FREERTOS #if LV_USE_OS == LV_OS_CUSTOM #define LV_OS_CUSTOM_INCLUDE <stdint.h> #endif /*======================== * RENDERING CONFIGURATION *========================*/ /*Align the stride of all layers and images to this bytes*/ #define LV_DRAW_BUF_STRIDE_ALIGN 1 /*Align the start address of draw_buf addresses to this bytes*/ #define LV_DRAW_BUF_ALIGN 4 /* If a widget has `style_opa < 255` (not `bg_opa`, `text_opa` etc) or not NORMAL blend mode * it is buffered into a "simple" layer before rendering. The widget can be buffered in smaller chunks. * "Transformed layers" (if `transform_angle/zoom` are set) use larger buffers * and can't be drawn in chunks. */ /*The target buffer size for simple layer chunks.*/ #define LV_DRAW_LAYER_SIMPLE_BUF_SIZE (24 * 1024) /*[bytes]*/ #define LV_USE_DRAW_SW 1 #if LV_USE_DRAW_SW == 1 /* Set the number of draw unit. * > 1 requires an operating system enabled in `LV_USE_OS` * > 1 means multiply threads will render the screen in parallel */ #define LV_DRAW_SW_DRAW_UNIT_CNT 1 /* Use Arm-2D to accelerate the sw render */ #define LV_USE_DRAW_ARM2D_SYNC 1 /* Enable native helium assembly to be compiled */ #define LV_USE_NATIVE_HELIUM_ASM 0 /* 0: use a simple renderer capable of drawing only simple rectangles with gradient, images, texts, and straight lines only * 1: use a complex renderer capable of drawing rounded corners, shadow, skew lines, and arcs too */ #define LV_DRAW_SW_COMPLEX 1 #if LV_DRAW_SW_COMPLEX == 1 /*Allow buffering some shadow calculation. *LV_DRAW_SW_SHADOW_CACHE_SIZE is the max. shadow size to buffer, where shadow size is `shadow_width + radius` *Caching has LV_DRAW_SW_SHADOW_CACHE_SIZE^2 RAM cost*/ #define LV_DRAW_SW_SHADOW_CACHE_SIZE 0 /* Set number of maximally cached circle data. * The circumference of 1/4 circle are saved for anti-aliasing * radius * 4 bytes are used per circle (the most often used radiuses are saved) * 0: to disable caching */ #define LV_DRAW_SW_CIRCLE_CACHE_SIZE 4 #endif #define LV_USE_DRAW_SW_ASM LV_DRAW_SW_ASM_NONE #if LV_USE_DRAW_SW_ASM == LV_DRAW_SW_ASM_CUSTOM #define LV_DRAW_SW_ASM_CUSTOM_INCLUDE "" #endif #endif /* Use NXP's VG-Lite GPU on iMX RTxxx platforms. */ #define LV_USE_DRAW_VGLITE 0 #if LV_USE_DRAW_VGLITE /* Enable blit quality degradation workaround recommended for screen's dimension > 352 pixels. */ #define LV_USE_VGLITE_BLIT_SPLIT 0 #if LV_USE_OS /* Enable VGLite draw async. Queue multiple tasks and flash them once to the GPU. */ #define LV_USE_VGLITE_DRAW_ASYNC 1 #endif /* Enable VGLite asserts. */ #define LV_USE_VGLITE_ASSERT 0 #endif /* Use NXP's PXP on iMX RTxxx platforms. */ #define LV_USE_DRAW_PXP 0 #if LV_USE_DRAW_PXP /* Enable PXP asserts. */ #define LV_USE_PXP_ASSERT 0 #endif /* Use Renesas Dave2D on RA platforms. */ #define LV_USE_DRAW_DAVE2D 0 /* Draw using cached SDL textures*/ #define LV_USE_DRAW_SDL 0 /* Use VG-Lite GPU. */ #define LV_USE_DRAW_VG_LITE 0 #if LV_USE_DRAW_VG_LITE /* Enable VG-Lite custom external 'gpu_init()' function */ #define LV_VG_LITE_USE_GPU_INIT 0 /* Enable VG-Lite assert. */ #define LV_VG_LITE_USE_ASSERT 0 /* VG-Lite flush commit trigger threshold. GPU will try to batch these many draw tasks. */ #define LV_VG_LITE_FLUSH_MAX_COUNT 8 /* Enable border to simulate shadow * NOTE: which usually improves performance, * but does not guarantee the same rendering quality as the software. */ #define LV_VG_LITE_USE_BOX_SHADOW 0 /* VG-Lite gradient image maximum cache number. * NOTE: The memory usage of a single gradient image is 4K bytes. */ #define LV_VG_LITE_GRAD_CACHE_SIZE 32 #endif /*======================= * FEATURE CONFIGURATION *=======================*/ /*------------- * Logging *-----------*/ /*Enable the log module*/ #define LV_USE_LOG 0 #if LV_USE_LOG /*How important log should be added: *LV_LOG_LEVEL_TRACE A lot of logs to give detailed information *LV_LOG_LEVEL_INFO Log important events *LV_LOG_LEVEL_WARN Log if something unwanted happened but didn't cause a problem *LV_LOG_LEVEL_ERROR Only critical issue, when the system may fail *LV_LOG_LEVEL_USER Only logs added by the user *LV_LOG_LEVEL_NONE Do not log anything*/ #define LV_LOG_LEVEL LV_LOG_LEVEL_WARN /*1: Print the log with 'printf'; *0: User need to register a callback with `lv_log_register_print_cb()`*/ #define LV_LOG_PRINTF 1 /*1: Enable print timestamp; *0: Disable print timestamp*/ #define LV_LOG_USE_TIMESTAMP 1 /*1: Print file and line number of the log; *0: Do not print file and line number of the log*/ #define LV_LOG_USE_FILE_LINE 1 /*Enable/disable LV_LOG_TRACE in modules that produces a huge number of logs*/ #define LV_LOG_TRACE_MEM 1 #define LV_LOG_TRACE_TIMER 1 #define LV_LOG_TRACE_INDEV 1 #define LV_LOG_TRACE_DISP_REFR 1 #define LV_LOG_TRACE_EVENT 1 #define LV_LOG_TRACE_OBJ_CREATE 1 #define LV_LOG_TRACE_LAYOUT 1 #define LV_LOG_TRACE_ANIM 1 #define LV_LOG_TRACE_CACHE 1 #endif /*LV_USE_LOG*/ /*------------- * Asserts *-----------*/ /*Enable asserts if an operation is failed or an invalid data is found. *If LV_USE_LOG is enabled an error message will be printed on failure*/ #define LV_USE_ASSERT_NULL 1 /*Check if the parameter is NULL. (Very fast, recommended)*/ #define LV_USE_ASSERT_MALLOC 1 /*Checks is the memory is successfully allocated or no. (Very fast, recommended)*/ #define LV_USE_ASSERT_STYLE 0 /*Check if the styles are properly initialized. (Very fast, recommended)*/ #define LV_USE_ASSERT_MEM_INTEGRITY 0 /*Check the integrity of `lv_mem` after critical operations. (Slow)*/ #define LV_USE_ASSERT_OBJ 0 /*Check the object's type and existence (e.g. not deleted). (Slow)*/ /*Add a custom handler when assert happens e.g. to restart the MCU*/ #define LV_ASSERT_HANDLER_INCLUDE <stdint.h> #define LV_ASSERT_HANDLER while(1); /*Halt by default*/ /*------------- * Debug *-----------*/ /*1: Draw random colored rectangles over the redrawn areas*/ #define LV_USE_REFR_DEBUG 0 /*1: Draw a red overlay for ARGB layers and a green overlay for RGB layers*/ #define LV_USE_LAYER_DEBUG 0 /*1: Draw overlays with different colors for each draw_unit's tasks. *Also add the index number of the draw unit on white background. *For layers add the index number of the draw unit on black background.*/ #define LV_USE_PARALLEL_DRAW_DEBUG 0 /*------------- * Others *-----------*/ #define LV_ENABLE_GLOBAL_CUSTOM 0 #if LV_ENABLE_GLOBAL_CUSTOM /*Header to include for the custom 'lv_global' function"*/ #define LV_GLOBAL_CUSTOM_INCLUDE <stdint.h> #endif /*Default cache size in bytes. *Used by image decoders such as `lv_lodepng` to keep the decoded image in the memory. *If size is not set to 0, the decoder will fail to decode when the cache is full. *If size is 0, the cache function is not enabled and the decoded mem will be released immediately after use.*/ #define LV_CACHE_DEF_SIZE 0 /*Default number of image header cache entries. The cache is used to store the headers of images *The main logic is like `LV_CACHE_DEF_SIZE` but for image headers.*/ #define LV_IMAGE_HEADER_CACHE_DEF_CNT 0 /*Number of stops allowed per gradient. Increase this to allow more stops. *This adds (sizeof(lv_color_t) + 1) bytes per additional stop*/ #define LV_GRADIENT_MAX_STOPS 2 /* Adjust color mix functions rounding. GPUs might calculate color mix (blending) differently. * 0: round down, 64: round up from x.75, 128: round up from half, 192: round up from x.25, 254: round up */ #define LV_COLOR_MIX_ROUND_OFS 0 /* Add 2 x 32 bit variables to each lv_obj_t to speed up getting style properties */ #define LV_OBJ_STYLE_CACHE 0 /* Add `id` field to `lv_obj_t` */ #define LV_USE_OBJ_ID 0 /* Use lvgl builtin method for obj ID */ #define LV_USE_OBJ_ID_BUILTIN 0 /*Use obj property set/get API*/ #define LV_USE_OBJ_PROPERTY 0 /* VG-Lite Simulator */ /*Requires: LV_USE_THORVG_INTERNAL or LV_USE_THORVG_EXTERNAL */ #define LV_USE_VG_LITE_THORVG 0 #if LV_USE_VG_LITE_THORVG /*Enable LVGL's blend mode support*/ #define LV_VG_LITE_THORVG_LVGL_BLEND_SUPPORT 0 /*Enable YUV color format support*/ #define LV_VG_LITE_THORVG_YUV_SUPPORT 0 /*Enable 16 pixels alignment*/ #define LV_VG_LITE_THORVG_16PIXELS_ALIGN 1 /*Buffer address alignment*/ #define LV_VG_LITE_THORVG_BUF_ADDR_ALIGN 64 /*Enable multi-thread render*/ #define LV_VG_LITE_THORVG_THREAD_RENDER 0 #endif /*===================== * COMPILER SETTINGS *====================*/ /*For big endian systems set to 1*/ #define LV_BIG_ENDIAN_SYSTEM 0 /*Define a custom attribute to `lv_tick_inc` function*/ #define LV_ATTRIBUTE_TICK_INC /*Define a custom attribute to `lv_timer_handler` function*/ #define LV_ATTRIBUTE_TIMER_HANDLER /*Define a custom attribute to `lv_display_flush_ready` function*/ #define LV_ATTRIBUTE_FLUSH_READY /*Required alignment size for buffers*/ #define LV_ATTRIBUTE_MEM_ALIGN_SIZE 4 /*Will be added where memories needs to be aligned (with -Os data might not be aligned to boundary by default). * E.g. __attribute__((aligned(4)))*/ #define LV_ATTRIBUTE_MEM_ALIGN __attribute__((aligned(4))) /*Attribute to mark large constant arrays for example font's bitmaps*/ #define LV_ATTRIBUTE_LARGE_CONST /*Compiler prefix for a big array declaration in RAM*/ #define LV_ATTRIBUTE_LARGE_RAM_ARRAY /*Place performance critical functions into a faster memory (e.g RAM)*/ #define LV_ATTRIBUTE_FAST_MEM /*Export integer constant to binding. This macro is used with constants in the form of LV_<CONST> that *should also appear on LVGL binding API such as Micropython.*/ #define LV_EXPORT_CONST_INT(int_value) struct _silence_gcc_warning /*The default value just prevents GCC warning*/ /*Prefix all global extern data with this*/ #define LV_ATTRIBUTE_EXTERN_DATA /* Use `float` as `lv_value_precise_t` */ #define LV_USE_FLOAT 0 /*================== * FONT USAGE *===================*/ /*Montserrat fonts with ASCII range and some symbols using bpp = 4 *https://fonts.google.com/specimen/Montserrat*/ #define LV_FONT_MONTSERRAT_8 0 #define LV_FONT_MONTSERRAT_10 0 #define LV_FONT_MONTSERRAT_12 0 #define LV_FONT_MONTSERRAT_14 1 #define LV_FONT_MONTSERRAT_16 1 #define LV_FONT_MONTSERRAT_18 0 #define LV_FONT_MONTSERRAT_20 0 #define LV_FONT_MONTSERRAT_22 0 #define LV_FONT_MONTSERRAT_24 1 #define LV_FONT_MONTSERRAT_26 0 #define LV_FONT_MONTSERRAT_28 0 #define LV_FONT_MONTSERRAT_30 0 #define LV_FONT_MONTSERRAT_32 0 #define LV_FONT_MONTSERRAT_34 0 #define LV_FONT_MONTSERRAT_36 0 #define LV_FONT_MONTSERRAT_38 0 #define LV_FONT_MONTSERRAT_40 0 #define LV_FONT_MONTSERRAT_42 0 #define LV_FONT_MONTSERRAT_44 0 #define LV_FONT_MONTSERRAT_46 0 #define LV_FONT_MONTSERRAT_48 0 /*Demonstrate special features*/ #define LV_FONT_MONTSERRAT_28_COMPRESSED 3 /*bpp = 3*/ #define LV_FONT_DEJAVU_16_PERSIAN_HEBREW 0 /*Hebrew, Arabic, Persian letters and all their forms*/ #define LV_FONT_SIMSUN_16_CJK 0 /*1000 most common CJK radicals*/ /*Pixel perfect monospace fonts*/ #define LV_FONT_UNSCII_8 0 #define LV_FONT_UNSCII_16 0 /*Optionally declare custom fonts here. *You can use these fonts as default font too and they will be available globally. *E.g. #define LV_FONT_CUSTOM_DECLARE LV_FONT_DECLARE(my_font_1) LV_FONT_DECLARE(my_font_2)*/ #define LV_FONT_CUSTOM_DECLARE /*Always set a default font*/ #define LV_FONT_DEFAULT &lv_font_montserrat_16 /*Enable handling large font and/or fonts with a lot of characters. *The limit depends on the font size, font face and bpp. *Compiler error will be triggered if a font needs it.*/ #define LV_FONT_FMT_TXT_LARGE 0 /*Enables/disables support for compressed fonts.*/ #define LV_USE_FONT_COMPRESSED 0 /*Enable drawing placeholders when glyph dsc is not found*/ #define LV_USE_FONT_PLACEHOLDER 1 /*================= * TEXT SETTINGS *=================*/ /** * Select a character encoding for strings. * Your IDE or editor should have the same character encoding * - LV_TXT_ENC_UTF8 * - LV_TXT_ENC_ASCII */ #define LV_TXT_ENC LV_TXT_ENC_UTF8 /*Can break (wrap) texts on these chars*/ #define LV_TXT_BREAK_CHARS " ,.;:-_)]}" /*If a word is at least this long, will break wherever "prettiest" *To disable, set to a value <= 0*/ #define LV_TXT_LINE_BREAK_LONG_LEN 0 /*Minimum number of characters in a long word to put on a line before a break. *Depends on LV_TXT_LINE_BREAK_LONG_LEN.*/ #define LV_TXT_LINE_BREAK_LONG_PRE_MIN_LEN 3 /*Minimum number of characters in a long word to put on a line after a break. *Depends on LV_TXT_LINE_BREAK_LONG_LEN.*/ #define LV_TXT_LINE_BREAK_LONG_POST_MIN_LEN 3 /*Support bidirectional texts. Allows mixing Left-to-Right and Right-to-Left texts. *The direction will be processed according to the Unicode Bidirectional Algorithm: *https://www.w3.org/International/articles/inline-bidi-markup/uba-basics*/ #define LV_USE_BIDI 0 #if LV_USE_BIDI /*Set the default direction. Supported values: *`LV_BASE_DIR_LTR` Left-to-Right *`LV_BASE_DIR_RTL` Right-to-Left *`LV_BASE_DIR_AUTO` detect texts base direction*/ #define LV_BIDI_BASE_DIR_DEF LV_BASE_DIR_AUTO #endif /*Enable Arabic/Persian processing *In these languages characters should be replaced with an other form based on their position in the text*/ #define LV_USE_ARABIC_PERSIAN_CHARS 0 /*================== * WIDGETS *================*/ /*Documentation of the widgets: https://docs.lvgl.io/latest/en/html/widgets/index.html*/ #define LV_WIDGETS_HAS_DEFAULT_VALUE 1 #define LV_USE_ANIMIMG 1 #define LV_USE_ARC 1 #define LV_USE_BAR 1 #define LV_USE_BUTTON 1 #define LV_USE_BUTTONMATRIX 1 #define LV_USE_CALENDAR 1 #if LV_USE_CALENDAR #define LV_CALENDAR_WEEK_STARTS_MONDAY 0 #if LV_CALENDAR_WEEK_STARTS_MONDAY #define LV_CALENDAR_DEFAULT_DAY_NAMES {"Mo", "Tu", "We", "Th", "Fr", "Sa", "Su"} #else #define LV_CALENDAR_DEFAULT_DAY_NAMES {"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"} #endif #define LV_CALENDAR_DEFAULT_MONTH_NAMES {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"} #define LV_USE_CALENDAR_HEADER_ARROW 1 #define LV_USE_CALENDAR_HEADER_DROPDOWN 1 #endif /*LV_USE_CALENDAR*/ #define LV_USE_CANVAS 1 #define LV_USE_CHART 1 #define LV_USE_CHECKBOX 1 #define LV_USE_DROPDOWN 1 /*Requires: lv_label*/ #define LV_USE_IMAGE 1 /*Requires: lv_label*/ #define LV_USE_IMAGEBUTTON 1 #define LV_USE_KEYBOARD 1 #define LV_USE_LABEL 1 #if LV_USE_LABEL #define LV_LABEL_TEXT_SELECTION 1 /*Enable selecting text of the label*/ #define LV_LABEL_LONG_TXT_HINT 1 /*Store some extra info in labels to speed up drawing of very long texts*/ #define LV_LABEL_WAIT_CHAR_COUNT 3 /*The count of wait chart*/ #endif #define LV_USE_LED 1 #define LV_USE_LINE 1 #define LV_USE_LIST 1 #define LV_USE_MENU 1 #define LV_USE_MSGBOX 1 #define LV_USE_ROLLER 1 /*Requires: lv_label*/ #define LV_USE_SCALE 1 #define LV_USE_SLIDER 1 /*Requires: lv_bar*/ #define LV_USE_SPAN 1 #if LV_USE_SPAN /*A line text can contain maximum num of span descriptor */ #define LV_SPAN_SNIPPET_STACK_SIZE 64 #endif #define LV_USE_SPINBOX 1 #define LV_USE_SPINNER 1 #define LV_USE_SWITCH 1 #define LV_USE_TEXTAREA 1 /*Requires: lv_label*/ #if LV_USE_TEXTAREA != 0 #define LV_TEXTAREA_DEF_PWD_SHOW_TIME 1500 /*ms*/ #endif #define LV_USE_TABLE 1 #define LV_USE_TABVIEW 1 #define LV_USE_TILEVIEW 1 #define LV_USE_WIN 1 /*================== * THEMES *==================*/ /*A simple, impressive and very complete theme*/ #define LV_USE_THEME_DEFAULT 1 #if LV_USE_THEME_DEFAULT /*0: Light mode; 1: Dark mode*/ #define LV_THEME_DEFAULT_DARK 0 /*1: Enable grow on press*/ #define LV_THEME_DEFAULT_GROW 1 /*Default transition time in [ms]*/ #define LV_THEME_DEFAULT_TRANSITION_TIME 80 #endif /*LV_USE_THEME_DEFAULT*/ /*A very simple theme that is a good starting point for a custom theme*/ #define LV_USE_THEME_SIMPLE 1 /*A theme designed for monochrome displays*/ #define LV_USE_THEME_MONO 1 /*================== * LAYOUTS *==================*/ /*A layout similar to Flexbox in CSS.*/ #define LV_USE_FLEX 1 /*A layout similar to Grid in CSS.*/ #define LV_USE_GRID 1 /*==================== * 3RD PARTS LIBRARIES *====================*/ /*File system interfaces for common APIs */ /*API for fopen, fread, etc*/ #define LV_USE_FS_STDIO 0 #if LV_USE_FS_STDIO #define LV_FS_STDIO_LETTER '\0' /*Set an upper cased letter on which the drive will accessible (e.g. 'A')*/ #define LV_FS_STDIO_PATH "" /*Set the working directory. File/directory paths will be appended to it.*/ #define LV_FS_STDIO_CACHE_SIZE 0 /*>0 to cache this number of bytes in lv_fs_read()*/ #endif /*API for open, read, etc*/ #define LV_USE_FS_POSIX 0 #if LV_USE_FS_POSIX #define LV_FS_POSIX_LETTER '\0' /*Set an upper cased letter on which the drive will accessible (e.g. 'A')*/ #define LV_FS_POSIX_PATH "" /*Set the working directory. File/directory paths will be appended to it.*/ #define LV_FS_POSIX_CACHE_SIZE 0 /*>0 to cache this number of bytes in lv_fs_read()*/ #endif /*API for CreateFile, ReadFile, etc*/ #define LV_USE_FS_WIN32 0 #if LV_USE_FS_WIN32 #define LV_FS_WIN32_LETTER '\0' /*Set an upper cased letter on which the drive will accessible (e.g. 'A')*/ #define LV_FS_WIN32_PATH "" /*Set the working directory. File/directory paths will be appended to it.*/ #define LV_FS_WIN32_CACHE_SIZE 0 /*>0 to cache this number of bytes in lv_fs_read()*/ #endif /*API for FATFS (needs to be added separately). Uses f_open, f_read, etc*/ #define LV_USE_FS_FATFS 0 #if LV_USE_FS_FATFS #define LV_FS_FATFS_LETTER '\0' /*Set an upper cased letter on which the drive will accessible (e.g. 'A')*/ #define LV_FS_FATFS_CACHE_SIZE 0 /*>0 to cache this number of bytes in lv_fs_read()*/ #endif /*API for memory-mapped file access. */ #define LV_USE_FS_MEMFS 0 #if LV_USE_FS_MEMFS #define LV_FS_MEMFS_LETTER '\0' /*Set an upper cased letter on which the drive will accessible (e.g. 'A')*/ #endif /*API for LittleFs. */ #define LV_USE_FS_LITTLEFS 0 #if LV_USE_FS_LITTLEFS #define LV_FS_LITTLEFS_LETTER '\0' /*Set an upper cased letter on which the drive will accessible (e.g. 'A')*/ #endif /*LODEPNG decoder library*/ #define LV_USE_LODEPNG 0 /*PNG decoder(libpng) library*/ #define LV_USE_LIBPNG 0 /*BMP decoder library*/ #define LV_USE_BMP 0 /* JPG + split JPG decoder library. * Split JPG is a custom format optimized for embedded systems. */ #define LV_USE_TJPGD 0 /* libjpeg-turbo decoder library. * Supports complete JPEG specifications and high-performance JPEG decoding. */ #define LV_USE_LIBJPEG_TURBO 0 /*GIF decoder library*/ #define LV_USE_GIF 0 #if LV_USE_GIF /*GIF decoder accelerate*/ #define LV_GIF_CACHE_DECODE_DATA 0 #endif /*Decode bin images to RAM*/ #define LV_BIN_DECODER_RAM_LOAD 0 /*RLE decompress library*/ #define LV_USE_RLE 0 /*QR code library*/ #define LV_USE_QRCODE 0 /*Barcode code library*/ #define LV_USE_BARCODE 0 /*FreeType library*/ #define LV_USE_FREETYPE 0 #if LV_USE_FREETYPE /*Let FreeType to use LVGL memory and file porting*/ #define LV_FREETYPE_USE_LVGL_PORT 0 /*Cache count of the glyphs in FreeType. It means the number of glyphs that can be cached. *The higher the value, the more memory will be used.*/ #define LV_FREETYPE_CACHE_FT_GLYPH_CNT 256 #endif /* Built-in TTF decoder */ #define LV_USE_TINY_TTF 0 #if LV_USE_TINY_TTF /* Enable loading TTF data from files */ #define LV_TINY_TTF_FILE_SUPPORT 0 #endif /*Rlottie library*/ #define LV_USE_RLOTTIE 0 /*Enable Vector Graphic APIs*/ #define LV_USE_VECTOR_GRAPHIC 0 /* Enable ThorVG (vector graphics library) from the src/libs folder */ #define LV_USE_THORVG_INTERNAL 0 /* Enable ThorVG by assuming that its installed and linked to the project */ #define LV_USE_THORVG_EXTERNAL 0 /*Use lvgl built-in LZ4 lib*/ #define LV_USE_LZ4_INTERNAL 0 /*Use external LZ4 library*/ #define LV_USE_LZ4_EXTERNAL 0 /*FFmpeg library for image decoding and playing videos *Supports all major image formats so do not enable other image decoder with it*/ #define LV_USE_FFMPEG 0 #if LV_USE_FFMPEG /*Dump input information to stderr*/ #define LV_FFMPEG_DUMP_FORMAT 0 #endif /*================== * OTHERS *==================*/ /*1: Enable API to take snapshot for object*/ #define LV_USE_SNAPSHOT 1 /*1: Enable system monitor component*/ #define LV_USE_SYSMON 1 #if LV_USE_SYSMON /*Get the idle percentage. E.g. uint32_t my_get_idle(void);*/ #define LV_SYSMON_GET_IDLE lv_timer_get_idle /*1: Show CPU usage and FPS count * Requires `LV_USE_SYSMON = 1`*/ #define LV_USE_PERF_MONITOR 1 #if LV_USE_PERF_MONITOR #define LV_USE_PERF_MONITOR_POS LV_ALIGN_BOTTOM_RIGHT /*0: Displays performance data on the screen, 1: Prints performance data using log.*/ #define LV_USE_PERF_MONITOR_LOG_MODE 0 #endif /*1: Show the used memory and the memory fragmentation * Requires `LV_USE_STDLIB_MALLOC = LV_STDLIB_BUILTIN` * Requires `LV_USE_SYSMON = 1`*/ #define LV_USE_MEM_MONITOR 1 #if LV_USE_MEM_MONITOR #define LV_USE_MEM_MONITOR_POS LV_ALIGN_BOTTOM_LEFT #endif #endif /*LV_USE_SYSMON*/ /*1: Enable the runtime performance profiler*/ #define LV_USE_PROFILER 0 #if LV_USE_PROFILER /*1: Enable the built-in profiler*/ #define LV_USE_PROFILER_BUILTIN 1 #if LV_USE_PROFILER_BUILTIN /*Default profiler trace buffer size*/ #define LV_PROFILER_BUILTIN_BUF_SIZE (16 * 1024) /*[bytes]*/ #endif /*Header to include for the profiler*/ #define LV_PROFILER_INCLUDE "lvgl/src/misc/lv_profiler_builtin.h" /*Profiler start point function*/ #define LV_PROFILER_BEGIN LV_PROFILER_BUILTIN_BEGIN /*Profiler end point function*/ #define LV_PROFILER_END LV_PROFILER_BUILTIN_END /*Profiler start point function with custom tag*/ #define LV_PROFILER_BEGIN_TAG LV_PROFILER_BUILTIN_BEGIN_TAG /*Profiler end point function with custom tag*/ #define LV_PROFILER_END_TAG LV_PROFILER_BUILTIN_END_TAG #endif /*1: Enable Monkey test*/ #define LV_USE_MONKEY 0 /*1: Enable grid navigation*/ #define LV_USE_GRIDNAV 0 /*1: Enable lv_obj fragment*/ #define LV_USE_FRAGMENT 0 /*1: Support using images as font in label or span widgets */ #define LV_USE_IMGFONT 0 /*1: Enable an observer pattern implementation*/ #define LV_USE_OBSERVER 1 /*1: Enable Pinyin input method*/ /*Requires: lv_keyboard*/ #define LV_USE_IME_PINYIN 0 #if LV_USE_IME_PINYIN /*1: Use default thesaurus*/ /*If you do not use the default thesaurus, be sure to use `lv_ime_pinyin` after setting the thesauruss*/ #define LV_IME_PINYIN_USE_DEFAULT_DICT 1 /*Set the maximum number of candidate panels that can be displayed*/ /*This needs to be adjusted according to the size of the screen*/ #define LV_IME_PINYIN_CAND_TEXT_NUM 6 /*Use 9 key input(k9)*/ #define LV_IME_PINYIN_USE_K9_MODE 1 #if LV_IME_PINYIN_USE_K9_MODE == 1 #define LV_IME_PINYIN_K9_CAND_TEXT_NUM 3 #endif /*LV_IME_PINYIN_USE_K9_MODE*/ #endif /*1: Enable file explorer*/ /*Requires: lv_table*/ #define LV_USE_FILE_EXPLORER 0 #if LV_USE_FILE_EXPLORER /*Maximum length of path*/ #define LV_FILE_EXPLORER_PATH_MAX_LEN (128) /*Quick access bar, 1:use, 0:not use*/ /*Requires: lv_list*/ #define LV_FILE_EXPLORER_QUICK_ACCESS 1 #endif /*================== * DEVICES *==================*/ /*Use SDL to open window on PC and handle mouse and keyboard*/ #define LV_USE_SDL 0 #if LV_USE_SDL #define LV_SDL_INCLUDE_PATH <SDL2/SDL.h> #define LV_SDL_RENDER_MODE LV_DISPLAY_RENDER_MODE_DIRECT /*LV_DISPLAY_RENDER_MODE_DIRECT is recommended for best performance*/ #define LV_SDL_BUF_COUNT 1 /*1 or 2*/ #define LV_SDL_FULLSCREEN 0 /*1: Make the window full screen by default*/ #define LV_SDL_DIRECT_EXIT 1 /*1: Exit the application when all SDL windows are closed*/ #define LV_SDL_MOUSEWHEEL_MODE LV_SDL_MOUSEWHEEL_MODE_ENCODER /*LV_SDL_MOUSEWHEEL_MODE_ENCODER/CROWN*/ #endif /*Use X11 to open window on Linux desktop and handle mouse and keyboard*/ #define LV_USE_X11 0 #if LV_USE_X11 #define LV_X11_DIRECT_EXIT 1 /*Exit the application when all X11 windows have been closed*/ #define LV_X11_DOUBLE_BUFFER 1 /*Use double buffers for endering*/ /*select only 1 of the following render modes (LV_X11_RENDER_MODE_PARTIAL preferred!)*/ #define LV_X11_RENDER_MODE_PARTIAL 1 /*Partial render mode (preferred)*/ #define LV_X11_RENDER_MODE_DIRECT 0 /*direct render mode*/ #define LV_X11_RENDER_MODE_FULL 0 /*Full render mode*/ #endif /*Driver for /dev/fb*/ #define LV_USE_LINUX_FBDEV 0 #if LV_USE_LINUX_FBDEV #define LV_LINUX_FBDEV_BSD 0 #define LV_LINUX_FBDEV_RENDER_MODE LV_DISPLAY_RENDER_MODE_PARTIAL #define LV_LINUX_FBDEV_BUFFER_COUNT 0 #define LV_LINUX_FBDEV_BUFFER_SIZE 60 #endif /*Use Nuttx to open window and handle touchscreen*/ #define LV_USE_NUTTX 0 #if LV_USE_NUTTX #define LV_USE_NUTTX_LIBUV 0 /*Use Nuttx custom init API to open window and handle touchscreen*/ #define LV_USE_NUTTX_CUSTOM_INIT 0 /*Driver for /dev/lcd*/ #define LV_USE_NUTTX_LCD 0 #if LV_USE_NUTTX_LCD #define LV_NUTTX_LCD_BUFFER_COUNT 0 #define LV_NUTTX_LCD_BUFFER_SIZE 60 #endif /*Driver for /dev/input*/ #define LV_USE_NUTTX_TOUCHSCREEN 0 #endif /*Driver for /dev/dri/card*/ #define LV_USE_LINUX_DRM 0 /*Interface for TFT_eSPI*/ #define LV_USE_TFT_ESPI 0 /*Driver for evdev input devices*/ #define LV_USE_EVDEV 0 /*Driver for libinput input devices*/ #define LV_USE_LIBINPUT 0 #if LV_USE_LIBINPUT #define LV_LIBINPUT_BSD 0 /*Full keyboard support*/ #define LV_LIBINPUT_XKB 0 #if LV_LIBINPUT_XKB /*"setxkbmap -query" can help find the right values for your keyboard*/ #define LV_LIBINPUT_XKB_KEY_MAP { .rules = NULL, .model = "pc101", .layout = "us", .variant = NULL, .options = NULL } #endif #endif /*Drivers for LCD devices connected via SPI/parallel port*/ #define LV_USE_ST77350 #define LV_USE_ST77890 #define LV_USE_ST77960 #define LV_USE_ILI93410 #define LV_USE_GENERIC_MIPI (LV_USE_ST7735 | LV_USE_ST7789 | LV_USE_ST7796 | LV_USE_ILI9341) /* LVGL Windows backend */ #define LV_USE_WINDOWS 0 /*================== * EXAMPLES *==================*/ /*Enable the examples to be built with the library*/ #define LV_BUILD_EXAMPLES 1 /*=================== * DEMO USAGE ====================*/ /*Show some widget. It might be required to increase `LV_MEM_SIZE` */ #define LV_USE_DEMO_WIDGETS 1 /*Demonstrate the usage of encoder and keyboard*/ #define LV_USE_DEMO_KEYPAD_AND_ENCODER 0 /*Benchmark your system*/ #define LV_USE_DEMO_BENCHMARK 1 /*Render test for each primitives. Requires at least 480x272 display*/ #define LV_USE_DEMO_RENDER 0 /*Stress test for LVGL*/ #define LV_USE_DEMO_STRESS 0 /*Music player demo*/ #define LV_USE_DEMO_MUSIC 0 #if LV_USE_DEMO_MUSIC #define LV_DEMO_MUSIC_SQUARE 0 #define LV_DEMO_MUSIC_LANDSCAPE 0 #define LV_DEMO_MUSIC_ROUND 0 #define LV_DEMO_MUSIC_LARGE 0 #define LV_DEMO_MUSIC_AUTO_PLAY 0 #endif /*Flex layout demo*/ #define LV_USE_DEMO_FLEX_LAYOUT 0 /*Smart-phone like multi-language demo*/ #define LV_USE_DEMO_MULTILANG 0 /*Widget transformation demo*/ #define LV_USE_DEMO_TRANSFORM 0 /*Demonstrate scroll settings*/ #define LV_USE_DEMO_SCROLL 0 /*Vector graphic demo*/ #define LV_USE_DEMO_VECTOR_GRAPHIC 0 /*--END OF LV_CONF_H--*/ #endif /*LV_CONF_H*/ #endif /*End of "Content enable"*/ /*==================== COLOR SETTINGS *====================*/   添加lvgl的文件路径 添加LVGL的benchmark demo 接下来编写lvgl_thread /* lvgl_thread entry function */ /* pvParameters contains TaskHandle_t */ void lvgl_thread_entry(void* pvParameters) { FSP_PARAMETER_NOT_USED(pvParameters); lv_init(); lv_port_disp_init(); lv_port_indev_init(); lv_demo_benchmark(); /* TODO: add your own code here */ while(1) { lv_task_handler(); // lv_obj_invalidate(lv_screen_active()); vTaskDelay(10); } }   下载运行,由于代码没有优化,运行帧数比较低。开硬件加速后程序会卡死,原因未知。[localvideo]f67c08cf2378af634956749a1ebf7a7f[/localvideo]  

  • 2024-07-26
  • 发表了主题帖: 【瑞萨RA8D1开发板,基于M85内核的图形MCU测评】3.RGB-LCD

    由于LVGL不支持RGB666,触摸的I2C和j-link串口冲突,所以上个贴子中的硬件设计需要重新设计一下 在移植LVGL之前首先进行RGB LCD驱动的编写,本次实验所用屏幕为反客4.3寸800*480分辨率RGB屏幕 本次实验实在点灯工程的基础上进行的,由于实验设置的屏幕色彩模式为RGB565,并采用双缓存,所以内部RAM空间不足,需要使用外部SDRAM,先进行外部SDRAM的驱动配置,此处参考官方程序即可,下面为IO配置 Sdram文件添加到工程中 接下来进行GLCDC接口的时钟配置 然后进行GLCDC的IO口设置,色彩模式RGB565 Stacks添加GLCDC 设置属性 添加LCD背光的PWM驱动 配置完成后点击代码生成,在工程中添加LCD驱动的。下面为部分驱动代码 static uint16_t *lcd_current_working_buffer = (uint16_t *) &fb_background[0]; static uint8_t lcd_framebuffer[LCD_BUF_SIZE] BSP_ALIGN_VARIABLE(64) BSP_PLACE_IN_SECTION(".sdram"); static void bsp_lcd_backlight_init(void); /** * [url=home.php?mod=space&uid=159083]@brief[/url] 初始化 * * @param 无 * @retval 无 */ void bsp_lcd_init (void) { fsp_err_t err; // Open the GLCDC driver err = R_GLCDC_Open(&g_display0_ctrl, &g_display0_cfg); //printf("err1 %d\r\n",err); err = R_GLCDC_Start(&g_display0_ctrl); //printf("err2 %d\r\n",err); bsp_lcd_backlight_init(); } /** * @brief 初始化 * * @param 无 * @retval 无 */ static void bsp_lcd_backlight_init(void) { /* 初始化 GPT 模块 */ R_GPT_Open(&g_timer_gpt6_ctrl, &g_timer_gpt6_cfg); /* 启动 GPT 定时器 */ R_GPT_Start(&g_timer_gpt6_ctrl); /* 重新设置占空比为 80% */ lcd_set_brightness(100); } /** 自定义函数:设置PWM占空比 @param duty 占空比范围:0~100 % */ void lcd_set_brightness(uint8_t duty) { timer_info_t info; uint32_t current_period_counts; uint32_t duty_cycle_counts; if (duty > 100) duty = 100; //限制占空比范围:0~100 /* 获得GPT的信息 */ R_GPT_InfoGet(&g_timer_gpt6_ctrl, &info); /* 获得计时器一个周期需要的计数次数 */ current_period_counts = info.period_counts; /* 根据占空比和一个周期的计数次数计算GTCCR寄存器的值 */ duty_cycle_counts = (uint32_t)(((uint64_t) current_period_counts * duty) / 100); /* 最后调用FSP库函数设置占空比 */ R_GPT_DutyCycleSet(&g_timer_gpt6_ctrl, duty_cycle_counts, GPT_IO_PIN_GTIOCA); } /** * @brief 设置显示缓存 * @param index:缓存区索引 1.第一缓存数组 2.第二缓存数组 * @retval 无 */ static void lcd_set_display_buffer(uint8_t index) { /* 更改图层的帧缓冲区指针 */ R_GLCDC_BufferChange(&g_display0_ctrl, (uint8_t*)fb_background[index - 1], DISPLAY_FRAME_LAYER_1); } /** * @brief 设置当前使用的缓存 * @param index:缓存区索引 1.第一缓存数组 2.第二缓存数组 * @retval 无 */ static void lcd_set_working_buffer(uint8_t index) { if (index >= 1 && index <= 2) { lcd_current_working_buffer = (uint16_t *)fb_background[index - 1]; } } ///** // * @brief 使能双buffer // * @retval 无 // */ //static void lcd_enable_double_buffer(void) //{ // lcd_set_working_buffer(1); // lcd_set_display_buffer(1); //} /** * @brief lcd清屏 * @param color:RGB565 颜色 * @retval 无 */ void lcd_clear(uint16_t color) { for (uint32_t i = 0; i < (LCD_WIDTH * LCD_HEIGHT); i++) { lcd_current_working_buffer[i] = color; } } /** * @brief lcd切换帧缓冲区 * @retval 无 */ void lcd_swap_buffer(void) { if (lcd_current_working_buffer == (uint16_t *)fb_background[0]) { lcd_set_working_buffer(2); lcd_set_display_buffer(2); } else { lcd_set_working_buffer(1); lcd_set_display_buffer(1); } } /** * @brief lcd清平 * @param color:RGB565 颜色 * @retval 无 */ void lcd_draw_pixel(uint32_t x, uint32_t y, uint16_t color) { // Verify pixel is within LCD range if ((x <= LCD_WIDTH) && (y <= LCD_HEIGHT)) { switch (g_screen_rotation) { case ROTATION_ZERO: { lcd_current_working_buffer[(y * LCD_WIDTH) + x] = color; break; } case ROTATION_180: { lcd_current_working_buffer[((LCD_HEIGHT - y) * LCD_WIDTH) + (LCD_WIDTH - x)] = color; break; } default: { lcd_current_working_buffer[(y * LCD_WIDTH) + x] = color; break; } } } else { printf("draw pixel outof range:%d,%d", x, y); } } /** * @brief 填充数组 * @param x_start: * @param y_start: * @param x_end: * @param y_end: * @param pcolor: * @retval 无 */ void lcd_fill_array(uint16_t x_start, uint16_t y_start, uint16_t x_end, uint16_t y_end, void *pcolor) { uint16_t *pixel = NULL; uint16_t cycle_y, x_offset = 0; pixel = (uint16_t *)pcolor; for (cycle_y = y_start; cycle_y <= y_end;) { for (x_offset = 0; x_start + x_offset <= x_end; x_offset++) { lcd_draw_pixel(x_start + x_offset, cycle_y, *pixel++); } cycle_y++; } } void lcd_fill_rectangle(uint16_t x_start, uint16_t y_start, uint16_t x_end, uint16_t y_end, uint16_t pixcolor) { uint16_t cycle_y, x_offset = 0; for (cycle_y = y_start; cycle_y <= y_end;) { for (x_offset = 0; x_start + x_offset <= x_end; x_offset++) { lcd_draw_pixel(x_start + x_offset, cycle_y, pixcolor); } cycle_y++; } }   在LED线程中测试一下 void led_thread_entry(void* pvParameters) { FSP_PARAMETER_NOT_USED(pvParameters); bsp_dwt_init(); bsp_led_init(); bsp_uart3_init(); bsp_sdram_init(); bsp_lcd_init(); lcd_clear(BLACK); lcd_fill_rectangle(100,100,200,400,RED); lcd_fill_rectangle(200,100,300,400,GREEN); lcd_fill_rectangle(300,100,400,400,BLUE); while(1) { led_toggle(); vTaskDelay(20); } }   拍照有些失真,屏幕的实际观感效果还是很不错的。下一步移植LVGL_V9.1

  • 2024-07-17
  • 回复了主题帖: 【瑞萨RA8D1开发板,基于M85内核的图形MCU测评】2.扩展板设计

    Maker_kun 发表于 2024-7-16 13:42 这个扩展板有点东西

  • 2024-07-15
  • 发表了主题帖: 【瑞萨RA8D1开发板,基于M85内核的图形MCU测评】2.扩展板设计

    CPKCOR-RA8D1B板上使用224BGA封装的RA8D1,它集成了高性能 CM85 内核和大内存,以及丰富的外设集,包括带并行 RGB 和 MIPI-DSI 接口的高分辨率 TFT-LCD 控制器、2D 绘图引擎、16 位摄像头接口和多个外部内存接口。CPKCOR-RA8D1B板上有两个80管脚的高密度板对板连接器,可根据客户要求进行不同功能的扩展。本次体验为了方便后面的图形测试等,需要进行扩展板的设计。 板子的资料中已经给出扩展板设计样例,本次扩展板主要参考样例进行设计。 接下来进行扩展板的设计 BTB引脚引出 全速USB设计 用户按键 相机接口 MIPI接口 RGB-LCD接口 WIFI扩展 8.RS485扩展 9.CAN接口扩展 10.IO接口2.54mm扩展 最终的PCB设计如下图 扩展板至此初步设计完成,进行PCB的打样,接下来等待PCB的到来进行焊接调试。

最近访客

< 1/5 >

统计信息

已有121人来访过

  • 芯积分:371
  • 好友:--
  • 主题:18
  • 回复:20

留言

你需要登录后才可以留言 登录 | 注册


现在还没有留言