I used asyncio and matplotlib to implement visualization of HWT905-TTL MPU-9250 angular data output.
However, this program has an issue where the plot updates are not performed within the asyncio event loop.
This can lead to problems...
handler = RotatingFileHandler("app.log", maxBytes=6000000, backupCount=5)
formatter = logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s")
handler.setFormatter(formatter)
logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)
logger.addHandler(handler)
# I wrapped the asyncio event loop in a function.
def start_asyncio_loop():
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)
loop.run_until_complete(readerAndWriter(loop))
loop.close
def main():
async_thread = threading.Thread(target=start_asyncio_loop)
async_thread.daemon = True
async_thread.start()
plot_data()
if __name__ == "__main__":
main()
Hello, my name is Koki. I am currently learning the web framework Django and English. In my free time, I enjoy hiking, cycling, and visiting shrines and temples. At work, I make software for programmable logic controllers (PLCs), I work especially with OMRON and Mitsubishi PLCs. Please feel free to contact me for any inquiries, job requests, or just to chat. We look forward to hearing from you via email!