高级会员
- 积分
- 830
- 金钱
- 830
- 注册时间
- 2020-7-1
- 在线时间
- 110 小时
|
10金钱
本帖最后由 q879524825 于 2022-6-13 16:57 编辑
stm32F407 跑LVGL,屏幕不定时 突然白屏
开了debug看 也没有进入 硬件错误。
这个界面是开了20个textarea 、21个label、一个键盘、2个button,
大约占了21KB,我给lvgl分配的是 36K
仔细检查过代码,不清楚哪里有内存泄露还是?
另外还有个bug, 用的40cm fpc排线接的 2.8寸屏幕, 屏幕一直闪烁,有时候闪烁的很厉害,是电源不稳吗? 按说不至于啊
- #include "my_app/settingPage.h"
- #include "my_app/mainWindow.h"
- #include "application.h"
- #include "stdio.h"
- static uint32_t userData[2] = { 0 }; //记录子对象 ID
- //偶尔会 白屏
- //char ta_string[20][15] = { "","","","","","","","","","","","","","","","","","","","" }; //记录textarea 字符串
- static void btn_event_cb(lv_event_t* e)
- {
- lv_event_code_t code = lv_event_get_code(e); //获取 触发回调的 事件
- lv_obj_t* target = lv_event_get_target(e); //获取触发回调的 对象
- uint32_t* data = lv_event_get_user_data(e);
- uint32_t ID = lv_obj_get_child_id(target);
- lv_obj_t* parent = lv_obj_get_parent(target);
- LV_LOG_USER("btn cb! ID:%d", ID);
- if (code == LV_EVENT_CLICKED && data[0] == ID) //验证子对象的ID
- {
- LV_LOG_USER("return_btn clicked!");//
- lv_obj_del(parent); //返回到主界面
- mainWin();
- }
- if (code == LV_EVENT_CLICKED && data[1] == ID) //验证子对象的ID
- {
- LV_LOG_USER("save_btn clicked!");//
-
- //直接从 ta对象提取 到参数结构体
- APP_Para.s_p_L_t=atoi(lv_textarea_get_text(lv_obj_get_child(parent, 4)));//ta子对象 ID从4-42
- APP_Para.s_p_H_t=atoi(lv_textarea_get_text(lv_obj_get_child(parent, 6)));
- APP_Para.l_p_L_t=atoi(lv_textarea_get_text(lv_obj_get_child(parent, 8)));
- APP_Para.l_p_H_t=atoi(lv_textarea_get_text(lv_obj_get_child(parent, 10)));
-
- APP_Para.Z_C_x_s=atoi(lv_textarea_get_text(lv_obj_get_child(parent, 12))); //8位
- APP_Para.Y_C_y_s=atoi(lv_textarea_get_text(lv_obj_get_child(parent, 14)));
- APP_Para.T1_s=atoi(lv_textarea_get_text(lv_obj_get_child(parent, 16)));
- APP_Para.T2_s=atoi(lv_textarea_get_text(lv_obj_get_child(parent, 18)));
- APP_Para.T3_s=atoi(lv_textarea_get_text(lv_obj_get_child(parent, 20)));
- APP_Para.T4_s=atoi(lv_textarea_get_text(lv_obj_get_child(parent, 22)));
- APP_Para.T5_s=atoi(lv_textarea_get_text(lv_obj_get_child(parent, 24)));
- APP_Para.T6_s=atoi(lv_textarea_get_text(lv_obj_get_child(parent, 26)));
- APP_Para.T7_s=atoi(lv_textarea_get_text(lv_obj_get_child(parent, 28)));
- APP_Para.Type=atoi(lv_textarea_get_text(lv_obj_get_child(parent, 30)));
-
- strcpy(APP_Para.login_ID, lv_textarea_get_text(lv_obj_get_child(parent, 32)));
- strcpy(APP_Para.login_PWD, lv_textarea_get_text(lv_obj_get_child(parent, 34)));
- strcpy(APP_Para.wifi_ID, lv_textarea_get_text(lv_obj_get_child(parent, 36)));
- strcpy(APP_Para.wifi_PWD, lv_textarea_get_text(lv_obj_get_child(parent, 38)));
- strcpy(APP_Para.wifi_server_IP, lv_textarea_get_text(lv_obj_get_child(parent, 40)));
- strcpy(APP_Para.wifi_server_PORT, lv_textarea_get_text(lv_obj_get_child(parent, 42)));
-
- APP_Para_Save(&APP_Para); //将结构体参数进行存储 **********没保存到flash
-
- //mesgbox提示保存完毕
- lv_obj_t* msgbox = lv_msgbox_create(parent, "Success!", "have saved", NULL, true);
- lv_obj_set_size(msgbox, 140, 60);
- lv_obj_align_to(msgbox, parent, LV_ALIGN_TOP_MID, 0, 20);
- //bug:一直触发一个事件[Warn] (508834.750, +32) lv_draw_letter: lv_draw_letter: glyph dsc. not found for U+FF01
- //排查问题是 "Success!" 中的感叹号用的 中文符号 "Success!",所以这个字符识别不到
- }
- }
- static void textarea_event_cb(lv_event_t* e)
- {
- //LV_LOG_USER("event_cb!"); //PC端的 LOG打印
- //const char* str_buff;
- lv_event_code_t code = lv_event_get_code(e); //获取 触发回调的 事件
- lv_obj_t* target = lv_event_get_target(e); //获取触发回调的 对象
- lv_obj_t* kb = lv_event_get_user_data(e);
- uint32_t ID = lv_obj_get_child_id(target);
- //LV_LOG_USER("ta cb! ID:%d", ID);
- if (code == LV_EVENT_CLICKED)
- {
- LV_LOG_USER("ta cb! ID:%d.keyboard!", ID);
- lv_keyboard_set_textarea(kb, target);
- lv_obj_align_to(kb, target, LV_ALIGN_OUT_BOTTOM_RIGHT,0,30); //将键盘位置 放置最下
- lv_obj_clear_flag(kb, LV_OBJ_FLAG_HIDDEN);
- lv_group_focus_obj(kb);
- lv_group_set_editing(lv_obj_get_group(kb), kb);
- //str_buff=lv_textarea_get_text(target);
- //strcpy(ta_string[(ID) / 2], str_buff);
-
- }
- /*if (code == LV_EVENT_DEFOCUSED)
- {
- LV_LOG_USER("hide keyboard!");
- lv_keyboard_set_textarea(kb, NULL);
- lv_obj_add_flag(kb, LV_OBJ_FLAG_HIDDEN);
- }*/
- if (code == LV_EVENT_READY || code == LV_EVENT_CANCEL )//|| code == LV_EVENT_LEAVE 在键盘出现时点击另一个对象 会卡住
- {
- LV_LOG_USER("ta cb! ID:%d.hide keyboard!", ID);
- lv_obj_add_flag(kb, LV_OBJ_FLAG_HIDDEN);
- //str_buff = lv_textarea_get_text(target);
- //strcpy(ta_string[(ID) / 2], str_buff); //可以直接查各个 ta子对象了
-
- }
- }
- void settingPage()
- {
- //列表+text area? 表格?
- //flex 布局,label+textarea 一行一行下去。
- //SAVE EXIT 两个按键 和一个 setting 大标题,放在最上边
- char ta_buf[15];
-
- uint16_t parent_width, parent_height,i=0;
- lv_obj_t* parent= lv_obj_create(lv_scr_act());
- parent_width = lv_obj_get_width(lv_scr_act());
- parent_height = lv_obj_get_height(lv_scr_act());
- lv_obj_set_size(parent, parent_width, parent_height);//建立全屏的页面对象,在这个页面上布局
- //画一条分界线
- static lv_style_t style_line;
- lv_style_init(&style_line);
- lv_style_set_line_width(&style_line, 2);
- lv_style_set_line_color(&style_line, lv_palette_main(LV_PALETTE_BLUE));
- lv_style_set_line_rounded(&style_line, true);
- static lv_point_t line_points[] = { {10, 30}, {220, 30} };
- lv_obj_t* line1 = lv_line_create(parent);
- lv_line_set_points(line1, line_points, 2);
- lv_obj_add_style(line1, &style_line, 0);
- //setting label 中间
- lv_obj_t* title_label = lv_label_create(parent); //return
- lv_label_set_text(title_label, "setting");
- lv_obj_align_to(title_label, line1, LV_ALIGN_CENTER, 0, -8);
-
-
- lv_obj_t* return_btn = lv_btn_create(parent); //return按钮 在左边
- lv_obj_set_size(return_btn, (parent_width - 10) / 4, 25);
- lv_obj_align_to(return_btn, title_label, LV_ALIGN_OUT_LEFT_MID, -20, 0);
- lv_obj_t* return_btn_label = lv_label_create(return_btn); //return
- lv_label_set_text(return_btn_label, "return");
- lv_obj_align(return_btn_label, LV_ALIGN_CENTER, 0, 0);
- lv_obj_t* save_btn = lv_btn_create(parent); //save按钮 在右边
- lv_obj_set_size(save_btn, (parent_width-10)/4, 25);
- lv_obj_align_to(save_btn, title_label, LV_ALIGN_OUT_RIGHT_MID, 20, 0);
- lv_obj_t* save_btn_label = lv_label_create(save_btn); //save
- lv_label_set_text(save_btn_label, "save");
- lv_obj_align(save_btn_label, LV_ALIGN_CENTER, 0, 0);
- /* lv_obj_t* setPage_con = lv_obj_create(parent); //不要这个框体了,以免寻找 爷孙对象(无法达成)
- lv_obj_set_size(setPage_con, parent_width, parent_height-40);
- lv_obj_align_to(setPage_con, line1, LV_ALIGN_OUT_BOTTOM_MID, 0, 5); */
-
- //****获取结构体中 的数据,然后 改成字符串放入 字符串数组,以下逐个进行显示
-
- i=0;
-
- // for (i = 0; i < 20; i++)
- // sprintf(ta_string[i], "test:%d", i); // 测试代码,给每个ta 赋字符串
-
- /* ta_string[0] = "text:1";
- ta_string[1] = "text:1";
- ta_string[2] = "text:1";
- ta_string[3] = "text:1";
- ta_string[4] = "text:1";
- ta_string[5] = "text:1";
- ta_string[6] = "text:1";
- ta_string[7] = "text:1";
- ta_string[8] = "text:1";
- ta_string[9] = "text:1";
- ta_string[10] = "text:19";
- ta_string[11] = "text:19";
- ta_string[12] = "text:19";
- ta_string[13] = "text:19";
- ta_string[14] = "text:19";
- ta_string[15] = "text:19";
- ta_string[16] = "text:19";
- ta_string[17] = "text:19";
- ta_string[18] = "text:19";
- ta_string[19] = "text:19";*/
-
- i = 0;
-
- sprintf(ta_buf, "%d", APP_Para.s_p_L_t);
-
- lv_obj_t* textarea1 = lv_textarea_create(parent); //先建立 ta 子对象ID就从0开始了 0、2、4、、、38
- lv_obj_set_size(textarea1, parent_width / 3 * 2 - 20, parent_height / 16);
- lv_textarea_set_max_length(textarea1, 10);
- lv_obj_align_to(textarea1, line1, LV_ALIGN_OUT_BOTTOM_RIGHT, 0, 0);
- lv_textarea_set_text(textarea1, ta_buf); //将读取flash到 结构体后 的字符串设置到这里
- //lv_textarea_set_placeholder_text(textarea1, ":"); //提示文本
- lv_textarea_set_one_line(textarea1, true); //单行模式
-
- lv_obj_t* label1 = lv_label_create(parent);
- lv_obj_set_size(label1, parent_width / 3, parent_height / 16);
- lv_label_set_text(label1, "supply pressure low threshold:");
- lv_label_set_long_mode(label1, LV_LABEL_LONG_SCROLL);
- lv_obj_align_to(label1, textarea1, LV_ALIGN_OUT_LEFT_MID, 0, 0); //label 放在 ta 左边
- sprintf(ta_buf, "%d", APP_Para.s_p_H_t);
- lv_obj_t* textarea2 = lv_textarea_create(parent);
- lv_obj_set_size(textarea2, parent_width / 3 * 2 - 20, parent_height / 16);
- lv_textarea_set_max_length(textarea2, 10);
- lv_obj_align_to(textarea2, textarea1, LV_ALIGN_OUT_BOTTOM_MID, 0, 0);
- lv_textarea_set_text(textarea2, ta_buf); //将读取flash到 结构体后 的字符串设置到这里
- lv_textarea_set_one_line(textarea2, true); //单行模式
-
- lv_obj_t* label2 = lv_label_create(parent);
- lv_obj_set_size(label2, parent_width / 3, parent_height / 16);
- lv_label_set_text(label2, "supply pressure high threshold:");
- lv_label_set_long_mode(label2, LV_LABEL_LONG_SCROLL);
- lv_obj_align_to(label2, textarea2, LV_ALIGN_OUT_LEFT_MID, 0, 0);
- sprintf(ta_buf, "%d", APP_Para.l_p_L_t);
-
- lv_obj_t* textarea3 = lv_textarea_create(parent);
- lv_obj_set_size(textarea3, parent_width / 3 * 2 - 20, parent_height / 16);
- lv_textarea_set_max_length(textarea3, 10);
- lv_obj_align_to(textarea3, textarea2, LV_ALIGN_OUT_BOTTOM_MID, 0, 0);
- lv_textarea_set_text(textarea3, ta_buf); //将读取flash到 结构体后 的字符串设置到这里
- lv_textarea_set_one_line(textarea3, true); //单行模式
- lv_obj_t* label3 = lv_label_create(parent);
- lv_obj_set_size(label3, parent_width / 3, parent_height / 16);
- lv_label_set_text(label3, "leakage pressure low threshold:");
- lv_label_set_long_mode(label3, LV_LABEL_LONG_SCROLL);
- lv_obj_align_to(label3, textarea3, LV_ALIGN_OUT_LEFT_MID, 0, 0);
- sprintf(ta_buf, "%d", APP_Para.l_p_H_t);
-
- lv_obj_t* textarea4 = lv_textarea_create(parent);
- lv_obj_set_size(textarea4, parent_width / 3 * 2 - 20, parent_height / 16);
- lv_textarea_set_max_length(textarea4, 10);
- lv_obj_align_to(textarea4, textarea3, LV_ALIGN_OUT_BOTTOM_MID, 0, 0);
- lv_textarea_set_text(textarea4, ta_buf); //将读取flash到 结构体后 的字符串设置到这里
- lv_textarea_set_one_line(textarea4, true); //单行模式
- lv_obj_t* label4 = lv_label_create(parent);
- lv_obj_set_size(label4, parent_width / 3, parent_height / 16);
- lv_label_set_text(label4, "leakage pressure high threshold:");
- lv_label_set_long_mode(label4, LV_LABEL_LONG_SCROLL);
- lv_obj_align_to(label4, textarea4, LV_ALIGN_OUT_LEFT_MID, 0, 0);
-
- sprintf(ta_buf, "%d", APP_Para.Z_C_x_s);
-
- lv_obj_t* textarea5 = lv_textarea_create(parent);
- lv_obj_set_size(textarea5, parent_width / 3 * 2 - 20, parent_height / 16);
- lv_textarea_set_max_length(textarea5, 10);
- lv_obj_align_to(textarea5, textarea4, LV_ALIGN_OUT_BOTTOM_MID, 0, 0);
- lv_textarea_set_text(textarea5, ta_buf); //将读取flash到 结构体后 的字符串设置到这里
- lv_textarea_set_one_line(textarea5, true); //单行模式
- lv_obj_t* label5 = lv_label_create(parent);
- lv_obj_set_size(label5, parent_width / 3, parent_height / 16);
- lv_label_set_text(label5, "z clamp time");
- lv_label_set_long_mode(label5, LV_LABEL_LONG_SCROLL);
- lv_obj_align_to(label5, textarea5, LV_ALIGN_OUT_LEFT_MID, 0, 0);
-
- sprintf(ta_buf, "%d", APP_Para.Y_C_y_s);
- lv_obj_t* textarea6 = lv_textarea_create(parent);
- lv_obj_set_size(textarea6, parent_width / 3 * 2 - 20, parent_height / 16);
- lv_textarea_set_max_length(textarea6, 10);
- lv_obj_align_to(textarea6, textarea5, LV_ALIGN_OUT_BOTTOM_MID, 0, 0);
- lv_textarea_set_text(textarea6, ta_buf); //将读取flash到 结构体后 的字符串设置到这里
- lv_textarea_set_one_line(textarea6, true); //单行模式
- lv_obj_t* label6 = lv_label_create(parent);
- lv_obj_set_size(label6, parent_width / 3, parent_height / 16);
- lv_label_set_text(label6, "y clamp time");
- lv_label_set_long_mode(label6, LV_LABEL_LONG_SCROLL);
- lv_obj_align_to(label6, textarea6, LV_ALIGN_OUT_LEFT_MID, 0, 0);
- sprintf(ta_buf, "%d", APP_Para.T1_s);
-
- lv_obj_t* textarea7 = lv_textarea_create(parent);
- lv_obj_set_size(textarea7, parent_width / 3 * 2 - 20, parent_height / 16);
- lv_textarea_set_max_length(textarea7, 10);
- lv_obj_align_to(textarea7, textarea6, LV_ALIGN_OUT_BOTTOM_MID, 0, 0);
- lv_textarea_set_text(textarea7, ta_buf); //将读取flash到 结构体后 的字符串设置到这里
- lv_textarea_set_one_line(textarea7, true); //单行模式
- lv_obj_t* label7 = lv_label_create(parent);
- lv_obj_set_size(label7, parent_width / 3, parent_height / 16);
- lv_label_set_text(label7, "(T1)pre inflation time:");
- lv_label_set_long_mode(label7, LV_LABEL_LONG_SCROLL);
- lv_obj_align_to(label7, textarea7, LV_ALIGN_OUT_LEFT_MID, 0, 0);
- sprintf(ta_buf, "%d", APP_Para.T2_s);
-
- lv_obj_t* textarea8 = lv_textarea_create(parent);
- lv_obj_set_size(textarea8, parent_width / 3 * 2 - 20, parent_height / 16);
- lv_textarea_set_max_length(textarea8, 10);
- lv_obj_align_to(textarea8, textarea7, LV_ALIGN_OUT_BOTTOM_MID, 0, 0);
- lv_textarea_set_text(textarea8, ta_buf); //将读取flash到 结构体后 的字符串设置到这里
- lv_textarea_set_one_line(textarea8, true); //单行模式
- lv_obj_t* label8 = lv_label_create(parent);
- lv_obj_set_size(label8, parent_width / 3, parent_height / 16);
- lv_label_set_text(label8, "(T2)inflation time:");
- lv_label_set_long_mode(label8, LV_LABEL_LONG_SCROLL);
- lv_obj_align_to(label8, textarea8, LV_ALIGN_OUT_LEFT_MID, 0, 0);
- sprintf(ta_buf, "%d", APP_Para.T3_s);
-
- lv_obj_t* textarea9 = lv_textarea_create(parent);
- lv_obj_set_size(textarea9, parent_width / 3 * 2 - 20, parent_height / 16);
- lv_textarea_set_max_length(textarea9, 10);
- lv_obj_align_to(textarea9, textarea8, LV_ALIGN_OUT_BOTTOM_MID, 0, 0);
- lv_textarea_set_text(textarea9, ta_buf); //将读取flash到 结构体后 的字符串设置到这里
- lv_textarea_set_one_line(textarea9, true); //单行模式
- lv_obj_t* label9 = lv_label_create(parent);
- lv_obj_set_size(label9, parent_width / 3, parent_height / 16);
- lv_label_set_text(label9, "(T3)balance time:");
- lv_label_set_long_mode(label9, LV_LABEL_LONG_SCROLL);
- lv_obj_align_to(label9, textarea9, LV_ALIGN_OUT_LEFT_MID, 0, 0);
- sprintf(ta_buf, "%d", APP_Para.T4_s);
-
- lv_obj_t* textarea10 = lv_textarea_create(parent);
- lv_obj_set_size(textarea10, parent_width / 3 * 2 - 20, parent_height / 16);
- lv_textarea_set_max_length(textarea10, 10);
- lv_obj_align_to(textarea10, textarea9, LV_ALIGN_OUT_BOTTOM_MID, 0, 0);
- lv_textarea_set_text(textarea10, ta_buf); //将读取flash到 结构体后 的字符串设置到这里
- lv_textarea_set_one_line(textarea10, true); //单行模式
- lv_obj_t* label10 = lv_label_create(parent);
- lv_obj_set_size(label10, parent_width / 3, parent_height / 16);
- lv_label_set_text(label10, "(T4)stabilization time:");
- lv_label_set_long_mode(label10, LV_LABEL_LONG_SCROLL);
- lv_obj_align_to(label10, textarea10, LV_ALIGN_OUT_LEFT_MID, 0, 0);
- sprintf(ta_buf, "%d", APP_Para.T5_s);
-
- lv_obj_t* textarea11 = lv_textarea_create(parent);
- lv_obj_set_size(textarea11, parent_width / 3 * 2 - 20, parent_height / 16);
- lv_textarea_set_max_length(textarea11, 10);
- lv_obj_align_to(textarea11, textarea10, LV_ALIGN_OUT_BOTTOM_MID, 0, 0);
- lv_textarea_set_text(textarea11, ta_buf); //将读取flash到 结构体后 的字符串设置到这里
- lv_textarea_set_one_line(textarea11, true); //单行模式
- lv_obj_t* label11 = lv_label_create(parent);
- lv_obj_set_size(label11, parent_width / 3, parent_height / 16);
- lv_label_set_text(label11, "(T5)test time:");
- lv_label_set_long_mode(label11, LV_LABEL_LONG_SCROLL);
- lv_obj_align_to(label11, textarea11, LV_ALIGN_OUT_LEFT_MID, 0, 0);
- sprintf(ta_buf, "%d", APP_Para.T6_s);
-
- lv_obj_t* textarea12 = lv_textarea_create(parent);
- lv_obj_set_size(textarea12, parent_width / 3 * 2 - 20, parent_height / 16);
- lv_textarea_set_max_length(textarea12, 10);
- lv_obj_align_to(textarea12, textarea11, LV_ALIGN_OUT_BOTTOM_MID, 0, 0);
- lv_textarea_set_text(textarea12, ta_buf); //将读取flash到 结构体后 的字符串设置到这里
- lv_textarea_set_one_line(textarea12, true); //单行模式
- lv_obj_t* label12 = lv_label_create(parent);
- lv_obj_set_size(label12, parent_width / 3, parent_height / 16);
- lv_label_set_text(label12, "(T6)exhaust time:");
- lv_label_set_long_mode(label12, LV_LABEL_LONG_SCROLL);
- lv_obj_align_to(label12, textarea12, LV_ALIGN_OUT_LEFT_MID, 0, 0);
- sprintf(ta_buf, "%d", APP_Para.T7_s);
-
- lv_obj_t* textarea13 = lv_textarea_create(parent);
- lv_obj_set_size(textarea13, parent_width / 3 * 2 - 20, parent_height / 16);
- lv_textarea_set_max_length(textarea13, 10);
- lv_obj_align_to(textarea13, textarea12, LV_ALIGN_OUT_BOTTOM_MID, 0, 0);
- lv_textarea_set_text(textarea13, ta_buf); //将读取flash到 结构体后 的字符串设置到这里
- lv_textarea_set_one_line(textarea13, true); //单行模式
- lv_obj_t* label13 = lv_label_create(parent);
- lv_obj_set_size(label13, parent_width / 3, parent_height / 16);
- lv_label_set_text(label13, "(T7)waiting time:");
- lv_label_set_long_mode(label13, LV_LABEL_LONG_SCROLL);
- lv_obj_align_to(label13, textarea13, LV_ALIGN_OUT_LEFT_MID, 0, 0);
- sprintf(ta_buf, "%d", APP_Para.Type);
-
- lv_obj_t* textarea14 = lv_textarea_create(parent);
- lv_obj_set_size(textarea14, parent_width / 3 * 2 - 20, parent_height / 16);
- lv_textarea_set_max_length(textarea14, 10);
- lv_obj_align_to(textarea14, textarea13, LV_ALIGN_OUT_BOTTOM_MID, 0, 0);
- lv_textarea_set_text(textarea14, ta_buf); //将读取flash到 结构体后 的字符串设置到这里
- lv_textarea_set_one_line(textarea14, true); //单行模式
- lv_obj_t* label14 = lv_label_create(parent);
- lv_obj_set_size(label14, parent_width / 3, parent_height / 16);
- lv_label_set_text(label14, "type:");
- lv_label_set_long_mode(label14, LV_LABEL_LONG_SCROLL);
- lv_obj_align_to(label14, textarea14, LV_ALIGN_OUT_LEFT_MID, 0, 0);
- sprintf(ta_buf, "%s", APP_Para.login_ID);
-
- lv_obj_t* textarea15 = lv_textarea_create(parent);
- lv_obj_set_size(textarea15, parent_width / 3 * 2 - 20, parent_height / 16);
- lv_textarea_set_max_length(textarea15, 14);
- lv_obj_align_to(textarea15, textarea14, LV_ALIGN_OUT_BOTTOM_MID, 0, 0);
- lv_textarea_set_text(textarea15, ta_buf); //将读取flash到 结构体后 的字符串设置到这里
- lv_textarea_set_one_line(textarea15, true); //单行模式
- lv_obj_t* label15 = lv_label_create(parent);
- lv_obj_set_size(label15, parent_width / 3, parent_height / 16);
- lv_label_set_text(label15, "loginID:");
- lv_label_set_long_mode(label15, LV_LABEL_LONG_SCROLL);
- lv_obj_align_to(label15, textarea15, LV_ALIGN_OUT_LEFT_MID, 0, 0);
- sprintf(ta_buf, "%s", APP_Para.login_PWD);
-
- lv_obj_t* textarea16 = lv_textarea_create(parent);
- lv_obj_set_size(textarea16, parent_width / 3 * 2 - 20, parent_height / 16);
- lv_textarea_set_max_length(textarea16, 14);
- lv_obj_align_to(textarea16, textarea15, LV_ALIGN_OUT_BOTTOM_MID, 0, 0);
- lv_textarea_set_text(textarea16, ta_buf); //将读取flash到 结构体后 的字符串设置到这里
- lv_textarea_set_one_line(textarea16, true); //单行模式
- lv_obj_t* label16 = lv_label_create(parent);
- lv_obj_set_size(label16, parent_width / 3, parent_height / 16);
- lv_label_set_text(label16, "loginPWD:");
- lv_label_set_long_mode(label16, LV_LABEL_LONG_SCROLL);
- lv_obj_align_to(label16, textarea16, LV_ALIGN_OUT_LEFT_MID, 0, 0);
- sprintf(ta_buf, "%s", APP_Para.wifi_ID);
-
- lv_obj_t* textarea17 = lv_textarea_create(parent);
- lv_obj_set_size(textarea17, parent_width / 3 * 2 - 20, parent_height / 16);
- lv_textarea_set_max_length(textarea17, 14);
- lv_obj_align_to(textarea17, textarea16, LV_ALIGN_OUT_BOTTOM_MID, 0, 0);
- lv_textarea_set_text(textarea17, ta_buf); //将读取flash到 结构体后 的字符串设置到这里
- lv_textarea_set_one_line(textarea17, true); //单行模式
- lv_obj_t* label17 = lv_label_create(parent);
- lv_obj_set_size(label17, parent_width / 3, parent_height / 16);
- lv_label_set_text(label17, "wifiID:");
- lv_label_set_long_mode(label17, LV_LABEL_LONG_SCROLL);
- lv_obj_align_to(label17, textarea17, LV_ALIGN_OUT_LEFT_MID, 0, 0);
- sprintf(ta_buf, "%s", APP_Para.wifi_PWD);
-
- lv_obj_t* textarea18 = lv_textarea_create(parent);
- lv_obj_set_size(textarea18, parent_width / 3 * 2 - 20, parent_height / 16);
- lv_textarea_set_max_length(textarea18, 14);
- lv_obj_align_to(textarea18, textarea17, LV_ALIGN_OUT_BOTTOM_MID, 0, 0);
- lv_textarea_set_text(textarea18, ta_buf); //将读取flash到 结构体后 的字符串设置到这里
- lv_textarea_set_one_line(textarea18, true); //单行模式
- lv_obj_t* label18 = lv_label_create(parent);
- lv_obj_set_size(label18, parent_width / 3, parent_height / 16);
- lv_label_set_text(label18, "wifiPWD:");
- lv_label_set_long_mode(label18, LV_LABEL_LONG_SCROLL);
- lv_obj_align_to(label18, textarea18, LV_ALIGN_OUT_LEFT_MID, 0, 0);
- sprintf(ta_buf, "%s", APP_Para.wifi_server_IP);
-
- lv_obj_t* textarea19 = lv_textarea_create(parent);
- lv_obj_set_size(textarea19, parent_width / 3 * 2 - 20, parent_height / 16);
- lv_textarea_set_max_length(textarea19, 14);
- lv_obj_align_to(textarea19, textarea18, LV_ALIGN_OUT_BOTTOM_MID, 0, 0);
- lv_textarea_set_text(textarea19, ta_buf); //将读取flash到 结构体后 的字符串设置到这里
- lv_textarea_set_one_line(textarea19, true); //单行模式
- lv_obj_t* label19 = lv_label_create(parent);
- lv_obj_set_size(label19, parent_width / 3, parent_height / 16);
- lv_label_set_text(label19, "serverIP:");
- lv_label_set_long_mode(label19, LV_LABEL_LONG_SCROLL);
- lv_obj_align_to(label19, textarea19, LV_ALIGN_OUT_LEFT_MID, 0, 0);
- sprintf(ta_buf, "%s", APP_Para.wifi_server_PORT);
- lv_obj_t* textarea20 = lv_textarea_create(parent);
- lv_obj_set_size(textarea20, parent_width / 3 * 2 - 20, parent_height / 16);
- lv_textarea_set_max_length(textarea20, 5);
- lv_obj_align_to(textarea20, textarea19, LV_ALIGN_OUT_BOTTOM_MID, 0, 0);
- lv_textarea_set_text(textarea20, ta_buf); //将读取flash到 结构体后 的字符串设置到这里
- lv_textarea_set_one_line(textarea20, true); //单行模式
- lv_obj_t* label20 = lv_label_create(parent);
- lv_obj_set_size(label20, parent_width / 3, parent_height / 16);
- lv_label_set_text(label20, "serverPort:");
- lv_label_set_long_mode(label20, LV_LABEL_LONG_SCROLL);
- lv_obj_align_to(label20, textarea20, LV_ALIGN_OUT_LEFT_MID, 0, 0);
-
- lv_obj_t* kb = lv_keyboard_create(parent); //创建键盘,点击textarea才显示
- lv_obj_add_flag(kb, LV_OBJ_FLAG_HIDDEN); //隐藏
- lv_keyboard_set_textarea(kb, textarea1); //先把键盘关联到textarea1
- //好像白屏 和键盘有关。。。尽量不要在这多停留吧。
- /* //添加全部事件 会频繁的进入 事件回调函数 ,死机白屏 可能就是因为这个 。tips: 非必要事件不要开启。
- lv_obj_add_event_cb(textarea1, textarea_event_cb, LV_EVENT_ALL, kb);
- lv_obj_add_event_cb(textarea2, textarea_event_cb, LV_EVENT_ALL, kb);
- lv_obj_add_event_cb(textarea3, textarea_event_cb, LV_EVENT_ALL, kb);
- lv_obj_add_event_cb(textarea4, textarea_event_cb, LV_EVENT_ALL, kb);
- lv_obj_add_event_cb(textarea5, textarea_event_cb, LV_EVENT_ALL, kb);
- lv_obj_add_event_cb(textarea6, textarea_event_cb, LV_EVENT_ALL, kb);
- lv_obj_add_event_cb(textarea7, textarea_event_cb, LV_EVENT_ALL, kb);
- lv_obj_add_event_cb(textarea8, textarea_event_cb, LV_EVENT_ALL, kb);
- lv_obj_add_event_cb(textarea9, textarea_event_cb, LV_EVENT_ALL, kb);
- lv_obj_add_event_cb(textarea10, textarea_event_cb, LV_EVENT_ALL, kb);
- lv_obj_add_event_cb(textarea11, textarea_event_cb, LV_EVENT_ALL, kb);
- lv_obj_add_event_cb(textarea12, textarea_event_cb, LV_EVENT_ALL, kb);
- lv_obj_add_event_cb(textarea13, textarea_event_cb, LV_EVENT_ALL, kb);
- lv_obj_add_event_cb(textarea14, textarea_event_cb, LV_EVENT_ALL, kb);
- lv_obj_add_event_cb(textarea15, textarea_event_cb, LV_EVENT_ALL, kb);
- lv_obj_add_event_cb(textarea16, textarea_event_cb, LV_EVENT_ALL, kb);
- lv_obj_add_event_cb(textarea17, textarea_event_cb, LV_EVENT_ALL, kb);
- lv_obj_add_event_cb(textarea18, textarea_event_cb, LV_EVENT_ALL, kb);
- lv_obj_add_event_cb(textarea19, textarea_event_cb, LV_EVENT_ALL, kb);
- lv_obj_add_event_cb(textarea20, textarea_event_cb, LV_EVENT_ALL, kb);
- */
- //只添加必要的触发事件
- lv_obj_add_event_cb(textarea1, textarea_event_cb, LV_EVENT_CLICKED, kb);
- lv_obj_add_event_cb(textarea1, textarea_event_cb, LV_EVENT_READY, kb); //添加更多事件
- lv_obj_add_event_cb(textarea1, textarea_event_cb, LV_EVENT_CANCEL, kb);
- lv_obj_add_event_cb(textarea2, textarea_event_cb, LV_EVENT_CLICKED, kb);
- lv_obj_add_event_cb(textarea2, textarea_event_cb, LV_EVENT_READY, kb);
- lv_obj_add_event_cb(textarea2, textarea_event_cb, LV_EVENT_CANCEL, kb);
- lv_obj_add_event_cb(textarea3, textarea_event_cb, LV_EVENT_CLICKED, kb);
- lv_obj_add_event_cb(textarea3, textarea_event_cb, LV_EVENT_READY, kb);
- lv_obj_add_event_cb(textarea3, textarea_event_cb, LV_EVENT_CANCEL, kb);
- lv_obj_add_event_cb(textarea4, textarea_event_cb, LV_EVENT_CLICKED, kb);
- lv_obj_add_event_cb(textarea4, textarea_event_cb, LV_EVENT_READY, kb);
- lv_obj_add_event_cb(textarea4, textarea_event_cb, LV_EVENT_CANCEL, kb);
- lv_obj_add_event_cb(textarea5, textarea_event_cb, LV_EVENT_CLICKED, kb);
- lv_obj_add_event_cb(textarea5, textarea_event_cb, LV_EVENT_READY, kb);
- lv_obj_add_event_cb(textarea5, textarea_event_cb, LV_EVENT_CANCEL, kb);
- lv_obj_add_event_cb(textarea6, textarea_event_cb, LV_EVENT_CLICKED, kb);
- lv_obj_add_event_cb(textarea6, textarea_event_cb, LV_EVENT_READY, kb);
- lv_obj_add_event_cb(textarea6, textarea_event_cb, LV_EVENT_CANCEL, kb);
- lv_obj_add_event_cb(textarea7, textarea_event_cb, LV_EVENT_CLICKED, kb);
- lv_obj_add_event_cb(textarea7, textarea_event_cb, LV_EVENT_READY, kb);
- lv_obj_add_event_cb(textarea7, textarea_event_cb, LV_EVENT_CANCEL, kb);
- lv_obj_add_event_cb(textarea8, textarea_event_cb, LV_EVENT_CLICKED, kb);
- lv_obj_add_event_cb(textarea8, textarea_event_cb, LV_EVENT_READY, kb);
- lv_obj_add_event_cb(textarea8, textarea_event_cb, LV_EVENT_CANCEL, kb);
- lv_obj_add_event_cb(textarea9, textarea_event_cb, LV_EVENT_CLICKED, kb);
- lv_obj_add_event_cb(textarea9, textarea_event_cb, LV_EVENT_READY, kb);
- lv_obj_add_event_cb(textarea9, textarea_event_cb, LV_EVENT_CANCEL, kb);
- lv_obj_add_event_cb(textarea10, textarea_event_cb, LV_EVENT_CLICKED, kb);
- lv_obj_add_event_cb(textarea10, textarea_event_cb, LV_EVENT_READY, kb);
- lv_obj_add_event_cb(textarea10, textarea_event_cb, LV_EVENT_CANCEL, kb);
- lv_obj_add_event_cb(textarea11, textarea_event_cb, LV_EVENT_CLICKED, kb);
- lv_obj_add_event_cb(textarea11, textarea_event_cb, LV_EVENT_READY, kb);
- lv_obj_add_event_cb(textarea11, textarea_event_cb, LV_EVENT_CANCEL, kb);
- lv_obj_add_event_cb(textarea12, textarea_event_cb, LV_EVENT_CLICKED, kb);
- lv_obj_add_event_cb(textarea12, textarea_event_cb, LV_EVENT_READY, kb);
- lv_obj_add_event_cb(textarea12, textarea_event_cb, LV_EVENT_CANCEL, kb);
- lv_obj_add_event_cb(textarea13, textarea_event_cb, LV_EVENT_CLICKED, kb);
- lv_obj_add_event_cb(textarea13, textarea_event_cb, LV_EVENT_READY, kb);
- lv_obj_add_event_cb(textarea13, textarea_event_cb, LV_EVENT_CANCEL, kb);
- lv_obj_add_event_cb(textarea14, textarea_event_cb, LV_EVENT_CLICKED, kb);
- lv_obj_add_event_cb(textarea14, textarea_event_cb, LV_EVENT_READY, kb);
- lv_obj_add_event_cb(textarea14, textarea_event_cb, LV_EVENT_CANCEL, kb);
- lv_obj_add_event_cb(textarea15, textarea_event_cb, LV_EVENT_CLICKED, kb);
- lv_obj_add_event_cb(textarea15, textarea_event_cb, LV_EVENT_READY, kb);
- lv_obj_add_event_cb(textarea15, textarea_event_cb, LV_EVENT_CANCEL, kb);
- lv_obj_add_event_cb(textarea16, textarea_event_cb, LV_EVENT_CLICKED, kb);
- lv_obj_add_event_cb(textarea16, textarea_event_cb, LV_EVENT_READY, kb);
- lv_obj_add_event_cb(textarea16, textarea_event_cb, LV_EVENT_CANCEL, kb);
- lv_obj_add_event_cb(textarea17, textarea_event_cb, LV_EVENT_CLICKED, kb);
- lv_obj_add_event_cb(textarea17, textarea_event_cb, LV_EVENT_READY, kb);
- lv_obj_add_event_cb(textarea17, textarea_event_cb, LV_EVENT_CANCEL, kb);
- lv_obj_add_event_cb(textarea18, textarea_event_cb, LV_EVENT_CLICKED, kb);
- lv_obj_add_event_cb(textarea18, textarea_event_cb, LV_EVENT_READY, kb);
- lv_obj_add_event_cb(textarea18, textarea_event_cb, LV_EVENT_CANCEL, kb);
- lv_obj_add_event_cb(textarea19, textarea_event_cb, LV_EVENT_CLICKED, kb);
- lv_obj_add_event_cb(textarea19, textarea_event_cb, LV_EVENT_READY, kb);
- lv_obj_add_event_cb(textarea19, textarea_event_cb, LV_EVENT_CANCEL, kb);
- lv_obj_add_event_cb(textarea20, textarea_event_cb, LV_EVENT_CLICKED, kb);
- lv_obj_add_event_cb(textarea20, textarea_event_cb, LV_EVENT_READY, kb);
- lv_obj_add_event_cb(textarea20, textarea_event_cb, LV_EVENT_CANCEL, kb);
- userData[0] = lv_obj_get_child_id(return_btn); //获取各个子对象的id;
- userData[1] = lv_obj_get_child_id(save_btn);
- //userData[2] = lv_obj_get_child_id(setPage_con);
-
- lv_obj_add_event_cb(return_btn, btn_event_cb, LV_EVENT_CLICKED, userData);
- lv_obj_add_event_cb(save_btn, btn_event_cb, LV_EVENT_CLICKED, userData);
- }
复制代码
|
|