view_info.c 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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. /* Renders the view with the detected message information. */
  5. void render_view_info(Canvas *const canvas, ProtoViewApp *app) {
  6. if (app->signal_decoded == false) {
  7. canvas_set_font(canvas, FontSecondary);
  8. canvas_draw_str(canvas, 30,36,"No signal decoded");
  9. return;
  10. }
  11. /* Protocol name as title. */
  12. canvas_set_font(canvas, FontPrimary);
  13. uint8_t y = 8, lineheight = 10;
  14. canvas_draw_str(canvas, 0, y, app->signal_info.name);
  15. y += lineheight;
  16. /* Info fields. */
  17. char buf[128];
  18. canvas_set_font(canvas, FontSecondary);
  19. if (app->signal_info.raw[0]) {
  20. snprintf(buf,sizeof(buf),"Raw: %s", app->signal_info.raw);
  21. canvas_draw_str(canvas, 0, y, buf);
  22. y += lineheight;
  23. }
  24. canvas_draw_str(canvas, 0, y, app->signal_info.info1); y += lineheight;
  25. canvas_draw_str(canvas, 0, y, app->signal_info.info2); y += lineheight;
  26. canvas_draw_str(canvas, 0, y, app->signal_info.info3); y += lineheight;
  27. canvas_draw_str(canvas, 0, y, app->signal_info.info4); y += lineheight;
  28. }
  29. /* Handle input for the info view. */
  30. void process_input_info(ProtoViewApp *app, InputEvent input) {
  31. if (input.type == InputTypeShort) {
  32. if (input.key == InputKeyOk) {
  33. /* Reset the current sample to capture the next. */
  34. reset_current_signal(app);
  35. }
  36. }
  37. }