缘起:
F1C100S 电阻触摸硬件电路电路如图:
而实际的却是:
---->X1;
---->Y1;
---->X2;
---->Y2;
正好中间的X2,Y1顺序调换了位置,导致触摸不正常,一直处于按下状态。查看手册,手册中说明X,Y可以调换,但不知道怎么调,查到的资料贴上来,大家帮忙一起想想办法,多谢大家。
离线
研究了几天触摸线序的问题未果,最终还是乖乖的改了图^^
新问题:
1.在RT-Thread 上移植了 LVGL8,DEMO还没跑成功,悲催:(不知问题出那里了……
/*GUI初始化*/
lv_init();
lv_port_disp_init();
lv_port_indev_init();
lv_fs_if_init();
while(1)
{
lv_task_handler();
rt_thread_mdelay(1);
}
代码中如果屏蔽 ‘lv_fs_if_init();’,系统可以正常启动,加上则系统跳转失败,串口输出一串乱码
[10:50:54.524]收←◆KQ@|@X`X@Ve4
lv_fs_if_init()代码如下:
void lv_fs_if_init(void)
{
lv_port_fs_init();
}
void lv_port_fs_init(void)
{
/*----------------------------------------------------
* Initialize your storage device and File System
* -------------------------------------------------*/
fs_init();
/*---------------------------------------------------
* Register the file system interface in LVGL
*--------------------------------------------------*/
/*Add a simple drive to open images*/
static lv_fs_drv_t fs_drv;
lv_fs_drv_init(&fs_drv);
/*Set up fields...*/
fs_drv.letter = 'S';
fs_drv.open_cb = fs_open;
fs_drv.close_cb = fs_close;
fs_drv.read_cb = fs_read;
fs_drv.write_cb = fs_write;
fs_drv.seek_cb = fs_seek;
fs_drv.tell_cb = fs_tell;
fs_drv.dir_close_cb = fs_dir_close;
fs_drv.dir_open_cb = fs_dir_open;
fs_drv.dir_read_cb = fs_dir_read;
lv_fs_drv_register(&fs_drv);
}
static void fs_init(void)
{
/*E.g. for FatFS initialize the SD card and FatFS itself*/
/*You code here*/
/*E.g. for FatFS initalize the SD card and FatFS itself*/
/*You code here*/
// FATFS * fs = (FATFS*)lv_mem_alloc(sizeof(FATFS));
FATFS fs;
FRESULT fres = FR_NOT_READY;
if (fres != FR_OK) {
fres = f_mount(&fs,"0:",1);
if (fres != FR_OK)
{
SD_Printf("SD Card mounted error. (%d)\n",fres);
}
else
{
SD_Printf("SD Card mounted successfully.\n");
}
}
// lv_mem_free(fs);
}
界面不显示也就罢了,一旦加入文件系统就启动不了,不知什么问题;
2.接上问题,为了排除是是系统移植有问题,在裸机程序上移植了LVGL,问题更诡异,LVGL启动程序如下:
void Lvgl_start(void)
{
int time1=0;
int time2=0;
GPIO_Congif(GPIOE,GPIO_Pin_6,GPIO_Mode_OUT,GPIO_PuPd_NOPULL);
/*lvgl tick*/
Sys_Timer1_Init();
/*lvgl 初始化*/
lv_init();
lv_port_disp_init();
lv_port_indev_init();
while(1)
{
lv_task_handler();
delay_us(10);
}
}
代码中有一行 ‘GPIO_Congif(GPIOE,GPIO_Pin_6,GPIO_Mode_OUT,GPIO_PuPd_NOPULL);’
如果屏蔽,则没办法从boot跳转的应用,如果取消屏蔽则运行正常……
@晕哥 真心求助
最近编辑记录 Sam (2021-09-05 11:13:46)
离线
只有一位寄存器,相信也实现不了太多的交换功能,试了一下没什么反应
离线
发个帖子下班:
裸机状态下,总算可以跑起来了,只是'lv_demo_widgets()'的demo 一直不成功;
代码如下:
/*lvgl tick*/
Sys_Timer1_Init();
/*lvgl 初始化*/
lv_init();
lv_port_disp_init();
lv_port_indev_init();
// lv_fs_if_init();
// #ifdef RTP_TOUCH_USR
// touch_chCalibrate();/*触屏校正*/
// #endif
lv_demo_widgets();
while(1)
{
lv_task_handler();
delay_us(10);
}
已经排除了定时器未进入中断问题、延时函数问题,最终定位到了
LV_ATTRIBUTE_TIMER_HANDLER uint32_t lv_timer_handler(void)
{
TIMER_TRACE("begin");
/*Avoid concurrent running of the timer handler*/
static bool already_running = false;
if(already_running) return 1;
already_running = true;
if(lv_timer_run == false) {
already_running = false; /*Release mutex*/
TIMER_TRACE("already running, concurrent calls are not allow, returning");
return 1;
}
static uint32_t idle_period_start = 0;
static uint32_t busy_time = 0;
uint32_t handler_start = lv_tick_get();
if(handler_start == 0) {
static uint32_t run_cnt = 0;
run_cnt ++;
if(run_cnt > 100) {
run_cnt = 0;
LV_LOG_WARN("It seems lv_tick_inc() is not called.");
}
}
/*Run all timer from the list*/
lv_timer_t * next;
do {
timer_deleted = false;
timer_created = false;
LV_GC_ROOT(_lv_timer_act) = _lv_ll_get_head(&LV_GC_ROOT(_lv_timer_ll));
while(LV_GC_ROOT(_lv_timer_act)) {
/*The timer might be deleted if it runs only once ('repeat_count = 1')
*So get next element until the current is surely valid*/
sysprintf("1\n");
next = _lv_ll_get_next(&LV_GC_ROOT(_lv_timer_ll), LV_GC_ROOT(_lv_timer_act));
sysprintf("2\n");
/**
* 可疑点
*/
if(lv_timer_exec(LV_GC_ROOT(_lv_timer_act))) {
sysprintf("3\n");
/*If a timer was created or deleted then this or the next item might be corrupted*/
if(timer_created || timer_deleted) {
sysprintf("4\n");
TIMER_TRACE("Start from the first timer again because a timer was created or deleted");
break;
}
}
sysprintf("5\n");
LV_GC_ROOT(_lv_timer_act) = next; /*Load the next timer*/
}
} while(LV_GC_ROOT(_lv_timer_act));
uint32_t time_till_next = LV_NO_TIMER_READY;
next = _lv_ll_get_head(&LV_GC_ROOT(_lv_timer_ll));
while(next) {
if(!next->paused) {
uint32_t delay = lv_timer_time_remaining(next);
if(delay < time_till_next)
time_till_next = delay;
}
next = _lv_ll_get_next(&LV_GC_ROOT(_lv_timer_ll), next); /*Find the next timer*/
}
busy_time += lv_tick_elaps(handler_start);
uint32_t idle_period_time = lv_tick_elaps(idle_period_start);
if(idle_period_time >= IDLE_MEAS_PERIOD) {
idle_last = (busy_time * 100) / idle_period_time; /*Calculate the busy percentage*/
idle_last = idle_last > 100 ? 0 : 100 - idle_last; /*But we need idle time*/
busy_time = 0;
idle_period_start = lv_tick_get();
}
already_running = false; /*Release the mutex*/
TIMER_TRACE("finished (%d ms until the next timer call)", time_till_next);
return time_till_next;
}
在执行'lv_timer_exec(LV_GC_ROOT(_lv_timer_act)'时死机引起,具体原因不详,可能是移植哪部分出了问题,明天继续……
最近编辑记录 Sam (2021-09-05 22:16:48)
离线
跟进一步:
屏蔽了demo例程‘lv_demo_widgets()’,程序执行畅通无阻,继续排查,先上代码
void lv_demo_widgets(void)
{
if(LV_HOR_RES <= 320) disp_size = DISP_SMALL;
else if(LV_HOR_RES < 720) disp_size = DISP_MEDIUM;
else disp_size = DISP_LARGE;
font_large = LV_FONT_DEFAULT;
font_normal = LV_FONT_DEFAULT;
lv_coord_t tab_h;
if(disp_size == DISP_LARGE) {
tab_h = 70;
#if LV_FONT_MONTSERRAT_24
font_large = &lv_font_montserrat_24;
#else
LV_LOG_WARN("LV_FONT_MONTSERRAT_24 is not enabled for the widgets demo. Using LV_FONT_DEFAULT instead.")
#endif
#if LV_FONT_MONTSERRAT_16
font_normal = &lv_font_montserrat_16;
#else
LV_LOG_WARN("LV_FONT_MONTSERRAT_16 is not enabled for the widgets demo. Using LV_FONT_DEFAULT instead.")
#endif
} else if(disp_size == DISP_MEDIUM) {
tab_h = 45;
#if LV_FONT_MONTSERRAT_20
font_large = &lv_font_montserrat_20;
#else
LV_LOG_WARN("LV_FONT_MONTSERRAT_20 is not enabled for the widgets demo. Using LV_FONT_DEFAULT instead.")
#endif
#if LV_FONT_MONTSERRAT_14
font_normal = &lv_font_montserrat_14;
#else
LV_LOG_WARN("LV_FONT_MONTSERRAT_14 is not enabled for the widgets demo. Using LV_FONT_DEFAULT instead.")
#endif
} else { /* disp_size == DISP_SMALL */
tab_h = 45;
#if LV_FONT_MONTSERRAT_18
font_large = &lv_font_montserrat_18;
#else
LV_LOG_WARN("LV_FONT_MONTSERRAT_18 is not enabled for the widgets demo. Using LV_FONT_DEFAULT instead.")
#endif
#if LV_FONT_MONTSERRAT_12
font_normal = &lv_font_montserrat_12;
#else
LV_LOG_WARN("LV_FONT_MONTSERRAT_12 is not enabled for the widgets demo. Using LV_FONT_DEFAULT instead.")
#endif
}
#if LV_USE_THEME_DEFAULT //LV_PALETTE_LIGHT_GREEN
lv_theme_default_init(NULL, lv_palette_main(LV_PALETTE_BLUE), lv_palette_main(LV_PALETTE_RED), LV_THEME_DEFAULT_DARK, font_normal);
// lv_theme_default_init(NULL, lv_palette_main(LV_PALETTE_LIGHT_GREEN), lv_palette_main(LV_PALETTE_LIGHT_GREEN), LV_THEME_DEFAULT_DARK, font_normal);
#endif
lv_style_init(&style_text_muted);
lv_style_set_text_opa(&style_text_muted, LV_OPA_50);
lv_style_init(&style_title);
lv_style_set_text_font(&style_title, font_large);
lv_style_init(&style_icon);
lv_style_set_text_color(&style_icon, lv_theme_get_color_primary(NULL));
lv_style_set_text_font(&style_icon, font_large);
lv_style_init(&style_bullet);
lv_style_set_border_width(&style_bullet, 0);
lv_style_set_radius(&style_bullet, LV_RADIUS_CIRCLE);
tv = lv_tabview_create(lv_scr_act(), LV_DIR_TOP, tab_h);
lv_obj_set_style_text_font(lv_scr_act(), font_normal, 0);
if(disp_size == DISP_LARGE) {
lv_obj_t * tab_btns = lv_tabview_get_tab_btns(tv);
lv_obj_set_style_pad_left(tab_btns, LV_HOR_RES / 2, 0);
lv_obj_t * logo = lv_img_create(tab_btns);
LV_IMG_DECLARE(img_lvgl_logo);
lv_img_set_src(logo, &img_lvgl_logo);
lv_obj_align(logo, LV_ALIGN_LEFT_MID, -LV_HOR_RES / 2 + 25, 0);
lv_obj_t * label = lv_label_create(tab_btns);
lv_obj_add_style(label, &style_title, 0);
lv_label_set_text(label, "LVGL v8");
lv_obj_align_to(label, logo, LV_ALIGN_OUT_RIGHT_TOP, 10, 0);
label = lv_label_create(tab_btns);
lv_label_set_text(label, "Widgets demo");
lv_obj_add_style(label, &style_text_muted, 0);
lv_obj_align_to(label, logo, LV_ALIGN_OUT_RIGHT_BOTTOM, 10, 0);
}
lv_obj_t * t1 = lv_tabview_add_tab(tv, "Profile");
lv_obj_t * t2 = lv_tabview_add_tab(tv, "Analytics");
lv_obj_t * t3 = lv_tabview_add_tab(tv, "Shop");
profile_create(t1);
analytics_create(t2);
shop_create(t3);
color_changer_create(tv);
}
最终屏蔽了'color_changer_create(tv)' 死机现象消失,打开则又出现死机;
深深的怀疑是移植的时候遗漏了什么,可又找不到……,还是采用笨办法,继续屏蔽
最终定位到了
// uint32_t i;
// for(i = 0; palette[i] != _LV_PALETTE_LAST; i++) {
// lv_obj_t * c = lv_btn_create(color_cont);
// lv_obj_set_style_bg_color(c, lv_palette_main(palette[i]), 0);
// lv_obj_set_style_radius(c, LV_RADIUS_CIRCLE, 0);
// lv_obj_set_style_opa(c, LV_OPA_TRANSP, 0);
// lv_obj_set_size(c, 20, 20);
// lv_obj_add_event_cb(c, color_event_cb, LV_EVENT_ALL, &palette[i]);
// lv_obj_clear_flag(c, LV_OBJ_FLAG_SCROLL_ON_FOCUS);
// }
猜想应该是触摸输入部分移植的有点问题或者什么其他问题,明儿继续……
最近编辑记录 Sam (2021-09-06 22:27:11)
离线
传个测试视频,没几下就死机了
离线