Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # import thư viện
- import time
- import Adafruit_SSD1306
- from PIL import Image
- from PIL import ImageDraw
- from PIL import ImageFont
- """thiết lập cho màn hình oled (128x64), ở đây mọi người có thể thay đổi để hiển thị trên màn hình oled 128x32 """
- disp = Adafruit_SSD1306.SSD1306_128_64(rst=None, i2c_bus=1, gpio=1)
- disp.begin()
- disp.clear()
- disp.display()
- width = disp.width
- height = disp.height
- image = Image.new('1', (width, height))
- draw = ImageDraw.Draw(image)
- draw.rectangle((0,0,width,height), outline=0, fill=0)
- padding = -2
- top = padding
- bottom = height-padding
- x = 0
- font = ImageFont.load_default()
- draw.rectangle((0,0,width,height), outline=0, fill=0)
- """x: là tọa độ từ trái sang (vd ở đây x = 0) và top: là từ trên xuống (vd: top = 0) thì sẽ in ra dòng chữ ‘hello world!’ ở tọa độ (0,0) của màn màn hinh oled."""
- draw.text((x, top),"Hello world!", font=font, fill=255)
- disp.image(image)
- disp.display()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement