mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2024-12-14 04:04:34 +00:00
Broaden SD card status detail in message.
This commit is contained in:
parent
5928086fd9
commit
42104d217a
@ -133,13 +133,17 @@ private:
|
|||||||
if( sd_card_present_now != sd_card_present ) {
|
if( sd_card_present_now != sd_card_present ) {
|
||||||
sd_card_present = sd_card_present_now;
|
sd_card_present = sd_card_present_now;
|
||||||
|
|
||||||
SDCardStatusMessage message { false };
|
SDCardStatusMessage message { sd_card_present ? SDCardStatusMessage::State::Present : SDCardStatusMessage::State::NotPresent };
|
||||||
|
|
||||||
if( sd_card_present ) {
|
if( sd_card_present ) {
|
||||||
if( sdcConnect(&SDCD1) == CH_SUCCESS ) {
|
if( sdcConnect(&SDCD1) == CH_SUCCESS ) {
|
||||||
if( sd_card::filesystem::mount() == FR_OK ) {
|
if( sd_card::filesystem::mount() == FR_OK ) {
|
||||||
message.is_mounted = true;
|
message.state = SDCardStatusMessage::State::Mounted;
|
||||||
|
} else {
|
||||||
|
message.state = SDCardStatusMessage::State::MountError;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
message.state = SDCardStatusMessage::State::ConnectError;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
sdcDisconnect(&SDCD1);
|
sdcDisconnect(&SDCD1);
|
||||||
|
@ -514,7 +514,7 @@ void ReceiverView::on_show() {
|
|||||||
message_map.register_handler(Message::ID::SDCardStatus,
|
message_map.register_handler(Message::ID::SDCardStatus,
|
||||||
[this](Message* const p) {
|
[this](Message* const p) {
|
||||||
const auto message = static_cast<const SDCardStatusMessage*>(p);
|
const auto message = static_cast<const SDCardStatusMessage*>(p);
|
||||||
this->on_sd_card_mounted(message->is_mounted);
|
this->on_sd_card_status(*message);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -585,8 +585,8 @@ void ReceiverView::on_packet_tpms(const TPMSPacketMessage& message) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ReceiverView::on_sd_card_mounted(const bool is_mounted) {
|
void ReceiverView::on_sd_card_status(const SDCardStatusMessage& message) {
|
||||||
if( is_mounted ) {
|
if( message.state == SDCardStatusMessage::State::Mounted ) {
|
||||||
const auto open_result = f_open(&fil_tpms, "tpms.txt", FA_WRITE | FA_OPEN_ALWAYS);
|
const auto open_result = f_open(&fil_tpms, "tpms.txt", FA_WRITE | FA_OPEN_ALWAYS);
|
||||||
if( open_result == FR_OK ) {
|
if( open_result == FR_OK ) {
|
||||||
const auto fil_size = f_size(&fil_tpms);
|
const auto fil_size = f_size(&fil_tpms);
|
||||||
|
@ -475,7 +475,7 @@ private:
|
|||||||
|
|
||||||
void on_packet_ais(const AISPacketMessage& message);
|
void on_packet_ais(const AISPacketMessage& message);
|
||||||
void on_packet_tpms(const TPMSPacketMessage& message);
|
void on_packet_tpms(const TPMSPacketMessage& message);
|
||||||
void on_sd_card_mounted(const bool is_mounted);
|
void on_sd_card_status(const SDCardStatusMessage& message);
|
||||||
};
|
};
|
||||||
|
|
||||||
} /* namespace ui */
|
} /* namespace ui */
|
||||||
|
@ -243,14 +243,23 @@ public:
|
|||||||
|
|
||||||
class SDCardStatusMessage : public Message {
|
class SDCardStatusMessage : public Message {
|
||||||
public:
|
public:
|
||||||
|
enum class State : int32_t {
|
||||||
|
IOError = -3,
|
||||||
|
MountError = -2,
|
||||||
|
ConnectError = -1,
|
||||||
|
NotPresent = 0,
|
||||||
|
Present = 1,
|
||||||
|
Mounted = 2,
|
||||||
|
};
|
||||||
|
|
||||||
constexpr SDCardStatusMessage(
|
constexpr SDCardStatusMessage(
|
||||||
bool is_mounted
|
State state
|
||||||
) : Message { ID::SDCardStatus },
|
) : Message { ID::SDCardStatus },
|
||||||
is_mounted { is_mounted }
|
state { state }
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
bool is_mounted;
|
State state;
|
||||||
};
|
};
|
||||||
|
|
||||||
class MessageHandlerMap {
|
class MessageHandlerMap {
|
||||||
|
Loading…
Reference in New Issue
Block a user