61
61
import math
62
62
import board
63
63
import digitalio
64
- import audiobusio
65
- import audiopwmio
66
- import audiocore
67
- import gamepad
68
- import touchio
69
64
import neopixel
70
65
import adafruit_apds9960 .apds9960
71
66
import adafruit_bmp280
72
67
import adafruit_lis3mdl
73
68
import adafruit_lsm6ds
74
69
import adafruit_sht31d
70
+ import audiobusio
71
+ import audiopwmio
72
+ import audiocore
73
+ import gamepad
74
+ import touchio
75
75
76
76
__version__ = "0.0.0-auto.0"
77
77
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_CLUE.git"
78
78
79
- class _DisplayClueData :
80
- """Display sensor data ."""
79
+ class _ClueSimpleTextDisplay :
80
+ """Easily display lines of text on CLUE display ."""
81
81
def __init__ (self , title = "CLUE Sensor Data" , title_color = 0xFFFFFF , title_scale = 1 , # pylint: disable=too-many-arguments
82
- clue_data_scale = 1 , font = None , num_lines = 1 , colors = None ):
82
+ text_scale = 1 , font = None , num_lines = 1 , colors = None ):
83
83
import displayio
84
84
import terminalio
85
85
from adafruit_display_text import label
@@ -104,8 +104,8 @@ def __init__(self, title="CLUE Sensor Data", title_color=0xFFFFFF, title_scale=1
104
104
title .y = 8
105
105
self ._y = title .y + 20
106
106
107
- self .data_group = displayio .Group (max_size = 20 , scale = clue_data_scale )
108
- self .data_group .append (title )
107
+ self .text_group = displayio .Group (max_size = 20 , scale = text_scale )
108
+ self .text_group .append (title )
109
109
110
110
self ._lines = []
111
111
for num in range (num_lines ):
@@ -117,17 +117,17 @@ def __getitem__(self, item):
117
117
118
118
def add_text_line (self , color = 0xFFFFFF ):
119
119
"""Adds a line on the display of the specified color and returns the label object."""
120
- clue_data_label = self ._label .Label (self ._font , text = "" , max_glyphs = 45 , color = color )
121
- clue_data_label .x = 0
122
- clue_data_label .y = self ._y
123
- self ._y = clue_data_label .y + 13
124
- self .data_group .append (clue_data_label )
120
+ text_label = self ._label .Label (self ._font , text = "" , max_glyphs = 45 , color = color )
121
+ text_label .x = 0
122
+ text_label .y = self ._y
123
+ self ._y = text_label .y + 13
124
+ self .text_group .append (text_label )
125
125
126
- return clue_data_label
126
+ return text_label
127
127
128
128
def show (self ):
129
129
"""Call show() to display the data list."""
130
- self ._display .show (self .data_group )
130
+ self ._display .show (self .text_group )
131
131
132
132
def show_terminal (self ):
133
133
"""Revert to terminalio screen."""
@@ -794,9 +794,9 @@ def loud_sound(self, sound_threshold=200):
794
794
return self .sound_level > sound_threshold
795
795
796
796
@staticmethod
797
- def display_clue_data (title = "CLUE Sensor Data" , title_color = (255 , 255 , 255 ), title_scale = 1 , # pylint: disable=too-many-arguments
798
- num_lines = 1 , clue_data_scale = 1 , font = None , colors = None ):
799
- """Display CLUE data as lines of text.
797
+ def simple_text_display (title = "CLUE Sensor Data" , title_color = (255 , 255 , 255 ), title_scale = 1 , # pylint: disable=too-many-arguments
798
+ num_lines = 1 , text_scale = 1 , font = None , colors = None ):
799
+ """Display lines of text on the CLUE display .
800
800
801
801
Setup occurs before the loop. For data to be dynamically updated on the display, you must
802
802
include the data call in the loop by using ``.text =``. For example, if setup is saved as
@@ -808,7 +808,7 @@ def display_clue_data(title="CLUE Sensor Data", title_color=(255, 255, 255), tit
808
808
:param title_color: The color of the displayed title. Defaults to white 255, 255, 255).
809
809
:param int title_scale: Scale the size of the title. Defaults to 1.
810
810
:param int num_lines: The number of lines of data you intend to display. Defaults to 1.
811
- :param int clue_data_scale : Scale the size of the data lines. Scales the title as well.
811
+ :param int text_scale : Scale the size of the data lines. Scales the title as well.
812
812
Defaults to 1.
813
813
:param str font: The font to use to display the title and data. Defaults to built in
814
814
``terminalio.FONT``.
@@ -836,9 +836,9 @@ def display_clue_data(title="CLUE Sensor Data", title_color=(255, 255, 255), tit
836
836
clue_data[1].text = "Gyro: {:.2f} {:.2f} {:.2f}".format(*clue.gyro)
837
837
clue_data[2].text = "Magnetic: {:.3f} {:.3f} {:.3f}".format(*clue.magnetic)
838
838
"""
839
- return _DisplayClueData (title = title , title_color = title_color , title_scale = title_scale ,
840
- num_lines = num_lines , clue_data_scale = clue_data_scale , font = font ,
841
- colors = colors )
839
+ return _ClueSimpleTextDisplay (title = title , title_color = title_color , title_scale = title_scale ,
840
+ num_lines = num_lines , text_scale = text_scale , font = font ,
841
+ colors = colors )
842
842
843
843
844
844
clue = Clue () # pylint: disable=invalid-name
0 commit comments