mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2025-08-13 21:11:02 +00:00
Daylight Savings Time support (#1793)
* Daylight Savings Time support * Cleanup * Clean-up * Revert ADSB change * Clean-up * Corrected date in comment, ironically
This commit is contained in:
@@ -33,6 +33,7 @@
|
||||
#include "ui_styles.hpp"
|
||||
#include "ui_painter.hpp"
|
||||
#include "utility.hpp"
|
||||
#include "rtc_time.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <string>
|
||||
@@ -235,6 +236,9 @@ struct data_t {
|
||||
// recovery mode magic value storage
|
||||
uint32_t config_mode_storage;
|
||||
|
||||
// Daylight savings time
|
||||
dst_config_t dst_config;
|
||||
|
||||
constexpr data_t()
|
||||
: structure_version(data_structure_version_enum::VERSION_CURRENT),
|
||||
target_frequency(target_frequency_reset_value),
|
||||
@@ -287,7 +291,8 @@ struct data_t {
|
||||
headphone_volume_cb(-600),
|
||||
misc_config(),
|
||||
ui_config2(),
|
||||
config_mode_storage(CONFIG_MODE_NORMAL_VALUE) {
|
||||
config_mode_storage(CONFIG_MODE_NORMAL_VALUE),
|
||||
dst_config() {
|
||||
}
|
||||
};
|
||||
|
||||
@@ -972,6 +977,22 @@ bool config_disable_config_mode_direct() {
|
||||
return ((misc_config_u32 & MC_CONFIG_DISABLE_CONFIG_MODE) != 0);
|
||||
}
|
||||
|
||||
// Daylight savings time
|
||||
bool dst_enabled() {
|
||||
return data->dst_config.b.dst_enabled;
|
||||
}
|
||||
void set_dst_enabled(bool v) {
|
||||
data->dst_config.b.dst_enabled = v;
|
||||
rtc_time::dst_init();
|
||||
}
|
||||
dst_config_t config_dst() {
|
||||
return data->dst_config;
|
||||
}
|
||||
void set_config_dst(dst_config_t v) {
|
||||
data->dst_config = v;
|
||||
rtc_time::dst_init();
|
||||
}
|
||||
|
||||
// PMem to sdcard settings
|
||||
|
||||
bool should_use_sdcard_for_pmem() {
|
||||
@@ -1073,6 +1094,7 @@ bool debug_dump() {
|
||||
// pmem_dump_file.write_line("UNUSED_8: " + to_string_dec_uint(data->UNUSED_8));
|
||||
pmem_dump_file.write_line("headphone_volume_cb: " + to_string_dec_int(data->headphone_volume_cb));
|
||||
pmem_dump_file.write_line("config_mode_storage: 0x" + to_string_hex(data->config_mode_storage, 8));
|
||||
pmem_dump_file.write_line("dst_config: 0x" + to_string_hex((uint32_t)data->dst_config.v, 8));
|
||||
|
||||
// ui_config bits
|
||||
const auto backlight_timer = portapack::persistent_memory::config_backlight_timer();
|
||||
|
@@ -116,6 +116,21 @@ enum encoder_dial_sensitivity {
|
||||
NUM_DIAL_SENSITIVITY
|
||||
};
|
||||
|
||||
typedef union {
|
||||
uint32_t v;
|
||||
struct {
|
||||
uint8_t start_which : 4;
|
||||
uint8_t start_weekday : 4;
|
||||
uint8_t start_month : 4;
|
||||
uint8_t end_which : 4;
|
||||
uint8_t end_weekday : 4;
|
||||
uint8_t end_month : 4;
|
||||
uint8_t UNUSED : 7;
|
||||
uint8_t dst_enabled : 1;
|
||||
} b;
|
||||
} dst_config_t;
|
||||
static_assert(sizeof(dst_config_t) == sizeof(uint32_t));
|
||||
|
||||
namespace cache {
|
||||
|
||||
/* Set values in cache to sensible defaults. */
|
||||
@@ -241,9 +256,14 @@ void set_pocsag_ignore_address(uint32_t address);
|
||||
|
||||
bool clkout_enabled();
|
||||
void set_clkout_enabled(bool v);
|
||||
uint16_t clkout_freq();
|
||||
void set_clkout_freq(uint16_t freq);
|
||||
|
||||
bool dst_enabled();
|
||||
void set_dst_enabled(bool v);
|
||||
uint16_t clkout_freq();
|
||||
dst_config_t config_dst();
|
||||
void set_config_dst(dst_config_t v);
|
||||
|
||||
/* Recon app */
|
||||
bool recon_autosave_freqs();
|
||||
bool recon_autostart_recon();
|
||||
|
@@ -32,8 +32,10 @@
|
||||
#include "irq_controls.hpp"
|
||||
#include "string_format.hpp"
|
||||
#include "usb_serial_device_to_host.h"
|
||||
#include "rtc_time.hpp"
|
||||
|
||||
using namespace portapack;
|
||||
using namespace rtc_time;
|
||||
|
||||
namespace ui {
|
||||
|
||||
@@ -433,7 +435,7 @@ void Labels::getWidgetName(std::string& result) {
|
||||
/* LiveDateTime **********************************************************/
|
||||
|
||||
void LiveDateTime::on_tick_second() {
|
||||
rtcGetTime(&RTCD1, &datetime);
|
||||
rtc_time::now(datetime);
|
||||
text = "";
|
||||
if (!hide_clock) {
|
||||
if (date_enabled) {
|
||||
|
Reference in New Issue
Block a user