Skip to content

Commit 7a6e27d

Browse files
committed
add splashscreen
1 parent 8fee3a0 commit 7a6e27d

3 files changed

Lines changed: 222 additions & 30 deletions

File tree

src/DisplayManager.cpp

Lines changed: 19 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include "DataTypes.h"
44
#include "DisplayConfig.h"
55
#include "drawing_utils.h"
6+
#include "SplashScreen.h"
67
#include "NotoSansBold15.h"
78
#include "NotoSansBold36.h"
89
#include <EEPROM.h>
@@ -21,20 +22,8 @@ void setupDisplay() {
2122
}
2223

2324
void drawSplashScreenWithImage() {
24-
display.fillScreen(TFT_BLACK);
25-
display.loadFont(AA_FONT_LARGE);
26-
display.setTextColor(TFT_WHITE, TFT_BLACK);
27-
28-
display.setTextDatum(TC_DATUM);
29-
int centerX = display.width() / 2;
30-
int centerY = (display.height() / 2) - 35;
31-
32-
display.drawString("MAZDUINO Display", centerX, centerY);
33-
display.loadFont(AA_FONT_SMALL);
34-
display.drawString("Firmware version: " + String(version), centerX, centerY + 50);
35-
display.drawString("www.mazduino.com", centerX, 300);
36-
37-
delay(5000);
25+
// Use the new modular animated splash screen
26+
showAnimatedSplashScreen();
3827
}
3928

4029
void drawConfigurablePanels(bool setup) {
@@ -43,14 +32,14 @@ void drawConfigurablePanels(bool setup) {
4332
// RPM bar occupies roughly Y=40 to Y=150, so panels moved to avoid collision
4433
// Each panel is 80px tall, fitting 2 main panels per column + 1 bottom panel each
4534
int panelPositions[8][2] = {
46-
{5, 10}, // Position 0: Left-Top (AFR) - Y=160 to Y=240
47-
{5, 100}, // Position 1: Left-Middle (TPS) - Y=245 to Y=325
48-
{5, 190}, // Position 2: Left-Bottom (IAT) - Y=280 to Y=360, will be clipped but user requested
49-
{365, 10}, // Position 3: Right-Top (MAP) - Y=160 to Y=240
50-
{365, 100}, // Position 4: Right-Middle (ADV) - Y=245 to Y=325
51-
{365, 190}, // Position 5: Right-Bottom (FP) - Y=280 to Y=360, will be clipped but user requested
52-
{120, 190}, // Position 6: Center-Left (Coolant) - moved to center to avoid overlap
53-
{240, 190} // Position 7: Center-Right (Voltage) - moved to center to avoid overlap
35+
{5, 20}, // Position 0: Left-Top (AFR) - Y=160 to Y=240
36+
{5, 110}, // Position 1: Left-Middle (TPS) - Y=245 to Y=325
37+
{5, 200}, // Position 2: Left-Bottom (IAT) - Y=280 to Y=360, will be clipped but user requested
38+
{365, 20}, // Position 3: Right-Top (MAP) - Y=160 to Y=240
39+
{365, 110}, // Position 4: Right-Middle (ADV) - Y=245 to Y=325
40+
{365, 200}, // Position 5: Right-Bottom (FP) - Y=280 to Y=360, will be clipped but user requested
41+
{120, 200}, // Position 6: Center-Left (Coolant) - moved to center to avoid overlap
42+
{240, 200} // Position 7: Center-Right (Voltage) - moved to center to avoid overlap
5443
};
5544

5645
// Draw each enabled panel
@@ -67,14 +56,14 @@ void drawModularDataPanel(const DisplayPanel &panel, bool setup) {
6756
// RPM bar occupies roughly Y=40 to Y=150, so panels moved to avoid collision
6857
// Each panel is 80px tall, fitting 2 main panels per column + 1 bottom panel each
6958
int panelPositions[8][2] = {
70-
{5, 10}, // Position 0: Left-Top (AFR) - Y=160 to Y=240
71-
{5, 100}, // Position 1: Left-Middle (TPS) - Y=245 to Y=325
72-
{5, 190}, // Position 2: Left-Bottom (IAT) - Y=280 to Y=360, will be clipped but user requested
73-
{365, 10}, // Position 3: Right-Top (MAP) - Y=160 to Y=240
74-
{365, 100}, // Position 4: Right-Middle (ADV) - Y=245 to Y=325
75-
{365, 190}, // Position 5: Right-Bottom (FP) - Y=280 to Y=360, will be clipped but user requested
76-
{120, 190}, // Position 6: Center-Left (Coolant) - moved to center to avoid overlap
77-
{240, 190} // Position 7: Center-Right (Voltage) - moved to center to avoid overlap
59+
{5, 20}, // Position 0: Left-Top (AFR) - Y=160 to Y=240
60+
{5, 110}, // Position 1: Left-Middle (TPS) - Y=245 to Y=325
61+
{5, 200}, // Position 2: Left-Bottom (IAT) - Y=280 to Y=360, will be clipped but user requested
62+
{365, 20}, // Position 3: Right-Top (MAP) - Y=160 to Y=240
63+
{365, 110}, // Position 4: Right-Middle (ADV) - Y=245 to Y=325
64+
{365, 200}, // Position 5: Right-Bottom (FP) - Y=280 to Y=360, will be clipped but user requested
65+
{120, 200}, // Position 6: Center-Left (Coolant) - moved to center to avoid overlap
66+
{240, 200} // Position 7: Center-Right (Voltage) - moved to center to avoid overlap
7867
};
7968

8069
if (panel.position >= 8) return;

src/SplashScreen.cpp

Lines changed: 187 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,187 @@
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+
}

src/SplashScreen.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#ifndef SPLASHSCREEN_H
2+
#define SPLASHSCREEN_H
3+
4+
#include <TFT_eSPI.h>
5+
6+
// Function declarations
7+
void showAnimatedSplashScreen();
8+
void drawFadeInBackground(int centerX, int centerY);
9+
void drawFadeInTitle(int centerX, int centerY);
10+
void drawFadeInSubtitle(int centerX, int centerY);
11+
void drawFadeInWebsite(int centerX, int centerY);
12+
void drawPulsingTitle(int centerX, int centerY);
13+
void drawLoadingBar(int centerX, int centerY);
14+
void drawFadeOutTransition();
15+
16+
#endif // SPLASHSCREEN_H

0 commit comments

Comments
 (0)