mirror of
https://github.com/eried/portapack-mayhem.git
synced 2025-06-09 23:53:04 -04:00
SD card detection and filesystem mounting.
This commit is contained in:
parent
9f6c495fef
commit
987ea3555d
4 changed files with 84 additions and 9 deletions
|
@ -52,6 +52,8 @@
|
|||
#include "lpc43xx_cpp.hpp"
|
||||
using namespace lpc43xx;
|
||||
|
||||
#include "sd_card.hpp"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
class EventDispatcher {
|
||||
|
@ -87,6 +89,7 @@ private:
|
|||
ui::Context& context;
|
||||
uint32_t encoder_last = 0;
|
||||
bool is_running = true;
|
||||
bool sd_card_present = false;
|
||||
|
||||
eventmask_t wait() {
|
||||
return chEvtWaitAny(ALL_EVENTS);
|
||||
|
@ -105,10 +108,6 @@ private:
|
|||
handle_lcd_frame_sync();
|
||||
}
|
||||
|
||||
if( events & EVT_MASK_SD_CARD_PRESENT ) {
|
||||
handle_sd_card_detect();
|
||||
}
|
||||
|
||||
if( events & EVT_MASK_SWITCHES ) {
|
||||
handle_switches();
|
||||
}
|
||||
|
@ -130,7 +129,28 @@ private:
|
|||
}
|
||||
|
||||
void handle_rtc_tick() {
|
||||
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;
|
||||
|
||||
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?
|
||||
}
|
||||
} else {
|
||||
// TODO: Error, modal warning?
|
||||
}
|
||||
} else {
|
||||
sdcDisconnect(&SDCD1);
|
||||
|
||||
SDCardStatusMessage message { false };
|
||||
context.message_map().send(&message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static ui::Widget* touch_widget(ui::Widget* const w, ui::TouchEvent event) {
|
||||
|
@ -181,10 +201,6 @@ private:
|
|||
painter.paint_widget_tree(top_widget);
|
||||
}
|
||||
|
||||
void handle_sd_card_detect() {
|
||||
|
||||
}
|
||||
|
||||
void handle_switches() {
|
||||
const auto switches_state = get_switches_state();
|
||||
for(size_t i=0; i<switches_state.size(); i++) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue