Skip to content

Commit

Permalink
Show when SD Card fails to mount
Browse files Browse the repository at this point in the history
  • Loading branch information
cgreening committed Apr 10, 2024
1 parent 73e30d8 commit 92d38e1
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 0 deletions.
8 changes: 8 additions & 0 deletions player/src/Displays/Matrix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,14 @@ void Matrix::drawTuningText() {
dma_display->println("TUNING...");
}

void Matrix::drawSDCardFailed() {
// fill the screen with red
dma_display->fillScreen(0xf800);
dma_display->setCursor(20, 20);
dma_display->setTextColor(0xffff, 0x0000);
dma_display->println("SD Card Failed");
}

void Matrix::drawFPS(int fps) {
// show the frame rate in the top right
dma_display->setCursor(width() - 50, 20);
Expand Down
1 change: 1 addition & 0 deletions player/src/Displays/Matrix.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ class Matrix: public Display {
void drawChannel(int channelIndex);
void drawTuningText();
void drawFPS(int fps);
void drawSDCardFailed();
};
8 changes: 8 additions & 0 deletions player/src/Displays/TFT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,14 @@ void TFT::drawTuningText() {
tft->println("TUNING...");
}

void TFT::drawSDCardFailed() {
tft->fillScreen(TFT_RED);
tft->setCursor(0, 20);
tft->setTextColor(TFT_WHITE);
tft->setTextSize(2);
tft->println("Failed to mount SD Card");
}

void TFT::drawFPS(int fps) {
// show the frame rate in the top right
tft->setCursor(width() - 50, 20);
Expand Down
1 change: 1 addition & 0 deletions player/src/Displays/TFT.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,6 @@ class TFT: public Display {
void drawChannel(int channelIndex);
void drawTuningText();
void drawFPS(int fps);
void drawSDCardFailed();
};
#endif
8 changes: 8 additions & 0 deletions player/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,14 @@ void setup()
#else
SDCard *card = new SDCard(SD_CARD_MISO, SD_CARD_MOSI, SD_CARD_CLK, SD_CARD_CS);
#endif
// check that the SD Card has mounted properly
if (!card->isMounted()) {
Serial.println("Failed to mount SD Card");
display.drawSDCardFailed();
while(true) {
delay(1000);
}
}
channelData = new SDCardChannelData(card, "/");
audioSource = new SDCardAudioSource((SDCardChannelData *) channelData);
videoSource = new SDCardVideoSource((SDCardChannelData *) channelData);
Expand Down

0 comments on commit 92d38e1

Please sign in to comment.