print("Hello, ESP32!")
print("This program integrates OLED screen with ESP32")
 
# Credits to https://RandomNerdTutorials.com & program edited accordingly

#1. Import necessary modules/libraries 
from machine import Pin, SoftI2C #SoftI2C SCL,SDA
import ssd1306 #import OLED library
from utime import sleep
#2. Pin declaration on OLED
i2c_oled = SoftI2C(scl=Pin(22), sda=Pin(21))
 
#3. Define the OLED variables
oled_width = 128 #based on spec
oled_height = 64 #based on spec
 
#4. Use OOP (object oriented programming) to create the object
#Remarks: object format --> library name.class name
#(width, height, i2c)
oled = ssd1306.SSD1306_I2C(oled_width, oled_height, i2c_oled)

#5. Test our OLED display
#Create text to be displayed on OLED screen
#Remark: code color is 1 for white, 0 for black (BY default: 1)
oled.fill(1)
oled.text('Hello Everyone', 0, 10, 0)
oled.text('I like IoT', 0, 30, 0)
oled.text('I <3 IoT subject', 0, 50,0)
 
oled.show()
sleep(3)

oled.invert(True)
oled.show()