datacute / Tiny4kOLED

Library for an ATTiny85 to use an SSD1306 powered, double buffered, 128x32 pixel OLED, over I2C
MIT License
269 stars 39 forks source link

How to center my bitmap with 128x64 oled screen? #64

Open Naografix opened 4 months ago

Naografix commented 4 months ago

Hey,

I'm trying your amazing lib to my oled 128x64 screen and my ATTINY85 but I have a little problem with battery animation, take a look:

448740887_903720268228729_997421146227043813_n

How can I center my bitmap? I tried to increase the Y but it not work. It seems I have a problem with a double buffer...

#include <Tiny4kOLED.h>
#include "SolomonSystech.h"

const uint8_t* batteryImages[] = {battery1, battery2, battery3, batteryfull};
int index = 0;

void setup() {  
  Serial.begin(9600);
  oled.begin(128, 64, sizeof(tiny4koled_init_128x64r), tiny4koled_init_128x64r); 
  oled.clear();   
  oled.on();  
  oled.switchRenderFrame();
} 

void loop() {
  index = (index + 1) % 4;
  oled.bitmap(32, 2, 95, 5, batteryImages[index]);
  delay(500);
}

Thanks for your help

datacute commented 4 months ago

Don't call oled.switchRenderFrame(); That's for choosing which half of the memory to show on 128x32 displays. On a 128x64 display, you typically want to display all the memory all the time.