Skip to content

Commit dc49d9a

Browse files
committed
going for v0.3.0
1 parent 043c8e4 commit dc49d9a

15 files changed

Lines changed: 132 additions & 30 deletions

dumbdisplay/_ddlayer.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ def DD_RGB_COLOR(r, g, b):
55
def _DD_INT_ARG(val):
66
return str(int(val))
77

8+
def _DD_FLOAT_ARG(val):
9+
return str(float(val))
10+
811
def _DD_BOOL_ARG(b):
912
if b:
1013
return "1"
@@ -125,7 +128,7 @@ def disableFeedback(self):
125128
'''disable feedback'''
126129
self.dd._sendCommand(self.layer_id, "feedback", _DD_BOOL_ARG(False))
127130
self._feedback_handler = None
128-
def getFeedback(self):
131+
def getFeedback(self) -> DDFeedback:
129132
'''
130133
get any feedback as the structure {type, x, y}
131134
:return: None if none (or when "handler" set)

dumbdisplay/_ddlayer_7segrow.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ def __init__(self, dd, digit_count = 1):
88
:param dd: DumbDisplay object
99
:param digit_count: number of digits / # rows
1010
'''
11-
layer_id = dd._createLayer(str("7segrow"), str(digit_count))
11+
layer_id = dd._createLayer("7segrow", str(digit_count))
1212
super().__init__(dd, layer_id)
1313
def segmentColor(self, color):
1414
'''set segment color'''

dumbdisplay/_ddlayer_graphical.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ def __init__(self, dd, width, height):
99
:param width: width
1010
:param height: height
1111
'''
12-
layer_id = dd._createLayer(str("graphical"), _DD_INT_ARG(width), _DD_INT_ARG(height))
12+
layer_id = dd._createLayer("graphical", _DD_INT_ARG(width), _DD_INT_ARG(height))
1313
super().__init__(dd, layer_id)
1414
def setCursor(self, x, y):
1515
self.dd._sendCommand(self.layer_id, "setcursor", str(x), str(y))

dumbdisplay/_ddlayer_joystick.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
from ._ddlayer import DDLayer
2+
from ._ddlayer import _DD_COLOR_ARG, _DD_BOOL_ARG, _DD_INT_ARG, _DD_FLOAT_ARG
3+
4+
class DDLayerJoystick(DDLayer):
5+
'''Virtual joystick'''
6+
def __init__(self, dd, maxStickValue: int = 1023, directions: str = "", stickLookScaleFactor: float = 1.0):
7+
'''
8+
:param dd: DumbDisplay object
9+
:param maxStickValue: the max value of the stick; e.g. 255 or 1023 (the default); min is 15
10+
:param directions: "lr" or "hori": left-to-right; "tb" or "vert": top-to-bottom; "rl": right-to-left; "bt": bottom-to-top;
11+
use "+" combines the above like "lr+tb" to mean both directions; "" the same as "lr+tb"
12+
:param stickLookScaleFactor: the scaling factor of the stick (UI); 1 by default
13+
'''
14+
layer_id = dd._createLayer("joystick", _DD_INT_ARG(maxStickValue), directions, _DD_FLOAT_ARG(stickLookScaleFactor))
15+
super().__init__(dd, layer_id)
16+
def autoRecenter(self, auto_recenter: bool = True):
17+
self.dd._sendCommand(self.layer_id, "autorecenter", _DD_BOOL_ARG(auto_recenter))
18+
def colors(self, stick_color: str, stick_outline_color: str, socket_color: str, socket_outline_color):
19+
self.dd._sendCommand(self.layer_id, "colors", _DD_COLOR_ARG(stick_color), _DD_COLOR_ARG(stick_outline_color), _DD_COLOR_ARG(socket_color), _DD_COLOR_ARG(socket_outline_color))
20+
def moveToPos(self, x: int, y: int, send_feedback: bool = False):
21+
'''
22+
move joystick position (if joystick is single directional, will only move in the movable direction)
23+
:param bg_color: "" means default
24+
:param x: x to move to
25+
:param y: y to move to
26+
:param send_feedback: if true, will send "feedback" for the move (regardless of the current position)
27+
'''
28+
self.dd._sendCommand(self.layer_id, "movetopos", str(x), str(y), _DD_BOOL_ARG(send_feedback))
29+
def moveToCenter(self, send_feedback: bool = False):
30+
'''
31+
move joystick to the center
32+
:param send_feedback: if true, will send "feedback" for the move (regardless of the current position)
33+
'''
34+
self.dd._sendCommand(self.layer_id, "movetocenter", _DD_BOOL_ARG(send_feedback))
35+
36+

dumbdisplay/_ddlayer_lcd.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def __init__(self, dd, col_count = 16, row_count = 2, char_height = 0, font_name
1212
:param char_height: char height
1313
:param font_name: font name
1414
'''
15-
layer_id = dd._createLayer(str("lcd"), str(col_count), str(row_count), str(char_height), font_name)
15+
layer_id = dd._createLayer("lcd", str(col_count), str(row_count), str(char_height), font_name)
1616
super().__init__(dd, layer_id)
1717
def print(self, text):
1818
self.dd._sendCommand(self.layer_id, "print", str(text))

dumbdisplay/_ddlayer_ledgrid.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def __init__(self, dd, col_count = 1, row_count = 1, sub_col_count = 1, sub_row_
1212
:param sub_col_count: # sub columns of each cell
1313
:param sub_row_count: # sub rows of each cell
1414
'''
15-
layer_id = dd._createLayer(str("ledgrid"), str(col_count), str(row_count), str(sub_col_count), str(sub_row_count))
15+
layer_id = dd._createLayer("ledgrid", str(col_count), str(row_count), str(sub_col_count), str(sub_row_count))
1616
super().__init__(dd, layer_id)
1717
def turnOn(self, x = 0, y = 0):
1818
'''turn on LED @ (x, y)'''

dumbdisplay/_ddlayer_plotter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def __init__(self, dd, width, height, pixels_per_second = 10):
1111
:param height: height
1212
:param pixels_per_second: # pixel to scroll per second
1313
'''
14-
layer_id = dd._createLayer(str("plotterview"), str(width), str(height), str(pixels_per_second))
14+
layer_id = dd._createLayer("plotterview", str(width), str(height), str(pixels_per_second))
1515
super().__init__(dd, layer_id)
1616
def label(self, no_key_label = None, **key_label_pairs):
1717
'''set labels of keys; if key has no label, the key will be the label'''

dumbdisplay/_dumbdisplay.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@ def _build_layout(self):
3838
else:
3939
layout_spec += layer.layer_id
4040
if layout_spec is not None:
41-
layout_spec = str(self.orientation) + '(' + layout_spec + ")"
41+
layout_spec = str(self.orientation) + '(' + layout_spec + ')'
42+
else:
43+
layout_spec = str(self.orientation) + '(*)'
4244
return layout_spec
4345

4446

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 ._ddlayer import DDFeedback as Feedback
34

45
from ._ddiobase import DD_DEF_PORT
56
from ._ddlayer import DD_RGB_COLOR as RGB_COLOR

dumbdisplay/layer_joystick.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from ._ddlayer_joystick import DDLayerJoystick as LayerJoystick

0 commit comments

Comments
 (0)