Procházet zdrojové kódy

add duration support for .ibtn in playlist

rdefeo před 1 rokem
rodič
revize
99287fd3d6
1 změnil soubory, kde provedl 14 přidání a 3 odebrání
  1. 14 3
      actions/action_qpl.c

+ 14 - 3
actions/action_qpl.c

@@ -30,9 +30,10 @@
 void action_qpl_tx(void* context, const FuriString* action_path, FuriString* error) {
     App* app = context;
 
-    // Save the current RFID and NFC Durations, in case the are changed during playback
+    // Save the current durations, in case the are changed during playback
     uint32_t orig_rfid_duration = app->settings.rfid_duration;
     uint32_t orig_nfc_duration = app->settings.nfc_duration;
+    uint32_t orig_ibutton_duration = app->settings.ibutton_duration;
 
     FuriString* buffer;
     buffer = furi_string_alloc();
@@ -84,7 +85,7 @@ void action_qpl_tx(void* context, const FuriString* action_path, FuriString* err
                     break;
                 }
 
-                // First token wasn't "pause", so maybe args_tmp is a .rfid filename followed
+                // First token wasn't "pause", so maybe args_tmp is a filename followed
                 // by a transmit duration in ms in buffer
                 // Note: Not using path_extract_extension since it expects to find slashes in the
                 // path, and thus won't work if we have a relative path file
@@ -109,6 +110,12 @@ void action_qpl_tx(void* context, const FuriString* action_path, FuriString* err
                         FURI_LOG_I(TAG, "NFC duration = %lu", nfc_duration);
                         app->settings.nfc_duration = nfc_duration;
                     }
+                } else if(!strcmp(ext, ".ibtn")) {
+                    uint32_t ibutton_duration = 0;
+                    if(sscanf(furi_string_get_cstr(buffer), "%lu", &ibutton_duration) == 1) {
+                        FURI_LOG_I(TAG, "iButton duration = %lu", ibutton_duration);
+                        app->settings.ibutton_duration = ibutton_duration;
+                    }
                 }
 
             } while(false);
@@ -145,6 +152,10 @@ void action_qpl_tx(void* context, const FuriString* action_path, FuriString* err
                 action_nfc_tx(context, buffer, error);
                 // Reset our default duration back - in case it was changed during playback
                 app->settings.nfc_duration = orig_nfc_duration;
+            } else if(!strcmp(ext, ".ibtn")) {
+                action_ibutton_tx(context, buffer, error);
+                // Reset our default duration back - in case it was changed during playback
+                app->settings.ibutton_duration = orig_ibutton_duration;
             } else if(!strcmp(ext, ".qpl")) {
                 ACTION_SET_ERROR("Playlist: Can't call playlist from playlist");
             } else {
@@ -170,4 +181,4 @@ void action_qpl_tx(void* context, const FuriString* action_path, FuriString* err
     furi_string_free(buffer);
     file_stream_close(file);
     stream_free(file);
-}
+}