configurable delay
This commit is contained in:
parent
79d2d87e32
commit
585a130ecd
7
si7021d
7
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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user