1
0
Fork 0
mirror of https://github.com/CTCaer/hekate.git synced 2024-11-22 18:06:40 +00:00

nyx: get rtc adjustments via driver

This commit is contained in:
CTCaer 2024-03-12 15:11:32 +02:00
parent 83ac40c4b9
commit b1e6661a7a
4 changed files with 13 additions and 27 deletions

View file

@ -282,12 +282,7 @@ static void _save_fb_to_bmp()
// Create date/time name.
char fname[32];
rtc_time_t time;
max77620_rtc_get_time(&time);
if (n_cfg.timeoff)
{
u32 epoch = max77620_rtc_date_to_epoch(&time) + (s32)n_cfg.timeoff;
max77620_rtc_epoch_to_date(epoch, &time);
}
max77620_rtc_get_time_adjusted(&time);
s_printf(fname, "%04d%02d%02d_%02d%02d%02d", time.year, time.month, time.day, time.hour, time.min, time.sec);
s_printf(path + strlen(path), "/nyx%s.bmp", fname);
@ -1318,12 +1313,7 @@ static void _update_status_bar(void *params)
rtc_time_t time;
// Get sensor data.
max77620_rtc_get_time(&time);
if (n_cfg.timeoff)
{
u32 epoch = max77620_rtc_date_to_epoch(&time) + (s32)n_cfg.timeoff;
max77620_rtc_epoch_to_date(epoch, &time);
}
max77620_rtc_get_time_adjusted(&time);
soc_temp = tmp451_get_soc_temp(false);
bq24193_get_property(BQ24193_ChargeStatus, &charge_status);
max17050_get_property(MAX17050_RepSOC, (int *)&batt_percent);

View file

@ -706,9 +706,14 @@ static lv_res_t _action_clock_edit(lv_obj_t *btns, const char * txt)
u32 new_epoch = max77620_rtc_date_to_epoch(&time);
// Stored in u32 and allow overflow for integer offset casting.
n_cfg.timeoff = new_epoch - epoch;
// If canceled set 1 for invalidating first boot clock edit.
if (!n_cfg.timeoff)
n_cfg.timeoff = 1;
else
max77620_rtc_set_epoch_offset((int)n_cfg.timeoff);
nyx_changes_made = true;
}
@ -744,12 +749,7 @@ static lv_res_t _create_mbox_clock_edit(lv_obj_t *btn)
// Get current time.
rtc_time_t time;
max77620_rtc_get_time(&time);
if (n_cfg.timeoff)
{
u32 epoch = max77620_rtc_date_to_epoch(&time) + (s32)n_cfg.timeoff;
max77620_rtc_epoch_to_date(epoch, &time);
}
max77620_rtc_get_time_adjusted(&time);
// Normalize year if out of range.
if (time.year < CLOCK_MIN_YEAR)

View file

@ -7,9 +7,6 @@
#include <bdk.h>
#include <libs/fatfs/ff.h>
#include "../../config.h"
extern nyx_config n_cfg;
#if FF_USE_LFN == 3 /* Dynamic memory allocation */
@ -50,12 +47,7 @@ DWORD get_fattime (
{
rtc_time_t time;
max77620_rtc_get_time(&time);
if (n_cfg.timeoff)
{
u32 epoch = (u32)((s32)max77620_rtc_date_to_epoch(&time) + (s32)n_cfg.timeoff);
max77620_rtc_epoch_to_date(epoch, &time);
}
max77620_rtc_get_time_adjusted(&time);
return (((DWORD)(time.year - 1980) << 25) | ((DWORD)time.month << 21) | ((DWORD)time.day << 16) |
((DWORD)time.hour << 11) | ((DWORD)time.min << 5) | (time.sec >> 1));

View file

@ -269,7 +269,11 @@ skip_main_cfg_parse:
else if (!strcmp("entries5col", kv->key))
n_cfg.entries_5_col = atoi(kv->val) == 1;
else if (!strcmp("timeoff", kv->key))
{
n_cfg.timeoff = strtol(kv->val, NULL, 16);
if (n_cfg.timeoff != 1)
max77620_rtc_set_epoch_offset((int)n_cfg.timeoff);
}
else if (!strcmp("homescreen", kv->key))
n_cfg.home_screen = atoi(kv->val);
else if (!strcmp("verification", kv->key))