40
40
"""
41
41
42
42
try :
43
- from typing import Union , Tuple
43
+ from typing import Union , Tuple , Optional
44
44
except ImportError :
45
45
pass
46
46
@@ -69,12 +69,12 @@ class _ClueSimpleTextDisplay:
69
69
70
70
def __init__ ( # pylint: disable=too-many-arguments
71
71
self ,
72
- title : str = None ,
72
+ title : Optional [ str ] = None ,
73
73
title_color : Union [int , Tuple ] = 0xFFFFFF ,
74
74
title_scale : int = 1 ,
75
75
text_scale : int = 1 ,
76
- font : str = None ,
77
- colors : Tuple = None ,
76
+ font : Optional [ str ] = None ,
77
+ colors : Optional [ Tuple [ Tuple [ int , int , int ], ...]] = None ,
78
78
):
79
79
# pylint: disable=import-outside-toplevel
80
80
import displayio
@@ -138,7 +138,7 @@ def __getitem__(self, item: int):
138
138
)
139
139
return self ._lines [item ]
140
140
141
- def add_text_line (self , color : int = 0xFFFFFF ):
141
+ def add_text_line (self , color : Union [ int , Tuple [ int , int , int ]] = 0xFFFFFF ):
142
142
"""Adds a line on the display of the specified color and returns the label object."""
143
143
text_label = self ._label .Label (self ._font , text = "" , color = color )
144
144
text_label .x = 0
@@ -387,7 +387,7 @@ def shake(
387
387
return total_accel > shake_threshold
388
388
389
389
@property
390
- def acceleration (self ) -> Tuple :
390
+ def acceleration (self ) -> Tuple [ int , int , int ] :
391
391
"""Obtain acceleration data from the x, y and z axes.
392
392
393
393
.. image :: ../docs/_static/accelerometer.jpg
@@ -407,7 +407,7 @@ def acceleration(self) -> Tuple:
407
407
return self ._accelerometer .acceleration
408
408
409
409
@property
410
- def gyro (self ) -> Tuple :
410
+ def gyro (self ) -> Tuple [ int , int , int ] :
411
411
"""Obtain x, y, z angular velocity values in degrees/second.
412
412
413
413
.. image :: ../docs/_static/accelerometer.jpg
@@ -427,7 +427,7 @@ def gyro(self) -> Tuple:
427
427
return self ._accelerometer .gyro
428
428
429
429
@property
430
- def magnetic (self ) -> Tuple :
430
+ def magnetic (self ) -> Tuple [ int , int , int ] :
431
431
"""Obtain x, y, z magnetic values in microteslas.
432
432
433
433
.. image :: ../docs/_static/magnetometer.jpg
@@ -469,7 +469,7 @@ def proximity(self) -> int:
469
469
return self ._sensor .proximity
470
470
471
471
@property
472
- def color (self ) -> Tuple :
472
+ def color (self ) -> Tuple [ int , int , int , int ] :
473
473
"""The red, green, blue, and clear light values. (r, g, b, c)
474
474
475
475
.. image :: ../docs/_static/proximity.jpg
@@ -619,7 +619,7 @@ def sea_level_pressure(self) -> float:
619
619
return self ._pressure .sea_level_pressure
620
620
621
621
@sea_level_pressure .setter
622
- def sea_level_pressure (self , value : int ):
622
+ def sea_level_pressure (self , value : float ):
623
623
self ._pressure .sea_level_pressure = value
624
624
625
625
@property
@@ -702,7 +702,7 @@ def _generate_sample(self, length: int = 100):
702
702
self ._audio_out = audiopwmio .PWMAudioOut (board .SPEAKER )
703
703
self ._sine_wave_sample = audiocore .RawSample (self ._sine_wave )
704
704
705
- def play_tone (self , frequency : int , duration : int ):
705
+ def play_tone (self , frequency : int , duration : float ):
706
706
"""Produce a tone using the speaker. Try changing frequency to change
707
707
the pitch of the tone.
708
708
@@ -868,12 +868,12 @@ def loud_sound(self, sound_threshold: int = 200) -> bool:
868
868
869
869
@staticmethod
870
870
def simple_text_display ( # pylint: disable=too-many-arguments
871
- title : str = None ,
871
+ title : Optional [ str ] = None ,
872
872
title_color : Tuple = (255 , 255 , 255 ),
873
873
title_scale : int = 1 ,
874
874
text_scale : int = 1 ,
875
- font : str = None ,
876
- colors : Tuple = None ,
875
+ font : Optional [ str ] = None ,
876
+ colors : Optional [ Tuple [ Tuple [ int , int , int ], ...]] = None ,
877
877
):
878
878
"""Display lines of text on the CLUE display. Lines of text are created in order as shown
879
879
in the example below. If you skip a number, the line will be shown blank on the display,
0 commit comments