This function establishes the pin as a digital input. Any changes on this pin will be reported through the call back function. :param my_board: a telemetrix instance :param pin: GPIO pin number """ # set the pin mode await my_board.set_pin_mode_digital_input_pulldown(pin, the_callback) while True: try: await asyncio.sleep(.001) except KeyboardInterrupt: await board.shutdown() sys.exit(0) # get the event loop loop = asyncio.get_event_loop() # instantiate telemetrix board = telemetrix_aio_esp32.TelemetrixAioEsp32(transport_address=IP_ADDRESS) try: # start the main function loop.run_until_complete(digital_in(board, DIGITAL_PIN)) except (KeyboardInterrupt, RuntimeError) as e: loop.run_until_complete(board.shutdown()) sys.exit(0)
# set up the data format register await my_board.i2c_write(83, [49, 8]) await asyncio.sleep(.1) await my_board.i2c_write(83, [49, 3]) await asyncio.sleep(.1) # read_count = 20 while True: # read 6 bytes from the data register try: await my_board.i2c_read(83, 50, 6, the_callback) await asyncio.sleep(.3) except (KeyboardInterrupt, RuntimeError): await my_board.shutdown() sys.exit(0) # get the event loop loop = asyncio.get_event_loop() # instantiate telemetrix board = telemetrix_aio_esp32.TelemetrixAioEsp32(transport_is_wifi=False) try: # start the main function loop.run_until_complete(adxl345(board)) except KeyboardInterrupt: loop.run_until_complete(board.shutdown()) sys.exit(0)