Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/ClusterM/flipperzero-firmware.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorあく <alleteam@gmail.com>2021-12-15 01:39:59 +0300
committerGitHub <noreply@github.com>2021-12-15 01:39:59 +0300
commit6579368053a0572d1fff38ca3a91ab209df1a1d2 (patch)
treefe32d41301876edee2ef3af6002b2d005b42dbc2 /applications/cli
parent965067b5bd7fb3fbb77d0459cc9ea10492168ad7 (diff)
[FL-1818] System setting and debug options. RTC HAL refactoring. (#902)
* FuriHal: RTC API refactoring. System Setting application. FuriCore: adjustable log levels. Minor code cleanup. * Storage: change logging levels for internal storage. * FuriCore: fix broken trace logging level
Diffstat (limited to 'applications/cli')
-rw-r--r--applications/cli/cli_commands.c76
1 files changed, 33 insertions, 43 deletions
diff --git a/applications/cli/cli_commands.c b/applications/cli/cli_commands.c
index c3e51656..7f194220 100644
--- a/applications/cli/cli_commands.c
+++ b/applications/cli/cli_commands.c
@@ -2,7 +2,6 @@
#include <furi-hal.h>
#include <furi-hal-gpio.h>
#include <furi-hal-info.h>
-#include <rtc.h>
#include <task-control-block.h>
#include <time.h>
#include <notification/notification-messages.h>
@@ -58,46 +57,40 @@ void cli_command_help(Cli* cli, string_t args, void* context) {
}
void cli_command_date(Cli* cli, string_t args, void* context) {
- RTC_TimeTypeDef time;
- RTC_DateTypeDef date;
+ FuriHalRtcDateTime datetime = {0};
if(string_size(args) > 0) {
- uint16_t Hours, Minutes, Seconds, Month, Date, Year, WeekDay;
+ uint16_t hours, minutes, seconds, month, day, year, weekday;
int ret = sscanf(
string_get_cstr(args),
"%hu:%hu:%hu %hu-%hu-%hu %hu",
- &Hours,
- &Minutes,
- &Seconds,
- &Month,
- &Date,
- &Year,
- &WeekDay);
+ &hours,
+ &minutes,
+ &seconds,
+ &month,
+ &day,
+ &year,
+ &weekday);
if(ret == 7) {
- time.Hours = Hours;
- time.Minutes = Minutes;
- time.Seconds = Seconds;
- time.DayLightSaving = RTC_DAYLIGHTSAVING_NONE;
- time.StoreOperation = RTC_STOREOPERATION_RESET;
- date.WeekDay = WeekDay;
- date.Month = Month;
- date.Date = Date;
- date.Year = Year - 2000;
- HAL_RTC_SetTime(&hrtc, &time, RTC_FORMAT_BIN);
- HAL_RTC_SetDate(&hrtc, &date, RTC_FORMAT_BIN);
-
+ datetime.hour = hours;
+ datetime.minute = minutes;
+ datetime.second = seconds;
+ datetime.weekday = weekday;
+ datetime.month = month;
+ datetime.day = day;
+ datetime.year = year;
+ furi_hal_rtc_set_datetime(&datetime);
// Verification
- HAL_RTC_GetTime(&hrtc, &time, RTC_FORMAT_BIN);
- HAL_RTC_GetDate(&hrtc, &date, RTC_FORMAT_BIN);
+ furi_hal_rtc_get_datetime(&datetime);
printf(
"New time is: %.2d:%.2d:%.2d %.2d-%.2d-%.2d %d",
- time.Hours,
- time.Minutes,
- time.Seconds,
- date.Month,
- date.Date,
- 2000 + date.Year,
- date.WeekDay);
+ datetime.hour,
+ datetime.minute,
+ datetime.second,
+ datetime.month,
+ datetime.day,
+ datetime.year,
+ datetime.weekday);
} else {
printf(
"Invalid time format, use `hh:mm:ss MM-DD-YYYY WD`. sscanf %d %s",
@@ -106,19 +99,16 @@ void cli_command_date(Cli* cli, string_t args, void* context) {
return;
}
} else {
- // TODO add get_datetime to core, not use HAL here
- // READ ORDER MATTERS! Time then date.
- HAL_RTC_GetTime(&hrtc, &time, RTC_FORMAT_BIN);
- HAL_RTC_GetDate(&hrtc, &date, RTC_FORMAT_BIN);
+ furi_hal_rtc_get_datetime(&datetime);
printf(
"%.2d:%.2d:%.2d %.2d-%.2d-%.2d %d",
- time.Hours,
- time.Minutes,
- time.Seconds,
- date.Month,
- date.Date,
- 2000 + date.Year,
- date.WeekDay);
+ datetime.hour,
+ datetime.minute,
+ datetime.second,
+ datetime.month,
+ datetime.day,
+ datetime.year,
+ datetime.weekday);
}
}