Skip to content

Commit

Permalink
FlipTDI (#234)
Browse files Browse the repository at this point in the history
  • Loading branch information
Skorpionm authored Oct 7, 2024
1 parent b791dea commit ee70c30
Show file tree
Hide file tree
Showing 44 changed files with 3,404 additions and 0 deletions.
7 changes: 7 additions & 0 deletions flip_tdi/.catalog/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# FlipTDI

This is a FT232H device emulation application

## Usage

Сonnect Flipper to your computer and open the application, a new FT232H compatible device will appear in the system
2 changes: 2 additions & 0 deletions flip_tdi/.catalog/changelog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
## 1.0
- Initial release
Binary file added flip_tdi/.catalog/screenshots/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added flip_tdi/.catalog/screenshots/2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added flip_tdi/.catalog/screenshots/3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added flip_tdi/.catalog/screenshots/4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 17 additions & 0 deletions flip_tdi/application.fam
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
App(
appid="flip_tdi",
name="FlipTDI",
apptype=FlipperAppType.EXTERNAL,
entry_point="flip_tdi_app",
requires=[
"gui",
"dialogs",
],
stack_size=2 * 1024,
fap_description="Flipper FTDI232H emulator.",
fap_version="1.0",
fap_icon="flip_tdi_icon_10px.png",
fap_category="USB",
fap_icon_assets="images",
fap_author="SkorP",
)
111 changes: 111 additions & 0 deletions flip_tdi/flip_tdi_app.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
#include <furi.h>
#include "flip_tdi_app_i.h"

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

static bool flip_tdi_app_back_event_callback(void* context) {
furi_assert(context);
FlipTDIApp* app = context;
return scene_manager_handle_back_event(app->scene_manager);
}

static void flip_tdi_app_tick_event_callback(void* context) {
furi_assert(context);
FlipTDIApp* app = context;
scene_manager_handle_tick_event(app->scene_manager);
}

FlipTDIApp* flip_tdi_app_alloc() {
FlipTDIApp* app = malloc(sizeof(FlipTDIApp));

// GUI
app->gui = furi_record_open(RECORD_GUI);

// View Dispatcher
app->view_dispatcher = view_dispatcher_alloc();
app->scene_manager = scene_manager_alloc(&flip_tdi_scene_handlers, app);

view_dispatcher_set_event_callback_context(app->view_dispatcher, app);
view_dispatcher_set_custom_event_callback(
app->view_dispatcher, flip_tdi_app_custom_event_callback);
view_dispatcher_set_navigation_event_callback(
app->view_dispatcher, flip_tdi_app_back_event_callback);
view_dispatcher_set_tick_event_callback(
app->view_dispatcher, flip_tdi_app_tick_event_callback, 100);

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

// Open Notification record
app->notifications = furi_record_open(RECORD_NOTIFICATION);

// SubMenu
app->submenu = submenu_alloc();
view_dispatcher_add_view(
app->view_dispatcher, FlipTDIViewSubmenu, submenu_get_view(app->submenu));

// Widget
app->widget = widget_alloc();
view_dispatcher_add_view(
app->view_dispatcher, FlipTDIViewWidget, widget_get_view(app->widget));

// Field Presence
app->flip_tdi_view_main_instance = flip_tdi_view_main_alloc();
view_dispatcher_add_view(
app->view_dispatcher,
FlipTDIViewMain,
flip_tdi_view_main_get_view(app->flip_tdi_view_main_instance));

// FTDI emulation Start
flip_tdi_start(app);

scene_manager_next_scene(app->scene_manager, FlipTDISceneMain);

return app;
}

void flip_tdi_app_free(FlipTDIApp* app) {
furi_assert(app);

// FTDI emulation Stop
flip_tdi_stop(app);

// Submenu
view_dispatcher_remove_view(app->view_dispatcher, FlipTDIViewSubmenu);
submenu_free(app->submenu);

// Widget
view_dispatcher_remove_view(app->view_dispatcher, FlipTDIViewWidget);
widget_free(app->widget);

// FlipTDIViewMain
view_dispatcher_remove_view(app->view_dispatcher, FlipTDIViewMain);
flip_tdi_view_main_free(app->flip_tdi_view_main_instance);

// View dispatcher
view_dispatcher_free(app->view_dispatcher);
scene_manager_free(app->scene_manager);

// Notifications
furi_record_close(RECORD_NOTIFICATION);
app->notifications = NULL;

// Close records
furi_record_close(RECORD_GUI);

free(app);
}

int32_t flip_tdi_app(void* p) {
UNUSED(p);
FlipTDIApp* flip_tdi_app = flip_tdi_app_alloc();

view_dispatcher_run(flip_tdi_app->view_dispatcher);

flip_tdi_app_free(flip_tdi_app);

return 0;
}
17 changes: 17 additions & 0 deletions flip_tdi/flip_tdi_app_i.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#include "flip_tdi_app_i.h"

#include <furi.h>

#define TAG "FlipTDI"

void flip_tdi_start(FlipTDIApp* app) {
furi_assert(app);

app->ftdi_usb = ftdi_usb_start();
}

void flip_tdi_stop(FlipTDIApp* app) {
furi_assert(app);

ftdi_usb_stop(app->ftdi_usb);
}
34 changes: 34 additions & 0 deletions flip_tdi/flip_tdi_app_i.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#pragma once

#include "helpers/flip_tdi_types.h"
#include "helpers/flip_tdi_event.h"

#include "scenes/flip_tdi_scene.h"
#include <gui/gui.h>
#include <gui/view_dispatcher.h>
#include <gui/scene_manager.h>
#include <gui/modules/submenu.h>
#include <gui/modules/widget.h>
#include <notification/notification_messages.h>
#include "views/flip_tdi_view_main.h"
#include <flip_tdi_icons.h>

#include "helpers/ftdi_usb.h"


typedef struct FlipTDIApp FlipTDIApp;

struct FlipTDIApp {
Gui* gui;
ViewDispatcher* view_dispatcher;
SceneManager* scene_manager;
NotificationApp* notifications;
Submenu* submenu;
Widget* widget;
FlipTDIViewMainType* flip_tdi_view_main_instance;

FtdiUsb* ftdi_usb;
};

void flip_tdi_start(FlipTDIApp* app);
void flip_tdi_stop(FlipTDIApp* app);
Binary file added flip_tdi/flip_tdi_icon_10px.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions flip_tdi/helpers/flip_tdi_event.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#pragma once

typedef enum {
//SubmenuIndex
SubmenuIndexWiringUart = 10,
SubmenuIndexWiringSpi,
SubmenuIndexWiringGpio,
SubmenuIndexAbout,

//FlipTDICustomEvent
FlipTDICustomEventStartId = 100,
FlipTDICustomEventMainMore,

} FlipTDICustomEvent;
14 changes: 14 additions & 0 deletions flip_tdi/helpers/flip_tdi_types.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#pragma once

#include <furi.h>
#include <furi_hal.h>

#define FLIP_TDI_DEVELOPED "SkorP"
#define FLIP_TDI_GITHUB "https://github.com/flipperdevices/flipperzero-good-faps"

typedef enum {
FlipTDIViewVariableItemList,
FlipTDIViewSubmenu,
FlipTDIViewMain,
FlipTDIViewWidget,
} FlipTDIView;
Loading

0 comments on commit ee70c30

Please sign in to comment.