31
31
import terminalio
32
32
from bitmaptools import draw_line
33
33
from vectorio import Circle
34
- from adafruit_display_text import bitmap_label
35
34
from ulab import numpy as np
36
35
37
36
41
40
42
41
# pylint: disable=too-many-arguments, too-many-instance-attributes, too-many-locals
43
42
# pylint: disable=too-many-statements
43
+ # pylint: disable=unused-import, import-outside-toplevel, undefined-variable
44
+
45
+
44
46
class Uplot (displayio .Group ):
45
47
"""
46
48
Canvas Class to add different elements to the screen.
@@ -99,6 +101,8 @@ def __init__(
99
101
100
102
self ._cartesianfirst = True
101
103
104
+ self ._showtext = False
105
+
102
106
self ._tickheight = 8
103
107
self ._tickcolor = 0xFFFFFF
104
108
self ._showticks = False
@@ -296,9 +300,10 @@ def _draw_ticks(self, x: int, y: int) -> None:
296
300
self ._newymin - self ._tickheight ,
297
301
2 ,
298
302
)
299
- self .show_text (
300
- "{:.2f}" .format (ticksxnorm [i ]), tick , self ._newymin , (0.5 , 0.0 )
301
- )
303
+ if self ._showtext :
304
+ self .show_text (
305
+ "{:.2f}" .format (ticksxnorm [i ]), tick , self ._newymin , (0.5 , 0.0 )
306
+ )
302
307
for i , tick in enumerate (ticksyrenorm ):
303
308
draw_line (
304
309
self ._plotbitmap ,
@@ -308,9 +313,10 @@ def _draw_ticks(self, x: int, y: int) -> None:
308
313
tick ,
309
314
2 ,
310
315
)
311
- self .show_text (
312
- "{:.2f}" .format (ticksynorm [i ]), self ._newxmin , tick , (1.0 , 0.5 )
313
- )
316
+ if self ._showtext :
317
+ self .show_text (
318
+ "{:.2f}" .format (ticksynorm [i ]), self ._newxmin , tick , (1.0 , 0.5 )
319
+ )
314
320
for tick in subticksxrenorm :
315
321
draw_line (
316
322
self ._plotbitmap ,
@@ -335,7 +341,11 @@ def _draw_ticks(self, x: int, y: int) -> None:
335
341
self ._draw_gridy (ticksyrenorm )
336
342
337
343
def tick_params (
338
- self , tickheight : int = 8 , tickcolor : int = 0xFFFFFF , tickgrid : bool = False
344
+ self ,
345
+ tickheight : int = 8 ,
346
+ tickcolor : int = 0xFFFFFF ,
347
+ tickgrid : bool = False ,
348
+ showtext : bool = False ,
339
349
) -> None :
340
350
"""
341
351
Function to set ticks parameters
@@ -352,6 +362,9 @@ def tick_params(
352
362
self ._tickheight = tickheight
353
363
self ._plot_palette [2 ] = tickcolor
354
364
self ._tickgrid = tickgrid
365
+ self ._showtext = showtext
366
+ if self ._showtext :
367
+ from adafruit_display_text import bitmap_label
355
368
356
369
def _draw_gridx (self , ticks_data : list [int ]) -> None :
357
370
"""
@@ -419,8 +432,8 @@ def show_text(
419
432
:param Tuple anchorpoint: Display_text anchor point. Defaults to (0.5, 0.0)
420
433
:return: None
421
434
"""
422
-
423
- text_toplot = bitmap_label .Label (terminalio .FONT , text = text , x = x , y = y )
424
- text_toplot .anchor_point = anchorpoint
425
- text_toplot .anchored_position = (x , y )
426
- self .append (text_toplot )
435
+ if self . _showtext :
436
+ text_toplot = bitmap_label .Label (terminalio .FONT , text = text , x = x , y = y )
437
+ text_toplot .anchor_point = anchorpoint
438
+ text_toplot .anchored_position = (x , y )
439
+ self .append (text_toplot )
0 commit comments