I think you can move away from the JPG file with a bit of maths!
The code is here:
# Drawing different coloured dial sectors
# Tony Goodhew 7th Jan 2023
from picographics import PicoGraphics, DISPLAY_LCD_240X240
import math
import time
import random
import machine # for ADC pot
display = PicoGraphics(display=DISPLAY_LCD_240X240)
red = display.create_pen(255,0,0)
white = display.create_pen(255,255,255)
green = display.create_pen(0,255,0)
blue = display.create_pen(0,0,255)
black = display.create_pen(0,0,0)
yellow = display.create_pen(255,255,0)
cyan = display.create_pen(0,255,255)
magenta = display.create_pen(255,0,255)
# =========== Main Program ================
display.set_font("bitmap8") # Provides Lower Case letters
display.set_pen(black)
display.clear()
xc = 160
yc = 160
display.set_pen(blue)
display.circle(xc,yc,160)
display.update()
display.set_pen(white)
for y in range(240):
for x in range(161):
dx = x-xc
dy = y-yc
h = math.sqrt(dy*dy + dx*dx)
if h < 129: # Break out of loop as we are inside the coloured arc
break
if (h <= 160) and (h >= 130):
if dx != 0: # Divide by zero by error trap
theta = math.atan(dy/dx)* 180 / math.pi # angle in degrees
if (theta <= 0):
display.set_pen(red)
if (theta > 0) and (theta <= 30):
display.set_pen(yellow)
if (theta > 30) and (theta <= 60):
display.set_pen(green)
if theta > 60:
display.set_pen(magenta)
display.pixel(x,y)
display.pixel(320-x,y)
display.update()
Pretty quick considering how much number crunching this takes. It’s what computers are for! Just Pythagoras and a bit of Trigonometry.
You may want to adjust the bottom corners. I’ve not got a Display 2 but the code should provide the other side.
