kopia lustrzana https://github.com/pimoroni/pimoroni-pico
Tufty 2040: Update spectrometer vector example.
rodzic
79844c6eaa
commit
cfe031db33
Plik binarny nie jest wyświetlany.
|
|
@ -3,7 +3,7 @@ import time
|
||||||
from pimoroni_i2c import PimoroniI2C
|
from pimoroni_i2c import PimoroniI2C
|
||||||
from breakout_as7262 import BreakoutAS7262
|
from breakout_as7262 import BreakoutAS7262
|
||||||
from picographics import PicoGraphics, DISPLAY_TUFTY_2040, PEN_RGB332
|
from picographics import PicoGraphics, DISPLAY_TUFTY_2040, PEN_RGB332
|
||||||
from picovector import PicoVector, Polygon, RegularPolygon, ANTIALIAS_X4
|
from picovector import PicoVector, Polygon, Transform, ANTIALIAS_NONE
|
||||||
|
|
||||||
PINS_TUFTY_2040 = {"sda": 4, "scl": 5}
|
PINS_TUFTY_2040 = {"sda": 4, "scl": 5}
|
||||||
i2c = PimoroniI2C(**PINS_TUFTY_2040)
|
i2c = PimoroniI2C(**PINS_TUFTY_2040)
|
||||||
|
|
@ -22,10 +22,13 @@ display.set_backlight(0.8)
|
||||||
|
|
||||||
# Set up PicoVector
|
# Set up PicoVector
|
||||||
vector = PicoVector(display)
|
vector = PicoVector(display)
|
||||||
vector.set_antialiasing(ANTIALIAS_X4)
|
vector.set_antialiasing(ANTIALIAS_NONE)
|
||||||
|
|
||||||
|
t = Transform()
|
||||||
|
vector.set_transform(t)
|
||||||
|
|
||||||
# Load an Alright Font, find this in common/AdvRe.af
|
# Load an Alright Font, find this in common/AdvRe.af
|
||||||
result = vector.set_font("/AdvRe.af", 30)
|
vector.set_font("/AdvRe.af", 40)
|
||||||
|
|
||||||
WIDTH, HEIGHT = display.get_bounds()
|
WIDTH, HEIGHT = display.get_bounds()
|
||||||
|
|
||||||
|
|
@ -67,8 +70,8 @@ def regular_polygon(o_x, o_y, radius, rotation):
|
||||||
return points
|
return points
|
||||||
|
|
||||||
|
|
||||||
lines = RegularPolygon(CENTER_X, CENTER_Y, 6, RADIUS)
|
lines = regular_polygon(CENTER_X, CENTER_Y, [RADIUS] * 6, 0)
|
||||||
label_points = list(RegularPolygon(CENTER_X, CENTER_Y, 6, RADIUS * 0.7, -(360 / 12)))
|
label_points = regular_polygon(CENTER_X, CENTER_Y, [RADIUS * 0.7] * 6, -(360 / 12))
|
||||||
|
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
|
|
@ -78,7 +81,7 @@ while True:
|
||||||
|
|
||||||
# Add the title
|
# Add the title
|
||||||
display.set_pen(WHITE)
|
display.set_pen(WHITE)
|
||||||
vector.text("Spectrograph", 5, -5)
|
vector.text("Spectrograph", 5, 30)
|
||||||
|
|
||||||
# Get the spectrometer readings
|
# Get the spectrometer readings
|
||||||
reading = list(as7262.read())
|
reading = list(as7262.read())
|
||||||
|
|
@ -110,8 +113,10 @@ while True:
|
||||||
point_b = points[i]
|
point_b = points[i]
|
||||||
label_x, label_y = label_points[i]
|
label_x, label_y = label_points[i]
|
||||||
display.set_pen(COLS[i])
|
display.set_pen(COLS[i])
|
||||||
vector.text(LABELS[i], int(label_x) - 5, int(label_y) - 20)
|
p = Polygon()
|
||||||
vector.draw(Polygon(point_a, point_b, (CENTER_X, CENTER_Y)))
|
p.path(point_a, point_b, (CENTER_X, CENTER_Y))
|
||||||
|
vector.draw(p)
|
||||||
|
vector.text(LABELS[i], int(label_x - 5), int(label_y + 5))
|
||||||
point_a = point_b
|
point_a = point_b
|
||||||
|
|
||||||
display.update()
|
display.update()
|
||||||
|
|
|
||||||
Ładowanie…
Reference in New Issue