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

Commit756c87d

Browse files
committed
Wrote a new I2C driver.
I am trying to figure out this I2C issue. It keeps on randomly tanking on me and reporting bad values, I am not sure why. So I decided to eliminate the MicroPython mechanics involved in it. There could be something in there that is causing the problem.I was going to change to ESP-IDF 5.1.2 but there is no large differences that jump right out at me compared to 5.0.6. 5.2 is where they released the whole new API for I2C and IO know that it is not going to be something easy to migrate to. I may try it in the upcoming weeks to see what is needed.
1 parent9b1db66 commit756c87d

File tree

7 files changed

+738
-27
lines changed

7 files changed

+738
-27
lines changed

‎builder/esp32.py‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -378,12 +378,12 @@ def submodules():
378378
defcompile():# NOQA
379379
env=setup_idf_environ()
380380

381-
machine_i2c_dst_path='lib/micropython/ports/esp32/machine_i2c.c'
382-
machine_i2c_src_path='ext_mod/ESP32_I2C/machine_i2c.c'
383-
384-
withopen(machine_i2c_src_path,'rb')assrc:
385-
withopen(machine_i2c_dst_path,'wb')asdst:
386-
dst.write(src.read())
381+
#machine_i2c_dst_path = 'lib/micropython/ports/esp32/machine_i2c.c'
382+
#machine_i2c_src_path = 'ext_mod/ESP32_I2C/machine_i2c.c'
383+
#
384+
#with open(machine_i2c_src_path, 'rb') as src:
385+
# with open(machine_i2c_dst_path, 'wb') as dst:
386+
# dst.write(src.read())
387387

388388
mpconfigport_path='lib/micropython/ports/esp32/mpconfigport.h'
389389

‎driver/frozen/other/i2c.py‎

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11

2+
try:
3+
fromesp_i2cimportI2Cas_I2C
4+
exceptImportError:
5+
frommachineimportI2Cas_I2C
6+
27
importmachine
38

49

@@ -20,7 +25,7 @@ def __init__(self, scl, sda, freq=400000, host=None, timeout=50000, use_locks=Fa
2025
else:
2126
I2CBus._busses[key]=self
2227

23-
self._bus=machine.I2C(
28+
self._bus=_I2C(
2429
host,
2530
scl=machine.Pin(scl),
2631
sda=machine.Pin(sda),
@@ -59,18 +64,6 @@ def scan(self):
5964
self._lock.release()
6065
returndata
6166

62-
defstart(self):
63-
self._bus.start()
64-
65-
defstop(self):
66-
self._bus.stop()
67-
68-
defreadinto(self,buf,nack=True):
69-
self._bus.readinto(buf,nack)
70-
71-
defwrite(self,buf):
72-
self._bus.write(buf)
73-
7467
defreadfrom(self,addr,nbytes,stop=True):
7568
returnself._bus.readfrom(addr,nbytes,stop)
7669

‎driver/indev/gt911.py‎

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@
7070
_VENDOR_ID_HIGH=const(0x81)
7171
_VENDOR_ID_LOW=const(0x4A)
7272

73-
7473
_ADDR1=const(0x5D)
7574
_ADDR2=const(0x14)
7675

@@ -81,12 +80,7 @@ def __init__(self, i2c_bus, reset_pin=None, interrupt_pin=None, touch_cal=None):
8180
buf=self._buf=bytearray(7)
8281
mv=self._mv=memoryview(self._buf)
8382

84-
if_ADDR1ini2c_bus.scan():
85-
self._addr=_ADDR1
86-
else:
87-
self._addr=_ADDR2
88-
89-
self._i2c=i2c.I2CDevice(i2c_bus,self._addr)
83+
self._i2c=i2c.I2CDevice(i2c_bus,_ADDR1)
9084

9185
super().__init__(touch_cal=touch_cal)
9286

@@ -157,7 +151,7 @@ def touch_reset(self):
157151
self._interrupt_pin(0)
158152
self._reset_pin(0)
159153
time.sleep_ms(10)
160-
self._interrupt_pin(int(self._addr==_ADDR2))
154+
self._interrupt_pin(0)
161155
time.sleep_ms(1)
162156
self._reset_pin(1)
163157
time.sleep_ms(5)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp