summaryrefslogtreecommitdiff
path: root/bsp
diff options
context:
space:
mode:
authorJianting (Meco) Man <[email protected]>2021-10-18 12:41:21 -0500
committerGitHub <[email protected]>2021-10-18 12:41:21 -0500
commit4ac91e3deca1b5e8db2071e2ca978616c1410f91 (patch)
treea045f783d609cb3b0459270ec2720fcd4f05e1a6 /bsp
parent21ef60c80b468f62c69e767aadaaaf5dc98a4eaa (diff)
parent655d8dc768484917a0ae056f9d46a3ddf725a241 (diff)
Merge pull request #59 from mysterywolf/l475
[bsp][stm32][l475] add lcd_fill_array()
Diffstat (limited to 'bsp')
-rw-r--r--bsp/stm32/stm32l475-atk-pandora/board/ports/drv_lcd.c61
-rw-r--r--bsp/stm32/stm32l475-atk-pandora/board/ports/drv_lcd.h2
2 files changed, 56 insertions, 7 deletions
diff --git a/bsp/stm32/stm32l475-atk-pandora/board/ports/drv_lcd.c b/bsp/stm32/stm32l475-atk-pandora/board/ports/drv_lcd.c
index 6ec90f880c..7a48c7e7e6 100644
--- a/bsp/stm32/stm32l475-atk-pandora/board/ports/drv_lcd.c
+++ b/bsp/stm32/stm32l475-atk-pandora/board/ports/drv_lcd.c
@@ -8,17 +8,17 @@
* 2018-08-14 flybreak the first version
* 2018-09-18 balanceTWK add sleep mode function
* 2018-09-27 ZYLX optimized display speed
+ * 2021-10-17 Meco Man add lcd_fill_array()
*/
#include <rtdevice.h>
#include "drv_spi.h"
-#include "drv_lcd.h"
+#include <drv_lcd.h>
#include "drv_lcd_font.h"
-#include "drv_gpio.h"
+#include <drv_gpio.h>
-#define DBG_SECTION_NAME "LCD"
-#define DBG_COLOR
-#define DBG_LEVEL DBG_LOG
+#define DBG_TAG "drv.lcd"
+#define DBG_LVL DBG_INFO
#include <rtdbg.h>
#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
rt_uint32_t size = 0, size_remain = 0;
rt_uint8_t *fill_buf = RT_NULL;
- size = (x_end - x_start) * (y_end - y_start) * 2;
+ size = (x_end - x_start + 1) * (y_end - y_start + 1) * 2;
if (size > LCD_CLEAR_SEND_NUMBER)
{
@@ -427,6 +427,55 @@ void lcd_fill(rt_uint16_t x_start, rt_uint16_t y_start, rt_uint16_t x_end, rt_ui
}
/**
+ * full color array on the lcd.
+ *
+ * @param x_start start of x position
+ * @param y_start start of y position
+ * @param x_end end of x position
+ * @param y_end end of y position
+ * @param color Fill color array's pointer
+ *
+ * @return void
+ */
+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)
+{
+ rt_uint32_t size = 0, size_remain = 0;
+
+ size = (x_end - x_start + 1) * (y_end - y_start + 1) * 2;
+
+ if (size > LCD_CLEAR_SEND_NUMBER)
+ {
+ /* the number of remaining to be filled */
+ size_remain = size - LCD_CLEAR_SEND_NUMBER;
+ size = LCD_CLEAR_SEND_NUMBER;
+ }
+
+ lcd_address_set(x_start, y_start, x_end, y_end);
+
+ /* fast fill */
+ while (1)
+ {
+ rt_pin_write(LCD_DC_PIN, PIN_HIGH);
+ rt_spi_send(spi_dev_lcd, pcolor, size);
+
+ /* Fill completed */
+ if (size_remain == 0)
+ break;
+
+ /* calculate the number of fill next time */
+ if (size_remain > LCD_CLEAR_SEND_NUMBER)
+ {
+ size_remain = size_remain - LCD_CLEAR_SEND_NUMBER;
+ }
+ else
+ {
+ size = size_remain;
+ size_remain = 0;
+ }
+ }
+}
+
+/**
* display a line on the lcd.
*
* @param x1 x1 position
diff --git a/bsp/stm32/stm32l475-atk-pandora/board/ports/drv_lcd.h b/bsp/stm32/stm32l475-atk-pandora/board/ports/drv_lcd.h
index 394305012e..021c010f20 100644
--- a/bsp/stm32/stm32l475-atk-pandora/board/ports/drv_lcd.h
+++ b/bsp/stm32/stm32l475-atk-pandora/board/ports/drv_lcd.h
@@ -50,7 +50,7 @@ void lcd_draw_circle(rt_uint16_t x0, rt_uint16_t y0, rt_uint8_t r);
void lcd_draw_line(rt_uint16_t x1, rt_uint16_t y1, rt_uint16_t x2, rt_uint16_t y2);
void lcd_draw_rectangle(rt_uint16_t x1, rt_uint16_t y1, rt_uint16_t x2, rt_uint16_t y2);
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);
-
+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);
void lcd_show_num(rt_uint16_t x, rt_uint16_t y, rt_uint32_t num, rt_uint8_t len, rt_uint32_t size);
rt_err_t lcd_show_string(rt_uint16_t x, rt_uint16_t y, rt_uint32_t size, const char *fmt, ...);
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);