view_direct_sampling.c 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /* Copyright (C) 2022-2023 Salvatore Sanfilippo -- All Rights Reserved
  2. * See the LICENSE file for information about the license. */
  3. #include "app.h"
  4. #include <cc1101.h>
  5. /* Read directly from the G0 CC1101 pin, and draw a black or white
  6. * dot depending on the level. */
  7. void render_view_direct_sampling(Canvas *const canvas, ProtoViewApp *app) {
  8. UNUSED(app);
  9. for (int y = 0; y < 64; y++) {
  10. for (int x = 0; x < 128; x++) {
  11. bool level = furi_hal_gpio_read(&gpio_cc1101_g0);
  12. if (level) canvas_draw_dot(canvas,x,y);
  13. /* Busy loop: this is a terrible approach as it blocks
  14. * everything else, but for now it's the best we can do
  15. * to obtain direct data with some spacing. */
  16. uint32_t x = 250; while(x--);
  17. }
  18. }
  19. canvas_set_font(canvas, FontSecondary);
  20. canvas_draw_str_with_border(canvas,40,60,"Direct sampling",
  21. ColorWhite,ColorBlack);
  22. }
  23. /* Handle input */
  24. void process_input_direct_sampling(ProtoViewApp *app, InputEvent input) {
  25. UNUSED(app);
  26. UNUSED(input);
  27. }
  28. /* Enter view. Stop the subghz thread to prevent access as we read
  29. * the CC1101 data directly. */
  30. void view_enter_direct_sampling(ProtoViewApp *app) {
  31. if (app->txrx->txrx_state == TxRxStateRx &&
  32. !app->txrx->debug_direct_sampling)
  33. {
  34. subghz_worker_stop(app->txrx->worker);
  35. } else {
  36. raw_sampling_worker_stop(app);
  37. }
  38. }
  39. /* Exit view. Restore the subghz thread. */
  40. void view_exit_direct_sampling(ProtoViewApp *app) {
  41. if (app->txrx->txrx_state == TxRxStateRx &&
  42. !app->txrx->debug_direct_sampling)
  43. {
  44. subghz_worker_start(app->txrx->worker);
  45. } else {
  46. raw_sampling_worker_start(app);
  47. }
  48. }