desktop_hw_mismatch.c 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #include <furi.h>
  2. #include "../desktop_i.h"
  3. #include <furi-hal.h>
  4. #include <furi-hal-version.h>
  5. #include "desktop_hw_mismatch.h"
  6. void desktop_hw_mismatch_set_callback(
  7. DesktopHwMismatchView* main_view,
  8. DesktopHwMismatchViewCallback callback,
  9. void* context) {
  10. furi_assert(main_view);
  11. furi_assert(callback);
  12. main_view->callback = callback;
  13. main_view->context = context;
  14. }
  15. void desktop_hw_mismatch_render(Canvas* canvas, void* model) {
  16. canvas_clear(canvas);
  17. canvas_set_color(canvas, ColorBlack);
  18. canvas_set_font(canvas, FontPrimary);
  19. canvas_draw_str(canvas, 2, 15, "!!!! HW Mismatch !!!!");
  20. char buffer[64];
  21. canvas_set_font(canvas, FontSecondary);
  22. snprintf(buffer, 64, "HW target: F%d", furi_hal_version_get_hw_target());
  23. canvas_draw_str(canvas, 5, 27, buffer);
  24. canvas_draw_str(canvas, 5, 38, "FW target: " TARGET);
  25. }
  26. View* desktop_hw_mismatch_get_view(DesktopHwMismatchView* hw_mismatch_view) {
  27. furi_assert(hw_mismatch_view);
  28. return hw_mismatch_view->view;
  29. }
  30. bool desktop_hw_mismatch_input(InputEvent* event, void* context) {
  31. furi_assert(event);
  32. furi_assert(context);
  33. DesktopHwMismatchView* hw_mismatch_view = context;
  34. if(event->type == InputTypeShort) {
  35. hw_mismatch_view->callback(DesktopHwMismatchEventExit, hw_mismatch_view->context);
  36. }
  37. return true;
  38. }
  39. DesktopHwMismatchView* desktop_hw_mismatch_alloc() {
  40. DesktopHwMismatchView* hw_mismatch_view = furi_alloc(sizeof(DesktopHwMismatchView));
  41. hw_mismatch_view->view = view_alloc();
  42. view_allocate_model(
  43. hw_mismatch_view->view, ViewModelTypeLocking, sizeof(DesktopHwMismatchViewModel));
  44. view_set_context(hw_mismatch_view->view, hw_mismatch_view);
  45. view_set_draw_callback(hw_mismatch_view->view, (ViewDrawCallback)desktop_hw_mismatch_render);
  46. view_set_input_callback(hw_mismatch_view->view, desktop_hw_mismatch_input);
  47. return hw_mismatch_view;
  48. }
  49. void desktop_hw_mismatch_free(DesktopHwMismatchView* hw_mismatch_view) {
  50. furi_assert(hw_mismatch_view);
  51. view_free(hw_mismatch_view->view);
  52. free(hw_mismatch_view);
  53. }