274c12fc56
* Streams: string stream * String stream: updated insert/delete api * Streams: generic stream interface and string stream implementation * Streams: helpers for insert and delete_and_insert * FFF: now compatible with streams * MinUnit: introduced tests with arguments * FFF: stream access violation * Streams: copy data between streams * Streams: file stream * FFF: documentation * FFStream: documentation * FFF: alloc as file * MinUnit: support for nested tests * Streams: changed delete_and_insert, now it returns success flag. Added ability dump stream inner parameters and data to cout. * FFF: simplified file open function * Streams: unit tests * FFF: tests * Streams: declare cache_size constant as define, to allow variable modified arrays * FFF: lib moved to a separate folder * iButton: new FFF * RFID: new FFF * Animations: new FFF * IR: new FFF * NFC: new FFF * Flipper file format: delete lib * U2F: new FFF * Subghz: new FFF and streams * Streams: read line * Streams: split * FuriCore: implement memset with extra asserts * FuriCore: implement extra heap asserts without inventing memset * Scene manager: protected access to the scene id stack with a size check * NFC worker: dirty fix for issue where hal_nfc was busy on app start * Furi: update allocator to erase memory on allocation. Replace furi_alloc with malloc. * FuriCore: cleanup memmgr code. * Furi HAL: furi_hal_init is split into critical and non-critical parts. The critical part is currently clock and console. * Memmgr: added ability to track allocations and deallocations through console. * FFStream: some speedup * Streams, FF: minor fixes * Tests: restore * File stream: a slightly more thread-safe version of file_stream_delete_and_insert Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
109 lines
3.3 KiB
C
109 lines
3.3 KiB
C
#include <furi.h>
|
|
#include <furi_hal.h>
|
|
|
|
#include <gui/view.h>
|
|
#include <gui/view_dispatcher.h>
|
|
#include <gui/modules/submenu.h>
|
|
#include <gui/gui.h>
|
|
|
|
typedef struct {
|
|
Gui* gui;
|
|
ViewDispatcher* view_dispatcher;
|
|
Submenu* submenu;
|
|
} UsbTestApp;
|
|
|
|
typedef enum {
|
|
UsbTestSubmenuIndexEnable,
|
|
UsbTestSubmenuIndexDisable,
|
|
UsbTestSubmenuIndexRestart,
|
|
UsbTestSubmenuIndexVcpSingle,
|
|
UsbTestSubmenuIndexVcpDual,
|
|
UsbTestSubmenuIndexHid,
|
|
UsbTestSubmenuIndexHidU2F,
|
|
} SubmenuIndex;
|
|
|
|
void usb_test_submenu_callback(void* context, uint32_t index) {
|
|
furi_assert(context);
|
|
//UsbTestApp* app = context;
|
|
if(index == UsbTestSubmenuIndexEnable) {
|
|
furi_hal_usb_enable();
|
|
} else if(index == UsbTestSubmenuIndexDisable) {
|
|
furi_hal_usb_disable();
|
|
} else if(index == UsbTestSubmenuIndexRestart) {
|
|
furi_hal_usb_reinit();
|
|
} else if(index == UsbTestSubmenuIndexVcpSingle) {
|
|
furi_hal_usb_set_config(&usb_cdc_single);
|
|
} else if(index == UsbTestSubmenuIndexVcpDual) {
|
|
furi_hal_usb_set_config(&usb_cdc_dual);
|
|
} else if(index == UsbTestSubmenuIndexHid) {
|
|
furi_hal_usb_set_config(&usb_hid);
|
|
} else if(index == UsbTestSubmenuIndexHidU2F) {
|
|
furi_hal_usb_set_config(&usb_hid_u2f);
|
|
}
|
|
}
|
|
|
|
uint32_t usb_test_exit(void* context) {
|
|
return VIEW_NONE;
|
|
}
|
|
|
|
UsbTestApp* usb_test_app_alloc() {
|
|
UsbTestApp* app = malloc(sizeof(UsbTestApp));
|
|
|
|
// Gui
|
|
app->gui = furi_record_open("gui");
|
|
|
|
// View dispatcher
|
|
app->view_dispatcher = view_dispatcher_alloc();
|
|
view_dispatcher_enable_queue(app->view_dispatcher);
|
|
view_dispatcher_attach_to_gui(app->view_dispatcher, app->gui, ViewDispatcherTypeFullscreen);
|
|
|
|
// Views
|
|
app->submenu = submenu_alloc();
|
|
submenu_add_item(
|
|
app->submenu, "Enable", UsbTestSubmenuIndexEnable, usb_test_submenu_callback, app);
|
|
submenu_add_item(
|
|
app->submenu, "Disable", UsbTestSubmenuIndexDisable, usb_test_submenu_callback, app);
|
|
submenu_add_item(
|
|
app->submenu, "Restart", UsbTestSubmenuIndexRestart, usb_test_submenu_callback, app);
|
|
submenu_add_item(
|
|
app->submenu, "Single VCP", UsbTestSubmenuIndexVcpSingle, usb_test_submenu_callback, app);
|
|
submenu_add_item(
|
|
app->submenu, "Dual VCP", UsbTestSubmenuIndexVcpDual, usb_test_submenu_callback, app);
|
|
submenu_add_item(
|
|
app->submenu, "HID KB+Mouse", UsbTestSubmenuIndexHid, usb_test_submenu_callback, app);
|
|
submenu_add_item(
|
|
app->submenu, "HID U2F", UsbTestSubmenuIndexHidU2F, usb_test_submenu_callback, app);
|
|
view_set_previous_callback(submenu_get_view(app->submenu), usb_test_exit);
|
|
view_dispatcher_add_view(app->view_dispatcher, 0, submenu_get_view(app->submenu));
|
|
|
|
// Switch to menu
|
|
view_dispatcher_switch_to_view(app->view_dispatcher, 0);
|
|
|
|
return app;
|
|
}
|
|
|
|
void usb_test_app_free(UsbTestApp* app) {
|
|
furi_assert(app);
|
|
|
|
// Free views
|
|
view_dispatcher_remove_view(app->view_dispatcher, 0);
|
|
submenu_free(app->submenu);
|
|
view_dispatcher_free(app->view_dispatcher);
|
|
|
|
// Close gui record
|
|
furi_record_close("gui");
|
|
app->gui = NULL;
|
|
|
|
// Free rest
|
|
free(app);
|
|
}
|
|
|
|
int32_t usb_test_app(void* p) {
|
|
UsbTestApp* app = usb_test_app_alloc();
|
|
|
|
view_dispatcher_run(app->view_dispatcher);
|
|
|
|
usb_test_app_free(app);
|
|
return 0;
|
|
}
|