antirez 3 лет назад
Родитель
Сommit
bdaebc51e3
3 измененных файлов с 40 добавлено и 4 удалено
  1. 1 2
      TODO
  2. 38 2
      app.c
  3. 1 0
      app_buffer.c

+ 1 - 2
TODO

@@ -1,8 +1,7 @@
 Core improvements
 =================
 
-- Remove processing from rendering callback, put it into timer.
-- Detection of non Manchester and non RZ encoded signals. Not sure if there are any signals that are not self clocked widely used in RF.
+- Detection of non Manchester and non RZ encoded signals. Not sure if there are any signals that are not self clocked widely used in RF. Note that the current approach already detects encodings using short high + long low and long high + short low to encode 0 and 1. In addition to the current classifier, it is possible to add one that checks for a sequence of pulses that are all multiples of some base length. This should detect, for instance, even NRZ encodings where 1 and 0 are just clocked as they are.
 
 Features
 ========

+ 38 - 2
app.c

@@ -22,8 +22,6 @@ extern const SubGhzProtocolRegistry protoview_protocol_registry;
  * The 'idx' argument is the first sample to render in the circular
  * buffer. */
 void render_signal(Canvas *const canvas, RawSamplesBuffer *buf, uint32_t idx) {
-    canvas_set_color(canvas, ColorWhite);
-    canvas_draw_box(canvas, 0, 0, 127, 63);
     canvas_set_color(canvas, ColorBlack);
 
     int rows = 8;
@@ -151,9 +149,47 @@ void scan_for_signal(ProtoViewApp *app) {
     raw_samples_free(copy);
 }
 
+/* Draw some white text with a black border. */
+void canvas_draw_str_with_border(Canvas* canvas, uint8_t x, uint8_t y, const char* str)
+{
+    struct {
+        uint8_t x; uint8_t y;
+    } dir[8] = {
+        {-1,-1},
+        {0,-1},
+        {1,-1},
+        {1,0},
+        {1,1},
+        {0,1},
+        {-1,1},
+        {-1,0}
+    };
+
+    /* Rotate in all the directions writing the same string in black
+     * to create a border, then write the actaul string in white in the
+     * middle. */
+    canvas_set_color(canvas, ColorBlack);
+    canvas_set_font(canvas, FontSecondary);
+    for (int j = 0; j < 8; j++)
+        canvas_draw_str(canvas,x+dir[j].x,y+dir[j].y,str);
+    canvas_set_color(canvas, ColorWhite);
+    canvas_draw_str(canvas,x,y,str);
+}
+
 static void render_callback(Canvas *const canvas, void *ctx) {
     UNUSED(ctx);
+
+    /* Clear screen. */
+    canvas_set_color(canvas, ColorWhite);
+    canvas_draw_box(canvas, 0, 0, 127, 63);
+
+    /* Show signal. */
     render_signal(canvas, DetectedSamples, 0);
+
+    /* Show signal information. */
+    char buf[64];
+    snprintf(buf,sizeof(buf),"%luus", (unsigned long)DetectedSamples->short_pulse_dur);
+    canvas_draw_str_with_border(canvas, 100, 63, buf);
 }
 
 /* Here all we do is putting the events into the queue that will be handled

+ 1 - 0
app_buffer.c

@@ -56,6 +56,7 @@ void raw_samples_copy(RawSamplesBuffer *dst, RawSamplesBuffer *src) {
     furi_mutex_acquire(src->mutex,FuriWaitForever);
     furi_mutex_acquire(dst->mutex,FuriWaitForever);
     dst->idx = src->idx;
+    dst->short_pulse_dur = src->short_pulse_dur;
     memcpy(dst->level,src->level,sizeof(dst->level));
     memcpy(dst->dur,src->dur,sizeof(dst->dur));
     furi_mutex_release(src->mutex);