mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-05-02 04:39:59 -07:00
Merge branch 'dev' of https://github.com/flipperdevices/flipperzero-firmware into xfw-dev
This commit is contained in:
@@ -30,7 +30,7 @@ static void locale_test_view_draw_callback(Canvas* canvas, void* _model) {
|
||||
}
|
||||
canvas_draw_str(canvas, 0, 10, furi_string_get_cstr(tmp_string));
|
||||
|
||||
FuriHalRtcDateTime datetime;
|
||||
DateTime datetime;
|
||||
furi_hal_rtc_get_datetime(&datetime);
|
||||
|
||||
locale_format_time(tmp_string, &datetime, locale_get_time_format(), false);
|
||||
|
||||
175
applications/debug/unit_tests/datetimelib/datetimelib_test.c
Normal file
175
applications/debug/unit_tests/datetimelib/datetimelib_test.c
Normal file
@@ -0,0 +1,175 @@
|
||||
#include <furi.h>
|
||||
#include "../minunit.h"
|
||||
|
||||
#include <datetime/datetime.h>
|
||||
|
||||
MU_TEST(test_datetime_validate_datetime_correct_min) {
|
||||
DateTime correct_min = {0, 0, 0, 1, 1, 2000, 1};
|
||||
bool result = datetime_validate_datetime(&correct_min);
|
||||
|
||||
mu_assert_int_eq(true, result);
|
||||
}
|
||||
|
||||
MU_TEST(test_datetime_validate_datetime_correct_max) {
|
||||
DateTime correct_max = {23, 59, 59, 31, 12, 2099, 7};
|
||||
bool result = datetime_validate_datetime(&correct_max);
|
||||
|
||||
mu_assert_int_eq(true, result);
|
||||
}
|
||||
|
||||
MU_TEST(test_datetime_validate_datetime_incorrect_second) {
|
||||
DateTime incorrect_sec = {0, 0, 60, 1, 1, 2000, 1};
|
||||
bool result = datetime_validate_datetime(&incorrect_sec);
|
||||
|
||||
mu_assert_int_eq(false, result);
|
||||
}
|
||||
|
||||
MU_TEST(test_datetime_validate_datetime_incorrect_minute) {
|
||||
DateTime incorrect_min = {0, 60, 0, 1, 1, 2000, 1};
|
||||
bool result = datetime_validate_datetime(&incorrect_min);
|
||||
|
||||
mu_assert_int_eq(false, result);
|
||||
}
|
||||
|
||||
MU_TEST(test_datetime_validate_datetime_incorrect_hour) {
|
||||
DateTime incorrect_hour = {24, 0, 0, 1, 1, 2000, 1};
|
||||
bool result = datetime_validate_datetime(&incorrect_hour);
|
||||
|
||||
mu_assert_int_eq(false, result);
|
||||
}
|
||||
|
||||
MU_TEST(test_datetime_validate_datetime_incorrect_day_min) {
|
||||
DateTime incorrect_day_min = {0, 0, 0, 0, 1, 2000, 1};
|
||||
bool result = datetime_validate_datetime(&incorrect_day_min);
|
||||
|
||||
mu_assert_int_eq(false, result);
|
||||
}
|
||||
|
||||
MU_TEST(test_datetime_validate_datetime_incorrect_day_max) {
|
||||
DateTime incorrect_day_max = {0, 0, 0, 32, 1, 2000, 1};
|
||||
bool result = datetime_validate_datetime(&incorrect_day_max);
|
||||
|
||||
mu_assert_int_eq(false, result);
|
||||
}
|
||||
|
||||
MU_TEST(test_datetime_validate_datetime_incorrect_month_min) {
|
||||
DateTime incorrect_month_min = {0, 0, 0, 1, 0, 2000, 1};
|
||||
bool result = datetime_validate_datetime(&incorrect_month_min);
|
||||
|
||||
mu_assert_int_eq(false, result);
|
||||
}
|
||||
|
||||
MU_TEST(test_datetime_validate_datetime_incorrect_month_max) {
|
||||
DateTime incorrect_month_max = {0, 0, 0, 1, 13, 2000, 1};
|
||||
bool result = datetime_validate_datetime(&incorrect_month_max);
|
||||
|
||||
mu_assert_int_eq(false, result);
|
||||
}
|
||||
|
||||
MU_TEST(test_datetime_validate_datetime_incorrect_year_min) {
|
||||
DateTime incorrect_year_min = {0, 0, 0, 1, 1, 1999, 1};
|
||||
bool result = datetime_validate_datetime(&incorrect_year_min);
|
||||
|
||||
mu_assert_int_eq(false, result);
|
||||
}
|
||||
|
||||
MU_TEST(test_datetime_validate_datetime_incorrect_year_max) {
|
||||
DateTime incorrect_year_max = {0, 0, 0, 1, 1, 2100, 1};
|
||||
bool result = datetime_validate_datetime(&incorrect_year_max);
|
||||
|
||||
mu_assert_int_eq(false, result);
|
||||
}
|
||||
|
||||
MU_TEST(test_datetime_validate_datetime_incorrect_weekday_min) {
|
||||
DateTime incorrect_weekday_min = {0, 0, 0, 1, 1, 2000, 0};
|
||||
bool result = datetime_validate_datetime(&incorrect_weekday_min);
|
||||
|
||||
mu_assert_int_eq(false, result);
|
||||
}
|
||||
|
||||
MU_TEST(test_datetime_validate_datetime_incorrect_weekday_max) {
|
||||
DateTime incorrect_weekday_max = {0, 0, 0, 1, 1, 2000, 8};
|
||||
bool result = datetime_validate_datetime(&incorrect_weekday_max);
|
||||
|
||||
mu_assert_int_eq(false, result);
|
||||
}
|
||||
|
||||
MU_TEST_SUITE(test_datetime_validate_datetime) {
|
||||
MU_RUN_TEST(test_datetime_validate_datetime_correct_min);
|
||||
MU_RUN_TEST(test_datetime_validate_datetime_correct_max);
|
||||
MU_RUN_TEST(test_datetime_validate_datetime_incorrect_second);
|
||||
MU_RUN_TEST(test_datetime_validate_datetime_incorrect_minute);
|
||||
MU_RUN_TEST(test_datetime_validate_datetime_incorrect_hour);
|
||||
MU_RUN_TEST(test_datetime_validate_datetime_incorrect_day_min);
|
||||
MU_RUN_TEST(test_datetime_validate_datetime_incorrect_day_max);
|
||||
MU_RUN_TEST(test_datetime_validate_datetime_incorrect_month_min);
|
||||
MU_RUN_TEST(test_datetime_validate_datetime_incorrect_month_max);
|
||||
MU_RUN_TEST(test_datetime_validate_datetime_incorrect_year_min);
|
||||
MU_RUN_TEST(test_datetime_validate_datetime_incorrect_year_max);
|
||||
MU_RUN_TEST(test_datetime_validate_datetime_incorrect_weekday_min);
|
||||
MU_RUN_TEST(test_datetime_validate_datetime_incorrect_weekday_max);
|
||||
}
|
||||
|
||||
MU_TEST(test_datetime_timestamp_to_datetime_min) {
|
||||
uint32_t test_value = 0;
|
||||
DateTime min_datetime_expected = {0, 0, 0, 1, 1, 1970, 0};
|
||||
|
||||
DateTime result = {0};
|
||||
datetime_timestamp_to_datetime(test_value, &result);
|
||||
|
||||
mu_assert_mem_eq(&min_datetime_expected, &result, sizeof(result));
|
||||
}
|
||||
|
||||
MU_TEST(test_datetime_timestamp_to_datetime_max) {
|
||||
uint32_t test_value = UINT32_MAX;
|
||||
DateTime max_datetime_expected = {6, 28, 15, 7, 2, 2106, 0};
|
||||
|
||||
DateTime result = {0};
|
||||
datetime_timestamp_to_datetime(test_value, &result);
|
||||
|
||||
mu_assert_mem_eq(&max_datetime_expected, &result, sizeof(result));
|
||||
}
|
||||
|
||||
MU_TEST(test_datetime_timestamp_to_datetime_to_timestamp) {
|
||||
uint32_t test_value = random();
|
||||
|
||||
DateTime datetime = {0};
|
||||
datetime_timestamp_to_datetime(test_value, &datetime);
|
||||
|
||||
uint32_t result = datetime_datetime_to_timestamp(&datetime);
|
||||
|
||||
mu_assert_int_eq(test_value, result);
|
||||
}
|
||||
|
||||
MU_TEST_SUITE(test_datetime_timestamp_to_datetime_suite) {
|
||||
MU_RUN_TEST(test_datetime_timestamp_to_datetime_min);
|
||||
MU_RUN_TEST(test_datetime_timestamp_to_datetime_max);
|
||||
MU_RUN_TEST(test_datetime_timestamp_to_datetime_to_timestamp);
|
||||
}
|
||||
|
||||
MU_TEST(test_datetime_datetime_to_timestamp_min) {
|
||||
DateTime min_datetime = {0, 0, 0, 1, 1, 1970, 0};
|
||||
|
||||
uint32_t result = datetime_datetime_to_timestamp(&min_datetime);
|
||||
mu_assert_int_eq(0, result);
|
||||
}
|
||||
|
||||
MU_TEST(test_datetime_datetime_to_timestamp_max) {
|
||||
DateTime max_datetime = {6, 28, 15, 7, 2, 2106, 0};
|
||||
|
||||
uint32_t result = datetime_datetime_to_timestamp(&max_datetime);
|
||||
mu_assert_int_eq(UINT32_MAX, result);
|
||||
}
|
||||
|
||||
MU_TEST_SUITE(test_datetime_datetime_to_timestamp_suite) {
|
||||
MU_RUN_TEST(test_datetime_datetime_to_timestamp_min);
|
||||
MU_RUN_TEST(test_datetime_datetime_to_timestamp_max);
|
||||
}
|
||||
|
||||
int run_minunit_test_datetime() {
|
||||
MU_RUN_SUITE(test_datetime_timestamp_to_datetime_suite);
|
||||
MU_RUN_SUITE(test_datetime_datetime_to_timestamp_suite);
|
||||
MU_RUN_SUITE(test_datetime_validate_datetime);
|
||||
|
||||
return MU_EXIT_CODE;
|
||||
}
|
||||
@@ -214,37 +214,6 @@ MU_TEST(furi_hal_i2c_ext_eeprom) {
|
||||
}
|
||||
}
|
||||
|
||||
MU_TEST(furi_hal_rtc_timestamp2datetime_min) {
|
||||
uint32_t test_value = 0;
|
||||
FuriHalRtcDateTime min_datetime_expected = {0, 0, 0, 1, 1, 1970, 0};
|
||||
|
||||
FuriHalRtcDateTime result = {0};
|
||||
furi_hal_rtc_timestamp_to_datetime(test_value, &result);
|
||||
|
||||
mu_assert_mem_eq(&min_datetime_expected, &result, sizeof(result));
|
||||
}
|
||||
|
||||
MU_TEST(furi_hal_rtc_timestamp2datetime_max) {
|
||||
uint32_t test_value = UINT32_MAX;
|
||||
FuriHalRtcDateTime max_datetime_expected = {6, 28, 15, 7, 2, 2106, 0};
|
||||
|
||||
FuriHalRtcDateTime result = {0};
|
||||
furi_hal_rtc_timestamp_to_datetime(test_value, &result);
|
||||
|
||||
mu_assert_mem_eq(&max_datetime_expected, &result, sizeof(result));
|
||||
}
|
||||
|
||||
MU_TEST(furi_hal_rtc_timestamp2datetime2timestamp) {
|
||||
uint32_t test_value = random();
|
||||
|
||||
FuriHalRtcDateTime datetime = {0};
|
||||
furi_hal_rtc_timestamp_to_datetime(test_value, &datetime);
|
||||
|
||||
uint32_t result = furi_hal_rtc_datetime_to_timestamp(&datetime);
|
||||
|
||||
mu_assert_int_eq(test_value, result);
|
||||
}
|
||||
|
||||
MU_TEST_SUITE(furi_hal_i2c_int_suite) {
|
||||
MU_SUITE_CONFIGURE(&furi_hal_i2c_int_setup, &furi_hal_i2c_int_teardown);
|
||||
MU_RUN_TEST(furi_hal_i2c_int_1b);
|
||||
@@ -258,15 +227,8 @@ MU_TEST_SUITE(furi_hal_i2c_ext_suite) {
|
||||
MU_RUN_TEST(furi_hal_i2c_ext_eeprom);
|
||||
}
|
||||
|
||||
MU_TEST_SUITE(furi_hal_rtc_datetime_suite) {
|
||||
MU_RUN_TEST(furi_hal_rtc_timestamp2datetime_min);
|
||||
MU_RUN_TEST(furi_hal_rtc_timestamp2datetime_max);
|
||||
MU_RUN_TEST(furi_hal_rtc_timestamp2datetime2timestamp);
|
||||
}
|
||||
|
||||
int run_minunit_test_furi_hal() {
|
||||
MU_RUN_SUITE(furi_hal_i2c_int_suite);
|
||||
MU_RUN_SUITE(furi_hal_i2c_ext_suite);
|
||||
MU_RUN_SUITE(furi_hal_rtc_datetime_suite);
|
||||
return MU_EXIT_CODE;
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ int run_minunit_test_protocol_dict();
|
||||
int run_minunit_test_lfrfid_protocols();
|
||||
int run_minunit_test_nfc();
|
||||
int run_minunit_test_bit_lib();
|
||||
int run_minunit_test_datetime();
|
||||
int run_minunit_test_float_tools();
|
||||
int run_minunit_test_bt();
|
||||
int run_minunit_test_dialogs_file_browser_options();
|
||||
@@ -57,6 +58,7 @@ const UnitTest unit_tests[] = {
|
||||
{.name = "protocol_dict", .entry = run_minunit_test_protocol_dict},
|
||||
{.name = "lfrfid", .entry = run_minunit_test_lfrfid_protocols},
|
||||
{.name = "bit_lib", .entry = run_minunit_test_bit_lib},
|
||||
{.name = "datetime", .entry = run_minunit_test_datetime},
|
||||
{.name = "float_tools", .entry = run_minunit_test_float_tools},
|
||||
{.name = "bt", .entry = run_minunit_test_bt},
|
||||
{.name = "dialogs_file_browser_options",
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
|
||||
#include <bit_lib.h>
|
||||
#include <applications/services/locale/locale.h>
|
||||
#include <furi_hal_rtc.h>
|
||||
#include <datetime/datetime.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
//
|
||||
@@ -173,7 +173,7 @@ static void furi_string_cat_timestamp(
|
||||
const char* date_hdr,
|
||||
const char* time_hdr,
|
||||
uint32_t tmst_1900);
|
||||
static void epoch_1900_datetime_to_furi(uint32_t seconds, FuriHalRtcDateTime* out);
|
||||
static void epoch_1900_datetime_to_furi(uint32_t seconds, DateTime* out);
|
||||
static bool get_file_contents(
|
||||
const MfDesfireApplication* app,
|
||||
const MfDesfireFileId* id,
|
||||
@@ -528,7 +528,7 @@ static void furi_string_cat_timestamp(
|
||||
const char* date_hdr,
|
||||
const char* time_hdr,
|
||||
uint32_t tmst_1900) {
|
||||
FuriHalRtcDateTime tm;
|
||||
DateTime tm;
|
||||
|
||||
epoch_1900_datetime_to_furi(tmst_1900, &tm);
|
||||
|
||||
@@ -551,7 +551,7 @@ static void furi_string_cat_timestamp(
|
||||
}
|
||||
|
||||
// Convert a "1900"-based timestamp to Furi time, assuming a UTC/GMT timezone.
|
||||
static void epoch_1900_datetime_to_furi(uint32_t seconds, FuriHalRtcDateTime* out) {
|
||||
static void epoch_1900_datetime_to_furi(uint32_t seconds, DateTime* out) {
|
||||
uint16_t year, month, day, hour, minute, second;
|
||||
|
||||
// Calculate absolute number of days elapsed since the 1900 epoch
|
||||
@@ -569,17 +569,17 @@ static void epoch_1900_datetime_to_furi(uint32_t seconds, FuriHalRtcDateTime* ou
|
||||
//
|
||||
|
||||
for(year = 1900;; year++) {
|
||||
uint16_t year_days = furi_hal_rtc_get_days_per_year(year);
|
||||
uint16_t year_days = datetime_get_days_per_year(year);
|
||||
if(absolute_days >= year_days)
|
||||
absolute_days -= year_days;
|
||||
else
|
||||
break;
|
||||
}
|
||||
|
||||
bool is_leap = furi_hal_rtc_is_leap_year(year);
|
||||
bool is_leap = datetime_is_leap_year(year);
|
||||
|
||||
for(month = 1;; month++) {
|
||||
uint8_t days_in_month = furi_hal_rtc_get_days_per_month(is_leap, month);
|
||||
uint8_t days_in_month = datetime_get_days_per_month(is_leap, month);
|
||||
if(absolute_days >= days_in_month)
|
||||
absolute_days -= days_in_month;
|
||||
else
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#include <lib/nfc/protocols/mf_desfire/mf_desfire.h>
|
||||
|
||||
#include <applications/services/locale/locale.h>
|
||||
#include <furi_hal_rtc.h>
|
||||
#include <datetime/datetime.h>
|
||||
|
||||
static const MfDesfireApplicationId itso_app_id = {.data = {0x16, 0x02, 0xa0}};
|
||||
static const MfDesfireFileId itso_file_id = 0x0f;
|
||||
@@ -87,8 +87,8 @@ static bool itso_parse(const NfcDevice* device, FuriString* parsed_data) {
|
||||
furi_string_push_back(parsed_data, ' ');
|
||||
}
|
||||
|
||||
FuriHalRtcDateTime timestamp = {0};
|
||||
furi_hal_rtc_timestamp_to_datetime(unixTimestamp, ×tamp);
|
||||
DateTime timestamp = {0};
|
||||
datetime_timestamp_to_datetime(unixTimestamp, ×tamp);
|
||||
FuriString* timestamp_str = furi_string_alloc();
|
||||
locale_format_date(timestamp_str, ×tamp, locale_get_date_format(), "-");
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
#include <lib/nfc/protocols/mf_desfire/mf_desfire.h>
|
||||
|
||||
#include <applications/services/locale/locale.h>
|
||||
#include <furi_hal_rtc.h>
|
||||
#include <datetime/datetime.h>
|
||||
|
||||
static const MfDesfireApplicationId opal_app_id = {.data = {0x31, 0x45, 0x53}};
|
||||
|
||||
@@ -78,11 +78,11 @@ typedef struct __attribute__((__packed__)) {
|
||||
|
||||
static_assert(sizeof(OpalFile) == 16, "OpalFile");
|
||||
|
||||
// Converts an Opal timestamp to FuriHalRtcDateTime.
|
||||
// Converts an Opal timestamp to DateTime.
|
||||
//
|
||||
// Opal measures days since 1980-01-01 and minutes since midnight, and presumes
|
||||
// all days are 1440 minutes.
|
||||
static void opal_date_time_to_furi(uint16_t days, uint16_t minutes, FuriHalRtcDateTime* out) {
|
||||
static void opal_date_time_to_furi(uint16_t days, uint16_t minutes, DateTime* out) {
|
||||
out->year = 1980;
|
||||
out->month = 1;
|
||||
// 1980-01-01 is a Tuesday
|
||||
@@ -93,7 +93,7 @@ static void opal_date_time_to_furi(uint16_t days, uint16_t minutes, FuriHalRtcDa
|
||||
|
||||
// What year is it?
|
||||
for(;;) {
|
||||
const uint16_t num_days_in_year = furi_hal_rtc_get_days_per_year(out->year);
|
||||
const uint16_t num_days_in_year = datetime_get_days_per_year(out->year);
|
||||
if(days < num_days_in_year) break;
|
||||
days -= num_days_in_year;
|
||||
out->year++;
|
||||
@@ -104,8 +104,8 @@ static void opal_date_time_to_furi(uint16_t days, uint16_t minutes, FuriHalRtcDa
|
||||
|
||||
for(;;) {
|
||||
// What month is it?
|
||||
const bool is_leap = furi_hal_rtc_is_leap_year(out->year);
|
||||
const uint8_t num_days_in_month = furi_hal_rtc_get_days_per_month(is_leap, out->month);
|
||||
const bool is_leap = datetime_is_leap_year(out->year);
|
||||
const uint8_t num_days_in_month = datetime_get_days_per_month(is_leap, out->month);
|
||||
if(days <= num_days_in_month) break;
|
||||
days -= num_days_in_month;
|
||||
out->month++;
|
||||
@@ -154,7 +154,7 @@ static bool opal_parse(const NfcDevice* device, FuriString* parsed_data) {
|
||||
const uint8_t balance_cents = balance % 100;
|
||||
const int32_t balance_dollars = balance / 100;
|
||||
|
||||
FuriHalRtcDateTime timestamp;
|
||||
DateTime timestamp;
|
||||
opal_date_time_to_furi(opal_file->days, opal_file->minutes, ×tamp);
|
||||
|
||||
// Usages 4..6 associated with the Manly Ferry, which correspond to
|
||||
|
||||
@@ -29,11 +29,11 @@
|
||||
#include "protocols/mf_classic/mf_classic.h"
|
||||
|
||||
#include <bit_lib.h>
|
||||
#include <furi_hal_rtc.h>
|
||||
#include <datetime/datetime.h>
|
||||
|
||||
#define TAG "Umarsh"
|
||||
|
||||
bool parse_datetime(uint16_t date, FuriHalRtcDateTime* result) {
|
||||
bool parse_datetime(uint16_t date, DateTime* result) {
|
||||
result->year = 2000 + (date >> 9);
|
||||
result->month = date >> 5 & 0x0F;
|
||||
result->day = date & 0x1F;
|
||||
@@ -81,13 +81,13 @@ static bool umarsh_parse(const NfcDevice* device, FuriString* parsed_data) {
|
||||
const uint16_t balance_rub = (bit_lib_bytes_to_num_be(block_start_ptr + 8, 2)) & 0x7FFF;
|
||||
const uint8_t balance_kop = bit_lib_bytes_to_num_be(block_start_ptr + 10, 1) & 0x7F;
|
||||
|
||||
FuriHalRtcDateTime expiry_datetime;
|
||||
DateTime expiry_datetime;
|
||||
bool is_expiry_datetime_valid = parse_datetime(expiry_date, &expiry_datetime);
|
||||
|
||||
FuriHalRtcDateTime valid_to_datetime;
|
||||
DateTime valid_to_datetime;
|
||||
bool is_valid_to_datetime_valid = parse_datetime(valid_to, &valid_to_datetime);
|
||||
|
||||
FuriHalRtcDateTime last_refill_datetime;
|
||||
DateTime last_refill_datetime;
|
||||
bool is_last_refill_datetime_valid =
|
||||
parse_datetime(last_refill_date, &last_refill_datetime);
|
||||
|
||||
|
||||
@@ -101,7 +101,7 @@ void cli_command_date(Cli* cli, FuriString* args, void* context) {
|
||||
UNUSED(cli);
|
||||
UNUSED(context);
|
||||
|
||||
FuriHalRtcDateTime datetime = {0};
|
||||
DateTime datetime = {0};
|
||||
|
||||
if(furi_string_size(args) > 0) {
|
||||
uint16_t hours, minutes, seconds, month, day, year, weekday;
|
||||
@@ -135,7 +135,7 @@ void cli_command_date(Cli* cli, FuriString* args, void* context) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(!furi_hal_rtc_validate_datetime(&datetime)) {
|
||||
if(!datetime_validate_datetime(&datetime)) {
|
||||
printf("Invalid datetime data");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ static void desktop_lock_icon_draw_callback(Canvas* canvas, void* context) {
|
||||
static void desktop_clock_update(Desktop* desktop) {
|
||||
furi_assert(desktop);
|
||||
|
||||
FuriHalRtcDateTime curr_dt;
|
||||
DateTime curr_dt;
|
||||
furi_hal_rtc_get_datetime(&curr_dt);
|
||||
bool time_format_12 = locale_get_time_format() == LocaleTimeFormat12h;
|
||||
|
||||
|
||||
@@ -129,7 +129,7 @@ static void dolphin_update_clear_limits_timer_period(Dolphin* dolphin) {
|
||||
uint32_t timer_expires_at = furi_timer_get_expire_time(dolphin->clear_limits_timer);
|
||||
|
||||
if((timer_expires_at - now_ticks) > HOURS_IN_TICKS(0.1)) {
|
||||
FuriHalRtcDateTime date;
|
||||
DateTime date;
|
||||
furi_hal_rtc_get_datetime(&date);
|
||||
uint32_t now_time_in_ms = ((date.hour * 60 + date.minute) * 60 + date.second) * 1000;
|
||||
uint32_t time_to_clear_limits = 0;
|
||||
|
||||
@@ -73,9 +73,9 @@ bool dolphin_state_load(DolphinState* dolphin_state) {
|
||||
}
|
||||
|
||||
uint64_t dolphin_state_timestamp() {
|
||||
FuriHalRtcDateTime datetime;
|
||||
DateTime datetime;
|
||||
furi_hal_rtc_get_datetime(&datetime);
|
||||
return furi_hal_rtc_datetime_to_timestamp(&datetime);
|
||||
return datetime_datetime_to_timestamp(&datetime);
|
||||
}
|
||||
|
||||
bool dolphin_state_is_levelup(uint32_t icounter) {
|
||||
|
||||
@@ -36,7 +36,7 @@ float locale_celsius_to_fahrenheit(float temp_c) {
|
||||
|
||||
void locale_format_time(
|
||||
FuriString* out_str,
|
||||
const FuriHalRtcDateTime* datetime,
|
||||
const DateTime* datetime,
|
||||
const LocaleTimeFormat format,
|
||||
const bool show_seconds) {
|
||||
furi_assert(out_str);
|
||||
@@ -69,7 +69,7 @@ void locale_format_time(
|
||||
|
||||
void locale_format_date(
|
||||
FuriString* out_str,
|
||||
const FuriHalRtcDateTime* datetime,
|
||||
const DateTime* datetime,
|
||||
const LocaleDateFormat format,
|
||||
const char* separator) {
|
||||
furi_assert(out_str);
|
||||
|
||||
@@ -73,7 +73,7 @@ void locale_set_time_format(LocaleTimeFormat format);
|
||||
*/
|
||||
void locale_format_time(
|
||||
FuriString* out_str,
|
||||
const FuriHalRtcDateTime* datetime,
|
||||
const DateTime* datetime,
|
||||
const LocaleTimeFormat format,
|
||||
const bool show_seconds);
|
||||
|
||||
@@ -98,7 +98,7 @@ void locale_set_date_format(LocaleDateFormat format);
|
||||
*/
|
||||
void locale_format_date(
|
||||
FuriString* out_str,
|
||||
const FuriHalRtcDateTime* datetime,
|
||||
const DateTime* datetime,
|
||||
const LocaleDateFormat format,
|
||||
const char* separator);
|
||||
|
||||
|
||||
@@ -122,7 +122,7 @@ static void rpc_system_system_get_datetime_process(const PB_Main* request, void*
|
||||
RpcSession* session = (RpcSession*)context;
|
||||
furi_assert(session);
|
||||
|
||||
FuriHalRtcDateTime datetime;
|
||||
DateTime datetime;
|
||||
furi_hal_rtc_get_datetime(&datetime);
|
||||
|
||||
PB_Main* response = malloc(sizeof(PB_Main));
|
||||
@@ -157,7 +157,7 @@ static void rpc_system_system_set_datetime_process(const PB_Main* request, void*
|
||||
return;
|
||||
}
|
||||
|
||||
FuriHalRtcDateTime datetime;
|
||||
DateTime datetime;
|
||||
datetime.hour = request->content.system_set_datetime_request.datetime.hour;
|
||||
datetime.minute = request->content.system_set_datetime_request.datetime.minute;
|
||||
datetime.second = request->content.system_set_datetime_request.datetime.second;
|
||||
|
||||
Reference in New Issue
Block a user