print("This program integrates OLED screen with ESP32")
# Credits to https://RandomNerdTutorials.com & program edited accordingly
#1.import all necessary modules and libraries
from machine import Pin, SoftI2C # soft 12c if any scl and sda
from utime import sleep
import ssd1306 #this is oled library
#2. declare pin on OLED display
i2c_oled = SoftI2C(scl=Pin(22), sda=Pin(21))
#3. define OLED basic parameter
oled_width = 128 #based on spec
oled_height = 64 #based on spec
#4. create an object called oled
#remark : object format "library name . class name"
oled = ssd1306.SSD1306_I2C(oled_width, oled_height, i2c_oled)
#let test the OLED
#remark : the font volor is default set to 1 (white)
#Create text to be displayed on OLED screen
oled.fill(1)
oled.text('testtt', 0, 0,0)
oled.text('Hello Everyone', 0, 10,0)
oled.text('I am AFIF', 0, 30,0)
oled.text('I <3 IoT subject', 0, 50,0)
oled.show() #to display the textS
sleep(3)
oled.invert(True)
oled.show()