David Lee 1 год назад
Родитель
Сommit
a523e11e93

+ 4 - 2
models/cross/xremote_cross_remote.c

@@ -89,10 +89,11 @@ const char* xremote_cross_remote_get_name(CrossRemote* remote) {
     return furi_string_get_cstr(remote->name);
     return furi_string_get_cstr(remote->name);
 }
 }
 
 
-bool xremote_cross_remote_add_ir_item(CrossRemote* remote, const char* name, InfraredSignal* signal) {
+bool xremote_cross_remote_add_ir_item(CrossRemote* remote, const char* name, InfraredSignal* signal, uint32_t timing) {
     CrossRemoteItem* item = xremote_cross_remote_item_alloc();
     CrossRemoteItem* item = xremote_cross_remote_item_alloc();
     xremote_cross_remote_item_set_type(item, XRemoteRemoteItemTypeInfrared);
     xremote_cross_remote_item_set_type(item, XRemoteRemoteItemTypeInfrared);
     xremote_cross_remote_item_set_name(item, name);
     xremote_cross_remote_item_set_name(item, name);
+    xremote_cross_remote_item_set_time(item, timing);
     xremote_cross_remote_item_set_ir_signal(item, signal);
     xremote_cross_remote_item_set_ir_signal(item, signal);
     CrossRemoteItemArray_push_back(remote->items, item);
     CrossRemoteItemArray_push_back(remote->items, item);
     return true;
     return true;
@@ -208,7 +209,8 @@ static bool xremote_cross_remote_store(CrossRemote* remote) {
                 success = xremote_cross_remote_item_ir_signal_save(
                 success = xremote_cross_remote_item_ir_signal_save(
                     xremote_cross_remote_item_get_ir_signal(item),
                     xremote_cross_remote_item_get_ir_signal(item),
                     ff,
                     ff,
-                    xremote_cross_remote_item_get_name(item));
+                    xremote_cross_remote_item_get_name(item),
+                    xremote_cross_remote_item_get_time(item));
             } else if(item->type == XRemoteRemoteItemTypePause) {
             } else if(item->type == XRemoteRemoteItemTypePause) {
                 success = xremote_cross_remote_item_pause_save(ff, item->time, xremote_cross_remote_item_get_name(item));
                 success = xremote_cross_remote_item_pause_save(ff, item->time, xremote_cross_remote_item_get_name(item));
             } else if(item->type == XRemoteRemoteItemTypeSubGhz) {
             } else if(item->type == XRemoteRemoteItemTypeSubGhz) {

+ 1 - 1
models/cross/xremote_cross_remote.h

@@ -13,7 +13,7 @@ const char* xremote_cross_remote_get_name(CrossRemote* remote);
 void xremote_cross_remote_set_transmitting(CrossRemote* remote, int status);
 void xremote_cross_remote_set_transmitting(CrossRemote* remote, int status);
 int xremote_cross_remote_get_transmitting(CrossRemote* remote);
 int xremote_cross_remote_get_transmitting(CrossRemote* remote);
 bool xremote_cross_remote_add_pause(CrossRemote* remote, int time);
 bool xremote_cross_remote_add_pause(CrossRemote* remote, int time);
-bool xremote_cross_remote_add_ir_item(CrossRemote* remote, const char* name, InfraredSignal* signal);
+bool xremote_cross_remote_add_ir_item(CrossRemote* remote, const char* name, InfraredSignal* signal, uint32_t timing);
 bool xremote_cross_remote_add_subghz(CrossRemote* remote, SubGhzRemote* subghz);
 bool xremote_cross_remote_add_subghz(CrossRemote* remote, SubGhzRemote* subghz);
 void xremote_cross_remote_remove_item(CrossRemote* remote, size_t index);
 void xremote_cross_remote_remove_item(CrossRemote* remote, size_t index);
 void xremote_cross_remote_rename_item(CrossRemote* remote, size_t index, const char* name);
 void xremote_cross_remote_rename_item(CrossRemote* remote, size_t index, const char* name);

+ 7 - 2
models/cross/xremote_cross_remote_item.c

@@ -225,10 +225,15 @@ SubGhzRemote* xremote_cross_remote_item_get_sg_signal(CrossRemoteItem* item) {
     return item->sg_signal;
     return item->sg_signal;
 }
 }
 
 
-bool xremote_cross_remote_item_ir_signal_save(InfraredSignal* signal, FlipperFormat* ff, const char* name) {
+uint32_t xremote_cross_remote_item_get_time(CrossRemoteItem* item) {
+    return item->time;
+}
+
+bool xremote_cross_remote_item_ir_signal_save(InfraredSignal* signal, FlipperFormat* ff, const char* name, uint32_t time) {
     if(!flipper_format_write_comment_cstr(ff, "") ||
     if(!flipper_format_write_comment_cstr(ff, "") ||
        !flipper_format_write_string_cstr(ff, "remote_type", "IR") ||
        !flipper_format_write_string_cstr(ff, "remote_type", "IR") ||
-       !flipper_format_write_string_cstr(ff, "name", name)) {
+       !flipper_format_write_string_cstr(ff, "name", name) || 
+       !flipper_format_write_uint32(ff, "time", &time, 1)) {
         return false;
         return false;
     } else if(signal->is_raw) {
     } else if(signal->is_raw) {
         return xremote_ir_signal_save_raw(&signal->payload.raw, ff);
         return xremote_ir_signal_save_raw(&signal->payload.raw, ff);

+ 2 - 1
models/cross/xremote_cross_remote_item.h

@@ -14,6 +14,7 @@ const char* xremote_cross_remote_item_get_name(CrossRemoteItem* item);
 
 
 void xremote_cross_remote_item_set_type(CrossRemoteItem* item, int type);
 void xremote_cross_remote_item_set_type(CrossRemoteItem* item, int type);
 void xremote_cross_remote_item_set_time(CrossRemoteItem* item, int32_t time);
 void xremote_cross_remote_item_set_time(CrossRemoteItem* item, int32_t time);
+uint32_t xremote_cross_remote_item_get_time(CrossRemoteItem* item);
 
 
 InfraredSignal* xremote_cross_remote_item_get_ir_signal(CrossRemoteItem* item);
 InfraredSignal* xremote_cross_remote_item_get_ir_signal(CrossRemoteItem* item);
 void xremote_cross_remote_item_set_ir_signal(CrossRemoteItem* item, InfraredSignal* signal);
 void xremote_cross_remote_item_set_ir_signal(CrossRemoteItem* item, InfraredSignal* signal);
@@ -21,5 +22,5 @@ SubGhzRemote* xremote_cross_remote_item_get_sg_signal(CrossRemoteItem* item);
 void xremote_cross_remote_item_set_sg_signal(CrossRemoteItem* item, SubGhzRemote* subghz);
 void xremote_cross_remote_item_set_sg_signal(CrossRemoteItem* item, SubGhzRemote* subghz);
 
 
 bool xremote_cross_remote_item_pause_save(FlipperFormat* ff, int32_t time, const char* name);
 bool xremote_cross_remote_item_pause_save(FlipperFormat* ff, int32_t time, const char* name);
-bool xremote_cross_remote_item_ir_signal_save(InfraredSignal* signal, FlipperFormat* ff, const char* name);
+bool xremote_cross_remote_item_ir_signal_save(InfraredSignal* signal, FlipperFormat* ff, const char* name, uint32_t time);
 bool xremote_cross_remote_item_sg_signal_save(SubGhzRemote* remote, FlipperFormat* ff, const char* name);
 bool xremote_cross_remote_item_sg_signal_save(SubGhzRemote* remote, FlipperFormat* ff, const char* name);

+ 1 - 1
scenes/xremote_scene_ir_remote.c

@@ -65,7 +65,7 @@ bool xremote_scene_ir_remote_on_event(void* context, SceneManagerEvent event) {
             const char* button_name = xremote_ir_remote_button_get_name(ir_button);
             const char* button_name = xremote_ir_remote_button_get_name(ir_button);
             InfraredSignal* signal = xremote_ir_remote_button_get_signal(ir_button);
             InfraredSignal* signal = xremote_ir_remote_button_get_signal(ir_button);
 
 
-            xremote_cross_remote_add_ir_item(app->cross_remote, button_name, signal);
+            xremote_cross_remote_add_ir_item(app->cross_remote, button_name, signal, app->ir_timing);
             scene_manager_next_scene(app->scene_manager, XRemoteSceneCreate);
             scene_manager_next_scene(app->scene_manager, XRemoteSceneCreate);
             consumed = true;
             consumed = true;
         }
         }

+ 1 - 1
xremote_i.h

@@ -48,7 +48,7 @@
 #define XREMOTE_DEFAULT_REMOTE_NAME "remote"
 #define XREMOTE_DEFAULT_REMOTE_NAME "remote"
 #define XREMOTE_APP_EXTENSION ".xr"
 #define XREMOTE_APP_EXTENSION ".xr"
 #define XREMOTE_FILE_TYPE "Cross Remote File"
 #define XREMOTE_FILE_TYPE "Cross Remote File"
-#define XREMOTE_FILE_VERSION 1
+#define XREMOTE_FILE_VERSION 2
 #define XREMOTE_TEXT_STORE_NUM 2
 #define XREMOTE_TEXT_STORE_NUM 2
 #define XREMOTE_TEXT_STORE_SIZE 128
 #define XREMOTE_TEXT_STORE_SIZE 128
 #define XREMOTE_MAX_ITEM_NAME_LENGTH 22
 #define XREMOTE_MAX_ITEM_NAME_LENGTH 22