Introduce I/O transactions at a slower clock speed

This commit is contained in:
Markus Koch 2020-07-28 21:55:33 +02:00
parent c618e058dd
commit 1eaa9c3c38

View File

@ -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()