diff options
author | Evgeny Zinoviev <me@ch1p.io> | 2021-11-11 19:41:36 +0300 |
---|---|---|
committer | Evgeny Zinoviev <me@ch1p.io> | 2021-11-11 19:41:36 +0300 |
commit | 585a130ecd828b03cf06ae1cfbedac49ad01e7ec (patch) | |
tree | 04b9330e6c8d99bc72d6ff35643d4946fa8db59d | |
parent | 79d2d87e32bde6a8347cbf7098026c65dec2b755 (diff) |
configurable delay
-rw-r--r-- | si7021d | 7 |
1 files changed, 6 insertions, 1 deletions
@@ -9,11 +9,12 @@ import logging logger = logging.getLogger(__name__) bus = None lock = asyncio.Lock() +delay = 0.01 async def si7021_read(): async with lock: - await asyncio.sleep(0.01) + await asyncio.sleep(delay) # these are still blocking... meh raw = bus.read_i2c_block_data(0x40, 0xE3, 2) @@ -61,8 +62,12 @@ if __name__ == '__main__': parser.add_argument('--port', type=int, default=8306) parser.add_argument('--bus', type=int, default=0, help='Bus number (X for /dev/i2c-X)') + parser.add_argument('--delay', type=float, default=delay, + help='Delay before reading') args = parser.parse_args() + + delay = args.delay logging.basicConfig(level=logging.INFO) bus = smbus.SMBus(args.bus) |