I'd like to add a method that replaces the entire image buffer into the Adafruit_SSD1306 library. I haven't worked with dynamic memory handling for ages and I'm not sure how to just simply overwrite its pointer to point to a different memory address where my newBuffer is.
static uint8_t buffer[SSD1306_LCDHEIGHT * SSD1306_LCDWIDTH / 8] = {}
void Adafruit_SSD1306::setBuffer(uint8_t * newBuffer) {
buffer = newBuffer; // not sure which operator to use
}
Update: Passing by reference wouldn't work. The question is: how to overwrite by copying? Would it work well with memcpy
?
void Adafruit_SSD1306::setBuffer(uint8_t * newBuffer) {
memcpy(newBuffer, buffer, (SSD1306_LCDWIDTH * SSD1306_LCDHEIGHT / 8));
}
Update: The code above doesn't seem to making anything. This one neither:
void Adafruit_SSD1306::setBuffer(uint8_t * newBuffer) {
for(int16_t i = 0; i < SSD1306_LCDWIDTH * SSD1306_LCDHEIGHT / 8; i++) {
buffer[i] = 255; // experimenting
}
}
Update: setPixel
doesn't work either. - Needed display.display();
:)
newBuffer
inbuffer
or rewritebuffer
to beuint8_t*
which you can change? – Maximilian Gerhardt Apr 1 '18 at 17:12newBuffer
from network and) I wan't a solution that replaces the imagebuffer
the fastest. I don't mind making some changes in the library as long as it's easy. :) – haxpanel Apr 1 '18 at 17:14