Skip to content

Commit 7b84832

Browse files
committed
Control I2C read chunk size via constant
1 parent 502db40 commit 7b84832

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

screen_brightness_control/linux.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,14 @@ class I2C(BrightnessMethod):
179179
WAIT_TIME = 0.05
180180
'''How long to wait between I2C commands'''
181181

182+
# misc
182183
MAX_THREADS = 4
183184
'''Number of I2C buses that can be queried at once'''
185+
I2C_READ_CHUNK_SIZE = 128
186+
'''
187+
When reading EDID this controls the max number of bytes read from an
188+
I2C bus at once
189+
'''
184190

185191
_max_brightness_cache: dict = {}
186192

@@ -226,7 +232,7 @@ def find_and_read(self, sub: bytes, length: int, max_search: int):
226232
'''
227233
buf = b''
228234
while len(buf) < max_search:
229-
buf += self.read(128)
235+
buf += self.read(I2C.I2C_READ_CHUNK_SIZE)
230236
if sub in buf:
231237
buf = buf[buf.index(sub):]
232238
remaining = length - len(buf)

0 commit comments

Comments
 (0)