abstracting images

This commit is contained in:
Jorj Bauer 2022-01-23 21:39:45 -05:00
parent 7464e05578
commit a7f6307174
9 changed files with 145212 additions and 145129 deletions

View File

@ -62,26 +62,35 @@ void AppleUI::drawBatteryStatus(uint8_t percent)
// the area around the apple is 12 wide; it's exactly 11 high the
// color is 210/202/159
float watermark = ((float)percent / 100.0) * 11;
static const uint8_t *img = NULL;
static uint16_t h,w;
if (!img) {
if (!getImageInfoAndData(IMG_APPLEBATTERY, &w, &h, &img)) {
return;
}
}
float watermark = ((float)percent / 100.0) * h;
for (int y=0; y<11; y++) {
for (int y=0; y<h; y++) {
uint8_t bgr = 210;
uint8_t bgg = 202;
uint8_t bgb = 159;
if (11-y > watermark) {
if ((h-y) > watermark) {
// black...
bgr = bgg = bgb = 0;
}
for (int x=0; x<10; x++) {
uint16_t w = w;
for (int x=0; x<w; x++) {
#ifdef TEENSYDUINO
uint8_t r = pgm_read_byte(&appleBitmap[(y * 10 + x)*4 + 0]);
uint8_t g = pgm_read_byte(&appleBitmap[(y * 10 + x)*4 + 1]);
uint8_t b = pgm_read_byte(&appleBitmap[(y * 10 + x)*4 + 2]);
uint8_t a = pgm_read_byte(&appleBitmap[(y * 10 + x)*4 + 3]);
uint8_t r = pgm_read_byte(&img[(y * w + x)*4 + 0]);
uint8_t g = pgm_read_byte(&img[(y * w + x)*4 + 1]);
uint8_t b = pgm_read_byte(&img[(y * w + x)*4 + 2]);
uint8_t a = pgm_read_byte(&img[(y * w + x)*4 + 3]);
#else
const uint8_t *p = &appleBitmap[(y * 10 + (x-1))*4];
const uint8_t *p = &img[(y * w + (x-1))*4];
uint8_t r, g, b, a;
r = p[0];
g = p[1];
@ -103,20 +112,43 @@ void AppleUI::drawBatteryStatus(uint8_t percent)
void AppleUI::blit()
{
static const uint8_t *bg_img = NULL;
static uint16_t bg_h,bg_w;
if (!bg_img) {
if (!getImageInfoAndData(IMG_SHELL, &bg_w, &bg_h, &bg_img))
return;
}
if (redrawFrame) {
redrawFrame = false;
g_display->drawImageOfSizeAt(displayBitmap, DBITMAP_WIDTH, DBITMAP_HEIGHT, 0, 0);
g_display->drawImageOfSizeAt(bg_img, bg_w, bg_h, 0, 0);
}
if (redrawDriveLatches) {
redrawDriveLatches = false;
const uint8_t *img;
static const uint8_t *d1open_img = NULL;
static const uint8_t *d1closed_img = NULL;
static const uint16_t d1_w, d1_h;
static const uint8_t *d2open_img = NULL;
static const uint8_t *d2closed_img = NULL;
static const uint16_t d2_w, d2_h;
img = driveInserted[0] ? drive1LatchOpen : drive1LatchClosed;
g_display->drawImageOfSizeAt(img, LATCH_WIDTH, LATCH_HEIGHT, LATCH_X, LATCH1_Y);
if (!d1open_img && !getImageInfoAndData(IMG_D1OPEN, &d1_w, &d1_h, &d1open_img))
return;
img = driveInserted[1] ? drive2LatchOpen : drive2LatchClosed;
g_display->drawImageOfSizeAt(img, LATCH_WIDTH, LATCH_HEIGHT, LATCH_X, LATCH2_Y);
if (!d1closed_img && !getImageInfoAndData(IMG_D1CLOSED, &d1_w, &d1_h, &d1closed_img))
return;
if (!d2open_img && !getImageInfoAndData(IMG_D2OPEN, &d2_w, &d2_h, &d2open_img))
return;
if (!d2closed_img && !getImageInfoAndData(IMG_D2CLOSED, &d2_w, &d2_h, &d2closed_img))
return;
// assumes all the latch images are the same width/height
g_display->drawImageOfSizeAt(driveInserted[0] ? d1closed_img : d1open_img, d1_w, d1_h, LATCH_X, LATCH1_Y);
g_display->drawImageOfSizeAt(driveInserted[1] ? d2closed_img : d2open_img, d2_w, d2_h, LATCH_X, LATCH1_Y);
}
if (redrawDriveActivity) {

58
image-8875-apple.h Normal file
View File

@ -0,0 +1,58 @@
const static uint8_t image_8875_apple[] PROGMEM = {
0xA7, 0xD7, 0x98, 0x00, 0x87, 0xCC, 0x72, 0x00,
0x7B, 0xC1, 0x65, 0x00, 0x9D, 0xD0, 0x8D, 0x00,
0xBF, 0xE0, 0xB7, 0x00, 0x81, 0xC9, 0x6A, 0x6F,
0x68, 0xC0, 0x4B, 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0xBC, 0xFF,
0x68, 0x77, 0xC2, 0xAE, 0x97, 0xA5, 0xD3, 0x00,
0x62, 0xC7, 0xEE, 0x00, 0x42, 0xC0, 0xEC, 0x23,
0x01, 0xA6, 0xE4, 0xC8, 0x01, 0xA4, 0xE4, 0xDB,
0x12, 0xAA, 0xE3, 0x90, 0x11, 0xAA, 0xE3, 0x93,
0x00, 0xA4, 0xE4, 0xE0, 0x06, 0xA8, 0xE5, 0xBA,
0x5C, 0xC8, 0xEC, 0x15, 0x77, 0xCC, 0xEC, 0x00
};

144002
image-8875-bg.h Normal file

File diff suppressed because it is too large Load Diff

1036
image-8875-drivelatches.h Normal file

File diff suppressed because it is too large Load Diff

145152
images.cpp

File diff suppressed because it is too large Load Diff

View File

@ -1,3 +1,6 @@
#ifndef __IMAGES_H
#define __IMAGES_H
#ifdef TEENSYDUINO
#include <Arduino.h>
#else
@ -22,20 +25,15 @@
#define LED1_Y 68
#define LED2_Y 117
// RGB
extern const uint8_t displayBitmap[];
enum {
IMG_SHELL = 0, // previously displayBitmap
IMG_D1OPEN = 1,
IMG_D1CLOSED = 2,
IMG_D2OPEN = 3,
IMG_D2CLOSED = 4,
IMG_APPLEBATTERY = 5
};
// RGB
extern const uint8_t drive1LatchClosed[];
const bool getImageInfoAndData(uint8_t imgnum, uint16_t *width, uint16_t *height, const uint8_t **dataptr);
// RGB
extern const uint8_t drive1LatchOpen[];
// RGB
extern const uint8_t drive2LatchClosed[];
// RGB
extern const uint8_t drive2LatchOpen[];
// 10 x 11, RGBA
extern const uint8_t appleBitmap[];
#endif

1
teensy/image-8875-apple.h Symbolic link
View File

@ -0,0 +1 @@
../image-8875-apple.h

1
teensy/image-8875-bg.h Symbolic link
View File

@ -0,0 +1 @@
../image-8875-bg.h

View File

@ -0,0 +1 @@
../image-8875-drivelatches.h