From ed6db700d4eb4274eced7ddb23dfe7b72d3c7da2 Mon Sep 17 00:00:00 2001 From: Salvatore La Bua Date: Tue, 8 Oct 2024 19:33:40 +0900 Subject: [PATCH 1/2] Add rotate(bool) method to rotate the screen by 180 deg --- ssd1306.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ssd1306.py b/ssd1306.py index 6359c85..9e5a454 100644 --- a/ssd1306.py +++ b/ssd1306.py @@ -84,6 +84,10 @@ def contrast(self, contrast): def invert(self, invert): self.write_cmd(SET_NORM_INV | (invert & 1)) + + def rotate(self, rotate): + self.write_cmd(SET_COM_OUT_DIR | ((rotate & 1) << 3)) + self.write_cmd(SET_SEG_REMAP | (rotate & 1)) def show(self): x0 = 0 From ff06aecdb7eea3ed831597bf581d8ab5c8b2d2a9 Mon Sep 17 00:00:00 2001 From: Salvatore La Bua Date: Sat, 19 Oct 2024 10:49:24 +0900 Subject: [PATCH 2/2] Add support for framebuf2 by peter-l5 https://github.com/peter-l5/framebuf2 --- ssd1306.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/ssd1306.py b/ssd1306.py index 9e5a454..a593d2a 100644 --- a/ssd1306.py +++ b/ssd1306.py @@ -1,7 +1,15 @@ # MicroPython SSD1306 OLED driver, I2C and SPI interfaces from micropython import const -import framebuf +# import extended framebuffer if available) +# https://github.com/peter-l5/framebuf2 +try: + import framebuf2 as framebuf + _fb_variant = 2 +except: + import framebuf + _fb_variant = 1 +print("framebuf is ", ("standard" if _fb_variant == 1 else "extended")) # register definitions