Skip to content

Commit 0b0288a

Browse files
authored
Merge pull request #13 from kmatch98/dial_gauge
Dial gauge
2 parents 054b12a + e155aaa commit 0b0288a

14 files changed

+1206
-1
lines changed

adafruit_displayio_layout/widgets/dial.py

Lines changed: 1120 additions & 0 deletions
Large diffs are not rendered by default.

docs/api.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,13 @@
2323

2424
.. inheritance-diagram:: adafruit_displayio_layout.widgets.switch_round
2525

26+
.. automodule:: adafruit_displayio_layout.widgets.dial
27+
:members:
28+
:member-order: bysource
29+
:inherited-members:
30+
31+
.. inheritance-diagram:: adafruit_displayio_layout.widgets.dial
32+
2633
.. automodule:: adafruit_displayio_layout.widgets.icon_widget
2734
:members:
2835
:member-order: bysource

docs/conf.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131
autodoc_mock_imports = [
3232
"displayio",
3333
"adafruit_display_shapes",
34+
"vectorio",
35+
"bitmaptools",
3436
"terminalio",
3537
"adafruit_imageload",
3638
"adafruit_display_text",
@@ -43,7 +45,7 @@
4345
}
4446

4547
# Show the docstring from both the class and its __init__() method.
46-
autoclass_content = "both"
48+
autoclass_content = "init"
4749

4850
# Add any paths that contain templates here, relative to this directory.
4951
templates_path = ["_templates"]

docs/dial.gif

189 KB
Loading

docs/dial.gif.license

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
SPDX-FileCopyrightText: 2021 Kevin Matocha
2+
3+
SPDX-License-Identifier: MIT

docs/dial_variables_angles.png

70 KB
Loading
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
SPDX-FileCopyrightText: 2021 Kevin Matocha
2+
3+
SPDX-License-Identifier: MIT

docs/dial_variables_clip_needle.png

66.2 KB
Loading
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
SPDX-FileCopyrightText: 2021 Kevin Matocha
2+
3+
SPDX-License-Identifier: MIT
24.4 KB
Loading
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
SPDX-FileCopyrightText: 2021 Kevin Matocha
2+
3+
SPDX-License-Identifier: MIT

docs/dial_variables_ticks.png

59.4 KB
Loading

docs/dial_variables_ticks.png.license

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
SPDX-FileCopyrightText: 2021 Kevin Matocha
2+
3+
SPDX-License-Identifier: MIT
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# SPDX-FileCopyrightText: 2021 Kevin Matocha
2+
#
3+
# SPDX-License-Identifier: MIT
4+
#############################
5+
"""
6+
This is a basic demonstration of a Dial widget.
7+
"""
8+
9+
import time
10+
import board
11+
import displayio
12+
import terminalio
13+
from adafruit_displayio_layout.widgets.dial import Dial
14+
15+
# Fonts used for the Dial tick labels
16+
tick_font = terminalio.FONT
17+
18+
display = board.DISPLAY # create the display on the PyPortal or Clue (for example)
19+
# otherwise change this to setup the display
20+
# for display chip driver and pinout you have (e.g. ILI9341)
21+
22+
23+
# Define the minimum and maximum values for the dial
24+
minimum_value = 0
25+
maximum_value = 100
26+
27+
# Create a Dial widget
28+
my_dial = Dial(
29+
x=20, # set x-position of the dial inside of my_group
30+
y=20, # set y-position of the dial inside of my_group
31+
width=180, # requested width of the dial
32+
height=180, # requested height of the dial
33+
padding=25, # add 25 pixels around the dial to make room for labels
34+
start_angle=-120, # left angle position at -120 degrees
35+
sweep_angle=240, # total sweep angle of 240 degrees
36+
min_value=minimum_value, # set the minimum value shown on the dial
37+
max_value=maximum_value, # set the maximum value shown on the dial
38+
tick_label_font=tick_font, # the font used for the tick labels
39+
tick_label_scale=2.0, # the scale factor for the tick label font
40+
)
41+
42+
my_group = displayio.Group(max_size=1)
43+
my_group.append(my_dial)
44+
45+
display.show(my_group) # add high level Group to the display
46+
47+
step_size = 1
48+
49+
while True:
50+
51+
# run the dial from minimum to maximum
52+
for this_value in range(minimum_value, maximum_value + 1, step_size):
53+
my_dial.value = this_value
54+
display.refresh() # force the display to refresh
55+
time.sleep(0.5)
56+
57+
# run the dial from maximum to minimum
58+
for this_value in range(maximum_value, minimum_value - 1, -step_size):
59+
my_dial.value = this_value
60+
display.refresh() # force the display to refresh
61+
time.sleep(0.5)

0 commit comments

Comments
 (0)