Simple test

Ensure your device works with this simple test.

examples/displayio_cartesian_simpletest.py
 1# SPDX-FileCopyrightText: 2021 Jose David M.
 2#
 3# SPDX-License-Identifier: MIT
 4#############################
 5"""
 6This is a basic demonstration of a Cartesian widget.
 7"""
 8
 9import time
10import board
11import displayio
12import terminalio
13from displayio_cartesian import Cartesian
14
15# Fonts used for the Dial tick labels
16tick_font = terminalio.FONT
17
18display = board.DISPLAY  # create the display on the PyPortal or Clue (for example)
19# otherwise change this to setup the display
20# for display chip driver and pinout you have (e.g. ILI9341)
21
22
23# Create a Cartesian widget
24my_plane = Cartesian(
25    x=150,  # x position for the plane
26    y=100,  # y plane position
27    width=100,  # display width
28    height=100,  # display height
29    axes_color=0xFFFFFF,  # axes line color
30    axes_stroke=2,  # axes lines width in pixels
31    tick_color=0xFFFFFF,  # ticks color
32    major_tick_stroke=1,  # ticks width in pixels
33    major_tick_length=5,  # ticks length in pixels
34    tick_label_font=tick_font,  # the font used for the tick labels
35    font_color=0xFFFFFF,  # ticks line color
36)
37
38my_group = displayio.Group()
39my_group.append(my_plane)
40display.show(my_group)  # add high level Group to the display
41
42posx = 0
43posy = 0
44
45while True:
46    for i in range(0, 90, 2):
47        my_plane.update_pointer(i, i)
48        time.sleep(0.5)

Advanced test

Advanced test showing illustrating usage of more features.

examples/displayio_cartesian_advanced_test.py
 1# SPDX-FileCopyrightText: 2021 Jose David M.
 2#
 3# SPDX-License-Identifier: MIT
 4#############################
 5"""
 6This is a more advance demonstration of a Cartesian widget and some configurable
 7parameters.
 8"""
 9
10import board
11import displayio
12import terminalio
13from displayio_cartesian import Cartesian
14
15# Fonts used for the Dial tick labels
16tick_font = terminalio.FONT
17
18display = board.DISPLAY  # create the display on the PyPortal or Clue (for example)
19# otherwise change this to setup the display
20# for display chip driver and pinout you have (e.g. ILI9341)
21
22
23# Create different Cartesian widgets
24my_group = displayio.Group()
25
26car = Cartesian(
27    x=25,
28    y=10,
29    width=100,
30    height=100,
31    subticks=True,
32)
33my_group.append(car)
34
35car3 = Cartesian(
36    x=150,
37    y=10,
38    width=150,
39    height=100,
40    xrange=(0, 160),
41    axes_stroke=1,
42    axes_color=0x990099,
43    subticks=True,
44)
45my_group.append(car3)
46
47car4 = Cartesian(
48    x=30,
49    y=140,
50    width=80,
51    height=80,
52    axes_stroke=1,
53    tick_color=0xFFFFFF,
54    subticks=True,
55)
56
57my_group.append(car4)
58
59car5 = Cartesian(
60    x=180,
61    y=140,
62    width=70,
63    height=70,
64    xrange=(0, 120),
65    yrange=(0, 90),
66    tick_color=0x990099,
67    axes_stroke=3,
68    major_tick_length=10,
69)
70my_group.append(car5)
71
72display.show(my_group)
73
74while True:
75    pass