summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvgeny Zinoviev <me@ch1p.io>2021-11-11 19:41:36 +0300
committerEvgeny Zinoviev <me@ch1p.io>2021-11-11 19:41:36 +0300
commit585a130ecd828b03cf06ae1cfbedac49ad01e7ec (patch)
tree04b9330e6c8d99bc72d6ff35643d4946fa8db59d
parent79d2d87e32bde6a8347cbf7098026c65dec2b755 (diff)
configurable delay
-rw-r--r--si7021d7
1 files changed, 6 insertions, 1 deletions
diff --git a/si7021d b/si7021d
index 77b3970..123fc39 100644
--- a/si7021d
+++ b/si7021d
@@ -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)