oled data is now a class
This commit is contained in:
parent
7e760a2917
commit
6970a6c786
@ -35,7 +35,7 @@ These are the changes that need to be made / added to your main.py
|
|||||||
### Config
|
### Config
|
||||||
no mater how you are going to use the oled you need this part
|
no mater how you are going to use the oled you need this part
|
||||||
```python
|
```python
|
||||||
from kmk.extensions.peg_oled_Display import Oled,OledDisplayMode,OledReactionType
|
from kmk.extensions.peg_oled_Display import Oled,OledDisplayMode,OledReactionType,OledData
|
||||||
keyboard = KMKKeyboard()
|
keyboard = KMKKeyboard()
|
||||||
# ... Other oled code
|
# ... Other oled code
|
||||||
keyboard.extensions.append(oled_ext)
|
keyboard.extensions.append(oled_ext)
|
||||||
@ -46,18 +46,18 @@ So the config for photos is quite simple. Getting the photos maybe not so much.
|
|||||||
|
|
||||||
oled takes 2-3 arguments
|
oled takes 2-3 arguments
|
||||||
|
|
||||||
1. array of data
|
1. OledData
|
||||||
* this array can have a length of 1 or 4. For images we use a length of 1.
|
* OledData can take image **or** corner_one,corner_two,corner_three and corner_four
|
||||||
* Every item in the array has 2 fields
|
* Every item in OledData has 2 fields
|
||||||
* 0: this is the reaction type right now it can be OledReactionType.LAYER or OledReactionType.STATIC
|
* 0: this is the reaction type right now it can be OledReactionType.LAYER or OledReactionType.STATIC
|
||||||
* 1: the items you want to show for the reaction. In this example 4 images to switch on the 4 layers
|
* 1: an array of the items you want to show for the reaction. In this example 4 images to switch on the 4 layers
|
||||||
2. toDisplay this takes a OledDisplayMode TXT or IMG.
|
2. toDisplay this takes a OledDisplayMode TXT or IMG.
|
||||||
* this tells the extension to load images or text.
|
* this tells the extension to load images or text.
|
||||||
3. flip Boolean this will simply flip your display.
|
3. flip Boolean this will simply flip your display.
|
||||||
|
|
||||||
|
|
||||||
```python
|
```python
|
||||||
oled_ext = oled([{0:OledReactionType.LAYER,1:["1.bmp","2.bmp","3.bmp","4.bmp"]}],toDisplay=OledDisplayMode.IMG,flip=True)
|
oled_ext = Oled(OledData(image={0:OledReactionType.LAYER,1:["1.bmp","2.bmp","1.bmp","2.bmp"]}),toDisplay=OledDisplayMode.IMG,flip=False)
|
||||||
```
|
```
|
||||||
In this code example we are saying to react to the layer change and load a image filed named "1.bmp" for layer one and "2.bmp" for layer two and so on.
|
In this code example we are saying to react to the layer change and load a image filed named "1.bmp" for layer one and "2.bmp" for layer two and so on.
|
||||||
|
|
||||||
@ -69,14 +69,12 @@ Your images need to be 128x32px and should only be black and white. After you ha
|
|||||||
### Text
|
### Text
|
||||||
Ok now we get into something that looks a lot more complicated but we will get though it.
|
Ok now we get into something that looks a lot more complicated but we will get though it.
|
||||||
|
|
||||||
Almost everything is the same We swap toDisplay to TXT and there are more things in the array. Lets get into that array.
|
Almost everything is the same We swap toDisplay to TXT and there are more items in the OledData Class, lets get into that.
|
||||||
|
|
||||||
So each item in the array is a corner of the oled display
|
1. top left
|
||||||
|
2. top right
|
||||||
0. top left
|
3. bottom left
|
||||||
1. top right
|
4. bottom right
|
||||||
2. bottom left
|
|
||||||
3. bottom right
|
|
||||||
|
|
||||||
After that is the same as the previous example. Each one has two fields 0:the reaction type. 1:what to display
|
After that is the same as the previous example. Each one has two fields 0:the reaction type. 1:what to display
|
||||||
|
|
||||||
@ -85,12 +83,27 @@ In this code we will always display the word "layer" in the top left corner of t
|
|||||||
|
|
||||||
|
|
||||||
```python
|
```python
|
||||||
oled_ext = oled([
|
oled_ext = Oled(
|
||||||
{0:OledReactionType.STATIC,1:["layer"]},
|
OledData(
|
||||||
{0:OledReactionType.LAYER,1:["1","2","3","4"]},
|
corner_one={0:OledReactionType.STATIC,1:["layer"]},
|
||||||
{0:OledReactionType.LAYER,1:["base","raise","lower","adjust"]},
|
corner_two={0:OledReactionType.LAYER,1:["1","2","3","4"]},
|
||||||
{0:OledReactionType.LAYER,1:["qwerty","nums","shifted","leds"]}
|
corner_three={0:OledReactionType.LAYER,1:["base","raise","lower","adjust"]},
|
||||||
],toDisplay=OledDisplayMode.TXT,flip=False)
|
corner_four={0:OledReactionType.LAYER,1:["qwerty","nums","shifted","leds"]}
|
||||||
|
),
|
||||||
|
toDisplay=OledDisplayMode.TXT,flip=False)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Note
|
||||||
|
your oled data can be a variable as shown below with images
|
||||||
|
|
||||||
|
```python
|
||||||
|
oled_display_data=OledData(image={0:OledReactionType.LAYER,1:["1.bmp","2.bmp","1.bmp","2.bmp"]})
|
||||||
|
|
||||||
|
oled_ext = Oled(oled_display_data,toDisplay=OledDisplayMode.IMG,flip=False)
|
||||||
|
```
|
||||||
|
|
||||||
|
### Text example
|
||||||
|
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
@ -18,6 +18,21 @@ class OledReactionType:
|
|||||||
STATIC = 0
|
STATIC = 0
|
||||||
LAYER = 1
|
LAYER = 1
|
||||||
|
|
||||||
|
class OledData:
|
||||||
|
def __init__(
|
||||||
|
self,
|
||||||
|
image=None,
|
||||||
|
corner_one=None,
|
||||||
|
corner_two=None,
|
||||||
|
corner_three=None,
|
||||||
|
corner_four=None,
|
||||||
|
):
|
||||||
|
if image:
|
||||||
|
self.data=[image]
|
||||||
|
elif corner_one and corner_two and corner_three and corner_four:
|
||||||
|
self.data= [corner_one,corner_two,corner_three,corner_four]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class Oled(Extension):
|
class Oled(Extension):
|
||||||
def __init__(
|
def __init__(
|
||||||
@ -30,7 +45,7 @@ class Oled(Extension):
|
|||||||
):
|
):
|
||||||
displayio.release_displays()
|
displayio.release_displays()
|
||||||
self.rotation = 180 if flip else 0
|
self.rotation = 180 if flip else 0
|
||||||
self._views = views
|
self._views = views.data
|
||||||
self._toDisplay = toDisplay
|
self._toDisplay = toDisplay
|
||||||
self._width = oWidth
|
self._width = oWidth
|
||||||
self._height = oHeight
|
self._height = oHeight
|
||||||
|
Loading…
x
Reference in New Issue
Block a user