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

Fix bitmap copy and oscilloscope view.

antirez 3 лет назад
Родитель
Сommit
56b968979c
4 измененных файлов с 16 добавлено и 7 удалено
  1. 2 1
      protocols/b4b1.c
  2. 1 1
      protocols/keeloq.c
  3. 2 2
      signal.c
  4. 11 3
      view_info.c

+ 2 - 1
protocols/b4b1.c

@@ -35,9 +35,10 @@ static bool decode(uint8_t *bits, uint32_t numbytes, uint32_t numbits, ProtoView
         convert_from_line_code(d,sizeof(d),bits,numbytes,off,"1000","1110");
 
     if (DEBUG_MSG) FURI_LOG_E(TAG, "B4B1 decoded: %lu",decoded);
-    if (decoded != 24) return false;
+    if (decoded < 24) return false;
 
     off += 24*4; // seek to end symbol offset to calculate the length.
+    off++; // In this protocol there is a final pulse as terminator.
     info->pulses_count = off - info->start_off;
     snprintf(info->name,PROTOVIEW_MSG_STR_LEN,"PT/SC remote");
     snprintf(info->raw,PROTOVIEW_MSG_STR_LEN,"%02X%02X%02X",d[0],d[1],d[2]);

+ 1 - 1
protocols/keeloq.c

@@ -57,7 +57,7 @@ static bool decode(uint8_t *bits, uint32_t numbytes, uint32_t numbits, ProtoView
 
     if (decoded < 66) return false; /* Require the full 66 bits. */
 
-    off += decoded+66*3; // Seek end to compute total length.
+    off += 66*3; // Seek end to compute total length.
     info->pulses_count = off - info->start_off;
 
     bitmap_reverse_bytes(raw,sizeof(raw)); /* Keeloq is LSB first. */

+ 2 - 2
signal.c

@@ -303,10 +303,10 @@ void bitmap_copy(uint8_t *d, uint32_t dlen, uint32_t doff,
                        (s[sidx+1] >> (8-skew)));
             sidx++;
             didx++;
+            soff += 8;
+            doff += 8;
             count -= 8;
         }
-        soff = sidx*8;
-        doff = didx*8;
     }
 
     /* Here count is guaranteed to be < 8.

+ 11 - 3
view_info.c

@@ -53,14 +53,21 @@ static void render_subview_save(Canvas *const canvas, ProtoViewApp *app) {
     uint32_t idx = privdata->signal_display_start_row * (128/4);
     bool prevbit = false;
     for (uint8_t y = bitheight+12; y <= rows*rowheight; y += rowheight) {
-        for (uint8_t x = 5; x < 128; x += 4) {
+        for (uint8_t x = 0; x < 128; x += 4) {
             bool bit = bitmap_get(app->msg_info->bits,
-                                  app->msg_info->bits_bytes,idx++);
+                                  app->msg_info->bits_bytes,idx);
             uint8_t prevy = y + prevbit*(bitheight*-1) - 1;
             uint8_t thisy = y + bit*(bitheight*-1) - 1;
             canvas_draw_line(canvas,x,prevy,x,thisy);
             canvas_draw_line(canvas,x,thisy,x+bitwidth-1,thisy);
             prevbit = bit;
+            if (idx >= app->msg_info->pulses_count) {
+                canvas_set_color(canvas, ColorWhite);
+                canvas_draw_dot(canvas, x+1,thisy);
+                canvas_draw_dot(canvas, x+3,thisy);
+                canvas_set_color(canvas, ColorBlack);
+            }
+            idx++; // Draw next bit
         }
     }
 
@@ -100,7 +107,8 @@ void process_input_info(ProtoViewApp *app, InputEvent input) {
         if (input.type == InputTypePress && input.key == InputKeyRight) {
             privdata->signal_display_start_row++;
         } else if (input.type == InputTypePress && input.key == InputKeyLeft) {
-            privdata->signal_display_start_row--;
+            if (privdata->signal_display_start_row != 0)
+                privdata->signal_display_start_row--;
         }
     }
 }