Open jasonblewis opened 5 years ago
Do you have a pinout diagram for the TTGO board? I was experimenting with one a few months ago (different display dimensions but most likely very similar otherwise) and the I2C pins connected to the display were not 21 and 22. SCL was 15 and SDA was 4.
See if the device shows up when you do i2c.scan().
i2c = machine.I2C(scl=machine.Pin(scl_pin_id), sda=machine.Pin(sda_pin_id), freq = freq) devices = i2c.scan() print("i2c scan", devices)
@carterw thanks, the board has a silkscreen on it saying SDA=21 and SCL=22, which is what I tested with, and got the result in the photo above. So I'm pretty confident they are the correct pins, its just not being driven correctly
Well that's good, and I assume you did the scan and the device shows up in the results? There may be a reset pin attached to the display that has to be toggled, check for that. Also look in the driver for places where a read of a register happens and put a print statement there to see if you are actually getting data.
I think the display is actually 128x64, but on SH1106 the buffer is 132x64 and the columns 2~130 are displayed. You should be able to implement the SH1106 driver as a subclass of SSD1306_I2C as follows:
from ssd1306 import SSD1306_I2C
SET_LOW_COLUMN = const(0x00)
SET_HIGH_COLUMN = const(0x10)
SET_PAGE_ADDR = const(0xb0)
SET_DISP_START_LINE = const(0x40)
class SH1106_I2C(SSD1306_I2C):
def show(self):
for pg in range(0, self.pages):
for cmd in (
SET_PAGE_ADDR | pg,
SET_LOW_COLUMN | 2,
SET_HIGH_COLUMN | 0,
):
self.write_cmd(cmd)
self.write_data(self.buffer[pg * 0x80:(pg + 1) * 0x80])
Than your code should look like:
import machine, time
WIDTH = const(128)
HEIGHT = const (64)
sda_pin = 21
scl_pin = 22
i2c = machine.I2C(scl=scl_pin, sda=sda_pin, speed=400000)
ssd = SH1106_I2C(WIDTH, HEIGHT, i2c)
import freesans20
from writer import Writer
wri2 = Writer(ssd, freesans20, verbose=True)
Writer.set_clip(True, True)
for y in range(0,HEIGHT-1):
for x in range(0,WIDTH-1):
Writer.set_textpos(x, y)
wri2.printstring('{} {} MicroPython\nby LoBo\n10/2017'.format(x,y))
ssd.show()
time.sleep(1)
I don't have SH1106 display, so this was not tested.
@loboris thank you! that works!
Dobrý den, mohu pomoci deska TTGA ESP8266 SH1106 (https://www.laskarduino.cz/lilygo-ttgo-to-esp8266-sh110-1-3--oled-meteostanice--wifi-modul/ ). stahuj ESP8266 weatherstation (DS1306) = pocasi . upraveni SH1106. zapis a neukazuje obraz. neco chyba posim pomoc esp8266-weather-station.zip(original) prosim prelozit. Dik DM email:mikeskadavid@tiscali.cz
Is it possible to support SH1106 OLED displays? The TTGO T-Eight board has one built into it.
If I try and use it by using the built in SD1306 driver, I get a few lines at the top of the screen and the rest of the screen looks like static.
It seems very similar to this issue, which might hold some clues as to how it could be supported:
https://github.com/rm-hull/luma.oled/issues/1
Also see https://github.com/adamyoung600/WRX_HUD/tree/master/Hardware/SH1106