from machine import Pin, I2C, ADC
from time import sleep_ms
from ssd1306 import SSD1306_I2C
import framebuf
ancho= 128
alto=64
i2c=I2C(1, scl=Pin(19), sda=Pin(18))
oled=SSD1306_I2C(ancho,alto, i2c)
oled.fill(0)#cls
oled.text("LDR",7,8*6)
oled.show()
for bla in range(8):
oled.scroll(0,-6)
oled.show()
oled.text("Clock "+str(machine.freq()/1e6)+"Mhz",3,2*7)
oled.show()
for x in range(8,ancho,8):
oled.line(0,32,x,alto,1)
oled.line(ancho,32,ancho-x,alto,1)
oled.show()
oled.fill(0)
oled.text("Entrada an(0)",3,2*7)
oled.show()
"""oled.rect(0,0,127,15,1)
oled.rect(0,16,127,47,1)
oled.text("LDR",52,4)
"""
while 1:
oled.fill_rect(0,32,ancho,12,0)
oled.rect(0,32,ancho,12,1)
a=ADC(0).read_u16()
w=int((ancho-4)*a/65535)#escala
oled.fill_rect(2,34,w,8,1)
oled.show()