当前位置:网站首页>[luatos-air551g] 6.2 repair: restart caused by line drawing
[luatos-air551g] 6.2 repair: restart caused by line drawing
2022-07-06 08:17:00 【Birds hate fish】
Preface
Solve the problem of drawing the starting and ending points of lines x or y If the coordinates are the same, there will be a restart problem .
problem
[2022-02-12 15:21:18.439] I/user.74 23 69 23
[2022-02-12 15:21:18.455] Guru Meditation Error: Core 0 panic'ed (Store access fault). Exception was unhandled.
[2022-02-12 15:28:01.448] I/user.68 64 64 64
[2022-02-12 15:28:01.448] Guru Meditation Error: Core 0 panic'ed (Store access fault). Exception was unhandled.
[2022-02-12 15:30:12.171] I/user.64 64 58 64
[2022-02-12 15:30:12.202] Guru Meditation Error: Core 0 panic'ed (Store access fault). Exception was unhandled.
When using lcd.drawline() when , If you enter the coordinates x perhaps y identical , Will cause a restart , I don't know how to solve this at present
solve
lcd.drawLine(64,64,59,64,0xf000) Unable to run
lcd.drawLine(59,64,64,64,0xf000) Can run
It seems to be the same x Or the same y It can only be from the point with small coordinate value to the point with large coordinate value .
Just add a function to exchange the positions of two points
-- Used when lcd When drawing lines , The horizontal and vertical coordinates are the same, from small points to large points
function judge_lcd_xy_same(x1,y1,x2,y2)
if x1 == x2 then
if y1>y2 then
temp = y1
y1 = y2
y2 = temp
end
end
if y1 == y2 then
if x1>x2 then
temp = x1
x1 = x2
x2 = temp
end
end
return x1,y1,x2,y2
end
Source code
int luat_lcd_draw_line(luat_lcd_conf_t* conf,uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2,uint32_t color){
uint16_t t;
uint32_t i = 0;
int xerr = 0, yerr = 0, delta_x, delta_y, distance;
int incx, incy, row, col;
if (x1 == x2 || y1 == y2)
{
/* fast draw transverse line */
luat_lcd_set_address(conf,x1, y1, x2, y2);
size_t dots = (x2 - x1 + 1) * (y2 - y1 + 1);// Number of points
uint8_t* line_buf = (uint8_t*)luat_heap_malloc(dots * 2);
for (i = 0; i < dots; i++)
{
line_buf[2 * i] = color >> 8;
line_buf[2 * i + 1] = color;
}
luat_gpio_set(conf->pin_dc, Luat_GPIO_HIGH);
if (conf->port == LUAT_LCD_SPI_DEVICE){
luat_spi_device_send((luat_spi_device_t*)(conf->userdata), (const char*)line_buf, dots * 2);
}else{
luat_spi_send(conf->port, (const char*)line_buf, dots * 2);
}
luat_heap_free(line_buf);
return 0;
}
delta_x = x2 - x1;
delta_y = y2 - y1;
row = x1;
col = y1;
if (delta_x > 0)incx = 1;
else if (delta_x == 0)incx = 0;
else
{
incx = -1;
delta_x = -delta_x;
}
if (delta_y > 0)incy = 1;
else if (delta_y == 0)incy = 0;
else
{
incy = -1;
delta_y = -delta_y;
}
if (delta_x > delta_y)distance = delta_x;
else distance = delta_y;
for (t = 0; t <= distance + 1; t++)
{
luat_lcd_draw_point(conf,row, col,color);
xerr += delta_x ;
yerr += delta_y ;
if (xerr > distance)
{
xerr -= distance;
row += incx;
}
if (yerr > distance)
{
yerr -= distance;
col += incy;
}
}
return 0;
}
边栏推荐
- Circular reference of ES6 module
- Go learning notes (3) basic types and statements (2)
- The ECU of 21 Audi q5l 45tfsi brushes is upgraded to master special adjustment, and the horsepower is safely and stably increased to 305 horsepower
- 备份与恢复 CR 介绍
- 指针进阶---指针数组,数组指针
- MFC 给列表控件发送左键单击、双击、以及右键单击消息
- Easy to use tcp-udp_ Debug tool download and use
- The Vice Minister of the Ministry of industry and information technology of "APEC industry +" of the national economic and information technology center led a team to Sichuan to investigate the operat
- 从 SQL 文件迁移数据到 TiDB
- Upgrade tidb with tiup
猜你喜欢
21. Delete data
ESP series pin description diagram summary
Analysis of pointer and array written test questions
The ECU of 21 Audi q5l 45tfsi brushes is upgraded to master special adjustment, and the horsepower is safely and stably increased to 305 horsepower
hcip--mpls
Résumé des diagrammes de description des broches de la série ESP
Understanding of law of large numbers and central limit theorem
The ECU of 21 Audi q5l 45tfsi brushes is upgraded to master special adjustment, and the horsepower is safely and stably increased to 305 horsepower
在 uniapp 中使用阿里图标
Hcip day 16
随机推荐
Step by step guide to setting NFT as an ens profile Avatar
好用的TCP-UDP_debug工具下载和使用
Flash return file download
Erc20 token agreement
Webrtc series-h.264 estimated bit rate calculation
Asia Pacific Financial Media | "APEC industry +" Western Silicon Valley invests 2trillion yuan in Chengdu Chongqing economic circle to catch up with Shanghai | stable strategy industry fund observatio
Pyqt5 development tips - obtain Manhattan distance between coordinates
The ECU of 21 Audi q5l 45tfsi brushes is upgraded to master special adjustment, and the horsepower is safely and stably increased to 305 horsepower
化不掉的钟薛高,逃不出网红产品的生命周期
Epoll and IO multiplexing of redis
Nft智能合约发行,盲盒,公开发售技术实战--合约篇
Use dumping to back up tidb cluster data to S3 compatible storage
The ECU of 21 Audi q5l 45tfsi brushes is upgraded to master special adjustment, and the horsepower is safely and stably increased to 305 horsepower
What is the use of entering the critical point? How to realize STM32 single chip microcomputer?
JS select all and tab bar switching, simple comments
matplotlib. Widgets are easy to use
CAD ARX gets the current viewport settings
[Yugong series] creation of 009 unity object of U3D full stack class in February 2022
Artcube information of "designer universe": Guangzhou implements the community designer system to achieve "great improvement" of urban quality | national economic and Information Center
flask返回文件下载