问题:RT-Thread 绘制屏幕时,函数执行完毕无法返回。
对MCU开发不熟,找不出原因,请帮忙。
代码:
- void mos_main()
- {
- rt_thread_t thread ;
- thread = rt_thread_create("gui",
- m_gui_thread_entry, RT_NULL,
- 8192, 26, 7);
-
- if (thread != RT_NULL)
- rt_thread_startup(thread);
-
- thread = rt_thread_create("event",
- m_event_thread_entry, RT_NULL,
- 512, 1, 7);
-
- if (thread != RT_NULL)
- rt_thread_startup(thread);
- }
- void gui_menu_entry(void)
- {
- mos_form_t form;
- mos_button_t button;
- mos_rect_t rect = {10,10,40,35};
- mos_point_t point = {5,60};
-
- mos_create_form(&form);
- form.parent.handler = ui_menu_handler;
-
- mos_create_button(&button, rect);
- button.parent.paint(&button.parent);
-
- mos_draw_text(point,"Please Enter Password:");
- point.y += 25;
- mos_draw_text(point, "ABCDEFGHIJKLMNOPQRSTUVWXYZ");
- point.y += 25;
- mos_draw_text(point, "123567890~`!@#$%^&*()_+:;"");
- point.y += 25;
- mos_draw_text(point, "'{]}[|\\<>?/.,\1");
-
- form.doLoop(&form);
- }
- void mos_draw_text(mos_point_t location, char* text)
- {
- mos_font_data_t* font;
- rt_uint16_t buff[MDF_ASC24GRY_WIDTH * MDF_ASC24GRY_HEIGHT];
- mos_rect_t rect;
- rect.x1=location.x;
- rect.y1= location.y;
- rect.y2= location.y + MDF_ASC24GRY_HEIGHT - 1;
-
- while(*text)
- {
- font = mos_font_asc24gray[*text];
- rect.x2= rect.x1 + font->width - 1;
-
- mos_batch_gray2rbg565p((const char*)font->data, &buff[0], font->width * MDF_ASC24GRY_HEIGHT * 4 / 8, MDF_ASC24GRY_WIDTH * MDF_ASC24GRY_HEIGHT);
- mos_blit_box((const char*)&buff[0], rect);
- text++;
- rect.x1 += font->width;
- }
- }
- void mos_gray2rgb565p(char src, mos_color_t* dst)
- {
- mos_color_t c255;
- //c255 = (0xf - src) << 4;
- c255 = src << 4;
- c255 = ((c255 >> 3) << 11) | ((c255 >> 2) << 5) | (c255 >> 3);
- *dst = c255;
- }
- void mos_batch_gray2rbg565p(const char* src, mos_color_t* dst, rt_size_t byteSize, rt_size_t maxBytes)
- {
- if (byteSize > maxBytes)
- {
- rt_kprintf("size override.");
- return;
- }
- while(byteSize--)
- {
- mos_gray2rgb565p((*src) >> 4, dst++);
- mos_gray2rgb565p((*src) & 0xf, dst++);
- src++;
- }
- }
- // char ~
- const unsigned char mos_font_asc24gray_7E_dat[] = {
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x00,0x00,0x00,0x0D,0xEF,0xD6,0x0B,
- 0xB0,0x7D,0x00,0xAF,0xFE,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,};
- mos_font_data_t mos_font_asc24gray_7E = {
- 10,24,
- &mos_font_asc24gray_7E_dat[0]};
- // data list
- mos_font_data_t* mos_font_asc24gray[] = {&mos_font_asc24gray_01,&mos_font_asc24gray_01,&mos_font_asc24gray_01,
- &mos_font_asc24gray_01,&mos_font_asc24gray_01,&mos_font_asc24gray_01,&mos_font_asc24gray_01,
- &mos_font_asc24gray_01,&mos_font_asc24gray_01,&mos_font_asc24gray_01,&mos_font_asc24gray_01,
- &mos_font_asc24gray_01,&mos_font_asc24gray_01,&mos_font_asc24gray_01,&mos_font_asc24gray_01,
- &mos_font_asc24gray_01,&mos_font_asc24gray_01,&mos_font_asc24gray_01,&mos_font_asc24gray_01,
- ............
复制代码
调试跟踪,在函数 void mos_draw_text(mos_point_t location, char* text) 执行完毕后,不知道跑哪去了,不能返回上及调用代码。
只显示了一行,后面的代码不执行了。 |