Skip to content

Commit

Permalink
datetime fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
xMasterX committed Feb 15, 2024
1 parent 8e34246 commit d8becee
Show file tree
Hide file tree
Showing 26 changed files with 52 additions and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ void nfc_debug_pcap_process_data(
bool crc_dropped) {
furi_assert(instance);
furi_assert(data);
FuriHalRtcDateTime datetime;
DateTime datetime;
furi_hal_rtc_get_datetime(&datetime);

uint8_t event = 0;
Expand Down Expand Up @@ -117,7 +117,7 @@ void nfc_debug_pcap_process_data(
uint8_t event;
uint16_t len;
} __attribute__((__packed__)) pkt_hdr = {
.ts_sec = furi_hal_rtc_datetime_to_timestamp(&datetime),
.ts_sec = datetime_datetime_to_timestamp(&datetime),
.ts_usec = 0,
.incl_len = len + 4,
.orig_len = len + 4,
Expand Down
4 changes: 2 additions & 2 deletions apps_source_code/bpmtapper/bpm.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@ static float queue_avg(queue* q) {

// TOO SLOW!
//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);
//}
//
typedef struct {
Expand Down
8 changes: 4 additions & 4 deletions apps_source_code/color_guess/views/color_guess_play.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ void color_guess_play_new_round(void* context, ColorGuessPlayModel* model) {
furi_assert(context);
ColorGuess* app = context;
//Reset timer
FuriHalRtcDateTime date_time;
DateTime date_time;
furi_hal_rtc_get_datetime(&date_time);
model->timestamp_start = furi_hal_rtc_datetime_to_timestamp(&date_time);
model->timestamp_start = datetime_datetime_to_timestamp(&date_time);
model->success = 0;
model->closeness = 0;
model->prev_closeness = 0;
Expand Down Expand Up @@ -154,9 +154,9 @@ void color_guess_play_draw(Canvas* canvas, ColorGuessPlayModel* model) {
}
const int cursorOffset = 30;
const int newCursorPos = (model->cursorpos * 12) + cursorOffset;
FuriHalRtcDateTime date_time;
DateTime date_time;
furi_hal_rtc_get_datetime(&date_time);
uint32_t timestamp = furi_hal_rtc_datetime_to_timestamp(&date_time);
uint32_t timestamp = datetime_datetime_to_timestamp(&date_time);
uint32_t time_elapsed = timestamp - model->timestamp_start;
model->time_spent = time_elapsed;

Expand Down
6 changes: 3 additions & 3 deletions apps_source_code/flipper-dcf77/dcf77_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ uint8_t get_dcf_message_bit(uint8_t* message, uint8_t bit) {

// should it still be const?
static void update_dcf77_message_from_rtc(AppFSM* app_fsm) {
FuriHalRtcDateTime dt;
DateTime dt;
furi_hal_rtc_get_datetime(&dt);
app_fsm->bit_number = dt.second;
app_fsm->next_message = malloc(8);
Expand Down Expand Up @@ -165,7 +165,7 @@ static void render_callback(Canvas* const canvas, void* ctx) {
canvas_draw_frame(canvas, 0, 0, 128, 64);
canvas_set_font(canvas, FontPrimary);
snprintf(buffer, 64, "%1x.%1x=%01x", bit_number / 8, (bit_number % 8), bit_value);
FuriHalRtcDateTime dt;
DateTime dt;
furi_hal_rtc_get_datetime(&dt);
//canvas_draw_str_aligned(canvas, 64, 10, AlignCenter, AlignBottom, "DCF77 emulator");
snprintf(
Expand Down Expand Up @@ -270,7 +270,7 @@ static void on_timer_tick(AppFSM* app_fsm) {
static bool last_output = false;
bool output = true;

FuriHalRtcDateTime dt;
DateTime dt;
furi_hal_rtc_get_datetime(&dt);
app_fsm->bit_number = dt.second;
app_fsm->bit_value = get_dcf_message_bit(app_fsm->dcf77_message, app_fsm->bit_number);
Expand Down
2 changes: 1 addition & 1 deletion apps_source_code/flipper_analog_clock/analog_clock.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ typedef struct {

typedef struct {
FuriMutex* mutex;
FuriHalRtcDateTime date_time;
DateTime date_time;
} ClockApp;

static Vector2 angle_to_vector2(float angle_in_degrees, uint8_t distance, Vector2 center) {
Expand Down
2 changes: 1 addition & 1 deletion apps_source_code/flipper_geiger/flipper_geiger.c
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ int32_t flipper_geiger_app() {
if(recordData == 0) {
notification_message(notification, &sequence_set_only_red_255);

FuriHalRtcDateTime datetime;
DateTime datetime;
furi_hal_rtc_get_datetime(&datetime);

char path[64];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ bool mifare_fuzzer_scene_emulator_on_event(void* context, SceneManagerEvent even
//FURI_LOG_D(TAG, "mifare_fuzzer_scene_emulator_on_event() :: SceneManagerEventTypeTick");

// Used to check tick length (not perfect but enough)
//FuriHalRtcDateTime curr_dt;
//DateTime curr_dt;
//furi_hal_rtc_get_datetime(&curr_dt);
//FURI_LOG_D(TAG, "Time is: %.2d:%.2d:%.2d", curr_dt.hour, curr_dt.minute, curr_dt.second);

Expand Down
8 changes: 4 additions & 4 deletions apps_source_code/pomodoro/pomodoro_timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@ void pomodoro_timer_process(PomodoroTimer* pomodoro_timer, InputEvent* event) {
model->ok_pressed = false;

// START/STOP TIMER
FuriHalRtcDateTime curr_dt;
DateTime curr_dt;
furi_hal_rtc_get_datetime(&curr_dt);
uint32_t current_timestamp = furi_hal_rtc_datetime_to_timestamp(&curr_dt);
uint32_t current_timestamp = datetime_datetime_to_timestamp(&curr_dt);

// STARTED -> PAUSED
if(model->timer_running) {
Expand Down Expand Up @@ -116,9 +116,9 @@ void pomodoro_timer_process(PomodoroTimer* pomodoro_timer, InputEvent* event) {
void pomodoro_draw_callback(Canvas* canvas, void* context, int max_seconds, int max_seconds_rest) {
furi_assert(context);
PomodoroTimerModel* model = context;
FuriHalRtcDateTime curr_dt;
DateTime curr_dt;
furi_hal_rtc_get_datetime(&curr_dt);
uint32_t current_timestamp = furi_hal_rtc_datetime_to_timestamp(&curr_dt);
uint32_t current_timestamp = datetime_datetime_to_timestamp(&curr_dt);

// Header
canvas_set_font(canvas, FontPrimary);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ void avr_isp_scene_input_name_text_callback(void* context) {
}

void avr_isp_scene_input_name_get_timefilename(FuriString* name) {
FuriHalRtcDateTime datetime = {0};
DateTime datetime = {0};
furi_hal_rtc_get_datetime(&datetime);
furi_string_printf(
name,
Expand Down
2 changes: 1 addition & 1 deletion base_pack/camera_suite/views/camera_suite_view_camera.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ static void save_image_to_flipper_sd_card(void* model) {
FuriString* file_name = furi_string_alloc();

// Get the current date and time.
FuriHalRtcDateTime datetime = {0};
DateTime datetime = {0};
furi_hal_rtc_get_datetime(&datetime);

// Create the file name.
Expand Down
8 changes: 4 additions & 4 deletions base_pack/picopass/loclass_writer.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ void loclass_writer_free(LoclassWriter* instance) {
bool loclass_writer_write_start_stop(LoclassWriter* instance, bool start) {
furi_assert(instance != NULL);

FuriHalRtcDateTime curr_dt;
DateTime curr_dt;
furi_hal_rtc_get_datetime(&curr_dt);
uint32_t curr_ts = furi_hal_rtc_datetime_to_timestamp(&curr_dt);
uint32_t curr_ts = datetime_datetime_to_timestamp(&curr_dt);

FuriString* str = furi_string_alloc_printf(
"loclass-v1-info ts %lu %s\n", curr_ts, start ? "started" : "finished");
Expand All @@ -61,9 +61,9 @@ bool loclass_writer_write_params(
const uint8_t mac[4]) {
furi_assert(instance != NULL);

FuriHalRtcDateTime curr_dt;
DateTime curr_dt;
furi_hal_rtc_get_datetime(&curr_dt);
uint32_t curr_ts = furi_hal_rtc_datetime_to_timestamp(&curr_dt);
uint32_t curr_ts = datetime_datetime_to_timestamp(&curr_dt);

FuriString* str = furi_string_alloc_printf(
"loclass-v1-mac ts %lu no %u "
Expand Down
2 changes: 1 addition & 1 deletion base_pack/totp/services/config/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ static char* totp_config_file_backup_i(Storage* storage) {
return NULL;
}

FuriHalRtcDateTime current_datetime;
DateTime current_datetime;
furi_hal_rtc_get_datetime(&current_datetime);

uint8_t backup_path_size = sizeof(CONFIG_FILE_BACKUP_BASE_PATH) + 14;
Expand Down
4 changes: 2 additions & 2 deletions base_pack/weather_station/protocols/ws_generic.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,9 @@ SubGhzProtocolStatus ws_block_generic_serialize(
}

//DATE AGE set
FuriHalRtcDateTime curr_dt;
DateTime curr_dt;
furi_hal_rtc_get_datetime(&curr_dt);
uint32_t curr_ts = furi_hal_rtc_datetime_to_timestamp(&curr_dt);
uint32_t curr_ts = datetime_datetime_to_timestamp(&curr_dt);

temp_data = curr_ts;
if(!flipper_format_write_uint32(flipper_format, "Ts", &temp_data, 1)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ void ws_view_receiver_info_update(WSReceiverInfo* ws_receiver_info, FlipperForma

ws_block_generic_deserialize(model->generic, fff);

FuriHalRtcDateTime curr_dt;
DateTime curr_dt;
furi_hal_rtc_get_datetime(&curr_dt);
model->curr_ts = furi_hal_rtc_datetime_to_timestamp(&curr_dt);
model->curr_ts = datetime_datetime_to_timestamp(&curr_dt);
},
true);
}
Expand Down Expand Up @@ -186,9 +186,9 @@ static void ws_view_receiver_info_timer(void* context) {
ws_receiver_info->view,
WSReceiverInfoModel * model,
{
FuriHalRtcDateTime curr_dt;
DateTime curr_dt;
furi_hal_rtc_get_datetime(&curr_dt);
model->curr_ts = furi_hal_rtc_datetime_to_timestamp(&curr_dt);
model->curr_ts = datetime_datetime_to_timestamp(&curr_dt);
},
true);
}
Expand Down
8 changes: 4 additions & 4 deletions non_catalog_apps/FlipperNightStand_clock/clock_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,9 @@ static void clock_render_callback(Canvas* const canvas, void* ctx) {
return;
}

FuriHalRtcDateTime curr_dt;
DateTime curr_dt;
furi_hal_rtc_get_datetime(&curr_dt);
uint32_t curr_ts = furi_hal_rtc_datetime_to_timestamp(&curr_dt);
uint32_t curr_ts = datetime_datetime_to_timestamp(&curr_dt);

char time_string[TIME_LEN];
char date_string[DATE_LEN];
Expand Down Expand Up @@ -225,9 +225,9 @@ static void clock_tick(void* ctx) {

void timer_start_stop(ClockState* plugin_state) {
// START/STOP TIMER
FuriHalRtcDateTime curr_dt;
DateTime curr_dt;
furi_hal_rtc_get_datetime(&curr_dt);
uint32_t curr_ts = furi_hal_rtc_datetime_to_timestamp(&curr_dt);
uint32_t curr_ts = datetime_datetime_to_timestamp(&curr_dt);

if(plugin_state->timer_running) {
// Update stopped seconds
Expand Down
2 changes: 1 addition & 1 deletion non_catalog_apps/FlipperNightStand_clock/clock_app.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ typedef struct {
typedef struct {
LocaleDateFormat date_format;
LocaleTimeFormat time_format;
FuriHalRtcDateTime datetime;
DateTime datetime;
FuriMutex* mutex;
FuriMessageQueue* event_queue;
uint32_t timer_start_timestamp;
Expand Down
2 changes: 1 addition & 1 deletion non_catalog_apps/calendar/calendar.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ static bool calendar_app_back_event_callback(void* context) {
}

VariableSharedContext* calendar_app_variable_shared_context_alloc() {
FuriHalRtcDateTime datetime;
DateTime datetime;
furi_hal_rtc_get_datetime(&datetime);
VariableSharedContext* variable_shared_context = malloc(sizeof(VariableSharedContext));
variable_shared_context->year_selected = datetime.year;
Expand Down
2 changes: 1 addition & 1 deletion non_catalog_apps/flipperzero-camera/camera.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ static void camera_view_draw_callback(Canvas* canvas, void* _model) {
}

void get_timefilename(FuriString* name) {
FuriHalRtcDateTime datetime = {0};
DateTime datetime = {0};
furi_hal_rtc_get_datetime(&datetime);
furi_string_printf(
name,
Expand Down
6 changes: 3 additions & 3 deletions non_catalog_apps/nrf24-batch/nrf24batch.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ uint8_t listen_addr[5];
uint8_t listen_addr_len = 0;
char* ListenFields = NULL; // ptr to string: field1,field2,... max 5 field now
bool ListenNew;
FuriHalRtcDateTime ListenLastTime = {0};
DateTime ListenLastTime = {0};
uint32_t ListenPrev = 0;
uint32_t ListenLast = 0;
FuriString** Read_cmd = NULL; // Names of read cmd
Expand Down Expand Up @@ -1039,7 +1039,7 @@ static void save_batch(void) {
FURI_LOG_D(TAG, "Save Batch");
char *p, *p2;
stream_seek(file_stream, 0, StreamOffsetFromEnd);
FuriHalRtcDateTime dt;
DateTime dt;
furi_hal_rtc_get_datetime(&dt);
stream_write_format(file_stream, "\n%s ", SettingsFld_WriteBatch);
p = (char*)furi_string_get_cstr(ReadBatch_cmd[view_cmd[rwt_read_batch]]);
Expand Down Expand Up @@ -1447,7 +1447,7 @@ void work_timer_callback(void* ctx) {
if(rw_type == rwt_listen) {
ListenPrev = ListenLast;
furi_hal_rtc_get_datetime(&ListenLastTime);
ListenLast = furi_hal_rtc_datetime_to_timestamp(&ListenLastTime);
ListenLast = datetime_datetime_to_timestamp(&ListenLastTime);
ListenNew = true;
} else if(send_status != sst_receiving)
break;
Expand Down
4 changes: 2 additions & 2 deletions non_catalog_apps/tpms_receiver/protocols/tpms_generic.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,9 @@ SubGhzProtocolStatus tpms_block_generic_serialize(
}

//DATE AGE set
FuriHalRtcDateTime curr_dt;
DateTime curr_dt;
furi_hal_rtc_get_datetime(&curr_dt);
uint32_t curr_ts = furi_hal_rtc_datetime_to_timestamp(&curr_dt);
uint32_t curr_ts = datetime_datetime_to_timestamp(&curr_dt);

temp_data = curr_ts;
if(!flipper_format_write_uint32(flipper_format, "Ts", &temp_data, 1)) {
Expand Down
8 changes: 4 additions & 4 deletions non_catalog_apps/tpms_receiver/views/tpms_receiver_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ void tpms_view_receiver_info_update(TPMSReceiverInfo* tpms_receiver_info, Flippe

tpms_block_generic_deserialize(model->generic, fff);

FuriHalRtcDateTime curr_dt;
DateTime curr_dt;
furi_hal_rtc_get_datetime(&curr_dt);
model->curr_ts = furi_hal_rtc_datetime_to_timestamp(&curr_dt);
model->curr_ts = datetime_datetime_to_timestamp(&curr_dt);
},
true);
}
Expand Down Expand Up @@ -172,9 +172,9 @@ static void tpms_view_receiver_info_timer(void* context) {
tpms_receiver_info->view,
TPMSReceiverInfoModel * model,
{
FuriHalRtcDateTime curr_dt;
DateTime curr_dt;
furi_hal_rtc_get_datetime(&curr_dt);
model->curr_ts = furi_hal_rtc_datetime_to_timestamp(&curr_dt);
model->curr_ts = datetime_datetime_to_timestamp(&curr_dt);
},
true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ void ublox_text_input_callback(void* context) {
}

FuriString* ublox_scene_enter_file_name_get_timename() {
FuriHalRtcDateTime datetime;
DateTime datetime;
furi_hal_rtc_get_datetime(&datetime);
FuriString* s = furi_string_alloc();

Expand Down
2 changes: 1 addition & 1 deletion non_catalog_apps/ublox/scenes/ublox_scene_sync_time.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ bool ublox_scene_sync_time_on_event(void* context, SceneManagerEvent event) {
// We don't have a timezone (or even UTC offset) in the
// RTC, so we can only update the minute and second---not
// even the date.
FuriHalRtcDateTime datetime;
DateTime datetime;
furi_hal_rtc_get_datetime(&datetime);
datetime.minute = (ublox->nav_timeutc).min;
datetime.second = (ublox->nav_timeutc).sec;
Expand Down
2 changes: 1 addition & 1 deletion non_catalog_apps/ublox/views/data_display_view.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ static void data_display_draw_callback(Canvas* canvas, void* model) {
canvas_set_font(canvas, FontPrimary);
canvas_draw_str(canvas, 0, 48, "Time:");

FuriHalRtcDateTime datetime;
DateTime datetime;
furi_hal_rtc_get_datetime(&datetime);
locale_format_time(s, &datetime, locale_get_time_format(), false);

Expand Down
2 changes: 1 addition & 1 deletion non_catalog_apps/wiegand/scenes/wiegand_save.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ void wiegand_save_scene_on_enter(void* context) {
App* app = context;
text_input_reset(app->text_input);

FuriHalRtcDateTime datetime;
DateTime datetime;
furi_hal_rtc_get_datetime(&datetime);
snprintf(
app->file_name,
Expand Down
2 changes: 1 addition & 1 deletion non_catalog_apps/wiegand/scenes/wiegand_scan.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ static void wiegand_stop_scan(void* context) {
static void wiegand_scan_found(void* context) {
App* app = context;

FuriHalRtcDateTime datetime;
DateTime datetime;
furi_hal_rtc_get_datetime(&datetime);
snprintf(
app->file_name,
Expand Down

0 comments on commit d8becee

Please sign in to comment.