Преглед изворни кода

Direct sampling mode, reading GDO0 directly.

antirez пре 3 година
родитељ
комит
6ba370282e
3 измењених фајлова са 34 додато и 0 уклоњено
  1. 4 0
      app.c
  2. 3 0
      app.h
  3. 27 0
      view_direct_sampling.c

+ 4 - 0
app.c

@@ -56,6 +56,7 @@ static void render_callback(Canvas *const canvas, void *ctx) {
     case ViewFrequencySettings:
     case ViewModulationSettings:
         render_view_settings(canvas,app); break;
+    case ViewDirectSampling: render_view_direct_sampling(canvas,app); break;
     case ViewLast: furi_crash(TAG " ViewLast selected"); break;
     }
 }
@@ -228,6 +229,9 @@ int32_t protoview_app_entry(void* p) {
                 case ViewModulationSettings:
                     process_input_settings(app,input);
                     break;
+                case ViewDirectSampling:
+                    process_input_direct_sampling(app,input);
+                    break;
                 case ViewLast: furi_crash(TAG " ViewLast selected"); break;
                 }
             }

+ 3 - 0
app.h

@@ -43,6 +43,7 @@ typedef enum {
     ViewInfo,
     ViewFrequencySettings,
     ViewModulationSettings,
+    ViewDirectSampling,
     ViewLast, /* Just a sentinel to wrap around. */
 } ProtoViewCurrentView;
 
@@ -149,6 +150,8 @@ void render_view_settings(Canvas *const canvas, ProtoViewApp *app);
 void process_input_settings(ProtoViewApp *app, InputEvent input);
 void render_view_info(Canvas *const canvas, ProtoViewApp *app);
 void process_input_info(ProtoViewApp *app, InputEvent input);
+void render_view_direct_sampling(Canvas *const canvas, ProtoViewApp *app);
+void process_input_direct_sampling(ProtoViewApp *app, InputEvent input);
 
 /* ui.c */
 void canvas_draw_str_with_border(Canvas* canvas, uint8_t x, uint8_t y, const char* str, Color text_color, Color border_color);

+ 27 - 0
view_direct_sampling.c

@@ -0,0 +1,27 @@
+/* Copyright (C) 2022-2023 Salvatore Sanfilippo -- All Rights Reserved
+ * See the LICENSE file for information about the license. */
+
+#include "app.h"
+
+#include <cc1101.h>
+
+/* 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);
+    for (int y = 0; y < 64; y++) {
+        for (int x = 0; x < 128; x++) {
+            bool level = furi_hal_gpio_read(&gpio_cc1101_g0);
+            if (level) canvas_draw_dot(canvas,x,y);
+        }
+    }
+    canvas_set_font(canvas, FontSecondary);
+    canvas_draw_str_with_border(canvas,40,60,"Direct sampling",
+        ColorWhite,ColorBlack);
+}
+
+/* Handle input */
+void process_input_direct_sampling(ProtoViewApp *app, InputEvent input) {
+    UNUSED(app);
+    UNUSED(input);
+}