Simplify SD card mount status code.

This commit is contained in:
Jared Boone 2015-11-29 15:37:24 -08:00
parent 435824e9b5
commit 5928086fd9
2 changed files with 11 additions and 11 deletions

View File

@ -128,29 +128,29 @@ private:
}
}
void handle_rtc_tick() {
void update_sd_card_status() {
const auto sd_card_present_now = sdc_lld_is_card_inserted(&SDCD1);
if( sd_card_present_now != sd_card_present ) {
sd_card_present = sd_card_present_now;
SDCardStatusMessage message { false };
if( sd_card_present ) {
if( sdcConnect(&SDCD1) == CH_SUCCESS ) {
if( sd_card::filesystem::mount() == FR_OK ) {
SDCardStatusMessage message { true };
context.message_map().send(&message);
} else {
// TODO: Error, modal warning?
message.is_mounted = true;
}
} else {
// TODO: Error, modal warning?
}
} else {
sdcDisconnect(&SDCD1);
}
SDCardStatusMessage message { false };
context.message_map().send(&message);
}
}
void handle_rtc_tick() {
update_sd_card_status();
}
static ui::Widget* touch_widget(ui::Widget* const w, ui::TouchEvent event) {

View File

@ -250,7 +250,7 @@ public:
{
}
const bool is_mounted;
bool is_mounted;
};
class MessageHandlerMap {