Skip to content

Commit 3641097

Browse files
committed
[stm32l475] update lcd driver
1 parent 5f2f862 commit 3641097

File tree

5 files changed

+27
-17
lines changed

5 files changed

+27
-17
lines changed

bsp/stm32/stm32l475-atk-pandora/board/ports/lcd/SConscript

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@ from building import *
22
import os
33

44
cwd = GetCurrentDir()
5-
src = Glob('*.c')
5+
src = ['drv_lcd.c']
66
CPPPATH = [cwd]
77

88
if GetDepend(['BSP_USING_LCD_QRCODE']):
9-
src = src + Glob('lcd_qrcode.c')
9+
src = src + ['lcd_qrcode.c']
1010

1111
if GetDepend(['BSP_USING_LCD_SAMPLE']):
12-
src = src + Glob('demo/lcd_sample.c')
12+
src = src + ['demo/lcd_sample.c']
1313

1414
group = DefineGroup('Drivers', src, depend = ['BSP_USING_SPI_LCD'], CPPPATH = CPPPATH)
1515

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

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@
1616
#include <drv_gpio.h>
1717
#include <drv_spi.h>
1818
#include "drv_lcd.h"
19+
#ifndef BSP_USING_LVGL
1920
#include "drv_lcd_font.h"
21+
#endif /* BSP_USING_LVGL */
2022

2123
#define DBG_TAG "drv.lcd"
2224
#define DBG_LVL DBG_INFO
@@ -25,9 +27,11 @@
2527
#define LCD_PWR_PIN GET_PIN(B, 7)
2628
#define LCD_DC_PIN GET_PIN(B, 4)
2729
#define LCD_RES_PIN GET_PIN(B, 6)
28-
#define LCD_CLEAR_SEND_NUMBER 5760 /* 240*240/10 */
2930

31+
#ifndef BSP_USING_LVGL
32+
#define LCD_CLEAR_SEND_NUMBER 5760 /* 240*240/10 */
3033
rt_uint16_t BACK_COLOR = WHITE, FORE_COLOR = BLACK;
34+
#endif /* BSP_USING_LVGL */
3135

3236
static struct rt_spi_device *spi_dev_lcd;
3337

@@ -86,6 +90,7 @@ static rt_err_t lcd_write_data(const rt_uint8_t data)
8690
}
8791
}
8892

93+
#ifndef BSP_USING_LVGL
8994
static rt_err_t lcd_write_half_word(const rt_uint16_t da)
9095
{
9196
rt_size_t len;
@@ -106,6 +111,7 @@ static rt_err_t lcd_write_half_word(const rt_uint16_t da)
106111
return RT_EOK;
107112
}
108113
}
114+
#endif /* BSP_USING_LVGL */
109115

110116
static void lcd_gpio_init(void)
111117
{
@@ -214,6 +220,7 @@ static int rt_hw_lcd_init(void)
214220
}
215221
INIT_DEVICE_EXPORT(rt_hw_lcd_init);
216222

223+
#ifndef BSP_USING_LVGL
217224
/**
218225
* Set background color and foreground color
219226
*
@@ -227,6 +234,7 @@ void lcd_set_color(rt_uint16_t back, rt_uint16_t fore)
227234
BACK_COLOR = back;
228235
FORE_COLOR = fore;
229236
}
237+
#endif /* BSP_USING_LVGL */
230238

231239
void lcd_display_on(void)
232240
{
@@ -281,6 +289,7 @@ void lcd_address_set(rt_uint16_t x1, rt_uint16_t y1, rt_uint16_t x2, rt_uint16_t
281289
lcd_write_cmd(0x2C);
282290
}
283291

292+
#ifndef BSP_USING_LVGL
284293
/**
285294
* clear the lcd.
286295
*
@@ -424,6 +433,8 @@ void lcd_fill(rt_uint16_t x_start, rt_uint16_t y_start, rt_uint16_t x_end, rt_ui
424433
}
425434
}
426435
}
436+
#endif /* BSP_USING_LVGL */
437+
427438

428439
/**
429440
* full color array on the lcd.
@@ -446,6 +457,7 @@ void lcd_fill_array(rt_uint16_t x_start, rt_uint16_t y_start, rt_uint16_t x_end,
446457
rt_spi_send(spi_dev_lcd, pcolor, size);
447458
}
448459

460+
#ifndef BSP_USING_LVGL
449461
/**
450462
* display a line on the lcd.
451463
*
@@ -856,3 +868,5 @@ rt_err_t lcd_show_image(rt_uint16_t x, rt_uint16_t y, rt_uint16_t length, rt_uin
856868

857869
return RT_EOK;
858870
}
871+
872+
#endif /* BSP_USING_LVGL */

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

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,19 @@
55
*
66
* Change Logs:
77
* Date Author Notes
8-
* 2018-08-14 flybreak the first version
9-
* 2018-09-18 balanceTWK add sleep mode function
8+
* 2018-08-14 flybreak the first version
9+
* 2018-09-18 balanceTWK add sleep mode function
1010
*/
1111

1212
#ifndef __DRV_LCD_H__
1313
#define __DRV_LCD_H__
1414

1515
#include <rtthread.h>
1616

17-
#ifdef PKG_USING_QRCODE
18-
#include <qrcode.h>
19-
#endif
20-
2117
#define LCD_W 240
2218
#define LCD_H 240
2319

24-
//POINT_COLOR
20+
#ifndef BSP_USING_LVGL
2521
#define WHITE 0xFFFF
2622
#define BLACK 0x0000
2723
#define BLUE 0x001F
@@ -42,25 +38,25 @@
4238
#define GRAY240 0XF79E
4339

4440
extern rt_uint16_t BACK_COLOR, FORE_COLOR;
45-
4641
void lcd_clear(rt_uint16_t color);
47-
void lcd_address_set(rt_uint16_t x1, rt_uint16_t y1, rt_uint16_t x2, rt_uint16_t y2);
4842
void lcd_set_color(rt_uint16_t back, rt_uint16_t fore);
49-
5043
void lcd_draw_point(rt_uint16_t x, rt_uint16_t y);
5144
void lcd_draw_point_color(rt_uint16_t x, rt_uint16_t y, rt_uint16_t color);
5245
void lcd_draw_circle(rt_uint16_t x0, rt_uint16_t y0, rt_uint8_t r);
5346
void lcd_draw_line(rt_uint16_t x1, rt_uint16_t y1, rt_uint16_t x2, rt_uint16_t y2);
5447
void lcd_draw_rectangle(rt_uint16_t x1, rt_uint16_t y1, rt_uint16_t x2, rt_uint16_t y2);
5548
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);
56-
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);
5749
void lcd_show_num(rt_uint16_t x, rt_uint16_t y, rt_uint32_t num, rt_uint8_t len, rt_uint32_t size);
5850
rt_err_t lcd_show_string(rt_uint16_t x, rt_uint16_t y, rt_uint32_t size, const char *fmt, ...);
5951
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);
52+
#endif /* BSP_USING_LVGL */
6053

6154
void lcd_enter_sleep(void);
6255
void lcd_exit_sleep(void);
6356
void lcd_display_on(void);
6457
void lcd_display_off(void);
6558

59+
void lcd_address_set(rt_uint16_t x1, rt_uint16_t y1, rt_uint16_t x2, rt_uint16_t y2);
60+
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);
61+
6662
#endif

bsp/stm32/stm32l475-atk-pandora/board/ports/lcd/lcd_qrcode.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,4 +186,4 @@ rt_err_t lcd_show_qrcode(rt_uint16_t x, rt_uint16_t y, rt_uint8_t version, rt_ui
186186

187187
return result;
188188
}
189-
#endif
189+
#endif /* BSP_USING_LCD_QRCODE */

bsp/stm32/stm32l475-atk-pandora/board/ports/lcd/lcd_qrcode.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
#include <rtconfig.h>
55

6-
#ifdef PKG_USING_QRCODE
6+
#ifdef BSP_USING_LCD_QRCODE
77
#include <rtdef.h>
88
rt_err_t lcd_show_qrcode(rt_uint16_t x, rt_uint16_t y, rt_uint8_t version, rt_uint8_t ecc, const char *data, rt_uint8_t enlargement);
99
#endif

0 commit comments

Comments
 (0)