mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-07-01 22:08:55 -07:00
Fix: Move midnight format setting out of furi_rtc
- Also felt like the midnight format setting was too out of place in `MNTM > Interface` with the 5 other submenu entries, so I put it in Misc for now.
This commit is contained in:
@@ -6,6 +6,7 @@ enum VarItemListIndex {
|
||||
VarItemListIndexSpoof,
|
||||
VarItemListIndexVgm,
|
||||
VarItemListIndexChargeCap,
|
||||
VarItemListIndexMidnightFormat,
|
||||
VarItemListIndexShowMomentumIntro,
|
||||
};
|
||||
|
||||
@@ -25,6 +26,14 @@ static void momentum_app_scene_misc_charge_cap_changed(VariableItem* item) {
|
||||
app->save_settings = true;
|
||||
}
|
||||
|
||||
static void momentum_app_scene_interface_midnight_format_changed(VariableItem* item) {
|
||||
MomentumApp* app = variable_item_get_context(item);
|
||||
bool value = variable_item_get_current_value_index(item);
|
||||
variable_item_set_current_value_text(item, value ? "00:XX" : "12:XX");
|
||||
momentum_settings.midnight_format_00 = value;
|
||||
app->save_settings = true;
|
||||
}
|
||||
|
||||
void momentum_app_scene_misc_on_enter(void* context) {
|
||||
MomentumApp* app = context;
|
||||
VariableItemList* var_item_list = app->var_item_list;
|
||||
@@ -55,6 +64,16 @@ void momentum_app_scene_misc_on_enter(void* context) {
|
||||
variable_item_set_current_value_index(item, value_index - 1);
|
||||
variable_item_set_current_value_text(item, cap_str);
|
||||
|
||||
item = variable_item_list_add(
|
||||
var_item_list,
|
||||
"Clock Midnight Format",
|
||||
2,
|
||||
momentum_app_scene_interface_midnight_format_changed,
|
||||
app);
|
||||
variable_item_set_current_value_index(item, momentum_settings.midnight_format_00);
|
||||
variable_item_set_current_value_text(
|
||||
item, momentum_settings.midnight_format_00 ? "00:XX" : "12:XX");
|
||||
|
||||
variable_item_list_add(var_item_list, "Show Momentum Intro", 0, NULL, app);
|
||||
|
||||
variable_item_list_set_enter_callback(
|
||||
|
||||
@@ -58,13 +58,10 @@ static void desktop_clock_update(Desktop* desktop) {
|
||||
DateTime curr_dt;
|
||||
furi_hal_rtc_get_datetime(&curr_dt);
|
||||
bool time_format_12 = locale_get_time_format() == LocaleTimeFormat12h;
|
||||
LocaleMidnightFormat midnight_format = locale_get_midnight_format();
|
||||
|
||||
if(desktop->clock.hour != curr_dt.hour || desktop->clock.minute != curr_dt.minute ||
|
||||
desktop->clock.format_12 != time_format_12 ||
|
||||
desktop->clock.midnight_format != midnight_format) {
|
||||
desktop->clock.format_12 != time_format_12) {
|
||||
desktop->clock.format_12 = time_format_12;
|
||||
desktop->clock.midnight_format = midnight_format;
|
||||
desktop->clock.hour = curr_dt.hour;
|
||||
desktop->clock.minute = curr_dt.minute;
|
||||
view_port_update(desktop->clock_viewport);
|
||||
@@ -99,7 +96,7 @@ static void desktop_clock_draw_callback(Canvas* canvas, void* context) {
|
||||
hour -= 12;
|
||||
}
|
||||
if(hour == 0) {
|
||||
hour = (desktop->clock.midnight_format == LocaleMidnightFormatZero) ? 0 : 12;
|
||||
hour = momentum_settings.midnight_format_00 ? 0 : 12;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
#include "desktop_keybinds.h"
|
||||
|
||||
#include "animations/animation_manager.h"
|
||||
#include "locale/locale.h"
|
||||
#include "views/desktop_view_pin_timeout.h"
|
||||
#include "views/desktop_view_pin_input.h"
|
||||
#include "views/desktop_view_locked.h"
|
||||
@@ -41,7 +40,6 @@ typedef struct {
|
||||
uint8_t hour;
|
||||
uint8_t minute;
|
||||
bool format_12; // 1 - 12 hour, 0 - 24H
|
||||
LocaleMidnightFormat midnight_format;
|
||||
} DesktopClock;
|
||||
|
||||
struct Desktop {
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
#include <locale/locale.h>
|
||||
#include <momentum/momentum.h>
|
||||
|
||||
#include "../desktop_i.h"
|
||||
#include "desktop_view_locked.h"
|
||||
|
||||
#define COVER_MOVING_INTERVAL_MS (50)
|
||||
@@ -44,7 +43,6 @@ typedef struct {
|
||||
bool pin_locked;
|
||||
int8_t cover_offset;
|
||||
DesktopViewLockedState view_state;
|
||||
LocaleMidnightFormat midnight_format;
|
||||
} DesktopViewLockedModel;
|
||||
|
||||
void desktop_view_locked_set_callback(
|
||||
@@ -81,7 +79,7 @@ void desktop_view_locked_draw_lockscreen(Canvas* canvas, void* m) {
|
||||
pm = datetime.hour > 12;
|
||||
snprintf(meridian_str, 3, datetime.hour >= 12 ? "PM" : "AM");
|
||||
if(datetime.hour == 0) {
|
||||
datetime.hour = (model->midnight_format == LocaleMidnightFormatZero) ? 0 : 12;
|
||||
datetime.hour = momentum_settings.midnight_format_00 ? 0 : 12;
|
||||
}
|
||||
}
|
||||
snprintf(time_str, 9, "%.2d:%.2d", pm ? datetime.hour - 12 : datetime.hour, datetime.minute);
|
||||
@@ -301,7 +299,6 @@ void desktop_view_locked_lock(DesktopViewLocked* locked_view, bool pin_locked) {
|
||||
furi_assert(model->view_state == DesktopViewLockedStateUnlocked);
|
||||
model->view_state = DesktopViewLockedStateLocked;
|
||||
model->pin_locked = pin_locked;
|
||||
model->midnight_format = locale_get_midnight_format();
|
||||
view_commit_model(locked_view->view, true);
|
||||
}
|
||||
|
||||
|
||||
@@ -381,14 +381,14 @@ static void menu_draw_callback(Canvas* canvas, void* _model) {
|
||||
furi_hal_rtc_get_datetime(&curr_dt);
|
||||
uint8_t hour = curr_dt.hour;
|
||||
uint8_t min = curr_dt.minute;
|
||||
if(hour > 12) {
|
||||
hour -= 12;
|
||||
}
|
||||
if(hour == 0) {
|
||||
hour = (locale_get_midnight_format() == LocaleMidnightFormatTwelve &&
|
||||
locale_get_time_format() == LocaleTimeFormat12h) ?
|
||||
12 :
|
||||
0;
|
||||
LocaleTimeFormat time_format = locale_get_time_format();
|
||||
if(time_format == LocaleTimeFormat12h) {
|
||||
if(hour > 12) {
|
||||
hour -= 12;
|
||||
}
|
||||
if(hour == 0) {
|
||||
hour = (momentum_settings.midnight_format_00 ? 0 : 12);
|
||||
}
|
||||
}
|
||||
canvas_set_font(canvas, FontSecondary);
|
||||
char clk[20];
|
||||
|
||||
@@ -18,14 +18,6 @@ void locale_set_time_format(LocaleTimeFormat format) {
|
||||
furi_hal_rtc_set_locale_timeformat((FuriHalRtcLocaleTimeFormat)format);
|
||||
}
|
||||
|
||||
LocaleMidnightFormat locale_get_midnight_format(void) {
|
||||
return (LocaleMidnightFormat)furi_hal_rtc_get_locale_midnightformat();
|
||||
}
|
||||
|
||||
void locale_set_midnight_format(LocaleMidnightFormat format) {
|
||||
furi_hal_rtc_set_locale_midnightformat((FuriHalRtcLocaleMidnightFormat)format);
|
||||
}
|
||||
|
||||
LocaleDateFormat locale_get_date_format(void) {
|
||||
return (LocaleDateFormat)furi_hal_rtc_get_locale_dateformat();
|
||||
}
|
||||
|
||||
@@ -18,11 +18,6 @@ typedef enum {
|
||||
LocaleTimeFormat12h = 1, /**< 12-hour format */
|
||||
} LocaleTimeFormat;
|
||||
|
||||
typedef enum {
|
||||
LocaleMidnightFormatTwelve = 0, /**< 12:XX format */
|
||||
LocaleMidnightFormatZero = 1, /**< 00:XX format */
|
||||
} LocaleMidnightFormat;
|
||||
|
||||
typedef enum {
|
||||
LocaleDateFormatDMY = 0, /**< Day/Month/Year */
|
||||
LocaleDateFormatMDY = 1, /**< Month/Day/Year */
|
||||
@@ -69,18 +64,6 @@ LocaleTimeFormat locale_get_time_format(void);
|
||||
*/
|
||||
void locale_set_time_format(LocaleTimeFormat format);
|
||||
|
||||
/** Get Locale midnight format
|
||||
*
|
||||
* @return The locale midnight format.
|
||||
*/
|
||||
LocaleMidnightFormat locale_get_midnight_format(void);
|
||||
|
||||
/** Set Locale midnight format
|
||||
*
|
||||
* @param[in] format The locale midnight format
|
||||
*/
|
||||
void locale_set_midnight_format(LocaleMidnightFormat format);
|
||||
|
||||
/** Format time to furi string
|
||||
*
|
||||
* @param[out] out_str The FuriString to store formatted time
|
||||
|
||||
@@ -165,22 +165,6 @@ static void time_format_changed(VariableItem* item) {
|
||||
locale_set_time_format(time_format_value[index]);
|
||||
}
|
||||
|
||||
const char* const midnight_format_text[] = {
|
||||
"12:XX",
|
||||
"00:XX",
|
||||
};
|
||||
|
||||
const uint32_t midnight_format_value[] = {
|
||||
LocaleMidnightFormatTwelve,
|
||||
LocaleMidnightFormatZero,
|
||||
};
|
||||
|
||||
static void midnight_format_changed(VariableItem* item) {
|
||||
uint8_t index = variable_item_get_current_value_index(item);
|
||||
variable_item_set_current_value_text(item, midnight_format_text[index]);
|
||||
locale_set_midnight_format(midnight_format_value[index]);
|
||||
}
|
||||
|
||||
const char* const date_format_text[] = {
|
||||
"D/M/Y",
|
||||
"M/D/Y",
|
||||
@@ -366,17 +350,6 @@ SystemSettings* system_settings_alloc(void) {
|
||||
variable_item_set_current_value_index(item, value_index);
|
||||
variable_item_set_current_value_text(item, time_format_text[value_index]);
|
||||
|
||||
item = variable_item_list_add(
|
||||
app->var_item_list,
|
||||
"Midnight Format",
|
||||
COUNT_OF(midnight_format_text),
|
||||
midnight_format_changed,
|
||||
app);
|
||||
value_index = value_index_uint32(
|
||||
locale_get_midnight_format(), midnight_format_value, COUNT_OF(midnight_format_value));
|
||||
variable_item_set_current_value_index(item, value_index);
|
||||
variable_item_set_current_value_text(item, midnight_format_text[value_index]);
|
||||
|
||||
item = variable_item_list_add(
|
||||
app->var_item_list, "Date Format", COUNT_OF(date_format_text), date_format_changed, app);
|
||||
value_index = value_index_uint32(
|
||||
|
||||
@@ -34,6 +34,7 @@ MomentumSettings momentum_settings = {
|
||||
.rgb_backlight = false, // OFF
|
||||
.butthurt_timer = 21600, // 6 H
|
||||
.charge_cap = 100, // 100%
|
||||
.midnight_format_00 = true, // 00:XX
|
||||
.spi_cc1101_handle = SpiDefault, // &furi_hal_spi_bus_handle_external
|
||||
.spi_nrf24_handle = SpiDefault, // &furi_hal_spi_bus_handle_external
|
||||
.uart_esp_channel = FuriHalSerialIdUsart, // pin 13,14
|
||||
@@ -103,6 +104,7 @@ static const struct {
|
||||
{setting_bool(rgb_backlight)},
|
||||
{setting_uint(butthurt_timer, 0, 172800)},
|
||||
{setting_uint(charge_cap, 5, 100)},
|
||||
{setting_bool(midnight_format_00)},
|
||||
{setting_enum(spi_cc1101_handle, SpiCount)},
|
||||
{setting_enum(spi_nrf24_handle, SpiCount)},
|
||||
{setting_enum(uart_esp_channel, FuriHalSerialIdMax)},
|
||||
|
||||
@@ -82,6 +82,7 @@ typedef struct {
|
||||
bool rgb_backlight;
|
||||
uint32_t butthurt_timer;
|
||||
uint32_t charge_cap;
|
||||
bool midnight_format_00;
|
||||
SpiHandle spi_cc1101_handle;
|
||||
SpiHandle spi_nrf24_handle;
|
||||
FuriHalSerialId uart_esp_channel;
|
||||
|
||||
@@ -1628,7 +1628,6 @@ Function,+,furi_hal_rtc_get_datetime,void,DateTime*
|
||||
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_midnightformat,FuriHalRtcLocaleMidnightFormat,
|
||||
Function,+,furi_hal_rtc_get_locale_timeformat,FuriHalRtcLocaleTimeFormat,
|
||||
Function,+,furi_hal_rtc_get_locale_units,FuriHalRtcLocaleUnits,
|
||||
Function,+,furi_hal_rtc_get_log_baud_rate,FuriHalRtcLogBaudRate,
|
||||
@@ -1652,7 +1651,6 @@ 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_midnightformat,void,FuriHalRtcLocaleMidnightFormat
|
||||
Function,+,furi_hal_rtc_set_locale_timeformat,void,FuriHalRtcLocaleTimeFormat
|
||||
Function,+,furi_hal_rtc_set_locale_units,void,FuriHalRtcLocaleUnits
|
||||
Function,+,furi_hal_rtc_set_log_baud_rate,void,FuriHalRtcLogBaudRate
|
||||
@@ -2349,11 +2347,9 @@ Function,+,locale_format_date,void,"FuriString*, const DateTime*, const LocaleDa
|
||||
Function,+,locale_format_time,void,"FuriString*, const DateTime*, const LocaleTimeFormat, const _Bool"
|
||||
Function,+,locale_get_date_format,LocaleDateFormat,
|
||||
Function,+,locale_get_measurement_unit,LocaleMeasurementUnits,
|
||||
Function,+,locale_get_midnight_format,LocaleMidnightFormat,
|
||||
Function,+,locale_get_time_format,LocaleTimeFormat,
|
||||
Function,+,locale_set_date_format,void,LocaleDateFormat
|
||||
Function,+,locale_set_measurement_unit,void,LocaleMeasurementUnits
|
||||
Function,+,locale_set_midnight_format,void,LocaleMidnightFormat
|
||||
Function,+,locale_set_time_format,void,LocaleTimeFormat
|
||||
Function,-,log,double,double
|
||||
Function,-,log10,double,double
|
||||
|
||||
|
@@ -31,14 +31,14 @@ typedef struct {
|
||||
uint8_t log_level : 4;
|
||||
uint8_t log_reserved : 4;
|
||||
uint8_t flags;
|
||||
FuriHalRtcBootMode boot_mode : 4;
|
||||
FuriHalRtcHeapTrackMode heap_track_mode : 2;
|
||||
FuriHalRtcLocaleUnits locale_units : 1;
|
||||
FuriHalRtcLocaleTimeFormat locale_timeformat : 1;
|
||||
FuriHalRtcLocaleMidnightFormat locale_midnightformat : 1;
|
||||
FuriHalRtcLocaleDateFormat locale_dateformat : 2;
|
||||
FuriHalRtcLogDevice log_device : 2;
|
||||
FuriHalRtcLogBaudRate log_baud_rate : 3;
|
||||
FuriHalRtcBootMode boot_mode : 4;
|
||||
FuriHalRtcHeapTrackMode heap_track_mode : 2;
|
||||
FuriHalRtcLocaleUnits locale_units : 1;
|
||||
FuriHalRtcLocaleTimeFormat locale_timeformat : 1;
|
||||
FuriHalRtcLocaleDateFormat locale_dateformat : 2;
|
||||
FuriHalRtcLogDevice log_device : 2;
|
||||
FuriHalRtcLogBaudRate log_baud_rate : 3;
|
||||
uint8_t reserved : 1;
|
||||
} SystemReg;
|
||||
|
||||
_Static_assert(sizeof(SystemReg) == 4, "SystemReg size mismatch");
|
||||
@@ -379,19 +379,6 @@ FuriHalRtcLocaleTimeFormat furi_hal_rtc_get_locale_timeformat(void) {
|
||||
return data->locale_timeformat;
|
||||
}
|
||||
|
||||
void furi_hal_rtc_set_locale_midnightformat(FuriHalRtcLocaleMidnightFormat value) {
|
||||
uint32_t data_reg = furi_hal_rtc_get_register(FuriHalRtcRegisterSystem);
|
||||
SystemReg* data = (SystemReg*)&data_reg;
|
||||
data->locale_midnightformat = value;
|
||||
furi_hal_rtc_set_register(FuriHalRtcRegisterSystem, data_reg);
|
||||
}
|
||||
|
||||
FuriHalRtcLocaleMidnightFormat furi_hal_rtc_get_locale_midnightformat(void) {
|
||||
uint32_t data_reg = furi_hal_rtc_get_register(FuriHalRtcRegisterSystem);
|
||||
SystemReg* data = (SystemReg*)&data_reg;
|
||||
return data->locale_midnightformat;
|
||||
}
|
||||
|
||||
void furi_hal_rtc_set_locale_dateformat(FuriHalRtcLocaleDateFormat value) {
|
||||
uint32_t data_reg = furi_hal_rtc_get_register(FuriHalRtcRegisterSystem);
|
||||
SystemReg* data = (SystemReg*)&data_reg;
|
||||
|
||||
@@ -65,11 +65,6 @@ typedef enum {
|
||||
FuriHalRtcLocaleTimeFormat12h = 0x1, /**< 12-hour format */
|
||||
} FuriHalRtcLocaleTimeFormat;
|
||||
|
||||
typedef enum {
|
||||
FuriHalRtcLocaleMidnightFormatTwelve = 0x0, /**< 12:XX format */
|
||||
FuriHalRtcLocaleMidnightFormatZero = 0x1, /**< 00:XX format */
|
||||
} FuriHalRtcLocaleMidnightFormat;
|
||||
|
||||
typedef enum {
|
||||
FuriHalRtcLocaleDateFormatDMY = 0x0, /**< Day/Month/Year */
|
||||
FuriHalRtcLocaleDateFormatMDY = 0x1, /**< Month/Day/Year */
|
||||
@@ -236,18 +231,6 @@ void furi_hal_rtc_set_locale_timeformat(FuriHalRtcLocaleTimeFormat value);
|
||||
*/
|
||||
FuriHalRtcLocaleTimeFormat furi_hal_rtc_get_locale_timeformat(void);
|
||||
|
||||
/** Set RTC Locale Midnight Format
|
||||
*
|
||||
* @param[in] value The RTC Locale Midnight Format
|
||||
*/
|
||||
void furi_hal_rtc_set_locale_midnightformat(FuriHalRtcLocaleMidnightFormat value);
|
||||
|
||||
/** Get RTC Locale Midnight Format
|
||||
*
|
||||
* @return The RTC Locale Midnight Format.
|
||||
*/
|
||||
FuriHalRtcLocaleMidnightFormat furi_hal_rtc_get_locale_midnightformat(void);
|
||||
|
||||
/** Set RTC Locale Date Format
|
||||
*
|
||||
* @param[in] value The RTC Locale Date Format
|
||||
|
||||
Reference in New Issue
Block a user