From 5928086fd9e2687de42ffcbd48eb5ab9dccf9638 Mon Sep 17 00:00:00 2001 From: Jared Boone Date: Sun, 29 Nov 2015 15:37:24 -0800 Subject: [PATCH] Simplify SD card mount status code. --- firmware/application/main.cpp | 20 ++++++++++---------- firmware/common/message.hpp | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/firmware/application/main.cpp b/firmware/application/main.cpp index ff7e92e97..ce9a7a2fd 100755 --- a/firmware/application/main.cpp +++ b/firmware/application/main.cpp @@ -128,31 +128,31 @@ 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); } + + 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) { if( !w->hidden() ) { // To achieve reverse depth ordering (last object drawn is diff --git a/firmware/common/message.hpp b/firmware/common/message.hpp index fccb2cdc8..393d3b3d5 100644 --- a/firmware/common/message.hpp +++ b/firmware/common/message.hpp @@ -250,7 +250,7 @@ public: { } - const bool is_mounted; + bool is_mounted; }; class MessageHandlerMap {