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 # SoftI2C kena ada kalau Pin SDL SCA wujud
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 the OLED basic parameter # boudrate, width, height
oled_width = 128 #based on spec
oled_height = 64 #based on spec
# 4. Create an object called "oled"
# Remarks: object format "library name.class name"
oled = ssd1306.SSD1306_I2C(oled_width, oled_height, i2c_oled)
# 5. Let's test the OLED
# Remarks: The font colour is default set to 1 (White)
#Create text to be displayed on OLED screen
oled.fill(1) # to make screen becoming white
oled.text('BEB34303', 0, 0, 0)
oled.text('Hello Everyone', 0, 10, 0)
oled.text('I am Marwangi', 0, 30, 0)
oled.text('I <3 IoT subject', 0, 50, 0)
oled.show() # to display the text
sleep(3)
oled.invert(True)
oled.show()