mirror of
https://github.com/eried/portapack-mayhem.git
synced 2024-10-01 01:26:06 -04:00
Add SD card status view to receiver UI.
This commit is contained in:
parent
c70d95dcbe
commit
0c36a74351
@ -162,6 +162,7 @@ CPPSRC = main.cpp \
|
||||
ui_setup.cpp \
|
||||
ui_debug.cpp \
|
||||
ui_baseband_stats_view.cpp \
|
||||
ui_sd_card_status_view.cpp \
|
||||
ui_console.cpp \
|
||||
ui_receiver.cpp \
|
||||
ui_spectrum.cpp \
|
||||
|
@ -37,7 +37,9 @@ namespace ui {
|
||||
SystemStatusView::SystemStatusView() {
|
||||
add_children({ {
|
||||
&portapack,
|
||||
&sd_card_status_view,
|
||||
} });
|
||||
sd_card_status_view.set_parent_rect({ 28 * 8, 0 * 16, 2 * 8, 1 * 16 });
|
||||
}
|
||||
|
||||
/* Navigation ************************************************************/
|
||||
|
@ -30,6 +30,7 @@
|
||||
#include "ui_rssi.hpp"
|
||||
#include "ui_channel.hpp"
|
||||
#include "ui_audio.hpp"
|
||||
#include "ui_sd_card_status_view.hpp"
|
||||
|
||||
#include <vector>
|
||||
|
||||
@ -44,6 +45,8 @@ private:
|
||||
{ 0, 0, 9 * 8, 1 * 16 },
|
||||
"PortaPack",
|
||||
};
|
||||
|
||||
SDCardStatusView sd_card_status_view;
|
||||
};
|
||||
|
||||
class NavigationView : public View {
|
||||
|
85
firmware/application/ui_sd_card_status_view.cpp
Normal file
85
firmware/application/ui_sd_card_status_view.cpp
Normal file
@ -0,0 +1,85 @@
|
||||
/*
|
||||
* Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc.
|
||||
*
|
||||
* This file is part of PortaPack.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 51 Franklin Street,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "ui_sd_card_status_view.hpp"
|
||||
|
||||
#include <string>
|
||||
#include <algorithm>
|
||||
|
||||
namespace ui {
|
||||
|
||||
/* SDCardStatusView *****************************************************/
|
||||
|
||||
SDCardStatusView::SDCardStatusView() {
|
||||
add_children({ {
|
||||
&text_status,
|
||||
} });
|
||||
|
||||
text_status.set("XX");
|
||||
}
|
||||
|
||||
void SDCardStatusView::on_show() {
|
||||
sd_card_status_signal_token = sd_card::status_signal += [this](const sd_card::Status status) {
|
||||
this->on_status(status);
|
||||
};
|
||||
}
|
||||
|
||||
void SDCardStatusView::on_hide() {
|
||||
sd_card::status_signal -= sd_card_status_signal_token;
|
||||
}
|
||||
|
||||
void SDCardStatusView::on_status(const sd_card::Status status) {
|
||||
std::string msg("??");
|
||||
|
||||
switch(status) {
|
||||
case sd_card::Status::IOError:
|
||||
msg = "IO";
|
||||
break;
|
||||
|
||||
case sd_card::Status::MountError:
|
||||
msg = "MT";
|
||||
break;
|
||||
|
||||
case sd_card::Status::ConnectError:
|
||||
msg = "CN";
|
||||
break;
|
||||
|
||||
case sd_card::Status::NotPresent:
|
||||
msg = "XX";
|
||||
break;
|
||||
|
||||
case sd_card::Status::Present:
|
||||
msg = "OO";
|
||||
break;
|
||||
|
||||
case sd_card::Status::Mounted:
|
||||
msg = "OK";
|
||||
break;
|
||||
|
||||
default:
|
||||
msg = "--";
|
||||
break;
|
||||
}
|
||||
|
||||
text_status.set(msg);
|
||||
}
|
||||
|
||||
} /* namespace ui */
|
50
firmware/application/ui_sd_card_status_view.hpp
Normal file
50
firmware/application/ui_sd_card_status_view.hpp
Normal file
@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc.
|
||||
*
|
||||
* This file is part of PortaPack.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 51 Franklin Street,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef __UI_SD_CARD_STATUS_VIEW_H__
|
||||
#define __UI_SD_CARD_STATUS_VIEW_H__
|
||||
|
||||
#include "ui_widget.hpp"
|
||||
#include "sd_card.hpp"
|
||||
|
||||
namespace ui {
|
||||
|
||||
class SDCardStatusView : public View {
|
||||
public:
|
||||
SDCardStatusView();
|
||||
|
||||
void on_show() override;
|
||||
void on_hide() override;
|
||||
|
||||
private:
|
||||
Text text_status {
|
||||
{ 0 * 8, 0, 2 * 8, 1 * 16 },
|
||||
"",
|
||||
};
|
||||
|
||||
SignalToken sd_card_status_signal_token;
|
||||
|
||||
void on_status(const sd_card::Status status);
|
||||
};
|
||||
|
||||
} /* namespace ui */
|
||||
|
||||
#endif/*__UI_SD_CARD_STATUS_VIEW_H__*/
|
Loading…
Reference in New Issue
Block a user