I am using a Clue board with the latest circuit python and libraries (as of last week).
I am trying to display an analog clock face. However, I can not get the hands to move. I have tried auto refresh false with a manual refresh and I have tried with the refresh at default. I can move the circle by changing x and y. I can change text, but so far I can not figure out how to refresh a line.
Please, what am I missing?
Below is a simplified copy of my code. The line simply does not move.
Yes, I know everyone else uses group or splash where I used canvas. Canvas is just easier for me. Also, I can guess where the group usage came from, but why use splash? What is splash?
Code: Select all
import board
import displayio
import terminalio
import math
import time
from adafruit_display_shapes.circle import Circle
from adafruit_display_shapes.line import Line
from adafruit_display_text import label
from adafruit_bitmap_font import bitmap_font
from adafruit_clue import clue
RED = 0x880000
GREEN = 0x008800
BLUE = 0x000088
YELLOW = 0x884400
CYAN = 0x0088BB
MAGENTA = 0x9900BB
WHITE = 0x888888
display = board.DISPLAY
canvas = displayio.Group()
display.show(canvas)
palette = displayio.Palette(3)
palette[0] = 0x125690
palette[2] = 0xFF00FF
cx = 110
cy = 110
edge = 10
R = 100
circle = Circle(cx, cy, R, fill=0, outline=GREEN, stroke=3)
canvas.append(circle)
# x and y start of the line
startX = cx
startY = cy
# here is an angle just to get the line started
angle = 45
# x and y end of the line
endX = startX + round(math.cos(angle) * R)
endY = startY - round(math.sin(angle) * R)
line = Line(startX, startY, round(endX), round(endY), color=0x00FF00)
canvas.append(line)
time.sleep(1)
while True:
# new angle just to see the refresh work
newAngle = 185
endX = startX + round(math.cos(newAngle) * R)
endY = startY - round(math.sin(newAngle) * R)
line.x0 = 110
line.y0 = 110
line.x1 = round(endX)
line.y1 = round(endY)
# print statements to show that the line start and end points have changed.
print("line x and y", line.x, line.y)
print("line x0 and y0: ", line.x0, line.y0)
print("line x1 and y1: ", line.x1, line.y1)
display.refresh()
time.sleep(1)