Skip to content

Commit 4ac91e3

Browse files
authored
Merge pull request #59 from mysterywolf/l475
[bsp][stm32][l475] add lcd_fill_array()
2 parents 21ef60c + 655d8dc commit 4ac91e3

File tree

2 files changed

+56
-7
lines changed

2 files changed

+56
-7
lines changed

bsp/stm32/stm32l475-atk-pandora/board/ports/drv_lcd.c

+55-6
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,17 @@
88
* 2018-08-14 flybreak the first version
99
* 2018-09-18 balanceTWK add sleep mode function
1010
* 2018-09-27 ZYLX optimized display speed
11+
* 2021-10-17 Meco Man add lcd_fill_array()
1112
*/
1213

1314
#include <rtdevice.h>
1415
#include "drv_spi.h"
15-
#include "drv_lcd.h"
16+
#include <drv_lcd.h>
1617
#include "drv_lcd_font.h"
17-
#include "drv_gpio.h"
18+
#include <drv_gpio.h>
1819

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
2222
#include <rtdbg.h>
2323

2424
#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
375375
rt_uint32_t size = 0, size_remain = 0;
376376
rt_uint8_t *fill_buf = RT_NULL;
377377

378-
size = (x_end - x_start) * (y_end - y_start) * 2;
378+
size = (x_end - x_start + 1) * (y_end - y_start + 1) * 2;
379379

380380
if (size > LCD_CLEAR_SEND_NUMBER)
381381
{
@@ -426,6 +426,55 @@ void lcd_fill(rt_uint16_t x_start, rt_uint16_t y_start, rt_uint16_t x_end, rt_ui
426426
}
427427
}
428428

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+
429478
/**
430479
* display a line on the lcd.
431480
*

bsp/stm32/stm32l475-atk-pandora/board/ports/drv_lcd.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ void lcd_draw_circle(rt_uint16_t x0, rt_uint16_t y0, rt_uint8_t r);
5050
void lcd_draw_line(rt_uint16_t x1, rt_uint16_t y1, rt_uint16_t x2, rt_uint16_t y2);
5151
void lcd_draw_rectangle(rt_uint16_t x1, rt_uint16_t y1, rt_uint16_t x2, rt_uint16_t y2);
5252
void lcd_fill(rt_uint16_t x_start, rt_uint16_t y_start, rt_uint16_t x_end, rt_uint16_t y_end, rt_uint16_t color);
53-
53+
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);
5454
void lcd_show_num(rt_uint16_t x, rt_uint16_t y, rt_uint32_t num, rt_uint8_t len, rt_uint32_t size);
5555
rt_err_t lcd_show_string(rt_uint16_t x, rt_uint16_t y, rt_uint32_t size, const char *fmt, ...);
5656
rt_err_t lcd_show_image(rt_uint16_t x, rt_uint16_t y, rt_uint16_t length, rt_uint16_t wide, const rt_uint8_t *p);

0 commit comments

Comments
 (0)