Skip to content

Commit aa82540

Browse files
committed
working on the global rotate
1 parent e147c52 commit aa82540

Some content is hidden

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

54 files changed

+3086
-3497
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#ifndef __LCD_BUS_UTILS_H__
2+
#define __LCD_BUS_UTILS_H__
3+
4+
mp_lcd_err_t mp_lcd_verify_frame_buffers(mp_lcd_framebuf_t *fb1, mp_lcd_framebuf_t *fb2);
5+
mp_lcd_err_t mp_lcd_allocate_rotation_buffers(mp_lcd_bus_obj_t *self);
6+
void mp_lcd_free_rotation_buffers(mp_lcd_bus_obj_t self);
7+
8+
#endif /* __LCD_BUS_UTILS_H__ */
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
// Copyright (c) 2024 - 2025 Kevin G. Schlosser
2+
3+
4+
// micropython includes
5+
#include "py/obj.h"
6+
7+
8+
#ifndef _COMMON_LCD_TYPES_H_
9+
#define _COMMON_LCD_TYPES_H_
10+
11+
#include "lcd_framebuf.h"
12+
#include "lcd_types.h"
13+
14+
#define LCD_UNUSED(x) ((void)x)
15+
16+
#if CONFIG_LCD_ENABLE_DEBUG_LOG
17+
#define LCD_DEBUG_PRINT(...) mp_printf(&mp_plat_print, __VA_ARGS__);
18+
#else
19+
#define LCD_DEBUG_PRINT(...)
20+
#endif
21+
22+
23+
extern const mp_obj_type_t mp_lcd_i2c_bus_type;
24+
extern const mp_obj_type_t mp_lcd_i80_bus_type;
25+
extern const mp_obj_type_t mp_lcd_rgb_bus_type;
26+
extern const mp_obj_type_t mp_lcd_spi_bus_type;
27+
28+
typedef struct _mp_lcd_i2c_bus_obj_t mp_lcd_i2c_bus_obj_t;
29+
typedef struct _mp_lcd_i80_bus_obj_t mp_lcd_i80_bus_obj_t;
30+
typedef struct _mp_lcd_rgb_bus_obj_t mp_lcd_rgb_bus_obj_t;
31+
typedef struct _mp_lcd_spi_bus_obj_t mp_lcd_spi_bus_obj_t;
32+
33+
typedef struct _lcd_panel_io_t lcd_panel_io_t;
34+
35+
36+
typedef enum {
37+
LCD_OK = 0,
38+
LCD_FAIL = -1,
39+
LCD_ERR_NO_MEM = 0x101,
40+
LCD_ERR_INVALID_ARG = 0x102,
41+
LCD_ERR_INVALID_STATE = 0x103,
42+
LCD_ERR_INVALID_SIZE = 0x104,
43+
LCD_ERR_NOT_SUPPORTED = 0x106
44+
} mp_lcd_err_t;
45+
46+
47+
typedef struct _mp_lcd_bus_obj_t {
48+
mp_obj_base_t base;
49+
lcd_panel_io_t panel_io_handle;
50+
51+
mp_obj_t callback;
52+
53+
mp_lcd_framebuf_t *fb1;
54+
mp_lcd_framebuf_t *fb2;
55+
56+
uint8_t trans_done: 1;
57+
uint8_t rgb565_byte_swap: 1;
58+
uint8_t sw_rotate: 1;
59+
uint8_t lanes: 5;
60+
61+
mp_lcd_sw_rotation_t sw_rot;
62+
} mp_lcd_bus_obj_t;
63+
64+
65+
void mp_lcd_flush_ready_cb(mp_obj_t cb);
66+
67+
#endif /* _COMMON_LCD_TYPES_H_ */

ext_mod/lcd_bus/include/common/lcd_types.h

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

ext_mod/lcd_bus/include/common/modlcd_bus.h

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

3+
#include "py/obj.h"
4+
35
#ifndef _MODLCD_BUS_H_
46
#define _MODLCD_BUS_H_
57

6-
#include "lcd_types.h"
7-
8-
// micropython includes
9-
#include "py/obj.h"
10-
#include "py/runtime.h"
11-
#include "py/objarray.h"
12-
138
extern const mp_obj_fun_builtin_var_t mp_lcd_bus_init_obj;
149
extern const mp_obj_fun_builtin_var_t mp_lcd_bus_get_lane_count_obj;
1510
extern const mp_obj_fun_builtin_var_t mp_lcd_bus_tx_param_obj;

ext_mod/lcd_bus/include/common/rgb565_dither.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,20 @@
77
#ifndef __RGB565_DITHER_H__
88
#define __RGB565_DITHER_H__
99

10-
#define CALC_THRESHOLD(x, y) (uint8_t)((y & 7) << 3) + (x & 7)
10+
#define CALC_THRESHOLD(x, y) (uint8_t)(((y & 7) << 3) + (x & 7))
1111

1212
extern uint8_t *red_thresh;
1313
extern uint8_t *green_thresh;
1414
extern uint8_t *blue_thresh;
1515

1616
bool rgb565_dither_init(void);
17+
void rgb565_dither_free(void);
1718

18-
static inline void rgb565_dither_pixel(uint8_t treshold_id, uint16_t *pixel)
19+
static inline void rgb565_dither_pixel(uint8_t treshold_id, uint16_t *src, uint16_t *dst)
1920
{
20-
*pixel = (((((*pixel >> 8) & 0xF8) + red_thresh[treshold_id]) << 8) |
21-
((((*pixel >> 3) & 0xFC) + green_thresh[treshold_id]) << 3) |
22-
((((*pixel & 0x1F) << 3) + blue_thresh[treshold_id]) >> 3));
21+
*dst = (((((*src >> 8) & 0xF8) + red_thresh[treshold_id]) << 8) |
22+
((((*src >> 3) & 0xFC) + green_thresh[treshold_id]) << 3) |
23+
((((*src & 0x1F) << 3) + blue_thresh[treshold_id]) >> 3));
2324
}
2425

2526
#endif

ext_mod/lcd_bus/include/common/sw_rotate.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@
88
#ifndef __SW_ROTATE_H__
99
#define __SW_ROTATE_H__
1010

11+
12+
#define LCD_ROTATION_0 (0)
13+
#define LCD_ROTATION_90 (1)
14+
#define LCD_ROTATION_180 (2)
15+
#define LCD_ROTATION_270 (3)
16+
1117
typedef struct _mp_lcd_sw_rotation_data_t {
1218
uint32_t x_start: 16;
1319
uint32_t y_start: 16;
@@ -19,6 +25,7 @@
1925
uint8_t rotation: 3;
2026
uint8_t last_update: 1;
2127
uint8_t rgb565_dither: 1;
28+
int cmd;
2229
} mp_lcd_sw_rotation_data_t;
2330

2431

Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
1-
#ifdef ESP_IDF_VERSION
2-
#include "esp32/sw_rotate_task.h"
3-
#elif defined(MP_PORT_UNIX)
4-
#include "posix/sw_rotate_task.h"
5-
#else
6-
#include "other_mcus/sw_rotate_task.h"
1+
#include "sw_rotate_task.h"
72

3+
#ifndef __SW_ROTATE_TASK_COMMON_H__
4+
#define __SW_ROTATE_TASK_COMMON_H__
85

9-
#ifndef __SW_ROTATE_TASK_H__
10-
#define __SW_ROTATE_TASK_H__
6+
typedef struct _mp_lcd_lock_t mp_lcd_lock_t;
7+
typedef struct _mp_lcd_event_t mp_lcd_event_t;
118

129
/* event */
1310
void mp_lcd_event_init(mp_lcd_event_t *event);
@@ -21,13 +18,13 @@
2118
void mp_lcd_event_wait(mp_lcd_event_t *event);
2219

2320
/* lock */
24-
bool mp_lcd_lock_acquire(mp_lcd_lock_t *lock, int32_t wait_ms);
21+
bool mp_lcd_lock_acquire(mp_lcd_lock_t *lock);
2522
void mp_lcd_lock_release(mp_lcd_lock_t *lock);
2623
void mp_lcd_lock_init(mp_lcd_lock_t *lock);
2724
void mp_lcd_lock_delete(mp_lcd_lock_t *lock);
2825
void mp_lcd_lock_release_from_isr(mp_lcd_lock_t *lock);
2926

3027

31-
void mp_lcd_sw_rotate_task(void *self_in);
28+
bool mp_lcd_start_rotate_task(void *self_in);
3229

33-
#endif /* __SW_ROTATE_TASK_H__ */
30+
#endif /* __SW_ROTATE_TASK_COMMON_H__ */

ext_mod/lcd_bus/include/esp32/dsi_bus.h

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
#define _ESP32_DSI_BUS_H_
66

77
//local_includes
8-
#include "common/lcd_types.h"
9-
#include "common/lcd_framebuf.h"
8+
#include "common/lcd_common_types.h"
109
#include "common/sw_rotate.h"
1110

1211
// micropython includes
@@ -27,19 +26,7 @@
2726

2827

2928
typedef struct _mp_lcd_dsi_bus_obj_t {
30-
mp_obj_base_t base;
31-
lcd_panel_io_t panel_io_handle;
32-
33-
mp_obj_t callback;
34-
35-
mp_lcd_framebuf_t *fb1;
36-
mp_lcd_framebuf_t *fb2;
37-
38-
uint8_t trans_done: 1;
39-
uint8_t rgb565_byte_swap: 1;
40-
uint8_t sw_rotate: 1;
41-
42-
mp_lcd_sw_rotation_t *sw_rot;
29+
struct _mp_lcd_bus_obj_t;
4330

4431
esp_lcd_dbi_io_config_t *panel_io_config;
4532
esp_lcd_dsi_bus_config_t *bus_config;
Lines changed: 10 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,20 @@
11
// Copyright (c) 2024 - 2025 Kevin G. Schlosser
22

3-
#ifndef _ESP32_I2C_BUS_H_
4-
#define _ESP32_I2C_BUS_H_
53

6-
//local_includes
7-
#include "common/lcd_types.h"
8-
#include "common/lcd_framebuf.h"
9-
#include "common/sw_rotate.h"
4+
#include "py/obj.h"
105

11-
// esp-idf includes
12-
#include "esp_lcd_panel_io.h"
13-
#include "driver/i2c.h"
14-
15-
// micropython includes
16-
#include "mphalport.h"
17-
#include "py/obj.h"
18-
#include "py/objarray.h"
196

20-
typedef struct _mp_lcd_i2c_bus_obj_t {
21-
mp_obj_base_t base;
22-
lcd_panel_io_t panel_io_handle;
7+
#ifndef _I2C_BUS_H_
8+
#define _I2C_BUS_H_
239

24-
mp_obj_t callback;
10+
#include "esp_lcd_panel_io.h"
11+
#include "driver/i2c.h"
2512

26-
mp_lcd_framebuf_t *fb1;
27-
mp_lcd_framebuf_t *fb2;
13+
#include "common/lcd_common_types.h"
2814

29-
uint8_t trans_done: 1;
30-
uint8_t rgb565_byte_swap: 1;
31-
uint8_t sw_rotate: 1;
3215

33-
mp_lcd_sw_rotation_t *sw_rot;
16+
struct _mp_lcd_i2c_bus_obj_t {
17+
struct _mp_lcd_bus_obj_t;
3418

3519
esp_lcd_panel_io_i2c_config_t *panel_io_config;
3620
i2c_config_t *bus_config;
@@ -40,10 +24,8 @@
4024

4125
int host;
4226

43-
} mp_lcd_i2c_bus_obj_t;
44-
45-
extern const mp_obj_type_t mp_lcd_i2c_bus_type;
27+
};
4628

4729
extern void mp_lcd_i2c_bus_deinit_all(void);
4830

49-
#endif /* _ESP32_I2C_BUS_H_ */
31+
#endif /* _I2C_BUS_H_ */

0 commit comments

Comments
 (0)