Skip to content

Commit da9e22d

Browse files
author
Ladyada
committed
add splashscreen support
1 parent 39302ff commit da9e22d

1 file changed

Lines changed: 36 additions & 3 deletions

File tree

M4_Eyes/M4_Eyes.ino

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636

3737
#define GLOBAL_VAR
3838
#include "globals.h"
39+
extern Adafruit_ImageReader reader;
3940

4041
// Global eye state that applies to all eyes (not per-eye):
4142
bool eyeInMotion = false;
@@ -117,7 +118,7 @@ static inline uint16_t readBoop(void) {
117118
}
118119

119120
// Crude error handler. Prints message to Serial Monitor, blinks LED.
120-
void fatal(char *message, uint16_t blinkDelay) {
121+
void fatal(const char *message, uint16_t blinkDelay) {
121122
Serial.println(message);
122123
for(bool ledState = HIGH;; ledState = !ledState) {
123124
digitalWrite(LED_BUILTIN, ledState);
@@ -135,7 +136,7 @@ void setup() {
135136
int i = file_setup();
136137

137138
Serial.begin(9600);
138-
// while(!Serial);
139+
//while(!Serial) delay(10);
139140

140141
Serial.printf("Available RAM at start: %d\n", availableRAM());
141142
Serial.printf("Available flash at start: %d\n", availableNVM());
@@ -162,11 +163,43 @@ void setup() {
162163
#endif
163164

164165
uint8_t e;
166+
// Initialize displays
165167
for(e=0; e<NUM_EYES; e++) {
166168
eye[e].display = new Adafruit_ST7789(eye[e].spi, eye[e].cs, eye[e].dc, eye[e].rst);
167169
eye[e].display->init(240, 240);
168-
eye[e].display->setRotation(3);
169170
eye[e].spi->setClockSource(DISPLAY_CLKSRC);
171+
eye[e].display->fillScreen(0x1234);
172+
eye[e].display->setRotation(0);
173+
}
174+
175+
if (reader.drawBMP("/splash.bmp", *(eye[0].display), 0, 0) == IMAGE_SUCCESS) {
176+
Serial.println("Splashing");
177+
#if NUM_EYES > 1
178+
// other eye
179+
reader.drawBMP("/splash.bmp", *(eye[1].display), 0, 0);
180+
#endif
181+
// backlight on for a bit
182+
for (int bl=0; bl<=250; bl+=10) {
183+
#if NUM_EYES > 1
184+
seesaw.analogWrite(SEESAW_BACKLIGHT_PIN, bl);
185+
#endif
186+
analogWrite(BACKLIGHT_PIN, bl);
187+
delay(10);
188+
}
189+
delay(2000);
190+
// backlight back off
191+
for (int bl=250; bl>=0; bl-=10) {
192+
#if NUM_EYES > 1
193+
seesaw.analogWrite(SEESAW_BACKLIGHT_PIN, bl);
194+
#endif
195+
analogWrite(BACKLIGHT_PIN, bl);
196+
delay(10);
197+
}
198+
}
199+
200+
// Initialize DMAs
201+
for(e=0; e<NUM_EYES; e++) {
202+
eye[e].display->setRotation(3);
170203
eye[e].display->fillScreen(0);
171204
eye[e].dma.allocate();
172205
eye[e].dma.setTrigger(eye[e].spi->getDMAC_ID_TX());

0 commit comments

Comments
 (0)