[FL-3024] Locale settings (#2137)
* Locale settings * Time/date format fix * Locale: add docs, enums for HAL, cleanup. Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
entry,status,name,type,params
|
||||
Version,+,11.0,,
|
||||
Version,+,11.1,,
|
||||
Header,+,applications/services/bt/bt_service/bt.h,,
|
||||
Header,+,applications/services/cli/cli.h,,
|
||||
Header,+,applications/services/cli/cli_vcp.h,,
|
||||
@@ -29,6 +29,7 @@ Header,+,applications/services/gui/view_dispatcher.h,,
|
||||
Header,+,applications/services/gui/view_stack.h,,
|
||||
Header,+,applications/services/input/input.h,,
|
||||
Header,+,applications/services/loader/loader.h,,
|
||||
Header,+,applications/services/locale/locale.h,,
|
||||
Header,+,applications/services/notification/notification.h,,
|
||||
Header,+,applications/services/notification/notification_messages.h,,
|
||||
Header,+,applications/services/power/power_service/power.h,,
|
||||
@@ -1265,6 +1266,9 @@ Function,+,furi_hal_rtc_get_boot_mode,FuriHalRtcBootMode,
|
||||
Function,+,furi_hal_rtc_get_datetime,void,FuriHalRtcDateTime*
|
||||
Function,+,furi_hal_rtc_get_fault_data,uint32_t,
|
||||
Function,+,furi_hal_rtc_get_heap_track_mode,FuriHalRtcHeapTrackMode,
|
||||
Function,+,furi_hal_rtc_get_locale_dateformat,FuriHalRtcLocaleDateFormat,
|
||||
Function,+,furi_hal_rtc_get_locale_timeformat,FuriHalRtcLocaleTimeFormat,
|
||||
Function,+,furi_hal_rtc_get_locale_units,FuriHalRtcLocaleUnits,
|
||||
Function,+,furi_hal_rtc_get_log_level,uint8_t,
|
||||
Function,+,furi_hal_rtc_get_pin_fails,uint32_t,
|
||||
Function,+,furi_hal_rtc_get_register,uint32_t,FuriHalRtcRegister
|
||||
@@ -1278,6 +1282,9 @@ Function,+,furi_hal_rtc_set_datetime,void,FuriHalRtcDateTime*
|
||||
Function,+,furi_hal_rtc_set_fault_data,void,uint32_t
|
||||
Function,+,furi_hal_rtc_set_flag,void,FuriHalRtcFlag
|
||||
Function,+,furi_hal_rtc_set_heap_track_mode,void,FuriHalRtcHeapTrackMode
|
||||
Function,+,furi_hal_rtc_set_locale_dateformat,void,FuriHalRtcLocaleDateFormat
|
||||
Function,+,furi_hal_rtc_set_locale_timeformat,void,FuriHalRtcLocaleTimeFormat
|
||||
Function,+,furi_hal_rtc_set_locale_units,void,FuriHalRtcLocaleUnits
|
||||
Function,+,furi_hal_rtc_set_log_level,void,uint8_t
|
||||
Function,+,furi_hal_rtc_set_pin_fails,void,uint32_t
|
||||
Function,+,furi_hal_rtc_set_register,void,"FuriHalRtcRegister, uint32_t"
|
||||
@@ -1736,6 +1743,16 @@ Function,+,loader_update_menu,void,
|
||||
Function,+,loading_alloc,Loading*,
|
||||
Function,+,loading_free,void,Loading*
|
||||
Function,+,loading_get_view,View*,Loading*
|
||||
Function,+,locale_celsius_to_fahrenheit,float,float
|
||||
Function,+,locale_fahrenheit_to_celsius,float,float
|
||||
Function,+,locale_format_date,void,"FuriString*, const FuriHalRtcDateTime*, const LocaleDateFormat, const char*"
|
||||
Function,+,locale_format_time,void,"FuriString*, const FuriHalRtcDateTime*, const LocaleTimeFormat, const _Bool"
|
||||
Function,+,locale_get_date_format,LocaleDateFormat,
|
||||
Function,+,locale_get_measurement_unit,LocaleMeasurementUnits,
|
||||
Function,+,locale_get_time_format,LocaleTimeFormat,
|
||||
Function,+,locale_set_date_format,void,LocaleDateFormat
|
||||
Function,+,locale_set_measurement_unit,void,LocaleMeasurementUnits
|
||||
Function,+,locale_set_time_format,void,LocaleTimeFormat
|
||||
Function,-,localtime,tm*,const time_t*
|
||||
Function,-,localtime_r,tm*,"const time_t*, tm*"
|
||||
Function,-,log,double,double
|
||||
|
|
@@ -29,12 +29,15 @@ typedef struct {
|
||||
uint8_t log_level : 4;
|
||||
uint8_t log_reserved : 4;
|
||||
uint8_t flags;
|
||||
uint8_t boot_mode : 4;
|
||||
uint8_t heap_track_mode : 2;
|
||||
uint16_t reserved : 10;
|
||||
} DeveloperReg;
|
||||
FuriHalRtcBootMode boot_mode : 4;
|
||||
FuriHalRtcHeapTrackMode heap_track_mode : 2;
|
||||
FuriHalRtcLocaleUnits locale_units : 1;
|
||||
FuriHalRtcLocaleTimeFormat locale_timeformat : 1;
|
||||
FuriHalRtcLocaleDateFormat locale_dateformat : 2;
|
||||
uint8_t reserved : 6;
|
||||
} SystemReg;
|
||||
|
||||
_Static_assert(sizeof(DeveloperReg) == 4, "DeveloperReg size mismatch");
|
||||
_Static_assert(sizeof(SystemReg) == 4, "SystemReg size mismatch");
|
||||
|
||||
#define FURI_HAL_RTC_SECONDS_PER_MINUTE 60
|
||||
#define FURI_HAL_RTC_SECONDS_PER_HOUR (FURI_HAL_RTC_SECONDS_PER_MINUTE * 60)
|
||||
@@ -172,7 +175,7 @@ void furi_hal_rtc_set_register(FuriHalRtcRegister reg, uint32_t value) {
|
||||
|
||||
void furi_hal_rtc_set_log_level(uint8_t level) {
|
||||
uint32_t data_reg = furi_hal_rtc_get_register(FuriHalRtcRegisterSystem);
|
||||
DeveloperReg* data = (DeveloperReg*)&data_reg;
|
||||
SystemReg* data = (SystemReg*)&data_reg;
|
||||
data->log_level = level;
|
||||
furi_hal_rtc_set_register(FuriHalRtcRegisterSystem, data_reg);
|
||||
furi_log_set_level(level);
|
||||
@@ -180,13 +183,13 @@ void furi_hal_rtc_set_log_level(uint8_t level) {
|
||||
|
||||
uint8_t furi_hal_rtc_get_log_level() {
|
||||
uint32_t data_reg = furi_hal_rtc_get_register(FuriHalRtcRegisterSystem);
|
||||
DeveloperReg* data = (DeveloperReg*)&data_reg;
|
||||
SystemReg* data = (SystemReg*)&data_reg;
|
||||
return data->log_level;
|
||||
}
|
||||
|
||||
void furi_hal_rtc_set_flag(FuriHalRtcFlag flag) {
|
||||
uint32_t data_reg = furi_hal_rtc_get_register(FuriHalRtcRegisterSystem);
|
||||
DeveloperReg* data = (DeveloperReg*)&data_reg;
|
||||
SystemReg* data = (SystemReg*)&data_reg;
|
||||
data->flags |= flag;
|
||||
furi_hal_rtc_set_register(FuriHalRtcRegisterSystem, data_reg);
|
||||
|
||||
@@ -197,7 +200,7 @@ void furi_hal_rtc_set_flag(FuriHalRtcFlag flag) {
|
||||
|
||||
void furi_hal_rtc_reset_flag(FuriHalRtcFlag flag) {
|
||||
uint32_t data_reg = furi_hal_rtc_get_register(FuriHalRtcRegisterSystem);
|
||||
DeveloperReg* data = (DeveloperReg*)&data_reg;
|
||||
SystemReg* data = (SystemReg*)&data_reg;
|
||||
data->flags &= ~flag;
|
||||
furi_hal_rtc_set_register(FuriHalRtcRegisterSystem, data_reg);
|
||||
|
||||
@@ -208,34 +211,73 @@ void furi_hal_rtc_reset_flag(FuriHalRtcFlag flag) {
|
||||
|
||||
bool furi_hal_rtc_is_flag_set(FuriHalRtcFlag flag) {
|
||||
uint32_t data_reg = furi_hal_rtc_get_register(FuriHalRtcRegisterSystem);
|
||||
DeveloperReg* data = (DeveloperReg*)&data_reg;
|
||||
SystemReg* data = (SystemReg*)&data_reg;
|
||||
return data->flags & flag;
|
||||
}
|
||||
|
||||
void furi_hal_rtc_set_boot_mode(FuriHalRtcBootMode mode) {
|
||||
uint32_t data_reg = furi_hal_rtc_get_register(FuriHalRtcRegisterSystem);
|
||||
DeveloperReg* data = (DeveloperReg*)&data_reg;
|
||||
SystemReg* data = (SystemReg*)&data_reg;
|
||||
data->boot_mode = mode;
|
||||
furi_hal_rtc_set_register(FuriHalRtcRegisterSystem, data_reg);
|
||||
}
|
||||
|
||||
FuriHalRtcBootMode furi_hal_rtc_get_boot_mode() {
|
||||
uint32_t data_reg = furi_hal_rtc_get_register(FuriHalRtcRegisterSystem);
|
||||
DeveloperReg* data = (DeveloperReg*)&data_reg;
|
||||
return (FuriHalRtcBootMode)data->boot_mode;
|
||||
SystemReg* data = (SystemReg*)&data_reg;
|
||||
return data->boot_mode;
|
||||
}
|
||||
|
||||
void furi_hal_rtc_set_heap_track_mode(FuriHalRtcHeapTrackMode mode) {
|
||||
uint32_t data_reg = furi_hal_rtc_get_register(FuriHalRtcRegisterSystem);
|
||||
DeveloperReg* data = (DeveloperReg*)&data_reg;
|
||||
SystemReg* data = (SystemReg*)&data_reg;
|
||||
data->heap_track_mode = mode;
|
||||
furi_hal_rtc_set_register(FuriHalRtcRegisterSystem, data_reg);
|
||||
}
|
||||
|
||||
FuriHalRtcHeapTrackMode furi_hal_rtc_get_heap_track_mode() {
|
||||
uint32_t data_reg = furi_hal_rtc_get_register(FuriHalRtcRegisterSystem);
|
||||
DeveloperReg* data = (DeveloperReg*)&data_reg;
|
||||
return (FuriHalRtcHeapTrackMode)data->heap_track_mode;
|
||||
SystemReg* data = (SystemReg*)&data_reg;
|
||||
return data->heap_track_mode;
|
||||
}
|
||||
|
||||
void furi_hal_rtc_set_locale_units(FuriHalRtcLocaleUnits value) {
|
||||
uint32_t data_reg = furi_hal_rtc_get_register(FuriHalRtcRegisterSystem);
|
||||
SystemReg* data = (SystemReg*)&data_reg;
|
||||
data->locale_units = value;
|
||||
furi_hal_rtc_set_register(FuriHalRtcRegisterSystem, data_reg);
|
||||
}
|
||||
|
||||
FuriHalRtcLocaleUnits furi_hal_rtc_get_locale_units() {
|
||||
uint32_t data_reg = furi_hal_rtc_get_register(FuriHalRtcRegisterSystem);
|
||||
SystemReg* data = (SystemReg*)&data_reg;
|
||||
return data->locale_units;
|
||||
}
|
||||
|
||||
void furi_hal_rtc_set_locale_timeformat(FuriHalRtcLocaleTimeFormat value) {
|
||||
uint32_t data_reg = furi_hal_rtc_get_register(FuriHalRtcRegisterSystem);
|
||||
SystemReg* data = (SystemReg*)&data_reg;
|
||||
data->locale_timeformat = value;
|
||||
furi_hal_rtc_set_register(FuriHalRtcRegisterSystem, data_reg);
|
||||
}
|
||||
|
||||
FuriHalRtcLocaleTimeFormat furi_hal_rtc_get_locale_timeformat() {
|
||||
uint32_t data_reg = furi_hal_rtc_get_register(FuriHalRtcRegisterSystem);
|
||||
SystemReg* data = (SystemReg*)&data_reg;
|
||||
return data->locale_timeformat;
|
||||
}
|
||||
|
||||
void furi_hal_rtc_set_locale_dateformat(FuriHalRtcLocaleDateFormat value) {
|
||||
uint32_t data_reg = furi_hal_rtc_get_register(FuriHalRtcRegisterSystem);
|
||||
SystemReg* data = (SystemReg*)&data_reg;
|
||||
data->locale_dateformat = value;
|
||||
furi_hal_rtc_set_register(FuriHalRtcRegisterSystem, data_reg);
|
||||
}
|
||||
|
||||
FuriHalRtcLocaleDateFormat furi_hal_rtc_get_locale_dateformat() {
|
||||
uint32_t data_reg = furi_hal_rtc_get_register(FuriHalRtcRegisterSystem);
|
||||
SystemReg* data = (SystemReg*)&data_reg;
|
||||
return data->locale_dateformat;
|
||||
}
|
||||
|
||||
void furi_hal_rtc_set_datetime(FuriHalRtcDateTime* datetime) {
|
||||
|
Reference in New Issue
Block a user