from machine import Pin,SoftI2C
from ssd1306 import SSD1306_I2C
from utime import sleep
i2c = SoftI2C(scl=Pin(22), sda=Pin(21))
display = SSD1306_I2C(128, 64, i2c)
from dht import DHT22
weather = DHT22(Pin(27))
while True:
weather.measure()
temp = weather.temperature()
hum = weather.humidity()
print(f"Temp: {temp}C\nHumidity: {hum}%")
# Basic functions:
# display.poweroff() # power off the display, pixels persist in memory
# display.poweron() # power on the display, pixels redrawn
# display.contrast(0) # dim
# display.contrast(255) # bright
# display.invert(1) # display inverted
# display.invert(0) # display normal
# display.rotate(True) # rotate 180 degrees
# display.rotate(False) # rotate 0 degrees
# display.show() # write the contents of the FrameBuffer to display memory
# display.fill(0) # fill entire screen with colour=0
# display.pixel(0, 10) # get pixel at x=0, y=10
# display.pixel(0, 10, 1) # set pixel at x=0, y=10 to colour=1
# display.hline(0, 8, 4, 1) # draw horizontal line x=0, y=8, width=4, colour=1
# display.vline(0, 8, 4, 1) # draw vertical line x=0, y=8, height=4, colour=1
# display.line(0, 0, 127, 63, 1) # draw a line from 0,0 to 127,63
# display.rect(10, 10, 107, 43, 1) # draw a rectangle outline 10,10 to 117,53, colour=1
# display.fill_rect(10, 10, 107, 43, 1) # draw a solid rectangle 10,10 to 117,53, colour=1
# display.text('Hello World', 0, 0, 1) # draw some text at x=0, y=0, colour=1
# display.scroll(20, 0) # scroll 20 pixels to the right
#display.pixel(127, 163) #display.contrast(0)
# display.pixel(60, 20, 1)
# display.hline(20, 30, 100, 1)
# display.vline(80, 0, 63, 1)
# display.line(0, 0, 110, 63, 1)
# display.show()
# sleep(3)
# display.fill(0)
# display.show()
# display.text("Zdraste!", 20, 40, 1)
# display.show()
# display.text("Salam alekum", 16, 24, 1)
# display.show()
# sleep(1.5)
# display.text("Ilusha", 17, 33, 1)
# display.show()
# display.text("Ilusha", 17, 43, 1)
# display.show()
# display.text("Ilusha", 17, 53, 1)
# display.show()
# display.fill(0)
# display.fill_rect(0, 0, 32, 32, 1)
# display.fill_rect(2, 2, 28, 28, 0)
# display.vline(9, 8, 22, 1)
# display.vline(16, 2, 22, 1)
# display.vline(23, 8, 22, 1)
# display.fill_rect(26, 24, 2, 4, 1)
# display.text('MicroPython', 40, 0, 1)
# display.text('SSD1306', 40, 12, 1)
# display.text('OLED 128x64', 40, 24, 1)
# display.show()
# for i in range (0, 128, 4):
# display.vline(i, 0, 63, 1)
# for h in range (0, 128, 4):
# display.hline(1, h, 128, 1)
# display.show()