add proper firmware flashing screen

This commit is contained in:
cottongin
2026-01-27 13:16:20 -05:00
parent 7349fbb208
commit a04388fd6c
8 changed files with 357 additions and 0 deletions

View File

@@ -205,6 +205,55 @@ void GfxRenderer::drawImage(const uint8_t bitmap[], const int x, const int y, co
einkDisplay.drawImage(bitmap, rotatedX, rotatedY, width, height);
}
void GfxRenderer::drawImageRotated(const uint8_t bitmap[], const int x, const int y, const int width, const int height,
const ImageRotation rotation, const bool invert) const {
// Calculate output dimensions based on rotation
const int outWidth = (rotation == ROTATE_90 || rotation == ROTATE_270) ? height : width;
const int outHeight = (rotation == ROTATE_90 || rotation == ROTATE_270) ? width : height;
// Draw each pixel from the source bitmap with rotation
for (int srcY = 0; srcY < height; srcY++) {
for (int srcX = 0; srcX < width; srcX++) {
// Read source pixel (1-bit packed, MSB first)
const int byteIndex = srcY * ((width + 7) / 8) + (srcX / 8);
const int bitIndex = 7 - (srcX % 8);
const bool srcPixel = (bitmap[byteIndex] >> bitIndex) & 1;
// Apply inversion if requested
const bool pixelState = invert ? !srcPixel : srcPixel;
// Skip black pixels (transparent on black background)
if (!pixelState) continue;
// Calculate destination coordinates based on rotation (clockwise)
int dstX, dstY;
switch (rotation) {
case ROTATE_0:
dstX = srcX;
dstY = srcY;
break;
case ROTATE_90: // 90° clockwise
dstX = height - 1 - srcY;
dstY = srcX;
break;
case ROTATE_180:
dstX = width - 1 - srcX;
dstY = height - 1 - srcY;
break;
case ROTATE_270: // 270° clockwise (= 90° counter-clockwise)
dstX = srcY;
dstY = width - 1 - srcX;
break;
}
// Draw the pixel at the rotated position
// Note: pixelState=true means white pixel, but drawPixel(state=true) draws black
// So we invert: draw with state=false for white pixels
drawPixel(x + dstX, y + dstY, false);
}
}
}
void GfxRenderer::drawBitmap(const Bitmap& bitmap, const int x, const int y, const int maxWidth, const int maxHeight,
const float cropX, const float cropY, const bool invert) const {
// For 1-bit bitmaps, use optimized 1-bit rendering path (no crop support for 1-bit)

View File

@@ -11,6 +11,9 @@ class GfxRenderer {
public:
enum RenderMode { BW, GRAYSCALE_LSB, GRAYSCALE_MSB };
// Image rotation (clockwise)
enum ImageRotation { ROTATE_0 = 0, ROTATE_90 = 90, ROTATE_180 = 180, ROTATE_270 = 270 };
// Logical screen orientation from the perspective of callers
enum Orientation {
Portrait, // 480x800 logical coordinates (current default)
@@ -69,6 +72,8 @@ class GfxRenderer {
// Handles current render mode (BW, GRAYSCALE_MSB, GRAYSCALE_LSB)
void fillRectGray(int x, int y, int width, int height, uint8_t grayLevel) const;
void drawImage(const uint8_t bitmap[], int x, int y, int width, int height) const;
void drawImageRotated(const uint8_t bitmap[], int x, int y, int width, int height,
ImageRotation rotation, bool invert = false) const;
void drawBitmap(const Bitmap& bitmap, int x, int y, int maxWidth, int maxHeight, float cropX = 0,
float cropY = 0, bool invert = false) const;
void drawBitmap1Bit(const Bitmap& bitmap, int x, int y, int maxWidth, int maxHeight, bool invert = false) const;