Skip to content

Commit da77588

Browse files
committed
Working on reorganizing the lcd bus drivers
The remodel of the bus drivers is to allow for better handling of each of the bus types on a per MCU/board basis. I am also expanding the software rotation in the RGB bus driver to allow its use across all bus types. I have added RGB888 dithering and RGB565 dithering that will be able to be used with or without rotation. rgb565 byte swap is being added in a manner that will allow only a single iteration over the frame buffer data is either software rotation is being used or dithering is being used or both. For memory constrained ESP32 boards I have to work out a way to handle the transmitting of the frame buffer without needing to allocate additional buffers. Ideally it is going to be best to create smaller buffers to allow the allocation of at least 1 additional frame buffer. Ideally if 2additional frame buffers are able to be allocated, in DMA memory space it would be best so while one buffer is transmitting the data is able to be copied into the second buffer. If only 1 buffer is able to be allocated, then None of the buffers will need to be allocated in DMA memory. This will at the very least give a performance boost because LVGL is going to be able to render to one of the user supplied buffers without being interrupted at all from ISRs during the sending to a display. This is because the sending to the display is going to be done on the second core even if 1 buffer is used for sending and that buffer is not in DMA memory. I need to put some thought into how to handle the buffer allocation in the best way as I don't want to add anything that can be confusing for the user. If everything works like I am hoping things should actually get a little easier to use because the user is not going to be given the ability to specify the type of memory a buffer has to be allocated in. The user will be able to simply create bytearrays for the frame buffers and pass memoryview instances pointing to those bytearrays to the display driver. The CI is going to fail for this commit. The code is not finished yet.
1 parent 7d783f5 commit da77588

167 files changed

Lines changed: 4273 additions & 2525 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

ext_mod/lcd_bus/bitbang/inc/i80.h

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
// Copyright (c) 2024 - 2025 Kevin G. Schlosser
2+
3+
#include "lcd_bus.h"
4+
#include "lcd_types.h"
5+
6+
// port includes
7+
#include "mphalport.h"
8+
9+
// micropython includes
10+
#include "py/obj.h"
11+
#include "py/objarray.h"
12+
#include "py/runtime.h"
13+
14+
15+
#ifndef __I80_H__
16+
#define __I80_H__
17+
18+
typedef struct {
19+
/*
20+
* GPIO used for CS line, set to -1 will declaim
21+
* exclusively use of I80 bus
22+
*/
23+
mp_hal_pin_obj_t cs_gpio_num;
24+
25+
/*
26+
* User private data, passed directly to
27+
* on_color_trans_done's user_ctx
28+
*/
29+
void *user_ctx;
30+
31+
/* Bit-width of LCD command */
32+
int lcd_cmd_bits;
33+
34+
/* Bit-width of LCD parameter */
35+
int lcd_param_bits;
36+
37+
/* Each i80 device might have its own D/C control logic */
38+
struct {
39+
/* Level of DC line in IDLE phase */
40+
unsigned int dc_idle_level: 1;
41+
42+
/* Level of DC line in CMD phase */
43+
unsigned int dc_cmd_level: 1;
44+
45+
/* Level of DC line in DUMMY phase */
46+
unsigned int dc_dummy_level: 1;
47+
48+
/* Level of DC line in DATA phase */
49+
unsigned int dc_data_level: 1;
50+
} dc_levels;
51+
52+
/* Panel IO config flags */
53+
struct {
54+
/*
55+
* If set, a high level of CS line will select the device,
56+
* otherwise, CS line is low level active
57+
*/
58+
unsigned int cs_active_high: 1;
59+
60+
/* Reverse the data bits, D[N:0] -> D[0:N] */
61+
unsigned int reverse_color_bits: 1;
62+
63+
/* Swap adjacent two color bytes */
64+
unsigned int swap_color_bytes: 1;
65+
66+
/*
67+
* The display will write data lines when there's a falling
68+
* edge on WR signal (a.k.a the PCLK)
69+
*/
70+
unsigned int pclk_active_neg: 1;
71+
72+
/*
73+
* The WR signal (a.k.a the PCLK)
74+
* stays at low level in IDLE phase
75+
*/
76+
unsigned int pclk_idle_low: 1;
77+
} flags;
78+
79+
} lcd_panel_io_i80_config_t;
80+
81+
82+
typedef struct _lcd_i80_bus_handle_t{
83+
/* GPIO used for D/C line */
84+
mp_hal_pin_obj_t dc_gpio_num;
85+
86+
/* GPIO used for WR line */
87+
mp_hal_pin_obj_t wr_gpio_num;
88+
89+
/* GPIOs used for data lines */
90+
mp_hal_pin_obj_t data_gpio_nums[16];
91+
92+
/* Number of data lines, 8 or 16 */
93+
size_t bus_width;
94+
95+
/*
96+
* Maximum transfer size, this determines
97+
* the length of internal DMA link
98+
*/
99+
size_t max_transfer_bytes;
100+
101+
/* DMA transfer alignment for data allocated from PSRAM */
102+
size_t psram_trans_align;
103+
104+
/* DMA transfer alignment for data allocated from SRAM */
105+
size_t sram_trans_align;
106+
} lcd_i80_bus_config_t;
107+
108+
struct _mp_lcd_i80_bus_obj_t {
109+
mp_obj_base_t base;
110+
111+
mp_obj_t callback;
112+
113+
void *buf1;
114+
void *buf2;
115+
116+
bool trans_done;
117+
bool rgb565_byte_swap;
118+
119+
lcd_panel_io_t panel_io_handle;
120+
121+
lcd_panel_io_i80_config_t panel_io_config;
122+
lcd_i80_bus_config_t bus_config;
123+
void *bus_handle;
124+
125+
uint32_t buffer_size;
126+
uint8_t bpp;
127+
128+
void (*write_color)(mp_lcd_i80_bus_obj_t *self, void *color, size_t color_size);
129+
};
130+
131+
#endif

0 commit comments

Comments
 (0)