I figured it out, also learned that displaying images takes a nice chunk of SRAM.
Anyway, I had to split the image into two and display half at a time.
Learned a lot about the sprite, found easier way to do it and save RAM (Program Memory)
I guess the bigger lesson for me is to look at the code. Thank goodness this is open source, also some programming I did on BMP files 13 years ago helped.
Here is the dirty:
Found this code
void LCD12864::DrawSprite(uint8_t xPos, uint8_t yPos) {
int count = 0;
for (int j = 0; j < sheight; j++) {
for (int i = 0; i < swidth; i++) {
if (pgm_read_byte_near(header_data + count) == 1)
this->DrawScreenBuffer(xPos+i,yPos+128+j);
count++;
}
}
}
Not know much about OOP, inheritance, and kind of want to see if this worked, I copied and made the following functions
void DrawSprite1(uint8_t xPos, uint8_t yPos) {
int count = 0;
// Zero out screen buffer
for (int j = 0; j < 31; j++) {
for (int i = 0; i < 15; i++) {
LCDA.ScreenBuffer[i][j] = 0;
}
}
for (int j = 0; j < 32; j++) {
for (int i = 0; i < swidth; i++) {
if (pgm_read_byte_near(header_data + count) == 1)
LCDA.DrawScreenBuffer(xPos+i,yPos+128+j);
count++;
}
}
}
void DrawSprite2(uint8_t xPos, uint8_t yPos) {
// Zero out screen buffer
for (int j = 0; j < 31; j++) {
for (int i = 0; i < 15; i++) {
LCDA.ScreenBuffer[i][j] = 0;
}
}
int count = 1728;
for (int j = 0; j < 22; j++) {
for (int i = 0; i < swidth; i++) {
if (pgm_read_byte_near(header_data + count) == 1)
LCDA.DrawScreenBuffer(xPos+i,yPos+128+j);
count++;
}
}
}
Here is how I called it
DrawSprite2(5,0); // 5 is the xPOS, 0 is the yPOS
delay(500); // you may or may not need the delay
LCDA.RenderScreenBuffer(2);
DrawSprite1(5,0); // 5 is the xPOS, 0 is the yPOS
delay(500); // you may or may not need the delay
LCDA.RenderScreenBuffer(1);
I agree this is ugly code, just figured it out and wanted to post it, I will do a write up of something cleaner, but this gives the gist of it.
