Skip to content

Commit 3e51194

Browse files
Feature/setup lcd init: bring up lvgl and integrate based lcd driver into picomotion (#17)
* initial changes to support LCD on pico * finished initial lcd setup * Auto format code with clang-format --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
1 parent eba1aca commit 3e51194

File tree

15 files changed

+1718
-9
lines changed

15 files changed

+1718
-9
lines changed

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
[submodule "extern/pico-sdk"]
22
path = extern/pico-sdk
33
url = https://github.com/raspberrypi/pico-sdk.git
4+
[submodule "extern/lvgl"]
5+
path = extern/lvgl
6+
url = https://github.com/lvgl/lvgl.git

CMakeLists.txt

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,22 @@ project(picomotion VERSION 1.0
1212
pico_sdk_init()
1313
# rest of your project
1414
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
15+
set(LV_CONF_PATH "${CMAKE_SOURCE_DIR}/include/lv_config/lv_conf.h")
1516

1617
add_subdirectory(src/gc9a01)
1718
add_subdirectory(src/qmi8658)
1819
add_subdirectory(src/hwconfig)
20+
add_subdirectory(extern/lvgl)
21+
add_subdirectory(src/gui)
22+
23+
# lvgl stuff
24+
include_directories(
25+
${CMAKE_SOURCE_DIR}/include/lv_config
26+
extern/lvgl
27+
extern/lvgl/src
28+
)
29+
30+
message(STATUS "Including lv_conf.h from ${LV_CONF_PATH} If there are compilation errors related to lv_conf.h, please check that this file is correctly configured according to your needs and that it is in the correct directory.")
1931

2032
add_executable(picomotion
2133
app/picomotion.c
@@ -28,7 +40,9 @@ target_link_libraries(picomotion
2840
hardware_i2c
2941
hwconfig
3042
qmi8658
31-
# gc9a01
43+
lvgl
44+
gc9a01
45+
gui
3246
)
3347

3448
# enable both usb and main

app/picomotion.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,15 @@
33
#include "sys_common.h"
44
#include <stdint.h>
55
#include <stdio.h>
6+
#include "gc9a01.h"
67

78
int main() {
89
stdio_init_all();
910
gprintf(DEBUG, "\n\033[2J\n"); // CLEAR SCREEN CMD
1011
init_hardware();
1112
configure_hardware();
13+
LCD_1IN28_Init(HORIZONTAL);
14+
LCD_1IN28_Clear(WHITE);
1215
int16_t raw_accel[3];
1316
int16_t raw_gyro[3];
1417
uint64_t time_count;

extern/lvgl

Submodule lvgl added at 38b0195

include/gc9a01/gc9a01.h

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#ifndef __LCD_1IN28_H
2+
#define __LCD_1IN28_H
3+
4+
#include <stdint.h>
5+
6+
#include <stdio.h>
7+
#include <stdlib.h> //itoa()
8+
9+
#define HORIZONTAL 0
10+
#define VERTICAL 1
11+
12+
#define WHITE 0xFFFF
13+
#define BLACK 0x0000
14+
#define BLUE 0x001F
15+
#define BRED 0XF81F
16+
#define GRED 0XFFE0
17+
#define GBLUE 0X07FF
18+
#define RED 0xF800
19+
#define MAGENTA 0xF81F
20+
#define GREEN 0x07E0
21+
#define CYAN 0x7FFF
22+
#define YELLOW 0xFFE0
23+
#define BROWN 0XBC40
24+
#define BRRED 0XFC07
25+
#define GRAY 0X8430
26+
#define DARKBLUE 0X01CF
27+
#define LIGHTBLUE 0X7D7C
28+
#define GRAYBLUE 0X5458
29+
#define LIGHTGREEN 0X841F
30+
#define LGRAY 0XC618
31+
#define LGRAYBLUE 0XA651
32+
#define LBBLUE 0X2B12
33+
typedef struct {
34+
uint16_t WIDTH;
35+
uint16_t HEIGHT;
36+
uint8_t SCAN_DIR;
37+
} LCD_1IN28_ATTRIBUTES;
38+
extern LCD_1IN28_ATTRIBUTES LCD_1IN28;
39+
40+
/********************************************************************************
41+
function:
42+
Macro definition variable name
43+
********************************************************************************/
44+
void LCD_1IN28_Init(uint8_t Scan_dir);
45+
void LCD_1IN28_Clear(uint16_t Color);
46+
void LCD_1IN28_Display(uint16_t* Image);
47+
void LCD_1IN28_DisplayWindows(
48+
uint16_t Xstart, uint16_t Ystart, uint16_t Xend, uint16_t Yend, uint16_t* Image);
49+
void LCD_1IN28_DisplayPoint(uint16_t X, uint16_t Y, uint16_t Color);
50+
51+
void LCD_1IN28_SetWindows(uint16_t Xstart, uint16_t Ystart, uint16_t Xend, uint16_t Yend);
52+
53+
#endif

include/gui/gui.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
2+
#ifndef _GUI_H_
3+
#define _GUI_H_
4+
5+
#define DISP_HOR_RES 240
6+
#define DISP_VER_RES 240
7+
8+
void gui_init(void);
9+
void gui_widgets_init(void);
10+
11+
#endif

include/hwconfig/hw_config.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,25 @@
11
#pragma once
2+
#include "hardware/dma.h"
3+
#include "hardware/spi.h"
24
#include "pico/stdlib.h"
35
#include "sys_common.h"
46

7+
#define PLL_SYS_KHZ (270 * 1000)
8+
#define LCD_SPI_PORT (spi1)
9+
10+
#define LCD_DC_PIN (8)
11+
#define LCD_CS_PIN (9)
12+
#define LCD_CLK_PIN (10)
13+
#define LCD_MOSI_PIN (11)
14+
#define LCD_RST_PIN (12)
15+
#define LCD_BL_PIN (25)
16+
17+
#define LCD_1IN28_HEIGHT 240
18+
#define LCD_1IN28_WIDTH 240
19+
20+
extern dma_channel_config c;
21+
extern uint dma_tx;
22+
523
enum _hw_config_pins {
624
QMI_SDA_PIN = 6,
725
QMI_SCL_PIN = 7,

0 commit comments

Comments
 (0)