mirror of
https://github.com/DashyFox/MusicRing.git
synced 2025-06-28 05:09:40 +00:00
wrapper
This commit is contained in:
@ -28,25 +28,45 @@ protected:
|
||||
struct ScreenParam {
|
||||
uint16_t width, height, orientation;
|
||||
} screen;
|
||||
uint8_t* screenBuffer;
|
||||
uint16_t screenBufferSize;
|
||||
|
||||
uint8_t* buffer;
|
||||
public:
|
||||
Display(uint16_t width, uint16_t height, uint16_t orientation) {
|
||||
screen.width = width;
|
||||
screen.height = height;
|
||||
screenBufferSize = (width * height) / 8 + ((width * height) / 8) ? 1 : 0;
|
||||
screen.orientation = orientation;
|
||||
|
||||
buffer = new uint8_t[((width * height) / 8)];
|
||||
screenBuffer = new uint8_t[screenBufferSize];
|
||||
}
|
||||
|
||||
virtual void writePixel() {};
|
||||
virtual void writePixel(uint16_t x, uint16_t y, bool color) {};
|
||||
|
||||
void drawBbitmap(int16_t x, int16_t y, const uint8_t bitmap [],
|
||||
int16_t w, int16_t h) {
|
||||
void drawBitmap(int16_t posX, int16_t posY, const uint8_t bitmap [], int16_t sizeX, int16_t sizeY) {
|
||||
|
||||
Picture<128, 32> logo;
|
||||
for (uint16_t iY = 1; iY <= sizeY; iY++) {
|
||||
for (uint16_t iX = 1; iX <= sizeX; iX++) {
|
||||
uint16_t local = iY * (sizeY - 1) + iX;
|
||||
uint16_t global = screen.height * (posY + iY - 1) + (posX + iX);
|
||||
bool localPixel = (bitmap[local / 8] >> (7 - (local % 8))) & 1;
|
||||
bool globalPixel = (screenBuffer[global / 8] >> (7 - (global % 8))) & 1;
|
||||
|
||||
if (localPixel != globalPixel) {
|
||||
_writePixel(posX + iX, posY + iY, localPixel);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected:
|
||||
void _writePixel(uint16_t x, uint16_t y, bool color) {
|
||||
uint16_t Y = screen.height * (y - 1);
|
||||
if (color) {
|
||||
screenBuffer[(Y + x) / 8] |= (1 << (7 - (Y + x) % 8)); // |= 0b00010000
|
||||
} else {
|
||||
screenBuffer[(Y + x) / 8] &= ~(1 << (7 - (Y + x) % 8)); // &= 11101111
|
||||
}
|
||||
writePixel(x, y, color);
|
||||
}
|
||||
};
|
||||
|
Reference in New Issue
Block a user