|
8 | 8 | * 2018-08-14 flybreak the first version
|
9 | 9 | * 2018-09-18 balanceTWK add sleep mode function
|
10 | 10 | * 2018-09-27 ZYLX optimized display speed
|
| 11 | + * 2021-10-17 Meco Man add lcd_fill_array() |
11 | 12 | */
|
12 | 13 |
|
13 | 14 | #include <rtdevice.h>
|
14 | 15 | #include "drv_spi.h"
|
15 |
| -#include "drv_lcd.h" |
| 16 | +#include <drv_lcd.h> |
16 | 17 | #include "drv_lcd_font.h"
|
17 |
| -#include "drv_gpio.h" |
| 18 | +#include <drv_gpio.h> |
18 | 19 |
|
19 |
| -#define DBG_SECTION_NAME "LCD" |
20 |
| -#define DBG_COLOR |
21 |
| -#define DBG_LEVEL DBG_LOG |
| 20 | +#define DBG_TAG "drv.lcd" |
| 21 | +#define DBG_LVL DBG_INFO |
22 | 22 | #include <rtdbg.h>
|
23 | 23 |
|
24 | 24 | #define LCD_PWR_PIN GET_PIN(B, 7)
|
@@ -375,7 +375,7 @@ void lcd_fill(rt_uint16_t x_start, rt_uint16_t y_start, rt_uint16_t x_end, rt_ui
|
375 | 375 | rt_uint32_t size = 0, size_remain = 0;
|
376 | 376 | rt_uint8_t *fill_buf = RT_NULL;
|
377 | 377 |
|
378 |
| - size = (x_end - x_start) * (y_end - y_start) * 2; |
| 378 | + size = (x_end - x_start + 1) * (y_end - y_start + 1) * 2; |
379 | 379 |
|
380 | 380 | if (size > LCD_CLEAR_SEND_NUMBER)
|
381 | 381 | {
|
@@ -426,6 +426,55 @@ void lcd_fill(rt_uint16_t x_start, rt_uint16_t y_start, rt_uint16_t x_end, rt_ui
|
426 | 426 | }
|
427 | 427 | }
|
428 | 428 |
|
| 429 | +/** |
| 430 | + * full color array on the lcd. |
| 431 | + * |
| 432 | + * @param x_start start of x position |
| 433 | + * @param y_start start of y position |
| 434 | + * @param x_end end of x position |
| 435 | + * @param y_end end of y position |
| 436 | + * @param color Fill color array's pointer |
| 437 | + * |
| 438 | + * @return void |
| 439 | + */ |
| 440 | +void lcd_fill_array(rt_uint16_t x_start, rt_uint16_t y_start, rt_uint16_t x_end, rt_uint16_t y_end, void *pcolor) |
| 441 | +{ |
| 442 | + rt_uint32_t size = 0, size_remain = 0; |
| 443 | + |
| 444 | + size = (x_end - x_start + 1) * (y_end - y_start + 1) * 2; |
| 445 | + |
| 446 | + if (size > LCD_CLEAR_SEND_NUMBER) |
| 447 | + { |
| 448 | + /* the number of remaining to be filled */ |
| 449 | + size_remain = size - LCD_CLEAR_SEND_NUMBER; |
| 450 | + size = LCD_CLEAR_SEND_NUMBER; |
| 451 | + } |
| 452 | + |
| 453 | + lcd_address_set(x_start, y_start, x_end, y_end); |
| 454 | + |
| 455 | + /* fast fill */ |
| 456 | + while (1) |
| 457 | + { |
| 458 | + rt_pin_write(LCD_DC_PIN, PIN_HIGH); |
| 459 | + rt_spi_send(spi_dev_lcd, pcolor, size); |
| 460 | + |
| 461 | + /* Fill completed */ |
| 462 | + if (size_remain == 0) |
| 463 | + break; |
| 464 | + |
| 465 | + /* calculate the number of fill next time */ |
| 466 | + if (size_remain > LCD_CLEAR_SEND_NUMBER) |
| 467 | + { |
| 468 | + size_remain = size_remain - LCD_CLEAR_SEND_NUMBER; |
| 469 | + } |
| 470 | + else |
| 471 | + { |
| 472 | + size = size_remain; |
| 473 | + size_remain = 0; |
| 474 | + } |
| 475 | + } |
| 476 | +} |
| 477 | + |
429 | 478 | /**
|
430 | 479 | * display a line on the lcd.
|
431 | 480 | *
|
|
0 commit comments