Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit2075ff1

Browse files
committed
Merge remote-tracking branch 'origin/main'
2 parents5ff8e8d +831c596 commit2075ff1

File tree

3 files changed

+22
-79
lines changed

3 files changed

+22
-79
lines changed

‎builder/esp32.py‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1401,6 +1401,8 @@ def build_sdkconfig(*args):
14011401
withopen(SDKCONFIG_PATH,'w')asf:
14021402
f.write('\n'.join(base_config))
14031403

1404+
returnargs
1405+
14041406

14051407
defrevert_custom_board():
14061408
ifcustom_board_pathisNone:
@@ -1424,7 +1426,7 @@ def compile(*args): # NOQA
14241426
ifccache:
14251427
env['IDF_CCACHE_ENABLE']='1'
14261428

1427-
build_sdkconfig(*args)
1429+
args=build_sdkconfig(*args)
14281430

14291431
ifcustom_board_pathisNone:
14301432

@@ -1447,7 +1449,7 @@ def compile(*args): # NOQA
14471449

14481450
try:
14491451
cmd_=compile_cmd[:]
1450-
cmd_.extend(list(args))
1452+
cmd_.extend(args)
14511453

14521454
ret_code,output=spawn(cmd_,env=env,cmpl=True)
14531455

‎ext_mod/lcd_bus/esp32_include/i2c_bus.h‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,13 @@
3030

3131
lcd_panel_io_tpanel_io_handle;
3232
esp_lcd_panel_io_i2c_config_tpanel_io_config;
33-
i2c_config_tbus_config;
33+
i2c_port_tport;
3434
esp_lcd_i2c_bus_handle_tbus_handle;
3535

36-
inthost;
37-
3836
}mp_lcd_i2c_bus_obj_t;
3937

4038
externconstmp_obj_type_tmp_lcd_i2c_bus_type;
4139

4240
externvoidmp_lcd_i2c_bus_deinit_all(void);
4341

44-
#endif/* _ESP32_I2C_BUS_H_ */
42+
#endif/* _ESP32_I2C_BUS_H_ */

‎ext_mod/lcd_bus/esp32_src/i2c_bus.c‎

Lines changed: 16 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -28,49 +28,38 @@ static uint8_t i2c_bus_count = 0;
2828
staticmp_lcd_i2c_bus_obj_t**i2c_bus_objs;
2929

3030

31+
typedefstruct_i2c_obj_t {
32+
mp_obj_base_tbase;
33+
i2c_port_tport :8;
34+
gpio_num_tscl :8;
35+
gpio_num_tsda :8;
36+
}_i2c_obj_t;
37+
38+
3139
voidmp_lcd_i2c_bus_deinit_all(void)
3240
{
3341
// we need to copy the existing array to a new one so the order doesn't
3442
// get all mucked up when objects get removed.
35-
mp_lcd_i2c_bus_obj_t*objs[i2c_bus_count];
36-
37-
for (uint8_ti=0;i<i2c_bus_count;i++) {
38-
objs[i]=i2c_bus_objs[i];
39-
}
40-
41-
for (uint8_ti=0;i<i2c_bus_count;i++) {
42-
i2c_del(MP_OBJ_FROM_PTR(objs[i]));
43-
}
4443
}
4544

4645

4746
staticmp_obj_tmp_lcd_i2c_bus_make_new(constmp_obj_type_t*type,size_tn_args,size_tn_kw,constmp_obj_t*all_args)
4847
{
4948
enum {
50-
ARG_sda,
51-
ARG_scl,
49+
ARG_i2c_bus,
5250
ARG_addr,
53-
ARG_host,
5451
ARG_control_phase_bytes,
5552
ARG_dc_bit_offset,
56-
ARG_freq,
5753
ARG_dc_low_on_data,
58-
ARG_sda_pullup,
59-
ARG_scl_pullup,
6054
ARG_disable_control_phase
6155
};
6256

6357
constmp_arg_tmake_new_args[]= {
64-
{MP_QSTR_sda,MP_ARG_INT |MP_ARG_KW_ONLY |MP_ARG_REQUIRED },
65-
{MP_QSTR_scl,MP_ARG_INT |MP_ARG_KW_ONLY |MP_ARG_REQUIRED },
58+
{MP_QSTR_i2c_bus,MP_ARG_OBJ |MP_ARG_KW_ONLY |MP_ARG_REQUIRED },
6659
{MP_QSTR_addr,MP_ARG_INT |MP_ARG_KW_ONLY |MP_ARG_REQUIRED },
67-
{MP_QSTR_host,MP_ARG_INT |MP_ARG_KW_ONLY, {.u_int=0 } },
6860
{MP_QSTR_control_phase_bytes,MP_ARG_INT |MP_ARG_KW_ONLY, {.u_int=1 } },
6961
{MP_QSTR_dc_bit_offset,MP_ARG_INT |MP_ARG_KW_ONLY, {.u_int=6 } },
70-
{MP_QSTR_freq,MP_ARG_INT |MP_ARG_KW_ONLY, {.u_int=100000 } },
71-
{MP_QSTR_dc_low_on_data,MP_ARG_BOOL |MP_ARG_KW_ONLY, {.u_bool= false } },
72-
{MP_QSTR_sda_pullup,MP_ARG_BOOL |MP_ARG_KW_ONLY, {.u_bool= true } },
73-
{MP_QSTR_scl_pullup,MP_ARG_BOOL |MP_ARG_KW_ONLY, {.u_bool= true } },
62+
{MP_QSTR_dc_low_on_data,MP_ARG_BOOL |MP_ARG_KW_ONLY, {.u_bool= true } },
7463
{MP_QSTR_disable_control_phase,MP_ARG_BOOL |MP_ARG_KW_ONLY, {.u_bool= false } }
7564
};
7665

@@ -90,17 +79,9 @@ static mp_obj_t mp_lcd_i2c_bus_make_new(const mp_obj_type_t *type, size_t n_args
9079

9180
self->callback=mp_const_none;
9281

93-
self->host=args[ARG_host].u_int;
94-
self->bus_handle= (esp_lcd_i2c_bus_handle_t)((uint32_t)self->host);
95-
96-
self->bus_config.mode=I2C_MODE_MASTER;
97-
self->bus_config.sda_io_num= (int)args[ARG_sda].u_int;
98-
self->bus_config.scl_io_num= (int)args[ARG_scl].u_int;
99-
self->bus_config.sda_pullup_en= (bool)args[ARG_sda_pullup].u_bool;
100-
self->bus_config.scl_pullup_en= (bool)args[ARG_scl_pullup].u_bool;
101-
self->bus_config.master.clk_speed= (uint32_t)args[ARG_freq].u_int;
102-
self->bus_config.clk_flags=I2C_SCLK_SRC_FLAG_FOR_NOMAL;
82+
_i2c_obj_t*bus=MP_OBJ_TO_PTR(args[ARG_i2c_bus].u_obj);
10383

84+
self->port=bus->port;
10485
self->panel_io_config.dev_addr= (uint32_t)args[ARG_addr].u_int;
10586
self->panel_io_config.on_color_trans_done=bus_trans_done_cb;
10687
self->panel_io_config.user_ctx=self;
@@ -129,12 +110,6 @@ mp_lcd_err_t i2c_del(mp_obj_t obj)
129110
returnret;
130111
}
131112

132-
ret=i2c_driver_delete(self->host);
133-
if (ret!=0) {
134-
mp_raise_msg_varg(&mp_type_ValueError,MP_ERROR_TEXT("%d(i2c_driver_delete)"),ret);
135-
returnret;
136-
}
137-
138113
self->panel_io_handle.panel_io=NULL;
139114

140115
if (self->view1!=NULL) {
@@ -152,22 +127,7 @@ mp_lcd_err_t i2c_del(mp_obj_t obj)
152127
self->view2=NULL;
153128
LCD_DEBUG_PRINT("i2c_free_framebuffer(self, buf=1)\n")
154129
}
155-
156-
uint8_ti=0;
157-
for (;i<i2c_bus_count;i++) {
158-
if (i2c_bus_objs[i]==self) {
159-
i2c_bus_objs[i]=NULL;
160-
break;
161-
}
162-
}
163-
164-
for (uint8_tj=i+1;j<i2c_bus_count;j++) {
165-
i2c_bus_objs[j-i+1]=i2c_bus_objs[j];
166-
}
167-
168-
i2c_bus_count--;
169-
i2c_bus_objs=m_realloc(i2c_bus_objs,i2c_bus_count*sizeof(mp_lcd_i2c_bus_obj_t*));
170-
130+
171131
returnret;
172132
}else {
173133
returnLCD_FAIL;
@@ -188,30 +148,13 @@ mp_lcd_err_t i2c_init(mp_obj_t obj, uint16_t width, uint16_t height, uint8_t bpp
188148
self->panel_io_config.lcd_cmd_bits= (int)cmd_bits;
189149
self->panel_io_config.lcd_param_bits= (int)param_bits;
190150

191-
mp_lcd_err_tret=i2c_param_config(self->host,&self->bus_config);
192-
if (ret!=0) {
193-
mp_raise_msg_varg(&mp_type_ValueError,MP_ERROR_TEXT("%d(i2c_param_config)"),ret);
194-
returnret;
195-
}
196-
197-
ret=i2c_driver_install(self->host,I2C_MODE_MASTER,0,0,0);
198-
if (ret!=0) {
199-
mp_raise_msg_varg(&mp_type_OSError,MP_ERROR_TEXT("%d(i2c_driver_install)"),ret);
200-
returnret;
201-
}
202-
203-
ret=esp_lcd_new_panel_io_i2c(self->bus_handle ,&self->panel_io_config,&self->panel_io_handle.panel_io);
151+
mp_lcd_err_tret=esp_lcd_new_panel_io_i2c(self->port ,&self->panel_io_config,&self->panel_io_handle.panel_io);
204152

205153
if (ret!=0) {
206154
mp_raise_msg_varg(&mp_type_ValueError,MP_ERROR_TEXT("%d(esp_lcd_new_panel_io_i2c)"),ret);
207155
returnret;
208156
}
209-
210-
// add the new bus ONLY after successfull initilization of the bus
211-
i2c_bus_count++;
212-
i2c_bus_objs=m_realloc(i2c_bus_objs,i2c_bus_count*sizeof(mp_lcd_i2c_bus_obj_t*));
213-
i2c_bus_objs[i2c_bus_count-1]=self;
214-
157+
215158
returnret;
216159
}
217160

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp