Skip to content

Dial gauge #13

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Mar 18, 2021
1,120 changes: 1,120 additions & 0 deletions adafruit_displayio_layout/widgets/dial.py

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@

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

.. automodule:: adafruit_displayio_layout.widgets.dial
:members:
:member-order: bysource
:inherited-members:

.. inheritance-diagram:: adafruit_displayio_layout.widgets.dial

.. automodule:: adafruit_displayio_layout.widgets.icon_widget
:members:
:member-order: bysource
4 changes: 3 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
autodoc_mock_imports = [
"displayio",
"adafruit_display_shapes",
"vectorio",
"bitmaptools",
"terminalio",
"adafruit_imageload",
"adafruit_display_text",
Expand All @@ -43,7 +45,7 @@
}

# Show the docstring from both the class and its __init__() method.
autoclass_content = "both"
autoclass_content = "init"

# Add any paths that contain templates here, relative to this directory.
templates_path = ["_templates"]
Expand Down
Binary file added docs/dial.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions docs/dial.gif.license
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SPDX-FileCopyrightText: 2021 Kevin Matocha

SPDX-License-Identifier: MIT
Binary file added docs/dial_variables_angles.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions docs/dial_variables_angles.png.license
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SPDX-FileCopyrightText: 2021 Kevin Matocha

SPDX-License-Identifier: MIT
Binary file added docs/dial_variables_clip_needle.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions docs/dial_variables_clip_needle.png.license
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SPDX-FileCopyrightText: 2021 Kevin Matocha

SPDX-License-Identifier: MIT
Binary file added docs/dial_variables_min_max_values.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions docs/dial_variables_min_max_values.png.license
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SPDX-FileCopyrightText: 2021 Kevin Matocha

SPDX-License-Identifier: MIT
Binary file added docs/dial_variables_ticks.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions docs/dial_variables_ticks.png.license
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SPDX-FileCopyrightText: 2021 Kevin Matocha

SPDX-License-Identifier: MIT
61 changes: 61 additions & 0 deletions examples/displayio_layout_dial_simpletest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# SPDX-FileCopyrightText: 2021 Kevin Matocha
#
# SPDX-License-Identifier: MIT
#############################
"""
This is a basic demonstration of a Dial widget.
"""

import time
import board
import displayio
import terminalio
from adafruit_displayio_layout.widgets.dial import Dial

# Fonts used for the Dial tick labels
tick_font = terminalio.FONT

display = board.DISPLAY # create the display on the PyPortal or Clue (for example)
# otherwise change this to setup the display
# for display chip driver and pinout you have (e.g. ILI9341)


# Define the minimum and maximum values for the dial
minimum_value = 0
maximum_value = 100

# Create a Dial widget
my_dial = Dial(
x=20, # set x-position of the dial inside of my_group
y=20, # set y-position of the dial inside of my_group
width=180, # requested width of the dial
height=180, # requested height of the dial
padding=25, # add 25 pixels around the dial to make room for labels
start_angle=-120, # left angle position at -120 degrees
sweep_angle=240, # total sweep angle of 240 degrees
min_value=minimum_value, # set the minimum value shown on the dial
max_value=maximum_value, # set the maximum value shown on the dial
tick_label_font=tick_font, # the font used for the tick labels
tick_label_scale=2.0, # the scale factor for the tick label font
)

my_group = displayio.Group(max_size=1)
my_group.append(my_dial)

display.show(my_group) # add high level Group to the display

step_size = 1

while True:

# run the dial from minimum to maximum
for this_value in range(minimum_value, maximum_value + 1, step_size):
my_dial.value = this_value
display.refresh() # force the display to refresh
time.sleep(0.5)

# run the dial from maximum to minimum
for this_value in range(maximum_value, minimum_value - 1, -step_size):
my_dial.value = this_value
display.refresh() # force the display to refresh
time.sleep(0.5)