Skip to content

Commit

Permalink
fix: Wrong rename fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
QtRoS committed Sep 30, 2023
1 parent 473ce0a commit 8f15b70
Show file tree
Hide file tree
Showing 24 changed files with 284 additions and 284 deletions.
2 changes: 1 addition & 1 deletion application.fam
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ App(
fap_libs=["assets"],
fap_icon="icons/hex_10px.png",
fap_icon_assets="icons",
fap_category="Misc",
fap_category="Tools",

)
50 changes: 25 additions & 25 deletions helpers/hex_viewer_custom_event.h
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
#pragma once

typedef enum {
BoilerplateCustomEventStartscreenUp,
BoilerplateCustomEventStartscreenDown,
BoilerplateCustomEventStartscreenLeft,
BoilerplateCustomEventStartscreenRight,
BoilerplateCustomEventStartscreenOk,
BoilerplateCustomEventStartscreenBack,
BoilerplateCustomEventScene1Up,
BoilerplateCustomEventScene1Down,
BoilerplateCustomEventScene1Left,
BoilerplateCustomEventScene1Right,
BoilerplateCustomEventScene1Ok,
BoilerplateCustomEventScene1Back,
BoilerplateCustomEventScene2Up,
BoilerplateCustomEventScene2Down,
BoilerplateCustomEventScene2Left,
BoilerplateCustomEventScene2Right,
BoilerplateCustomEventScene2Ok,
BoilerplateCustomEventScene2Back,
} BoilerplateCustomEvent;
HexViewerCustomEventStartscreenUp,
HexViewerCustomEventStartscreenDown,
HexViewerCustomEventStartscreenLeft,
HexViewerCustomEventStartscreenRight,
HexViewerCustomEventStartscreenOk,
HexViewerCustomEventStartscreenBack,
HexViewerCustomEventScene1Up,
HexViewerCustomEventScene1Down,
HexViewerCustomEventScene1Left,
HexViewerCustomEventScene1Right,
HexViewerCustomEventScene1Ok,
HexViewerCustomEventScene1Back,
HexViewerCustomEventScene2Up,
HexViewerCustomEventScene2Down,
HexViewerCustomEventScene2Left,
HexViewerCustomEventScene2Right,
HexViewerCustomEventScene2Ok,
HexViewerCustomEventScene2Back,
} HexViewerCustomEvent;

enum BoilerplateCustomEventType {
enum HexViewerCustomEventType {
// Reserve first 100 events for button types and indexes, starting from 0
BoilerplateCustomEventMenuVoid,
BoilerplateCustomEventMenuSelected,
HexViewerCustomEventMenuVoid,
HexViewerCustomEventMenuSelected,
};

#pragma pack(push, 1)
Expand All @@ -34,15 +34,15 @@ typedef union {
uint16_t type;
int16_t value;
} content;
} BoilerplateCustomEventMenu;
} HexViewerCustomEventMenu;
#pragma pack(pop)

static inline uint32_t hex_viewer_custom_menu_event_pack(uint16_t type, int16_t value) {
BoilerplateCustomEventMenu event = {.content = {.type = type, .value = value}};
HexViewerCustomEventMenu event = {.content = {.type = type, .value = value}};
return event.packed_value;
}
static inline void hex_viewer_custom_menu_event_unpack(uint32_t packed_value, uint16_t* type, int16_t* value) {
BoilerplateCustomEventMenu event = {.packed_value = packed_value};
HexViewerCustomEventMenu event = {.packed_value = packed_value};
if(type) *type = event.content.type;
if(value) *value = event.content.value;
}
Expand Down
6 changes: 3 additions & 3 deletions helpers/hex_viewer_haptic.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@


void hex_viewer_play_happy_bump(void* context) {
Boilerplate* app = context;
HexViewer* app = context;
if (app->haptic != 1) {
return;
}
Expand All @@ -13,7 +13,7 @@ void hex_viewer_play_happy_bump(void* context) {
}

void hex_viewer_play_bad_bump(void* context) {
Boilerplate* app = context;
HexViewer* app = context;
if (app->haptic != 1) {
return;
}
Expand All @@ -23,7 +23,7 @@ void hex_viewer_play_bad_bump(void* context) {
}

void hex_viewer_play_long_bump(void* context) {
Boilerplate* app = context;
HexViewer* app = context;
if (app->haptic != 1) {
return;
}
Expand Down
4 changes: 2 additions & 2 deletions helpers/hex_viewer_led.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@


void hex_viewer_led_set_rgb(void* context, int red, int green, int blue) {
Boilerplate* app = context;
HexViewer* app = context;
if (app->led != 1) {
return;
}
Expand All @@ -30,7 +30,7 @@ void hex_viewer_led_set_rgb(void* context, int red, int green, int blue) {
}

void hex_viewer_led_reset(void* context) {
Boilerplate* app = context;
HexViewer* app = context;
notification_message(app->notification, &sequence_reset_red);
notification_message(app->notification, &sequence_reset_green);
notification_message(app->notification, &sequence_reset_blue);
Expand Down
4 changes: 2 additions & 2 deletions helpers/hex_viewer_speaker.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#define NOTE_INPUT 587.33f

void hex_viewer_play_input_sound(void* context) {
Boilerplate* app = context;
HexViewer* app = context;
if (app->speaker != 1) {
return;
}
Expand All @@ -16,7 +16,7 @@ void hex_viewer_play_input_sound(void* context) {
}

void hex_viewer_stop_all_sound(void* context) {
Boilerplate* app = context;
HexViewer* app = context;
if (app->speaker != 1) {
return;
}
Expand Down
42 changes: 21 additions & 21 deletions helpers/hex_viewer_storage.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ static void hex_viewer_close_config_file(FlipperFormat* file) {
}

void hex_viewer_save_settings(void* context) {
Boilerplate* app = context;
HexViewer* app = context;
if (app->save_settings == 0) {
return;
}
Expand All @@ -26,13 +26,13 @@ void hex_viewer_save_settings(void* context) {
FlipperFormat* fff_file = flipper_format_file_alloc(storage);

// Overwrite wont work, so delete first
if(storage_file_exists(storage, BOILERPLATE_SETTINGS_SAVE_PATH)) {
storage_simply_remove(storage, BOILERPLATE_SETTINGS_SAVE_PATH);
if(storage_file_exists(storage, HEX_VIEWER_SETTINGS_SAVE_PATH)) {
storage_simply_remove(storage, HEX_VIEWER_SETTINGS_SAVE_PATH);
}

// Open File, create if not exists
if(!storage_common_stat(storage, BOILERPLATE_SETTINGS_SAVE_PATH, NULL) == FSE_OK) {
FURI_LOG_D(TAG, "Config file %s is not found. Will create new.", BOILERPLATE_SETTINGS_SAVE_PATH);
if(!storage_common_stat(storage, HEX_VIEWER_SETTINGS_SAVE_PATH, NULL) == FSE_OK) {
FURI_LOG_D(TAG, "Config file %s is not found. Will create new.", HEX_VIEWER_SETTINGS_SAVE_PATH);
if(storage_common_stat(storage, CONFIG_FILE_DIRECTORY_PATH, NULL) == FSE_NOT_EXIST) {
FURI_LOG_D(
TAG,
Expand All @@ -44,24 +44,24 @@ void hex_viewer_save_settings(void* context) {
}
}

if(!flipper_format_file_open_new(fff_file, BOILERPLATE_SETTINGS_SAVE_PATH)) {
if(!flipper_format_file_open_new(fff_file, HEX_VIEWER_SETTINGS_SAVE_PATH)) {
//totp_close_config_file(fff_file);
FURI_LOG_E(TAG, "Error creating new file %s", BOILERPLATE_SETTINGS_SAVE_PATH);
FURI_LOG_E(TAG, "Error creating new file %s", HEX_VIEWER_SETTINGS_SAVE_PATH);
hex_viewer_close_storage();
return;
}

// Store Settings
flipper_format_write_header_cstr(
fff_file, BOILERPLATE_SETTINGS_HEADER, BOILERPLATE_SETTINGS_FILE_VERSION);
fff_file, HEX_VIEWER_SETTINGS_HEADER, HEX_VIEWER_SETTINGS_FILE_VERSION);
flipper_format_write_uint32(
fff_file, BOILERPLATE_SETTINGS_KEY_HAPTIC, &app->haptic, 1);
fff_file, HEX_VIEWER_SETTINGS_KEY_HAPTIC, &app->haptic, 1);
flipper_format_write_uint32(
fff_file, BOILERPLATE_SETTINGS_KEY_SPEAKER, &app->speaker, 1);
fff_file, HEX_VIEWER_SETTINGS_KEY_SPEAKER, &app->speaker, 1);
flipper_format_write_uint32(
fff_file, BOILERPLATE_SETTINGS_KEY_LED, &app->led, 1);
fff_file, HEX_VIEWER_SETTINGS_KEY_LED, &app->led, 1);
flipper_format_write_uint32(
fff_file, BOILERPLATE_SETTINGS_KEY_SAVE_SETTINGS, &app->save_settings, 1);
fff_file, HEX_VIEWER_SETTINGS_KEY_SAVE_SETTINGS, &app->save_settings, 1);

if(!flipper_format_rewind(fff_file)) {
hex_viewer_close_config_file(fff_file);
Expand All @@ -75,20 +75,20 @@ void hex_viewer_save_settings(void* context) {
}

void hex_viewer_read_settings(void* context) {
Boilerplate* app = context;
HexViewer* app = context;
Storage* storage = hex_viewer_open_storage();
FlipperFormat* fff_file = flipper_format_file_alloc(storage);

if(storage_common_stat(storage, BOILERPLATE_SETTINGS_SAVE_PATH, NULL) != FSE_OK) {
if(storage_common_stat(storage, HEX_VIEWER_SETTINGS_SAVE_PATH, NULL) != FSE_OK) {
hex_viewer_close_config_file(fff_file);
hex_viewer_close_storage();
return;
}
uint32_t file_version;
FuriString* temp_str = furi_string_alloc();

if (!flipper_format_file_open_existing(fff_file, BOILERPLATE_SETTINGS_SAVE_PATH)) {
FURI_LOG_E(TAG, "Cannot open file %s", BOILERPLATE_SETTINGS_SAVE_PATH);
if (!flipper_format_file_open_existing(fff_file, HEX_VIEWER_SETTINGS_SAVE_PATH)) {
FURI_LOG_E(TAG, "Cannot open file %s", HEX_VIEWER_SETTINGS_SAVE_PATH);
hex_viewer_close_config_file(fff_file);
hex_viewer_close_storage();
return;
Expand All @@ -101,17 +101,17 @@ void hex_viewer_read_settings(void* context) {
return;
}

if(file_version < BOILERPLATE_SETTINGS_FILE_VERSION) {
if(file_version < HEX_VIEWER_SETTINGS_FILE_VERSION) {
FURI_LOG_I(TAG, "old config version, will be removed.");
hex_viewer_close_config_file(fff_file);
hex_viewer_close_storage();
return;
}

flipper_format_read_uint32(fff_file, BOILERPLATE_SETTINGS_KEY_HAPTIC, &app->haptic, 1);
flipper_format_read_uint32(fff_file, BOILERPLATE_SETTINGS_KEY_SPEAKER, &app->speaker, 1);
flipper_format_read_uint32(fff_file, BOILERPLATE_SETTINGS_KEY_LED, &app->led, 1);
flipper_format_read_uint32(fff_file, BOILERPLATE_SETTINGS_KEY_SAVE_SETTINGS, &app->save_settings, 1);
flipper_format_read_uint32(fff_file, HEX_VIEWER_SETTINGS_KEY_HAPTIC, &app->haptic, 1);
flipper_format_read_uint32(fff_file, HEX_VIEWER_SETTINGS_KEY_SPEAKER, &app->speaker, 1);
flipper_format_read_uint32(fff_file, HEX_VIEWER_SETTINGS_KEY_LED, &app->led, 1);
flipper_format_read_uint32(fff_file, HEX_VIEWER_SETTINGS_KEY_SAVE_SETTINGS, &app->save_settings, 1);

flipper_format_rewind(fff_file);

Expand Down
16 changes: 8 additions & 8 deletions helpers/hex_viewer_storage.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
#include <flipper_format/flipper_format_i.h>
#include "../hex_viewer.h"

#define BOILERPLATE_SETTINGS_FILE_VERSION 1
#define HEX_VIEWER_SETTINGS_FILE_VERSION 1
#define CONFIG_FILE_DIRECTORY_PATH EXT_PATH("apps_data/hex_viewer")
#define BOILERPLATE_SETTINGS_SAVE_PATH CONFIG_FILE_DIRECTORY_PATH "/hex_viewer.conf"
#define BOILERPLATE_SETTINGS_SAVE_PATH_TMP BOILERPLATE_SETTINGS_SAVE_PATH ".tmp"
#define BOILERPLATE_SETTINGS_HEADER "Boilerplate Config File"
#define BOILERPLATE_SETTINGS_KEY_HAPTIC "Haptic"
#define BOILERPLATE_SETTINGS_KEY_LED "Led"
#define BOILERPLATE_SETTINGS_KEY_SPEAKER "Speaker"
#define BOILERPLATE_SETTINGS_KEY_SAVE_SETTINGS "SaveSettings"
#define HEX_VIEWER_SETTINGS_SAVE_PATH CONFIG_FILE_DIRECTORY_PATH "/hex_viewer.conf"
#define HEX_VIEWER_SETTINGS_SAVE_PATH_TMP HEX_VIEWER_SETTINGS_SAVE_PATH ".tmp"
#define HEX_VIEWER_SETTINGS_HEADER "HexViewer Config File"
#define HEX_VIEWER_SETTINGS_KEY_HAPTIC "Haptic"
#define HEX_VIEWER_SETTINGS_KEY_LED "Led"
#define HEX_VIEWER_SETTINGS_KEY_SPEAKER "Speaker"
#define HEX_VIEWER_SETTINGS_KEY_SAVE_SETTINGS "SaveSettings"

void hex_viewer_save_settings(void* context);
void hex_viewer_read_settings(void* context);
38 changes: 19 additions & 19 deletions hex_viewer.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,25 @@

bool hex_viewer_custom_event_callback(void* context, uint32_t event) {
furi_assert(context);
Boilerplate* app = context;
HexViewer* app = context;
return scene_manager_handle_custom_event(app->scene_manager, event);
}

void hex_viewer_tick_event_callback(void* context) {
furi_assert(context);
Boilerplate* app = context;
HexViewer* app = context;
scene_manager_handle_tick_event(app->scene_manager);
}

//leave app if back button pressed
bool hex_viewer_navigation_event_callback(void* context) {
furi_assert(context);
Boilerplate* app = context;
HexViewer* app = context;
return scene_manager_handle_back_event(app->scene_manager);
}

Boilerplate* hex_viewer_app_alloc() {
Boilerplate* app = malloc(sizeof(Boilerplate));
HexViewer* hex_viewer_app_alloc() {
HexViewer* app = malloc(sizeof(HexViewer));
app->gui = furi_record_open(RECORD_GUI);
app->notification = furi_record_open(RECORD_NOTIFICATION);

Expand Down Expand Up @@ -51,35 +51,35 @@ Boilerplate* hex_viewer_app_alloc() {
// Load configs
hex_viewer_read_settings(app);

view_dispatcher_add_view(app->view_dispatcher, BoilerplateViewIdMenu, submenu_get_view(app->submenu));
view_dispatcher_add_view(app->view_dispatcher, HexViewerViewIdMenu, submenu_get_view(app->submenu));
app->hex_viewer_startscreen = hex_viewer_startscreen_alloc();
view_dispatcher_add_view(app->view_dispatcher, BoilerplateViewIdStartscreen, hex_viewer_startscreen_get_view(app->hex_viewer_startscreen));
view_dispatcher_add_view(app->view_dispatcher, HexViewerViewIdStartscreen, hex_viewer_startscreen_get_view(app->hex_viewer_startscreen));
app->hex_viewer_scene_1 = hex_viewer_scene_1_alloc();
view_dispatcher_add_view(app->view_dispatcher, BoilerplateViewIdScene1, hex_viewer_scene_1_get_view(app->hex_viewer_scene_1));
view_dispatcher_add_view(app->view_dispatcher, HexViewerViewIdScene1, hex_viewer_scene_1_get_view(app->hex_viewer_scene_1));
app->hex_viewer_scene_2 = hex_viewer_scene_2_alloc();
view_dispatcher_add_view(app->view_dispatcher, BoilerplateViewIdScene2, hex_viewer_scene_2_get_view(app->hex_viewer_scene_2));
view_dispatcher_add_view(app->view_dispatcher, HexViewerViewIdScene2, hex_viewer_scene_2_get_view(app->hex_viewer_scene_2));
app->button_menu = button_menu_alloc();
view_dispatcher_add_view(app->view_dispatcher, BoilerplateViewIdScene3, button_menu_get_view(app->button_menu));
view_dispatcher_add_view(app->view_dispatcher, HexViewerViewIdScene3, button_menu_get_view(app->button_menu));

app->variable_item_list = variable_item_list_alloc();
view_dispatcher_add_view(app->view_dispatcher, BoilerplateViewIdSettings, variable_item_list_get_view(app->variable_item_list));
view_dispatcher_add_view(app->view_dispatcher, HexViewerViewIdSettings, variable_item_list_get_view(app->variable_item_list));

//End Scene Additions

return app;
}

void hex_viewer_app_free(Boilerplate* app) {
void hex_viewer_app_free(HexViewer* app) {
furi_assert(app);

// Scene manager
scene_manager_free(app->scene_manager);

// View Dispatcher
view_dispatcher_remove_view(app->view_dispatcher, BoilerplateViewIdMenu);
view_dispatcher_remove_view(app->view_dispatcher, BoilerplateViewIdScene1);
view_dispatcher_remove_view(app->view_dispatcher, BoilerplateViewIdScene2);
view_dispatcher_remove_view(app->view_dispatcher, BoilerplateViewIdSettings);
view_dispatcher_remove_view(app->view_dispatcher, HexViewerViewIdMenu);
view_dispatcher_remove_view(app->view_dispatcher, HexViewerViewIdScene1);
view_dispatcher_remove_view(app->view_dispatcher, HexViewerViewIdScene2);
view_dispatcher_remove_view(app->view_dispatcher, HexViewerViewIdSettings);
submenu_free(app->submenu);

view_dispatcher_free(app->view_dispatcher);
Expand All @@ -98,12 +98,12 @@ void hex_viewer_app_free(Boilerplate* app) {

int32_t hex_viewer_app(void* p) {
UNUSED(p);
Boilerplate* app = hex_viewer_app_alloc();
HexViewer* app = hex_viewer_app_alloc();

view_dispatcher_attach_to_gui(app->view_dispatcher, app->gui, ViewDispatcherTypeFullscreen);

scene_manager_next_scene(app->scene_manager, BoilerplateSceneStartscreen); //Start with start screen
//scene_manager_next_scene(app->scene_manager, BoilerplateSceneMenu); //if you want to directly start with Menu
scene_manager_next_scene(app->scene_manager, HexViewerSceneStartscreen); //Start with start screen
//scene_manager_next_scene(app->scene_manager, HexViewerSceneMenu); //if you want to directly start with Menu

furi_hal_power_suppress_charge_enter();

Expand Down
Loading

0 comments on commit 8f15b70

Please sign in to comment.