Просмотр исходного кода

Multi page INFO. Long press to reset signal.

antirez 3 лет назад
Родитель
Сommit
0d11844445
4 измененных файлов с 52 добавлено и 15 удалено
  1. 1 0
      app.h
  2. 1 6
      signal.c
  3. 28 4
      view_info.c
  4. 22 5
      view_raw_signal.c

+ 1 - 0
app.h

@@ -272,6 +272,7 @@ void process_input_direct_sampling(ProtoViewApp *app, InputEvent input);
 void view_enter_direct_sampling(ProtoViewApp *app);
 void view_exit_direct_sampling(ProtoViewApp *app);
 void view_exit_settings(ProtoViewApp *app);
+void adjust_raw_view_scale(ProtoViewApp *app, uint32_t short_pulse_dur);
 
 /* ui.c */
 int ui_get_current_subview(ProtoViewApp *app);

+ 1 - 6
signal.c

@@ -198,12 +198,7 @@ void scan_for_signal(ProtoViewApp *app) {
                 FURI_LOG_E(TAG, "===> Displayed sample updated (%d samples %lu us)",
                     (int)thislen, DetectedSamples->short_pulse_dur);
 
-                /* Adjust raw view scale if the signal has an high
-                 * data rate. */
-                if (DetectedSamples->short_pulse_dur < 75)
-                    app->us_scale = 10;
-                else if (DetectedSamples->short_pulse_dur < 145)
-                    app->us_scale = 30;
+                adjust_raw_view_scale(app,DetectedSamples->short_pulse_dur);
                 notify_signal_detected(app,decoded);
             } else {
                 /* If the structure was not filled, discard it. Otherwise

+ 28 - 4
view_info.c

@@ -21,6 +21,9 @@ typedef struct {
      * you can move to next rows. Here we store where we are. */
     uint32_t signal_display_start_row;
     char *filename;
+    uint8_t cur_info_page; // Info page to display. Useful when there are
+                           // too many fields populated by the decoder that
+                           // a single page is not enough.
 } InfoViewPrivData;
 
 /* Draw the text label and value of the specified info field at x,y. */
@@ -79,17 +82,35 @@ static void render_info_field(Canvas *const canvas,
 }
 
 /* Render the view with the detected message information. */
+#define INFO_LINES_PER_PAGE 5
 static void render_subview_main(Canvas *const canvas, ProtoViewApp *app) {
+    InfoViewPrivData *privdata = app->view_privdata;
+    uint8_t pages = (app->msg_info->fieldset->numfields
+                     +(INFO_LINES_PER_PAGE-1)) / INFO_LINES_PER_PAGE;
+    privdata->cur_info_page %= pages;
+    uint8_t current_page = privdata->cur_info_page;
+    char buf[32];
+
     /* Protocol name as title. */
     canvas_set_font(canvas, FontPrimary);
     uint8_t y = 8, lineheight = 10;
-    canvas_draw_str(canvas, 0, y, app->msg_info->decoder->name);
+
+    if (pages > 1) {
+        snprintf(buf,sizeof(buf),"%s %u/%u", app->msg_info->decoder->name,
+                                             current_page+1, pages);
+        canvas_draw_str(canvas, 0, y, buf);
+    } else {
+        canvas_draw_str(canvas, 0, y, app->msg_info->decoder->name);
+    }
     y += lineheight;
 
     /* Draw the info fields. */
-    for (uint32_t j = 0; j < app->msg_info->fieldset->numfields; j++) {
-        render_info_field(canvas,app->msg_info->fieldset->fields[j],0,y);
+    uint8_t max_lines = INFO_LINES_PER_PAGE;
+    uint32_t j = current_page*max_lines;
+    while (j < app->msg_info->fieldset->numfields) {
+        render_info_field(canvas,app->msg_info->fieldset->fields[j++],0,y);
         y += lineheight;
+        if (--max_lines == 0) break;
     }
 
     /* Draw a vertical "save" label. Temporary solution, to switch to
@@ -313,9 +334,12 @@ void process_input_info(ProtoViewApp *app, InputEvent input) {
 
     /* Main subview. */
     if (subview == SubViewInfoMain) {
-        if (input.type == InputTypeShort && input.key == InputKeyOk) {
+        if (input.type == InputTypeLong && input.key == InputKeyOk) {
             /* Reset the current sample to capture the next. */
             reset_current_signal(app);
+        } else if (input.type == InputTypeShort && input.key == InputKeyOk) {
+            /* Show next info page. */
+            privdata->cur_info_page++;
         }
     } else if (subview == SubViewInfoSave) {
     /* Save subview. */

+ 22 - 5
view_raw_signal.c

@@ -77,14 +77,15 @@ void process_input_raw_pulses(ProtoViewApp *app, InputEvent input) {
          * previous samples. */
         if (input.key == InputKeyRight) app->signal_offset++;
         else if (input.key == InputKeyLeft) app->signal_offset--;
-        else if (input.key == InputKeyOk) {
-            app->signal_offset = 0;
-            app->us_scale = PROTOVIEW_RAW_VIEW_DEFAULT_SCALE;
-        }
-    } else if (input.type == InputTypeShort) {
+    } else if (input.type == InputTypeLong) {
         if (input.key == InputKeyOk) {
             /* Reset the current sample to capture the next. */
             reset_current_signal(app);
+        }
+    } else if (input.type == InputTypeShort) {
+        if (input.key == InputKeyOk) {
+            app->signal_offset = 0;
+            adjust_raw_view_scale(app,DetectedSamples->short_pulse_dur);
         } else if (input.key == InputKeyDown) {
             /* Rescaling. The set becomes finer under 50us per pixel. */
             uint32_t scale_step = app->us_scale >= 50 ? 50 : 10;
@@ -95,3 +96,19 @@ void process_input_raw_pulses(ProtoViewApp *app, InputEvent input) {
         }
     }
 }
+
+/* Adjust raw view scale depending on short pulse duration. */
+void adjust_raw_view_scale(ProtoViewApp *app, uint32_t short_pulse_dur) {
+    if (short_pulse_dur == 0)
+        app->us_scale = PROTOVIEW_RAW_VIEW_DEFAULT_SCALE;
+    else if (short_pulse_dur < 75)
+        app->us_scale = 10;
+    else if (short_pulse_dur < 145)
+        app->us_scale = 30;
+    else if (short_pulse_dur < 400)
+        app->us_scale = 100;
+    else if (short_pulse_dur < 1000)
+        app->us_scale = 200;
+    else
+        app->us_scale = PROTOVIEW_RAW_VIEW_DEFAULT_SCALE;
+}