Willy-JL hai 1 ano
pai
achega
18ef160397

+ 1 - 0
bt_trigger/.gitsubtree

@@ -1 +1,2 @@
+https://github.com/xMasterX/all-the-plugins dev apps_source_code/bluetooth-trigger
 https://github.com/Nem0oo/flipper-zero-bluetooth-trigger main /

+ 11 - 0
bt_trigger/README-catalog.md

@@ -0,0 +1,11 @@
+With the BT Trigger app, you can remotely take pictures with the help of your Flipper Zero via Bluetooth Low Energy.
+
+To take a picture remotely, do as follows:
+
+1. Run the BT Trigger app and connect to your smartphone. Your Flipper Zero will be displayed as Control (device name) in Bluetooth settings.
+2. Run the Camera app on your smartphone.
+3. To take one picture, press the Right button.
+
+
+You can take multiple pictures by pressing the Ok button. You can also set the delay between shots by pressing the Up and Down buttons. The number of photos taken is displayed in the app. To reset the shot count, press the Left button.
+

+ 15 - 2
bt_trigger/README.md

@@ -1,2 +1,15 @@
-# flipper-zero_ios-bluetooth-trigger
-A Bluetooth trigger / intervalometer for the flipper zero
+# BT Trigger
+
+Control your smartphone camera via your Flipper Zero
+
+With the BT Trigger app, you can remotely take pictures with the help of your Flipper Zero via Bluetooth Low Energy.
+
+To take a picture remotely, do as follows:
+
+1. Run the BT Trigger app and connect to your smartphone. Your Flipper Zero will be displayed as Control <device name> in Bluetooth settings.
+2. Run the Camera app on your smartphone.
+3. To take one picture, press the Right button.
+
+
+You can take multiple pictures by pressing the Ok button. You can also set the delay between shots by pressing the Up and Down buttons. The number of photos taken is displayed in the app. To reset the shot count, press the Left button.
+

+ 9 - 7
bt_trigger/application.fam

@@ -1,14 +1,16 @@
 App(
     appid="bt_trigger",
     apptype=FlipperAppType.EXTERNAL,
-    name="BT trigger",
+    name="BT Trigger",
     entry_point="bt_trigger_app",
     cdefines=["APP_BT_TRIGGER"],
-    requires=[
-        "gui"
-    ],
+    requires=["gui"],
     stack_size=1 * 1024,
-	fap_icon="bt_trigger_logo.png",
-    fap_category="Misc",
-    fap_icon_assets="assets"
+    fap_icon="bt_trigger_logo.png",
+    fap_category="Bluetooth",
+    fap_icon_assets="assets",
+    fap_author="@Nem0oo",
+    fap_weburl="https://github.com/Nem0oo/flipper-zero-bluetooth-trigger",
+    fap_version="1.2",
+    fap_description="Control your smartphone camera via your Flipper Zero",
 )

+ 85 - 83
bt_trigger/bt_trigger.c

@@ -1,14 +1,14 @@
 #include "bt_trigger.h"
 
-__int32_t bt_trigger_app(void *p){
-    //Fake using p to compile 
+__int32_t bt_trigger_app(void* p) {
+    //Fake using p to compile
     UNUSED(p);
     AppStruct* app = appStructAlloc();
 
-    bt_disconnect(app->bt);
+    //bt_disconnect(app->bt);
 
     // Wait 2nd core to update nvm storage
-    furi_delay_ms(200);
+    //furi_delay_ms(200);
 
     bt_keys_storage_set_storage_path(app->bt, HID_BT_KEYS_STORAGE_PATH);
 
@@ -19,11 +19,11 @@ __int32_t bt_trigger_app(void *p){
     furi_hal_bt_start_advertising();
     bt_set_status_changed_callback(app->bt, bt_hid_connection_status_changed_callback, app);
 
-    DOLPHIN_DEED(DolphinDeedPluginStart);
+    dolphin_deed(DolphinDeedPluginStart);
 
     //An event
     IosTriggerEvent event;
-    //List of 8 events 
+    //List of 8 events
     FuriMessageQueue* event_queue = furi_message_queue_alloc(8, sizeof(IosTriggerEvent));
     //A timer
     FuriTimer* timer = furi_timer_alloc(timer_callback, FuriTimerTypePeriodic, event_queue);
@@ -32,86 +32,88 @@ __int32_t bt_trigger_app(void *p){
     view_port_draw_callback_set(app->view_port, draw_callback, app);
     //Callback for the inputs passing the list as param
     view_port_input_callback_set(app->view_port, input_callback, event_queue);
-    
+
     //Linking the drawin on the display
     gui_add_view_port(app->gui, app->view_port, GuiLayerFullscreen);
 
     //Main loop
-    while(app->running){
+    while(app->running) {
         //Geting new event from the envent list in the event variable
         //waiting forever if the list is empty
         //checking status as ok
         furi_check(furi_message_queue_get(event_queue, &event, FuriWaitForever) == FuriStatusOk);
 
         //Dealing with events one by one
-        switch(event.type){
-            case(EventTypeInput):
-               //On ne considère que les appuies courts
-               if(event.input.type == InputTypeShort) {
-                    switch(event.input.key){
-                        case(InputKeyBack):
-                            //Breaking main loop if the back key is pressed
-                            app->shooting = false;
-                            app->running = false;
-                            break;
-                        case(InputKeyOk): //Take a shot and start intervalometer
-                            if(app->delay > 0){
-                                app->shooting = !app->shooting;
-                                if(app->shooting){
-                                    furi_hal_bt_hid_consumer_key_press(HID_CONSUMER_VOLUME_INCREMENT);
-                                    furi_hal_bt_hid_consumer_key_release(HID_CONSUMER_VOLUME_INCREMENT);
-                                    notification_message(app->notifications, &sequence_blink_blue_100);
-                                    app->shots++;
-                                    //Timer triggered every delay ms    
-                                    furi_timer_start(timer, app->delay * 1000);
-                                }else{
-                                    //Timer triggered every delay ms    
-                                    furi_timer_stop(timer);
-                                }
-                            }
-                            break;
-                        case(InputKeyUp): //Increase delay
-                            if(!app->shooting){
-                                app->delay++;
-                            }
-                            break;
-                        case(InputKeyDown): //Decrease delay
-                            if(!app->shooting && app->delay > 1){
-                                app->delay--;
-                            }
-                            break;
-                        case(InputKeyLeft): //Reset shots counter
-                            if(!app->shooting){
-                                app->shots = 0;
-                            }
-                            break;
-                        case(InputKeyRight): //Take a shot
-                            if(!app->shooting){
-                                furi_hal_bt_hid_consumer_key_press(HID_CONSUMER_VOLUME_INCREMENT);
-                                furi_hal_bt_hid_consumer_key_release(HID_CONSUMER_VOLUME_INCREMENT);
-                                notification_message(app->notifications, &sequence_blink_blue_100);
-                                app->shots++;
-                            }
-                            break;
-                        default:
-                            break;
+        switch(event.type) {
+        case(EventTypeInput):
+            //On ne considère que les appuies courts
+            if(event.input.type == InputTypeShort) {
+                switch(event.input.key) {
+                case(InputKeyBack):
+                    //Breaking main loop if the back key is pressed
+                    app->shooting = false;
+                    app->running = false;
+                    break;
+                case(InputKeyOk): //Take a shot and start intervalometer
+                    if(app->delay > 0) {
+                        app->shooting = !app->shooting;
+                        if(app->shooting) {
+                            furi_hal_bt_hid_consumer_key_press(HID_CONSUMER_VOLUME_INCREMENT);
+                            furi_hal_bt_hid_consumer_key_release(HID_CONSUMER_VOLUME_INCREMENT);
+                            notification_message(app->notifications, &sequence_blink_blue_100);
+                            app->shots++;
+                            //Timer triggered every delay ms
+                            furi_timer_start(timer, app->delay * 1000);
+                        } else {
+                            //Timer triggered every delay ms
+                            furi_timer_stop(timer);
+                        }
+                    }
+                    break;
+                case(InputKeyUp): //Increase delay
+                    if(!app->shooting) {
+                        app->delay++;
+                    }
+                    break;
+                case(InputKeyDown): //Decrease delay
+                    if(!app->shooting && app->delay > 1) {
+                        app->delay--;
                     }
-               }
-                break;
-            case(EventTypeTick):
-                if(app->shooting){
-                    //sending command to trigger via BT
-                    furi_hal_bt_hid_consumer_key_press(HID_CONSUMER_VOLUME_INCREMENT);
-                    furi_hal_bt_hid_consumer_key_release(HID_CONSUMER_VOLUME_INCREMENT);
-                    notification_message(app->notifications, &sequence_blink_blue_100);
-                    app->shots++;
+                    break;
+                case(InputKeyLeft): //Reset shots counter
+                    if(!app->shooting) {
+                        app->shots = 0;
+                    }
+                    break;
+                case(InputKeyRight): //Take a shot
+                    if(!app->shooting) {
+                        furi_hal_bt_hid_consumer_key_press(HID_CONSUMER_VOLUME_INCREMENT);
+                        furi_hal_bt_hid_consumer_key_release(HID_CONSUMER_VOLUME_INCREMENT);
+                        notification_message(app->notifications, &sequence_blink_blue_100);
+                        app->shots++;
+                    }
+                    break;
+                default:
+                    break;
                 }
-                break;
-            default:
-                break;
+            }
+            view_port_update(app->view_port);
+            break;
+        case(EventTypeTick):
+            if(app->shooting) {
+                //sending command to trigger via BT
+                furi_hal_bt_hid_consumer_key_press(HID_CONSUMER_VOLUME_INCREMENT);
+                furi_hal_bt_hid_consumer_key_release(HID_CONSUMER_VOLUME_INCREMENT);
+                notification_message(app->notifications, &sequence_blink_blue_100);
+                app->shots++;
+            }
+            view_port_update(app->view_port);
+            break;
+        default:
+            break;
         }
     }
-    
+
     //Going back to serial mode BT
     bt_set_status_changed_callback(app->bt, NULL, NULL);
     bt_disconnect(app->bt);
@@ -137,16 +139,15 @@ static void draw_callback(Canvas* canvas, void* ctx) {
     char chaine_photo[36];
     char chaine_delais[36];
     char chaine_shooting[36];
-    
+
     snprintf(chaine_photo, sizeof(chaine_photo), "%i shots", app->shots);
     snprintf(chaine_delais, sizeof(chaine_delais), "%i", app->delay);
-    if(app->shooting){
+    if(app->shooting) {
         snprintf(chaine_shooting, sizeof(chaine_shooting), "Press to stop");
-    }else {
+    } else {
         snprintf(chaine_shooting, sizeof(chaine_shooting), "Press to start");
     }
-    
-    
+
     canvas_clear(canvas);
     canvas_draw_frame(canvas, 0, 0, 128, 64);
     canvas_set_font(canvas, FontPrimary);
@@ -154,7 +155,7 @@ static void draw_callback(Canvas* canvas, void* ctx) {
     //Represent
     canvas_set_font(canvas, FontSecondary);
     canvas_draw_str(canvas, 92, 62, "Nem0oo");
-    if(app->connected){
+    if(app->connected) {
         canvas_draw_icon(canvas, 111, 2, &I_Ble_connected_15x15);
 
         canvas_set_font(canvas, FontSecondary);
@@ -174,8 +175,8 @@ static void draw_callback(Canvas* canvas, void* ctx) {
         canvas_draw_str(canvas, 13, 52, "Reset shot count");
         //Shots number line
         canvas_draw_icon(canvas, 2, 53, &I_dir_10px);
-        canvas_draw_str(canvas, 14, 62, chaine_photo);     
-    }else{
+        canvas_draw_str(canvas, 14, 62, chaine_photo);
+    } else {
         canvas_draw_icon(canvas, 111, 2, &I_Ble_disconnected_15x15);
         canvas_draw_icon(canvas, 1, 21, &I_WarningDolphin_45x42);
         canvas_set_font(canvas, FontSecondary);
@@ -190,7 +191,7 @@ static void input_callback(InputEvent* input_event, void* ctx) {
     FuriMessageQueue* event_queue = ctx;
 
     //Adding the event to our custom Struct
-    IosTriggerEvent event = {.type = EventTypeInput, .input = *input_event}; 
+    IosTriggerEvent event = {.type = EventTypeInput, .input = *input_event};
 
     //Adding our event to the event queue
     furi_message_queue_put(event_queue, &event, FuriWaitForever);
@@ -209,9 +210,10 @@ static void bt_hid_connection_status_changed_callback(BtStatus status, void* con
     furi_assert(context);
     AppStruct* app = context;
     app->connected = (status == BtStatusConnected);
+    view_port_update(app->view_port);
 }
 
-AppStruct* appStructAlloc(){
+AppStruct* appStructAlloc() {
     AppStruct* app = malloc(sizeof(AppStruct));
     //Init bluetooth
     app->bt = furi_record_open(RECORD_BT);
@@ -227,7 +229,7 @@ AppStruct* appStructAlloc(){
     return app;
 }
 
-void cleanUpBeforeYouLeave(AppStruct* app){
+void cleanUpBeforeYouLeave(AppStruct* app) {
     furi_assert(app);
     //Freeing notifications
     furi_record_close(RECORD_NOTIFICATION);

+ 7 - 10
bt_trigger/bt_trigger.h

@@ -13,20 +13,19 @@
 #include <gui/modules/dialog_ex.h>
 #include <gui/modules/popup.h>
 #include <dolphin/dolphin.h>
-#include <assets_icons.h>
-//#include "ios_trigger_icons.h"
+#include "bt_trigger_icons.h"
 
-#define HID_BT_KEYS_STORAGE_PATH EXT_PATH("apps_data/bt_trigger/hid.keys")
+#define HID_BT_KEYS_STORAGE_PATH EXT_PATH("apps_data/hid_ble/.bt_hid.keys")
 #define TAG "bt_trigger"
 
-//Enum of allowed event types
-typedef enum{
+// Enum of allowed event types
+typedef enum {
     EventTypeTick,
     EventTypeInput,
-    
+
 } EventType;
 
-//Struct to store an event and its type
+// Struct to store an event and its type
 typedef struct {
     EventType type;
     InputEvent input;
@@ -41,11 +40,9 @@ typedef struct {
     bool running;
     bool shooting;
     int shots;
-    int delay;//in ms
+    int delay; // in ms
 } AppStruct;
 
-
-
 static void draw_callback(Canvas* canvas, void* ctx);
 static void input_callback(InputEvent* input_event, void* ctx);
 static void timer_callback(FuriMessageQueue* event_queue);

BIN=BIN
bt_trigger/img/1.png


BIN=BIN
bt_trigger/img/2.png