abstracting and cleaning up

This commit is contained in:
Jorj Bauer 2022-02-02 08:14:58 -05:00
parent 3e2ddb725f
commit 8cd2bc24ab
5 changed files with 59 additions and 25 deletions

View File

@ -121,17 +121,7 @@ void AppleUI::blit()
if (redrawDriveActivity) { if (redrawDriveActivity) {
redrawDriveActivity = false; redrawDriveActivity = false;
g_display->drawDriveActivity(driveActivity[0], driveActivity[1]);
/*
// FIXME make these bitmaps so the size/location are abstracted
for (int y=0; y<LED_HEIGHT; y++) {
for (int x=0; x<LED_WIDTH; x++) {
g_display->drawPixel(x + LED_X, y + LED1_Y, driveActivity[0] ? 0xFA00 : 0x0000);
g_display->drawPixel(x + LED_X, y + LED2_Y, driveActivity[1] ? 0xFA00 : 0x0000);
}
}
*/
} }
} }

View File

@ -12,12 +12,13 @@
#define SCREENINSET_9341_X (18) #define SCREENINSET_9341_X (18)
#define SCREENINSET_9341_Y (13) #define SCREENINSET_9341_Y (13)
// Spacing and positioning of elements within the DBITMAP, used by AppleUI // drive activity LED positions
#define LED_HEIGHT 9 #define LED_HEIGHT_8875 9
#define LED_WIDTH 17 #define LED_WIDTH_8875 17
#define LED_X 48 #define LED1_X_8875 48
#define LED1_Y 68 #define LED2_X_8875 48
#define LED2_Y 117 #define LED1_Y_8875 68
#define LED2_Y_8875 117
// These are the ABSTRACTED constants that AppleUI uses to tell the // These are the ABSTRACTED constants that AppleUI uses to tell the
// display what it wants redrawn via drawUIImage(uint8_t imageIdx) // display what it wants redrawn via drawUIImage(uint8_t imageIdx)

View File

@ -15,6 +15,7 @@ class PhysicalDisplay {
virtual void flush() = 0; virtual void flush() = 0;
virtual void drawUIImage(uint8_t imageIdx) = 0; virtual void drawUIImage(uint8_t imageIdx) = 0;
virtual void drawDriveActivity(bool drive0, bool drive1) = 0;
// FIXME: drawImageOfSizeAt should probably be private now // FIXME: drawImageOfSizeAt should probably be private now
virtual void drawImageOfSizeAt(const uint8_t *img, uint16_t sizex, uint16_t sizey, uint16_t wherex, uint16_t wherey) = 0; virtual void drawImageOfSizeAt(const uint8_t *img, uint16_t sizex, uint16_t sizey, uint16_t wherex, uint16_t wherey) = 0;

View File

@ -53,12 +53,13 @@ TeensyDisplay::TeensyDisplay()
appleImage = NULL; appleImage = NULL;
// FIXME abstract pin number, don't hard code it // FIXME abstract pin number, don't hard code it
pinMode(11, INPUT); pinMode(11, INPUT_PULLUP);
digitalWrite(11, HIGH); // turn on pull-up delay(10); // let it rise before reading it
if (digitalRead(11)) { if (digitalRead(11)) {
// Default: use older, smaller but faster, ILI display if pin 11 is not connected to ground // Default: use older, smaller but faster, ILI display if pin 11 is not connected to ground
Serial.println(" using ILI9341 display"); Serial.println(" using ILI9341 display");
use8875 = false;
dmaBuffer16 = (uint16_t *)malloc((320*240)*2+32); // malloc() happens in the DMAMEM area (RAM2) dmaBuffer16 = (uint16_t *)malloc((320*240)*2+32); // malloc() happens in the DMAMEM area (RAM2)
// And we have to be sure dmaBuffer16 is 32-byte aligned for DMA purposes // And we have to be sure dmaBuffer16 is 32-byte aligned for DMA purposes
@ -81,6 +82,7 @@ TeensyDisplay::TeensyDisplay()
} else { } else {
// If someone grounded pin 11, then use the new RA8875 display // If someone grounded pin 11, then use the new RA8875 display
Serial.println(" using RA8875 display"); Serial.println(" using RA8875 display");
use8875 = true;
dmaBuffer = (uint8_t *)malloc(800*480+32); // malloc() happens in the DMAMEM area (RAM2) dmaBuffer = (uint8_t *)malloc(800*480+32); // malloc() happens in the DMAMEM area (RAM2)
// And we have to be sure dmaBuffer is 32-byte aligned for DMA purposes // And we have to be sure dmaBuffer is 32-byte aligned for DMA purposes
@ -129,16 +131,24 @@ void TeensyDisplay::drawUIImage(uint8_t imageIdx)
drawImageOfSizeAt(shellImage, shellWidth, shellHeight, 0, 0); drawImageOfSizeAt(shellImage, shellWidth, shellHeight, 0, 0);
break; break;
case IMG_D1OPEN: case IMG_D1OPEN:
drawImageOfSizeAt(d1OpenImage, driveWidth, driveHeight, 55, 216); drawImageOfSizeAt(d1OpenImage, driveWidth, driveHeight,
use8875 ? 4 : 55,
use8875 ? 67 : 216);
break; break;
case IMG_D1CLOSED: case IMG_D1CLOSED:
drawImageOfSizeAt(d1ClosedImage, driveWidth, driveHeight, 55, 216); drawImageOfSizeAt(d1ClosedImage, driveWidth, driveHeight,
use8875 ? 4 : 55,
use8875 ? 67 : 216);
break; break;
case IMG_D2OPEN: case IMG_D2OPEN:
drawImageOfSizeAt(d2OpenImage, driveWidth, driveHeight, 189, 216); drawImageOfSizeAt(d2OpenImage, driveWidth, driveHeight,
use8875 ? 4 : 189,
use8875 ? 116 : 216);
break; break;
case IMG_D2CLOSED: case IMG_D2CLOSED:
drawImageOfSizeAt(d2ClosedImage, driveWidth, driveHeight, 189, 216); drawImageOfSizeAt(d2ClosedImage, driveWidth, driveHeight,
use8875 ? 4 : 189,
use8875 ? 116 : 216);
break; break;
case IMG_APPLEBATTERY: case IMG_APPLEBATTERY:
// FIXME *** // FIXME ***
@ -146,6 +156,33 @@ void TeensyDisplay::drawUIImage(uint8_t imageIdx)
} }
} }
void TeensyDisplay::drawDriveActivity(bool drive0, bool drive1)
{
// FIXME port constants for 9341
if (drive0 != driveIndicator[0]) {
if (use8875) {
for (int y=0; y<LED_HEIGHT_8875; y++) {
for (int x=0; x<LED_WIDTH_8875; x++) {
drawPixel(x+LED1_X_8875, y+LED1_Y_8875, drive0 ? 0xFA00 : 0x0000);
}
}
}
driveIndicator[0] = drive0;
}
if (drive1 != driveIndicator[1]) {
if (use8875) {
for (int y=0; y<LED_HEIGHT_8875; y++) {
for (int x=0; x<LED_WIDTH_8875; x++) {
drawPixel(x+LED2_X_8875, y+LED2_Y_8875, drive1 ? 0xFA00 : 0x0000);
}
}
}
// FIXME also 9341
driveIndicator[1] = drive1;
}
}
// *** this probably needs to be private now FIXME // *** this probably needs to be private now FIXME
void TeensyDisplay::drawImageOfSizeAt(const uint8_t *img, void TeensyDisplay::drawImageOfSizeAt(const uint8_t *img,
uint16_t sizex, uint16_t sizey, uint16_t sizex, uint16_t sizey,
@ -179,7 +216,8 @@ void TeensyDisplay::blit()
static uint32_t nextMessageTime = 0; static uint32_t nextMessageTime = 0;
if (millis() >= nextMessageTime) { if (millis() >= nextMessageTime) {
if (overlayMessage[0]) { if (overlayMessage[0]) {
drawString(M_SELECTDISABLED, 1, (RA8875_HEIGHT - 18)/2, overlayMessage); // FIXME this /2 is clunky b/c drawString winds up doubling /// FIXME This position needs updating for each display differently
// drawString(M_SELECTDISABLED, 1, (RA8875_HEIGHT - 18)/2, overlayMessage); // FIXME this /2 is clunky b/c drawString winds up doubling
} }
nextMessageTime = millis() + 1000; nextMessageTime = millis() + 1000;
} }

View File

@ -22,6 +22,8 @@ class TeensyDisplay : public PhysicalDisplay {
virtual void clrScr(uint8_t coloridx); virtual void clrScr(uint8_t coloridx);
virtual void drawUIImage(uint8_t imageIdx); virtual void drawUIImage(uint8_t imageIdx);
virtual void drawDriveActivity(bool drive0, bool drive1);
virtual void drawImageOfSizeAt(const uint8_t *img, uint16_t sizex, uint16_t sizey, uint16_t wherex, uint16_t wherey); virtual void drawImageOfSizeAt(const uint8_t *img, uint16_t sizex, uint16_t sizey, uint16_t wherex, uint16_t wherey);
virtual void cacheDoubleWidePixel(uint16_t x, uint16_t y, uint8_t color); virtual void cacheDoubleWidePixel(uint16_t x, uint16_t y, uint8_t color);
@ -47,6 +49,8 @@ private:
const uint8_t *appleImage; const uint8_t *appleImage;
const uint16_t appleImageWidth, appleImageHeight; const uint16_t appleImageWidth, appleImageHeight;
bool use8875;
BaseDisplay *tft; BaseDisplay *tft;
}; };