|
| 1 | +#include "SplashScreen.h" |
| 2 | +#include "Config.h" |
| 3 | +#include "GlobalVariables.h" |
| 4 | +#include "NotoSansBold15.h" |
| 5 | +#include "NotoSansBold36.h" |
| 6 | + |
| 7 | +// External display object |
| 8 | +extern TFT_eSPI display; |
| 9 | + |
| 10 | +void showAnimatedSplashScreen() { |
| 11 | + display.fillScreen(TFT_BLACK); |
| 12 | + |
| 13 | + int centerX = display.width() / 2; |
| 14 | + int centerY = (display.height() / 2) - 35; |
| 15 | + |
| 16 | + // Animation sequence - no slide animations to avoid ghosting |
| 17 | + drawFadeInBackground(centerX, centerY); |
| 18 | + drawFadeInTitle(centerX, centerY); |
| 19 | + drawFadeInSubtitle(centerX, centerY); |
| 20 | + drawFadeInWebsite(centerX, centerY); |
| 21 | + drawPulsingTitle(centerX, centerY); |
| 22 | + drawLoadingBar(centerX, centerY); |
| 23 | + drawFadeOutTransition(); |
| 24 | + |
| 25 | + // Final black screen |
| 26 | + display.fillScreen(TFT_BLACK); |
| 27 | +} |
| 28 | + |
| 29 | +void drawFadeInBackground(int centerX, int centerY) { |
| 30 | + // Animation 1: Fade in logo background |
| 31 | + for (int alpha = 0; alpha <= 40; alpha += 2) { |
| 32 | + uint16_t bgColor = display.color565(0, alpha/2, alpha); // Dark blue background |
| 33 | + display.fillRoundRect(centerX - 200, centerY - 60, 400, 120, 10, bgColor); |
| 34 | + delay(10); |
| 35 | + } |
| 36 | +} |
| 37 | + |
| 38 | +void drawFadeInTitle(int centerX, int centerY) { |
| 39 | + // Animation 2: Fade in main title |
| 40 | + display.loadFont(AA_FONT_LARGE); |
| 41 | + display.setTextDatum(TC_DATUM); |
| 42 | + |
| 43 | + uint16_t bgColor = display.color565(0, 20, 40); |
| 44 | + |
| 45 | + // Draw the background rectangle once |
| 46 | + display.fillRoundRect(centerX - 200, centerY - 60, 400, 120, 10, bgColor); |
| 47 | + |
| 48 | + // Fade in the title text |
| 49 | + for (int alpha = 0; alpha <= 255; alpha += 15) { |
| 50 | + // Clear title area |
| 51 | + display.fillRect(centerX - 150, centerY - 20, 300, 40, bgColor); |
| 52 | + |
| 53 | + // Draw title with fade effect |
| 54 | + uint16_t textColor = display.color565(alpha, alpha, alpha); |
| 55 | + display.setTextColor(textColor, bgColor); |
| 56 | + display.drawString("MAZDUINO Display", centerX, centerY); |
| 57 | + |
| 58 | + delay(20); |
| 59 | + } |
| 60 | +} |
| 61 | + |
| 62 | +void drawFadeInSubtitle(int centerX, int centerY) { |
| 63 | + // Animation 3: Fade in subtitle |
| 64 | + display.loadFont(AA_FONT_SMALL); |
| 65 | + String versionText = "Firmware version: " + String(version); |
| 66 | + uint16_t bgColor = display.color565(0, 20, 40); |
| 67 | + |
| 68 | + for (int alpha = 0; alpha <= 200; alpha += 20) { |
| 69 | + // Clear subtitle area |
| 70 | + display.fillRect(centerX - 120, centerY + 40, 240, 30, bgColor); |
| 71 | + |
| 72 | + // Draw subtitle with fade effect |
| 73 | + uint16_t textColor = display.color565(alpha, alpha, alpha); |
| 74 | + display.setTextColor(textColor, bgColor); |
| 75 | + display.drawString(versionText, centerX, centerY + 50); |
| 76 | + |
| 77 | + delay(20); |
| 78 | + } |
| 79 | +} |
| 80 | + |
| 81 | +void drawFadeInWebsite(int centerX, int centerY) { |
| 82 | + // Animation 4: Fade in website text |
| 83 | + String websiteText = "www.mazduino.com"; |
| 84 | + uint16_t bgColor = display.color565(0, 20, 40); |
| 85 | + |
| 86 | + // Draw the background rectangle once |
| 87 | + display.fillRoundRect(centerX - 100, 290, 200, 30, 5, bgColor); |
| 88 | + |
| 89 | + // Fade in the website text |
| 90 | + for (int alpha = 0; alpha <= 255; alpha += 20) { |
| 91 | + // Clear website area |
| 92 | + display.fillRect(centerX - 100, 290, 200, 30, bgColor); |
| 93 | + |
| 94 | + // Draw website with fade effect |
| 95 | + uint16_t textColor = display.color565(0, alpha, alpha); // Cyan fade effect |
| 96 | + display.setTextColor(textColor, bgColor); |
| 97 | + display.drawString(websiteText, centerX, 300); |
| 98 | + |
| 99 | + delay(30); |
| 100 | + } |
| 101 | +} |
| 102 | + |
| 103 | +void drawPulsingTitle(int centerX, int centerY) { |
| 104 | + // Animation 5: Pulsing effect on main title |
| 105 | + display.loadFont(AA_FONT_LARGE); |
| 106 | + uint16_t bgColor = display.color565(0, 20, 40); |
| 107 | + |
| 108 | + for (int pulse = 0; pulse < 2; pulse++) { |
| 109 | + // Pulse bright |
| 110 | + for (int brightness = 255; brightness >= 180; brightness -= 10) { |
| 111 | + // Clear title area |
| 112 | + display.fillRect(centerX - 150, centerY - 20, 300, 40, bgColor); |
| 113 | + |
| 114 | + // Draw pulsing title |
| 115 | + uint16_t pulseColor = display.color565(brightness, brightness, brightness); |
| 116 | + display.setTextColor(pulseColor, bgColor); |
| 117 | + display.drawString("MAZDUINO Display", centerX, centerY); |
| 118 | + |
| 119 | + delay(15); |
| 120 | + } |
| 121 | + |
| 122 | + // Pulse dim |
| 123 | + for (int brightness = 180; brightness <= 255; brightness += 10) { |
| 124 | + // Clear title area |
| 125 | + display.fillRect(centerX - 150, centerY - 20, 300, 40, bgColor); |
| 126 | + |
| 127 | + // Draw pulsing title |
| 128 | + uint16_t pulseColor = display.color565(brightness, brightness, brightness); |
| 129 | + display.setTextColor(pulseColor, bgColor); |
| 130 | + display.drawString("MAZDUINO Display", centerX, centerY); |
| 131 | + |
| 132 | + delay(15); |
| 133 | + } |
| 134 | + } |
| 135 | +} |
| 136 | + |
| 137 | +void drawLoadingBar(int centerX, int centerY) { |
| 138 | + // Animation 6: Loading bar animation |
| 139 | + int barWidth = 280; |
| 140 | + int barHeight = 8; |
| 141 | + int barX = centerX - barWidth / 2; |
| 142 | + int barY = centerY + 75; |
| 143 | + uint16_t bgColor = display.color565(0, 20, 40); |
| 144 | + |
| 145 | + // Draw loading bar background |
| 146 | + display.fillRoundRect(barX - 2, barY - 2, barWidth + 4, barHeight + 4, 5, TFT_DARKGREY); |
| 147 | + display.fillRoundRect(barX, barY, barWidth, barHeight, 3, TFT_BLACK); |
| 148 | + |
| 149 | + // Animate loading bar |
| 150 | + for (int progress = 0; progress <= barWidth; progress += 4) { |
| 151 | + // Clear percentage area |
| 152 | + display.fillRect(centerX - 25, barY + 20, 50, 20, bgColor); |
| 153 | + |
| 154 | + // Draw progress bar |
| 155 | + for (int i = 0; i < progress; i++) { |
| 156 | + uint16_t barColor; |
| 157 | + if (i < barWidth * 0.4) { |
| 158 | + barColor = TFT_RED; |
| 159 | + } else if (i < barWidth * 0.8) { |
| 160 | + barColor = TFT_YELLOW; |
| 161 | + } else { |
| 162 | + barColor = TFT_GREEN; |
| 163 | + } |
| 164 | + display.drawFastVLine(barX + i, barY, barHeight, barColor); |
| 165 | + } |
| 166 | + |
| 167 | + // Show percentage |
| 168 | + int percentage = (progress * 100) / barWidth; |
| 169 | + display.setTextColor(TFT_WHITE, bgColor); |
| 170 | + display.loadFont(AA_FONT_SMALL); |
| 171 | + display.drawString(String(percentage) + "%", centerX, barY + 25); |
| 172 | + |
| 173 | + delay(10); |
| 174 | + } |
| 175 | + |
| 176 | + // Hold at 100% for a moment |
| 177 | + delay(300); |
| 178 | +} |
| 179 | + |
| 180 | +void drawFadeOutTransition() { |
| 181 | + // Animation 7: Fade out splash screen |
| 182 | + for (int alpha = 40; alpha >= 0; alpha -= 2) { |
| 183 | + uint16_t fadeColor = display.color565(0, alpha/2, alpha); |
| 184 | + display.fillScreen(fadeColor); |
| 185 | + delay(10); |
| 186 | + } |
| 187 | +} |
0 commit comments