micropython-lib icon indicating copy to clipboard operation
micropython-lib copied to clipboard

ssd1306 might need to send SET_IREF_SELECT(0xad) <-- 0x30 during init_display.

Open gvdl opened this issue 6 months ago • 2 comments

G'day, All.

I have been trying to find some solid evidence of this but have not managed to find a data sheet with the command. Given that I haven't found any solid evidence I'm not sure if this is a real issue or not.

I recently downloaded a ssd1306 micropython from the Sunfounder website and then I looked at Peter Hinch's micro python-nano-gui and saw a difference between the two drivers.

Specifically their init_display() method has one extra command, the SET_IREF_SELECT, 0x30. As I said this new command is NOT mentioned in the 2008 Solomon ssd1306 chip data sheet and I have been unable to find any other reference in any newer data sheet. But both the Sunfounder and Adafruit drivers do set this. I did find one discussion while googling around that this field clears up a flicker problem for atleast one person.

I'm happy to create a pull request for this myself. if you feel it is a good idea to pick up the change. My issue is I only have a few cheap knockoff ssd1306 so I'm not sure how thoroughly I can test the change.

SET_IREF_SELECT = const(0xAD)
...
    def init_display(self):
        for cmd in (
            SET_DISP,  # display off
            # address setting
            SET_MEM_ADDR,
            0x00,  # horizontal
            # resolution and layout
            SET_DISP_START_LINE,  # start at line 0
            SET_SEG_REMAP | 0x01,  # column addr 127 mapped to SEG0
            SET_MUX_RATIO,
            self.height - 1,
            SET_COM_OUT_DIR | 0x08,  # scan from COM[N] to COM0
            SET_DISP_OFFSET,
            0x00,
            SET_COM_PIN_CFG,
            0x02 if self.width > 2 * self.height else 0x12,
            # timing and driving scheme
            SET_DISP_CLK_DIV,
            0x80,
            SET_PRECHARGE,
            0x22 if self.external_vcc else 0xF1,
            SET_VCOM_DESEL,
            0x30,  # 0.83*Vcc
            # display
            SET_CONTRAST,
            0xFF,  # maximum
            SET_ENTIRE_ON,  # output follows RAM contents
            SET_NORM_INV,  # not inverted
            SET_IREF_SELECT,
            0x30,  # enable internal IREF during display on
            # charge pump
            SET_CHARGE_PUMP,
            0x10 if self.external_vcc else 0x14,
            SET_DISP | 0x01,  # display on
        ):  # on
            self.write_cmd(cmd)
        self.fill(0)
        self.show()

gvdl avatar Jun 16 '25 18:06 gvdl

I did find this commit in adafruit's github repo. Not much to go on unfortunately.

Commit f10baf6

https://github.com/adafruit/Adafruit_CircuitPython_SSD1306/commit/f10baf66b442a3e0ec82acdeb0bbcb2a717b521c

gvdl avatar Jun 16 '25 19:06 gvdl

Finally found a reference to SET_IREF_SELECT and it isn't supported by the Solomon ssd1306. This section is apprarantly supported by the ssd1316 which is a different slightly smaller monochrome display. I suspect the use in the 1306 is bleed over from the 1316 but I'm not sure if it IREF_SELECT has made it to late model 1306 displays or not.

I have been using it locally now for a few months on a 1306 and I haven't found an issue with SET_IREF_SELECT.

gvdl avatar Jun 20 '25 20:06 gvdl