Here is some code to produce a suggested sine trace in green. It works on my 240x240 Pico Explorer screen. Hope this helps.
# "Oscilloscope Sine trace"
# For 240x240 pixel display
# Tony Goodhew 20 Feb 2022
import picoexplorer as display
import utime, random, math
width = display.get_width()
height = display.get_height()
display_buffer = bytearray(width * height * 2)
display.init(display_buffer)
def horiz(l,t,r): # left, right , top
n = r-l+1 # Horizontal line
for i in range(n):
display.pixel(l + i, t)
def vert(l,t,b): # left, top, bottom
n = b-t+1 # Vertical line
for i in range(n):
display.pixel(l, t+i)
def box(l,t,r,b): # left, top, right, bottom
horiz(l,t,r) # Hollow rectangle
horiz(l,b,r)
vert(l,t,b)
vert(r,t,b)
def line(x,y,xx,yy): # (x,y) to (xx,yy)
if x > xx:
t = x # Swap co-ordinates if necessary
x = xx
xx = t
t = y
y = yy
yy = t
if xx-x == 0: # Avoid div by zero if vertical
vert(x,min(y,yy),max(y,yy))
else: # Draw line one dot at a time L to R
n=xx-x+1
grad = float((yy-y)/(xx-x)) # Calculate gradient
for i in range(n):
y3 = y + int(grad * i)
display.pixel(x+i,y3) # One dot at a time
display.set_pen(0,0,0)
display.clear()
display.update()
display.set_pen(0,200,0)
display.text("Drawing Graphs", 20, 70, 200, 4)
display.update()
utime.sleep(2)
display.set_pen(0,0,0)
display.clear()
display.update()
factor = 361 /60 # change the 60 to alter number of cycles
#sine = []
display.set_pen(0,200,0)
horiz(0,120,239)
display.update()
display.set_pen(0,200,0)
for x in range(0,240):
y = int ((math.sin(math.radians(x * factor)))* -70) + 120
# sine.append(element)
display.pixel(x,y)
#display.text("Sine", 40, 70, 200, 2)
display.update()
Please, let me know how you get on.