فهرست منبع

Allow switching between normal and debug DS mode.

antirez 3 سال پیش
والد
کامیت
b879bb945a
4فایلهای تغییر یافته به همراه36 افزوده شده و 32 حذف شده
  1. 19 27
      app.c
  2. 9 4
      app_subghz.c
  3. 1 1
      view_direct_sampling.c
  4. 7 0
      view_settings.c

+ 19 - 27
app.c

@@ -130,33 +130,25 @@ ProtoViewApp* protoview_app_alloc() {
 
     /* Setup rx worker and environment. */
     app->txrx->freq_mod_changed = false;
-    app->txrx->debug_direct_sampling = true;
-    if (app->txrx->debug_direct_sampling) {
-        app->txrx->ds_thread = NULL;
-    } else {
-        app->txrx->worker = subghz_worker_alloc();
-    #ifdef PROTOVIEW_DISABLE_SUBGHZ_FILTER
-        app->txrx->worker->filter_running = 0;
-    #endif
-
-        app->txrx->environment = subghz_environment_alloc();
-
-        subghz_environment_set_protocol_registry(
-            app->txrx->environment, (void*)&protoview_protocol_registry);
-
-        app->txrx->receiver =
-            subghz_receiver_alloc_init(app->txrx->environment);
-
-        subghz_receiver_set_filter(app->txrx->receiver,
-                                   SubGhzProtocolFlag_Decodable);
-        subghz_worker_set_overrun_callback(
-            app->txrx->worker,
-            (SubGhzWorkerOverrunCallback)subghz_receiver_reset);
-
-        subghz_worker_set_pair_callback(
-            app->txrx->worker, (SubGhzWorkerPairCallback)subghz_receiver_decode);
-        subghz_worker_set_context(app->txrx->worker, app->txrx->receiver);
-    }
+    app->txrx->debug_direct_sampling = false;
+    app->txrx->ds_thread = NULL;
+    app->txrx->worker = subghz_worker_alloc();
+#ifdef PROTOVIEW_DISABLE_SUBGHZ_FILTER
+    app->txrx->worker->filter_running = 0;
+#endif
+    app->txrx->environment = subghz_environment_alloc();
+    subghz_environment_set_protocol_registry(
+        app->txrx->environment, (void*)&protoview_protocol_registry);
+    app->txrx->receiver =
+        subghz_receiver_alloc_init(app->txrx->environment);
+    subghz_receiver_set_filter(app->txrx->receiver,
+                               SubGhzProtocolFlag_Decodable);
+    subghz_worker_set_overrun_callback(
+        app->txrx->worker,
+        (SubGhzWorkerOverrunCallback)subghz_receiver_reset);
+    subghz_worker_set_pair_callback(
+        app->txrx->worker, (SubGhzWorkerPairCallback)subghz_receiver_decode);
+    subghz_worker_set_context(app->txrx->worker, app->txrx->receiver);
     
     app->frequency = subghz_setting_get_default_frequency(app->setting);
     app->modulation = 0; /* Defaults to ProtoViewModulations[0]. */

+ 9 - 4
app_subghz.c

@@ -128,10 +128,15 @@ int32_t direct_sampling_thread(void *ctx) {
             uint32_t dur = now - last_change_time;
             dur /= furi_hal_cortex_instructions_per_microsecond();
 
-            raw_samples_add(RawSamples, last_level, dur);
-            if (j < 50) {
-                l[j] = last_level;
-                d[j] = dur;
+            if (dur > 20) {
+                raw_samples_add(RawSamples, last_level, dur);
+                if (j < 50) {
+                    l[j] = last_level;
+                    d[j] = dur;
+                }
+            } else {
+                last_level = !last_level;
+                continue;
             }
 
             last_level = !last_level; /* What g0 is now. */

+ 1 - 1
view_direct_sampling.c

@@ -16,7 +16,7 @@ void render_view_direct_sampling(Canvas *const canvas, ProtoViewApp *app) {
             /* Busy loop: this is a terrible approach as it blocks
              * everything else, but for now it's the best we can do
              * to obtain direct data with some spacing. */
-            // uint32_t x = 500; while(x--);
+            uint32_t x = 250; while(x--);
         }
     }
     canvas_set_font(canvas, FontSecondary);

+ 7 - 0
view_settings.c

@@ -20,6 +20,9 @@ void render_view_settings(Canvas *const canvas, ProtoViewApp *app) {
     canvas_set_font(canvas, FontSecondary);
     canvas_draw_str(canvas,10,61,"Use up and down to modify");
 
+    if (app->txrx->debug_direct_sampling)
+        canvas_draw_str(canvas,3,54,"(DEBUG direct sampling is ON)");
+
     /* Show frequency. We can use big numbers font since it's just a number. */
     if (app->current_view == ViewFrequencySettings) {
         char buf[16];
@@ -40,6 +43,10 @@ void process_input_settings(ProtoViewApp *app, InputEvent input) {
          * modulation. */
         app->frequency = subghz_setting_get_default_frequency(app->setting);
         app->modulation = 0;
+    } else if (input.type == InputTypeLong && input.key == InputKeyDown) {
+        /* Long pressing to down switches between normal and debug
+         * direct sampling mode. */
+        app->txrx->debug_direct_sampling = !app->txrx->debug_direct_sampling;
     } else if (input.type == InputTypePress &&
               (input.key != InputKeyDown || input.key != InputKeyUp))
     {