OLED Expnasion - converting pixel coordinates to bit offset coordinates
I'm trying to build a very simple Python script to draw images onto the OLED expansion screen.
So far what I'm doing is storing the image I want as an array of bits. I'm stumped on the coordinate system however. Given X and Y coordinates, how would I know which bit to change in my bit array?
I'm plainly guessing but basing on my experience with displays, I'd say it would be something like this:
arrayIndex = x + (y/8)*screenWidth
bitIndex = y%8
Look at the display's documentation, it has to precise this.
This is the screen I'm referring to. It's a little more complicated than that I'm afraid. It has some weird addressing.
The chip used is the SSD1306. If you're opening I2C for direct write from your script I recommend you to read the chip datasheet: https://www.olimex.com/Products/Modules/LCD/MOD-OLED-128x64/resources/SSD1306.pdf
The datasheet has more information and detail on is the mapping organized.