mirror of
https://github.com/eried/portapack-mayhem.git
synced 2024-12-23 14:29:23 -05:00
Move weather to ext app
This commit is contained in:
parent
bed011473d
commit
8a84aac2f5
@ -308,7 +308,7 @@ set(CPPSRC
|
||||
apps/ui_touch_calibration.cpp
|
||||
apps/ui_touchtunes.cpp
|
||||
apps/ui_view_wav.cpp
|
||||
apps/ui_weatherstation.cpp
|
||||
# apps/ui_weatherstation.cpp
|
||||
apps/ui_whipcalc.cpp
|
||||
protocols/aprs.cpp
|
||||
protocols/ax25.cpp
|
||||
|
5
firmware/application/external/external.cmake
vendored
5
firmware/application/external/external.cmake
vendored
@ -20,6 +20,10 @@ set(EXTCPPSRC
|
||||
external/blespam/main.cpp
|
||||
external/blespam/ui_blespam.cpp
|
||||
|
||||
#weatherstation
|
||||
external/weatherstation/main.cpp
|
||||
external/weatherstation/ui_weatherstation.cpp
|
||||
|
||||
)
|
||||
|
||||
set(EXTAPPLIST
|
||||
@ -28,4 +32,5 @@ set(EXTAPPLIST
|
||||
calculator
|
||||
font_viewer
|
||||
blespam
|
||||
weatherstation
|
||||
)
|
||||
|
9
firmware/application/external/external.ld
vendored
9
firmware/application/external/external.ld
vendored
@ -22,6 +22,7 @@ MEMORY
|
||||
ram_external_app_calculator (rwx) : org = 0xEEEB0000, len = 32k
|
||||
ram_external_app_font_viewer(rwx) : org = 0xEEEC0000, len = 32k
|
||||
ram_external_app_blespam(rwx) : org = 0xEEED0000, len = 32k
|
||||
ram_external_app_weatherstation(rwx) : org = 0xEEEE0000, len = 36k
|
||||
}
|
||||
|
||||
SECTIONS
|
||||
@ -56,4 +57,12 @@ SECTIONS
|
||||
KEEP(*(.external_app.app_blespam.application_information));
|
||||
*(*ui*external_app*blespam*);
|
||||
} > ram_external_app_blespam
|
||||
|
||||
.external_app_weatherstation : ALIGN(4) SUBALIGN(4)
|
||||
{
|
||||
KEEP(*(.external_app.app_weatherstation.application_information));
|
||||
*(*ui*external_app*weatherstation*);
|
||||
} > ram_external_app_weatherstation
|
||||
|
||||
|
||||
}
|
||||
|
82
firmware/application/external/weatherstation/main.cpp
vendored
Normal file
82
firmware/application/external/weatherstation/main.cpp
vendored
Normal file
@ -0,0 +1,82 @@
|
||||
/*
|
||||
* Copyright (C) 2023 Bernd Herzog
|
||||
*
|
||||
* 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.hpp"
|
||||
#include "ui_weatherstation.hpp"
|
||||
#include "ui_navigation.hpp"
|
||||
#include "external_app.hpp"
|
||||
|
||||
namespace ui::external_app::weatherstation {
|
||||
void initialize_app(ui::NavigationView& nav) {
|
||||
nav.push<WeatherView>();
|
||||
}
|
||||
} // namespace ui::external_app::weatherstation
|
||||
|
||||
extern "C" {
|
||||
|
||||
__attribute__((section(".external_app.app_weatherstation.application_information"), used)) application_information_t _application_information_weatherstation = {
|
||||
/*.memory_location = */ (uint8_t*)0x00000000,
|
||||
/*.externalAppEntry = */ ui::external_app::weatherstation::initialize_app,
|
||||
/*.header_version = */ CURRENT_HEADER_VERSION,
|
||||
/*.app_version = */ VERSION_MD5,
|
||||
|
||||
/*.app_name = */ "Weather",
|
||||
/*.bitmap_data = */ {
|
||||
0xC0,
|
||||
0x00,
|
||||
0x20,
|
||||
0x01,
|
||||
0x10,
|
||||
0x02,
|
||||
0x10,
|
||||
0x3A,
|
||||
0x10,
|
||||
0x02,
|
||||
0x10,
|
||||
0x1A,
|
||||
0x10,
|
||||
0x02,
|
||||
0xD0,
|
||||
0x3A,
|
||||
0xD0,
|
||||
0x02,
|
||||
0xD0,
|
||||
0x1A,
|
||||
0xD0,
|
||||
0x02,
|
||||
0xE8,
|
||||
0x05,
|
||||
0xE8,
|
||||
0x05,
|
||||
0xC8,
|
||||
0x04,
|
||||
0x10,
|
||||
0x02,
|
||||
0xE0,
|
||||
0x01,
|
||||
},
|
||||
/*.icon_color = */ ui::Color::green().v,
|
||||
/*.menu_location = */ app_location_t::RX,
|
||||
|
||||
/*.m4_app_tag = portapack::spi_flash::image_tag_afsk_rx */ {'P', 'W', 'T', 'H'},
|
||||
/*.m4_app_offset = */ 0x00000000, // will be filled at compile time
|
||||
};
|
||||
}
|
@ -30,7 +30,7 @@
|
||||
using namespace portapack;
|
||||
using namespace ui;
|
||||
|
||||
namespace ui {
|
||||
namespace ui::external_app::weatherstation {
|
||||
|
||||
void WeatherRecentEntryDetailView::update_data() {
|
||||
// set text elements
|
||||
@ -40,7 +40,7 @@ void WeatherRecentEntryDetailView::update_data() {
|
||||
else
|
||||
text_id.set("-");
|
||||
if (entry_.temp != WS_NO_TEMPERATURE)
|
||||
text_temp.set(weather_units_fahr ? to_string_decimal((entry_.temp * 9 / 5) + 32, 1) + STR_DEGREES_F : to_string_decimal(entry_.temp, 2) + STR_DEGREES_C);
|
||||
text_temp.set(ui::external_app::weatherstation::WeatherView::weather_units_fahr ? to_string_decimal((entry_.temp * 9 / 5) + 32, 1) + STR_DEGREES_F : to_string_decimal(entry_.temp, 2) + STR_DEGREES_C);
|
||||
else
|
||||
text_temp.set("-");
|
||||
if (entry_.humidity != WS_NO_HUMIDITY)
|
||||
@ -110,7 +110,7 @@ WeatherView::WeatherView(NavigationView& nav)
|
||||
};
|
||||
options_temperature.set_selected_index(weather_units_fahr, false);
|
||||
|
||||
const Rect content_rect{0, header_height, screen_width, screen_height - header_height};
|
||||
const Rect content_rect{0, 3 * 16, screen_width, screen_height - (3 * 16)};
|
||||
recent_entries_view.set_parent_rect(content_rect);
|
||||
recent_entries_view.on_select = [this](const WeatherRecentEntry& entry) {
|
||||
nav_.push<WeatherRecentEntryDetailView>(entry);
|
||||
@ -203,8 +203,11 @@ std::string WeatherView::pad_string_with_spaces(int snakes) {
|
||||
return paddedStr;
|
||||
}
|
||||
|
||||
} // namespace ui::external_app::weatherstation
|
||||
namespace ui {
|
||||
|
||||
template <>
|
||||
void RecentEntriesTable<ui::WeatherRecentEntries>::draw(
|
||||
void RecentEntriesTable<ui::external_app::weatherstation::WeatherRecentEntries>::draw(
|
||||
const Entry& entry,
|
||||
const Rect& target_rect,
|
||||
Painter& painter,
|
||||
@ -212,22 +215,22 @@ void RecentEntriesTable<ui::WeatherRecentEntries>::draw(
|
||||
std::string line{};
|
||||
line.reserve(30);
|
||||
|
||||
line = WeatherView::getWeatherSensorTypeName((FPROTO_WEATHER_SENSOR)entry.sensorType);
|
||||
line = ui::external_app::weatherstation::WeatherView::getWeatherSensorTypeName((FPROTO_WEATHER_SENSOR)entry.sensorType);
|
||||
if (line.length() < 10) {
|
||||
line += WeatherView::pad_string_with_spaces(10 - line.length());
|
||||
line += ui::external_app::weatherstation::WeatherView::pad_string_with_spaces(10 - line.length());
|
||||
} else {
|
||||
line = truncate(line, 10);
|
||||
}
|
||||
|
||||
std::string temp = (weather_units_fahr ? to_string_decimal((entry.temp * 9 / 5) + 32, 1) : to_string_decimal(entry.temp, 1));
|
||||
std::string temp = (ui::external_app::weatherstation::WeatherView::weather_units_fahr ? to_string_decimal((entry.temp * 9 / 5) + 32, 1) : to_string_decimal(entry.temp, 1));
|
||||
std::string humStr = (entry.humidity != WS_NO_HUMIDITY) ? to_string_dec_uint(entry.humidity) + "%" : "-";
|
||||
std::string chStr = (entry.channel != WS_NO_CHANNEL) ? to_string_dec_uint(entry.channel) : "-";
|
||||
std::string ageStr = to_string_dec_uint(entry.age);
|
||||
|
||||
line += WeatherView::pad_string_with_spaces(6 - temp.length()) + temp;
|
||||
line += WeatherView::pad_string_with_spaces(5 - humStr.length()) + humStr;
|
||||
line += WeatherView::pad_string_with_spaces(4 - chStr.length()) + chStr;
|
||||
line += WeatherView::pad_string_with_spaces(4 - ageStr.length()) + ageStr;
|
||||
line += ui::external_app::weatherstation::WeatherView::pad_string_with_spaces(6 - temp.length()) + temp;
|
||||
line += ui::external_app::weatherstation::WeatherView::pad_string_with_spaces(5 - humStr.length()) + humStr;
|
||||
line += ui::external_app::weatherstation::WeatherView::pad_string_with_spaces(4 - chStr.length()) + chStr;
|
||||
line += ui::external_app::weatherstation::WeatherView::pad_string_with_spaces(4 - ageStr.length()) + ageStr;
|
||||
|
||||
line.resize(target_rect.width() / 8, ' ');
|
||||
painter.draw_string(target_rect.location(), style, line);
|
@ -35,9 +35,7 @@
|
||||
#include "../baseband/fprotos/weathertypes.hpp"
|
||||
using namespace ui;
|
||||
|
||||
namespace ui {
|
||||
|
||||
static bool weather_units_fahr{false};
|
||||
namespace ui::external_app::weatherstation {
|
||||
|
||||
struct WeatherRecentEntry {
|
||||
using Key = uint64_t;
|
||||
@ -92,6 +90,7 @@ class WeatherView : public View {
|
||||
std::string title() const override { return "Weather"; };
|
||||
static const char* getWeatherSensorTypeName(FPROTO_WEATHER_SENSOR type);
|
||||
static std::string pad_string_with_spaces(int snakes);
|
||||
inline static bool weather_units_fahr{false};
|
||||
|
||||
private:
|
||||
void on_tick_second();
|
||||
@ -136,8 +135,6 @@ class WeatherView : public View {
|
||||
{0, 16, 7 * 8, 32},
|
||||
"Clear"};
|
||||
|
||||
static constexpr auto header_height = 3 * 16;
|
||||
|
||||
const RecentEntriesColumns columns{{
|
||||
{"Type", 10},
|
||||
{"Temp", 5},
|
||||
@ -188,6 +185,6 @@ class WeatherRecentEntryDetailView : public View {
|
||||
"Done"};
|
||||
};
|
||||
|
||||
} // namespace ui
|
||||
} // namespace ui::external_app::weatherstation
|
||||
|
||||
#endif /*__UI_WEATHER_H__*/
|
@ -79,7 +79,7 @@
|
||||
#include "ui_tone_search.hpp"
|
||||
#include "ui_touchtunes.hpp"
|
||||
#include "ui_view_wav.hpp"
|
||||
#include "ui_weatherstation.hpp"
|
||||
// #include "ui_weatherstation.hpp"
|
||||
#include "ui_subghzd.hpp"
|
||||
#include "ui_whipcalc.hpp"
|
||||
#include "ui_external_items_menu_loader.hpp"
|
||||
@ -567,7 +567,7 @@ ReceiversMenuView::ReceiversMenuView(NavigationView& nav) {
|
||||
{"Recon", Color::green(), &bitmap_icon_scanner, [&nav]() { nav.push<ReconView>(); }},
|
||||
{"Search", Color::yellow(), &bitmap_icon_search, [&nav]() { nav.push<SearchView>(); }},
|
||||
{"TPMS Cars", Color::green(), &bitmap_icon_tpms, [&nav]() { nav.push<TPMSAppView>(); }},
|
||||
{"Weather", Color::green(), &bitmap_icon_thermometer, [&nav]() { nav.push<WeatherView>(); }},
|
||||
//{"Weather", Color::green(), &bitmap_icon_thermometer, [&nav]() { nav.push<WeatherView>(); }}, //moved to ext
|
||||
{"SubGhzD", Color::yellow(), &bitmap_icon_remote, [&nav]() { nav.push<SubGhzDView>(); }},
|
||||
// {"FSK RX", Color::yellow(), &bitmap_icon_remote, [&nav]() { nav.push<FskxRxMainView>(); }},
|
||||
// {"DMR", Color::dark_grey(), &bitmap_icon_dmr, [&nav](){ nav.push<NotImplementedView>(); }},
|
||||
|
Loading…
Reference in New Issue
Block a user