Ferrazzi 3 лет назад
Родитель
Сommit
76f814a35d

+ 3 - 3
FlipperZero-IFTTT_app/application.fam

@@ -1,6 +1,6 @@
 App(
 App(
-    appid="ifttt_virtual_button",
-    name="IFTTT Virtual Button",
+    appid="ESP8266_IFTTT_Virtual_Button",
+    name="[ESP] IFTTT Virtual Button",
     apptype=FlipperAppType.EXTERNAL,
     apptype=FlipperAppType.EXTERNAL,
     entry_point="ifttt_virtual_button_app",
     entry_point="ifttt_virtual_button_app",
     cdefines=["APP_IFTTT_VIRTUAL_BUTTON"],
     cdefines=["APP_IFTTT_VIRTUAL_BUTTON"],
@@ -11,4 +11,4 @@ App(
     order=20,
     order=20,
     fap_icon="icon.png",
     fap_icon="icon.png",
     fap_category="GPIO",
     fap_category="GPIO",
-)
+)

+ 2 - 6
FlipperZero-IFTTT_app/ifttt_virtual_button.c

@@ -41,9 +41,7 @@ VirtualButtonApp* ifttt_virtual_button_app_alloc(uint32_t first_scene) {
     // Views
     // Views
     app->sen_view = send_view_alloc();
     app->sen_view = send_view_alloc();
     view_dispatcher_add_view(
     view_dispatcher_add_view(
-        app->view_dispatcher,
-        VirtualButtonAppViewSendView,
-        send_view_get_view(app->sen_view));
+        app->view_dispatcher, VirtualButtonAppViewSendView, send_view_get_view(app->sen_view));
 
 
     app->modul_view = module_view_alloc();
     app->modul_view = module_view_alloc();
     view_dispatcher_add_view(
     view_dispatcher_add_view(
@@ -59,9 +57,7 @@ VirtualButtonApp* ifttt_virtual_button_app_alloc(uint32_t first_scene) {
 
 
     app->rese_view = reset_view_alloc();
     app->rese_view = reset_view_alloc();
     view_dispatcher_add_view(
     view_dispatcher_add_view(
-        app->view_dispatcher,
-        VirtualButtonAppViewResetView,
-        reset_view_get_view(app->rese_view));
+        app->view_dispatcher, VirtualButtonAppViewResetView, reset_view_get_view(app->rese_view));
 
 
     app->submenu = submenu_alloc();
     app->submenu = submenu_alloc();
     view_dispatcher_add_view(
     view_dispatcher_add_view(

+ 3 - 3
FlipperZero-IFTTT_app/scenes/virtual_button_scene_start.c

@@ -54,11 +54,11 @@ bool virtual_button_scene_start_on_event(void* context, SceneManagerEvent event)
     if(event.type == SceneManagerEventTypeCustom) {
     if(event.type == SceneManagerEventTypeCustom) {
         if(event.event == VirtualButtonSubmenuIndexSendView) {
         if(event.event == VirtualButtonSubmenuIndexSendView) {
             scene_manager_next_scene(app->scene_manager, VirtualButtonAppSceneSendView);
             scene_manager_next_scene(app->scene_manager, VirtualButtonAppSceneSendView);
-        }else if(event.event == VirtualButtonSubmenuIndexModuleView) {
+        } else if(event.event == VirtualButtonSubmenuIndexModuleView) {
             scene_manager_next_scene(app->scene_manager, VirtualButtonAppSceneModuleView);
             scene_manager_next_scene(app->scene_manager, VirtualButtonAppSceneModuleView);
-        }else if(event.event == VirtualButtonSubmenuIndexRebootView) {
+        } else if(event.event == VirtualButtonSubmenuIndexRebootView) {
             scene_manager_next_scene(app->scene_manager, VirtualButtonAppSceneRebootView);
             scene_manager_next_scene(app->scene_manager, VirtualButtonAppSceneRebootView);
-        }else if(event.event == VirtualButtonSubmenuIndexResetView) {
+        } else if(event.event == VirtualButtonSubmenuIndexResetView) {
             scene_manager_next_scene(app->scene_manager, VirtualButtonAppSceneResetView);
             scene_manager_next_scene(app->scene_manager, VirtualButtonAppSceneResetView);
         }
         }
         scene_manager_set_scene_state(app->scene_manager, VirtualButtonAppSceneStart, event.event);
         scene_manager_set_scene_state(app->scene_manager, VirtualButtonAppSceneStart, event.event);

+ 21 - 28
FlipperZero-IFTTT_app/views/module_view.c

@@ -11,11 +11,7 @@
 
 
 bool configState;
 bool configState;
 
 
-typedef enum ESerialCommand
-{
-    ESerialCommand_Config_On,
-    ESerialCommand_Config_Off
-} ESerialCommand;
+typedef enum ESerialCommand { ESerialCommand_Config_On, ESerialCommand_Config_Off } ESerialCommand;
 
 
 struct ModuleView {
 struct ModuleView {
     View* view;
     View* view;
@@ -34,20 +30,18 @@ static void Shake(void) {
 }
 }
 */
 */
 
 
-void send_serial_command_module(ESerialCommand command)
-{
-    uint8_t data[1] = { 0 };
-
-    switch(command)
-    {
-        case ESerialCommand_Config_On:
-            data[0] = MODULE_CONTROL_COMMAND_CONFIG_ON;
-            break;
-        case ESerialCommand_Config_Off:
-            data[0] = MODULE_CONTROL_COMMAND_CONFIG_OFF;
-            break;
-        default:
-            return;          
+void send_serial_command_module(ESerialCommand command) {
+    uint8_t data[1] = {0};
+
+    switch(command) {
+    case ESerialCommand_Config_On:
+        data[0] = MODULE_CONTROL_COMMAND_CONFIG_ON;
+        break;
+    case ESerialCommand_Config_Off:
+        data[0] = MODULE_CONTROL_COMMAND_CONFIG_OFF;
+        break;
+    default:
+        return;
     };
     };
 
 
     furi_hal_uart_tx(FuriHalUartIdUSART1, data, 1);
     furi_hal_uart_tx(FuriHalUartIdUSART1, data, 1);
@@ -66,10 +60,10 @@ static void module_view_draw_callback(Canvas* canvas, void* context) {
     canvas_draw_str_aligned(canvas, 64, 45, AlignCenter, AlignTop, "and hold back to return");
     canvas_draw_str_aligned(canvas, 64, 45, AlignCenter, AlignTop, "and hold back to return");
     canvas_draw_str_aligned(canvas, 64, 55, AlignCenter, AlignTop, "to the menu");
     canvas_draw_str_aligned(canvas, 64, 55, AlignCenter, AlignTop, "to the menu");
 
 
-    if(configState == false){
+    if(configState == false) {
         send_serial_command_module(ESerialCommand_Config_On);
         send_serial_command_module(ESerialCommand_Config_On);
         configState = true;
         configState = true;
-    }   
+    }
 
 
     // Right
     // Right
     if(model->right_pressed) {
     if(model->right_pressed) {
@@ -78,7 +72,9 @@ static void module_view_draw_callback(Canvas* canvas, void* context) {
 
 
 static void module_view_process(ModuleView* module_view, InputEvent* event) {
 static void module_view_process(ModuleView* module_view, InputEvent* event) {
     with_view_model(
     with_view_model(
-        module_view->view, (ModuleViewModel * model) {
+        module_view->view,
+        ModuleViewModel * model,
+        {
             if(event->type == InputTypePress) {
             if(event->type == InputTypePress) {
                 if(event->key == InputKeyUp) {
                 if(event->key == InputKeyUp) {
                 } else if(event->key == InputKeyDown) {
                 } else if(event->key == InputKeyDown) {
@@ -101,8 +97,8 @@ static void module_view_process(ModuleView* module_view, InputEvent* event) {
                 if(event->key == InputKeyBack) {
                 if(event->key == InputKeyBack) {
                 }
                 }
             }
             }
-            return true;
-        });
+        },
+        true);
 }
 }
 
 
 static bool module_view_input_callback(InputEvent* event, void* context) {
 static bool module_view_input_callback(InputEvent* event, void* context) {
@@ -147,8 +143,5 @@ View* module_view_get_view(ModuleView* module_view) {
 void module_view_set_data(ModuleView* module_view, bool connected) {
 void module_view_set_data(ModuleView* module_view, bool connected) {
     furi_assert(module_view);
     furi_assert(module_view);
     with_view_model(
     with_view_model(
-        module_view->view, (ModuleViewModel * model) {
-            model->connected = connected;
-            return true;
-        });
+        module_view->view, ModuleViewModel * model, { model->connected = connected; }, true);
 }
 }

+ 16 - 22
FlipperZero-IFTTT_app/views/reboot_view.c

@@ -8,10 +8,7 @@
 #define MODULE_CONTROL_COMMAND_REBOOT 'r'
 #define MODULE_CONTROL_COMMAND_REBOOT 'r'
 #define FLIPPERZERO_SERIAL_BAUD 115200
 #define FLIPPERZERO_SERIAL_BAUD 115200
 
 
-typedef enum ESerialCommand
-{
-    ESerialCommand_Reboot
-} ESerialCommand;
+typedef enum ESerialCommand { ESerialCommand_Reboot } ESerialCommand;
 
 
 struct RebootView {
 struct RebootView {
     View* view;
     View* view;
@@ -28,17 +25,15 @@ static void Shake(void) {
     furi_record_close(RECORD_NOTIFICATION);
     furi_record_close(RECORD_NOTIFICATION);
 }
 }
 
 
-void send_serial_command_reboot(ESerialCommand command)
-{
-    uint8_t data[1] = { 0 };
-
-    switch(command)
-    {
-        case ESerialCommand_Reboot:
-            data[0] = MODULE_CONTROL_COMMAND_REBOOT;
-            break;
-        default:
-            return;          
+void send_serial_command_reboot(ESerialCommand command) {
+    uint8_t data[1] = {0};
+
+    switch(command) {
+    case ESerialCommand_Reboot:
+        data[0] = MODULE_CONTROL_COMMAND_REBOOT;
+        break;
+    default:
+        return;
     };
     };
 
 
     furi_hal_uart_tx(FuriHalUartIdUSART1, data, 1);
     furi_hal_uart_tx(FuriHalUartIdUSART1, data, 1);
@@ -62,7 +57,9 @@ static void reboot_view_draw_callback(Canvas* canvas, void* context) {
 
 
 static void reboot_view_process(RebootView* reboot_view, InputEvent* event) {
 static void reboot_view_process(RebootView* reboot_view, InputEvent* event) {
     with_view_model(
     with_view_model(
-        reboot_view->view, (RebootViewModel * model) {
+        reboot_view->view,
+        RebootViewModel * model,
+        {
             if(event->type == InputTypePress) {
             if(event->type == InputTypePress) {
                 if(event->key == InputKeyUp) {
                 if(event->key == InputKeyUp) {
                 } else if(event->key == InputKeyDown) {
                 } else if(event->key == InputKeyDown) {
@@ -87,8 +84,8 @@ static void reboot_view_process(RebootView* reboot_view, InputEvent* event) {
                 if(event->key == InputKeyBack) {
                 if(event->key == InputKeyBack) {
                 }
                 }
             }
             }
-            return true;
-        });
+        },
+        true);
 }
 }
 
 
 static bool reboot_view_input_callback(InputEvent* event, void* context) {
 static bool reboot_view_input_callback(InputEvent* event, void* context) {
@@ -131,8 +128,5 @@ View* reboot_view_get_view(RebootView* reboot_view) {
 void reboot_view_set_data(RebootView* reboot_view, bool connected) {
 void reboot_view_set_data(RebootView* reboot_view, bool connected) {
     furi_assert(reboot_view);
     furi_assert(reboot_view);
     with_view_model(
     with_view_model(
-        reboot_view->view, (RebootViewModel * model) {
-            model->connected = connected;
-            return true;
-        });
+        reboot_view->view, RebootViewModel * model, { model->connected = connected; }, true);
 }
 }

+ 16 - 22
FlipperZero-IFTTT_app/views/reset_view.c

@@ -8,10 +8,7 @@
 #define MODULE_CONTROL_COMMAND_RESET 'a'
 #define MODULE_CONTROL_COMMAND_RESET 'a'
 #define FLIPPERZERO_SERIAL_BAUD 115200
 #define FLIPPERZERO_SERIAL_BAUD 115200
 
 
-typedef enum ESerialCommand
-{
-    ESerialCommand_Reset
-} ESerialCommand;
+typedef enum ESerialCommand { ESerialCommand_Reset } ESerialCommand;
 
 
 struct ResetView {
 struct ResetView {
     View* view;
     View* view;
@@ -28,17 +25,15 @@ static void Shake(void) {
     furi_record_close(RECORD_NOTIFICATION);
     furi_record_close(RECORD_NOTIFICATION);
 }
 }
 
 
-void send_serial_command_reset(ESerialCommand command)
-{
-    uint8_t data[1] = { 0 };
-
-    switch(command)
-    {
-        case ESerialCommand_Reset:
-            data[0] = MODULE_CONTROL_COMMAND_RESET;
-            break;
-        default:
-            return;          
+void send_serial_command_reset(ESerialCommand command) {
+    uint8_t data[1] = {0};
+
+    switch(command) {
+    case ESerialCommand_Reset:
+        data[0] = MODULE_CONTROL_COMMAND_RESET;
+        break;
+    default:
+        return;
     };
     };
 
 
     furi_hal_uart_tx(FuriHalUartIdUSART1, data, 1);
     furi_hal_uart_tx(FuriHalUartIdUSART1, data, 1);
@@ -62,7 +57,9 @@ static void reset_view_draw_callback(Canvas* canvas, void* context) {
 
 
 static void reset_view_process(ResetView* reset_view, InputEvent* event) {
 static void reset_view_process(ResetView* reset_view, InputEvent* event) {
     with_view_model(
     with_view_model(
-        reset_view->view, (ResetViewModel * model) {
+        reset_view->view,
+        ResetViewModel * model,
+        {
             if(event->type == InputTypePress) {
             if(event->type == InputTypePress) {
                 if(event->key == InputKeyUp) {
                 if(event->key == InputKeyUp) {
                 } else if(event->key == InputKeyDown) {
                 } else if(event->key == InputKeyDown) {
@@ -87,8 +84,8 @@ static void reset_view_process(ResetView* reset_view, InputEvent* event) {
                 if(event->key == InputKeyBack) {
                 if(event->key == InputKeyBack) {
                 }
                 }
             }
             }
-            return true;
-        });
+        },
+        true);
 }
 }
 
 
 static bool reset_view_input_callback(InputEvent* event, void* context) {
 static bool reset_view_input_callback(InputEvent* event, void* context) {
@@ -131,8 +128,5 @@ View* reset_view_get_view(ResetView* reset_view) {
 void reset_view_set_data(ResetView* reset_view, bool connected) {
 void reset_view_set_data(ResetView* reset_view, bool connected) {
     furi_assert(reset_view);
     furi_assert(reset_view);
     with_view_model(
     with_view_model(
-        reset_view->view, (ResetViewModel * model) {
-            model->connected = connected;
-            return true;
-        });
+        reset_view->view, ResetViewModel * model, { model->connected = connected; }, true);
 }
 }

+ 16 - 22
FlipperZero-IFTTT_app/views/send_view.c

@@ -8,10 +8,7 @@
 #define MODULE_CONTROL_COMMAND_SEND 's'
 #define MODULE_CONTROL_COMMAND_SEND 's'
 #define FLIPPERZERO_SERIAL_BAUD 115200
 #define FLIPPERZERO_SERIAL_BAUD 115200
 
 
-typedef enum ESerialCommand
-{
-    ESerialCommand_Send
-} ESerialCommand;
+typedef enum ESerialCommand { ESerialCommand_Send } ESerialCommand;
 
 
 struct SendView {
 struct SendView {
     View* view;
     View* view;
@@ -28,17 +25,15 @@ static void Shake(void) {
     furi_record_close(RECORD_NOTIFICATION);
     furi_record_close(RECORD_NOTIFICATION);
 }
 }
 
 
-void send_serial_command_send(ESerialCommand command)
-{
-    uint8_t data[1] = { 0 };
-
-    switch(command)
-    {
-        case ESerialCommand_Send:
-            data[0] = MODULE_CONTROL_COMMAND_SEND;
-            break;
-        default:
-            return;          
+void send_serial_command_send(ESerialCommand command) {
+    uint8_t data[1] = {0};
+
+    switch(command) {
+    case ESerialCommand_Send:
+        data[0] = MODULE_CONTROL_COMMAND_SEND;
+        break;
+    default:
+        return;
     };
     };
 
 
     furi_hal_uart_tx(FuriHalUartIdUSART1, data, 1);
     furi_hal_uart_tx(FuriHalUartIdUSART1, data, 1);
@@ -62,7 +57,9 @@ static void send_view_draw_callback(Canvas* canvas, void* context) {
 
 
 static void send_view_process(SendView* send_view, InputEvent* event) {
 static void send_view_process(SendView* send_view, InputEvent* event) {
     with_view_model(
     with_view_model(
-        send_view->view, (SendViewModel * model) {
+        send_view->view,
+        SendViewModel * model,
+        {
             if(event->type == InputTypePress) {
             if(event->type == InputTypePress) {
                 if(event->key == InputKeyUp) {
                 if(event->key == InputKeyUp) {
                 } else if(event->key == InputKeyDown) {
                 } else if(event->key == InputKeyDown) {
@@ -87,8 +84,8 @@ static void send_view_process(SendView* send_view, InputEvent* event) {
                 if(event->key == InputKeyBack) {
                 if(event->key == InputKeyBack) {
                 }
                 }
             }
             }
-            return true;
-        });
+        },
+        true);
 }
 }
 
 
 static bool send_view_input_callback(InputEvent* event, void* context) {
 static bool send_view_input_callback(InputEvent* event, void* context) {
@@ -131,8 +128,5 @@ View* send_view_get_view(SendView* send_view) {
 void send_view_set_data(SendView* send_view, bool connected) {
 void send_view_set_data(SendView* send_view, bool connected) {
     furi_assert(send_view);
     furi_assert(send_view);
     with_view_model(
     with_view_model(
-        send_view->view, (SendViewModel * model) {
-            model->connected = connected;
-            return true;
-        });
+        send_view->view, SendViewModel * model, { model->connected = connected; }, true);
 }
 }