/ examples / equalizer_simpletest.py
equalizer_simpletest.py
 1  # SPDX-FileCopyrightText: 2021 Jose David M.
 2  #
 3  # SPDX-License-Identifier: MIT
 4  #############################
 5  """
 6  This is a basic demonstration of a Equalizer widget.
 7  """
 8  
 9  import time
10  import board
11  import displayio
12  from equalizer.equalizer import Equalizer
13  
14  display = board.DISPLAY  # create the display on the PyPortal or Clue (for example)
15  # otherwise change this to setup the display
16  # for display chip driver and pinout you have (e.g. ILI9341)
17  
18  
19  # Create a Equalizer widget
20  my_equa = Equalizer(
21      x=100,
22      y=100,
23      width=100,
24      height=100,
25      number_bars=5,
26      bar_width=10,
27      number_segments=6,
28      segments_height=25,
29      bar_best_fit=True,
30      pad_x=2,
31  )
32  
33  my_group = displayio.Group()
34  my_group.append(my_equa)
35  display.show(my_group)  # add high level Group to the display
36  
37  while True:
38      # We updates the values for 5 bars. We update the values for
39      # each bar
40      my_equa.show_bars((10, 0, 10, 35, 85))
41      time.sleep(0.5)
42  
43      my_equa.show_bars((70, 10, 0, 10, 35))
44      time.sleep(0.5)
45  
46      my_equa.show_bars((0, 10, 35, 0, 90))
47      time.sleep(0.5)
48  
49      my_equa.show_bars((35, 85, 10, 0, 10))
50      time.sleep(0.5)
51  
52      my_equa.show_bars((10, 35, 85, 10, 0))
53      time.sleep(0.5)
54  
55      my_equa.show_bars((0, 10, 35, 56, 90))
56      time.sleep(0.5)