Sfoglia il codice sorgente

Enable/disable and explain direct sampling.

antirez 3 anni fa
parent
commit
a81a3f2c10
3 ha cambiato i file con 19 aggiunte e 3 eliminazioni
  1. 1 0
      app.c
  2. 2 0
      app.h
  3. 16 3
      view_direct_sampling.c

+ 1 - 0
app.c

@@ -118,6 +118,7 @@ ProtoViewApp* protoview_app_alloc() {
     gui_add_view_port(app->gui, app->view_port, GuiLayerFullscreen);
     app->event_queue = furi_message_queue_alloc(8, sizeof(InputEvent));
     app->current_view = ViewRawPulses;
+    app->direct_sampling_enabled = false;
 
     // Signal found and visualization defaults
     app->signal_bestlen = 0;

+ 2 - 0
app.h

@@ -116,6 +116,8 @@ struct ProtoViewApp {
     uint32_t signal_bestlen; /* Longest coherent signal observed so far. */
     bool signal_decoded;     /* Was the current signal decoded? */
     ProtoViewMsgInfo signal_info; /* Decoded message, if signal_decoded true. */
+    bool direct_sampling_enabled; /* This special view needs an explicit
+                                     acknowledge to work. */
 
     /* Raw view apps state. */
     uint32_t us_scale;       /* microseconds per pixel. */

+ 16 - 3
view_direct_sampling.c

@@ -8,7 +8,18 @@
 /* Read directly from the G0 CC1101 pin, and draw a black or white
  * dot depending on the level. */
 void render_view_direct_sampling(Canvas *const canvas, ProtoViewApp *app) {
-    UNUSED(app);
+    if (!app->direct_sampling_enabled) {
+        canvas_set_font(canvas, FontSecondary);
+        canvas_draw_str(canvas,2,9,"Direct sampling is a special");
+        canvas_draw_str(canvas,2,18,"mode that displays the signal");
+        canvas_draw_str(canvas,2,27,"captured in real time. Like in");
+        canvas_draw_str(canvas,2,36,"a old CRT TV. It's very slow.");
+        canvas_draw_str(canvas,2,45,"Can crash your Flipper.");
+        canvas_set_font(canvas, FontPrimary);
+        canvas_draw_str(canvas,14,60,"To enable press OK");
+        return;
+    }
+
     for (int y = 0; y < 64; y++) {
         for (int x = 0; x < 128; x++) {
             bool level = furi_hal_gpio_read(&gpio_cc1101_g0);
@@ -26,8 +37,9 @@ void render_view_direct_sampling(Canvas *const canvas, ProtoViewApp *app) {
 
 /* Handle input */
 void process_input_direct_sampling(ProtoViewApp *app, InputEvent input) {
-    UNUSED(app);
-    UNUSED(input);
+    if (input.type == InputTypePress && input.key == InputKeyOk) {
+        app->direct_sampling_enabled = !app->direct_sampling_enabled;
+    }
 }
 
 /* Enter view. Stop the subghz thread to prevent access as we read
@@ -51,4 +63,5 @@ void view_exit_direct_sampling(ProtoViewApp *app) {
     } else {
         raw_sampling_worker_start(app);
     }
+    app->direct_sampling_enabled = false;
 }