Currently, I am able to output a value on OLED but as each value gets updated, it stays on top of the previous value.
How can I refresh the OLED, so that I can get the latest value.
I have looked into the displayio library, and it does mention about OLED_reset, and it has to be assigned to a pin. Is there a way to do a periodic refresh without assigning oled_reset to any pin.
I hope to hear your response.
Below is the code,
Code: Select all
import time
import board
import displayio
import terminalio
import adafruit_displayio_ssd1306
from adafruit_display_text import label
from analogio import AnalogIn
analog_in = AnalogIn(board.A1)
analog_in1 = 0
# OLED Connection
displayio.release_displays()
# Using I2C connection
i2c = board.I2C()
display_bus = displayio.I2CDisplay(i2c, device_address=0x3C)
WIDTH = 128
HEIGHT = 32
BORDER = 5
display = adafruit_displayio_ssd1306.SSD1306(display_bus, width=128, height=32)
# Display Conect below
splash = displayio.Group()
display.show(splash)
while True:
initial = time.monotonic()
for i in range(100):
analog_in2 = analog_in.value
if analog_in2 > analog_in1:
analog_in1 = analog_in2
time.sleep(0.05)
# print((analog_in1 * 3.3) / 65536)
text = "V = " + str((analog_in1 * 3.3) / 65536)
text_area = label.Label(
terminalio.FONT, text=text, color=0xFFFFFF, x=28, y=HEIGHT // 2 - 1
)
splash.append(text_area)