from machine import Pin, I2C
import time
from lcd_api import LcdApi
from i2c_lcd import I2cLcd
import oled
address = []
last_freq = 0
def config_LCD_I2C(freq,SCL,SDA):
global address,last_freq,lcd,oled1
if freq != last_freq:
# I2C Pin setup for ESP32
i2c = I2C(scl=SCL, sda=SDA, freq=freq)
print("freq for LCD is now", freq)
last_freq = freq
# scan for connected devices on the I2C
address = i2c.scan()
# create the LCD object based on the address
lcd = I2cLcd(i2c, address[0], 2, 16)
# Oled setup with I2C for ESP32
oled1 = oled.I2C(128, 64, i2c)
def main():
config_LCD_I2C(400000,Pin(13),Pin(16))
while True:
lcd.clear()
lcd.putstr("DECI students")
time.sleep(1)
lcd.clear()
lcd.putstr("Embedded systems")
time.sleep(1)
oled1.clear()
oled1.text('I2C ok', 10, 3)
oled1.show()
if __name__ == "__main__":
main()