Simple test¶
Ensure your device works with this simple test.
1# SPDX-FileCopyrightText: 2021 Jose David M.
2#
3# SPDX-License-Identifier: MIT
4#############################
5"""
6This is a basic demonstration of a Equalizer widget.
7"""
8
9import time
10import board
11import displayio
12from equalizer.equalizer import Equalizer
13
14display = 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
20my_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
33my_group = displayio.Group()
34my_group.append(my_equa)
35display.show(my_group) # add high level Group to the display
36
37while 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)