I am trying to update an image on screen based on input (button pressed)
the code look roughly like this:
package main
import (
"machine"
"time"
"image/color"
"tinygo.org/x/drivers/ssd1306"
"tinygo.org/x/tinydraw"
)
func main() {
UP := machine.GP17
UP.Configure(machine.PinConfig{
Mode: machine.PinInputPullup,
})
// configure the display
machine.I2C0.Configure(machine.I2CConfig{Frequency: machine.TWI_FREQ_400KHZ, SCL: 1, SDA: 0 })
display := ssd1306.NewI2C(machine.I2C0)
display.Configure(ssd1306.Config{Width: 128, Height: 64, Address: ssd1306.Address_128_32, VccState: ssd1306.SWITCHCAPVCC})
for {
if UP.Get(){
display.ClearDisplay()
tinydraw.Circle(&display, 64, 48, 8, color.RGBA{1, 1, 1, 255})
}else{
tinydraw.FilledCircle(&display, 64, 48, 8, color.RGBA{1, 1, 1, 255})
}
// blip on screen
display.Display()
// timer, without time it doens work
time.Sleep(time.Millisecond * 300)
}
}
My question is is really why to I need the timer at the end. If I remove it, I the changes on changes are not pushed to the screen. with it, it takes too much time to update.
is there anyways to speed up the screen updating process ? maybe another lib that tinydraw?
I have tryed to change the timer, but it either takes too long to update or just stop updating whrn the value is too low.