Clock: 12 hour "midnight format" (#341)

* Clock: 12 hour midnight format

- References #317 and adds the options `12:XX` and `00:XX` in `Settings > System > Midnight Format` to display the preferred clock format past midnight on all clocks (Desktop, Main Menu MNTM style, Lock screen and Nightstand clock app). "12:30 AM" -> "00:30" OR "12:30".

* 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.

* clock app external

* Moved midnight format setting into new `Interface > General`

* Update applications/main/momentum_app/scenes/momentum_app_scene_interface_general.c

* Update changelog

---------

Co-authored-by: Willy-JL <49810075+Willy-JL@users.noreply.github.com>
This commit is contained in:
Alexander Bays
2025-03-01 22:20:38 -06:00
committed by GitHub
parent a6c8f81545
commit adc66d78da
9 changed files with 87 additions and 7 deletions

View File

@@ -25,6 +25,7 @@
- OFW: Infrared: Universal IR signal selection (by @portasynthinca3)
- OFW: NFC: Disney Infinity KDF plugin (by @bettse)
- Archive: Add item count to directory info scene (#378 by @956MB)
- Clock: 12 hour "midnight format" in Momentum Settings (#341 by @956MB)
- UL: Input: Vibro on Button press option (by @Dmitry422)
- Desktop:
- UL: Option to prevent Auto Lock when connected to USB/RPC (by @Dmitry422)

View File

@@ -10,6 +10,7 @@ ADD_SCENE(momentum_app, interface_mainmenu_style, InterfaceMainmenuStyle)
ADD_SCENE(momentum_app, interface_lockscreen, InterfaceLockscreen)
ADD_SCENE(momentum_app, interface_statusbar, InterfaceStatusbar)
ADD_SCENE(momentum_app, interface_filebrowser, InterfaceFilebrowser)
ADD_SCENE(momentum_app, interface_general, InterfaceGeneral)
ADD_SCENE(momentum_app, protocols, Protocols)
ADD_SCENE(momentum_app, protocols_freqs, ProtocolsFreqs)
ADD_SCENE(momentum_app, protocols_freqs_static, ProtocolsFreqsStatic)

View File

@@ -6,6 +6,7 @@ enum VarItemListIndex {
VarItemListIndexLockscreen,
VarItemListIndexStatusbar,
VarItemListIndexFileBrowser,
VarItemListIndexGeneral,
};
void momentum_app_scene_interface_var_item_list_callback(void* context, uint32_t index) {
@@ -33,6 +34,9 @@ void momentum_app_scene_interface_on_enter(void* context) {
item = variable_item_list_add(var_item_list, "File Browser", 0, NULL, app);
variable_item_set_current_value_text(item, ">");
item = variable_item_list_add(var_item_list, "General", 0, NULL, app);
variable_item_set_current_value_text(item, ">");
variable_item_list_set_enter_callback(
var_item_list, momentum_app_scene_interface_var_item_list_callback, app);
@@ -76,6 +80,10 @@ bool momentum_app_scene_interface_on_event(void* context, SceneManagerEvent even
app->scene_manager, MomentumAppSceneInterfaceFilebrowser, 0);
scene_manager_next_scene(app->scene_manager, MomentumAppSceneInterfaceFilebrowser);
break;
case VarItemListIndexGeneral:
scene_manager_set_scene_state(app->scene_manager, MomentumAppSceneInterfaceGeneral, 0);
scene_manager_next_scene(app->scene_manager, MomentumAppSceneInterfaceGeneral);
break;
default:
break;
}

View File

@@ -0,0 +1,61 @@
#include "../momentum_app.h"
enum VarItemListIndex {
VarItemListIndexMidnightFormat,
};
void momentum_app_scene_interface_general_var_item_list_callback(void* context, uint32_t index) {
MomentumApp* app = context;
view_dispatcher_send_custom_event(app->view_dispatcher, index);
}
static void momentum_app_scene_interface_general_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:00");
momentum_settings.midnight_format_00 = value;
app->save_settings = true;
}
void momentum_app_scene_interface_general_on_enter(void* context) {
MomentumApp* app = context;
VariableItemList* var_item_list = app->var_item_list;
VariableItem* item;
item = variable_item_list_add(
var_item_list,
"Clock Midnight Format",
2,
momentum_app_scene_interface_general_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_set_enter_callback(
var_item_list, momentum_app_scene_interface_general_var_item_list_callback, app);
variable_item_list_set_selected_item(
var_item_list,
scene_manager_get_scene_state(app->scene_manager, MomentumAppSceneInterfaceGeneral));
view_dispatcher_switch_to_view(app->view_dispatcher, MomentumAppViewVarItemList);
}
bool momentum_app_scene_interface_general_on_event(void* context, SceneManagerEvent event) {
MomentumApp* app = context;
bool consumed = false;
if(event.type == SceneManagerEventTypeCustom) {
scene_manager_set_scene_state(
app->scene_manager, MomentumAppSceneInterfaceGeneral, event.event);
consumed = true;
}
return consumed;
}
void momentum_app_scene_interface_general_on_exit(void* context) {
MomentumApp* app = context;
variable_item_list_reset(app->var_item_list);
}

View File

@@ -96,7 +96,7 @@ static void desktop_clock_draw_callback(Canvas* canvas, void* context) {
hour -= 12;
}
if(hour == 0) {
hour = 12;
hour = momentum_settings.midnight_format_00 ? 0 : 12;
}
}

View File

@@ -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)
@@ -79,6 +78,9 @@ void desktop_view_locked_draw_lockscreen(Canvas* canvas, void* m) {
} else {
pm = datetime.hour > 12;
snprintf(meridian_str, 3, datetime.hour >= 12 ? "PM" : "AM");
if(datetime.hour == 0) {
datetime.hour = momentum_settings.midnight_format_00 ? 0 : 12;
}
}
snprintf(time_str, 9, "%.2d:%.2d", pm ? datetime.hour - 12 : datetime.hour, datetime.minute);
snprintf(second_str, 5, ":%.2d", datetime.second);

View File

@@ -1,5 +1,6 @@
#include "menu.h"
#include "locale/locale.h"
#include <gui/elements.h>
#include <assets_icons.h>
#include <gui/icon_i.h>
@@ -398,11 +399,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 = 12;
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];

View File

@@ -35,6 +35,7 @@ MomentumSettings momentum_settings = {
.dark_mode = false, // OFF
.rgb_backlight = false, // OFF
.butthurt_timer = 21600, // 6 H
.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
@@ -105,6 +106,7 @@ static const struct {
{setting_bool(dark_mode)},
{setting_bool(rgb_backlight)},
{setting_uint(butthurt_timer, 0, 172800)},
{setting_bool(midnight_format_00)},
{setting_enum(spi_cc1101_handle, SpiCount)},
{setting_enum(spi_nrf24_handle, SpiCount)},
{setting_enum(uart_esp_channel, FuriHalSerialIdMax)},

View File

@@ -92,6 +92,7 @@ typedef struct {
bool dark_mode;
bool rgb_backlight;
uint32_t butthurt_timer;
bool midnight_format_00;
SpiHandle spi_cc1101_handle;
SpiHandle spi_nrf24_handle;
FuriHalSerialId uart_esp_channel;