Alex4386 1 год назад
Родитель
Сommit
c5b34ec5ac
10 измененных файлов с 11 добавлено и 249 удалено
  1. 4 4
      README.md
  2. 5 5
      application.fam
  3. BIN
      icon.png
  4. 0 76
      src/scenes/about/main.c
  5. 0 15
      src/scenes/about/main.h
  6. 0 125
      src/scenes/home/main.c
  7. 0 16
      src/scenes/home/main.h
  8. 0 2
      src/scenes/import.h
  9. 0 2
      src/scenes/list.h
  10. 2 4
      src/scenes/mtp/main.c

+ 4 - 4
README.md

@@ -10,14 +10,14 @@
 
 
 ## Build Status
 ## Build Status
 
 
-<!-- Replace the https://github.com/Alex4386/f0-template to your own repo after using template! -->
+<!-- Replace the https://github.com/Alex4386/f0-mtp to your own repo after using template! -->
 
 
-- **Latest Release**: [Download](https://github.com/Alex4386/f0-template/releases/latest)
-- **Latest Nightly**: [Download](https://github.com/Alex4386/f0-template/actions/workflows/nightly.yml) _(GitHub Login Required)_
+- **Latest Release**: [Download](https://github.com/Alex4386/f0-mtp/releases/latest)
+- **Latest Nightly**: [Download](https://github.com/Alex4386/f0-mtp/actions/workflows/nightly.yml) _(GitHub Login Required)_
 
 
 |                                           Nightly Build                                           |                                           Release Build                                           |
 |                                           Nightly Build                                           |                                           Release Build                                           |
 | :-----------------------------------------------------------------------------------------------: | :-----------------------------------------------------------------------------------------------: |
 | :-----------------------------------------------------------------------------------------------: | :-----------------------------------------------------------------------------------------------: |
-| ![Nightly Build](https://github.com/Alex4386/f0-template/actions/workflows/nightly.yml/badge.svg) | ![Release Build](https://github.com/Alex4386/f0-template/actions/workflows/release.yml/badge.svg) |
+| ![Nightly Build](https://github.com/Alex4386/f0-mtp/actions/workflows/nightly.yml/badge.svg) | ![Release Build](https://github.com/Alex4386/f0-mtp/actions/workflows/release.yml/badge.svg) |
 
 
 ## Setup Build environment
 ## Setup Build environment
 
 

+ 5 - 5
application.fam

@@ -2,8 +2,8 @@
 # https://developer.flipper.net/flipperzero/doxygen/app_manifests.html
 # https://developer.flipper.net/flipperzero/doxygen/app_manifests.html
 
 
 App(
 App(
-    appid="demo_app",  # Must be unique
-    name="Demo Application",  # Displayed in UI
+    appid="f0_mtp",  # Must be unique
+    name="MTP",  # Displayed in UI
     apptype=FlipperAppType.EXTERNAL,
     apptype=FlipperAppType.EXTERNAL,
     entry_point="entrypoint",
     entry_point="entrypoint",
     stack_size=2 * 1024, # size of memory stack it will allocate
     stack_size=2 * 1024, # size of memory stack it will allocate
@@ -21,12 +21,12 @@ App(
     ],
     ],
 
 
     # FAP Settings
     # FAP Settings
-    fap_category="Tools",
-    fap_description="A simple app for demonstration",
+    fap_category="USB",
+    fap_description="Use Flipper Zero as a MTP device.",
     fap_version="1.0",  # (major, minor)
     fap_version="1.0",  # (major, minor)
     fap_icon="icon.png",  # 10x10 1-bit PNG
     fap_icon="icon.png",  # 10x10 1-bit PNG
     fap_author="Alex4386",
     fap_author="Alex4386",
-    fap_weburl="https://github.com/Alex4386/f0-template",
+    fap_weburl="https://github.com/Alex4386/f0-mtp",
     fap_icon_assets="icons",  # Image assets to compile for this application
     fap_icon_assets="icons",  # Image assets to compile for this application
                               # available as {appid}_icons.h in the source code
                               # available as {appid}_icons.h in the source code
 )
 )


+ 0 - 76
src/scenes/about/main.c

@@ -1,76 +0,0 @@
-#include <gui/view.h>
-#include <gui/modules/submenu.h>
-#include "../../main.h"
-#include "main.h"
-#include <demo_app_icons.h>
-
-#define THIS_SCENE About
-
-void About_on_draw(Canvas* canvas, void* context);
-AppAbout* About_alloc() {
-    AppAbout* about = (AppAbout*)malloc(sizeof(AppAbout));
-    about->view = view_alloc();
-    view_set_draw_callback(about->view, About_on_draw);
-
-    return about;
-}
-
-void About_on_draw(Canvas* canvas, void* context) {
-    UNUSED(context);
-
-    canvas_clear(canvas);
-
-    canvas_set_bitmap_mode(canvas, true);
-    canvas_draw_icon(canvas, 2, 3, &I_DolphinWait);
-    canvas_set_font(canvas, FontPrimary);
-    canvas_draw_str(canvas, 67, 11, "f0-template");
-    canvas_set_font(canvas, FontSecondary);
-    canvas_draw_str(canvas, 72, 20, "by Alex4386");
-    canvas_draw_line(canvas, 68, 25, 124, 25);
-    canvas_draw_str(canvas, 71, 39, "Protected by");
-    canvas_set_font(canvas, FontPrimary);
-    canvas_draw_str(canvas, 61, 51, "Fantasy Seal");
-    canvas_draw_str(canvas, 69, 61, "Technology");
-}
-
-void About_free(void* ptr) {
-    AppAbout* home = (AppAbout*)ptr;
-    FURI_LOG_I("DemoApp", "Triggering Free for view");
-
-    view_free(home->view);
-    home->view = NULL;
-
-    free(home);
-}
-
-View* About_get_view(void* ptr) {
-    AppAbout* home = (AppAbout*)ptr;
-    return home->view;
-}
-
-void About_on_enter(void* context) {
-    App* app = (App*)context;
-
-    view_dispatcher_switch_to_view(app->view_dispatcher, THIS_SCENE);
-}
-
-bool About_on_event(void* context, SceneManagerEvent event) {
-    UNUSED(context);
-    UNUSED(event);
-
-    if(event.type == SceneManagerEventTypeBack) {
-        return false;
-    }
-
-    return true;
-}
-
-void About_on_exit(void* context) {
-    App* app = (App*)context;
-    if(app == NULL) {
-        return;
-    }
-
-    //if(app->view_dispatcher) view_dispatcher_switch_to_view(app->view_dispatcher, Home);
-    //if(app->scene_manager) scene_manager_previous_scene(app->scene_manager);
-}

+ 0 - 15
src/scenes/about/main.h

@@ -1,15 +0,0 @@
-#pragma once
-#include <gui/view.h>
-#include <gui/modules/submenu.h>
-
-typedef struct AppAbout {
-    View* view;
-    Canvas* canvas;
-} AppAbout;
-
-AppAbout* About_alloc();
-void About_free(void* ptr);
-View* About_get_view(void* ptr);
-void About_on_enter(void* context);
-bool About_on_event(void* context, SceneManagerEvent event);
-void About_on_exit(void* context);

+ 0 - 125
src/scenes/home/main.c

@@ -1,125 +0,0 @@
-#include <gui/view.h>
-#include <gui/modules/submenu.h>
-#include <gui/modules/popup.h>
-#include "../../main.h"
-#include "main.h"
-
-#define THIS_SCENE Home
-
-AppHome* Home_alloc() {
-    AppHome* home = (AppHome*)malloc(sizeof(AppHome));
-    home->menu = submenu_alloc();
-    home->view = NULL;
-
-    return home;
-}
-
-void Home_free(void* ptr) {
-    AppHome* home = (AppHome*)ptr;
-
-    FURI_LOG_I("DemoApp", "Freeing Home.");
-    if(home == NULL) {
-        FURI_LOG_I("DemoApp", "Home is NULL.");
-        return;
-    }
-
-    if(home->view != NULL) {
-        FURI_LOG_I("DemoApp", "Freeing View.");
-        view_free(home->view);
-        home->view = NULL;
-    }
-
-    // I don't know the reason why
-    // but this is causing NULL pointer exception
-
-    // if(home->menu != NULL) {
-    //     FURI_LOG_I("DemoApp", "Freeing Submenu.");
-    //     submenu_free(home->menu);
-    //     home->menu = NULL;
-    // }
-
-    free(home);
-    FURI_LOG_I("DemoApp", "Home freed.");
-}
-
-View* Home_get_view(void* ptr) {
-    AppHome* home = (AppHome*)ptr;
-
-    if(home->view == NULL) {
-        home->view = submenu_get_view(home->menu);
-        furi_assert(home->view != NULL, "View is NULL");
-    }
-
-    return home->view;
-}
-
-void Home_on_submenu_item(void* context, uint32_t index) {
-    App* app = (App*)context;
-    AppHome* home = app->allocated_scenes[THIS_SCENE];
-    furi_assert(home != NULL, "Home is NULL");
-
-    switch(index) {
-    case 0:
-        FURI_LOG_I("DemoApp", "Hello World");
-        break;
-    case 1:
-        FURI_LOG_I("DemoApp", "About");
-        scene_manager_next_scene(app->scene_manager, About);
-        break;
-    case 2:
-        FURI_LOG_I("DemoApp", "MTP");
-        scene_manager_next_scene(app->scene_manager, MTP);
-        break;
-    case 99:
-        FURI_LOG_I("DemoApp", "Exit");
-        Home_on_exit(app);
-        view_dispatcher_stop(app->view_dispatcher);
-        break;
-    default:
-        break;
-    }
-}
-
-void Home_on_enter(void* context) {
-    App* app = (App*)context;
-    AppHome* home = app->allocated_scenes[THIS_SCENE];
-
-    submenu_add_item(home->menu, "Hello World", 0, Home_on_submenu_item, app);
-    submenu_add_item(home->menu, "About", 1, Home_on_submenu_item, app);
-    submenu_add_item(home->menu, "MTP", 2, Home_on_submenu_item, app);
-    submenu_add_item(home->menu, "Exit", 99, Home_on_submenu_item, app);
-
-    view_dispatcher_switch_to_view(app->view_dispatcher, THIS_SCENE);
-}
-
-bool Home_on_event(void* context, SceneManagerEvent event) {
-    UNUSED(context);
-
-    if(event.type == SceneManagerEventTypeBack) {
-        return false;
-    }
-
-    return true;
-}
-
-void Home_on_exit(void* context) {
-    App* app = (App*)context;
-    // if the on_exit has been ran, the app will be NULL
-    if(app == NULL || app->allocated_scenes == NULL) {
-        return;
-    }
-
-    AppHome* home = app->allocated_scenes[THIS_SCENE];
-    if(home == NULL) {
-        return;
-    }
-
-    FURI_LOG_I("DemoApp", "Exiting Home.");
-
-    Submenu* menu = home->menu;
-    if(menu != NULL) {
-        submenu_reset(menu);
-    }
-
-    FURI_LOG_I("DemoApp", "Reset submenu complete.");
-}

+ 0 - 16
src/scenes/home/main.h

@@ -1,16 +0,0 @@
-#pragma once
-#include <gui/view.h>
-#include <gui/modules/submenu.h>
-#include <gui/modules/popup.h>
-
-typedef struct AppHome {
-    Submenu* menu;
-    View* view;
-} AppHome;
-
-AppHome* Home_alloc();
-void Home_free(void* ptr);
-View* Home_get_view(void* ptr);
-void Home_on_enter(void* context);
-bool Home_on_event(void* context, SceneManagerEvent event);
-void Home_on_exit(void* context);

+ 0 - 2
src/scenes/import.h

@@ -4,6 +4,4 @@
  * This is the file for importing scenes in this directory
  * This is the file for importing scenes in this directory
  */
  */
 
 
-#include "home/main.h"
-#include "about/main.h"
 #include "mtp/main.h"
 #include "mtp/main.h"

+ 0 - 2
src/scenes/list.h

@@ -12,6 +12,4 @@
  * 3. Include the scene in the list of scenes in main.h.
  * 3. Include the scene in the list of scenes in main.h.
  */
  */
 
 
-SCENE_ACTION(Home)
-SCENE_ACTION(About)
 SCENE_ACTION(MTP)
 SCENE_ACTION(MTP)

+ 2 - 4
src/scenes/mtp/main.c

@@ -2,7 +2,7 @@
 #include <gui/modules/submenu.h>
 #include <gui/modules/submenu.h>
 #include "../../main.h"
 #include "../../main.h"
 #include "main.h"
 #include "main.h"
-#include <demo_app_icons.h>
+#include <f0_mtp_icons.h>
 #include "usb.h"
 #include "usb.h"
 #include "usb_desc.h"
 #include "usb_desc.h"
 
 
@@ -42,11 +42,9 @@ void MTP_on_draw(Canvas* canvas, void* context) {
     if(usb_connected) {
     if(usb_connected) {
         canvas_set_bitmap_mode(canvas, true);
         canvas_set_bitmap_mode(canvas, true);
         canvas_draw_icon(canvas, 0, 14, &I_DFU);
         canvas_draw_icon(canvas, 0, 14, &I_DFU);
-        canvas_draw_icon(canvas, 2, 2, &I_Pin_back_arrow);
         canvas_set_font(canvas, FontPrimary);
         canvas_set_font(canvas, FontPrimary);
         canvas_draw_str(canvas, 43, 10, "MTP Connection");
         canvas_draw_str(canvas, 43, 10, "MTP Connection");
         canvas_set_font(canvas, FontSecondary);
         canvas_set_font(canvas, FontSecondary);
-        canvas_draw_str(canvas, 15, 10, "Back");
         canvas_draw_str(canvas, 3, 22, "Disconnect or");
         canvas_draw_str(canvas, 3, 22, "Disconnect or");
         canvas_draw_icon(canvas, 28, 23, &I_Pin_back_arrow);
         canvas_draw_icon(canvas, 28, 23, &I_Pin_back_arrow);
         canvas_draw_str(canvas, 3, 31, "Press");
         canvas_draw_str(canvas, 3, 31, "Press");
@@ -57,7 +55,7 @@ void MTP_on_draw(Canvas* canvas, void* context) {
         canvas_draw_str(canvas, 10, 25, "Plug me into computer!");
         canvas_draw_str(canvas, 10, 25, "Plug me into computer!");
         canvas_draw_icon(canvas, 2, 2, &I_Pin_back_arrow);
         canvas_draw_icon(canvas, 2, 2, &I_Pin_back_arrow);
         canvas_set_font(canvas, FontSecondary);
         canvas_set_font(canvas, FontSecondary);
-        canvas_draw_str(canvas, 15, 10, "Back");
+        canvas_draw_str(canvas, 15, 10, "Exit");
         canvas_draw_str(canvas, 61, 41, "Waiting for USB");
         canvas_draw_str(canvas, 61, 41, "Waiting for USB");
         canvas_draw_str(canvas, 72, 50, "Connection...");
         canvas_draw_str(canvas, 72, 50, "Connection...");
     }
     }