stuff
This commit is contained in:
parent
413dee8b7f
commit
46dc4764a3
2 changed files with 16 additions and 0 deletions
12
display.py
12
display.py
|
|
@ -1,12 +1,15 @@
|
|||
import asyncio
|
||||
from LCD import LCD
|
||||
|
||||
alloc_lock = asyncio.Lock()
|
||||
|
||||
class display:
|
||||
def __init__(self, width=20, height=4, i2c_addr=0x27):
|
||||
self.width = width
|
||||
self.height = height
|
||||
self.device = LCD(2, i2c_addr, True)
|
||||
self.contents = [" " * width] * self.height
|
||||
self.custom_char_allocations = [False] * 8
|
||||
|
||||
async def redraw(self, row = None):
|
||||
if row == None:
|
||||
|
|
@ -15,6 +18,15 @@ class display:
|
|||
else:
|
||||
await self.device.async_message(self.contents[row - 1], row)
|
||||
|
||||
async def alloc_cchar(self):
|
||||
async with alloc_lock:
|
||||
new_alloc = self.custom_char_allocations.index(False)
|
||||
self.custom_char_allocations[new_alloc] = True
|
||||
return new_alloc
|
||||
|
||||
async def free_cchar(self, cchar):
|
||||
self.custom_char_allocations[cchar] = False
|
||||
|
||||
async def read(self, row):
|
||||
return self.contents[row]
|
||||
|
||||
|
|
|
|||
|
|
@ -7,3 +7,7 @@ GPIO pins:
|
|||
2, 3: display
|
||||
|
||||
23, 24: misc buttons
|
||||
|
||||
5, 6: aux serial (5 is pi->pc)
|
||||
|
||||
12: fan pwm
|
||||
Loading…
Add table
Add a link
Reference in a new issue