Adafruit_SSD1306 icon indicating copy to clipboard operation
Adafruit_SSD1306 copied to clipboard

Display shifting the first line randomly

Open Alexxxxissssssss opened this issue 5 years ago • 0 comments

Hi,

thanks for taking time to read this. I'm having a problem with my oled while displaying on it. I can display everything I need correctly with i2c on the display by sending the complete buffer each time i want to refresh it. I've divided it on 8 lines of 8 bit each. The normal display looks like this : image

And some times it seems that the offset of the display is taking a random offset and the display looks like this (the line from the bottom goes to the top, the screen was refreshing during the picture) : image

To get back my normal display I have to resend the entire configuration to it.

Here is my configuration

`static unsigned char display_config[] = { SSD1306_SETLOWCOLUMN, SSD1306_DISPLAYOFF,

SSD1306_SET_PAGE_ADDRESS,
0x02, //set lower column address
0x10, //set higher column address

SSD1306_SETMULTIPLEX, 0x3F,
// Set the display offset to 0
SSD1306_SETDISPLAYOFFSET, 0x00,
// Display start line to 0
SSD1306_SETSTARTLINE,
// Mirror the x-axis. In case you set it up such that the pins are north.
// 0xA0 - in case pins are south - default
SSD1306_SEGREMAP,

SSD1306_COLUMNADDR, 0x00, 0x7F,

SSD1306_PAGEADDR, 0x00, 0x07,
// Mirror the y-axis. In case you set it up such that the pins are north.
// 0xC0 - in case pins are south - default
SSD1306_COMSCANINC,
// Default - alternate COM pin map
SSD1306_SETCOMPINS, 0x12,
// set contrast
SSD1306_SETCONTRAST, 0xFF,
// Set display to enable rendering from GDDRAM (Graphic Display Data RAM)
SSD1306_DISPLAYALLON_RESUME,
// Normal mode!
SSD1306_NORMALDISPLAY,
// Default oscillator clock
SSD1306_SETDISPLAYCLOCKDIV, 0x80,
// Enable the charge pump
SSD1306_CHARGEPUMP, 0x14,
// Set precharge cycles to high cap type
SSD1306_SETPRECHARGE, 0x22,
// Set the V_COMH deselect volatage to max
SSD1306_SETVCOMDETECT, 0x30,
// Horizonatal addressing mode - same as the KS108 GLCD
SSD1306_MEMORYMODE, 0x00,
// Turn the Display ON
SSD1306_DISPLAYON,

SSD1306_SET_PAGE_ADDRESS,
0x00,
0x10

};`

And here is my display function

`void SSD1306_display(void) { SSD1306_sendCommand(SSD1306_SET_PAGE_ADDRESS); SSD1306_sendCommand(0x00); SSD1306_sendCommand(0x10);

SSD1306_sendBuffer();

}

void SSD1306_sendBuffer(){ struct sized_array payload; unsigned char packet[129];

toolMutexLock(&MutexI2c);
SSD1306_Open("/dev/i2c-0");

for (int index = 0; index < 8; index++) {
	packet[0] = SSD1306_SETSTARTLINE;

	memcpy(&packet[1], &buffer[index*128], 128);

	payload.size = 129;
	payload.array = packet;

	if (write(display.file,&payload.array[0], payload.size) != payload.size){
		goto END_FCT;
	}
}

END_FCT: SSD1306_Close(); toolMutexUnlock(&MutexI2c); } ` My guess would be that I'm trying to update the screen content while the screen is refreshing the frame but how could I counter this ? If this is the problem...

Thanks for helping :)

Alexxxxissssssss avatar May 23 '19 08:05 Alexxxxissssssss