Skip to content

Commit f0bcf13

Browse files
committed
going for v0.3.0
1 parent ce73a85 commit f0bcf13

3 files changed

Lines changed: 36 additions & 6 deletions

File tree

dumbdisplay/_dumbdisplay.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313

1414

1515
class DDAutoPin:
16-
def __init__(self, orientation, *layers):
16+
def __init__(self, orientation: str, *layers):
1717
'''
18-
:param orientation: H or V
18+
:param orientation: H or V or S
1919
:param layers: layer or "pinner"
2020
'''
2121
self.orientation = orientation
@@ -24,16 +24,15 @@ def build(self):
2424
return self._build_layout()
2525
def pin(self, dd):
2626
layout_spec = self._build_layout()
27-
if layout_spec is not None:
28-
dd.configAutoPin(layout_spec)
27+
dd.configAutoPin(layout_spec)
2928
def _build_layout(self):
3029
layout_spec = None
3130
for layer in self.layers:
3231
if layout_spec is None:
3332
layout_spec = ''
3433
else:
3534
layout_spec += '+'
36-
if type(layer) == DDAutoPin:
35+
if type(layer) == DDAutoPin or type(layer) == DDPaddedAutoPin:
3736
layout_spec += layer._build_layout()
3837
else:
3938
layout_spec += layer.layer_id
@@ -43,6 +42,17 @@ def _build_layout(self):
4342
layout_spec = str(self.orientation) + '(*)'
4443
return layout_spec
4544

45+
class DDPaddedAutoPin(DDAutoPin):
46+
def __init__(self, orientation: str, left: int, top: int, right: int, bottom: int, *layers):
47+
self.left = left
48+
self.top = top
49+
self.right = right
50+
self.bottom = bottom
51+
super().__init__(orientation, *layers)
52+
def _build_layout(self):
53+
layout_spec = super()._build_layout()
54+
return f"S/{self.left}-{self.top}-{self.right}-{self.bottom}({layout_spec})"
55+
4656

4757
class DumbDisplay(DumbDisplayImpl):
4858
@staticmethod

dumbdisplay/core.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from ._dumbdisplay import DumbDisplay
22
from ._dumbdisplay import DDAutoPin as AutoPin
3+
from ._dumbdisplay import DDPaddedAutoPin as PaddedAutoPin
34
from ._ddlayer import DDFeedback as Feedback
45

56
from ._ddiobase import DD_DEF_PORT

samples/neopixels/main.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ def ShowNeoPixels(*pixels):
7676
from dumbdisplay.layer_lcd import *
7777
from dumbdisplay.layer_graphical import *
7878
from dumbdisplay.layer_joystick import *
79+
from dumbdisplay.layer_7segrow import *
7980

8081
# create DumbDisplay
8182
if DumbDisplay.runningWithMicropython():
@@ -105,6 +106,19 @@ def ShowNeoPixels(*pixels):
105106
advance_button.writeCenteredLine(">>>")
106107
advance_button.enableFeedback("fl")
107108

109+
110+
r_7seg_layer = Layer7SegmentRow(dd,2)
111+
r_7seg_layer.border(10, "black")
112+
r_7seg_layer.noBackgroundColor()
113+
114+
g_7seg_layer = Layer7SegmentRow(dd,2)
115+
g_7seg_layer.border(10, "black")
116+
g_7seg_layer.noBackgroundColor()
117+
118+
b_7seg_layer = Layer7SegmentRow(dd,2)
119+
b_7seg_layer.border(10, "black")
120+
b_7seg_layer.noBackgroundColor()
121+
108122
# create a graphical layer (LayerGraphical) to show the color set using the following sliders
109123
color_layer = LayerGraphical(dd, 255, 255)
110124
color_layer.border(5, "black", "round", 2)
@@ -128,7 +142,9 @@ def ShowNeoPixels(*pixels):
128142
# auto "pin" the above layers
129143
AutoPin('V',
130144
AutoPin('H', auto_advance_tab, advance_button),
131-
color_layer,
145+
AutoPin('S',
146+
color_layer,
147+
PaddedAutoPin('H', 25, 25, 25, 25, r_7seg_layer, g_7seg_layer, b_7seg_layer)),
132148
r_slider_layer,
133149
g_slider_layer,
134150
b_slider_layer).pin(dd)
@@ -208,6 +224,9 @@ def ShowNeoPixels(*pixels):
208224
if r != old_r or g != old_g or b != old_b:
209225
# set the background color of the color layer to the new (r, g, b) color
210226
color_layer.backgroundColor(RGB_COLOR(r, g, b))
227+
r_7seg_layer.showHexNumber(r)
228+
g_7seg_layer.showHexNumber(g)
229+
b_7seg_layer.showHexNumber(b)
211230
if sync_sliders:
212231
# check to see if RGB needs to be synced with the sliders
213232
if r != old_r:

0 commit comments

Comments
 (0)