black my bad
This commit is contained in:
parent
86e3b138b2
commit
44d27ef09a
@ -1,10 +1,13 @@
|
|||||||
import busio
|
import busio
|
||||||
|
import gc
|
||||||
|
|
||||||
|
import adafruit_displayio_ssd1306
|
||||||
import displayio
|
import displayio
|
||||||
import terminalio
|
import terminalio
|
||||||
from adafruit_display_text import label
|
from adafruit_display_text import label
|
||||||
import adafruit_displayio_ssd1306
|
|
||||||
from kmk.extensions import Extension
|
from kmk.extensions import Extension
|
||||||
import gc
|
|
||||||
|
|
||||||
class oled(Extension):
|
class oled(Extension):
|
||||||
def __init__(
|
def __init__(
|
||||||
@ -15,18 +18,20 @@ class oled(Extension):
|
|||||||
oWidth: int = 128,
|
oWidth: int = 128,
|
||||||
oHeight: int = 32,
|
oHeight: int = 32,
|
||||||
flip: bool = False,
|
flip: bool = False,
|
||||||
|
|
||||||
):
|
):
|
||||||
displayio.release_displays()
|
displayio.release_displays()
|
||||||
self._views = views
|
self._views = views
|
||||||
self._toDisplay = toDisplay
|
self._toDisplay = toDisplay
|
||||||
i2c = busio.I2C(board.SCL, board.SDA)
|
i2c = busio.I2C(board.SCL, board.SDA)
|
||||||
self.width=oWidth,
|
self.width = (oWidth,)
|
||||||
self.height=oHeight,
|
self.height = (oHeight,)
|
||||||
self.rotation = 180 if flip else 0
|
self.rotation = 180 if flip else 0
|
||||||
self._display = adafruit_displayio_ssd1306.SSD1306(displayio.I2CDisplay(i2c, device_address=0x3C),
|
self._display = adafruit_displayio_ssd1306.SSD1306(
|
||||||
|
displayio.I2CDisplay(i2c, device_address=0x3C),
|
||||||
width=oWidth,
|
width=oWidth,
|
||||||
height=oHeight,rotation=self.rotation)
|
height=oHeight,
|
||||||
|
rotation=self.rotation,
|
||||||
|
)
|
||||||
self._prevLayers = 0
|
self._prevLayers = 0
|
||||||
gc.collect()
|
gc.collect()
|
||||||
|
|
||||||
@ -37,38 +42,57 @@ class oled(Extension):
|
|||||||
if singleView[0] == "LAYER":
|
if singleView[0] == "LAYER":
|
||||||
return singleView[1][layer]
|
return singleView[1][layer]
|
||||||
|
|
||||||
|
|
||||||
def renderOledTextLayer(self, layer):
|
def renderOledTextLayer(self, layer):
|
||||||
splash = displayio.Group()
|
splash = displayio.Group()
|
||||||
self._display.show(splash)
|
self._display.show(splash)
|
||||||
splash.append(
|
splash.append(
|
||||||
label.Label(terminalio.FONT,
|
label.Label(
|
||||||
|
terminalio.FONT,
|
||||||
text=self.returnCurrectRenderText(layer, self._views[0]),
|
text=self.returnCurrectRenderText(layer, self._views[0]),
|
||||||
color=0xFFFFFF, x=0, y=10))
|
color=0xFFFFFF,
|
||||||
|
x=0,
|
||||||
|
y=10,
|
||||||
|
)
|
||||||
|
)
|
||||||
splash.append(
|
splash.append(
|
||||||
label.Label(terminalio.FONT,
|
label.Label(
|
||||||
|
terminalio.FONT,
|
||||||
text=self.returnCurrectRenderText(layer, self._views[1]),
|
text=self.returnCurrectRenderText(layer, self._views[1]),
|
||||||
color=0xFFFFFF, x=64, y=10))
|
color=0xFFFFFF,
|
||||||
|
x=64,
|
||||||
|
y=10,
|
||||||
|
)
|
||||||
|
)
|
||||||
splash.append(
|
splash.append(
|
||||||
label.Label(terminalio.FONT,
|
label.Label(
|
||||||
|
terminalio.FONT,
|
||||||
text=self.returnCurrectRenderText(layer, self._views[2]),
|
text=self.returnCurrectRenderText(layer, self._views[2]),
|
||||||
color=0xFFFFFF, x=0, y=25))
|
color=0xFFFFFF,
|
||||||
|
x=0,
|
||||||
|
y=25,
|
||||||
|
)
|
||||||
|
)
|
||||||
splash.append(
|
splash.append(
|
||||||
label.Label(terminalio.FONT,
|
label.Label(
|
||||||
|
terminalio.FONT,
|
||||||
text=self.returnCurrectRenderText(layer, self._views[3]),
|
text=self.returnCurrectRenderText(layer, self._views[3]),
|
||||||
color=0xFFFFFF, x=64, y=25))
|
color=0xFFFFFF,
|
||||||
|
x=64,
|
||||||
|
y=25,
|
||||||
|
)
|
||||||
|
)
|
||||||
gc.collect()
|
gc.collect()
|
||||||
|
|
||||||
def renderOledImgLayer(self, layer):
|
def renderOledImgLayer(self, layer):
|
||||||
splash = displayio.Group()
|
splash = displayio.Group()
|
||||||
self._display.show(splash)
|
self._display.show(splash)
|
||||||
odb = displayio.OnDiskBitmap('/'+self.returnCurrectRenderText(layer,self._views[0]))
|
odb = displayio.OnDiskBitmap(
|
||||||
|
'/' + self.returnCurrectRenderText(layer, self._views[0])
|
||||||
|
)
|
||||||
image = displayio.TileGrid(odb, pixel_shader=odb.pixel_shader)
|
image = displayio.TileGrid(odb, pixel_shader=odb.pixel_shader)
|
||||||
splash.append(image)
|
splash.append(image)
|
||||||
gc.collect()
|
gc.collect()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def updateOLED(self, sandbox):
|
def updateOLED(self, sandbox):
|
||||||
if self._toDisplay == "TXT":
|
if self._toDisplay == "TXT":
|
||||||
self.renderOledTextLayer(sandbox.active_layers[0])
|
self.renderOledTextLayer(sandbox.active_layers[0])
|
||||||
@ -76,7 +100,6 @@ class oled(Extension):
|
|||||||
self.renderOledImgLayer(sandbox.active_layers[0])
|
self.renderOledImgLayer(sandbox.active_layers[0])
|
||||||
gc.collect()
|
gc.collect()
|
||||||
|
|
||||||
|
|
||||||
def on_runtime_enable(self, sandbox):
|
def on_runtime_enable(self, sandbox):
|
||||||
return
|
return
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user