MX 2 lat temu
rodzic
commit
8c46e20644
7 zmienionych plików z 42 dodań i 33 usunięć
  1. 1 1
      xremote.h
  2. 15 11
      xremote_app.c
  3. 1 0
      xremote_app.h
  4. 8 2
      xremote_learn.c
  5. 1 1
      xremote_settings.c
  6. 14 16
      xremote_signal.c
  7. 2 2
      xremote_signal.h

+ 1 - 1
xremote.h

@@ -10,6 +10,6 @@
 
 #define XREMOTE_VERSION_MAJOR 1
 #define XREMOTE_VERSION_MINOR 0
-#define XREMOTE_BUILD_NUMBER 2
+#define XREMOTE_BUILD_NUMBER 5
 
 void xremote_get_version(char* version, size_t length);

+ 15 - 11
xremote_app.c

@@ -41,15 +41,18 @@ bool xremote_app_settings_store(XRemoteAppSettings* settings) {
     do {
         /* Write header in config file */
         if(!flipper_format_file_open_always(ff, XREMOTE_APP_SETTINGS)) break;
-        if(!flipper_format_write_header_cstr(ff, "XRemote settings file", 1)) break;
+        if(!flipper_format_write_header_cstr(ff, "XRemote", 1)) break;
         if(!flipper_format_write_comment_cstr(ff, "")) break;
 
         /* Write actual configuration to the settings file */
-        if(!flipper_format_write_uint32(ff, "orientation", (uint32_t*)&settings->orientation, 1))
-            break;
-        if(!flipper_format_write_uint32(ff, "repeat", (uint32_t*)&settings->repeat_count, 1))
-            break;
-        if(!flipper_format_write_uint32(ff, "exit", (uint32_t*)&settings->exit_behavior, 1)) break;
+        uint32_t value = settings->orientation == ViewOrientationHorizontal ? 0 : 1;
+        if(!flipper_format_write_uint32(ff, "orientation", &value, 1)) break;
+
+        value = settings->exit_behavior == XRemoteAppExitPress ? 0 : 1;
+        if(!flipper_format_write_uint32(ff, "appexit", &value, 1)) break;
+
+        value = settings->repeat_count;
+        if(!flipper_format_write_uint32(ff, "repeat", &value, 1)) break;
 
         success = true;
     } while(false);
@@ -74,15 +77,15 @@ bool xremote_app_settings_load(XRemoteAppSettings* settings) {
         /* Open file and read the header */
         if(!flipper_format_buffered_file_open_existing(ff, XREMOTE_APP_SETTINGS)) break;
         if(!flipper_format_read_header(ff, header, &version)) break;
-        if(!furi_string_equal(header, "XRemote settings file") || (version != 1)) break;
+        if(!furi_string_equal(header, "XRemote") || (version != 1)) break;
 
         /* Parse config data from the buffer */
         if(!flipper_format_read_uint32(ff, "orientation", &value, 1)) break;
-        settings->orientation = value;
+        settings->orientation = value == 0 ? ViewOrientationHorizontal : ViewOrientationVertical;
+        if(!flipper_format_read_uint32(ff, "appexit", &value, 1)) break;
+        settings->exit_behavior = value == 0 ? XRemoteAppExitPress : XRemoteAppExitHold;
         if(!flipper_format_read_uint32(ff, "repeat", &value, 1)) break;
         settings->repeat_count = value;
-        if(!flipper_format_read_uint32(ff, "exit", &value, 1)) break;
-        settings->exit_behavior = value;
 
         success = true;
     } while(false);
@@ -225,7 +228,7 @@ void xremote_app_submenu_alloc(XRemoteApp* app, uint32_t index, ViewNavigationCa
     View* view = submenu_get_view(app->submenu);
     view_set_previous_callback(view, prev_cb);
 
-#ifdef FW_ORIGIN_Unleashed
+#if defined(FW_ORIGIN_Unleashed) || defined(FW_ORIGIN_RM)
     submenu_set_orientation(app->submenu, settings->orientation);
 #else
     view_set_orientation(view, settings->orientation);
@@ -299,6 +302,7 @@ void xremote_app_free(XRemoteApp* app) {
     xremote_app_submenu_free(app);
     xremote_app_view_free(app);
 
+    /* Call clear callback if there is an user context attached  */
     if(app->on_clear != NULL) app->on_clear(app->context);
 
     free(app);

+ 1 - 0
xremote_app.h

@@ -83,6 +83,7 @@ void xremote_app_submenu_add(
     const char* name,
     uint32_t index,
     SubmenuItemCallback callback);
+
 void xremote_app_submenu_alloc(XRemoteApp* app, uint32_t index, ViewNavigationCallback prev_cb);
 void xremote_app_submenu_free(XRemoteApp* app);
 

+ 8 - 2
xremote_learn.c

@@ -255,6 +255,12 @@ static void xremote_learn_finish(XRemoteLearnContext* learn_ctx) {
     xremote_learn_switch_to_view(learn_ctx, XRemoteViewSubmenu);
 }
 
+static bool xremote_learn_custom_event_dummy_callback(void* context, uint32_t event) {
+    UNUSED(context);
+    UNUSED(event);
+    return true;
+}
+
 static bool xremote_learn_custom_event_callback(void* context, uint32_t event) {
     xremote_app_assert(context, false);
     XRemoteLearnContext* learn_ctx = context;
@@ -363,8 +369,8 @@ static void xremote_learn_context_free(XRemoteLearnContext* learn_ctx) {
     xremote_learn_exit_dialog_free(learn_ctx);
 
     ViewDispatcher* view_disp = learn_ctx->app_ctx->view_dispatcher;
-    view_dispatcher_set_custom_event_callback(view_disp, NULL);
-    view_dispatcher_set_event_callback_context(view_disp, NULL);
+    view_dispatcher_set_custom_event_callback(
+        view_disp, xremote_learn_custom_event_dummy_callback);
 
     view_dispatcher_remove_view(view_disp, XRemoteViewTextInput);
     text_input_free(learn_ctx->text_input);

+ 1 - 1
xremote_settings.c

@@ -22,7 +22,7 @@ typedef struct {
 
 #define XREMOTE_EXIT_BEHAVIOR_TEXT_PRESS "Press"
 #define XREMOTE_EXIT_BEHAVIOR_TEXT_HOLD "Hold"
-#define XREMOTE_EXIT_BEHAVIOR_TEXT "Exit App"
+#define XREMOTE_EXIT_BEHAVIOR_TEXT "Exit Apps"
 #define XREMOTE_EXIT_BEHAVIOR_INDEX_PRESS 0
 #define XREMOTE_EXIT_BEHAVIOR_INDEX_HOLD 1
 #define XREMOTE_EXIT_BEHAVIOR_MAX 2

+ 14 - 16
xremote_signal.c

@@ -91,34 +91,32 @@ void xremote_signal_receiver_set_rx_callback(
     rx_ctx->rx_callback = rx_callback;
 }
 
-void xremote_signal_receiver_start(XRemoteSignalReceiver* rx_ctx) {
-    xremote_app_assert_void((rx_ctx && rx_ctx->worker && !rx_ctx->started));
+void xremote_signal_receiver_attach(XRemoteSignalReceiver* rx_ctx) {
+    xremote_app_assert_void((rx_ctx && rx_ctx->worker));
     infrared_worker_rx_set_received_signal_callback(
-        rx_ctx->worker, xremote_signal_receiver_rx_callback, (void*)rx_ctx);
+        rx_ctx->worker, xremote_signal_receiver_rx_callback, rx_ctx);
+}
 
+void xremote_signal_receiver_detach(XRemoteSignalReceiver* rx_ctx) {
+    xremote_app_assert_void((rx_ctx && rx_ctx->worker));
+    infrared_worker_rx_set_received_signal_callback(rx_ctx->worker, NULL, NULL);
+}
+
+void xremote_signal_receiver_start(XRemoteSignalReceiver* rx_ctx) {
+    xremote_app_assert_void((rx_ctx && !rx_ctx->started));
+    xremote_signal_receiver_attach(rx_ctx);
     infrared_worker_rx_start(rx_ctx->worker);
     xremote_app_notification_blink(rx_ctx->notifications);
     rx_ctx->started = true;
 }
 
 void xremote_signal_receiver_stop(XRemoteSignalReceiver* rx_ctx) {
-    xremote_app_assert_void((rx_ctx && rx_ctx->worker && rx_ctx->started));
-    infrared_worker_rx_set_received_signal_callback(rx_ctx->worker, NULL, NULL);
+    xremote_app_assert_void((rx_ctx && rx_ctx->started));
+    xremote_signal_receiver_detach(rx_ctx);
     infrared_worker_rx_stop(rx_ctx->worker);
     rx_ctx->started = false;
 }
 
-void xremote_signal_receiver_pause(XRemoteSignalReceiver* rx_ctx) {
-    xremote_app_assert_void((rx_ctx && rx_ctx->worker));
-    infrared_worker_rx_set_received_signal_callback(rx_ctx->worker, NULL, NULL);
-}
-
-void xremote_signal_receiver_resume(XRemoteSignalReceiver* rx_ctx) {
-    xremote_app_assert_void((rx_ctx && rx_ctx->worker));
-    infrared_worker_rx_set_received_signal_callback(
-        rx_ctx->worker, xremote_signal_receiver_rx_callback, (void*)rx_ctx);
-}
-
 InfraredSignal* xremote_signal_receiver_get_signal(XRemoteSignalReceiver* rx_ctx) {
     xremote_app_assert(rx_ctx, NULL);
     return rx_ctx->signal;

+ 2 - 2
xremote_signal.h

@@ -29,5 +29,5 @@ InfraredSignal* xremote_signal_receiver_get_signal(XRemoteSignalReceiver* rx_ctx
 void xremote_signal_receiver_start(XRemoteSignalReceiver* rx_ctx);
 void xremote_signal_receiver_stop(XRemoteSignalReceiver* rx_ctx);
 
-void xremote_signal_receiver_pause(XRemoteSignalReceiver* rx_ctx);
-void xremote_signal_receiver_resume(XRemoteSignalReceiver* rx_ctx);
+void xremote_signal_receiver_detach(XRemoteSignalReceiver* rx_ctx);
+void xremote_signal_receiver_attach(XRemoteSignalReceiver* rx_ctx);