mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-05-12 22:58:36 -07:00
Merge branch 'dev' of https://github.com/flipperdevices/flipperzero-firmware into mntm-dev
This commit is contained in:
@@ -165,7 +165,7 @@ static void bt_cli_command_packet_rx(Cli* cli, FuriString* args, void* context)
|
||||
} while(false);
|
||||
}
|
||||
|
||||
static void bt_cli_print_usage() {
|
||||
static void bt_cli_print_usage(void) {
|
||||
printf("Usage:\r\n");
|
||||
printf("bt <cmd> <args>\r\n");
|
||||
printf("Cmd list:\r\n");
|
||||
@@ -233,6 +233,6 @@ static const FlipperAppPluginDescriptor plugin_descriptor = {
|
||||
.entry_point = &bt_cli,
|
||||
};
|
||||
|
||||
const FlipperAppPluginDescriptor* bt_cli_plugin_ep() {
|
||||
const FlipperAppPluginDescriptor* bt_cli_plugin_ep(void) {
|
||||
return &plugin_descriptor;
|
||||
}
|
||||
|
||||
@@ -138,7 +138,7 @@ static void bt_battery_level_changed_callback(const void* _event, void* context)
|
||||
}
|
||||
}
|
||||
|
||||
Bt* bt_alloc() {
|
||||
Bt* bt_alloc(void) {
|
||||
Bt* bt = malloc(sizeof(Bt));
|
||||
// Init default maximum packet size
|
||||
bt->max_packet_size = BLE_PROFILE_SERIAL_PACKET_SIZE_MAX;
|
||||
|
||||
@@ -5,7 +5,7 @@ FuriHalBleProfileBase* bt_profile_start(
|
||||
Bt* bt,
|
||||
const FuriHalBleProfileTemplate* profile_template,
|
||||
FuriHalBleProfileParams params) {
|
||||
furi_assert(bt);
|
||||
furi_check(bt);
|
||||
|
||||
// Send message
|
||||
FuriHalBleProfileBase* profile_instance = NULL;
|
||||
@@ -32,7 +32,7 @@ bool bt_profile_restore_default(Bt* bt) {
|
||||
}
|
||||
|
||||
void bt_disconnect(Bt* bt) {
|
||||
furi_assert(bt);
|
||||
furi_check(bt);
|
||||
|
||||
// Send message
|
||||
BtMessage message = {.lock = api_lock_alloc_locked(), .type = BtMessageTypeDisconnect};
|
||||
@@ -43,23 +43,23 @@ void bt_disconnect(Bt* bt) {
|
||||
}
|
||||
|
||||
void bt_set_status_changed_callback(Bt* bt, BtStatusChangedCallback callback, void* context) {
|
||||
furi_assert(bt);
|
||||
furi_check(bt);
|
||||
|
||||
bt->status_changed_cb = callback;
|
||||
bt->status_changed_ctx = context;
|
||||
}
|
||||
|
||||
void bt_forget_bonded_devices(Bt* bt) {
|
||||
furi_assert(bt);
|
||||
furi_check(bt);
|
||||
BtMessage message = {.type = BtMessageTypeForgetBondedDevices};
|
||||
furi_check(
|
||||
furi_message_queue_put(bt->message_queue, &message, FuriWaitForever) == FuriStatusOk);
|
||||
}
|
||||
|
||||
void bt_keys_storage_set_storage_path(Bt* bt, const char* keys_storage_path) {
|
||||
furi_assert(bt);
|
||||
furi_assert(bt->keys_storage);
|
||||
furi_assert(keys_storage_path);
|
||||
furi_check(bt);
|
||||
furi_check(bt->keys_storage);
|
||||
furi_check(keys_storage_path);
|
||||
|
||||
Storage* storage = furi_record_open(RECORD_STORAGE);
|
||||
FuriString* path = furi_string_alloc_set(keys_storage_path);
|
||||
@@ -72,8 +72,8 @@ void bt_keys_storage_set_storage_path(Bt* bt, const char* keys_storage_path) {
|
||||
}
|
||||
|
||||
void bt_keys_storage_set_default_path(Bt* bt) {
|
||||
furi_assert(bt);
|
||||
furi_assert(bt->keys_storage);
|
||||
furi_check(bt);
|
||||
furi_check(bt->keys_storage);
|
||||
|
||||
bt_keys_storage_set_file_path(bt->keys_storage, BT_KEYS_STORAGE_PATH);
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ static void bt_cli_wrapper(Cli* cli, FuriString* args, void* context) {
|
||||
cli_plugin_wrapper("bt_cli", 1, cli, args, context);
|
||||
}
|
||||
|
||||
void bt_on_system_start() {
|
||||
void bt_on_system_start(void) {
|
||||
Cli* cli = furi_record_open(RECORD_CLI);
|
||||
cli_add_command(cli, RECORD_BT, CliCommandFlagDefault, bt_cli_wrapper, NULL);
|
||||
furi_record_close(RECORD_CLI);
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
|
||||
#define CLI_INPUT_LEN_LIMIT 256
|
||||
|
||||
Cli* cli_alloc() {
|
||||
Cli* cli_alloc(void) {
|
||||
Cli* cli = malloc(sizeof(Cli));
|
||||
|
||||
CliCommandTree_init(cli->commands);
|
||||
@@ -31,14 +31,14 @@ Cli* cli_alloc() {
|
||||
}
|
||||
|
||||
void cli_putc(Cli* cli, char c) {
|
||||
furi_assert(cli);
|
||||
furi_check(cli);
|
||||
if(cli->session != NULL) {
|
||||
cli->session->tx((uint8_t*)&c, 1);
|
||||
}
|
||||
}
|
||||
|
||||
char cli_getc(Cli* cli) {
|
||||
furi_assert(cli);
|
||||
furi_check(cli);
|
||||
char c = 0;
|
||||
if(cli->session != NULL) {
|
||||
if(cli->session->rx((uint8_t*)&c, 1, FuriWaitForever) == 0) {
|
||||
@@ -53,14 +53,14 @@ char cli_getc(Cli* cli) {
|
||||
}
|
||||
|
||||
void cli_write(Cli* cli, const uint8_t* buffer, size_t size) {
|
||||
furi_assert(cli);
|
||||
furi_check(cli);
|
||||
if(cli->session != NULL) {
|
||||
cli->session->tx(buffer, size);
|
||||
}
|
||||
}
|
||||
|
||||
size_t cli_read(Cli* cli, uint8_t* buffer, size_t size) {
|
||||
furi_assert(cli);
|
||||
furi_check(cli);
|
||||
if(cli->session != NULL) {
|
||||
return cli->session->rx(buffer, size, FuriWaitForever);
|
||||
} else {
|
||||
@@ -69,7 +69,7 @@ size_t cli_read(Cli* cli, uint8_t* buffer, size_t size) {
|
||||
}
|
||||
|
||||
size_t cli_read_timeout(Cli* cli, uint8_t* buffer, size_t size, uint32_t timeout) {
|
||||
furi_assert(cli);
|
||||
furi_check(cli);
|
||||
if(cli->session != NULL) {
|
||||
return cli->session->rx(buffer, size, timeout);
|
||||
} else {
|
||||
@@ -78,7 +78,7 @@ size_t cli_read_timeout(Cli* cli, uint8_t* buffer, size_t size, uint32_t timeout
|
||||
}
|
||||
|
||||
bool cli_is_connected(Cli* cli) {
|
||||
furi_assert(cli);
|
||||
furi_check(cli);
|
||||
if(cli->session != NULL) {
|
||||
return (cli->session->is_connected());
|
||||
}
|
||||
@@ -86,7 +86,7 @@ bool cli_is_connected(Cli* cli) {
|
||||
}
|
||||
|
||||
bool cli_cmd_interrupt_received(Cli* cli) {
|
||||
furi_assert(cli);
|
||||
furi_check(cli);
|
||||
char c = '\0';
|
||||
if(cli_is_connected(cli)) {
|
||||
if(cli->session->rx((uint8_t*)&c, 1, 0) == 1) {
|
||||
@@ -99,14 +99,14 @@ bool cli_cmd_interrupt_received(Cli* cli) {
|
||||
}
|
||||
|
||||
void cli_print_usage(const char* cmd, const char* usage, const char* arg) {
|
||||
furi_assert(cmd);
|
||||
furi_assert(arg);
|
||||
furi_assert(usage);
|
||||
furi_check(cmd);
|
||||
furi_check(arg);
|
||||
furi_check(usage);
|
||||
|
||||
printf("%s: illegal option -- %s\r\nusage: %s %s", cmd, arg, cmd, usage);
|
||||
}
|
||||
|
||||
void cli_motd() {
|
||||
void cli_motd(void) {
|
||||
printf("\r\n"
|
||||
" _.-------.._ -,\r\n"
|
||||
" .-\"```\"--..,,_/ /`-, -, \\ \r\n"
|
||||
@@ -389,6 +389,7 @@ void cli_add_command(
|
||||
CliCommandFlag flags,
|
||||
CliCallback callback,
|
||||
void* context) {
|
||||
furi_check(cli);
|
||||
FuriString* name_str;
|
||||
name_str = furi_string_alloc_set(name);
|
||||
furi_string_trim(name_str);
|
||||
@@ -411,6 +412,7 @@ void cli_add_command(
|
||||
}
|
||||
|
||||
void cli_delete_command(Cli* cli, const char* name) {
|
||||
furi_check(cli);
|
||||
FuriString* name_str;
|
||||
name_str = furi_string_alloc_set(name);
|
||||
furi_string_trim(name_str);
|
||||
@@ -428,7 +430,7 @@ void cli_delete_command(Cli* cli, const char* name) {
|
||||
}
|
||||
|
||||
void cli_session_open(Cli* cli, void* session) {
|
||||
furi_assert(cli);
|
||||
furi_check(cli);
|
||||
|
||||
furi_check(furi_mutex_acquire(cli->mutex, FuriWaitForever) == FuriStatusOk);
|
||||
cli->session = session;
|
||||
@@ -443,7 +445,7 @@ void cli_session_open(Cli* cli, void* session) {
|
||||
}
|
||||
|
||||
void cli_session_close(Cli* cli) {
|
||||
furi_assert(cli);
|
||||
furi_check(cli);
|
||||
|
||||
furi_check(furi_mutex_acquire(cli->mutex, FuriWaitForever) == FuriStatusOk);
|
||||
if(cli->session != NULL) {
|
||||
|
||||
@@ -121,7 +121,7 @@ char cli_getc(Cli* cli);
|
||||
|
||||
/** New line Send new ine sequence
|
||||
*/
|
||||
void cli_nl();
|
||||
void cli_nl(Cli* cli);
|
||||
|
||||
void cli_session_open(Cli* cli, void* session);
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include <furi_hal.h>
|
||||
#include <lib/toolbox/args.h>
|
||||
|
||||
void cli_command_gpio_print_usage() {
|
||||
void cli_command_gpio_print_usage(void) {
|
||||
printf("Usage:\r\n");
|
||||
printf("gpio <cmd> <args>\r\n");
|
||||
printf("Cmd list:\r\n");
|
||||
|
||||
@@ -83,7 +83,7 @@ void cli_command_help(Cli* cli, FuriString* args, void* context) {
|
||||
}
|
||||
|
||||
if(furi_string_size(args) > 0) {
|
||||
cli_nl();
|
||||
cli_nl(cli);
|
||||
printf("`");
|
||||
printf("%s", furi_string_get_cstr(args));
|
||||
printf("` command not found");
|
||||
@@ -282,7 +282,7 @@ void cli_command_sysctl_heap_track(Cli* cli, FuriString* args, void* context) {
|
||||
}
|
||||
}
|
||||
|
||||
void cli_command_sysctl_print_usage() {
|
||||
void cli_command_sysctl_print_usage(void) {
|
||||
printf("Usage:\r\n");
|
||||
printf("sysctl <cmd> <args>\r\n");
|
||||
printf("Cmd list:\r\n");
|
||||
|
||||
@@ -54,7 +54,7 @@ struct Cli {
|
||||
size_t cursor_position;
|
||||
};
|
||||
|
||||
Cli* cli_alloc();
|
||||
Cli* cli_alloc(void);
|
||||
|
||||
void cli_reset(Cli* cli);
|
||||
|
||||
|
||||
@@ -64,7 +64,7 @@ static CliVcp* vcp = NULL;
|
||||
static const uint8_t ascii_soh = 0x01;
|
||||
static const uint8_t ascii_eot = 0x04;
|
||||
|
||||
static void cli_vcp_init() {
|
||||
static void cli_vcp_init(void) {
|
||||
if(vcp == NULL) {
|
||||
vcp = malloc(sizeof(CliVcp));
|
||||
vcp->tx_stream = furi_stream_buffer_alloc(VCP_TX_BUF_SIZE, 1);
|
||||
@@ -80,7 +80,7 @@ static void cli_vcp_init() {
|
||||
FURI_LOG_I(TAG, "Init OK");
|
||||
}
|
||||
|
||||
static void cli_vcp_deinit() {
|
||||
static void cli_vcp_deinit(void) {
|
||||
furi_thread_flags_set(furi_thread_get_id(vcp->thread), VcpEvtStop);
|
||||
furi_thread_join(vcp->thread);
|
||||
furi_thread_free(vcp->thread);
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include <lib/toolbox/args.h>
|
||||
#include <cli/cli.h>
|
||||
|
||||
void crypto_cli_print_usage() {
|
||||
void crypto_cli_print_usage(void) {
|
||||
printf("Usage:\r\n");
|
||||
printf("crypto <cmd> <args>\r\n");
|
||||
printf("Cmd list:\r\n");
|
||||
@@ -324,6 +324,6 @@ static const FlipperAppPluginDescriptor plugin_descriptor = {
|
||||
.entry_point = &crypto_cli,
|
||||
};
|
||||
|
||||
const FlipperAppPluginDescriptor* crypto_cli_plugin_ep() {
|
||||
const FlipperAppPluginDescriptor* crypto_cli_plugin_ep(void) {
|
||||
return &plugin_descriptor;
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ static void crypto_cli_wrapper(Cli* cli, FuriString* args, void* context) {
|
||||
cli_plugin_wrapper("crypto_cli", 1, cli, args, context);
|
||||
}
|
||||
|
||||
void crypto_on_system_start() {
|
||||
void crypto_on_system_start(void) {
|
||||
Cli* cli = furi_record_open(RECORD_CLI);
|
||||
cli_add_command(cli, "crypto", CliCommandFlagDefault, crypto_cli_wrapper, NULL);
|
||||
furi_record_close(RECORD_CLI);
|
||||
|
||||
@@ -270,7 +270,7 @@ void desktop_set_stealth_mode_state(Desktop* desktop, bool enabled) {
|
||||
desktop->in_transition = false;
|
||||
}
|
||||
|
||||
Desktop* desktop_alloc() {
|
||||
Desktop* desktop_alloc(void) {
|
||||
Desktop* desktop = malloc(sizeof(Desktop));
|
||||
|
||||
desktop->animation_manager = animation_manager_alloc();
|
||||
|
||||
@@ -86,7 +86,7 @@ struct Desktop {
|
||||
FuriPubSubSubscription* ascii_events_subscription;
|
||||
};
|
||||
|
||||
Desktop* desktop_alloc();
|
||||
Desktop* desktop_alloc(void);
|
||||
|
||||
void desktop_free(Desktop* desktop);
|
||||
void desktop_lock(Desktop* desktop, bool pin_lock);
|
||||
|
||||
@@ -28,13 +28,13 @@ static const NotificationSequence sequence_pin_fail = {
|
||||
NULL,
|
||||
};
|
||||
|
||||
void desktop_pin_lock_error_notify() {
|
||||
void desktop_pin_lock_error_notify(void) {
|
||||
NotificationApp* notification = furi_record_open(RECORD_NOTIFICATION);
|
||||
notification_message(notification, &sequence_pin_fail);
|
||||
furi_record_close(RECORD_NOTIFICATION);
|
||||
}
|
||||
|
||||
uint32_t desktop_pin_lock_get_fail_timeout() {
|
||||
uint32_t desktop_pin_lock_get_fail_timeout(void) {
|
||||
uint32_t pin_fails = furi_hal_rtc_get_pin_fails();
|
||||
if(pin_fails < 3) {
|
||||
return 0;
|
||||
|
||||
@@ -4,9 +4,9 @@
|
||||
#include "../desktop.h"
|
||||
#include <desktop/desktop_settings.h>
|
||||
|
||||
void desktop_pin_lock_error_notify();
|
||||
void desktop_pin_lock_error_notify(void);
|
||||
|
||||
uint32_t desktop_pin_lock_get_fail_timeout();
|
||||
uint32_t desktop_pin_lock_get_fail_timeout(void);
|
||||
|
||||
bool desktop_pin_compare(const PinCode* pin_code1, const PinCode* pin_code2);
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ _Static_assert(sizeof(SlideshowFrameHeader) == 2, "Incorrect SlideshowFrameHeade
|
||||
|
||||
#pragma pack(pop)
|
||||
|
||||
Slideshow* slideshow_alloc() {
|
||||
Slideshow* slideshow_alloc(void) {
|
||||
Slideshow* ret = malloc(sizeof(Slideshow));
|
||||
ret->loaded = false;
|
||||
return ret;
|
||||
|
||||
@@ -9,7 +9,7 @@ typedef struct {
|
||||
bool loaded;
|
||||
} Slideshow;
|
||||
|
||||
Slideshow* slideshow_alloc();
|
||||
Slideshow* slideshow_alloc(void);
|
||||
|
||||
void slideshow_free(Slideshow* slideshow);
|
||||
bool slideshow_load(Slideshow* slideshow, const char* fspath);
|
||||
|
||||
@@ -346,7 +346,7 @@ bool desktop_lock_menu_input_callback(InputEvent* event, void* context) {
|
||||
return consumed;
|
||||
}
|
||||
|
||||
DesktopLockMenuView* desktop_lock_menu_alloc() {
|
||||
DesktopLockMenuView* desktop_lock_menu_alloc(void) {
|
||||
DesktopLockMenuView* lock_menu = malloc(sizeof(DesktopLockMenuView));
|
||||
lock_menu->bt = furi_record_open(RECORD_BT);
|
||||
lock_menu->notification = furi_record_open(RECORD_NOTIFICATION);
|
||||
|
||||
@@ -43,5 +43,5 @@ View* desktop_lock_menu_get_view(DesktopLockMenuView* lock_menu);
|
||||
void desktop_lock_menu_set_pin_state(DesktopLockMenuView* lock_menu, bool pin_is_set);
|
||||
void desktop_lock_menu_set_stealth_mode_state(DesktopLockMenuView* lock_menu, bool stealth_mode);
|
||||
void desktop_lock_menu_set_idx(DesktopLockMenuView* lock_menu, uint8_t idx);
|
||||
DesktopLockMenuView* desktop_lock_menu_alloc();
|
||||
DesktopLockMenuView* desktop_lock_menu_alloc(void);
|
||||
void desktop_lock_menu_free(DesktopLockMenuView* lock_menu);
|
||||
|
||||
@@ -16,11 +16,11 @@
|
||||
#define LOCKED_HINT_TIMEOUT_MS (3000)
|
||||
#define UNLOCKED_HINT_TIMEOUT_MS (2000)
|
||||
|
||||
#define COVER_OFFSET_START -64
|
||||
#define COVER_OFFSET_END 0
|
||||
#define COVER_OFFSET_START (-64)
|
||||
#define COVER_OFFSET_END (0)
|
||||
|
||||
#define UNLOCK_CNT 3
|
||||
#define UNLOCK_RST_TIMEOUT 600
|
||||
#define UNLOCK_CNT (3)
|
||||
#define UNLOCK_RST_TIMEOUT (600)
|
||||
|
||||
struct DesktopViewLocked {
|
||||
View* view;
|
||||
@@ -64,7 +64,7 @@ static void locked_view_timer_callback(void* context) {
|
||||
|
||||
void desktop_view_locked_draw_lockscreen(Canvas* canvas, void* m) {
|
||||
DesktopViewLockedModel* model = m;
|
||||
int y = model->cover_offset;
|
||||
int32_t y = model->cover_offset;
|
||||
char time_str[9];
|
||||
char second_str[5];
|
||||
char date_str[14];
|
||||
@@ -263,7 +263,7 @@ static bool desktop_view_locked_input(InputEvent* event, void* context) {
|
||||
return true;
|
||||
}
|
||||
|
||||
DesktopViewLocked* desktop_view_locked_alloc() {
|
||||
DesktopViewLocked* desktop_view_locked_alloc(void) {
|
||||
DesktopViewLocked* locked_view = malloc(sizeof(DesktopViewLocked));
|
||||
locked_view->view = view_alloc();
|
||||
locked_view->timer =
|
||||
|
||||
@@ -14,7 +14,7 @@ void desktop_view_locked_set_callback(
|
||||
void* context);
|
||||
void desktop_view_locked_update(DesktopViewLocked* locked_view);
|
||||
View* desktop_view_locked_get_view(DesktopViewLocked* locked_view);
|
||||
DesktopViewLocked* desktop_view_locked_alloc();
|
||||
DesktopViewLocked* desktop_view_locked_alloc(void);
|
||||
void desktop_view_locked_free(DesktopViewLocked* locked_view);
|
||||
void desktop_view_locked_lock(DesktopViewLocked* locked_view, bool pin_locked);
|
||||
void desktop_view_locked_unlock(DesktopViewLocked* locked_view);
|
||||
|
||||
@@ -58,7 +58,7 @@ bool desktop_main_input_callback(InputEvent* event, void* context) {
|
||||
return true;
|
||||
}
|
||||
|
||||
DesktopMainView* desktop_main_alloc() {
|
||||
DesktopMainView* desktop_main_alloc(void) {
|
||||
DesktopMainView* main_view = malloc(sizeof(DesktopMainView));
|
||||
|
||||
main_view->view = view_alloc();
|
||||
|
||||
@@ -13,5 +13,5 @@ void desktop_main_set_callback(
|
||||
void* context);
|
||||
|
||||
View* desktop_main_get_view(DesktopMainView* main_view);
|
||||
DesktopMainView* desktop_main_alloc();
|
||||
DesktopMainView* desktop_main_alloc(void);
|
||||
void desktop_main_free(DesktopMainView* main_view);
|
||||
|
||||
@@ -158,7 +158,7 @@ static void desktop_view_slideshow_exit(void* context) {
|
||||
view_commit_model(instance->view, false);
|
||||
}
|
||||
|
||||
DesktopSlideshowView* desktop_view_slideshow_alloc() {
|
||||
DesktopSlideshowView* desktop_view_slideshow_alloc(void) {
|
||||
DesktopSlideshowView* instance = malloc(sizeof(DesktopSlideshowView));
|
||||
instance->view = view_alloc();
|
||||
view_allocate_model(instance->view, ViewModelTypeLocking, sizeof(DesktopSlideshowViewModel));
|
||||
|
||||
@@ -10,7 +10,7 @@ typedef struct DesktopSlideshowView DesktopSlideshowView;
|
||||
|
||||
typedef void (*DesktopSlideshowViewCallback)(DesktopEvent event, void* context);
|
||||
|
||||
DesktopSlideshowView* desktop_view_slideshow_alloc();
|
||||
DesktopSlideshowView* desktop_view_slideshow_alloc(void);
|
||||
|
||||
void desktop_view_slideshow_free(DesktopSlideshowView* main_view);
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ void dialog_file_browser_set_basic_options(
|
||||
DialogsFileBrowserOptions* options,
|
||||
const char* extension,
|
||||
const Icon* icon) {
|
||||
furi_check(options);
|
||||
options->extension = extension;
|
||||
options->base_path = NULL;
|
||||
options->skip_assets = true;
|
||||
@@ -18,7 +19,7 @@ void dialog_file_browser_set_basic_options(
|
||||
options->item_loader_context = NULL;
|
||||
}
|
||||
|
||||
static DialogsApp* dialogs_app_alloc() {
|
||||
static DialogsApp* dialogs_app_alloc(void) {
|
||||
DialogsApp* app = malloc(sizeof(DialogsApp));
|
||||
app->message_queue = furi_message_queue_alloc(8, sizeof(DialogsAppMessage));
|
||||
|
||||
|
||||
@@ -87,7 +87,7 @@ typedef struct DialogMessage DialogMessage;
|
||||
* Allocate and fill message
|
||||
* @return DialogMessage*
|
||||
*/
|
||||
DialogMessage* dialog_message_alloc();
|
||||
DialogMessage* dialog_message_alloc(void);
|
||||
|
||||
/**
|
||||
* Free message struct
|
||||
|
||||
@@ -65,6 +65,8 @@ bool dialog_file_browser_show(
|
||||
/****************** Message ******************/
|
||||
|
||||
DialogMessageButton dialog_message_show(DialogsApp* context, const DialogMessage* dialog_message) {
|
||||
furi_check(context);
|
||||
|
||||
FuriApiLock lock = api_lock_alloc_locked();
|
||||
furi_check(lock != NULL);
|
||||
|
||||
@@ -91,6 +93,8 @@ DialogMessageButton dialog_message_show(DialogsApp* context, const DialogMessage
|
||||
/****************** Storage error ******************/
|
||||
|
||||
void dialog_message_show_storage_error(DialogsApp* context, const char* error_text) {
|
||||
furi_check(context);
|
||||
|
||||
DialogMessage* message = dialog_message_alloc();
|
||||
dialog_message_set_text(message, error_text, 88, 32, AlignCenter, AlignCenter);
|
||||
dialog_message_set_icon(message, &I_SDQuestion_35x43, 5, 6);
|
||||
|
||||
@@ -101,12 +101,13 @@ DialogMessageButton dialogs_app_process_module_message(const DialogsAppMessageDa
|
||||
return ret;
|
||||
}
|
||||
|
||||
DialogMessage* dialog_message_alloc() {
|
||||
DialogMessage* dialog_message_alloc(void) {
|
||||
DialogMessage* message = malloc(sizeof(DialogMessage));
|
||||
return message;
|
||||
}
|
||||
|
||||
void dialog_message_free(DialogMessage* message) {
|
||||
furi_check(message);
|
||||
free(message);
|
||||
}
|
||||
|
||||
@@ -117,6 +118,8 @@ void dialog_message_set_text(
|
||||
uint8_t y,
|
||||
Align horizontal,
|
||||
Align vertical) {
|
||||
furi_check(message);
|
||||
|
||||
message->dialog_text = text;
|
||||
message->dialog_text_x = x;
|
||||
message->dialog_text_y = y;
|
||||
@@ -131,6 +134,8 @@ void dialog_message_set_header(
|
||||
uint8_t y,
|
||||
Align horizontal,
|
||||
Align vertical) {
|
||||
furi_check(message);
|
||||
|
||||
message->header_text = text;
|
||||
message->header_text_x = x;
|
||||
message->header_text_y = y;
|
||||
@@ -139,6 +144,8 @@ void dialog_message_set_header(
|
||||
}
|
||||
|
||||
void dialog_message_set_icon(DialogMessage* message, const Icon* icon, uint8_t x, uint8_t y) {
|
||||
furi_check(message);
|
||||
|
||||
message->icon = icon;
|
||||
message->icon_x = x;
|
||||
message->icon_y = y;
|
||||
@@ -149,6 +156,8 @@ void dialog_message_set_buttons(
|
||||
const char* left,
|
||||
const char* center,
|
||||
const char* right) {
|
||||
furi_check(message);
|
||||
|
||||
message->left_button_text = left;
|
||||
message->center_button_text = center;
|
||||
message->right_button_text = right;
|
||||
|
||||
@@ -23,7 +23,7 @@ void dolphin_deed(DolphinDeed deed) {
|
||||
}
|
||||
|
||||
DolphinStats dolphin_stats(Dolphin* dolphin) {
|
||||
furi_assert(dolphin);
|
||||
furi_check(dolphin);
|
||||
|
||||
DolphinStats stats;
|
||||
DolphinEvent event;
|
||||
@@ -37,7 +37,7 @@ DolphinStats dolphin_stats(Dolphin* dolphin) {
|
||||
}
|
||||
|
||||
void dolphin_flush(Dolphin* dolphin) {
|
||||
furi_assert(dolphin);
|
||||
furi_check(dolphin);
|
||||
|
||||
DolphinEvent event;
|
||||
event.type = DolphinEventTypeFlush;
|
||||
@@ -74,7 +74,7 @@ void dolphin_clear_limits_timer_callback(void* context) {
|
||||
dolphin_event_send_async(dolphin, &event);
|
||||
}
|
||||
|
||||
Dolphin* dolphin_alloc() {
|
||||
Dolphin* dolphin_alloc(void) {
|
||||
Dolphin* dolphin = malloc(sizeof(Dolphin));
|
||||
|
||||
dolphin->state = dolphin_state_alloc();
|
||||
@@ -120,6 +120,7 @@ void dolphin_event_release(Dolphin* dolphin, DolphinEvent* event) {
|
||||
}
|
||||
|
||||
FuriPubSub* dolphin_get_pubsub(Dolphin* dolphin) {
|
||||
furi_check(dolphin);
|
||||
return dolphin->pubsub;
|
||||
}
|
||||
|
||||
@@ -204,6 +205,8 @@ int32_t dolphin_srv(void* p) {
|
||||
}
|
||||
|
||||
void dolphin_upgrade_level(Dolphin* dolphin) {
|
||||
furi_check(dolphin);
|
||||
|
||||
dolphin_state_increase_level(dolphin->state);
|
||||
dolphin_flush(dolphin);
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ struct Dolphin {
|
||||
FuriTimer* clear_limits_timer;
|
||||
};
|
||||
|
||||
Dolphin* dolphin_alloc();
|
||||
Dolphin* dolphin_alloc(void);
|
||||
|
||||
void dolphin_event_send_async(Dolphin* dolphin, DolphinEvent* event);
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ const uint32_t DOLPHIN_LEVELS[] = {100, 200, 300, 450, 600, 750, 950, 115
|
||||
5250, 5700, 6150, 6600, 7100, 7600, 8100, 8650, 9999};
|
||||
const size_t DOLPHIN_LEVEL_COUNT = COUNT_OF(DOLPHIN_LEVELS);
|
||||
|
||||
DolphinState* dolphin_state_alloc() {
|
||||
DolphinState* dolphin_state_alloc(void) {
|
||||
return malloc(sizeof(DolphinState));
|
||||
}
|
||||
|
||||
@@ -72,8 +72,10 @@ bool dolphin_state_load(DolphinState* dolphin_state) {
|
||||
return success;
|
||||
}
|
||||
|
||||
uint64_t dolphin_state_timestamp() {
|
||||
return furi_hal_rtc_get_timestamp();
|
||||
uint64_t dolphin_state_timestamp(void) {
|
||||
DateTime datetime;
|
||||
furi_hal_rtc_get_datetime(&datetime);
|
||||
return datetime_datetime_to_timestamp(&datetime);
|
||||
}
|
||||
|
||||
bool dolphin_state_is_levelup(uint32_t icounter) {
|
||||
|
||||
@@ -33,7 +33,7 @@ struct DolphinState {
|
||||
bool dirty;
|
||||
};
|
||||
|
||||
DolphinState* dolphin_state_alloc();
|
||||
DolphinState* dolphin_state_alloc(void);
|
||||
|
||||
void dolphin_state_free(DolphinState* dolphin_state);
|
||||
|
||||
@@ -43,7 +43,7 @@ bool dolphin_state_load(DolphinState* dolphin_state);
|
||||
|
||||
void dolphin_state_clear_limits(DolphinState* dolphin_state);
|
||||
|
||||
uint64_t dolphin_state_timestamp();
|
||||
uint64_t dolphin_state_timestamp(void);
|
||||
|
||||
void dolphin_state_on_deed(DolphinState* dolphin_state, DolphinDeed deed);
|
||||
|
||||
|
||||
@@ -238,7 +238,7 @@ static int32_t expansion_control(void* context) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
static Expansion* expansion_alloc() {
|
||||
static Expansion* expansion_alloc(void) {
|
||||
Expansion* instance = malloc(sizeof(Expansion));
|
||||
|
||||
instance->queue =
|
||||
|
||||
@@ -15,7 +15,7 @@ const CanvasFontParameters canvas_font_params[FontTotalNumber] = {
|
||||
[FontBatteryPercent] = {.leading_default = 11, .leading_min = 9, .height = 6, .descender = 0},
|
||||
};
|
||||
|
||||
Canvas* canvas_init() {
|
||||
Canvas* canvas_init(void) {
|
||||
Canvas* canvas = malloc(sizeof(Canvas));
|
||||
canvas->compress_icon = compress_icon_alloc();
|
||||
|
||||
@@ -41,7 +41,7 @@ Canvas* canvas_init() {
|
||||
}
|
||||
|
||||
void canvas_free(Canvas* canvas) {
|
||||
furi_assert(canvas);
|
||||
furi_check(canvas);
|
||||
compress_icon_free(canvas->compress_icon);
|
||||
CanvasCallbackPairArray_clear(canvas->canvas_callback_pair);
|
||||
furi_mutex_free(canvas->mutex);
|
||||
@@ -59,7 +59,7 @@ static void canvas_unlock(Canvas* canvas) {
|
||||
}
|
||||
|
||||
void canvas_reset(Canvas* canvas) {
|
||||
furi_assert(canvas);
|
||||
furi_check(canvas);
|
||||
|
||||
canvas_clear(canvas);
|
||||
|
||||
@@ -69,7 +69,7 @@ void canvas_reset(Canvas* canvas) {
|
||||
}
|
||||
|
||||
void canvas_commit(Canvas* canvas) {
|
||||
furi_assert(canvas);
|
||||
furi_check(canvas);
|
||||
u8g2_SendBuffer(&canvas->fb);
|
||||
|
||||
// Iterate over callbacks
|
||||
@@ -86,41 +86,41 @@ void canvas_commit(Canvas* canvas) {
|
||||
}
|
||||
|
||||
uint8_t* canvas_get_buffer(Canvas* canvas) {
|
||||
furi_assert(canvas);
|
||||
furi_check(canvas);
|
||||
return u8g2_GetBufferPtr(&canvas->fb);
|
||||
}
|
||||
|
||||
size_t canvas_get_buffer_size(const Canvas* canvas) {
|
||||
furi_assert(canvas);
|
||||
furi_check(canvas);
|
||||
return u8g2_GetBufferTileWidth(&canvas->fb) * u8g2_GetBufferTileHeight(&canvas->fb) * 8;
|
||||
}
|
||||
|
||||
void canvas_frame_set(
|
||||
Canvas* canvas,
|
||||
uint8_t offset_x,
|
||||
uint8_t offset_y,
|
||||
uint8_t width,
|
||||
uint8_t height) {
|
||||
furi_assert(canvas);
|
||||
int32_t offset_x,
|
||||
int32_t offset_y,
|
||||
size_t width,
|
||||
size_t height) {
|
||||
furi_check(canvas);
|
||||
canvas->offset_x = offset_x;
|
||||
canvas->offset_y = offset_y;
|
||||
canvas->width = width;
|
||||
canvas->height = height;
|
||||
}
|
||||
|
||||
uint8_t canvas_width(const Canvas* canvas) {
|
||||
furi_assert(canvas);
|
||||
size_t canvas_width(const Canvas* canvas) {
|
||||
furi_check(canvas);
|
||||
return canvas->width;
|
||||
}
|
||||
|
||||
uint8_t canvas_height(const Canvas* canvas) {
|
||||
furi_assert(canvas);
|
||||
size_t canvas_height(const Canvas* canvas) {
|
||||
furi_check(canvas);
|
||||
return canvas->height;
|
||||
}
|
||||
|
||||
uint8_t canvas_current_font_height(const Canvas* canvas) {
|
||||
furi_assert(canvas);
|
||||
uint8_t font_height = u8g2_GetMaxCharHeight(&canvas->fb);
|
||||
size_t canvas_current_font_height(const Canvas* canvas) {
|
||||
furi_check(canvas);
|
||||
size_t font_height = u8g2_GetMaxCharHeight(&canvas->fb);
|
||||
|
||||
if(canvas->fb.font == u8g2_font_haxrcorp4089_tr) {
|
||||
font_height += 1;
|
||||
@@ -129,14 +129,14 @@ uint8_t canvas_current_font_height(const Canvas* canvas) {
|
||||
return font_height;
|
||||
}
|
||||
|
||||
uint8_t canvas_current_font_width(const Canvas* canvas) {
|
||||
furi_assert(canvas);
|
||||
return (uint8_t)u8g2_GetMaxCharWidth(&canvas->fb);
|
||||
size_t canvas_current_font_width(const Canvas* canvas) {
|
||||
furi_check(canvas);
|
||||
return u8g2_GetMaxCharWidth(&canvas->fb);
|
||||
}
|
||||
|
||||
const CanvasFontParameters* canvas_get_font_params(const Canvas* canvas, Font font) {
|
||||
furi_assert(canvas);
|
||||
furi_assert(font < FontTotalNumber);
|
||||
furi_check(canvas);
|
||||
furi_check(font < FontTotalNumber);
|
||||
if(asset_packs.font_params[font]) {
|
||||
return asset_packs.font_params[font];
|
||||
}
|
||||
@@ -144,7 +144,7 @@ const CanvasFontParameters* canvas_get_font_params(const Canvas* canvas, Font fo
|
||||
}
|
||||
|
||||
void canvas_clear(Canvas* canvas) {
|
||||
furi_assert(canvas);
|
||||
furi_check(canvas);
|
||||
if(momentum_settings.dark_mode) {
|
||||
u8g2_FillBuffer(&canvas->fb);
|
||||
} else {
|
||||
@@ -153,7 +153,7 @@ void canvas_clear(Canvas* canvas) {
|
||||
}
|
||||
|
||||
void canvas_set_color(Canvas* canvas, Color color) {
|
||||
furi_assert(canvas);
|
||||
furi_check(canvas);
|
||||
if(momentum_settings.dark_mode) {
|
||||
if(color == ColorBlack) {
|
||||
color = ColorWhite;
|
||||
@@ -165,7 +165,7 @@ void canvas_set_color(Canvas* canvas, Color color) {
|
||||
}
|
||||
|
||||
void canvas_set_font_direction(Canvas* canvas, CanvasDirection dir) {
|
||||
furi_assert(canvas);
|
||||
furi_check(canvas);
|
||||
u8g2_SetFontDirection(&canvas->fb, dir);
|
||||
}
|
||||
|
||||
@@ -174,7 +174,7 @@ void canvas_invert_color(Canvas* canvas) {
|
||||
}
|
||||
|
||||
void canvas_set_font(Canvas* canvas, Font font) {
|
||||
furi_assert(canvas);
|
||||
furi_check(canvas);
|
||||
u8g2_SetFontMode(&canvas->fb, 1);
|
||||
if(asset_packs.fonts[font]) {
|
||||
u8g2_SetFont(&canvas->fb, asset_packs.fonts[font]);
|
||||
@@ -203,27 +203,27 @@ void canvas_set_font(Canvas* canvas, Font font) {
|
||||
}
|
||||
|
||||
void canvas_set_custom_u8g2_font(Canvas* canvas, const uint8_t* font) {
|
||||
furi_assert(canvas);
|
||||
furi_check(canvas);
|
||||
u8g2_SetFontMode(&canvas->fb, 1);
|
||||
u8g2_SetFont(&canvas->fb, font);
|
||||
}
|
||||
|
||||
void canvas_draw_str(Canvas* canvas, uint8_t x, uint8_t y, const char* str) {
|
||||
furi_assert(canvas);
|
||||
void canvas_draw_str(Canvas* canvas, int32_t x, int32_t y, const char* str) {
|
||||
furi_check(canvas);
|
||||
if(!str) return;
|
||||
x += canvas->offset_x;
|
||||
y += canvas->offset_y;
|
||||
u8g2_DrawStr(&canvas->fb, x, y, str);
|
||||
u8g2_DrawUTF8(&canvas->fb, x, y, str);
|
||||
}
|
||||
|
||||
void canvas_draw_str_aligned(
|
||||
Canvas* canvas,
|
||||
uint8_t x,
|
||||
uint8_t y,
|
||||
int32_t x,
|
||||
int32_t y,
|
||||
Align horizontal,
|
||||
Align vertical,
|
||||
const char* str) {
|
||||
furi_assert(canvas);
|
||||
furi_check(canvas);
|
||||
if(!str) return;
|
||||
x += canvas->offset_x;
|
||||
y += canvas->offset_y;
|
||||
@@ -232,10 +232,10 @@ void canvas_draw_str_aligned(
|
||||
case AlignLeft:
|
||||
break;
|
||||
case AlignRight:
|
||||
x -= u8g2_GetStrWidth(&canvas->fb, str);
|
||||
x -= u8g2_GetUTF8Width(&canvas->fb, str);
|
||||
break;
|
||||
case AlignCenter:
|
||||
x -= (u8g2_GetStrWidth(&canvas->fb, str) / 2);
|
||||
x -= (u8g2_GetUTF8Width(&canvas->fb, str) / 2);
|
||||
break;
|
||||
default:
|
||||
furi_crash();
|
||||
@@ -256,28 +256,28 @@ void canvas_draw_str_aligned(
|
||||
break;
|
||||
}
|
||||
|
||||
u8g2_DrawStr(&canvas->fb, x, y, str);
|
||||
u8g2_DrawUTF8(&canvas->fb, x, y, str);
|
||||
}
|
||||
|
||||
uint16_t canvas_string_width(Canvas* canvas, const char* str) {
|
||||
furi_assert(canvas);
|
||||
furi_check(canvas);
|
||||
if(!str) return 0;
|
||||
return u8g2_GetStrWidth(&canvas->fb, str);
|
||||
return u8g2_GetUTF8Width(&canvas->fb, str);
|
||||
}
|
||||
|
||||
uint8_t canvas_glyph_width(Canvas* canvas, uint16_t symbol) {
|
||||
furi_assert(canvas);
|
||||
size_t canvas_glyph_width(Canvas* canvas, uint16_t symbol) {
|
||||
furi_check(canvas);
|
||||
return u8g2_GetGlyphWidth(&canvas->fb, symbol);
|
||||
}
|
||||
|
||||
void canvas_draw_bitmap(
|
||||
Canvas* canvas,
|
||||
uint8_t x,
|
||||
uint8_t y,
|
||||
uint8_t width,
|
||||
uint8_t height,
|
||||
int32_t x,
|
||||
int32_t y,
|
||||
size_t width,
|
||||
size_t height,
|
||||
const uint8_t* compressed_bitmap_data) {
|
||||
furi_assert(canvas);
|
||||
furi_check(canvas);
|
||||
|
||||
x += canvas->offset_x;
|
||||
y += canvas->offset_y;
|
||||
@@ -288,11 +288,11 @@ void canvas_draw_bitmap(
|
||||
|
||||
void canvas_draw_icon_animation(
|
||||
Canvas* canvas,
|
||||
uint8_t x,
|
||||
uint8_t y,
|
||||
int32_t x,
|
||||
int32_t y,
|
||||
IconAnimation* icon_animation) {
|
||||
furi_assert(canvas);
|
||||
furi_assert(icon_animation);
|
||||
furi_check(canvas);
|
||||
furi_check(icon_animation);
|
||||
|
||||
x += canvas->offset_x;
|
||||
y += canvas->offset_y;
|
||||
@@ -384,32 +384,28 @@ static void canvas_draw_u8g2_bitmap_int(
|
||||
|
||||
void canvas_draw_u8g2_bitmap(
|
||||
u8g2_t* u8g2,
|
||||
u8g2_uint_t x,
|
||||
u8g2_uint_t y,
|
||||
u8g2_uint_t w,
|
||||
u8g2_uint_t h,
|
||||
int32_t x,
|
||||
int32_t y,
|
||||
size_t width,
|
||||
size_t height,
|
||||
const uint8_t* bitmap,
|
||||
IconRotation rotation) {
|
||||
u8g2_uint_t blen;
|
||||
blen = w;
|
||||
blen += 7;
|
||||
blen >>= 3;
|
||||
#ifdef U8G2_WITH_INTERSECTION
|
||||
if(u8g2_IsIntersection(u8g2, x, y, x + w, y + h) == 0) return;
|
||||
if(u8g2_IsIntersection(u8g2, x, y, x + width, y + height) == 0) return;
|
||||
#endif /* U8G2_WITH_INTERSECTION */
|
||||
|
||||
switch(rotation) {
|
||||
case IconRotation0:
|
||||
canvas_draw_u8g2_bitmap_int(u8g2, x, y, w, h, 0, 0, bitmap);
|
||||
canvas_draw_u8g2_bitmap_int(u8g2, x, y, width, height, 0, 0, bitmap);
|
||||
break;
|
||||
case IconRotation90:
|
||||
canvas_draw_u8g2_bitmap_int(u8g2, x, y, w, h, 0, 1, bitmap);
|
||||
canvas_draw_u8g2_bitmap_int(u8g2, x, y, width, height, 0, 1, bitmap);
|
||||
break;
|
||||
case IconRotation180:
|
||||
canvas_draw_u8g2_bitmap_int(u8g2, x, y, w, h, 1, 0, bitmap);
|
||||
canvas_draw_u8g2_bitmap_int(u8g2, x, y, width, height, 1, 0, bitmap);
|
||||
break;
|
||||
case IconRotation270:
|
||||
canvas_draw_u8g2_bitmap_int(u8g2, x, y, w, h, 1, 1, bitmap);
|
||||
canvas_draw_u8g2_bitmap_int(u8g2, x, y, width, height, 1, 1, bitmap);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@@ -418,12 +414,12 @@ void canvas_draw_u8g2_bitmap(
|
||||
|
||||
void canvas_draw_icon_ex(
|
||||
Canvas* canvas,
|
||||
uint8_t x,
|
||||
uint8_t y,
|
||||
int32_t x,
|
||||
int32_t y,
|
||||
const Icon* icon,
|
||||
IconRotation rotation) {
|
||||
furi_assert(canvas);
|
||||
furi_assert(icon);
|
||||
furi_check(canvas);
|
||||
furi_check(icon);
|
||||
|
||||
x += canvas->offset_x;
|
||||
y += canvas->offset_y;
|
||||
@@ -433,9 +429,9 @@ void canvas_draw_icon_ex(
|
||||
&canvas->fb, x, y, icon_get_width(icon), icon_get_height(icon), icon_data, rotation);
|
||||
}
|
||||
|
||||
void canvas_draw_icon(Canvas* canvas, uint8_t x, uint8_t y, const Icon* icon) {
|
||||
furi_assert(canvas);
|
||||
furi_assert(icon);
|
||||
void canvas_draw_icon(Canvas* canvas, int32_t x, int32_t y, const Icon* icon) {
|
||||
furi_check(canvas);
|
||||
furi_check(icon);
|
||||
|
||||
x += canvas->offset_x;
|
||||
y += canvas->offset_y;
|
||||
@@ -445,15 +441,15 @@ void canvas_draw_icon(Canvas* canvas, uint8_t x, uint8_t y, const Icon* icon) {
|
||||
&canvas->fb, x, y, icon_get_width(icon), icon_get_height(icon), icon_data, IconRotation0);
|
||||
}
|
||||
|
||||
void canvas_draw_dot(Canvas* canvas, uint8_t x, uint8_t y) {
|
||||
furi_assert(canvas);
|
||||
void canvas_draw_dot(Canvas* canvas, int32_t x, int32_t y) {
|
||||
furi_check(canvas);
|
||||
x += canvas->offset_x;
|
||||
y += canvas->offset_y;
|
||||
u8g2_DrawPixel(&canvas->fb, x, y);
|
||||
}
|
||||
|
||||
void canvas_draw_box(Canvas* canvas, uint8_t x, uint8_t y, uint8_t width, uint8_t height) {
|
||||
furi_assert(canvas);
|
||||
void canvas_draw_box(Canvas* canvas, int32_t x, int32_t y, size_t width, size_t height) {
|
||||
furi_check(canvas);
|
||||
x += canvas->offset_x;
|
||||
y += canvas->offset_y;
|
||||
u8g2_DrawBox(&canvas->fb, x, y, width, height);
|
||||
@@ -461,19 +457,19 @@ void canvas_draw_box(Canvas* canvas, uint8_t x, uint8_t y, uint8_t width, uint8_
|
||||
|
||||
void canvas_draw_rbox(
|
||||
Canvas* canvas,
|
||||
uint8_t x,
|
||||
uint8_t y,
|
||||
uint8_t width,
|
||||
uint8_t height,
|
||||
uint8_t radius) {
|
||||
furi_assert(canvas);
|
||||
int32_t x,
|
||||
int32_t y,
|
||||
size_t width,
|
||||
size_t height,
|
||||
size_t radius) {
|
||||
furi_check(canvas);
|
||||
x += canvas->offset_x;
|
||||
y += canvas->offset_y;
|
||||
u8g2_DrawRBox(&canvas->fb, x, y, width, height, radius);
|
||||
}
|
||||
|
||||
void canvas_draw_frame(Canvas* canvas, uint8_t x, uint8_t y, uint8_t width, uint8_t height) {
|
||||
furi_assert(canvas);
|
||||
void canvas_draw_frame(Canvas* canvas, int32_t x, int32_t y, size_t width, size_t height) {
|
||||
furi_check(canvas);
|
||||
x += canvas->offset_x;
|
||||
y += canvas->offset_y;
|
||||
u8g2_DrawFrame(&canvas->fb, x, y, width, height);
|
||||
@@ -481,19 +477,19 @@ void canvas_draw_frame(Canvas* canvas, uint8_t x, uint8_t y, uint8_t width, uint
|
||||
|
||||
void canvas_draw_rframe(
|
||||
Canvas* canvas,
|
||||
uint8_t x,
|
||||
uint8_t y,
|
||||
uint8_t width,
|
||||
uint8_t height,
|
||||
uint8_t radius) {
|
||||
furi_assert(canvas);
|
||||
int32_t x,
|
||||
int32_t y,
|
||||
size_t width,
|
||||
size_t height,
|
||||
size_t radius) {
|
||||
furi_check(canvas);
|
||||
x += canvas->offset_x;
|
||||
y += canvas->offset_y;
|
||||
u8g2_DrawRFrame(&canvas->fb, x, y, width, height, radius);
|
||||
}
|
||||
|
||||
void canvas_draw_line(Canvas* canvas, uint8_t x1, uint8_t y1, uint8_t x2, uint8_t y2) {
|
||||
furi_assert(canvas);
|
||||
void canvas_draw_line(Canvas* canvas, int32_t x1, int32_t y1, int32_t x2, int32_t y2) {
|
||||
furi_check(canvas);
|
||||
x1 += canvas->offset_x;
|
||||
y1 += canvas->offset_y;
|
||||
x2 += canvas->offset_x;
|
||||
@@ -501,15 +497,15 @@ void canvas_draw_line(Canvas* canvas, uint8_t x1, uint8_t y1, uint8_t x2, uint8_
|
||||
u8g2_DrawLine(&canvas->fb, x1, y1, x2, y2);
|
||||
}
|
||||
|
||||
void canvas_draw_circle(Canvas* canvas, uint8_t x, uint8_t y, uint8_t radius) {
|
||||
furi_assert(canvas);
|
||||
void canvas_draw_circle(Canvas* canvas, int32_t x, int32_t y, size_t radius) {
|
||||
furi_check(canvas);
|
||||
x += canvas->offset_x;
|
||||
y += canvas->offset_y;
|
||||
u8g2_DrawCircle(&canvas->fb, x, y, radius, U8G2_DRAW_ALL);
|
||||
}
|
||||
|
||||
void canvas_draw_disc(Canvas* canvas, uint8_t x, uint8_t y, uint8_t radius) {
|
||||
furi_assert(canvas);
|
||||
void canvas_draw_disc(Canvas* canvas, int32_t x, int32_t y, size_t radius) {
|
||||
furi_check(canvas);
|
||||
x += canvas->offset_x;
|
||||
y += canvas->offset_y;
|
||||
u8g2_DrawDisc(&canvas->fb, x, y, radius, U8G2_DRAW_ALL);
|
||||
@@ -517,12 +513,12 @@ void canvas_draw_disc(Canvas* canvas, uint8_t x, uint8_t y, uint8_t radius) {
|
||||
|
||||
void canvas_draw_triangle(
|
||||
Canvas* canvas,
|
||||
uint8_t x,
|
||||
uint8_t y,
|
||||
uint8_t base,
|
||||
uint8_t height,
|
||||
int32_t x,
|
||||
int32_t y,
|
||||
size_t base,
|
||||
size_t height,
|
||||
CanvasDirection dir) {
|
||||
furi_assert(canvas);
|
||||
furi_check(canvas);
|
||||
if(dir == CanvasDirectionBottomToTop) {
|
||||
canvas_draw_line(canvas, x - base / 2, y, x + base / 2, y);
|
||||
canvas_draw_line(canvas, x - base / 2, y, x, y - height + 1);
|
||||
@@ -544,19 +540,19 @@ void canvas_draw_triangle(
|
||||
|
||||
void canvas_draw_xbm(
|
||||
Canvas* canvas,
|
||||
uint8_t x,
|
||||
uint8_t y,
|
||||
uint8_t w,
|
||||
uint8_t h,
|
||||
int32_t x,
|
||||
int32_t y,
|
||||
size_t width,
|
||||
size_t height,
|
||||
const uint8_t* bitmap) {
|
||||
furi_assert(canvas);
|
||||
furi_check(canvas);
|
||||
x += canvas->offset_x;
|
||||
y += canvas->offset_y;
|
||||
canvas_draw_u8g2_bitmap(&canvas->fb, x, y, w, h, bitmap, IconRotation0);
|
||||
canvas_draw_u8g2_bitmap(&canvas->fb, x, y, width, height, bitmap, IconRotation0);
|
||||
}
|
||||
|
||||
void canvas_draw_glyph(Canvas* canvas, uint8_t x, uint8_t y, uint16_t ch) {
|
||||
furi_assert(canvas);
|
||||
void canvas_draw_glyph(Canvas* canvas, int32_t x, int32_t y, uint16_t ch) {
|
||||
furi_check(canvas);
|
||||
x += canvas->offset_x;
|
||||
y += canvas->offset_y;
|
||||
u8g2_DrawGlyph(&canvas->fb, x, y, ch);
|
||||
@@ -567,7 +563,7 @@ void canvas_set_bitmap_mode(Canvas* canvas, bool alpha) {
|
||||
}
|
||||
|
||||
void canvas_set_orientation(Canvas* canvas, CanvasOrientation orientation) {
|
||||
furi_assert(canvas);
|
||||
furi_check(canvas);
|
||||
const u8g2_cb_t* rotate_cb = NULL;
|
||||
bool need_swap = false;
|
||||
if(canvas->orientation != orientation) {
|
||||
@@ -607,12 +603,12 @@ CanvasOrientation canvas_get_orientation(const Canvas* canvas) {
|
||||
}
|
||||
|
||||
void canvas_add_framebuffer_callback(Canvas* canvas, CanvasCommitCallback callback, void* context) {
|
||||
furi_assert(canvas);
|
||||
furi_check(canvas);
|
||||
|
||||
const CanvasCallbackPair p = {callback, context};
|
||||
|
||||
canvas_lock(canvas);
|
||||
furi_assert(!CanvasCallbackPairArray_count(canvas->canvas_callback_pair, p));
|
||||
furi_check(!CanvasCallbackPairArray_count(canvas->canvas_callback_pair, p));
|
||||
CanvasCallbackPairArray_push_back(canvas->canvas_callback_pair, p);
|
||||
canvas_unlock(canvas);
|
||||
}
|
||||
@@ -621,12 +617,12 @@ void canvas_remove_framebuffer_callback(
|
||||
Canvas* canvas,
|
||||
CanvasCommitCallback callback,
|
||||
void* context) {
|
||||
furi_assert(canvas);
|
||||
furi_check(canvas);
|
||||
|
||||
const CanvasCallbackPair p = {callback, context};
|
||||
|
||||
canvas_lock(canvas);
|
||||
furi_assert(CanvasCallbackPairArray_count(canvas->canvas_callback_pair, p) == 1);
|
||||
furi_check(CanvasCallbackPairArray_count(canvas->canvas_callback_pair, p) == 1);
|
||||
CanvasCallbackPairArray_remove_val(canvas->canvas_callback_pair, p);
|
||||
canvas_unlock(canvas);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include <gui/icon_animation.h>
|
||||
#include <gui/icon.h>
|
||||
|
||||
@@ -102,7 +103,7 @@ void canvas_commit(Canvas* canvas);
|
||||
*
|
||||
* @return width in pixels.
|
||||
*/
|
||||
uint8_t canvas_width(const Canvas* canvas);
|
||||
size_t canvas_width(const Canvas* canvas);
|
||||
|
||||
/** Get Canvas height
|
||||
*
|
||||
@@ -110,7 +111,7 @@ uint8_t canvas_width(const Canvas* canvas);
|
||||
*
|
||||
* @return height in pixels.
|
||||
*/
|
||||
uint8_t canvas_height(const Canvas* canvas);
|
||||
size_t canvas_height(const Canvas* canvas);
|
||||
|
||||
/** Get current font height
|
||||
*
|
||||
@@ -118,7 +119,7 @@ uint8_t canvas_height(const Canvas* canvas);
|
||||
*
|
||||
* @return height in pixels.
|
||||
*/
|
||||
uint8_t canvas_current_font_height(const Canvas* canvas);
|
||||
size_t canvas_current_font_height(const Canvas* canvas);
|
||||
|
||||
/** Get current font width
|
||||
*
|
||||
@@ -126,7 +127,7 @@ uint8_t canvas_current_font_height(const Canvas* canvas);
|
||||
*
|
||||
* @return width in pixels.
|
||||
*/
|
||||
uint8_t canvas_current_font_width(const Canvas* canvas);
|
||||
size_t canvas_current_font_width(const Canvas* canvas);
|
||||
|
||||
/** Get font parameters
|
||||
*
|
||||
@@ -150,8 +151,7 @@ void canvas_clear(Canvas* canvas);
|
||||
*/
|
||||
void canvas_set_color(Canvas* canvas, Color color);
|
||||
|
||||
/** Set font swap
|
||||
* Argument String Rotation Description
|
||||
/** Set font swap Argument String Rotation Description
|
||||
*
|
||||
* @param canvas Canvas instance
|
||||
* @param dir Direction font
|
||||
@@ -185,7 +185,7 @@ void canvas_set_custom_u8g2_font(Canvas* canvas, const uint8_t* font);
|
||||
* @param y anchor point y coordinate
|
||||
* @param str C-string
|
||||
*/
|
||||
void canvas_draw_str(Canvas* canvas, uint8_t x, uint8_t y, const char* str);
|
||||
void canvas_draw_str(Canvas* canvas, int32_t x, int32_t y, const char* str);
|
||||
|
||||
/** Draw aligned string defined by x, y.
|
||||
*
|
||||
@@ -201,8 +201,8 @@ void canvas_draw_str(Canvas* canvas, uint8_t x, uint8_t y, const char* str);
|
||||
*/
|
||||
void canvas_draw_str_aligned(
|
||||
Canvas* canvas,
|
||||
uint8_t x,
|
||||
uint8_t y,
|
||||
int32_t x,
|
||||
int32_t y,
|
||||
Align horizontal,
|
||||
Align vertical,
|
||||
const char* str);
|
||||
@@ -223,37 +223,37 @@ uint16_t canvas_string_width(Canvas* canvas, const char* str);
|
||||
*
|
||||
* @return width in pixels
|
||||
*/
|
||||
uint8_t canvas_glyph_width(Canvas* canvas, uint16_t symbol);
|
||||
size_t canvas_glyph_width(Canvas* canvas, uint16_t symbol);
|
||||
|
||||
/** Draw bitmap picture at position defined by x,y.
|
||||
*
|
||||
* @param canvas Canvas instance
|
||||
* @param x x coordinate
|
||||
* @param y y coordinate
|
||||
* @param width width of bitmap
|
||||
* @param height height of bitmap
|
||||
* @param compressed_bitmap_data compressed bitmap data
|
||||
* @param canvas Canvas instance
|
||||
* @param x x coordinate
|
||||
* @param y y coordinate
|
||||
* @param width width of bitmap
|
||||
* @param height height of bitmap
|
||||
* @param compressed_bitmap_data compressed bitmap data
|
||||
*/
|
||||
void canvas_draw_bitmap(
|
||||
Canvas* canvas,
|
||||
uint8_t x,
|
||||
uint8_t y,
|
||||
uint8_t width,
|
||||
uint8_t height,
|
||||
int32_t x,
|
||||
int32_t y,
|
||||
size_t width,
|
||||
size_t height,
|
||||
const uint8_t* compressed_bitmap_data);
|
||||
|
||||
/** Draw icon at position defined by x,y with rotation and flip.
|
||||
*
|
||||
* @param canvas Canvas instance
|
||||
* @param x x coordinate
|
||||
* @param y y coordinate
|
||||
* @param icon Icon instance
|
||||
* @param rotation IconRotation
|
||||
* @param canvas Canvas instance
|
||||
* @param x x coordinate
|
||||
* @param y y coordinate
|
||||
* @param icon Icon instance
|
||||
* @param rotation IconRotation
|
||||
*/
|
||||
void canvas_draw_icon_ex(
|
||||
Canvas* canvas,
|
||||
uint8_t x,
|
||||
uint8_t y,
|
||||
int32_t x,
|
||||
int32_t y,
|
||||
const Icon* icon,
|
||||
IconRotation rotation);
|
||||
|
||||
@@ -266,8 +266,8 @@ void canvas_draw_icon_ex(
|
||||
*/
|
||||
void canvas_draw_icon_animation(
|
||||
Canvas* canvas,
|
||||
uint8_t x,
|
||||
uint8_t y,
|
||||
int32_t x,
|
||||
int32_t y,
|
||||
IconAnimation* icon_animation);
|
||||
|
||||
/** Draw icon at position defined by x,y.
|
||||
@@ -277,23 +277,23 @@ void canvas_draw_icon_animation(
|
||||
* @param y y coordinate
|
||||
* @param icon Icon instance
|
||||
*/
|
||||
void canvas_draw_icon(Canvas* canvas, uint8_t x, uint8_t y, const Icon* icon);
|
||||
void canvas_draw_icon(Canvas* canvas, int32_t x, int32_t y, const Icon* icon);
|
||||
|
||||
/** Draw XBM bitmap
|
||||
*
|
||||
* @param canvas Canvas instance
|
||||
* @param x x coordinate
|
||||
* @param y y coordinate
|
||||
* @param w bitmap width
|
||||
* @param h bitmap height
|
||||
* @param[in] width bitmap width
|
||||
* @param[in] height bitmap height
|
||||
* @param bitmap pointer to XBM bitmap data
|
||||
*/
|
||||
void canvas_draw_xbm(
|
||||
Canvas* canvas,
|
||||
uint8_t x,
|
||||
uint8_t y,
|
||||
uint8_t w,
|
||||
uint8_t h,
|
||||
int32_t x,
|
||||
int32_t y,
|
||||
size_t width,
|
||||
size_t height,
|
||||
const uint8_t* bitmap);
|
||||
|
||||
/** Draw dot at x,y
|
||||
@@ -302,7 +302,7 @@ void canvas_draw_xbm(
|
||||
* @param x x coordinate
|
||||
* @param y y coordinate
|
||||
*/
|
||||
void canvas_draw_dot(Canvas* canvas, uint8_t x, uint8_t y);
|
||||
void canvas_draw_dot(Canvas* canvas, int32_t x, int32_t y);
|
||||
|
||||
/** Draw box of width, height at x,y
|
||||
*
|
||||
@@ -312,7 +312,7 @@ void canvas_draw_dot(Canvas* canvas, uint8_t x, uint8_t y);
|
||||
* @param width box width
|
||||
* @param height box height
|
||||
*/
|
||||
void canvas_draw_box(Canvas* canvas, uint8_t x, uint8_t y, uint8_t width, uint8_t height);
|
||||
void canvas_draw_box(Canvas* canvas, int32_t x, int32_t y, size_t width, size_t height);
|
||||
|
||||
/** Draw frame of width, height at x,y
|
||||
*
|
||||
@@ -322,7 +322,7 @@ void canvas_draw_box(Canvas* canvas, uint8_t x, uint8_t y, uint8_t width, uint8_
|
||||
* @param width frame width
|
||||
* @param height frame height
|
||||
*/
|
||||
void canvas_draw_frame(Canvas* canvas, uint8_t x, uint8_t y, uint8_t width, uint8_t height);
|
||||
void canvas_draw_frame(Canvas* canvas, int32_t x, int32_t y, size_t width, size_t height);
|
||||
|
||||
/** Draw line from x1,y1 to x2,y2
|
||||
*
|
||||
@@ -332,41 +332,42 @@ void canvas_draw_frame(Canvas* canvas, uint8_t x, uint8_t y, uint8_t width, uint
|
||||
* @param x2 x2 coordinate
|
||||
* @param y2 y2 coordinate
|
||||
*/
|
||||
void canvas_draw_line(Canvas* canvas, uint8_t x1, uint8_t y1, uint8_t x2, uint8_t y2);
|
||||
void canvas_draw_line(Canvas* canvas, int32_t x1, int32_t y1, int32_t x2, int32_t y2);
|
||||
|
||||
/** Draw circle at x,y with radius r
|
||||
*
|
||||
* @param canvas Canvas instance
|
||||
* @param x x coordinate
|
||||
* @param y y coordinate
|
||||
* @param r radius
|
||||
* @param radius radius
|
||||
*/
|
||||
void canvas_draw_circle(Canvas* canvas, uint8_t x, uint8_t y, uint8_t r);
|
||||
void canvas_draw_circle(Canvas* canvas, int32_t x, int32_t y, size_t radius);
|
||||
|
||||
/** Draw disc at x,y with radius r
|
||||
*
|
||||
* @param canvas Canvas instance
|
||||
* @param x x coordinate
|
||||
* @param y y coordinate
|
||||
* @param r radius
|
||||
* @param radius radius
|
||||
*/
|
||||
void canvas_draw_disc(Canvas* canvas, uint8_t x, uint8_t y, uint8_t r);
|
||||
void canvas_draw_disc(Canvas* canvas, int32_t x, int32_t y, size_t radius);
|
||||
|
||||
/** Draw triangle with given base and height lengths and their intersection coordinate
|
||||
/** Draw triangle with given base and height lengths and their intersection
|
||||
* coordinate
|
||||
*
|
||||
* @param canvas Canvas instance
|
||||
* @param x x coordinate of base and height intersection
|
||||
* @param y y coordinate of base and height intersection
|
||||
* @param base length of triangle side
|
||||
* @param height length of triangle height
|
||||
* @param dir CanvasDirection triangle orientation
|
||||
* @param canvas Canvas instance
|
||||
* @param x x coordinate of base and height intersection
|
||||
* @param y y coordinate of base and height intersection
|
||||
* @param base length of triangle side
|
||||
* @param height length of triangle height
|
||||
* @param dir CanvasDirection triangle orientation
|
||||
*/
|
||||
void canvas_draw_triangle(
|
||||
Canvas* canvas,
|
||||
uint8_t x,
|
||||
uint8_t y,
|
||||
uint8_t base,
|
||||
uint8_t height,
|
||||
int32_t x,
|
||||
int32_t y,
|
||||
size_t base,
|
||||
size_t height,
|
||||
CanvasDirection dir);
|
||||
|
||||
/** Draw glyph
|
||||
@@ -376,7 +377,7 @@ void canvas_draw_triangle(
|
||||
* @param y y coordinate
|
||||
* @param ch character
|
||||
*/
|
||||
void canvas_draw_glyph(Canvas* canvas, uint8_t x, uint8_t y, uint16_t ch);
|
||||
void canvas_draw_glyph(Canvas* canvas, int32_t x, int32_t y, uint16_t ch);
|
||||
|
||||
/** Set transparency mode
|
||||
*
|
||||
@@ -396,11 +397,11 @@ void canvas_set_bitmap_mode(Canvas* canvas, bool alpha);
|
||||
*/
|
||||
void canvas_draw_rframe(
|
||||
Canvas* canvas,
|
||||
uint8_t x,
|
||||
uint8_t y,
|
||||
uint8_t width,
|
||||
uint8_t height,
|
||||
uint8_t radius);
|
||||
int32_t x,
|
||||
int32_t y,
|
||||
size_t width,
|
||||
size_t height,
|
||||
size_t radius);
|
||||
|
||||
/** Draw rounded-corner box of width, height at x,y, with round value radius
|
||||
*
|
||||
@@ -413,11 +414,11 @@ void canvas_draw_rframe(
|
||||
*/
|
||||
void canvas_draw_rbox(
|
||||
Canvas* canvas,
|
||||
uint8_t x,
|
||||
uint8_t y,
|
||||
uint8_t width,
|
||||
uint8_t height,
|
||||
uint8_t radius);
|
||||
int32_t x,
|
||||
int32_t y,
|
||||
size_t width,
|
||||
size_t height,
|
||||
size_t radius);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -38,10 +38,10 @@ ALGO_DEF(CanvasCallbackPairArray, CanvasCallbackPairArray_t);
|
||||
struct Canvas {
|
||||
u8g2_t fb;
|
||||
CanvasOrientation orientation;
|
||||
uint8_t offset_x;
|
||||
uint8_t offset_y;
|
||||
uint8_t width;
|
||||
uint8_t height;
|
||||
size_t offset_x;
|
||||
size_t offset_y;
|
||||
size_t width;
|
||||
size_t height;
|
||||
CompressIcon* compress_icon;
|
||||
CanvasCallbackPairArray_t canvas_callback_pair;
|
||||
FuriMutex* mutex;
|
||||
@@ -51,7 +51,7 @@ struct Canvas {
|
||||
*
|
||||
* @return Canvas instance
|
||||
*/
|
||||
Canvas* canvas_init();
|
||||
Canvas* canvas_init(void);
|
||||
|
||||
/** Free canvas memory
|
||||
*
|
||||
@@ -85,10 +85,10 @@ size_t canvas_get_buffer_size(const Canvas* canvas);
|
||||
*/
|
||||
void canvas_frame_set(
|
||||
Canvas* canvas,
|
||||
uint8_t offset_x,
|
||||
uint8_t offset_y,
|
||||
uint8_t width,
|
||||
uint8_t height);
|
||||
int32_t offset_x,
|
||||
int32_t offset_y,
|
||||
size_t width,
|
||||
size_t height);
|
||||
|
||||
/** Set canvas orientation
|
||||
*
|
||||
@@ -117,10 +117,10 @@ CanvasOrientation canvas_get_orientation(const Canvas* canvas);
|
||||
*/
|
||||
void canvas_draw_u8g2_bitmap(
|
||||
u8g2_t* u8g2,
|
||||
uint8_t x,
|
||||
uint8_t y,
|
||||
uint8_t width,
|
||||
uint8_t height,
|
||||
int32_t x,
|
||||
int32_t y,
|
||||
size_t width,
|
||||
size_t height,
|
||||
const uint8_t* bitmap,
|
||||
IconRotation rotation);
|
||||
|
||||
|
||||
@@ -28,8 +28,8 @@ typedef struct {
|
||||
} ElementTextBoxLine;
|
||||
|
||||
void elements_progress_bar(Canvas* canvas, uint8_t x, uint8_t y, uint8_t width, float progress) {
|
||||
furi_assert(canvas);
|
||||
furi_assert((progress >= 0) && (progress <= 1.0));
|
||||
furi_check(canvas);
|
||||
furi_check((progress >= 0.0f) && (progress <= 1.0f));
|
||||
uint8_t height = 9;
|
||||
|
||||
uint8_t progress_length = roundf(progress * (width - 2));
|
||||
@@ -49,8 +49,8 @@ void elements_progress_bar_with_text(
|
||||
uint8_t width,
|
||||
float progress,
|
||||
const char* text) {
|
||||
furi_assert(canvas);
|
||||
furi_assert((progress >= 0.0f) && (progress <= 1.0f));
|
||||
furi_check(canvas);
|
||||
furi_check((progress >= 0.0f) && (progress <= 1.0f));
|
||||
uint8_t height = 11;
|
||||
|
||||
uint8_t progress_length = roundf(progress * (width - 2));
|
||||
@@ -74,7 +74,7 @@ void elements_scrollbar_pos(
|
||||
uint8_t height,
|
||||
uint16_t pos,
|
||||
uint16_t total) {
|
||||
furi_assert(canvas);
|
||||
furi_check(canvas);
|
||||
// prevent overflows
|
||||
canvas_set_color(canvas, ColorWhite);
|
||||
canvas_draw_box(canvas, x - 3, y, 3, height);
|
||||
@@ -97,7 +97,7 @@ void elements_scrollbar_horizontal(
|
||||
uint8_t width,
|
||||
uint16_t pos,
|
||||
uint16_t total) {
|
||||
furi_assert(canvas);
|
||||
furi_check(canvas);
|
||||
// prevent overflows
|
||||
canvas_set_color(canvas, ColorWhite);
|
||||
canvas_draw_box(canvas, x, y - 3, width, 3);
|
||||
@@ -114,7 +114,7 @@ void elements_scrollbar_horizontal(
|
||||
}
|
||||
|
||||
void elements_scrollbar(Canvas* canvas, uint16_t pos, uint16_t total) {
|
||||
furi_assert(canvas);
|
||||
furi_check(canvas);
|
||||
|
||||
uint8_t width = canvas_width(canvas);
|
||||
uint8_t height = canvas_height(canvas);
|
||||
@@ -134,7 +134,7 @@ void elements_scrollbar(Canvas* canvas, uint16_t pos, uint16_t total) {
|
||||
}
|
||||
|
||||
void elements_frame(Canvas* canvas, uint8_t x, uint8_t y, uint8_t width, uint8_t height) {
|
||||
furi_assert(canvas);
|
||||
furi_check(canvas);
|
||||
|
||||
canvas_draw_line(canvas, x + 2, y, x + width - 2, y);
|
||||
canvas_draw_line(canvas, x + 1, y + height - 1, x + width, y + height - 1);
|
||||
@@ -148,6 +148,8 @@ void elements_frame(Canvas* canvas, uint8_t x, uint8_t y, uint8_t width, uint8_t
|
||||
}
|
||||
|
||||
void elements_button_left(Canvas* canvas, const char* str) {
|
||||
furi_check(canvas);
|
||||
|
||||
const uint8_t button_height = 12;
|
||||
const uint8_t vertical_offset = 3;
|
||||
const uint8_t horizontal_offset = 3;
|
||||
@@ -174,6 +176,8 @@ void elements_button_left(Canvas* canvas, const char* str) {
|
||||
}
|
||||
|
||||
void elements_button_right(Canvas* canvas, const char* str) {
|
||||
furi_check(canvas);
|
||||
|
||||
const uint8_t button_height = 12;
|
||||
const uint8_t vertical_offset = 3;
|
||||
const uint8_t horizontal_offset = 3;
|
||||
@@ -200,6 +204,8 @@ void elements_button_right(Canvas* canvas, const char* str) {
|
||||
}
|
||||
|
||||
void elements_button_center(Canvas* canvas, const char* str) {
|
||||
furi_check(canvas);
|
||||
|
||||
const uint8_t button_height = 12;
|
||||
const uint8_t vertical_offset = 3;
|
||||
const uint8_t horizontal_offset = 1;
|
||||
@@ -283,8 +289,8 @@ void elements_multiline_text_aligned(
|
||||
Align horizontal,
|
||||
Align vertical,
|
||||
const char* text) {
|
||||
furi_assert(canvas);
|
||||
furi_assert(text);
|
||||
furi_check(canvas);
|
||||
furi_check(text);
|
||||
|
||||
uint8_t lines_count = 0;
|
||||
uint8_t font_height = canvas_current_font_height(canvas);
|
||||
@@ -329,8 +335,8 @@ void elements_multiline_text_aligned(
|
||||
}
|
||||
|
||||
void elements_multiline_text(Canvas* canvas, uint8_t x, uint8_t y, const char* text) {
|
||||
furi_assert(canvas);
|
||||
furi_assert(text);
|
||||
furi_check(canvas);
|
||||
furi_check(text);
|
||||
|
||||
uint8_t font_height = canvas_current_font_height(canvas);
|
||||
FuriString* str;
|
||||
@@ -352,8 +358,8 @@ void elements_multiline_text(Canvas* canvas, uint8_t x, uint8_t y, const char* t
|
||||
}
|
||||
|
||||
void elements_multiline_text_framed(Canvas* canvas, uint8_t x, uint8_t y, const char* text) {
|
||||
furi_assert(canvas);
|
||||
furi_assert(text);
|
||||
furi_check(canvas);
|
||||
furi_check(text);
|
||||
|
||||
uint8_t font_y = canvas_current_font_height(canvas);
|
||||
uint16_t str_width = canvas_string_width(canvas, text);
|
||||
@@ -382,7 +388,7 @@ void elements_slightly_rounded_frame(
|
||||
uint8_t y,
|
||||
uint8_t width,
|
||||
uint8_t height) {
|
||||
furi_assert(canvas);
|
||||
furi_check(canvas);
|
||||
canvas_draw_rframe(canvas, x, y, width, height, 1);
|
||||
}
|
||||
|
||||
@@ -392,7 +398,7 @@ void elements_slightly_rounded_box(
|
||||
uint8_t y,
|
||||
uint8_t width,
|
||||
uint8_t height) {
|
||||
furi_assert(canvas);
|
||||
furi_check(canvas);
|
||||
canvas_draw_rbox(canvas, x, y, width, height, 1);
|
||||
}
|
||||
|
||||
@@ -402,7 +408,7 @@ void elements_bold_rounded_frame(
|
||||
uint8_t y,
|
||||
uint8_t width,
|
||||
uint8_t height) {
|
||||
furi_assert(canvas);
|
||||
furi_check(canvas);
|
||||
|
||||
canvas_set_color(canvas, ColorWhite);
|
||||
canvas_draw_box(canvas, x + 2, y + 2, width - 3, height - 3);
|
||||
@@ -438,7 +444,7 @@ void elements_bold_rounded_frame(
|
||||
}
|
||||
|
||||
void elements_bubble(Canvas* canvas, uint8_t x, uint8_t y, uint8_t width, uint8_t height) {
|
||||
furi_assert(canvas);
|
||||
furi_check(canvas);
|
||||
canvas_draw_rframe(canvas, x + 4, y, width, height, 3);
|
||||
uint8_t y_corner = y + height * 2 / 3;
|
||||
canvas_draw_line(canvas, x, y_corner, x + 4, y_corner - 4);
|
||||
@@ -455,8 +461,8 @@ void elements_bubble_str(
|
||||
const char* text,
|
||||
Align horizontal,
|
||||
Align vertical) {
|
||||
furi_assert(canvas);
|
||||
furi_assert(text);
|
||||
furi_check(canvas);
|
||||
furi_check(text);
|
||||
|
||||
uint8_t font_y = canvas_current_font_height(canvas);
|
||||
uint16_t str_width = canvas_string_width(canvas, text);
|
||||
@@ -583,8 +589,8 @@ void elements_bubble_str(
|
||||
}
|
||||
|
||||
void elements_string_fit_width(Canvas* canvas, FuriString* string, uint8_t width) {
|
||||
furi_assert(canvas);
|
||||
furi_assert(string);
|
||||
furi_check(canvas);
|
||||
furi_check(string);
|
||||
|
||||
uint16_t len_px = canvas_string_width(canvas, furi_string_get_cstr(string));
|
||||
if(len_px > width) {
|
||||
@@ -606,7 +612,10 @@ void elements_scrollable_text_line_str(
|
||||
size_t scroll,
|
||||
bool ellipsis,
|
||||
bool centered) {
|
||||
FuriString* line = furi_string_alloc_set_str(string);
|
||||
furi_check(canvas);
|
||||
furi_check(string);
|
||||
|
||||
FuriString* line = furi_string_alloc_set(string);
|
||||
|
||||
size_t len_px = canvas_string_width(canvas, furi_string_get_cstr(line));
|
||||
if(len_px > width) {
|
||||
@@ -690,7 +699,7 @@ void elements_text_box(
|
||||
Align vertical,
|
||||
const char* text,
|
||||
bool strip_to_dots) {
|
||||
furi_assert(canvas);
|
||||
furi_check(canvas);
|
||||
|
||||
ElementTextBoxLine line[ELEMENTS_MAX_LINES_NUM];
|
||||
bool bold = false;
|
||||
|
||||
@@ -417,9 +417,10 @@ void gui_unlock(Gui* gui) {
|
||||
}
|
||||
|
||||
void gui_add_view_port(Gui* gui, ViewPort* view_port, GuiLayer layer) {
|
||||
furi_assert(gui);
|
||||
furi_assert(view_port);
|
||||
furi_check(gui);
|
||||
furi_check(view_port);
|
||||
furi_check(layer < GuiLayerMAX);
|
||||
|
||||
// Only fullscreen supports Vertical orientation for now
|
||||
ViewPortOrientation view_port_orientation = view_port_get_orientation(view_port);
|
||||
furi_check(
|
||||
@@ -447,8 +448,8 @@ void gui_add_view_port(Gui* gui, ViewPort* view_port, GuiLayer layer) {
|
||||
}
|
||||
|
||||
void gui_remove_view_port(Gui* gui, ViewPort* view_port) {
|
||||
furi_assert(gui);
|
||||
furi_assert(view_port);
|
||||
furi_check(gui);
|
||||
furi_check(view_port);
|
||||
|
||||
gui_lock(gui);
|
||||
view_port_gui_set(view_port, NULL);
|
||||
@@ -473,8 +474,8 @@ void gui_remove_view_port(Gui* gui, ViewPort* view_port) {
|
||||
}
|
||||
|
||||
void gui_view_port_send_to_front(Gui* gui, ViewPort* view_port) {
|
||||
furi_assert(gui);
|
||||
furi_assert(view_port);
|
||||
furi_check(gui);
|
||||
furi_check(view_port);
|
||||
|
||||
gui_lock(gui);
|
||||
// Remove
|
||||
@@ -485,14 +486,14 @@ void gui_view_port_send_to_front(Gui* gui, ViewPort* view_port) {
|
||||
while(!ViewPortArray_end_p(it)) {
|
||||
if(*ViewPortArray_ref(it) == view_port) {
|
||||
ViewPortArray_remove(gui->layers[i], it);
|
||||
furi_assert(layer == GuiLayerMAX);
|
||||
furi_check(layer == GuiLayerMAX);
|
||||
layer = i;
|
||||
} else {
|
||||
ViewPortArray_next(it);
|
||||
}
|
||||
}
|
||||
}
|
||||
furi_assert(layer != GuiLayerMAX);
|
||||
furi_check(layer != GuiLayerMAX);
|
||||
// Return to the top
|
||||
ViewPortArray_push_back(gui->layers[layer], view_port);
|
||||
gui_unlock(gui);
|
||||
@@ -531,7 +532,7 @@ void gui_view_port_send_to_back(Gui* gui, ViewPort* view_port) {
|
||||
}
|
||||
|
||||
void gui_add_framebuffer_callback(Gui* gui, GuiCanvasCommitCallback callback, void* context) {
|
||||
furi_assert(gui);
|
||||
furi_check(gui);
|
||||
|
||||
canvas_add_framebuffer_callback(gui->canvas, callback, context);
|
||||
|
||||
@@ -540,13 +541,14 @@ void gui_add_framebuffer_callback(Gui* gui, GuiCanvasCommitCallback callback, vo
|
||||
}
|
||||
|
||||
void gui_remove_framebuffer_callback(Gui* gui, GuiCanvasCommitCallback callback, void* context) {
|
||||
furi_assert(gui);
|
||||
furi_check(gui);
|
||||
|
||||
canvas_remove_framebuffer_callback(gui->canvas, callback, context);
|
||||
}
|
||||
|
||||
size_t gui_get_framebuffer_size(const Gui* gui) {
|
||||
furi_assert(gui);
|
||||
furi_check(gui);
|
||||
|
||||
return canvas_get_buffer_size(gui->canvas);
|
||||
}
|
||||
|
||||
@@ -566,7 +568,7 @@ void gui_set_hide_statusbar(Gui* gui, bool hidden) {
|
||||
}
|
||||
|
||||
void gui_set_lockdown(Gui* gui, bool lockdown) {
|
||||
furi_assert(gui);
|
||||
furi_check(gui);
|
||||
|
||||
gui_lock(gui);
|
||||
gui->lockdown = lockdown;
|
||||
@@ -577,7 +579,8 @@ void gui_set_lockdown(Gui* gui, bool lockdown) {
|
||||
}
|
||||
|
||||
Canvas* gui_direct_draw_acquire(Gui* gui) {
|
||||
furi_assert(gui);
|
||||
furi_check(gui);
|
||||
|
||||
gui_lock(gui);
|
||||
gui->direct_draw = true;
|
||||
gui_unlock(gui);
|
||||
@@ -591,7 +594,7 @@ Canvas* gui_direct_draw_acquire(Gui* gui) {
|
||||
}
|
||||
|
||||
void gui_direct_draw_release(Gui* gui) {
|
||||
furi_assert(gui);
|
||||
furi_check(gui);
|
||||
|
||||
canvas_reset(gui->canvas);
|
||||
canvas_commit(gui->canvas);
|
||||
@@ -603,7 +606,7 @@ void gui_direct_draw_release(Gui* gui) {
|
||||
gui_update(gui);
|
||||
}
|
||||
|
||||
Gui* gui_alloc() {
|
||||
Gui* gui_alloc(void) {
|
||||
Gui* gui = malloc(sizeof(Gui));
|
||||
// Thread ID
|
||||
gui->thread_id = furi_thread_get_current_id();
|
||||
|
||||
@@ -1,13 +1,20 @@
|
||||
#include "icon_i.h"
|
||||
#include <furi.h>
|
||||
|
||||
uint8_t icon_get_width(const Icon* instance) {
|
||||
furi_check(instance);
|
||||
|
||||
return instance->width;
|
||||
}
|
||||
|
||||
uint8_t icon_get_height(const Icon* instance) {
|
||||
furi_check(instance);
|
||||
|
||||
return instance->height;
|
||||
}
|
||||
|
||||
const uint8_t* icon_get_data(const Icon* instance) {
|
||||
furi_check(instance);
|
||||
|
||||
return instance->frames[0];
|
||||
}
|
||||
|
||||
@@ -4,18 +4,22 @@
|
||||
#include <furi.h>
|
||||
|
||||
IconAnimation* icon_animation_alloc(const Icon* icon) {
|
||||
furi_assert(icon);
|
||||
furi_check(icon);
|
||||
|
||||
IconAnimation* instance = malloc(sizeof(IconAnimation));
|
||||
instance->icon = icon;
|
||||
instance->timer =
|
||||
furi_timer_alloc(icon_animation_timer_callback, FuriTimerTypePeriodic, instance);
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
void icon_animation_free(IconAnimation* instance) {
|
||||
furi_assert(instance);
|
||||
furi_check(instance);
|
||||
|
||||
icon_animation_stop(instance);
|
||||
furi_timer_free(instance->timer);
|
||||
|
||||
free(instance);
|
||||
}
|
||||
|
||||
@@ -23,7 +27,8 @@ void icon_animation_set_update_callback(
|
||||
IconAnimation* instance,
|
||||
IconAnimationCallback callback,
|
||||
void* context) {
|
||||
furi_assert(instance);
|
||||
furi_check(instance);
|
||||
|
||||
instance->callback = callback;
|
||||
instance->callback_context = context;
|
||||
}
|
||||
@@ -51,17 +56,20 @@ void icon_animation_timer_callback(void* context) {
|
||||
}
|
||||
|
||||
uint8_t icon_animation_get_width(const IconAnimation* instance) {
|
||||
furi_assert(instance);
|
||||
furi_check(instance);
|
||||
|
||||
return instance->icon->width;
|
||||
}
|
||||
|
||||
uint8_t icon_animation_get_height(const IconAnimation* instance) {
|
||||
furi_assert(instance);
|
||||
furi_check(instance);
|
||||
|
||||
return instance->icon->height;
|
||||
}
|
||||
|
||||
void icon_animation_start(IconAnimation* instance) {
|
||||
furi_assert(instance);
|
||||
furi_check(instance);
|
||||
|
||||
if(!instance->animating && instance->icon->frame_rate && instance->icon->frame_count > 1) {
|
||||
instance->animating = true;
|
||||
furi_assert(instance->icon->frame_rate);
|
||||
@@ -73,7 +81,8 @@ void icon_animation_start(IconAnimation* instance) {
|
||||
}
|
||||
|
||||
void icon_animation_stop(IconAnimation* instance) {
|
||||
furi_assert(instance);
|
||||
furi_check(instance);
|
||||
|
||||
if(instance->animating) {
|
||||
instance->animating = false;
|
||||
furi_timer_stop(instance->timer);
|
||||
@@ -82,6 +91,7 @@ void icon_animation_stop(IconAnimation* instance) {
|
||||
}
|
||||
|
||||
bool icon_animation_is_last_frame(const IconAnimation* instance) {
|
||||
furi_assert(instance);
|
||||
furi_check(instance);
|
||||
|
||||
return instance->icon->frame_count - instance->frame <= 1;
|
||||
}
|
||||
|
||||
@@ -300,12 +300,12 @@ static bool button_menu_view_input_callback(InputEvent* event, void* context) {
|
||||
}
|
||||
|
||||
View* button_menu_get_view(ButtonMenu* button_menu) {
|
||||
furi_assert(button_menu);
|
||||
furi_check(button_menu);
|
||||
return button_menu->view;
|
||||
}
|
||||
|
||||
void button_menu_reset(ButtonMenu* button_menu) {
|
||||
furi_assert(button_menu);
|
||||
furi_check(button_menu);
|
||||
|
||||
with_view_model(
|
||||
button_menu->view,
|
||||
@@ -319,7 +319,7 @@ void button_menu_reset(ButtonMenu* button_menu) {
|
||||
}
|
||||
|
||||
void button_menu_set_header(ButtonMenu* button_menu, const char* header) {
|
||||
furi_assert(button_menu);
|
||||
furi_check(button_menu);
|
||||
|
||||
with_view_model(
|
||||
button_menu->view, ButtonMenuModel * model, { model->header = header; }, true);
|
||||
@@ -333,8 +333,8 @@ ButtonMenuItem* button_menu_add_item(
|
||||
ButtonMenuItemType type,
|
||||
void* callback_context) {
|
||||
ButtonMenuItem* item = NULL;
|
||||
furi_assert(label);
|
||||
furi_assert(button_menu);
|
||||
furi_check(label);
|
||||
furi_check(button_menu);
|
||||
|
||||
with_view_model(
|
||||
button_menu->view,
|
||||
@@ -376,7 +376,7 @@ ButtonMenu* button_menu_alloc(void) {
|
||||
}
|
||||
|
||||
void button_menu_free(ButtonMenu* button_menu) {
|
||||
furi_assert(button_menu);
|
||||
furi_check(button_menu);
|
||||
|
||||
with_view_model(
|
||||
button_menu->view,
|
||||
@@ -388,7 +388,7 @@ void button_menu_free(ButtonMenu* button_menu) {
|
||||
}
|
||||
|
||||
void button_menu_set_selected_item(ButtonMenu* button_menu, uint32_t index) {
|
||||
furi_assert(button_menu);
|
||||
furi_check(button_menu);
|
||||
|
||||
with_view_model(
|
||||
button_menu->view,
|
||||
|
||||
@@ -67,7 +67,7 @@ static void button_panel_process_ok(ButtonPanel* button_panel);
|
||||
static void button_panel_view_draw_callback(Canvas* canvas, void* _model);
|
||||
static bool button_panel_view_input_callback(InputEvent* event, void* context);
|
||||
|
||||
ButtonPanel* button_panel_alloc() {
|
||||
ButtonPanel* button_panel_alloc(void) {
|
||||
ButtonPanel* button_panel = malloc(sizeof(ButtonPanel));
|
||||
button_panel->view = view_alloc();
|
||||
view_set_orientation(button_panel->view, ViewOrientationVertical);
|
||||
@@ -114,7 +114,7 @@ void button_panel_reserve(ButtonPanel* button_panel, size_t reserve_x, size_t re
|
||||
}
|
||||
|
||||
void button_panel_free(ButtonPanel* button_panel) {
|
||||
furi_assert(button_panel);
|
||||
furi_check(button_panel);
|
||||
|
||||
button_panel_reset(button_panel);
|
||||
|
||||
@@ -132,7 +132,7 @@ void button_panel_free(ButtonPanel* button_panel) {
|
||||
}
|
||||
|
||||
void button_panel_reset(ButtonPanel* button_panel) {
|
||||
furi_assert(button_panel);
|
||||
furi_check(button_panel);
|
||||
|
||||
with_view_model(
|
||||
button_panel->view,
|
||||
@@ -177,7 +177,7 @@ void button_panel_add_item(
|
||||
const Icon* icon_name_selected,
|
||||
ButtonItemCallback callback,
|
||||
void* callback_context) {
|
||||
furi_assert(button_panel);
|
||||
furi_check(button_panel);
|
||||
|
||||
with_view_model( //-V773
|
||||
button_panel->view,
|
||||
@@ -200,7 +200,7 @@ void button_panel_add_item(
|
||||
}
|
||||
|
||||
View* button_panel_get_view(ButtonPanel* button_panel) {
|
||||
furi_assert(button_panel);
|
||||
furi_check(button_panel);
|
||||
return button_panel->view;
|
||||
}
|
||||
|
||||
@@ -405,7 +405,7 @@ void button_panel_add_label(
|
||||
uint16_t y,
|
||||
Font font,
|
||||
const char* label_str) {
|
||||
furi_assert(button_panel);
|
||||
furi_check(button_panel);
|
||||
|
||||
with_view_model(
|
||||
button_panel->view,
|
||||
@@ -426,7 +426,7 @@ void button_panel_add_icon(
|
||||
uint16_t x,
|
||||
uint16_t y,
|
||||
const Icon* icon_name) {
|
||||
furi_assert(button_panel);
|
||||
furi_check(button_panel);
|
||||
|
||||
with_view_model( //-V773
|
||||
button_panel->view,
|
||||
|
||||
@@ -740,7 +740,7 @@ static void byte_input_reset_model_input_data(ByteInputModel* model) {
|
||||
model->first_visible_byte = 0;
|
||||
}
|
||||
|
||||
ByteInput* byte_input_alloc() {
|
||||
ByteInput* byte_input_alloc(void) {
|
||||
ByteInput* byte_input = malloc(sizeof(ByteInput));
|
||||
byte_input->view = view_alloc();
|
||||
view_set_context(byte_input->view, byte_input);
|
||||
@@ -764,13 +764,13 @@ ByteInput* byte_input_alloc() {
|
||||
}
|
||||
|
||||
void byte_input_free(ByteInput* byte_input) {
|
||||
furi_assert(byte_input);
|
||||
furi_check(byte_input);
|
||||
view_free(byte_input->view);
|
||||
free(byte_input);
|
||||
}
|
||||
|
||||
View* byte_input_get_view(ByteInput* byte_input) {
|
||||
furi_assert(byte_input);
|
||||
furi_check(byte_input);
|
||||
return byte_input->view;
|
||||
}
|
||||
|
||||
@@ -781,6 +781,8 @@ void byte_input_set_result_callback(
|
||||
void* callback_context,
|
||||
uint8_t* bytes,
|
||||
uint8_t bytes_count) {
|
||||
furi_check(byte_input);
|
||||
|
||||
with_view_model(
|
||||
byte_input->view,
|
||||
ByteInputModel * model,
|
||||
@@ -796,6 +798,8 @@ void byte_input_set_result_callback(
|
||||
}
|
||||
|
||||
void byte_input_set_header_text(ByteInput* byte_input, const char* text) {
|
||||
furi_check(byte_input);
|
||||
|
||||
with_view_model(
|
||||
byte_input->view, ByteInputModel * model, { model->header = text; }, true);
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ typedef void (*ByteChangedCallback)(void* context);
|
||||
*
|
||||
* @return ByteInput instance pointer
|
||||
*/
|
||||
ByteInput* byte_input_alloc();
|
||||
ByteInput* byte_input_alloc(void);
|
||||
|
||||
/** Deinitialize and free byte input
|
||||
*
|
||||
|
||||
@@ -143,7 +143,7 @@ static bool dialog_ex_view_input_callback(InputEvent* event, void* context) {
|
||||
return consumed;
|
||||
}
|
||||
|
||||
DialogEx* dialog_ex_alloc() {
|
||||
DialogEx* dialog_ex_alloc(void) {
|
||||
DialogEx* dialog_ex = malloc(sizeof(DialogEx));
|
||||
dialog_ex->view = view_alloc();
|
||||
view_set_context(dialog_ex->view, dialog_ex);
|
||||
@@ -180,23 +180,23 @@ DialogEx* dialog_ex_alloc() {
|
||||
}
|
||||
|
||||
void dialog_ex_free(DialogEx* dialog_ex) {
|
||||
furi_assert(dialog_ex);
|
||||
furi_check(dialog_ex);
|
||||
view_free(dialog_ex->view);
|
||||
free(dialog_ex);
|
||||
}
|
||||
|
||||
View* dialog_ex_get_view(DialogEx* dialog_ex) {
|
||||
furi_assert(dialog_ex);
|
||||
furi_check(dialog_ex);
|
||||
return dialog_ex->view;
|
||||
}
|
||||
|
||||
void dialog_ex_set_result_callback(DialogEx* dialog_ex, DialogExResultCallback callback) {
|
||||
furi_assert(dialog_ex);
|
||||
furi_check(dialog_ex);
|
||||
dialog_ex->callback = callback;
|
||||
}
|
||||
|
||||
void dialog_ex_set_context(DialogEx* dialog_ex, void* context) {
|
||||
furi_assert(dialog_ex);
|
||||
furi_check(dialog_ex);
|
||||
dialog_ex->context = context;
|
||||
}
|
||||
|
||||
@@ -207,7 +207,7 @@ void dialog_ex_set_header(
|
||||
uint8_t y,
|
||||
Align horizontal,
|
||||
Align vertical) {
|
||||
furi_assert(dialog_ex);
|
||||
furi_check(dialog_ex);
|
||||
with_view_model(
|
||||
dialog_ex->view,
|
||||
DialogExModel * model,
|
||||
@@ -228,7 +228,7 @@ void dialog_ex_set_text(
|
||||
uint8_t y,
|
||||
Align horizontal,
|
||||
Align vertical) {
|
||||
furi_assert(dialog_ex);
|
||||
furi_check(dialog_ex);
|
||||
with_view_model(
|
||||
dialog_ex->view,
|
||||
DialogExModel * model,
|
||||
@@ -243,7 +243,7 @@ void dialog_ex_set_text(
|
||||
}
|
||||
|
||||
void dialog_ex_set_icon(DialogEx* dialog_ex, uint8_t x, uint8_t y, const Icon* icon) {
|
||||
furi_assert(dialog_ex);
|
||||
furi_check(dialog_ex);
|
||||
with_view_model(
|
||||
dialog_ex->view,
|
||||
DialogExModel * model,
|
||||
@@ -256,25 +256,25 @@ void dialog_ex_set_icon(DialogEx* dialog_ex, uint8_t x, uint8_t y, const Icon* i
|
||||
}
|
||||
|
||||
void dialog_ex_set_left_button_text(DialogEx* dialog_ex, const char* text) {
|
||||
furi_assert(dialog_ex);
|
||||
furi_check(dialog_ex);
|
||||
with_view_model(
|
||||
dialog_ex->view, DialogExModel * model, { model->left_text = text; }, true);
|
||||
}
|
||||
|
||||
void dialog_ex_set_center_button_text(DialogEx* dialog_ex, const char* text) {
|
||||
furi_assert(dialog_ex);
|
||||
furi_check(dialog_ex);
|
||||
with_view_model(
|
||||
dialog_ex->view, DialogExModel * model, { model->center_text = text; }, true);
|
||||
}
|
||||
|
||||
void dialog_ex_set_right_button_text(DialogEx* dialog_ex, const char* text) {
|
||||
furi_assert(dialog_ex);
|
||||
furi_check(dialog_ex);
|
||||
with_view_model(
|
||||
dialog_ex->view, DialogExModel * model, { model->right_text = text; }, true);
|
||||
}
|
||||
|
||||
void dialog_ex_reset(DialogEx* dialog_ex) {
|
||||
furi_assert(dialog_ex);
|
||||
furi_check(dialog_ex);
|
||||
TextElement clean_text_el = {
|
||||
.text = NULL, .x = 0, .y = 0, .horizontal = AlignLeft, .vertical = AlignLeft};
|
||||
IconElement clean_icon_el = {.icon = NULL, .x = 0, .y = 0};
|
||||
@@ -295,11 +295,11 @@ void dialog_ex_reset(DialogEx* dialog_ex) {
|
||||
}
|
||||
|
||||
void dialog_ex_enable_extended_events(DialogEx* dialog_ex) {
|
||||
furi_assert(dialog_ex);
|
||||
furi_check(dialog_ex);
|
||||
dialog_ex->enable_extended_events = true;
|
||||
}
|
||||
|
||||
void dialog_ex_disable_extended_events(DialogEx* dialog_ex) {
|
||||
furi_assert(dialog_ex);
|
||||
furi_check(dialog_ex);
|
||||
dialog_ex->enable_extended_events = false;
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ typedef void (*DialogExResultCallback)(DialogExResult result, void* context);
|
||||
*
|
||||
* @return DialogEx instance
|
||||
*/
|
||||
DialogEx* dialog_ex_alloc();
|
||||
DialogEx* dialog_ex_alloc(void);
|
||||
|
||||
/** Deinitialize and free dialog
|
||||
*
|
||||
|
||||
@@ -16,7 +16,7 @@ static bool empty_screen_view_input_callback(InputEvent* event, void* context) {
|
||||
return false;
|
||||
}
|
||||
|
||||
EmptyScreen* empty_screen_alloc() {
|
||||
EmptyScreen* empty_screen_alloc(void) {
|
||||
EmptyScreen* empty_screen = malloc(sizeof(EmptyScreen));
|
||||
empty_screen->view = view_alloc();
|
||||
view_set_context(empty_screen->view, empty_screen);
|
||||
@@ -26,12 +26,12 @@ EmptyScreen* empty_screen_alloc() {
|
||||
}
|
||||
|
||||
void empty_screen_free(EmptyScreen* empty_screen) {
|
||||
furi_assert(empty_screen);
|
||||
furi_check(empty_screen);
|
||||
view_free(empty_screen->view);
|
||||
free(empty_screen);
|
||||
}
|
||||
|
||||
View* empty_screen_get_view(EmptyScreen* empty_screen) {
|
||||
furi_assert(empty_screen);
|
||||
furi_check(empty_screen);
|
||||
return empty_screen->view;
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ typedef struct EmptyScreen EmptyScreen;
|
||||
*
|
||||
* @return EmptyScreen instance
|
||||
*/
|
||||
EmptyScreen* empty_screen_alloc();
|
||||
EmptyScreen* empty_screen_alloc(void);
|
||||
|
||||
/** Deinitialize and free empty screen
|
||||
*
|
||||
|
||||
@@ -165,14 +165,14 @@ static void
|
||||
static void browser_long_load_cb(void* context);
|
||||
|
||||
static void file_browser_scroll_timer_callback(void* context) {
|
||||
furi_assert(context);
|
||||
furi_check(context);
|
||||
FileBrowser* browser = context;
|
||||
with_view_model(
|
||||
browser->view, FileBrowserModel * model, { model->scroll_counter++; }, true);
|
||||
}
|
||||
|
||||
static void file_browser_view_enter_callback(void* context) {
|
||||
furi_assert(context);
|
||||
furi_check(context);
|
||||
FileBrowser* browser = context;
|
||||
with_view_model(
|
||||
browser->view, FileBrowserModel * model, { model->scroll_counter = 0; }, true);
|
||||
@@ -180,13 +180,14 @@ static void file_browser_view_enter_callback(void* context) {
|
||||
}
|
||||
|
||||
static void file_browser_view_exit_callback(void* context) {
|
||||
furi_assert(context);
|
||||
furi_check(context);
|
||||
FileBrowser* browser = context;
|
||||
furi_timer_stop(browser->scroll_timer);
|
||||
}
|
||||
|
||||
FileBrowser* file_browser_alloc(FuriString* result_path) {
|
||||
furi_assert(result_path);
|
||||
furi_check(result_path);
|
||||
|
||||
FileBrowser* browser = malloc(sizeof(FileBrowser));
|
||||
browser->view = view_alloc();
|
||||
view_allocate_model(browser->view, ViewModelTypeLocking, sizeof(FileBrowserModel));
|
||||
@@ -208,7 +209,7 @@ FileBrowser* file_browser_alloc(FuriString* result_path) {
|
||||
}
|
||||
|
||||
void file_browser_free(FileBrowser* browser) {
|
||||
furi_assert(browser);
|
||||
furi_check(browser);
|
||||
|
||||
furi_timer_free(browser->scroll_timer);
|
||||
|
||||
@@ -220,7 +221,7 @@ void file_browser_free(FileBrowser* browser) {
|
||||
}
|
||||
|
||||
View* file_browser_get_view(FileBrowser* browser) {
|
||||
furi_assert(browser);
|
||||
furi_check(browser);
|
||||
return browser->view;
|
||||
}
|
||||
|
||||
@@ -232,7 +233,7 @@ void file_browser_configure(
|
||||
bool hide_dot_files,
|
||||
const Icon* file_icon,
|
||||
bool hide_ext) {
|
||||
furi_assert(browser);
|
||||
furi_check(browser);
|
||||
|
||||
browser->ext_filter = extension;
|
||||
browser->skip_assets = skip_assets;
|
||||
@@ -251,7 +252,7 @@ void file_browser_configure(
|
||||
}
|
||||
|
||||
void file_browser_start(FileBrowser* browser, FuriString* path) {
|
||||
furi_assert(browser);
|
||||
furi_check(browser);
|
||||
browser->worker = file_browser_worker_alloc(
|
||||
path,
|
||||
browser->base_path,
|
||||
@@ -266,7 +267,7 @@ void file_browser_start(FileBrowser* browser, FuriString* path) {
|
||||
}
|
||||
|
||||
void file_browser_stop(FileBrowser* browser) {
|
||||
furi_assert(browser);
|
||||
furi_check(browser);
|
||||
file_browser_worker_free(browser->worker);
|
||||
with_view_model(
|
||||
browser->view,
|
||||
@@ -282,6 +283,7 @@ void file_browser_stop(FileBrowser* browser) {
|
||||
}
|
||||
|
||||
void file_browser_set_callback(FileBrowser* browser, FileBrowserCallback callback, void* context) {
|
||||
furi_check(browser);
|
||||
browser->context = context;
|
||||
browser->callback = callback;
|
||||
}
|
||||
@@ -290,6 +292,8 @@ void file_browser_set_item_callback(
|
||||
FileBrowser* browser,
|
||||
FileBrowserLoadItemCallback callback,
|
||||
void* context) {
|
||||
furi_check(browser);
|
||||
|
||||
browser->item_context = context;
|
||||
browser->item_callback = callback;
|
||||
}
|
||||
@@ -335,7 +339,7 @@ static void browser_list_rollover(FileBrowserModel* model) {
|
||||
}
|
||||
|
||||
static void browser_update_offset(FileBrowser* browser) {
|
||||
furi_assert(browser);
|
||||
furi_check(browser);
|
||||
|
||||
with_view_model(
|
||||
browser->view,
|
||||
@@ -361,7 +365,7 @@ static void browser_update_offset(FileBrowser* browser) {
|
||||
|
||||
static void
|
||||
browser_folder_open_cb(void* context, uint32_t item_cnt, int32_t file_idx, bool is_root) {
|
||||
furi_assert(context);
|
||||
furi_check(context);
|
||||
FileBrowser* browser = (FileBrowser*)context;
|
||||
|
||||
int32_t load_offset = 0;
|
||||
@@ -395,7 +399,7 @@ static void
|
||||
}
|
||||
|
||||
static void browser_list_load_cb(void* context, uint32_t list_load_offset) {
|
||||
furi_assert(context);
|
||||
furi_check(context);
|
||||
FileBrowser* browser = (FileBrowser*)context;
|
||||
|
||||
BrowserItem_t back_item;
|
||||
@@ -423,7 +427,7 @@ static void browser_list_load_cb(void* context, uint32_t list_load_offset) {
|
||||
|
||||
static void
|
||||
browser_list_item_cb(void* context, FuriString* item_path, bool is_folder, bool is_last) {
|
||||
furi_assert(context);
|
||||
furi_check(context);
|
||||
FileBrowser* browser = (FileBrowser*)context;
|
||||
|
||||
BrowserItem_t item;
|
||||
@@ -514,7 +518,7 @@ static void
|
||||
}
|
||||
|
||||
static void browser_long_load_cb(void* context) {
|
||||
furi_assert(context);
|
||||
furi_check(context);
|
||||
FileBrowser* browser = (FileBrowser*)context;
|
||||
|
||||
with_view_model(
|
||||
@@ -651,7 +655,7 @@ static void file_browser_view_draw_callback(Canvas* canvas, void* _model) {
|
||||
|
||||
static bool file_browser_view_input_callback(InputEvent* event, void* context) {
|
||||
FileBrowser* browser = context;
|
||||
furi_assert(browser);
|
||||
furi_check(browser);
|
||||
bool consumed = false;
|
||||
bool is_loading = false;
|
||||
|
||||
|
||||
@@ -356,7 +356,7 @@ static bool browser_folder_load_full(BrowserWorker* browser, FuriString* path) {
|
||||
|
||||
static int32_t browser_worker(void* context) {
|
||||
BrowserWorker* browser = (BrowserWorker*)context;
|
||||
furi_assert(browser);
|
||||
furi_check(browser);
|
||||
FURI_LOG_D(TAG, "Start");
|
||||
|
||||
uint32_t items_cnt = 0;
|
||||
@@ -371,7 +371,7 @@ static int32_t browser_worker(void* context) {
|
||||
while(1) {
|
||||
uint32_t flags =
|
||||
furi_thread_flags_wait(WORKER_FLAGS_ALL, FuriFlagWaitAny, FuriWaitForever);
|
||||
furi_assert((flags & FuriFlagError) == 0);
|
||||
furi_check((flags & FuriFlagError) == 0);
|
||||
|
||||
if(flags & WorkerEvtConfigChange) {
|
||||
if(browser->keep_selection && furi_string_start_with(path, browser->path_next)) {
|
||||
@@ -523,7 +523,7 @@ BrowserWorker* file_browser_worker_alloc(
|
||||
} //-V773
|
||||
|
||||
void file_browser_worker_free(BrowserWorker* browser) {
|
||||
furi_assert(browser);
|
||||
furi_check(browser);
|
||||
|
||||
furi_thread_flags_set(furi_thread_get_id(browser->thread), WorkerEvtStop);
|
||||
furi_thread_join(browser->thread);
|
||||
@@ -540,35 +540,35 @@ void file_browser_worker_free(BrowserWorker* browser) {
|
||||
}
|
||||
|
||||
void file_browser_worker_set_callback_context(BrowserWorker* browser, void* context) {
|
||||
furi_assert(browser);
|
||||
furi_check(browser);
|
||||
browser->cb_ctx = context;
|
||||
}
|
||||
|
||||
void file_browser_worker_set_folder_callback(
|
||||
BrowserWorker* browser,
|
||||
BrowserWorkerFolderOpenCallback cb) {
|
||||
furi_assert(browser);
|
||||
furi_check(browser);
|
||||
browser->folder_cb = cb;
|
||||
}
|
||||
|
||||
void file_browser_worker_set_list_callback(
|
||||
BrowserWorker* browser,
|
||||
BrowserWorkerListLoadCallback cb) {
|
||||
furi_assert(browser);
|
||||
furi_check(browser);
|
||||
browser->list_load_cb = cb;
|
||||
}
|
||||
|
||||
void file_browser_worker_set_item_callback(
|
||||
BrowserWorker* browser,
|
||||
BrowserWorkerListItemCallback cb) {
|
||||
furi_assert(browser);
|
||||
furi_check(browser);
|
||||
browser->list_item_cb = cb;
|
||||
}
|
||||
|
||||
void file_browser_worker_set_long_load_callback(
|
||||
BrowserWorker* browser,
|
||||
BrowserWorkerLongLoadCallback cb) {
|
||||
furi_assert(browser);
|
||||
furi_check(browser);
|
||||
browser->long_load_cb = cb;
|
||||
}
|
||||
|
||||
@@ -578,7 +578,7 @@ void file_browser_worker_set_config(
|
||||
const char* ext_filter,
|
||||
bool skip_assets,
|
||||
bool hide_dot_files) {
|
||||
furi_assert(browser);
|
||||
furi_check(browser);
|
||||
furi_string_set(browser->path_next, path);
|
||||
browser->keep_selection = false;
|
||||
browser_parse_ext_filter(browser->ext_filter, ext_filter);
|
||||
@@ -589,7 +589,7 @@ void file_browser_worker_set_config(
|
||||
}
|
||||
|
||||
const char* file_browser_worker_get_filter_ext(BrowserWorker* browser) {
|
||||
furi_assert(browser);
|
||||
furi_check(browser);
|
||||
return furi_string_get_cstr(browser->passed_ext_filter);
|
||||
}
|
||||
|
||||
@@ -597,7 +597,7 @@ void file_browser_worker_set_filter_ext(
|
||||
BrowserWorker* browser,
|
||||
FuriString* path,
|
||||
const char* ext_filter) {
|
||||
furi_assert(browser);
|
||||
furi_check(browser);
|
||||
furi_string_set(browser->path_next, path);
|
||||
browser->keep_selection = true;
|
||||
browser_parse_ext_filter(browser->ext_filter, ext_filter);
|
||||
@@ -606,24 +606,24 @@ void file_browser_worker_set_filter_ext(
|
||||
}
|
||||
|
||||
void file_browser_worker_folder_enter(BrowserWorker* browser, FuriString* path, int32_t item_idx) {
|
||||
furi_assert(browser);
|
||||
furi_check(browser);
|
||||
furi_string_set(browser->path_next, path);
|
||||
UNUSED(item_idx);
|
||||
furi_thread_flags_set(furi_thread_get_id(browser->thread), WorkerEvtFolderEnter);
|
||||
}
|
||||
|
||||
bool file_browser_worker_is_in_start_folder(BrowserWorker* browser) {
|
||||
furi_assert(browser);
|
||||
furi_check(browser);
|
||||
return (furi_string_cmp(browser->path_start, browser->path_current) == 0);
|
||||
}
|
||||
|
||||
void file_browser_worker_folder_exit(BrowserWorker* browser) {
|
||||
furi_assert(browser);
|
||||
furi_check(browser);
|
||||
furi_thread_flags_set(furi_thread_get_id(browser->thread), WorkerEvtFolderExit);
|
||||
}
|
||||
|
||||
void file_browser_worker_folder_refresh_sel(BrowserWorker* browser, const char* item_name) {
|
||||
furi_assert(browser);
|
||||
furi_check(browser);
|
||||
if(item_name != NULL) {
|
||||
furi_string_set(browser->path_next, item_name);
|
||||
} else {
|
||||
@@ -638,7 +638,7 @@ void file_browser_worker_folder_refresh(BrowserWorker* browser, int32_t item_idx
|
||||
}
|
||||
|
||||
void file_browser_worker_load(BrowserWorker* browser, uint32_t offset, uint32_t count) {
|
||||
furi_assert(browser);
|
||||
furi_check(browser);
|
||||
browser->load_offset = offset;
|
||||
browser->load_count = count;
|
||||
furi_thread_flags_set(furi_thread_get_id(browser->thread), WorkerEvtLoad);
|
||||
|
||||
@@ -79,6 +79,8 @@ Loading* loading_alloc(void) {
|
||||
}
|
||||
|
||||
void loading_free(Loading* instance) {
|
||||
furi_check(instance);
|
||||
|
||||
LoadingModel* model = view_get_model(instance->view);
|
||||
icon_animation_free(model->icon);
|
||||
view_commit_model(instance->view, false);
|
||||
@@ -89,7 +91,6 @@ void loading_free(Loading* instance) {
|
||||
}
|
||||
|
||||
View* loading_get_view(Loading* instance) {
|
||||
furi_assert(instance);
|
||||
furi_assert(instance->view);
|
||||
furi_check(instance);
|
||||
return instance->view;
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ typedef struct Loading Loading;
|
||||
*
|
||||
* @return Loading View instance
|
||||
*/
|
||||
Loading* loading_alloc();
|
||||
Loading* loading_alloc(void);
|
||||
|
||||
/** Deinitialize and free Loading View
|
||||
*
|
||||
|
||||
@@ -507,9 +507,9 @@ static void menu_exit(void* context) {
|
||||
furi_timer_stop(menu->scroll_timer);
|
||||
}
|
||||
|
||||
Menu* menu_alloc() {
|
||||
Menu* menu_alloc(void) {
|
||||
Menu* menu = malloc(sizeof(Menu));
|
||||
menu->view = view_alloc(menu->view);
|
||||
menu->view = view_alloc();
|
||||
view_set_context(menu->view, menu);
|
||||
view_allocate_model(menu->view, ViewModelTypeLocking, sizeof(MenuModel));
|
||||
view_set_draw_callback(menu->view, menu_draw_callback);
|
||||
@@ -532,17 +532,19 @@ Menu* menu_alloc() {
|
||||
}
|
||||
|
||||
void menu_free(Menu* menu) {
|
||||
furi_assert(menu);
|
||||
furi_check(menu);
|
||||
|
||||
menu_reset(menu);
|
||||
with_view_model(
|
||||
menu->view, MenuModel * model, { MenuItemArray_clear(model->items); }, false);
|
||||
view_free(menu->view);
|
||||
furi_timer_free(menu->scroll_timer);
|
||||
|
||||
free(menu);
|
||||
}
|
||||
|
||||
View* menu_get_view(Menu* menu) {
|
||||
furi_assert(menu);
|
||||
furi_check(menu);
|
||||
return (menu->view);
|
||||
}
|
||||
|
||||
@@ -553,8 +555,8 @@ void menu_add_item(
|
||||
uint32_t index,
|
||||
MenuItemCallback callback,
|
||||
void* context) {
|
||||
furi_assert(menu);
|
||||
furi_assert(label);
|
||||
furi_check(menu);
|
||||
furi_check(label);
|
||||
|
||||
MenuItem* item = NULL;
|
||||
with_view_model(
|
||||
@@ -573,7 +575,7 @@ void menu_add_item(
|
||||
}
|
||||
|
||||
void menu_reset(Menu* menu) {
|
||||
furi_assert(menu);
|
||||
furi_check(menu);
|
||||
with_view_model(
|
||||
menu->view,
|
||||
MenuModel * model,
|
||||
@@ -591,6 +593,8 @@ void menu_reset(Menu* menu) {
|
||||
}
|
||||
|
||||
void menu_set_selected_item(Menu* menu, uint32_t index) {
|
||||
furi_check(menu);
|
||||
|
||||
with_view_model(
|
||||
menu->view,
|
||||
MenuModel * model,
|
||||
|
||||
@@ -21,7 +21,7 @@ typedef void (*MenuItemCallback)(void* context, uint32_t index);
|
||||
*
|
||||
* @return Menu instance
|
||||
*/
|
||||
Menu* menu_alloc();
|
||||
Menu* menu_alloc(void);
|
||||
|
||||
/** Free menu
|
||||
*
|
||||
|
||||
@@ -108,7 +108,7 @@ void popup_stop_timer(void* context) {
|
||||
furi_timer_stop(popup->timer);
|
||||
}
|
||||
|
||||
Popup* popup_alloc() {
|
||||
Popup* popup_alloc(void) {
|
||||
Popup* popup = malloc(sizeof(Popup));
|
||||
popup->view = view_alloc();
|
||||
popup->timer = furi_timer_alloc(popup_timer_callback, FuriTimerTypeOnce, popup);
|
||||
@@ -148,24 +148,25 @@ Popup* popup_alloc() {
|
||||
}
|
||||
|
||||
void popup_free(Popup* popup) {
|
||||
furi_assert(popup);
|
||||
furi_check(popup);
|
||||
furi_timer_free(popup->timer);
|
||||
view_free(popup->view);
|
||||
free(popup);
|
||||
}
|
||||
|
||||
View* popup_get_view(Popup* popup) {
|
||||
furi_assert(popup);
|
||||
furi_check(popup);
|
||||
|
||||
return popup->view;
|
||||
}
|
||||
|
||||
void popup_set_callback(Popup* popup, PopupCallback callback) {
|
||||
furi_assert(popup);
|
||||
furi_check(popup);
|
||||
popup->callback = callback;
|
||||
}
|
||||
|
||||
void popup_set_context(Popup* popup, void* context) {
|
||||
furi_assert(popup);
|
||||
furi_check(popup);
|
||||
popup->context = context;
|
||||
}
|
||||
|
||||
@@ -176,7 +177,8 @@ void popup_set_header(
|
||||
uint8_t y,
|
||||
Align horizontal,
|
||||
Align vertical) {
|
||||
furi_assert(popup);
|
||||
furi_check(popup);
|
||||
|
||||
with_view_model(
|
||||
popup->view,
|
||||
PopupModel * model,
|
||||
@@ -197,7 +199,8 @@ void popup_set_text(
|
||||
uint8_t y,
|
||||
Align horizontal,
|
||||
Align vertical) {
|
||||
furi_assert(popup);
|
||||
furi_check(popup);
|
||||
|
||||
with_view_model(
|
||||
popup->view,
|
||||
PopupModel * model,
|
||||
@@ -212,7 +215,8 @@ void popup_set_text(
|
||||
}
|
||||
|
||||
void popup_set_icon(Popup* popup, uint8_t x, uint8_t y, const Icon* icon) {
|
||||
furi_assert(popup);
|
||||
furi_check(popup);
|
||||
|
||||
with_view_model(
|
||||
popup->view,
|
||||
PopupModel * model,
|
||||
@@ -225,20 +229,24 @@ void popup_set_icon(Popup* popup, uint8_t x, uint8_t y, const Icon* icon) {
|
||||
}
|
||||
|
||||
void popup_set_timeout(Popup* popup, uint32_t timeout_in_ms) {
|
||||
furi_assert(popup);
|
||||
furi_check(popup);
|
||||
popup->timer_period_in_ms = timeout_in_ms;
|
||||
}
|
||||
|
||||
void popup_enable_timeout(Popup* popup) {
|
||||
furi_check(popup);
|
||||
|
||||
popup->timer_enabled = true;
|
||||
}
|
||||
|
||||
void popup_disable_timeout(Popup* popup) {
|
||||
furi_check(popup);
|
||||
|
||||
popup->timer_enabled = false;
|
||||
}
|
||||
|
||||
void popup_reset(Popup* popup) {
|
||||
furi_assert(popup);
|
||||
furi_check(popup);
|
||||
|
||||
with_view_model(
|
||||
popup->view,
|
||||
|
||||
@@ -25,7 +25,7 @@ typedef void (*PopupCallback)(void* context);
|
||||
*
|
||||
* @return Popup instance
|
||||
*/
|
||||
Popup* popup_alloc();
|
||||
Popup* popup_alloc(void);
|
||||
|
||||
/** Deinitialize and free popup
|
||||
*
|
||||
|
||||
@@ -234,7 +234,7 @@ void submenu_timer_callback(void* context) {
|
||||
submenu->view, SubmenuModel * model, { model->locked_message_visible = false; }, true);
|
||||
}
|
||||
|
||||
Submenu* submenu_alloc() {
|
||||
Submenu* submenu_alloc(void) {
|
||||
Submenu* submenu = malloc(sizeof(Submenu));
|
||||
submenu->view = view_alloc();
|
||||
view_set_context(submenu->view, submenu);
|
||||
@@ -259,7 +259,7 @@ Submenu* submenu_alloc() {
|
||||
}
|
||||
|
||||
void submenu_free(Submenu* submenu) {
|
||||
furi_assert(submenu);
|
||||
furi_check(submenu);
|
||||
|
||||
with_view_model(
|
||||
submenu->view,
|
||||
@@ -276,7 +276,7 @@ void submenu_free(Submenu* submenu) {
|
||||
}
|
||||
|
||||
View* submenu_get_view(Submenu* submenu) {
|
||||
furi_assert(submenu);
|
||||
furi_check(submenu);
|
||||
return submenu->view;
|
||||
}
|
||||
|
||||
@@ -298,8 +298,8 @@ void submenu_add_lockable_item(
|
||||
bool locked,
|
||||
const char* locked_message) {
|
||||
SubmenuItem* item = NULL;
|
||||
furi_assert(label);
|
||||
furi_assert(submenu);
|
||||
furi_check(label);
|
||||
furi_check(submenu);
|
||||
if(locked) {
|
||||
furi_assert(locked_message);
|
||||
}
|
||||
@@ -322,7 +322,7 @@ void submenu_add_lockable_item(
|
||||
}
|
||||
|
||||
void submenu_reset(Submenu* submenu) {
|
||||
furi_assert(submenu);
|
||||
furi_check(submenu);
|
||||
view_set_orientation(submenu->view, ViewOrientationHorizontal);
|
||||
|
||||
with_view_model(
|
||||
@@ -339,6 +339,7 @@ void submenu_reset(Submenu* submenu) {
|
||||
}
|
||||
|
||||
void submenu_set_selected_item(Submenu* submenu, uint32_t index) {
|
||||
furi_check(submenu);
|
||||
with_view_model(
|
||||
submenu->view,
|
||||
SubmenuModel * model,
|
||||
@@ -452,7 +453,7 @@ void submenu_process_ok(Submenu* submenu) {
|
||||
}
|
||||
|
||||
void submenu_set_header(Submenu* submenu, const char* header) {
|
||||
furi_assert(submenu);
|
||||
furi_check(submenu);
|
||||
|
||||
with_view_model(
|
||||
submenu->view,
|
||||
@@ -468,7 +469,7 @@ void submenu_set_header(Submenu* submenu, const char* header) {
|
||||
}
|
||||
|
||||
void submenu_set_orientation(Submenu* submenu, ViewOrientation orientation) {
|
||||
furi_assert(submenu);
|
||||
furi_check(submenu);
|
||||
const bool is_vertical =
|
||||
(orientation == ViewOrientationVertical || orientation == ViewOrientationVerticalFlip) ?
|
||||
true :
|
||||
|
||||
@@ -21,7 +21,7 @@ typedef void (*SubmenuItemCallback)(void* context, uint32_t index);
|
||||
*
|
||||
* @return Submenu instance
|
||||
*/
|
||||
Submenu* submenu_alloc();
|
||||
Submenu* submenu_alloc(void);
|
||||
|
||||
/** Deinitialize and free submenu
|
||||
*
|
||||
|
||||
@@ -170,7 +170,7 @@ static bool text_box_view_input_callback(InputEvent* event, void* context) {
|
||||
return consumed;
|
||||
}
|
||||
|
||||
TextBox* text_box_alloc() {
|
||||
TextBox* text_box_alloc(void) {
|
||||
TextBox* text_box = malloc(sizeof(TextBox));
|
||||
text_box->view = view_alloc();
|
||||
view_set_context(text_box->view, text_box);
|
||||
@@ -193,7 +193,7 @@ TextBox* text_box_alloc() {
|
||||
}
|
||||
|
||||
void text_box_free(TextBox* text_box) {
|
||||
furi_assert(text_box);
|
||||
furi_check(text_box);
|
||||
|
||||
with_view_model(
|
||||
text_box->view, TextBoxModel * model, { furi_string_free(model->text_formatted); }, true);
|
||||
@@ -202,12 +202,12 @@ void text_box_free(TextBox* text_box) {
|
||||
}
|
||||
|
||||
View* text_box_get_view(TextBox* text_box) {
|
||||
furi_assert(text_box);
|
||||
furi_check(text_box);
|
||||
return text_box->view;
|
||||
}
|
||||
|
||||
void text_box_reset(TextBox* text_box) {
|
||||
furi_assert(text_box);
|
||||
furi_check(text_box);
|
||||
|
||||
with_view_model(
|
||||
text_box->view,
|
||||
@@ -223,8 +223,8 @@ void text_box_reset(TextBox* text_box) {
|
||||
}
|
||||
|
||||
void text_box_set_text(TextBox* text_box, const char* text) {
|
||||
furi_assert(text_box);
|
||||
furi_assert(text);
|
||||
furi_check(text_box);
|
||||
furi_check(text);
|
||||
size_t str_length = strlen(text);
|
||||
size_t formating_margin = str_length * TEXT_BOX_MAX_SYMBOL_WIDTH / TEXT_BOX_LINE_WIDTH;
|
||||
|
||||
@@ -241,14 +241,14 @@ void text_box_set_text(TextBox* text_box, const char* text) {
|
||||
}
|
||||
|
||||
void text_box_set_font(TextBox* text_box, TextBoxFont font) {
|
||||
furi_assert(text_box);
|
||||
furi_check(text_box);
|
||||
|
||||
with_view_model(
|
||||
text_box->view, TextBoxModel * model, { model->font = font; }, true);
|
||||
}
|
||||
|
||||
void text_box_set_focus(TextBox* text_box, TextBoxFocus focus) {
|
||||
furi_assert(text_box);
|
||||
furi_check(text_box);
|
||||
|
||||
with_view_model(
|
||||
text_box->view, TextBoxModel * model, { model->focus = focus; }, true);
|
||||
|
||||
@@ -28,7 +28,7 @@ typedef enum {
|
||||
*
|
||||
* @return TextBox instance
|
||||
*/
|
||||
TextBox* text_box_alloc();
|
||||
TextBox* text_box_alloc(void);
|
||||
|
||||
/** Deinitialize and free text_box
|
||||
*
|
||||
|
||||
@@ -695,7 +695,7 @@ static void apply_extra_symbols(TextInputModel* model) {
|
||||
char, get_row(&symbol_keyboard, 0)[get_row_size(&symbol_keyboard, 0) - 4].text, '_');
|
||||
}
|
||||
|
||||
TextInput* text_input_alloc() {
|
||||
TextInput* text_input_alloc(void) {
|
||||
TextInput* text_input = malloc(sizeof(TextInput));
|
||||
text_input->view = view_alloc();
|
||||
view_set_context(text_input->view, text_input);
|
||||
@@ -724,7 +724,7 @@ TextInput* text_input_alloc() {
|
||||
}
|
||||
|
||||
void text_input_free(TextInput* text_input) {
|
||||
furi_assert(text_input);
|
||||
furi_check(text_input);
|
||||
with_view_model(
|
||||
text_input->view,
|
||||
TextInputModel * model,
|
||||
@@ -742,7 +742,7 @@ void text_input_free(TextInput* text_input) {
|
||||
}
|
||||
|
||||
void text_input_reset(TextInput* text_input) {
|
||||
furi_assert(text_input);
|
||||
furi_check(text_input);
|
||||
with_view_model(
|
||||
text_input->view,
|
||||
TextInputModel * model,
|
||||
@@ -769,7 +769,7 @@ void text_input_reset(TextInput* text_input) {
|
||||
}
|
||||
|
||||
View* text_input_get_view(TextInput* text_input) {
|
||||
furi_assert(text_input);
|
||||
furi_check(text_input);
|
||||
return text_input->view;
|
||||
}
|
||||
|
||||
@@ -780,6 +780,7 @@ void text_input_set_result_callback(
|
||||
char* text_buffer,
|
||||
size_t text_buffer_size,
|
||||
bool clear_default_text) {
|
||||
furi_check(text_input);
|
||||
with_view_model(
|
||||
text_input->view,
|
||||
TextInputModel * model,
|
||||
@@ -804,6 +805,7 @@ void text_input_set_result_callback(
|
||||
}
|
||||
|
||||
void text_input_set_minimum_length(TextInput* text_input, size_t minimum_length) {
|
||||
furi_check(text_input);
|
||||
with_view_model(
|
||||
text_input->view,
|
||||
TextInputModel * model,
|
||||
@@ -812,6 +814,7 @@ void text_input_set_minimum_length(TextInput* text_input, size_t minimum_length)
|
||||
}
|
||||
|
||||
void text_input_add_extra_symbol(TextInput* text_input, char symbol) {
|
||||
furi_check(text_input);
|
||||
if(!symbol) return;
|
||||
with_view_model(
|
||||
text_input->view,
|
||||
@@ -829,6 +832,7 @@ void text_input_add_extra_symbol(TextInput* text_input, char symbol) {
|
||||
}
|
||||
|
||||
void text_input_add_illegal_symbols(TextInput* text_input) {
|
||||
furi_check(text_input);
|
||||
with_view_model(
|
||||
text_input->view,
|
||||
TextInputModel * model,
|
||||
@@ -852,6 +856,7 @@ void text_input_set_validator(
|
||||
TextInput* text_input,
|
||||
TextInputValidatorCallback callback,
|
||||
void* callback_context) {
|
||||
furi_check(text_input);
|
||||
with_view_model(
|
||||
text_input->view,
|
||||
TextInputModel * model,
|
||||
@@ -863,6 +868,7 @@ void text_input_set_validator(
|
||||
}
|
||||
|
||||
TextInputValidatorCallback text_input_get_validator_callback(TextInput* text_input) {
|
||||
furi_check(text_input);
|
||||
TextInputValidatorCallback validator_callback = NULL;
|
||||
with_view_model(
|
||||
text_input->view,
|
||||
@@ -873,6 +879,7 @@ TextInputValidatorCallback text_input_get_validator_callback(TextInput* text_inp
|
||||
}
|
||||
|
||||
void* text_input_get_validator_callback_context(TextInput* text_input) {
|
||||
furi_check(text_input);
|
||||
void* validator_callback_context = NULL;
|
||||
with_view_model(
|
||||
text_input->view,
|
||||
@@ -883,6 +890,7 @@ void* text_input_get_validator_callback_context(TextInput* text_input) {
|
||||
}
|
||||
|
||||
void text_input_set_header_text(TextInput* text_input, const char* text) {
|
||||
furi_check(text_input);
|
||||
with_view_model(
|
||||
text_input->view, TextInputModel * model, { model->header = text; }, true);
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ typedef bool (*TextInputValidatorCallback)(const char* text, FuriString* error,
|
||||
*
|
||||
* @return TextInput instance
|
||||
*/
|
||||
TextInput* text_input_alloc();
|
||||
TextInput* text_input_alloc(void);
|
||||
|
||||
/** Deinitialize and free text input
|
||||
*
|
||||
|
||||
@@ -9,7 +9,7 @@ struct ValidatorIsFile {
|
||||
};
|
||||
|
||||
bool validator_is_file_callback(const char* text, FuriString* error, void* context) {
|
||||
furi_assert(context);
|
||||
furi_check(context);
|
||||
ValidatorIsFile* instance = context;
|
||||
|
||||
if(instance->current_name != NULL) {
|
||||
@@ -47,7 +47,7 @@ ValidatorIsFile* validator_is_file_alloc_init(
|
||||
}
|
||||
|
||||
void validator_is_file_free(ValidatorIsFile* instance) {
|
||||
furi_assert(instance);
|
||||
furi_check(instance);
|
||||
free(instance->app_path_folder);
|
||||
free(instance->current_name);
|
||||
free(instance);
|
||||
|
||||
@@ -162,6 +162,7 @@ static void variable_item_list_draw_callback(Canvas* canvas, void* _model) {
|
||||
}
|
||||
|
||||
void variable_item_list_set_selected_item(VariableItemList* variable_item_list, uint8_t index) {
|
||||
furi_check(variable_item_list);
|
||||
with_view_model(
|
||||
variable_item_list->view,
|
||||
VariableItemListModel * model,
|
||||
@@ -196,6 +197,7 @@ void variable_item_list_set_selected_item(VariableItemList* variable_item_list,
|
||||
}
|
||||
|
||||
uint8_t variable_item_list_get_selected_item_index(VariableItemList* variable_item_list) {
|
||||
furi_check(variable_item_list);
|
||||
VariableItemListModel* model = view_get_model(variable_item_list->view);
|
||||
uint8_t idx = model->position;
|
||||
view_commit_model(variable_item_list->view, false);
|
||||
@@ -433,7 +435,7 @@ void variable_item_list_locked_timer_callback(void* context) {
|
||||
true);
|
||||
}
|
||||
|
||||
VariableItemList* variable_item_list_alloc() {
|
||||
VariableItemList* variable_item_list_alloc(void) {
|
||||
VariableItemList* variable_item_list = malloc(sizeof(VariableItemList));
|
||||
variable_item_list->view = view_alloc();
|
||||
view_set_context(variable_item_list->view, variable_item_list);
|
||||
@@ -464,7 +466,7 @@ VariableItemList* variable_item_list_alloc() {
|
||||
}
|
||||
|
||||
void variable_item_list_free(VariableItemList* variable_item_list) {
|
||||
furi_assert(variable_item_list);
|
||||
furi_check(variable_item_list);
|
||||
|
||||
with_view_model(
|
||||
variable_item_list->view,
|
||||
@@ -490,7 +492,7 @@ void variable_item_list_free(VariableItemList* variable_item_list) {
|
||||
}
|
||||
|
||||
void variable_item_list_reset(VariableItemList* variable_item_list) {
|
||||
furi_assert(variable_item_list);
|
||||
furi_check(variable_item_list);
|
||||
|
||||
with_view_model(
|
||||
variable_item_list->view,
|
||||
@@ -510,7 +512,7 @@ void variable_item_list_reset(VariableItemList* variable_item_list) {
|
||||
}
|
||||
|
||||
View* variable_item_list_get_view(VariableItemList* variable_item_list) {
|
||||
furi_assert(variable_item_list);
|
||||
furi_check(variable_item_list);
|
||||
return variable_item_list->view;
|
||||
}
|
||||
|
||||
@@ -521,8 +523,8 @@ VariableItem* variable_item_list_add(
|
||||
VariableItemChangeCallback change_callback,
|
||||
void* context) {
|
||||
VariableItem* item = NULL;
|
||||
furi_assert(label);
|
||||
furi_assert(variable_item_list);
|
||||
furi_check(label);
|
||||
furi_check(variable_item_list);
|
||||
|
||||
with_view_model(
|
||||
variable_item_list->view,
|
||||
@@ -564,7 +566,7 @@ void variable_item_list_set_enter_callback(
|
||||
VariableItemList* variable_item_list,
|
||||
VariableItemListEnterCallback callback,
|
||||
void* context) {
|
||||
furi_assert(callback);
|
||||
furi_check(callback);
|
||||
with_view_model(
|
||||
variable_item_list->view,
|
||||
VariableItemListModel * model,
|
||||
@@ -577,10 +579,12 @@ void variable_item_list_set_enter_callback(
|
||||
}
|
||||
|
||||
void variable_item_set_current_value_index(VariableItem* item, uint8_t current_value_index) {
|
||||
furi_check(item);
|
||||
item->current_value_index = current_value_index;
|
||||
}
|
||||
|
||||
void variable_item_set_values_count(VariableItem* item, uint8_t values_count) {
|
||||
furi_check(item);
|
||||
item->values_count = values_count;
|
||||
}
|
||||
|
||||
@@ -589,6 +593,7 @@ void variable_item_set_item_label(VariableItem* item, const char* label) {
|
||||
}
|
||||
|
||||
void variable_item_set_current_value_text(VariableItem* item, const char* current_value_text) {
|
||||
furi_check(item);
|
||||
furi_string_set(item->current_value_text, current_value_text);
|
||||
}
|
||||
|
||||
@@ -602,9 +607,11 @@ void variable_item_set_locked(VariableItem* item, bool locked, const char* locke
|
||||
}
|
||||
|
||||
uint8_t variable_item_get_current_value_index(VariableItem* item) {
|
||||
furi_check(item);
|
||||
return item->current_value_index;
|
||||
}
|
||||
|
||||
void* variable_item_get_context(VariableItem* item) {
|
||||
furi_check(item);
|
||||
return item->context;
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ typedef void (*VariableItemListEnterCallback)(void* context, uint32_t index);
|
||||
*
|
||||
* @return VariableItemList*
|
||||
*/
|
||||
VariableItemList* variable_item_list_alloc();
|
||||
VariableItemList* variable_item_list_alloc(void);
|
||||
|
||||
/** Deinitialize and free VariableItemList
|
||||
*
|
||||
|
||||
@@ -54,7 +54,7 @@ static bool gui_widget_view_input_callback(InputEvent* event, void* context) {
|
||||
return consumed;
|
||||
}
|
||||
|
||||
Widget* widget_alloc() {
|
||||
Widget* widget_alloc(void) {
|
||||
Widget* widget = malloc(sizeof(Widget));
|
||||
widget->view = view_alloc();
|
||||
view_set_context(widget->view, widget);
|
||||
@@ -69,7 +69,7 @@ Widget* widget_alloc() {
|
||||
}
|
||||
|
||||
void widget_reset(Widget* widget) {
|
||||
furi_assert(widget);
|
||||
furi_check(widget);
|
||||
|
||||
with_view_model(
|
||||
widget->view,
|
||||
@@ -89,7 +89,7 @@ void widget_reset(Widget* widget) {
|
||||
}
|
||||
|
||||
void widget_free(Widget* widget) {
|
||||
furi_assert(widget);
|
||||
furi_check(widget);
|
||||
// Free all elements
|
||||
widget_reset(widget);
|
||||
// Free elements container
|
||||
@@ -101,7 +101,7 @@ void widget_free(Widget* widget) {
|
||||
}
|
||||
|
||||
View* widget_get_view(Widget* widget) {
|
||||
furi_assert(widget);
|
||||
furi_check(widget);
|
||||
return widget->view;
|
||||
}
|
||||
|
||||
@@ -127,7 +127,7 @@ WidgetElement* widget_add_string_multiline_element(
|
||||
Align vertical,
|
||||
Font font,
|
||||
const char* text) {
|
||||
furi_assert(widget);
|
||||
furi_check(widget);
|
||||
WidgetElement* string_multiline_element =
|
||||
widget_element_string_multiline_create(x, y, horizontal, vertical, font, text);
|
||||
widget_add_element(widget, string_multiline_element);
|
||||
@@ -142,7 +142,7 @@ WidgetElement* widget_add_string_element(
|
||||
Align vertical,
|
||||
Font font,
|
||||
const char* text) {
|
||||
furi_assert(widget);
|
||||
furi_check(widget);
|
||||
WidgetElement* string_element =
|
||||
widget_element_string_create(x, y, horizontal, vertical, font, text);
|
||||
widget_add_element(widget, string_element);
|
||||
@@ -159,7 +159,7 @@ WidgetElement* widget_add_text_box_element(
|
||||
Align vertical,
|
||||
const char* text,
|
||||
bool strip_to_dots) {
|
||||
furi_assert(widget);
|
||||
furi_check(widget);
|
||||
WidgetElement* text_box_element = widget_element_text_box_create(
|
||||
x, y, width, height, horizontal, vertical, text, strip_to_dots);
|
||||
widget_add_element(widget, text_box_element);
|
||||
@@ -173,7 +173,7 @@ WidgetElement* widget_add_text_scroll_element(
|
||||
uint8_t width,
|
||||
uint8_t height,
|
||||
const char* text) {
|
||||
furi_assert(widget);
|
||||
furi_check(widget);
|
||||
WidgetElement* text_scroll_element =
|
||||
widget_element_text_scroll_create(x, y, width, height, text);
|
||||
widget_add_element(widget, text_scroll_element);
|
||||
@@ -186,7 +186,7 @@ WidgetElement* widget_add_button_element(
|
||||
const char* text,
|
||||
ButtonCallback callback,
|
||||
void* context) {
|
||||
furi_assert(widget);
|
||||
furi_check(widget);
|
||||
WidgetElement* button_element =
|
||||
widget_element_button_create(button_type, text, callback, context);
|
||||
widget_add_element(widget, button_element);
|
||||
@@ -194,8 +194,8 @@ WidgetElement* widget_add_button_element(
|
||||
}
|
||||
|
||||
WidgetElement* widget_add_icon_element(Widget* widget, uint8_t x, uint8_t y, const Icon* icon) {
|
||||
furi_assert(widget);
|
||||
furi_assert(icon);
|
||||
furi_check(widget);
|
||||
furi_check(icon);
|
||||
WidgetElement* icon_element = widget_element_icon_create(x, y, icon);
|
||||
widget_add_element(widget, icon_element);
|
||||
return icon_element;
|
||||
@@ -208,7 +208,7 @@ WidgetElement* widget_add_frame_element(
|
||||
uint8_t width,
|
||||
uint8_t height,
|
||||
uint8_t radius) {
|
||||
furi_assert(widget);
|
||||
furi_check(widget);
|
||||
WidgetElement* frame_element = widget_element_frame_create(x, y, width, height, radius);
|
||||
widget_add_element(widget, frame_element);
|
||||
return frame_element;
|
||||
|
||||
@@ -18,7 +18,7 @@ typedef struct WidgetElement WidgetElement;
|
||||
*
|
||||
* @return Widget instance
|
||||
*/
|
||||
Widget* widget_alloc();
|
||||
Widget* widget_alloc(void);
|
||||
|
||||
/** Free Widget
|
||||
* @note this function free allocated Widget Elements
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#include <furi.h>
|
||||
|
||||
SceneManager* scene_manager_alloc(const SceneManagerHandlers* app_scene_handlers, void* context) {
|
||||
furi_assert(context);
|
||||
furi_check(context);
|
||||
|
||||
SceneManager* scene_manager = malloc(sizeof(SceneManager));
|
||||
// Set SceneManager context and scene handlers
|
||||
@@ -17,7 +17,7 @@ SceneManager* scene_manager_alloc(const SceneManagerHandlers* app_scene_handlers
|
||||
}
|
||||
|
||||
void scene_manager_free(SceneManager* scene_manager) {
|
||||
furi_assert(scene_manager);
|
||||
furi_check(scene_manager);
|
||||
|
||||
// Clear SceneManager array
|
||||
SceneManagerIdStack_clear(scene_manager->scene_id_stack);
|
||||
@@ -28,21 +28,21 @@ void scene_manager_free(SceneManager* scene_manager) {
|
||||
}
|
||||
|
||||
void scene_manager_set_scene_state(SceneManager* scene_manager, uint32_t scene_id, uint32_t state) {
|
||||
furi_assert(scene_manager);
|
||||
furi_assert(scene_id < scene_manager->scene_handlers->scene_num);
|
||||
furi_check(scene_manager);
|
||||
furi_check(scene_id < scene_manager->scene_handlers->scene_num);
|
||||
|
||||
scene_manager->scene[scene_id].state = state;
|
||||
}
|
||||
|
||||
uint32_t scene_manager_get_scene_state(const SceneManager* scene_manager, uint32_t scene_id) {
|
||||
furi_assert(scene_manager);
|
||||
furi_assert(scene_id < scene_manager->scene_handlers->scene_num);
|
||||
furi_check(scene_manager);
|
||||
furi_check(scene_id < scene_manager->scene_handlers->scene_num);
|
||||
|
||||
return scene_manager->scene[scene_id].state;
|
||||
}
|
||||
|
||||
bool scene_manager_handle_custom_event(SceneManager* scene_manager, uint32_t custom_event) {
|
||||
furi_assert(scene_manager);
|
||||
furi_check(scene_manager);
|
||||
|
||||
SceneManagerEvent event = {
|
||||
.type = SceneManagerEventTypeCustom,
|
||||
@@ -61,7 +61,7 @@ bool scene_manager_handle_custom_event(SceneManager* scene_manager, uint32_t cus
|
||||
}
|
||||
|
||||
bool scene_manager_handle_back_event(SceneManager* scene_manager) {
|
||||
furi_assert(scene_manager);
|
||||
furi_check(scene_manager);
|
||||
|
||||
SceneManagerEvent event = {
|
||||
.type = SceneManagerEventTypeBack,
|
||||
@@ -82,7 +82,7 @@ bool scene_manager_handle_back_event(SceneManager* scene_manager) {
|
||||
}
|
||||
|
||||
void scene_manager_handle_tick_event(SceneManager* scene_manager) {
|
||||
furi_assert(scene_manager);
|
||||
furi_check(scene_manager);
|
||||
|
||||
SceneManagerEvent event = {
|
||||
.type = SceneManagerEventTypeTick,
|
||||
@@ -96,8 +96,8 @@ void scene_manager_handle_tick_event(SceneManager* scene_manager) {
|
||||
}
|
||||
|
||||
void scene_manager_next_scene(SceneManager* scene_manager, uint32_t next_scene_id) {
|
||||
furi_assert(scene_manager);
|
||||
furi_assert(next_scene_id < scene_manager->scene_handlers->scene_num);
|
||||
furi_check(scene_manager);
|
||||
furi_check(next_scene_id < scene_manager->scene_handlers->scene_num);
|
||||
|
||||
// Check if it is not the first scene
|
||||
if(SceneManagerIdStack_size(scene_manager->scene_id_stack) > 0) {
|
||||
@@ -110,7 +110,7 @@ void scene_manager_next_scene(SceneManager* scene_manager, uint32_t next_scene_i
|
||||
}
|
||||
|
||||
bool scene_manager_previous_scene(SceneManager* scene_manager) {
|
||||
furi_assert(scene_manager);
|
||||
furi_check(scene_manager);
|
||||
|
||||
if(SceneManagerIdStack_size(scene_manager->scene_id_stack) > 0) {
|
||||
uint32_t cur_scene_id = 0;
|
||||
@@ -133,7 +133,7 @@ bool scene_manager_previous_scene(SceneManager* scene_manager) {
|
||||
bool scene_manager_search_and_switch_to_previous_scene(
|
||||
SceneManager* scene_manager,
|
||||
uint32_t scene_id) {
|
||||
furi_assert(scene_manager);
|
||||
furi_check(scene_manager);
|
||||
|
||||
if(SceneManagerIdStack_size(scene_manager->scene_id_stack) > 0) {
|
||||
uint32_t prev_scene_id = 0;
|
||||
@@ -169,8 +169,8 @@ bool scene_manager_search_and_switch_to_previous_scene_one_of(
|
||||
SceneManager* scene_manager,
|
||||
const uint32_t* scene_ids,
|
||||
size_t scene_ids_size) {
|
||||
furi_assert(scene_manager);
|
||||
furi_assert(scene_ids);
|
||||
furi_check(scene_manager);
|
||||
furi_check(scene_ids);
|
||||
bool scene_found = false;
|
||||
|
||||
for(size_t i = 0; i < scene_ids_size; ++i) {
|
||||
@@ -185,7 +185,7 @@ bool scene_manager_search_and_switch_to_previous_scene_one_of(
|
||||
}
|
||||
|
||||
bool scene_manager_has_previous_scene(const SceneManager* scene_manager, uint32_t scene_id) {
|
||||
furi_assert(scene_manager);
|
||||
furi_check(scene_manager);
|
||||
bool scene_found = false;
|
||||
|
||||
if(SceneManagerIdStack_size(scene_manager->scene_id_stack) > 0) {
|
||||
@@ -211,8 +211,8 @@ bool scene_manager_has_previous_scene(const SceneManager* scene_manager, uint32_
|
||||
bool scene_manager_search_and_switch_to_another_scene(
|
||||
SceneManager* scene_manager,
|
||||
uint32_t scene_id) {
|
||||
furi_assert(scene_manager);
|
||||
furi_assert(scene_id < scene_manager->scene_handlers->scene_num);
|
||||
furi_check(scene_manager);
|
||||
furi_check(scene_id < scene_manager->scene_handlers->scene_num);
|
||||
|
||||
if(SceneManagerIdStack_size(scene_manager->scene_id_stack) > 0) {
|
||||
uint32_t cur_scene_id = *SceneManagerIdStack_back(scene_manager->scene_id_stack);
|
||||
@@ -234,7 +234,7 @@ bool scene_manager_search_and_switch_to_another_scene(
|
||||
}
|
||||
|
||||
void scene_manager_stop(SceneManager* scene_manager) {
|
||||
furi_assert(scene_manager);
|
||||
furi_check(scene_manager);
|
||||
|
||||
if(SceneManagerIdStack_size(scene_manager->scene_id_stack) > 0) {
|
||||
uint32_t cur_scene_id = *SceneManagerIdStack_back(scene_manager->scene_id_stack);
|
||||
|
||||
@@ -1,29 +1,29 @@
|
||||
#include "view_i.h"
|
||||
|
||||
View* view_alloc() {
|
||||
View* view_alloc(void) {
|
||||
View* view = malloc(sizeof(View));
|
||||
view->orientation = ViewOrientationHorizontal;
|
||||
return view;
|
||||
}
|
||||
|
||||
void view_free(View* view) {
|
||||
furi_assert(view);
|
||||
furi_check(view);
|
||||
view_free_model(view);
|
||||
free(view);
|
||||
}
|
||||
|
||||
void view_tie_icon_animation(View* view, IconAnimation* icon_animation) {
|
||||
furi_assert(view);
|
||||
furi_check(view);
|
||||
icon_animation_set_update_callback(icon_animation, view_icon_animation_callback, view);
|
||||
}
|
||||
|
||||
void view_set_draw_callback(View* view, ViewDrawCallback callback) {
|
||||
furi_assert(view);
|
||||
furi_check(view);
|
||||
view->draw_callback = callback;
|
||||
}
|
||||
|
||||
void view_set_input_callback(View* view, ViewInputCallback callback) {
|
||||
furi_assert(view);
|
||||
furi_check(view);
|
||||
view->input_callback = callback;
|
||||
}
|
||||
|
||||
@@ -33,50 +33,50 @@ void view_set_ascii_callback(View* view, ViewAsciiCallback callback) {
|
||||
}
|
||||
|
||||
void view_set_custom_callback(View* view, ViewCustomCallback callback) {
|
||||
furi_assert(view);
|
||||
furi_check(view);
|
||||
view->custom_callback = callback;
|
||||
}
|
||||
|
||||
void view_set_previous_callback(View* view, ViewNavigationCallback callback) {
|
||||
furi_assert(view);
|
||||
furi_check(view);
|
||||
view->previous_callback = callback;
|
||||
}
|
||||
|
||||
void view_set_enter_callback(View* view, ViewCallback callback) {
|
||||
furi_assert(view);
|
||||
furi_check(view);
|
||||
view->enter_callback = callback;
|
||||
}
|
||||
|
||||
void view_set_exit_callback(View* view, ViewCallback callback) {
|
||||
furi_assert(view);
|
||||
furi_check(view);
|
||||
view->exit_callback = callback;
|
||||
}
|
||||
|
||||
void view_set_update_callback(View* view, ViewUpdateCallback callback) {
|
||||
furi_assert(view);
|
||||
furi_check(view);
|
||||
view->update_callback = callback;
|
||||
}
|
||||
|
||||
void view_set_update_callback_context(View* view, void* context) {
|
||||
furi_assert(view);
|
||||
furi_check(view);
|
||||
view->update_callback_context = context;
|
||||
}
|
||||
|
||||
void view_set_context(View* view, void* context) {
|
||||
furi_assert(view);
|
||||
furi_check(view);
|
||||
view->context = context;
|
||||
}
|
||||
|
||||
void view_set_orientation(View* view, ViewOrientation orientation) {
|
||||
furi_assert(view);
|
||||
furi_check(view);
|
||||
view->orientation = orientation;
|
||||
}
|
||||
|
||||
void view_allocate_model(View* view, ViewModelType type, size_t size) {
|
||||
furi_assert(view);
|
||||
furi_assert(size > 0);
|
||||
furi_assert(view->model_type == ViewModelTypeNone);
|
||||
furi_assert(view->model == NULL);
|
||||
furi_check(view);
|
||||
furi_check(size > 0);
|
||||
furi_check(view->model_type == ViewModelTypeNone);
|
||||
furi_check(view->model == NULL);
|
||||
view->model_type = type;
|
||||
if(view->model_type == ViewModelTypeLockFree) {
|
||||
view->model = malloc(size);
|
||||
@@ -92,7 +92,7 @@ void view_allocate_model(View* view, ViewModelType type, size_t size) {
|
||||
}
|
||||
|
||||
void view_free_model(View* view) {
|
||||
furi_assert(view);
|
||||
furi_check(view);
|
||||
if(view->model_type == ViewModelTypeNone) {
|
||||
return;
|
||||
} else if(view->model_type == ViewModelTypeLockFree) {
|
||||
@@ -109,7 +109,7 @@ void view_free_model(View* view) {
|
||||
}
|
||||
|
||||
void* view_get_model(View* view) {
|
||||
furi_assert(view);
|
||||
furi_check(view);
|
||||
if(view->model_type == ViewModelTypeLocking) {
|
||||
ViewModelLocking* model = (ViewModelLocking*)(view->model);
|
||||
furi_check(furi_mutex_acquire(model->mutex, FuriWaitForever) == FuriStatusOk);
|
||||
@@ -119,7 +119,7 @@ void* view_get_model(View* view) {
|
||||
}
|
||||
|
||||
void view_commit_model(View* view, bool update) {
|
||||
furi_assert(view);
|
||||
furi_check(view);
|
||||
view_unlock_model(view);
|
||||
if(update && view->update_callback) {
|
||||
view->update_callback(view, view->update_callback_context);
|
||||
@@ -128,7 +128,7 @@ void view_commit_model(View* view, bool update) {
|
||||
|
||||
void view_icon_animation_callback(IconAnimation* instance, void* context) {
|
||||
UNUSED(instance);
|
||||
furi_assert(context);
|
||||
furi_check(context);
|
||||
View* view = context;
|
||||
if(view->update_callback) {
|
||||
view->update_callback(view, view->update_callback_context);
|
||||
@@ -136,7 +136,7 @@ void view_icon_animation_callback(IconAnimation* instance, void* context) {
|
||||
}
|
||||
|
||||
void view_unlock_model(View* view) {
|
||||
furi_assert(view);
|
||||
furi_check(view);
|
||||
if(view->model_type == ViewModelTypeLocking) {
|
||||
ViewModelLocking* model = (ViewModelLocking*)(view->model);
|
||||
furi_check(furi_mutex_release(model->mutex) == FuriStatusOk);
|
||||
@@ -144,7 +144,7 @@ void view_unlock_model(View* view) {
|
||||
}
|
||||
|
||||
void view_draw(View* view, Canvas* canvas) {
|
||||
furi_assert(view);
|
||||
furi_check(view);
|
||||
if(view->draw_callback) {
|
||||
void* data = view_get_model(view);
|
||||
view->draw_callback(canvas, data);
|
||||
@@ -153,7 +153,7 @@ void view_draw(View* view, Canvas* canvas) {
|
||||
}
|
||||
|
||||
bool view_input(View* view, InputEvent* event) {
|
||||
furi_assert(view);
|
||||
furi_check(view);
|
||||
if(view->input_callback) {
|
||||
return view->input_callback(event, view->context);
|
||||
} else {
|
||||
@@ -171,7 +171,7 @@ bool view_ascii(View* view, AsciiEvent* event) {
|
||||
}
|
||||
|
||||
bool view_custom(View* view, uint32_t event) {
|
||||
furi_assert(view);
|
||||
furi_check(view);
|
||||
if(view->custom_callback) {
|
||||
return view->custom_callback(event, view->context);
|
||||
} else {
|
||||
@@ -180,7 +180,7 @@ bool view_custom(View* view, uint32_t event) {
|
||||
}
|
||||
|
||||
uint32_t view_previous(View* view) {
|
||||
furi_assert(view);
|
||||
furi_check(view);
|
||||
if(view->previous_callback) {
|
||||
return view->previous_callback(view->context);
|
||||
} else {
|
||||
@@ -189,11 +189,11 @@ uint32_t view_previous(View* view) {
|
||||
}
|
||||
|
||||
void view_enter(View* view) {
|
||||
furi_assert(view);
|
||||
furi_check(view);
|
||||
if(view->enter_callback) view->enter_callback(view->context);
|
||||
}
|
||||
|
||||
void view_exit(View* view) {
|
||||
furi_assert(view);
|
||||
furi_check(view);
|
||||
if(view->exit_callback) view->exit_callback(view->context);
|
||||
}
|
||||
|
||||
@@ -101,7 +101,7 @@ typedef enum {
|
||||
/** Allocate and init View
|
||||
* @return View instance
|
||||
*/
|
||||
View* view_alloc();
|
||||
View* view_alloc(void);
|
||||
|
||||
/** Free View
|
||||
*
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
#define TAG "ViewDispatcher"
|
||||
|
||||
ViewDispatcher* view_dispatcher_alloc() {
|
||||
ViewDispatcher* view_dispatcher_alloc(void) {
|
||||
ViewDispatcher* view_dispatcher = malloc(sizeof(ViewDispatcher));
|
||||
|
||||
view_dispatcher->view_port = view_port_alloc();
|
||||
@@ -25,7 +25,7 @@ void view_dispatcher_free(ViewDispatcher* view_dispatcher) {
|
||||
gui_remove_view_port(view_dispatcher->gui, view_dispatcher->view_port);
|
||||
}
|
||||
// Crash if not all views were freed
|
||||
furi_assert(!ViewDict_size(view_dispatcher->views));
|
||||
furi_check(!ViewDict_size(view_dispatcher->views));
|
||||
|
||||
ViewDict_clear(view_dispatcher->views);
|
||||
// Free ViewPort
|
||||
@@ -39,29 +39,29 @@ void view_dispatcher_free(ViewDispatcher* view_dispatcher) {
|
||||
}
|
||||
|
||||
void view_dispatcher_enable_queue(ViewDispatcher* view_dispatcher) {
|
||||
furi_assert(view_dispatcher);
|
||||
furi_assert(view_dispatcher->queue == NULL);
|
||||
furi_check(view_dispatcher);
|
||||
furi_check(view_dispatcher->queue == NULL);
|
||||
view_dispatcher->queue = furi_message_queue_alloc(16, sizeof(ViewDispatcherMessage));
|
||||
}
|
||||
|
||||
void view_dispatcher_set_event_callback_context(ViewDispatcher* view_dispatcher, void* context) {
|
||||
furi_assert(view_dispatcher);
|
||||
furi_check(view_dispatcher);
|
||||
view_dispatcher->event_context = context;
|
||||
}
|
||||
|
||||
void view_dispatcher_set_navigation_event_callback(
|
||||
ViewDispatcher* view_dispatcher,
|
||||
ViewDispatcherNavigationEventCallback callback) {
|
||||
furi_assert(view_dispatcher);
|
||||
furi_assert(callback);
|
||||
furi_check(view_dispatcher);
|
||||
furi_check(callback);
|
||||
view_dispatcher->navigation_event_callback = callback;
|
||||
}
|
||||
|
||||
void view_dispatcher_set_custom_event_callback(
|
||||
ViewDispatcher* view_dispatcher,
|
||||
ViewDispatcherCustomEventCallback callback) {
|
||||
furi_assert(view_dispatcher);
|
||||
furi_assert(callback);
|
||||
furi_check(view_dispatcher);
|
||||
furi_check(callback);
|
||||
view_dispatcher->custom_event_callback = callback;
|
||||
}
|
||||
|
||||
@@ -69,15 +69,15 @@ void view_dispatcher_set_tick_event_callback(
|
||||
ViewDispatcher* view_dispatcher,
|
||||
ViewDispatcherTickEventCallback callback,
|
||||
uint32_t tick_period) {
|
||||
furi_assert(view_dispatcher);
|
||||
furi_assert(callback);
|
||||
furi_check(view_dispatcher);
|
||||
furi_check(callback);
|
||||
view_dispatcher->tick_event_callback = callback;
|
||||
view_dispatcher->tick_period = tick_period;
|
||||
}
|
||||
|
||||
void view_dispatcher_run(ViewDispatcher* view_dispatcher) {
|
||||
furi_assert(view_dispatcher);
|
||||
furi_assert(view_dispatcher->queue);
|
||||
furi_check(view_dispatcher);
|
||||
furi_check(view_dispatcher->queue);
|
||||
|
||||
uint32_t tick_period = view_dispatcher->tick_period == 0 ? FuriWaitForever :
|
||||
view_dispatcher->tick_period;
|
||||
@@ -113,8 +113,8 @@ void view_dispatcher_run(ViewDispatcher* view_dispatcher) {
|
||||
}
|
||||
|
||||
void view_dispatcher_stop(ViewDispatcher* view_dispatcher) {
|
||||
furi_assert(view_dispatcher);
|
||||
furi_assert(view_dispatcher->queue);
|
||||
furi_check(view_dispatcher);
|
||||
furi_check(view_dispatcher->queue);
|
||||
ViewDispatcherMessage message;
|
||||
message.type = ViewDispatcherMessageTypeStop;
|
||||
furi_check(
|
||||
@@ -122,8 +122,8 @@ void view_dispatcher_stop(ViewDispatcher* view_dispatcher) {
|
||||
}
|
||||
|
||||
void view_dispatcher_add_view(ViewDispatcher* view_dispatcher, uint32_t view_id, View* view) {
|
||||
furi_assert(view_dispatcher);
|
||||
furi_assert(view);
|
||||
furi_check(view_dispatcher);
|
||||
furi_check(view);
|
||||
// Check if view id is not used and register view
|
||||
furi_check(ViewDict_get(view_dispatcher->views, view_id) == NULL);
|
||||
|
||||
@@ -143,7 +143,7 @@ void view_dispatcher_add_view(ViewDispatcher* view_dispatcher, uint32_t view_id,
|
||||
}
|
||||
|
||||
void view_dispatcher_remove_view(ViewDispatcher* view_dispatcher, uint32_t view_id) {
|
||||
furi_assert(view_dispatcher);
|
||||
furi_check(view_dispatcher);
|
||||
|
||||
// Lock gui
|
||||
if(view_dispatcher->gui) {
|
||||
@@ -173,7 +173,7 @@ void view_dispatcher_remove_view(ViewDispatcher* view_dispatcher, uint32_t view_
|
||||
}
|
||||
|
||||
void view_dispatcher_switch_to_view(ViewDispatcher* view_dispatcher, uint32_t view_id) {
|
||||
furi_assert(view_dispatcher);
|
||||
furi_check(view_dispatcher);
|
||||
if(view_id == VIEW_NONE) {
|
||||
view_dispatcher_set_current_view(view_dispatcher, NULL);
|
||||
} else if(view_id == VIEW_IGNORE) {
|
||||
@@ -185,14 +185,14 @@ void view_dispatcher_switch_to_view(ViewDispatcher* view_dispatcher, uint32_t vi
|
||||
}
|
||||
|
||||
void view_dispatcher_send_to_front(ViewDispatcher* view_dispatcher) {
|
||||
furi_assert(view_dispatcher);
|
||||
furi_assert(view_dispatcher->gui);
|
||||
furi_check(view_dispatcher);
|
||||
furi_check(view_dispatcher->gui);
|
||||
gui_view_port_send_to_front(view_dispatcher->gui, view_dispatcher->view_port);
|
||||
}
|
||||
|
||||
void view_dispatcher_send_to_back(ViewDispatcher* view_dispatcher) {
|
||||
furi_assert(view_dispatcher);
|
||||
furi_assert(view_dispatcher->gui);
|
||||
furi_check(view_dispatcher);
|
||||
furi_check(view_dispatcher->gui);
|
||||
gui_view_port_send_to_back(view_dispatcher->gui, view_dispatcher->view_port);
|
||||
}
|
||||
|
||||
@@ -200,9 +200,9 @@ void view_dispatcher_attach_to_gui(
|
||||
ViewDispatcher* view_dispatcher,
|
||||
Gui* gui,
|
||||
ViewDispatcherType type) {
|
||||
furi_assert(view_dispatcher);
|
||||
furi_assert(view_dispatcher->gui == NULL);
|
||||
furi_assert(gui);
|
||||
furi_check(view_dispatcher);
|
||||
furi_check(view_dispatcher->gui == NULL);
|
||||
furi_check(gui);
|
||||
|
||||
if(type == ViewDispatcherTypeDesktop) {
|
||||
gui_add_view_port(gui, view_dispatcher->view_port, GuiLayerDesktop);
|
||||
@@ -372,8 +372,8 @@ void view_dispatcher_handle_custom_event(ViewDispatcher* view_dispatcher, uint32
|
||||
}
|
||||
|
||||
void view_dispatcher_send_custom_event(ViewDispatcher* view_dispatcher, uint32_t event) {
|
||||
furi_assert(view_dispatcher);
|
||||
furi_assert(view_dispatcher->queue);
|
||||
furi_check(view_dispatcher);
|
||||
furi_check(view_dispatcher->queue);
|
||||
|
||||
ViewDispatcherMessage message;
|
||||
message.type = ViewDispatcherMessageTypeCustomEvent;
|
||||
@@ -391,7 +391,7 @@ static const ViewPortOrientation view_dispatcher_view_port_orientation_table[] =
|
||||
};
|
||||
|
||||
void view_dispatcher_set_current_view(ViewDispatcher* view_dispatcher, View* view) {
|
||||
furi_assert(view_dispatcher);
|
||||
furi_check(view_dispatcher);
|
||||
// Dispatch view exit event
|
||||
if(view_dispatcher->current_view) {
|
||||
view_exit(view_dispatcher->current_view);
|
||||
@@ -419,8 +419,8 @@ void view_dispatcher_set_current_view(ViewDispatcher* view_dispatcher, View* vie
|
||||
}
|
||||
|
||||
void view_dispatcher_update(View* view, void* context) {
|
||||
furi_assert(view);
|
||||
furi_assert(context);
|
||||
furi_check(view);
|
||||
furi_check(context);
|
||||
|
||||
ViewDispatcher* view_dispatcher = context;
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ typedef void (*ViewDispatcherTickEventCallback)(void* context);
|
||||
*
|
||||
* @return pointer to ViewDispatcher instance
|
||||
*/
|
||||
ViewDispatcher* view_dispatcher_alloc();
|
||||
ViewDispatcher* view_dispatcher_alloc(void);
|
||||
|
||||
/** Free ViewDispatcher instance
|
||||
*
|
||||
|
||||
@@ -21,7 +21,7 @@ static void view_holder_draw_callback(Canvas* canvas, void* context);
|
||||
static void view_holder_input_callback(InputEvent* event, void* context);
|
||||
static bool view_holder_ascii_callback(AsciiEvent* event, void* context);
|
||||
|
||||
ViewHolder* view_holder_alloc() {
|
||||
ViewHolder* view_holder_alloc(void) {
|
||||
ViewHolder* view_holder = malloc(sizeof(ViewHolder));
|
||||
|
||||
view_holder->view_port = view_port_alloc();
|
||||
|
||||
@@ -30,7 +30,7 @@ typedef void (*BackCallback)(void* back_context);
|
||||
* @brief Allocate ViewHolder
|
||||
* @return pointer to ViewHolder instance
|
||||
*/
|
||||
ViewHolder* view_holder_alloc();
|
||||
ViewHolder* view_holder_alloc(void);
|
||||
|
||||
/**
|
||||
* @brief Free ViewHolder and call Free callback
|
||||
|
||||
@@ -61,7 +61,7 @@ static const CanvasOrientation view_port_orientation_mapping[ViewPortOrientation
|
||||
|
||||
// Remaps directional pad buttons on Flipper based on ViewPort orientation
|
||||
static void view_port_map_input(InputEvent* event, ViewPortOrientation orientation) {
|
||||
furi_assert(orientation < ViewPortOrientationMAX && event->key < InputKeyMAX);
|
||||
furi_check(orientation < ViewPortOrientationMAX && event->key < InputKeyMAX);
|
||||
|
||||
if(event->sequence_source != INPUT_SEQUENCE_SOURCE_HARDWARE) {
|
||||
return;
|
||||
@@ -90,7 +90,7 @@ static void view_port_setup_canvas_orientation(const ViewPort* view_port, Canvas
|
||||
canvas_set_orientation(canvas, orientation);
|
||||
}
|
||||
|
||||
ViewPort* view_port_alloc() {
|
||||
ViewPort* view_port_alloc(void) {
|
||||
ViewPort* view_port = malloc(sizeof(ViewPort));
|
||||
view_port->orientation = ViewPortOrientationHorizontal;
|
||||
view_port->is_enabled = true;
|
||||
@@ -99,7 +99,7 @@ ViewPort* view_port_alloc() {
|
||||
}
|
||||
|
||||
void view_port_free(ViewPort* view_port) {
|
||||
furi_assert(view_port);
|
||||
furi_check(view_port);
|
||||
furi_check(furi_mutex_acquire(view_port->mutex, FuriWaitForever) == FuriStatusOk);
|
||||
furi_check(view_port->gui == NULL);
|
||||
furi_check(furi_mutex_release(view_port->mutex) == FuriStatusOk);
|
||||
@@ -108,14 +108,14 @@ void view_port_free(ViewPort* view_port) {
|
||||
}
|
||||
|
||||
void view_port_set_width(ViewPort* view_port, uint8_t width) {
|
||||
furi_assert(view_port);
|
||||
furi_check(view_port);
|
||||
furi_check(furi_mutex_acquire(view_port->mutex, FuriWaitForever) == FuriStatusOk);
|
||||
view_port->width = width;
|
||||
furi_check(furi_mutex_release(view_port->mutex) == FuriStatusOk);
|
||||
}
|
||||
|
||||
uint8_t view_port_get_width(const ViewPort* view_port) {
|
||||
furi_assert(view_port);
|
||||
furi_check(view_port);
|
||||
furi_check(furi_mutex_acquire(view_port->mutex, FuriWaitForever) == FuriStatusOk);
|
||||
uint8_t width = view_port->width;
|
||||
furi_check(furi_mutex_release(view_port->mutex) == FuriStatusOk);
|
||||
@@ -123,14 +123,14 @@ uint8_t view_port_get_width(const ViewPort* view_port) {
|
||||
}
|
||||
|
||||
void view_port_set_height(ViewPort* view_port, uint8_t height) {
|
||||
furi_assert(view_port);
|
||||
furi_check(view_port);
|
||||
furi_check(furi_mutex_acquire(view_port->mutex, FuriWaitForever) == FuriStatusOk);
|
||||
view_port->height = height;
|
||||
furi_check(furi_mutex_release(view_port->mutex) == FuriStatusOk);
|
||||
}
|
||||
|
||||
uint8_t view_port_get_height(const ViewPort* view_port) {
|
||||
furi_assert(view_port);
|
||||
furi_check(view_port);
|
||||
furi_check(furi_mutex_acquire(view_port->mutex, FuriWaitForever) == FuriStatusOk);
|
||||
uint8_t height = view_port->height;
|
||||
furi_check(furi_mutex_release(view_port->mutex) == FuriStatusOk);
|
||||
@@ -138,7 +138,7 @@ uint8_t view_port_get_height(const ViewPort* view_port) {
|
||||
}
|
||||
|
||||
void view_port_enabled_set(ViewPort* view_port, bool enabled) {
|
||||
furi_assert(view_port);
|
||||
furi_check(view_port);
|
||||
furi_check(furi_mutex_acquire(view_port->mutex, FuriWaitForever) == FuriStatusOk);
|
||||
if(view_port->is_enabled != enabled) {
|
||||
view_port->is_enabled = enabled;
|
||||
@@ -148,7 +148,7 @@ void view_port_enabled_set(ViewPort* view_port, bool enabled) {
|
||||
}
|
||||
|
||||
bool view_port_is_enabled(const ViewPort* view_port) {
|
||||
furi_assert(view_port);
|
||||
furi_check(view_port);
|
||||
furi_check(furi_mutex_acquire(view_port->mutex, FuriWaitForever) == FuriStatusOk);
|
||||
bool is_enabled = view_port->is_enabled;
|
||||
furi_check(furi_mutex_release(view_port->mutex) == FuriStatusOk);
|
||||
@@ -156,7 +156,7 @@ bool view_port_is_enabled(const ViewPort* view_port) {
|
||||
}
|
||||
|
||||
void view_port_draw_callback_set(ViewPort* view_port, ViewPortDrawCallback callback, void* context) {
|
||||
furi_assert(view_port);
|
||||
furi_check(view_port);
|
||||
furi_check(furi_mutex_acquire(view_port->mutex, FuriWaitForever) == FuriStatusOk);
|
||||
view_port->draw_callback = callback;
|
||||
view_port->draw_callback_context = context;
|
||||
@@ -167,7 +167,7 @@ void view_port_input_callback_set(
|
||||
ViewPort* view_port,
|
||||
ViewPortInputCallback callback,
|
||||
void* context) {
|
||||
furi_assert(view_port);
|
||||
furi_check(view_port);
|
||||
furi_check(furi_mutex_acquire(view_port->mutex, FuriWaitForever) == FuriStatusOk);
|
||||
view_port->input_callback = callback;
|
||||
view_port->input_callback_context = context;
|
||||
@@ -186,7 +186,7 @@ void view_port_ascii_callback_set(
|
||||
}
|
||||
|
||||
void view_port_update(ViewPort* view_port) {
|
||||
furi_assert(view_port);
|
||||
furi_check(view_port);
|
||||
|
||||
// We are not going to lockup system, but will notify you instead
|
||||
// Make sure that you don't call viewport methods inside of another mutex, especially one that is used in draw call
|
||||
@@ -199,15 +199,15 @@ void view_port_update(ViewPort* view_port) {
|
||||
}
|
||||
|
||||
void view_port_gui_set(ViewPort* view_port, Gui* gui) {
|
||||
furi_assert(view_port);
|
||||
furi_check(view_port);
|
||||
furi_check(furi_mutex_acquire(view_port->mutex, FuriWaitForever) == FuriStatusOk);
|
||||
view_port->gui = gui;
|
||||
furi_check(furi_mutex_release(view_port->mutex) == FuriStatusOk);
|
||||
}
|
||||
|
||||
void view_port_draw(ViewPort* view_port, Canvas* canvas) {
|
||||
furi_assert(view_port);
|
||||
furi_assert(canvas);
|
||||
furi_check(view_port);
|
||||
furi_check(canvas);
|
||||
|
||||
// We are not going to lockup system, but will notify you instead
|
||||
// Make sure that you don't call viewport methods inside of another mutex, especially one that is used in draw call
|
||||
@@ -226,8 +226,8 @@ void view_port_draw(ViewPort* view_port, Canvas* canvas) {
|
||||
}
|
||||
|
||||
void view_port_input(ViewPort* view_port, InputEvent* event) {
|
||||
furi_assert(view_port);
|
||||
furi_assert(event);
|
||||
furi_check(view_port);
|
||||
furi_check(event);
|
||||
furi_check(furi_mutex_acquire(view_port->mutex, FuriWaitForever) == FuriStatusOk);
|
||||
furi_check(view_port->gui);
|
||||
|
||||
@@ -287,7 +287,7 @@ void view_port_ascii(ViewPort* view_port, AsciiEvent* event) {
|
||||
}
|
||||
|
||||
void view_port_set_orientation(ViewPort* view_port, ViewPortOrientation orientation) {
|
||||
furi_assert(view_port);
|
||||
furi_check(view_port);
|
||||
furi_check(furi_mutex_acquire(view_port->mutex, FuriWaitForever) == FuriStatusOk);
|
||||
view_port->orientation = orientation;
|
||||
furi_check(furi_mutex_release(view_port->mutex) == FuriStatusOk);
|
||||
|
||||
@@ -44,7 +44,7 @@ typedef bool (*ViewPortAsciiCallback)(AsciiEvent* event, void* context);
|
||||
*
|
||||
* @return ViewPort instance
|
||||
*/
|
||||
ViewPort* view_port_alloc();
|
||||
ViewPort* view_port_alloc(void);
|
||||
|
||||
/** ViewPort deallocator
|
||||
*
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include <cli/cli.h>
|
||||
#include <toolbox/args.h>
|
||||
|
||||
static void input_cli_usage() {
|
||||
static void input_cli_usage(void) {
|
||||
printf("Usage:\r\n");
|
||||
printf("input <cmd> <args>\r\n");
|
||||
printf("Cmd list:\r\n");
|
||||
@@ -134,7 +134,7 @@ static void input_cli_keyboard(Cli* cli, FuriString* args, Input* input) {
|
||||
}
|
||||
}
|
||||
|
||||
static void input_cli_send_print_usage() {
|
||||
static void input_cli_send_print_usage(void) {
|
||||
printf("Invalid arguments. Usage:\r\n");
|
||||
printf("\tinput send <key> <type>\r\n");
|
||||
printf("\t\t <key>\t - one of 'up', 'down', 'left', 'right', 'back', 'ok'\r\n");
|
||||
@@ -231,6 +231,6 @@ static const FlipperAppPluginDescriptor plugin_descriptor = {
|
||||
.entry_point = &input_cli,
|
||||
};
|
||||
|
||||
const FlipperAppPluginDescriptor* input_cli_plugin_ep() {
|
||||
const FlipperAppPluginDescriptor* input_cli_plugin_ep(void) {
|
||||
return &plugin_descriptor;
|
||||
}
|
||||
|
||||
@@ -41,6 +41,9 @@ static const char*
|
||||
|
||||
LoaderStatus
|
||||
loader_start(Loader* loader, const char* name, const char* args, FuriString* error_message) {
|
||||
furi_check(loader);
|
||||
furi_check(name);
|
||||
|
||||
LoaderMessage message;
|
||||
LoaderMessageLoaderStatusResult result;
|
||||
|
||||
@@ -52,6 +55,7 @@ LoaderStatus
|
||||
message.status_value = &result;
|
||||
furi_message_queue_put(loader->queue, &message, FuriWaitForever);
|
||||
api_lock_wait_unlock_and_free(message.api_lock);
|
||||
|
||||
return result.value;
|
||||
}
|
||||
|
||||
@@ -79,6 +83,9 @@ static void loader_show_gui_error(LoaderStatus status, FuriString* error_message
|
||||
}
|
||||
|
||||
LoaderStatus loader_start_with_gui_error(Loader* loader, const char* name, const char* args) {
|
||||
furi_check(loader);
|
||||
furi_check(name);
|
||||
|
||||
FuriString* error_message = furi_string_alloc();
|
||||
LoaderStatus status = loader_start(loader, name, args, error_message);
|
||||
loader_show_gui_error(status, error_message);
|
||||
@@ -87,6 +94,9 @@ LoaderStatus loader_start_with_gui_error(Loader* loader, const char* name, const
|
||||
}
|
||||
|
||||
void loader_start_detached_with_gui_error(Loader* loader, const char* name, const char* args) {
|
||||
furi_check(loader);
|
||||
furi_check(name);
|
||||
|
||||
LoaderMessage message;
|
||||
|
||||
message.type = LoaderMessageTypeStartByNameDetachedWithGuiError;
|
||||
@@ -96,6 +106,8 @@ void loader_start_detached_with_gui_error(Loader* loader, const char* name, cons
|
||||
}
|
||||
|
||||
bool loader_lock(Loader* loader) {
|
||||
furi_check(loader);
|
||||
|
||||
LoaderMessage message;
|
||||
LoaderMessageBoolResult result;
|
||||
message.type = LoaderMessageTypeLock;
|
||||
@@ -103,16 +115,22 @@ bool loader_lock(Loader* loader) {
|
||||
message.bool_value = &result;
|
||||
furi_message_queue_put(loader->queue, &message, FuriWaitForever);
|
||||
api_lock_wait_unlock_and_free(message.api_lock);
|
||||
|
||||
return result.value;
|
||||
}
|
||||
|
||||
void loader_unlock(Loader* loader) {
|
||||
furi_check(loader);
|
||||
|
||||
LoaderMessage message;
|
||||
message.type = LoaderMessageTypeUnlock;
|
||||
|
||||
furi_message_queue_put(loader->queue, &message, FuriWaitForever);
|
||||
}
|
||||
|
||||
bool loader_is_locked(Loader* loader) {
|
||||
furi_check(loader);
|
||||
|
||||
LoaderMessage message;
|
||||
LoaderMessageBoolResult result;
|
||||
message.type = LoaderMessageTypeIsLocked;
|
||||
@@ -120,23 +138,30 @@ bool loader_is_locked(Loader* loader) {
|
||||
message.bool_value = &result;
|
||||
furi_message_queue_put(loader->queue, &message, FuriWaitForever);
|
||||
api_lock_wait_unlock_and_free(message.api_lock);
|
||||
|
||||
return result.value;
|
||||
}
|
||||
|
||||
void loader_show_menu(Loader* loader) {
|
||||
furi_check(loader);
|
||||
|
||||
LoaderMessage message;
|
||||
message.type = LoaderMessageTypeShowMenu;
|
||||
|
||||
furi_message_queue_put(loader->queue, &message, FuriWaitForever);
|
||||
}
|
||||
|
||||
void loader_show_settings(Loader* loader) {
|
||||
furi_check(loader);
|
||||
|
||||
LoaderMessage message;
|
||||
message.type = LoaderMessageTypeShowSettings;
|
||||
|
||||
furi_message_queue_put(loader->queue, &message, FuriWaitForever);
|
||||
}
|
||||
|
||||
FuriPubSub* loader_get_pubsub(Loader* loader) {
|
||||
furi_assert(loader);
|
||||
furi_check(loader);
|
||||
// it's safe to return pubsub without locking
|
||||
// because it's never freed and loader is never exited
|
||||
// also the loader instance cannot be obtained until the pubsub is created
|
||||
@@ -230,7 +255,7 @@ static void loader_make_menu_file(Storage* storage) {
|
||||
stream_free(new);
|
||||
}
|
||||
|
||||
static Loader* loader_alloc() {
|
||||
static Loader* loader_alloc(void) {
|
||||
Loader* loader = malloc(sizeof(Loader));
|
||||
loader->pubsub = furi_pubsub_alloc();
|
||||
loader->queue = furi_message_queue_alloc(1, sizeof(LoaderMessage));
|
||||
|
||||
@@ -49,7 +49,7 @@ typedef struct {
|
||||
Loading* loading;
|
||||
} LoaderApplicationsApp;
|
||||
|
||||
static LoaderApplicationsApp* loader_applications_app_alloc() {
|
||||
static LoaderApplicationsApp* loader_applications_app_alloc(void) {
|
||||
LoaderApplicationsApp* app = malloc(sizeof(LoaderApplicationsApp)); //-V799
|
||||
app->file_path = furi_string_alloc_set(EXT_PATH("apps"));
|
||||
app->dialogs = furi_record_open(RECORD_DIALOGS);
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#include <notification/notification_messages.h>
|
||||
#include "loader.h"
|
||||
|
||||
static void loader_cli_print_usage() {
|
||||
static void loader_cli_print_usage(void) {
|
||||
printf("Usage:\r\n");
|
||||
printf("loader <cmd> <args>\r\n");
|
||||
printf("Cmd list:\r\n");
|
||||
@@ -14,7 +14,7 @@ static void loader_cli_print_usage() {
|
||||
printf("\tinfo\t - Show loader state\r\n");
|
||||
}
|
||||
|
||||
static void loader_cli_list() {
|
||||
static void loader_cli_list(void) {
|
||||
printf("Apps:\r\n");
|
||||
for(size_t i = 0; i < FLIPPER_APPS_COUNT; i++) {
|
||||
printf("\t%s\r\n", FLIPPER_APPS[i].name);
|
||||
@@ -112,6 +112,6 @@ static const FlipperAppPluginDescriptor plugin_descriptor = {
|
||||
.entry_point = &loader_cli,
|
||||
};
|
||||
|
||||
const FlipperAppPluginDescriptor* loader_cli_plugin_ep() {
|
||||
const FlipperAppPluginDescriptor* loader_cli_plugin_ep(void) {
|
||||
return &plugin_descriptor;
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ static void loader_cli_wrapper(Cli* cli, FuriString* args, void* context) {
|
||||
cli_plugin_wrapper("loader_cli", 1, cli, args, context);
|
||||
}
|
||||
|
||||
void loader_on_system_start() {
|
||||
void loader_on_system_start(void) {
|
||||
Cli* cli = furi_record_open(RECORD_CLI);
|
||||
cli_add_command(cli, RECORD_LOADER, CliCommandFlagParallelSafe, loader_cli_wrapper, NULL);
|
||||
furi_record_close(RECORD_CLI);
|
||||
|
||||
@@ -39,8 +39,8 @@ void locale_format_time(
|
||||
const DateTime* datetime,
|
||||
const LocaleTimeFormat format,
|
||||
const bool show_seconds) {
|
||||
furi_assert(out_str);
|
||||
furi_assert(datetime);
|
||||
furi_check(out_str);
|
||||
furi_check(datetime);
|
||||
|
||||
uint8_t hours = datetime->hour;
|
||||
uint8_t am_pm = 0;
|
||||
@@ -72,9 +72,9 @@ void locale_format_date(
|
||||
const DateTime* datetime,
|
||||
const LocaleDateFormat format,
|
||||
const char* separator) {
|
||||
furi_assert(out_str);
|
||||
furi_assert(datetime);
|
||||
furi_assert(separator);
|
||||
furi_check(out_str);
|
||||
furi_check(datetime);
|
||||
furi_check(separator);
|
||||
|
||||
if(format == LocaleDateFormatDMY) {
|
||||
furi_string_printf(
|
||||
|
||||
@@ -28,7 +28,7 @@ typedef enum {
|
||||
*
|
||||
* @return The locale measurement units.
|
||||
*/
|
||||
LocaleMeasurementUnits locale_get_measurement_unit();
|
||||
LocaleMeasurementUnits locale_get_measurement_unit(void);
|
||||
|
||||
/** Set locale measurement units
|
||||
*
|
||||
@@ -56,7 +56,7 @@ float locale_celsius_to_fahrenheit(float temp_c);
|
||||
*
|
||||
* @return The locale time format.
|
||||
*/
|
||||
LocaleTimeFormat locale_get_time_format();
|
||||
LocaleTimeFormat locale_get_time_format(void);
|
||||
|
||||
/** Set Locale Time Format
|
||||
*
|
||||
|
||||
@@ -164,7 +164,7 @@ static void notification_vibro_on(bool force) {
|
||||
}
|
||||
}
|
||||
|
||||
static void notification_vibro_off() {
|
||||
static void notification_vibro_off(void) {
|
||||
furi_hal_vibro_on(false);
|
||||
}
|
||||
|
||||
@@ -176,7 +176,7 @@ static void notification_sound_on(float freq, float volume, bool force) {
|
||||
}
|
||||
}
|
||||
|
||||
static void notification_sound_off() {
|
||||
static void notification_sound_off(void) {
|
||||
if(furi_hal_speaker_is_mine()) {
|
||||
furi_hal_speaker_stop();
|
||||
furi_hal_speaker_release();
|
||||
@@ -461,7 +461,7 @@ static void ascii_event_callback(const void* value, void* context) {
|
||||
}
|
||||
|
||||
// App alloc
|
||||
static NotificationApp* notification_app_alloc() {
|
||||
static NotificationApp* notification_app_alloc(void) {
|
||||
NotificationApp* app = malloc(sizeof(NotificationApp));
|
||||
app->queue = furi_message_queue_alloc(8, sizeof(NotificationAppMessage));
|
||||
app->display_timer = furi_timer_alloc(notification_display_timer, FuriTimerTypeOnce, app);
|
||||
|
||||
@@ -5,18 +5,27 @@
|
||||
#include "notification_app.h"
|
||||
|
||||
void notification_message(NotificationApp* app, const NotificationSequence* sequence) {
|
||||
furi_check(app);
|
||||
furi_check(sequence);
|
||||
|
||||
NotificationAppMessage m = {
|
||||
.type = NotificationLayerMessage, .sequence = sequence, .back_event = NULL};
|
||||
furi_check(furi_message_queue_put(app->queue, &m, FuriWaitForever) == FuriStatusOk);
|
||||
}
|
||||
|
||||
void notification_internal_message(NotificationApp* app, const NotificationSequence* sequence) {
|
||||
furi_check(app);
|
||||
furi_check(sequence);
|
||||
|
||||
NotificationAppMessage m = {
|
||||
.type = InternalLayerMessage, .sequence = sequence, .back_event = NULL};
|
||||
furi_check(furi_message_queue_put(app->queue, &m, FuriWaitForever) == FuriStatusOk);
|
||||
}
|
||||
|
||||
void notification_message_block(NotificationApp* app, const NotificationSequence* sequence) {
|
||||
furi_check(app);
|
||||
furi_check(sequence);
|
||||
|
||||
NotificationAppMessage m = {
|
||||
.type = NotificationLayerMessage,
|
||||
.sequence = sequence,
|
||||
@@ -30,6 +39,9 @@ void notification_message_block(NotificationApp* app, const NotificationSequence
|
||||
void notification_internal_message_block(
|
||||
NotificationApp* app,
|
||||
const NotificationSequence* sequence) {
|
||||
furi_check(app);
|
||||
furi_check(sequence);
|
||||
|
||||
NotificationAppMessage m = {
|
||||
.type = InternalLayerMessage, .sequence = sequence, .back_event = furi_event_flag_alloc()};
|
||||
furi_check(furi_message_queue_put(app->queue, &m, FuriWaitForever) == FuriStatusOk);
|
||||
|
||||
@@ -48,7 +48,7 @@ void power_cli_3v3(Cli* cli, FuriString* args) {
|
||||
}
|
||||
}
|
||||
|
||||
static void power_cli_command_print_usage() {
|
||||
static void power_cli_command_print_usage(void) {
|
||||
printf("Usage:\r\n");
|
||||
printf("power <cmd> <args>\r\n");
|
||||
printf("Cmd list:\r\n");
|
||||
@@ -114,6 +114,6 @@ static const FlipperAppPluginDescriptor plugin_descriptor = {
|
||||
.entry_point = &power_cli,
|
||||
};
|
||||
|
||||
const FlipperAppPluginDescriptor* power_cli_plugin_ep() {
|
||||
const FlipperAppPluginDescriptor* power_cli_plugin_ep(void) {
|
||||
return &plugin_descriptor;
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void power_on_system_start();
|
||||
void power_on_system_start(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -326,7 +326,7 @@ static void power_shutdown_time_changed_callback(const void* event, void* contex
|
||||
}
|
||||
}
|
||||
|
||||
Power* power_alloc() {
|
||||
Power* power_alloc(void) {
|
||||
Power* power = malloc(sizeof(Power));
|
||||
|
||||
// Records
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
#include <update_util/update_operation.h>
|
||||
|
||||
void power_off(Power* power) {
|
||||
furi_check(power);
|
||||
|
||||
furi_hal_power_off();
|
||||
// Notify user if USB is plugged
|
||||
view_dispatcher_send_to_front(power->view_dispatcher);
|
||||
@@ -20,13 +22,16 @@ void power_reboot(PowerBootMode mode) {
|
||||
furi_hal_rtc_set_boot_mode(FuriHalRtcBootModeDfu);
|
||||
} else if(mode == PowerBootModeUpdateStart) {
|
||||
furi_hal_rtc_set_boot_mode(FuriHalRtcBootModePreUpdate);
|
||||
} else {
|
||||
furi_crash();
|
||||
}
|
||||
|
||||
furi_hal_power_reset();
|
||||
}
|
||||
|
||||
void power_get_info(Power* power, PowerInfo* info) {
|
||||
furi_assert(power);
|
||||
furi_assert(info);
|
||||
furi_check(power);
|
||||
furi_check(info);
|
||||
|
||||
furi_mutex_acquire(power->api_mtx, FuriWaitForever);
|
||||
memcpy(info, &power->info, sizeof(power->info));
|
||||
@@ -34,7 +39,7 @@ void power_get_info(Power* power, PowerInfo* info) {
|
||||
}
|
||||
|
||||
FuriPubSub* power_get_pubsub(Power* power) {
|
||||
furi_assert(power);
|
||||
furi_check(power);
|
||||
return power->event_pubsub;
|
||||
}
|
||||
|
||||
@@ -44,7 +49,7 @@ FuriPubSub* power_get_settings_events_pubsub(Power* power) {
|
||||
}
|
||||
|
||||
bool power_is_battery_healthy(Power* power) {
|
||||
furi_assert(power);
|
||||
furi_check(power);
|
||||
bool is_healthy = false;
|
||||
furi_mutex_acquire(power->api_mtx, FuriWaitForever);
|
||||
is_healthy = power->info.health > POWER_BATTERY_HEALTHY_LEVEL;
|
||||
@@ -53,7 +58,7 @@ bool power_is_battery_healthy(Power* power) {
|
||||
}
|
||||
|
||||
void power_enable_low_battery_level_notification(Power* power, bool enable) {
|
||||
furi_assert(power);
|
||||
furi_check(power);
|
||||
furi_mutex_acquire(power->api_mtx, FuriWaitForever);
|
||||
power->show_low_bat_level_message = enable;
|
||||
furi_mutex_release(power->api_mtx);
|
||||
|
||||
@@ -62,7 +62,7 @@ static bool power_off_input_callback(InputEvent* event, void* context) {
|
||||
return true;
|
||||
}
|
||||
|
||||
PowerOff* power_off_alloc() {
|
||||
PowerOff* power_off_alloc(void) {
|
||||
PowerOff* power_off = malloc(sizeof(PowerOff));
|
||||
|
||||
power_off->view = view_alloc();
|
||||
|
||||
@@ -11,7 +11,7 @@ typedef enum {
|
||||
|
||||
#include <gui/view.h>
|
||||
|
||||
PowerOff* power_off_alloc();
|
||||
PowerOff* power_off_alloc(void);
|
||||
|
||||
void power_off_free(PowerOff* power_off);
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ static void power_unplug_usb_draw_callback(Canvas* canvas, void* _model) {
|
||||
canvas, 64, 32, AlignCenter, AlignCenter, "It's now safe to unplug\nthe USB cable");
|
||||
}
|
||||
|
||||
PowerUnplugUsb* power_unplug_usb_alloc() {
|
||||
PowerUnplugUsb* power_unplug_usb_alloc(void) {
|
||||
PowerUnplugUsb* power_unplug_usb = malloc(sizeof(PowerUnplugUsb));
|
||||
|
||||
power_unplug_usb->view = view_alloc();
|
||||
|
||||
@@ -4,7 +4,7 @@ typedef struct PowerUnplugUsb PowerUnplugUsb;
|
||||
|
||||
#include <gui/view.h>
|
||||
|
||||
PowerUnplugUsb* power_unplug_usb_alloc();
|
||||
PowerUnplugUsb* power_unplug_usb_alloc(void);
|
||||
|
||||
void power_unplug_usb_free(PowerUnplugUsb* power_unplug_usb);
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ static void power_cli_wrapper(Cli* cli, FuriString* args, void* context) {
|
||||
cli_plugin_wrapper("power_cli", 1, cli, args, context);
|
||||
}
|
||||
|
||||
void power_on_system_start() {
|
||||
void power_on_system_start(void) {
|
||||
Cli* cli = furi_record_open(RECORD_CLI);
|
||||
cli_add_command(cli, "power", CliCommandFlagParallelSafe, power_cli_wrapper, NULL);
|
||||
furi_record_close(RECORD_CLI);
|
||||
|
||||
@@ -94,7 +94,7 @@ struct Rpc {
|
||||
};
|
||||
|
||||
RpcOwner rpc_session_get_owner(RpcSession* session) {
|
||||
furi_assert(session);
|
||||
furi_check(session);
|
||||
return session->owner;
|
||||
}
|
||||
|
||||
@@ -115,7 +115,7 @@ static void rpc_close_session_process(const PB_Main* request, void* context) {
|
||||
}
|
||||
|
||||
void rpc_session_set_context(RpcSession* session, void* context) {
|
||||
furi_assert(session);
|
||||
furi_check(session);
|
||||
|
||||
furi_mutex_acquire(session->callbacks_mutex, FuriWaitForever);
|
||||
session->context = context;
|
||||
@@ -123,7 +123,7 @@ void rpc_session_set_context(RpcSession* session, void* context) {
|
||||
}
|
||||
|
||||
void rpc_session_set_close_callback(RpcSession* session, RpcSessionClosedCallback callback) {
|
||||
furi_assert(session);
|
||||
furi_check(session);
|
||||
|
||||
furi_mutex_acquire(session->callbacks_mutex, FuriWaitForever);
|
||||
session->closed_callback = callback;
|
||||
@@ -131,7 +131,7 @@ void rpc_session_set_close_callback(RpcSession* session, RpcSessionClosedCallbac
|
||||
}
|
||||
|
||||
void rpc_session_set_send_bytes_callback(RpcSession* session, RpcSendBytesCallback callback) {
|
||||
furi_assert(session);
|
||||
furi_check(session);
|
||||
|
||||
furi_mutex_acquire(session->callbacks_mutex, FuriWaitForever);
|
||||
session->send_bytes_callback = callback;
|
||||
@@ -141,7 +141,7 @@ void rpc_session_set_send_bytes_callback(RpcSession* session, RpcSendBytesCallba
|
||||
void rpc_session_set_buffer_is_empty_callback(
|
||||
RpcSession* session,
|
||||
RpcBufferIsEmptyCallback callback) {
|
||||
furi_assert(session);
|
||||
furi_check(session);
|
||||
|
||||
furi_mutex_acquire(session->callbacks_mutex, FuriWaitForever);
|
||||
session->buffer_is_empty_callback = callback;
|
||||
@@ -151,7 +151,7 @@ void rpc_session_set_buffer_is_empty_callback(
|
||||
void rpc_session_set_terminated_callback(
|
||||
RpcSession* session,
|
||||
RpcSessionTerminatedCallback callback) {
|
||||
furi_assert(session);
|
||||
furi_check(session);
|
||||
|
||||
furi_mutex_acquire(session->callbacks_mutex, FuriWaitForever);
|
||||
session->terminated_callback = callback;
|
||||
@@ -169,8 +169,8 @@ size_t rpc_session_feed(
|
||||
const uint8_t* encoded_bytes,
|
||||
size_t size,
|
||||
uint32_t timeout) {
|
||||
furi_assert(session);
|
||||
furi_assert(encoded_bytes);
|
||||
furi_check(session);
|
||||
furi_check(encoded_bytes);
|
||||
|
||||
if(!size) return 0;
|
||||
|
||||
@@ -182,7 +182,7 @@ size_t rpc_session_feed(
|
||||
}
|
||||
|
||||
size_t rpc_session_get_available_size(RpcSession* session) {
|
||||
furi_assert(session);
|
||||
furi_check(session);
|
||||
return furi_stream_buffer_spaces_available(session->stream);
|
||||
}
|
||||
|
||||
@@ -388,7 +388,7 @@ RpcSession* rpc_session_open(Rpc* rpc, RpcOwner owner) {
|
||||
!momentum_settings.allow_locked_rpc_commands)
|
||||
return NULL;
|
||||
|
||||
furi_assert(rpc);
|
||||
furi_check(rpc);
|
||||
|
||||
RpcSession* session = malloc(sizeof(RpcSession));
|
||||
session->callbacks_mutex = furi_mutex_alloc(FuriMutexTypeNormal);
|
||||
@@ -428,8 +428,8 @@ RpcSession* rpc_session_open(Rpc* rpc, RpcOwner owner) {
|
||||
}
|
||||
|
||||
void rpc_session_close(RpcSession* session) {
|
||||
furi_assert(session);
|
||||
furi_assert(session->rpc);
|
||||
furi_check(session);
|
||||
furi_check(session->rpc);
|
||||
|
||||
session->rpc->sessions_count--;
|
||||
|
||||
|
||||
@@ -314,20 +314,20 @@ static void rpc_system_app_data_exchange_process(const PB_Main* request, void* c
|
||||
}
|
||||
|
||||
void rpc_system_app_send_started(RpcAppSystem* rpc_app) {
|
||||
furi_assert(rpc_app);
|
||||
furi_check(rpc_app);
|
||||
rpc_system_app_send_state_response(rpc_app, PB_App_AppState_APP_STARTED, "SendStarted");
|
||||
}
|
||||
|
||||
void rpc_system_app_send_exited(RpcAppSystem* rpc_app) {
|
||||
furi_assert(rpc_app);
|
||||
furi_check(rpc_app);
|
||||
rpc_system_app_send_state_response(rpc_app, PB_App_AppState_APP_CLOSED, "SendExit");
|
||||
}
|
||||
|
||||
void rpc_system_app_confirm(RpcAppSystem* rpc_app, bool result) {
|
||||
furi_assert(rpc_app);
|
||||
furi_assert(rpc_app->last_command_id != 0);
|
||||
furi_check(rpc_app);
|
||||
furi_check(rpc_app->last_command_id != 0);
|
||||
/* Ensure that only commands of these types can be confirmed */
|
||||
furi_assert(
|
||||
furi_check(
|
||||
rpc_app->last_event_type == RpcAppEventTypeAppExit ||
|
||||
rpc_app->last_event_type == RpcAppEventTypeLoadFile ||
|
||||
rpc_app->last_event_type == RpcAppEventTypeButtonPress ||
|
||||
@@ -353,19 +353,19 @@ void rpc_system_app_confirm(RpcAppSystem* rpc_app, bool result) {
|
||||
}
|
||||
|
||||
void rpc_system_app_set_callback(RpcAppSystem* rpc_app, RpcAppSystemCallback callback, void* ctx) {
|
||||
furi_assert(rpc_app);
|
||||
furi_check(rpc_app);
|
||||
|
||||
rpc_app->callback = callback;
|
||||
rpc_app->callback_context = ctx;
|
||||
}
|
||||
|
||||
void rpc_system_app_set_error_code(RpcAppSystem* rpc_app, uint32_t error_code) {
|
||||
furi_assert(rpc_app);
|
||||
furi_check(rpc_app);
|
||||
rpc_app->error_code = error_code;
|
||||
}
|
||||
|
||||
void rpc_system_app_set_error_text(RpcAppSystem* rpc_app, const char* error_text) {
|
||||
furi_assert(rpc_app);
|
||||
furi_check(rpc_app);
|
||||
|
||||
if(rpc_app->error_text) {
|
||||
free(rpc_app->error_text);
|
||||
@@ -375,14 +375,14 @@ void rpc_system_app_set_error_text(RpcAppSystem* rpc_app, const char* error_text
|
||||
}
|
||||
|
||||
void rpc_system_app_error_reset(RpcAppSystem* rpc_app) {
|
||||
furi_assert(rpc_app);
|
||||
furi_check(rpc_app);
|
||||
|
||||
rpc_system_app_set_error_code(rpc_app, 0);
|
||||
rpc_system_app_set_error_text(rpc_app, NULL);
|
||||
}
|
||||
|
||||
void rpc_system_app_exchange_data(RpcAppSystem* rpc_app, const uint8_t* data, size_t data_size) {
|
||||
furi_assert(rpc_app);
|
||||
furi_check(rpc_app);
|
||||
|
||||
PB_Main* request = malloc(sizeof(PB_Main));
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "filesystem_api_defines.h"
|
||||
#include <furi.h>
|
||||
|
||||
const char* filesystem_api_error_get_desc(FS_Error error_id) {
|
||||
const char* result = "unknown error";
|
||||
@@ -38,5 +39,6 @@ const char* filesystem_api_error_get_desc(FS_Error error_id) {
|
||||
}
|
||||
|
||||
bool file_info_is_dir(const FileInfo* file_info) {
|
||||
furi_check(file_info);
|
||||
return (file_info->flags & FSF_DIRECTORY);
|
||||
}
|
||||
@@ -32,7 +32,7 @@ static void storage_app_sd_icon_draw_callback(Canvas* canvas, void* context) {
|
||||
}
|
||||
}
|
||||
|
||||
Storage* storage_app_alloc() {
|
||||
Storage* storage_app_alloc(void) {
|
||||
Storage* app = malloc(sizeof(Storage));
|
||||
app->message_queue = furi_message_queue_alloc(8, sizeof(StorageMessage));
|
||||
app->pubsub = furi_pubsub_alloc();
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user