2023-01-18 20:18:19 +03:00
|
|
|
/* 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. */
|
2023-01-18 22:25:39 +03:00
|
|
|
void render_view_direct_sampling(Canvas* const canvas, ProtoViewApp* app) {
|
|
|
|
if(!app->direct_sampling_enabled) {
|
2023-01-18 20:18:19 +03:00
|
|
|
canvas_set_font(canvas, FontSecondary);
|
2023-01-18 22:25:39 +03:00
|
|
|
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.");
|
2023-01-18 20:18:19 +03:00
|
|
|
canvas_set_font(canvas, FontPrimary);
|
2023-01-18 22:25:39 +03:00
|
|
|
canvas_draw_str(canvas, 14, 60, "To enable press OK");
|
2023-01-18 20:18:19 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2023-01-18 22:25:39 +03:00
|
|
|
for(int y = 0; y < 64; y++) {
|
|
|
|
for(int x = 0; x < 128; x++) {
|
2023-01-18 20:18:19 +03:00
|
|
|
bool level = furi_hal_gpio_read(&gpio_cc1101_g0);
|
2023-01-18 22:25:39 +03:00
|
|
|
if(level) canvas_draw_dot(canvas, x, y);
|
2023-01-18 20:18:19 +03:00
|
|
|
/* Busy loop: this is a terrible approach as it blocks
|
|
|
|
* everything else, but for now it's the best we can do
|
|
|
|
* to obtain direct data with some spacing. */
|
2023-01-18 22:25:39 +03:00
|
|
|
uint32_t x = 250;
|
|
|
|
while(x--)
|
|
|
|
;
|
2023-01-18 20:18:19 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
canvas_set_font(canvas, FontSecondary);
|
2023-01-18 22:25:39 +03:00
|
|
|
canvas_draw_str_with_border(canvas, 36, 60, "Direct sampling", ColorWhite, ColorBlack);
|
2023-01-18 20:18:19 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Handle input */
|
2023-01-18 22:25:39 +03:00
|
|
|
void process_input_direct_sampling(ProtoViewApp* app, InputEvent input) {
|
|
|
|
if(input.type == InputTypePress && input.key == InputKeyOk) {
|
2023-01-18 20:18:19 +03:00
|
|
|
app->direct_sampling_enabled = !app->direct_sampling_enabled;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Enter view. Stop the subghz thread to prevent access as we read
|
|
|
|
* the CC1101 data directly. */
|
2023-01-18 22:25:39 +03:00
|
|
|
void view_enter_direct_sampling(ProtoViewApp* app) {
|
|
|
|
if(app->txrx->txrx_state == TxRxStateRx && !app->txrx->debug_timer_sampling) {
|
2023-01-18 20:18:19 +03:00
|
|
|
subghz_worker_stop(app->txrx->worker);
|
|
|
|
} else {
|
|
|
|
raw_sampling_worker_stop(app);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Exit view. Restore the subghz thread. */
|
2023-01-18 22:25:39 +03:00
|
|
|
void view_exit_direct_sampling(ProtoViewApp* app) {
|
|
|
|
if(app->txrx->txrx_state == TxRxStateRx && !app->txrx->debug_timer_sampling) {
|
2023-01-18 20:18:19 +03:00
|
|
|
subghz_worker_start(app->txrx->worker);
|
|
|
|
} else {
|
|
|
|
raw_sampling_worker_start(app);
|
|
|
|
}
|
|
|
|
app->direct_sampling_enabled = false;
|
|
|
|
}
|