Matiasus / SSD1306

C library for SSD1306 OLED Driver
MIT License
72 stars 19 forks source link

Not working with 128X32 .96" Display #11

Open bbarenz opened 11 months ago

bbarenz commented 11 months ago

I'm attempting to use your library with the 128X32 .91" display. I have tested it by loading the Adafruit sketch in Arduino and it works as expected. Moving to native C in Atmel Studio with this library, the output sometimes resembles text but is too small and the top is cut off. Any thoughts on what to check?
Setup:

define SSD1306_SET_MUX_RATIO 0x1F

define SSD1306_COM_PIN_CONF 0x02

define END_PAGE_ADDR 3

bbarenz commented 11 months ago

I made some progress. I can get your library to work if I first flash the Adafruit firmware. It appears something is not getting set and seems to persist after the display is powered off (I didn't think the SSD1306 had non volatile memory so maybe something else is happening?) For example, if I set SSD1306_SET_MUX_RATIO = 0xA8 it will garble the screen but even after setting it back to 0x1F it will stay garbled even after a power cycle. If I flash the Adafruit firmware then go back to your firmware it works fine.

Matiasus commented 11 months ago

Thanks for Your feedback, I will check it in the next few days and write back to you. Best Regards Matiasus

pi 8. 12. 2023 o 16:49 Ben Barenz @.***> napísal(a):

I made some progress. I can get your library to work if I first flash the Adafruit firmware. It appears something is not getting set and seems to persist after the display is powered off (I didn't think the SSD1306 had non volatile memory so maybe something else is happening?) For example, if I set SSD1306_SET_MUX_RATIO = 0xA8 it will garble the screen but even after setting it back to 0x1F it will stay garbled even after a power cycle. If I flash the Adafruit firmware then go back to your firmware it works fine.

— Reply to this email directly, view it on GitHub https://github.com/Matiasus/SSD1306/issues/11#issuecomment-1847416700, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACZOSOEADXBTVUDXCPBTPDTYIMZKHAVCNFSM6AAAAABALYRWU6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNBXGQYTMNZQGA . You are receiving this because you are subscribed to this thread.Message ID: @.***>

Matiasus commented 11 months ago

Hi bbarenz, I tested library yesterday with defined settings for 128x32 / 0.91" oled (SSD1306_SET_MUX_RATIO 0x1F, SSD1306_COM_PIN_CONF 0x02, END_PAGE_ADDR 3) but it worked correctly. I tested it with raw atmega328p with high fuse set to 'DE' and low fuse set to 'FF'. But you can try this list of commands & arguments settings according to adafruit:

// @const List of init commands with arguments by Adafruit
// @link https://github.com/adafruit/Adafruit_SSD1306
const uint8_t INIT_SSD1306[] PROGMEM = {
  17,                                                             // number of initializers
  0, SSD1306_DISPLAY_OFF,                                         // 0xAE / Set Display OFF
  1, SSD1306_SET_OSC_FREQ, 0x80,                                  // 0xD5 / 0x80 => D=1; DCLK = Fosc / D <=> DCLK = Fosc
  1, SSD1306_SET_MUX_RATIO, 0x1F,                                 // 0xA8 / 0x3F (64MUX) for 128 x 64 version
                                                                  //      / 0x1F (32MUX) for 128 x 32 version
  1, SSD1306_DISPLAY_OFFSET, 0x00,                                // 0xD3
  0, SSD1306_SET_START_LINE,                                      // 0x40
  1, SSD1306_SET_CHAR_REG, 0x14,                                  // 0x8D / Enable charge pump during display on
  1, SSD1306_MEMORY_ADDR_MODE, 0x00,                              // 0x20 / Set Memory Addressing Mode
                                                                  // 0x00 / Horizontal Addressing Mode
                                                                  // 0x01 / Vertical Addressing Mode
                                                                  // 0x02 /  Page Addressing Mode (RESET)
  0, SSD1306_SEG_REMAP_OP,                                        // 0xA0 / remap 0xA1
  0, SSD1306_COM_SCAN_DIR_OP,                                     // 0xC8
  1, SSD1306_COM_PIN_CONF, 0x02,                                  // 0xDA / 0x12 - Disable COM Left/Right remap, Alternative COM pin configuration
                                                                  //        0x12 - for 128 x 64 version
                                                                  //        0x02 - for 128 x 32 version
  1, SSD1306_SET_CONTRAST, 0x8F,                                  // 0x81 / 0x8F - reset value (max 0xFF)
  1, SSD1306_SET_PRECHARGE, 0xc2,                                 // 0xD9 / higher value less blinking
                                                                  //        0xC2, 1st phase = 2 DCLK,  2nd phase = 13 DCLK
  1, SSD1306_VCOM_DESELECT, 0x40,                                 // 0xDB / Set V COMH Deselect, reset value 0x22 = 0,77xUcc
  0, SSD1306_DIS_ENT_DISP_ON,                                     // 0xA4
  0, SSD1306_DIS_NORMAL,                                          // 0xA6
  0, SSD1306_DEACT_SCROLL,                                        // 0x2E
  0, SSD1306_DISPLAY_ON                                           // 0xAF / Set Display ON  
};