[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:
Nikolay Minaylov
2022-12-19 12:38:20 +03:00
committed by GitHub
parent 2dea6969fe
commit f10e82c64d
10 changed files with 636 additions and 19 deletions

View File

@@ -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
1 entry status name type params
2 Version + 11.0 11.1
3 Header + applications/services/bt/bt_service/bt.h
4 Header + applications/services/cli/cli.h
5 Header + applications/services/cli/cli_vcp.h
29 Header + applications/services/gui/view_stack.h
30 Header + applications/services/input/input.h
31 Header + applications/services/loader/loader.h
32 Header + applications/services/locale/locale.h
33 Header + applications/services/notification/notification.h
34 Header + applications/services/notification/notification_messages.h
35 Header + applications/services/power/power_service/power.h
1266 Function + furi_hal_rtc_get_datetime void FuriHalRtcDateTime*
1267 Function + furi_hal_rtc_get_fault_data uint32_t
1268 Function + furi_hal_rtc_get_heap_track_mode FuriHalRtcHeapTrackMode
1269 Function + furi_hal_rtc_get_locale_dateformat FuriHalRtcLocaleDateFormat
1270 Function + furi_hal_rtc_get_locale_timeformat FuriHalRtcLocaleTimeFormat
1271 Function + furi_hal_rtc_get_locale_units FuriHalRtcLocaleUnits
1272 Function + furi_hal_rtc_get_log_level uint8_t
1273 Function + furi_hal_rtc_get_pin_fails uint32_t
1274 Function + furi_hal_rtc_get_register uint32_t FuriHalRtcRegister
1282 Function + furi_hal_rtc_set_fault_data void uint32_t
1283 Function + furi_hal_rtc_set_flag void FuriHalRtcFlag
1284 Function + furi_hal_rtc_set_heap_track_mode void FuriHalRtcHeapTrackMode
1285 Function + furi_hal_rtc_set_locale_dateformat void FuriHalRtcLocaleDateFormat
1286 Function + furi_hal_rtc_set_locale_timeformat void FuriHalRtcLocaleTimeFormat
1287 Function + furi_hal_rtc_set_locale_units void FuriHalRtcLocaleUnits
1288 Function + furi_hal_rtc_set_log_level void uint8_t
1289 Function + furi_hal_rtc_set_pin_fails void uint32_t
1290 Function + furi_hal_rtc_set_register void FuriHalRtcRegister, uint32_t
1743 Function + loading_alloc Loading*
1744 Function + loading_free void Loading*
1745 Function + loading_get_view View* Loading*
1746 Function + locale_celsius_to_fahrenheit float float
1747 Function + locale_fahrenheit_to_celsius float float
1748 Function + locale_format_date void FuriString*, const FuriHalRtcDateTime*, const LocaleDateFormat, const char*
1749 Function + locale_format_time void FuriString*, const FuriHalRtcDateTime*, const LocaleTimeFormat, const _Bool
1750 Function + locale_get_date_format LocaleDateFormat
1751 Function + locale_get_measurement_unit LocaleMeasurementUnits
1752 Function + locale_get_time_format LocaleTimeFormat
1753 Function + locale_set_date_format void LocaleDateFormat
1754 Function + locale_set_measurement_unit void LocaleMeasurementUnits
1755 Function + locale_set_time_format void LocaleTimeFormat
1756 Function - localtime tm* const time_t*
1757 Function - localtime_r tm* const time_t*, tm*
1758 Function - log double double

View File

@@ -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) {