mirror of
https://github.com/eried/portapack-mayhem.git
synced 2024-10-01 01:26:06 -04:00
indentation & added load & save persistent settings to sdcard
This commit is contained in:
parent
835bc49999
commit
17250304e0
@ -34,6 +34,12 @@
|
||||
#include <algorithm>
|
||||
#include <utility>
|
||||
|
||||
#include <string>
|
||||
#include <fstream>
|
||||
#include "file.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace portapack {
|
||||
namespace persistent_memory {
|
||||
|
||||
@ -406,7 +412,7 @@ static_assert(sizeof(data_t) <= sizeof(backup_ram_t) - sizeof(uint32_t));
|
||||
static backup_ram_t* const backup_ram = reinterpret_cast<backup_ram_t*>(memory::map::backup_ram.base());
|
||||
|
||||
static backup_ram_t cached_backup_ram;
|
||||
static data_t* const data = reinterpret_cast<data_t*>(&cached_backup_ram);
|
||||
static data_t* data = reinterpret_cast<data_t*>(&cached_backup_ram);
|
||||
|
||||
namespace cache {
|
||||
|
||||
@ -423,6 +429,7 @@ void defaults() {
|
||||
set_recon_update_ranges_when_recon( true );
|
||||
set_recon_load_hamradios( true );
|
||||
set_recon_match_mode( 0 );
|
||||
|
||||
}
|
||||
|
||||
void init() {
|
||||
@ -774,5 +781,32 @@ void set_config_updown_converter(const bool v){
|
||||
void set_config_converter_freq(const int64_t v ){
|
||||
data-> converter_frequency_offset = v ;
|
||||
}
|
||||
|
||||
// sd persisting settings
|
||||
int save_persistent_settings_to_file( std::string filename )
|
||||
{
|
||||
delete_file( filename );
|
||||
File outfile ;
|
||||
auto result = outfile.create(filename);
|
||||
if( result.is_valid() )
|
||||
{
|
||||
return false ;
|
||||
}
|
||||
outfile.write( reinterpret_cast<char*>(&cached_backup_ram), sizeof(backup_ram_t) );
|
||||
return true ;
|
||||
}
|
||||
|
||||
int load_persistent_settings_from_file( std::string filename )
|
||||
{
|
||||
File infile ;
|
||||
auto result = infile.open(filename);
|
||||
if( !result.is_valid() )
|
||||
{
|
||||
infile.read( reinterpret_cast<char*>(&cached_backup_ram), sizeof(backup_ram_t) );
|
||||
return true ;
|
||||
}
|
||||
return false ;
|
||||
}
|
||||
|
||||
} /* namespace persistent_memory */
|
||||
} /* namespace portapack */
|
||||
|
@ -36,6 +36,7 @@ using namespace modems;
|
||||
using namespace serializer;
|
||||
|
||||
namespace portapack {
|
||||
|
||||
namespace persistent_memory {
|
||||
|
||||
enum backlight_timeout_t {
|
||||
@ -216,7 +217,12 @@ void set_clkout_freq(uint32_t freq);
|
||||
void set_recon_load_hamradios(const bool v );
|
||||
void set_recon_match_mode( const bool v );
|
||||
|
||||
// sd persisting settings
|
||||
int save_persistent_settings_to_file( std::string filename );
|
||||
int load_persistent_settings_from_file( std::string filename );
|
||||
|
||||
} /* namespace persistent_memory */
|
||||
|
||||
} /* namespace portapack */
|
||||
|
||||
#endif/*__PORTAPACK_PERSISTENT_MEMORY_H__*/
|
||||
|
Loading…
Reference in New Issue
Block a user