From 1eaa9c3c38779b23a7a704d4cf0ebf7681ce026d Mon Sep 17 00:00:00 2001 From: Markus Koch Date: Tue, 28 Jul 2020 21:55:33 +0200 Subject: [PATCH] Introduce I/O transactions at a slower clock speed --- software/webradio.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/software/webradio.py b/software/webradio.py index 7461aee..b9d22a1 100644 --- a/software/webradio.py +++ b/software/webradio.py @@ -7,6 +7,7 @@ import spidev IO_DELAY = (1.0 / 25.0) MPD_DELAY = 0.5 +SPI_SPEED = 600000 class display(object): def __init__(self): @@ -132,8 +133,10 @@ class radioserv: while True: self.disp_mgr.animate(1) self.disp_mgr.render() + rdata = self.spi.xfer([100, 101, 102, 103], 100000, 1) + print(rdata) data = list(self.disp_mgr.get_image()) - self.spi.xfer(data) + rdata = self.spi.xfer(data, SPI_SPEED, 1) await self.io_event.wait() self.io_event.clear() @@ -195,7 +198,7 @@ class radioserv: # Connect to SPI self.spi = spidev.SpiDev() self.spi.open(0, 0) - self.spi.max_speed_hz = 500000 + self.spi.max_speed_hz = SPI_SPEED self.spi.mode = 0b00 # Connect to MPD @@ -217,7 +220,7 @@ class radioserv: mpd_task = asyncio.create_task(self.mpd_main()) # TODO: Wait for exit condition (shutdown command) - await asyncio.sleep(60) + await asyncio.sleep(6000) io_timer_task.cancel() io_task.cancel()