Hi!
Recently i made some Arduboy clones using OLEDS with SSH1106 and SSD1309 drivers.
I’ve done some modifications in the libraries Arduboy / Arduboy2 and i think it’s good open a new thread for discussing the modifications.
For the 1.3’’ SSH1106 screen i take some code from a library shared through this community… (I can´t remember the thread…)
The changes in code are in the src/core/core.cpp and src/Arduboy2core.cpp for arduboy and arduboy2 libraries.
In Arduboy2/src/arduboy2core.cpp relace the two ‘paintscreen’ funcions with this:
void Arduboy2Core::paintScreen(uint8_t *image, bool clear){
for (int8_t i = 7; i >= 0; i--)
{
LCDCommandMode();
SPI.transfer(0xB0 + i); // Set row
SPI.transfer(0x02); // 0x02, Set lower column address (use 0x00 for SD1306 and SSD1309)
SPI.transfer(0x10); // Set higher column address
LCDDataMode();
for (uint16_t j = 128; j > 0; j--)
{
if(clear) image[i*128+128-j] = 0;
SPI.transfer(image[i*128+128-j]);
}
}
}
void Arduboy2Core::paintScreen(const uint8_t *image)
{
for (int8_t i = 7; i >= 0; i--)
{
LCDCommandMode();
SPI.transfer(0xB0 + i); // Set row
SPI.transfer(0x02); // 0x02, Set lower column address (use 0x00 for SD1306 and 1309)
SPI.transfer(0x10); // Set higher column address
LCDDataMode();
for (uint16_t j = 128; j > 0; j--)
{
SPI.transfer(image[i*128+128-j]);
}
}
}
And for the Arduboy/src/core/core.cpp in the Arduboy library replace the paintScreen funcion for this code:
void ArduboyCore::paintScreen(unsigned char image[])
{
for (int8_t i = 7; i >= 0; i–)
{
LCDCommandMode();
SPI.transfer(0xB0 + i); // Set row
SPI.transfer(0x02); // 0x02, Set lower column address (use 0x00 for SD1306 and 1309)
SPI.transfer(0x10); // Set higher column address
LCDDataMode();for (uint16_t j = 128; j > 0; j--) { SPI.transfer(image[i*128+128-j]); }
}
}
Since the last update of Arduboy2, the command SPI.transfer now is SPItransfer (no dot)
(thanks @Nono_Nano )
i’m pretty sure that with only this changes the SH1106 works well but i wrote this modifications some weeks ago and maybe i forgot something.
The good thing it’s that this code works for SSD1306, SSD1309 (2.42’’ OLED) and SH1106 and the only change it’s the 0x02 value in one line. (a horizontal offset) So you can easily adapt for to your driver.
And the bad thing it’s that consumes more memory. not much but i can’t load Evade that occupies 99% of memory. (Solved deleting a some parts of the soundtrack data )
Try and comment if worked or have some issues.
I know there’s a lot of programmers in the community and this changes may not be the better solution but it worked forme.
I’m not very experienced programming Arduboy software, one of my next projects will be a game for this great machine.
But for now this is my small contribution for the programmers and makers having issues with the differents OLED drivers.
Cheers!