Skip to content

Commit

Permalink
flipbip39 > flipbip
Browse files Browse the repository at this point in the history
  • Loading branch information
xtruan committed Mar 3, 2023
1 parent 9e53238 commit 81b9e20
Show file tree
Hide file tree
Showing 41 changed files with 661 additions and 661 deletions.
6 changes: 3 additions & 3 deletions application.fam
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
App(
appid="FlipBIP",
name="BIP39 Tool",
name="BIP32/39/44 Tool",
apptype=FlipperAppType.EXTERNAL,
entry_point="flipbip39_app",
entry_point="flipbip_app",
cdefines=["APP_FLIPBIP"],
requires=[
"gui",
],
stack_size=2 * 1024,
order=10,
fap_icon="flipbip39_10px.png",
fap_icon="flipbip_10px.png",
fap_icon_assets="icons",
fap_category="Misc",
)
110 changes: 110 additions & 0 deletions flipbip.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
#include "flipbip.h"

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

void flipbip_tick_event_callback(void* context) {
furi_assert(context);
FlipBip* app = context;
scene_manager_handle_tick_event(app->scene_manager);
}

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

FlipBip* flipbip_app_alloc() {
FlipBip* app = malloc(sizeof(FlipBip));
app->gui = furi_record_open(RECORD_GUI);
app->notification = furi_record_open(RECORD_NOTIFICATION);

//Turn backlight on, believe me this makes testing your app easier
notification_message(app->notification, &sequence_display_backlight_on);

//Scene additions
app->view_dispatcher = view_dispatcher_alloc();
view_dispatcher_enable_queue(app->view_dispatcher);

app->scene_manager = scene_manager_alloc(&flipbip_scene_handlers, app);
view_dispatcher_set_event_callback_context(app->view_dispatcher, app);
view_dispatcher_set_navigation_event_callback(app->view_dispatcher, flipbip_navigation_event_callback);
view_dispatcher_set_tick_event_callback(app->view_dispatcher, flipbip_tick_event_callback, 100);
view_dispatcher_set_custom_event_callback(app->view_dispatcher, flipbip_custom_event_callback);
app->submenu = submenu_alloc();

app->haptic = 1;
app->speaker = 1;
app->led = 1;
app->bip39_strength = 2; // 256 bits (24 words)

view_dispatcher_add_view(app->view_dispatcher, FlipBipViewIdMenu, submenu_get_view(app->submenu));
app->flipbip_startscreen = flipbip_startscreen_alloc();
view_dispatcher_add_view(app->view_dispatcher, FlipBipViewIdStartscreen, flipbip_startscreen_get_view(app->flipbip_startscreen));
app->flipbip_scene_1 = flipbip_scene_1_alloc();
view_dispatcher_add_view(app->view_dispatcher, FlipBipViewIdScene1, flipbip_scene_1_get_view(app->flipbip_scene_1));
app->flipbip_scene_2 = flipbip_scene_2_alloc();
view_dispatcher_add_view(app->view_dispatcher, FlipBipViewIdScene2, flipbip_scene_2_get_view(app->flipbip_scene_2));
app->variable_item_list = variable_item_list_alloc();
view_dispatcher_add_view(app->view_dispatcher, FlipBipViewIdSettings, variable_item_list_get_view(app->variable_item_list));

//End Scene Additions

return app;
}

void flipbip_app_free(FlipBip* app) {
furi_assert(app);

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

// View Dispatcher
view_dispatcher_remove_view(app->view_dispatcher, FlipBipViewIdMenu);
view_dispatcher_remove_view(app->view_dispatcher, FlipBipViewIdScene1);
view_dispatcher_remove_view(app->view_dispatcher, FlipBipViewIdScene2);
view_dispatcher_remove_view(app->view_dispatcher, FlipBipViewIdSettings);
submenu_free(app->submenu);

view_dispatcher_free(app->view_dispatcher);
furi_record_close(RECORD_GUI);

app->gui = NULL;
app->notification = NULL;

//Remove whatever is left
free(app);
}

int32_t flipbip_app(void* p) {
UNUSED(p);
FlipBip* app = flipbip_app_alloc();

// Disabled because causes exit on customer firmwares such as RM
/*if(!furi_hal_region_is_provisioned()) {
flipbip_app_free(app);
return 1;
}*/

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

scene_manager_next_scene(app->scene_manager, FlipBipSceneStartscreen); //Start with start screen
//scene_manager_next_scene(app->scene_manager, FlipBipSceneMenu); //if you want to directly start with Menu

furi_hal_power_suppress_charge_enter();

view_dispatcher_run(app->view_dispatcher);

furi_hal_power_suppress_charge_exit();
flipbip_app_free(app);

return 0;
}



61 changes: 61 additions & 0 deletions flipbip.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#pragma once

#include <furi.h>
#include <furi_hal.h>
#include <gui/gui.h>
#include <input/input.h>
#include <stdlib.h>
#include <notification/notification_messages.h>
#include <gui/view_dispatcher.h>
#include <gui/modules/submenu.h>
#include <gui/scene_manager.h>
#include <gui/modules/variable_item_list.h>
#include "scenes/flipbip_scene.h"
#include "views/flipbip_startscreen.h"
#include "views/flipbip_scene_1.h"
#include "views/flipbip_scene_2.h"

typedef struct {
Gui* gui;
NotificationApp* notification;
ViewDispatcher* view_dispatcher;
Submenu* submenu;
SceneManager* scene_manager;
VariableItemList* variable_item_list;
FlipBipStartscreen* flipbip_startscreen;
FlipBipScene1* flipbip_scene_1;
FlipBipScene2* flipbip_scene_2;
int haptic;
int speaker;
int led;
int bip39_strength;
} FlipBip;

typedef enum {
FlipBipViewIdStartscreen,
FlipBipViewIdMenu,
FlipBipViewIdScene1,
FlipBipViewIdScene2,
FlipBipViewIdSettings,
} FlipBipViewId;

typedef enum {
FlipBipHapticOff,
FlipBipHapticOn,
} FlipBipHapticState;

typedef enum {
FlipBipSpeakerOff,
FlipBipSpeakerOn,
} FlipBipSpeakerState;

typedef enum {
FlipBipLedOff,
FlipBipLedOn,
} FlipBipLedState;

typedef enum {
FlipBipStrength128,
FlipBipStrength192,
FlipBipStrength256,
} FlipBipStrengthState;
110 changes: 0 additions & 110 deletions flipbip39.c

This file was deleted.

61 changes: 0 additions & 61 deletions flipbip39.h

This file was deleted.

File renamed without changes
22 changes: 0 additions & 22 deletions helpers/flipbip39_custom_event.h

This file was deleted.

8 changes: 0 additions & 8 deletions helpers/flipbip39_haptic.h

This file was deleted.

Loading

0 comments on commit 81b9e20

Please sign in to comment.