Procházet zdrojové kódy

Enabled GPIO support for IR boards

David Lee před 11 měsíci
rodič
revize
f59526e476
8 změnil soubory, kde provedl 46 přidání a 10 odebrání
  1. 2 0
      README.md
  2. 1 1
      application.fam
  3. 1 0
      docs/README.md
  4. 3 0
      docs/changelog.md
  5. 3 5
      scenes/xremote_scene_settings.c
  6. 32 2
      xremote.c
  7. 3 1
      xremote.h
  8. 1 1
      xremote_i.h

+ 2 - 0
README.md

@@ -36,6 +36,8 @@ Wouldn't it be nicer to simply click one button and let everything happen? This
 - Save settings, stores a file with your settings in it on exit
 - IR time ms, the default duration of an IR signal transmission. Individual times can be set
 - SubG. time ms, the default duration of a SubGhz signal. Only needed for Encoded signals, RAW files play until finished
+- Loop transmip, repeats the command chain until cancelled
+- External IR & 5V on GPIO, settings for external IR boards
 
 ### Limitations
 SubGhz commands will stop working if you move/rename/delete the original files on your Flipper. This is because of how the Flippers SubGhz worker expects data. 

+ 1 - 1
application.fam

@@ -6,7 +6,7 @@ App(
     stack_size=3 * 1024,
     fap_icon="icons/xremote_10px.png",
     fap_icon_assets="icons",
-    fap_version="3.1",
+    fap_version="3.2",
     fap_category="Infrared",
     fap_author="Leedave",
     fap_description="One-Click, sends multiple commands",

+ 1 - 0
docs/README.md

@@ -4,6 +4,7 @@ This app combines your IR and SubGhz commands into a playlist that can be run wi
 
 ## Features
 - Read out commands you recorded in the IR app
+- Supports external GPIO Boards like IR Blaster or Masta-Blasta
 - Read out commands you saved as .sub files
 - Combine commands to a chain/playlist 
 - Add pauses inbetween commands 

+ 3 - 0
docs/changelog.md

@@ -1,3 +1,6 @@
+## 3.2
+- Added support for external IR GPIO boards, tested on IR Blaster & Masta-Blasta. 
+
 ## 3.1
 - Bugfix to enable save on first use (thanks to WillyJL)
 - Bugfix for loop transmit when using RAW SubGHz transmissions

+ 3 - 5
scenes/xremote_scene_settings.c

@@ -185,18 +185,16 @@ void xremote_scene_settings_on_enter(void* context) {
 
 bool xremote_scene_settings_on_event(void* context, SceneManagerEvent event) {
     XRemote* app = context;
-    UNUSED(app);
     bool consumed = false;
     if(event.type == SceneManagerEventTypeCustom) {
         const uint16_t custom_event_type = xremote_custom_menu_event_get_type(event.event);
-        const uint16_t custom_event_value = xremote_custom_menu_event_get_value(event.event);
-
-        UNUSED(custom_event_value);
+        
         if (custom_event_type == XRemoteCustomEventTypeIrGpioPinChanged) {
             variable_item_list_reset(app->variable_item_list);
             xremote_scene_settings_init(app);
+            xremote_ir_set_tx_pin(app);
         } else if(custom_event_type == XRemoteCustomEventTypeIrGpioOtgChanged) {
-
+            xremote_ir_enable_otg(app, app->ir_is_otg_enabled);
         }
     }
     return consumed;

+ 32 - 2
xremote.c

@@ -191,10 +191,38 @@ void xremote_text_input_callback(void* context) {
     view_dispatcher_send_custom_event(app->view_dispatcher, XRemoteCustomEventTextInput);
 }
 
+void xremote_ir_enable_otg(XRemote* app, bool enable) {
+    if(enable) {
+        furi_hal_power_enable_otg();
+    } else {
+        furi_hal_power_disable_otg();
+    }
+    app->ir_is_otg_enabled = enable;
+}
+
+void xremote_ir_set_tx_pin(XRemote* app) {
+    if(app->ir_tx_pin < FuriHalInfraredTxPinMax) {
+        furi_hal_infrared_set_tx_output(app->ir_tx_pin);
+    } else {
+        FuriHalInfraredTxPin tx_pin_detected = furi_hal_infrared_detect_tx_output();
+        furi_hal_infrared_set_tx_output(tx_pin_detected);
+        if(tx_pin_detected != FuriHalInfraredTxPinInternal) {
+            xremote_ir_enable_otg(app, true);
+        }
+    }
+}
+
+static void xremote_ir_load_settings(XRemote* app) {
+    xremote_ir_set_tx_pin(app);
+    if(app->ir_tx_pin < FuriHalInfraredTxPinMax) {
+        xremote_ir_enable_otg(app, app->ir_is_otg_enabled);
+    }
+}
+
 int32_t xremote_app(void* p) {
     UNUSED(p);
     XRemote* app = xremote_app_alloc();
-
+    
     view_dispatcher_attach_to_gui(app->view_dispatcher, app->gui, ViewDispatcherTypeFullscreen);
 
     //scene_manager_next_scene(app->scene_manager, XRemoteSceneInfoscreen); //Start with start screen
@@ -202,6 +230,8 @@ int32_t xremote_app(void* p) {
         app->scene_manager, XRemoteSceneMenu); //if you want to directly start with Menu
 
     furi_hal_power_suppress_charge_enter();
+    xremote_ir_load_settings(app);
+
 
     Storage* storage = furi_record_open(RECORD_STORAGE);
     storage_common_mkdir(storage, XREMOTE_APP_FOLDER);
@@ -210,8 +240,8 @@ int32_t xremote_app(void* p) {
     view_dispatcher_run(app->view_dispatcher);
 
     xremote_save_settings(app);
-
     furi_hal_power_suppress_charge_exit();
+    xremote_ir_enable_otg(app, false);
     xremote_app_free(app);
 
     return 0;

+ 3 - 1
xremote.h

@@ -100,4 +100,6 @@ typedef enum {
 } XRemoteSettingsStoreState;
 
 void xremote_popup_closed_callback(void* context);
-void xremote_text_input_callback(void* context);
+void xremote_text_input_callback(void* context);
+void xremote_ir_enable_otg(XRemote* app, bool enable);
+void xremote_ir_set_tx_pin(XRemote* app);

+ 1 - 1
xremote_i.h

@@ -51,7 +51,7 @@
 #define XREMOTE_TEXT_STORE_SIZE 128
 #define XREMOTE_MAX_ITEM_NAME_LENGTH 22
 #define XREMOTE_MAX_REMOTE_NAME_LENGTH 22
-#define XREMOTE_VERSION "3.1"
+#define XREMOTE_VERSION "3.2"
 
 #define INFRARED_APP_EXTENSION ".ir"
 #define INFRARED_APP_FOLDER EXT_PATH("infrared")