mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2024-12-13 11:44:31 +00:00
93 lines
2.2 KiB
C++
93 lines
2.2 KiB
C++
/*
|
|
* Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc.
|
|
* Copyright (C) 2016 Furrtek
|
|
* Copyright (C) 2022 Arjan Onwezen
|
|
*
|
|
* 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 __APP_SETTINGS_H__
|
|
#define __APP_SETTINGS_H__
|
|
|
|
|
|
#include <cstddef>
|
|
#include <cstdint>
|
|
#include <string>
|
|
|
|
#include "file.hpp"
|
|
#include "string_format.hpp"
|
|
|
|
|
|
namespace std {
|
|
class app_settings {
|
|
|
|
|
|
|
|
public:
|
|
|
|
#define SETTINGS_OK 0 // settings found
|
|
#define SETTINGS_UNABLE_TO_LOAD -1 // settings (file) not found
|
|
#define SETTINGS_UNABLE_TO_SAVE -2 // unable to save settings
|
|
#define SETTINGS_DISABLED -3 // load/save settings disabled in settings
|
|
|
|
|
|
|
|
struct AppSettings {
|
|
uint32_t baseband_bandwidth;
|
|
uint32_t channel_bandwidth;
|
|
uint8_t lna;
|
|
uint8_t modulation;
|
|
uint8_t rx_amp;
|
|
uint32_t rx_frequency;
|
|
uint32_t sampling_rate;
|
|
uint8_t tx_amp;
|
|
uint32_t tx_frequency;
|
|
uint8_t tx_gain;
|
|
uint8_t vga;
|
|
uint32_t step;
|
|
uint8_t am_config_index;
|
|
uint8_t nbfm_config_index;
|
|
uint8_t wfm_config_index;
|
|
uint8_t squelch;
|
|
};
|
|
|
|
int load(std::string application, AppSettings* settings);
|
|
int save(std::string application, AppSettings* settings);
|
|
|
|
|
|
private:
|
|
|
|
#define MAX_FILE_CONTENT_SIZE 1000
|
|
|
|
char file_content[MAX_FILE_CONTENT_SIZE] = {};
|
|
std::string file_path = "";
|
|
std::string folder = "SETTINGS";
|
|
int rc = SETTINGS_OK;
|
|
File settings_file { };
|
|
long long int setting_value {} ;
|
|
|
|
long long int read_long_long(char* file_content, const char* setting_text);
|
|
|
|
|
|
}; // class app_settings
|
|
} // namespace std
|
|
|
|
|
|
|
|
#endif/*__APP_SETTINGS_H__*/
|