mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2026-08-20 06:29:02 +00:00
c34a6940ca
* First step to EPIRB rx app fix * Added spike filtering on carrier detection for more robustness. * Created dedicated packet builder * First step to fixing UI. * First step to epirb-rx ui rework. * Made static methods static members * Code optim * Code cleanup + first step to new UI * Fixed display * Added BeaconList widget + BeaconDB * Epirb TX app memory optim * Fixed OOM when opening Map Display or Locator editor on EPIRB TX app * First step to tabs + code cleanup to free some space... * Added spectrum analyzer + fixed display * Fixed display refresh issue after leaving spectrum. * More code optim + first step to detail view. * Fixed float coord display. * Fixed protocol names * Fixed location display * Externalized country base to sd card + more code optim * Fixed country display * Fixed path * Added protocol description and resource manager * Added main/aux loc device * Removed specan to save space * First step to adding QR code * Used a custom TextArea component instead of Console * Fixed QR code display for map URL * Added beacon selection management + fixes * First step to map/data qr. * QR tab : added data + detail/map toggle * Removed sqhelch to save space * Removed audio to save space * Removed freq label to save space * Removed packet timestamp to save space * Moved frequency values to resource file * Fixed detection parameters to suite real beacons (slower phase shift time). * Fixed countdown field size * Fixed frequency list. * Fixed detail view on select. * First step to fix settings. * Fixed squelch for a 0-99 range. * Added bch code correction (single bit error). * More code optim, disable country cache, removed inline from location to reduce code size. * Removed inline, code formatting. * Added bch code correction display. * Fixed focus bug, fixed packet size check. Added BCH1/BCH2 correction test cases in BEACONS.TXT file for EPIRB TX application. * Fixed merge * Added countdown setting. * Added selection display to beacon list * Restored squelch control. Added countdown reset. * Code optim on formatSummary * More code optim * Made ResourceManager methods static * Externalized beacon strings to res file *Removed frame parameter from methods * Added test beacons for emergency. Removed old res file. * Fixed resource manager * Fixed resources. Added emergency display. * BCH + res fixes * Fixed beacons * Fixed app color. Fixed HexId and Serial calculation. * Fixed frequency list. Comments. * Code cleanup and comments * Added slideshow mode to EPIRB TX application. Code comments / cleanup. * Fixed frame end after wrong code cleanup * More code optim and comments. Removed touch from beacon list. * Added beacon selection with encoder on detail view. * Added beacon paging in header. Fixed timeout display * Fixed build for PRALINE * Fixed formatting * Potential fix for pull request finding * stop on carriage return * empty string if unknown * zeroing data buffer before use * fix typo * add include * fix case if pair == 0 * fix scpectrum_on to spectrum_on * fix typos * replaced 3 inlined offset blocks with apply_offset calls * set_beacon consolidation
101 lines
3.3 KiB
C++
101 lines
3.3 KiB
C++
/*
|
|
* Copyright (C) 2026 Frederic BORRY - ADRASEC 31
|
|
*
|
|
* 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 __RESOUCES_H__
|
|
#define __RESOUCES_H__
|
|
|
|
#include <cstring>
|
|
#include <vector>
|
|
#include "file_reader.hpp"
|
|
#include "file_path.hpp"
|
|
|
|
namespace ui::external_app::epirb_rx {
|
|
|
|
#define UNKNOWN_LABEL "Unk."
|
|
|
|
extern std::vector<std::string> beacon_res;
|
|
extern std::vector<std::string> freq;
|
|
|
|
/**
|
|
* This class is used to load string resources from SD card.
|
|
* This is done mostly to reduce application size and keep it under the 32kb limit.
|
|
* It's also used to load frequency values, allowing users to customize frequency list by editing FREQ.TXT file on SD card.
|
|
*/
|
|
class ResourceManager {
|
|
public:
|
|
// Singleton getter
|
|
static ResourceManager* getInstance();
|
|
|
|
// Singleton instance
|
|
static ResourceManager* current;
|
|
// Used from standalone app, to prevent memleak
|
|
static void destroy();
|
|
|
|
// Get a string from BEACON.RES file
|
|
static const char* get_beacon_resource(uint8_t line) {
|
|
ResourceManager* rm = getInstance();
|
|
if (rm->beacon_res.empty()) {
|
|
load_file((epirb_dir / u"RES/BEACON.RES"), rm->beacon_res);
|
|
}
|
|
if (line < rm->beacon_res.size()) {
|
|
return rm->beacon_res[line].c_str();
|
|
}
|
|
return UNKNOWN_LABEL;
|
|
}
|
|
|
|
// Get frequency values
|
|
static const std::vector<std::string>& get_frequencies() {
|
|
ResourceManager* rm = getInstance();
|
|
if (rm->freq.empty()) {
|
|
load_file((epirb_dir / u"FREQ.TXT"), rm->freq);
|
|
}
|
|
return rm->freq;
|
|
}
|
|
|
|
private:
|
|
// BEACON.RES content
|
|
std::vector<std::string> beacon_res{};
|
|
// FREQ.TXT content
|
|
std::vector<std::string> freq{};
|
|
|
|
static void load_file(const std::filesystem::path& path, std::vector<std::string>& vect) {
|
|
FIL file;
|
|
if (f_open(&file, path.tchar(), FA_READ) == FR_OK) {
|
|
TCHAR line_buffer[32];
|
|
// Read the file line by line
|
|
while (f_gets(line_buffer, sizeof(line_buffer) / sizeof(TCHAR), &file)) {
|
|
std::string s;
|
|
for (int i = 0; line_buffer[i] != '\0' && line_buffer[i] != '\n' && line_buffer[i] != '\r'; i++) {
|
|
// Convert each TCHAR in char
|
|
s += (char)line_buffer[i];
|
|
}
|
|
vect.push_back(std::move(s));
|
|
}
|
|
f_close(&file);
|
|
}
|
|
if (vect.empty()) vect.push_back(UNKNOWN_LABEL);
|
|
}
|
|
};
|
|
|
|
} // namespace ui::external_app::epirb_rx
|
|
|
|
#endif // __RESOUCES_H__
|