forked from xuos/xiuos
fix:test_lcd_edu.c draw line mem overread
This commit is contained in:
parent
779444f998
commit
8a589d0eaa
|
@ -18,8 +18,21 @@ void TestLcd(void)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// draw text
|
|
||||||
LcdWriteParam graph_param;
|
LcdWriteParam graph_param;
|
||||||
|
|
||||||
|
// black
|
||||||
|
uint16* color_select = malloc(sizeof(uint16) * 321 * 321);
|
||||||
|
memset(color_select, 0x00, sizeof(uint16) * 321 * 321);
|
||||||
|
graph_param.type = LCD_DOT_TYPE;
|
||||||
|
graph_param.pixel_info.x_startpos = 0;
|
||||||
|
graph_param.pixel_info.y_startpos = 0;
|
||||||
|
graph_param.pixel_info.x_endpos = 320;
|
||||||
|
graph_param.pixel_info.y_endpos = 320;
|
||||||
|
graph_param.pixel_info.pixel_color = color_select;
|
||||||
|
PrivWrite(lcd_fd, &graph_param, NULL_PARAMETER);
|
||||||
|
free(color_select);
|
||||||
|
|
||||||
|
// draw text
|
||||||
graph_param.type = LCD_STRING_TYPE;
|
graph_param.type = LCD_STRING_TYPE;
|
||||||
graph_param.string_info.x_pos = 0;
|
graph_param.string_info.x_pos = 0;
|
||||||
graph_param.string_info.y_pos = 0;
|
graph_param.string_info.y_pos = 0;
|
||||||
|
@ -29,20 +42,25 @@ void TestLcd(void)
|
||||||
graph_param.string_info.back_color = 0xFFFF;
|
graph_param.string_info.back_color = 0xFFFF;
|
||||||
graph_param.string_info.font_color = 0x0000;
|
graph_param.string_info.font_color = 0x0000;
|
||||||
graph_param.string_info.addr = "hello_world!";
|
graph_param.string_info.addr = "hello_world!";
|
||||||
|
|
||||||
PrivWrite(lcd_fd, &graph_param, NULL_PARAMETER);
|
PrivWrite(lcd_fd, &graph_param, NULL_PARAMETER);
|
||||||
|
|
||||||
uint16 color_select = 0xF800;
|
// draw line
|
||||||
for (int i = 0; i < 5; i++)
|
color_select = malloc(sizeof(uint16) * 1 * 320);
|
||||||
|
for (int i = 0; i < 320; i++)
|
||||||
|
{
|
||||||
|
color_select[i] = 0xF800;
|
||||||
|
}
|
||||||
|
for (int i = 1; i <= 5; i++)
|
||||||
{
|
{
|
||||||
graph_param.type = LCD_DOT_TYPE;
|
graph_param.type = LCD_DOT_TYPE;
|
||||||
graph_param.pixel_info.x_startpos = 0;
|
graph_param.pixel_info.x_startpos = 0;
|
||||||
graph_param.pixel_info.y_startpos = 50 * i;
|
graph_param.pixel_info.y_startpos = i * 50;
|
||||||
graph_param.pixel_info.x_endpos = 320;
|
graph_param.pixel_info.x_endpos = 319;
|
||||||
graph_param.pixel_info.y_endpos = 50 * i;
|
graph_param.pixel_info.y_endpos = i * 50;
|
||||||
graph_param.pixel_info.pixel_color = &color_select;
|
graph_param.pixel_info.pixel_color = color_select;
|
||||||
PrivWrite(lcd_fd, &graph_param, NULL_PARAMETER);
|
PrivWrite(lcd_fd, &graph_param, NULL_PARAMETER);
|
||||||
}
|
}
|
||||||
|
free(color_select);
|
||||||
|
|
||||||
PrivClose(lcd_fd);
|
PrivClose(lcd_fd);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue