Skip to content

Commit 275f817

Browse files
committed
Reorganization of the lcd_bus extension module source and header files.
This needs to be done in order to handle the rotation due to the rotation running on a second core if applicable. We have to separate the MCU's so we have the ability to use the appropriate RTOS that is available for the port being used. It is also a cleaner way to understand what is happening in general with the build. We have the ability to see what is and is not available. This change also adds all busses to all ports and the busses that are not supported will throw an error stating they are not available. This would be a good mechanism to use when determining how to set up the display driver based on the MCU being used. Simple exception catching when starting the display bus will allow the program to determine what board to use. A fantastic use of this is when writing the software on a desktop using the unix port and the final program is going to be run on the ESP32 port.
1 parent 11fae09 commit 275f817

File tree

181 files changed

+2614
-2137
lines changed

Some content is hidden

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

181 files changed

+2614
-2137
lines changed
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
// Copyright (c) 2024 - 2025 Kevin G. Schlosser
2+
3+
#ifndef __I80_BUS_H__
4+
#define __I80_BUS_H__
5+
6+
//local_includes
7+
#include "modlcd_bus.h"
8+
#include "mphalport.h"
9+
10+
// micropython includes
11+
#include "py/obj.h"
12+
#include "py/objarray.h"
13+
#include "py/runtime.h"
14+
15+
typedef struct _lcd_panel_io_i80_config_t {
16+
mp_obj_t cs_gpio_num; /*!< GPIO used for CS line, set to -1 will declaim exclusively use of I80 bus */
17+
void *user_ctx; /*!< User private data, passed directly to on_color_trans_done's user_ctx */
18+
int lcd_cmd_bits; /*!< Bit-width of LCD command */
19+
int lcd_param_bits; /*!< Bit-width of LCD parameter */
20+
struct {
21+
unsigned int dc_idle_level: 1; /*!< Level of DC line in IDLE phase */
22+
unsigned int dc_cmd_level: 1; /*!< Level of DC line in CMD phase */
23+
unsigned int dc_dummy_level: 1; /*!< Level of DC line in DUMMY phase */
24+
unsigned int dc_data_level: 1; /*!< Level of DC line in DATA phase */
25+
} dc_levels; /*!< Each i80 device might have its own D/C control logic */
26+
struct {
27+
unsigned int cs_active_high: 1; /*!< If set, a high level of CS line will select the device, otherwise, CS line is low level active */
28+
unsigned int reverse_color_bits: 1; /*!< Reverse the data bits, D[N:0] -> D[0:N] */
29+
unsigned int swap_color_bytes: 1; /*!< Swap adjacent two color bytes */
30+
unsigned int pclk_active_neg: 1; /*!< The display will write data lines when there's a falling edge on WR signal (a.k.a the PCLK) */
31+
unsigned int pclk_idle_low: 1; /*!< The WR signal (a.k.a the PCLK) stays at low level in IDLE phase */
32+
} flags; /*!< Panel IO config flags */
33+
} lcd_panel_io_i80_config_t;
34+
35+
36+
typedef struct _lcd_i80_bus_handle_t {
37+
mp_obj_t dc_gpio_num; /*!< GPIO used for D/C line */
38+
mp_obj_t wr_gpio_num; /*!< GPIO used for WR line */
39+
mp_obj_t data_gpio_nums[16]; /*!< GPIOs used for data lines */
40+
size_t bus_width; /*!< Number of data lines, 8 or 16 */
41+
size_t max_transfer_bytes; /*!< Maximum transfer size, this determines the length of internal DMA link */
42+
size_t psram_trans_align; /*!< DMA transfer alignment for data allocated from PSRAM */
43+
size_t sram_trans_align; /*!< DMA transfer alignment for data allocated from SRAM */
44+
} lcd_i80_bus_config_t;
45+
46+
47+
typedef struct _mp_lcd_i80_bus_obj_t {
48+
mp_obj_base_t base;
49+
50+
mp_obj_t callback;
51+
52+
void *buf1;
53+
void *buf2;
54+
55+
bool trans_done;
56+
bool rgb565_byte_swap;
57+
58+
lcd_panel_io_t panel_io_handle;
59+
60+
lcd_panel_io_i80_config_t panel_io_config;
61+
lcd_i80_bus_config_t bus_config;
62+
void *bus_handle;
63+
64+
uint32_t buffer_size;
65+
uint8_t bpp;
66+
67+
void (*write_color)(mp_lcd_i80_bus_obj_t *self, void *color, size_t color_size);
68+
} mp_lcd_i80_bus_obj_t;
69+
70+
extern const mp_obj_type_t mp_lcd_i80_bus_type;
71+
#endif /* __I80_BUS_H__ */

ext_mod/lcd_bus/bitbang/src/i80_bus.c

Lines changed: 580 additions & 0 deletions
Large diffs are not rendered by default.

ext_mod/lcd_bus/lcd_types.h renamed to ext_mod/lcd_bus/common/include/lcd_types.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright (c) 2024 - 2025 Kevin G. Schlosser
22

3-
#ifndef _LCD_TYPES_H_
4-
#define _LCD_TYPES_H_
3+
#ifndef __LCD_TYPES_H__
4+
#define __LCD_TYPES_H__
55

66
#define LCD_UNUSED(x) ((void)x)
77

@@ -103,4 +103,4 @@
103103

104104

105105
void rgb565_byte_swap(void *buf, uint32_t buf_size_px);
106-
#endif /* _LCD_TYPES_H_ */
106+
#endif /* __LCD_TYPES_H__ */

ext_mod/lcd_bus/modlcd_bus.h renamed to ext_mod/lcd_bus/common/include/modlcd_bus.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright (c) 2024 - 2025 Kevin G. Schlosser
22

3-
#ifndef _MODLCD_BUS_H_
4-
#define _MODLCD_BUS_H_
3+
#ifndef __MODLCD_BUS_H__
4+
#define __MODLCD_BUS_H__
55

66
#include "lcd_types.h"
77

@@ -22,6 +22,6 @@
2222

2323
extern const mp_obj_dict_t mp_lcd_bus_locals_dict;
2424

25-
#endif /* _MODLCD_BUS_H_ */
25+
#endif /* __MODLCD_BUS_H__ */
2626

2727

File renamed without changes.

ext_mod/lcd_bus/modlcd_bus.c renamed to ext_mod/lcd_bus/common/src/modlcd_bus.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
#include "i2c_bus.h"
77
#include "i80_bus.h"
88
#include "rgb_bus.h"
9+
#include "sdl_bus.h"
10+
#include "led_bus.h"
11+
#include "dsi_bus.h"
912

10-
#ifdef MP_PORT_UNIX
11-
#include "sdl_bus.h"
12-
#endif
1313

1414
// micropython includes
1515
#include "py/obj.h"
@@ -291,11 +291,12 @@ static const mp_rom_map_elem_t mp_module_lcd_bus_globals_table[] = {
291291
{ MP_ROM_QSTR(MP_QSTR_SPIBus), MP_ROM_PTR(&mp_lcd_spi_bus_type) },
292292
{ MP_ROM_QSTR(MP_QSTR_I2CBus), MP_ROM_PTR(&mp_lcd_i2c_bus_type) },
293293
{ MP_ROM_QSTR(MP_QSTR_I80Bus), MP_ROM_PTR(&mp_lcd_i80_bus_type) },
294+
{ MP_ROM_QSTR(MP_QSTR_SDLBus), MP_ROM_PTR(&mp_lcd_sdl_bus_type) },
295+
{ MP_ROM_QSTR(MP_QSTR_DSIBus), MP_ROM_PTR(&mp_lcd_dsi_bus_type) },
296+
{ MP_ROM_QSTR(MP_QSTR_LEDBus), MP_ROM_PTR(&mp_lcd_led_bus_type) },
297+
294298
{ MP_ROM_QSTR(MP_QSTR__pump_main_thread), MP_ROM_PTR(&mp_lcd_bus__pump_main_thread_obj) },
295299

296-
#ifdef MP_PORT_UNIX
297-
{ MP_ROM_QSTR(MP_QSTR_SDLBus), MP_ROM_PTR(&mp_lcd_sdl_bus_type) },
298-
#endif
299300
{ MP_ROM_QSTR(MP_QSTR_DEBUG_ENABLED), MP_ROM_INT(LCD_DEBUG) },
300301

301302
#ifdef ESP_IDF_VERSION

ext_mod/lcd_bus/common_include/i2c_bus.h

Lines changed: 0 additions & 36 deletions
This file was deleted.

ext_mod/lcd_bus/common_include/i80_bus.h

Lines changed: 0 additions & 101 deletions
This file was deleted.

ext_mod/lcd_bus/common_include/rgb_bus.h

Lines changed: 0 additions & 36 deletions
This file was deleted.

0 commit comments

Comments
 (0)