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

Commitc7559e6

Browse files
committed
Hopefully finally fixes I2C
1 parentd93bf42 commitc7559e6

File tree

8 files changed

+74
-1342
lines changed

8 files changed

+74
-1342
lines changed

‎builder/__init__.py‎

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,7 @@ def get_lvgl():
118118

119119
cmd_= ['cd lib/lvgl && git checkout master']
120120

121-
result,_=spawn(cmd_,spinner=True)
122-
ifresult!=0:
123-
sys.exit(result)
121+
spawn(cmd_,out_to_screen=False)
124122

125123

126124
defget_micropython():
@@ -139,9 +137,7 @@ def get_micropython():
139137

140138
cmd_= ['cd lib/micropython && git checkout v1.22.2']
141139

142-
result,_=spawn(cmd_,spinner=True)
143-
ifresult!=0:
144-
sys.exit(result)
140+
spawn(cmd_,out_to_screen=False)
145141

146142

147143
defget_pycparser():

‎builder/esp32.py‎

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -378,13 +378,6 @@ 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-
# with open(machine_i2c_src_path, 'rb') as src:
385-
# with open(machine_i2c_dst_path, 'wb') as dst:
386-
# dst.write(src.read())
387-
388381
mpconfigport_path='lib/micropython/ports/esp32/mpconfigport.h'
389382

390383
withopen(mpconfigport_path,'rb')asf:

‎driver/frozen/other/i2c.py‎

Lines changed: 23 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
2-
try:
3-
fromesp_i2cimportI2Cas_I2C
4-
exceptImportError:
5-
frommachineimportI2Cas_I2C
6-
71
importmachine
82

93

@@ -18,38 +12,31 @@ def __init__(self, scl, sda, freq=400000, host=None, timeout=50000, use_locks=Fa
1812
else:
1913
host=1
2014

21-
key= (scl,sda,freq,host)
15+
self._bus=machine.I2C(
16+
host,
17+
scl=machine.Pin(scl),
18+
sda=machine.Pin(sda),
19+
freq=freq,
20+
timeout=timeout
21+
)
2222

23-
ifkeyinI2CBus._busses:
24-
self.__dict__.update(I2CBus._busses[key].__dict__)
25-
else:
26-
I2CBus._busses[key]=self
27-
28-
self._bus=_I2C(
29-
host,
30-
scl=machine.Pin(scl),
31-
sda=machine.Pin(sda),
32-
freq=freq,
33-
timeout=timeout
34-
)
23+
ifuse_locks:
24+
import_thread
25+
self._lock=_thread.allocate_lock()
3526

36-
ifuse_locks:
37-
import_thread
38-
self._lock=_thread.allocate_lock()
39-
40-
else:
41-
classLock(object):
27+
else:
28+
classLock(object):
4229

43-
defacquire(self):
44-
pass
30+
defacquire(self):
31+
pass
4532

46-
defrelease(self):
47-
pass
33+
defrelease(self):
34+
pass
4835

49-
defis_locked(self):
50-
returnFalse
36+
defis_locked(self):
37+
returnFalse
5138

52-
self._lock=Lock()
39+
self._lock=Lock()
5340

5441
def__enter__(self):
5542
self._lock.acquire()
@@ -95,7 +82,7 @@ def __init__(self, bus, dev_id, reg_bits=8):
9582

9683
defread_mem(self,memaddr,num_bytes=None,buf=None):
9784
withself._bus:
98-
ifbufisNone:
85+
ifnum_bytesisnotNone:
9986
returnself._bus.readfrom_mem(
10087
self.dev_id,
10188
memaddr,
@@ -120,10 +107,10 @@ def write_mem(self, memaddr, buf):
120107
addrsize=self._reg_bits
121108
)
122109

123-
defread(self,nbytes=None,buf=None,stop=True):
110+
defread(self,num_bytes=None,buf=None,stop=True):
124111
withself._bus:
125-
ifbufisNone:
126-
returnself._bus.readfrom(self.dev_id,nbytes,stop)
112+
ifnum_bytesisnotNone:
113+
returnself._bus.readfrom(self.dev_id,num_bytes,stop)
127114
else:
128115
self._bus.readfrom_into(self.dev_id,buf,stop)
129116

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp