camera_suite_view_camera.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. #pragma once
  2. #include <furi.h>
  3. #include <furi_hal.h>
  4. #include <furi_hal_console.h>
  5. #include <furi_hal_uart.h>
  6. #include <gui/elements.h>
  7. #include <gui/gui.h>
  8. #include <gui/icon_i.h>
  9. #include <gui/modules/dialog_ex.h>
  10. #include <gui/view.h>
  11. #include <gui/view_dispatcher.h>
  12. #include <notification/notification.h>
  13. #include <notification/notification_messages.h>
  14. #include <storage/filesystem_api_defines.h>
  15. #include <storage/storage.h>
  16. #include "../helpers/camera_suite_custom_event.h"
  17. #include <xtreme/xtreme.h>
  18. #define UART_CH \
  19. (xtreme_settings.uart_esp_channel == UARTDefault ? FuriHalUartIdUSART1 : FuriHalUartIdLPUART1)
  20. #define BITMAP_HEADER_LENGTH 62
  21. #define FRAME_BIT_DEPTH 1
  22. #define FRAME_BUFFER_LENGTH 1024
  23. #define FRAME_HEIGHT 64
  24. #define FRAME_WIDTH 128
  25. #define HEADER_LENGTH 3 // 'Y', ':', and row identifier
  26. #define LAST_ROW_INDEX 1008
  27. #define RING_BUFFER_LENGTH 19
  28. #define ROW_BUFFER_LENGTH 16
  29. static const unsigned char bitmap_header[BITMAP_HEADER_LENGTH] = {
  30. 0x42, 0x4D, 0x3E, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3E, 0x00, 0x00, 0x00, 0x28, 0x00,
  31. 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00,
  32. 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  33. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x00};
  34. extern const Icon I_DolphinCommon_56x48;
  35. typedef enum {
  36. WorkerEventReserved = (1 << 0), // Reserved for StreamBuffer internal event
  37. WorkerEventStop = (1 << 1),
  38. WorkerEventRx = (1 << 2),
  39. } WorkerEventFlags;
  40. #define WORKER_EVENTS_MASK (WorkerEventStop | WorkerEventRx)
  41. // Forward declaration
  42. typedef void (*CameraSuiteViewCameraCallback)(CameraSuiteCustomEvent event, void* context);
  43. typedef struct CameraSuiteViewCamera {
  44. CameraSuiteViewCameraCallback callback;
  45. FuriStreamBuffer* rx_stream;
  46. FuriThread* worker_thread;
  47. NotificationApp* notification;
  48. View* view;
  49. void* context;
  50. } CameraSuiteViewCamera;
  51. typedef struct UartDumpModel {
  52. bool is_dithering_enabled;
  53. bool is_initialized;
  54. bool is_inverted;
  55. int rotation_angle;
  56. uint32_t orientation;
  57. uint8_t pixels[FRAME_BUFFER_LENGTH];
  58. uint8_t ringbuffer_index;
  59. uint8_t row_identifier;
  60. uint8_t row_ringbuffer[RING_BUFFER_LENGTH];
  61. } UartDumpModel;
  62. // Function Prototypes
  63. CameraSuiteViewCamera* camera_suite_view_camera_alloc();
  64. View* camera_suite_view_camera_get_view(CameraSuiteViewCamera* camera_suite_static);
  65. void camera_suite_view_camera_free(CameraSuiteViewCamera* camera_suite_static);
  66. void camera_suite_view_camera_set_callback(
  67. CameraSuiteViewCamera* camera_suite_view_camera,
  68. CameraSuiteViewCameraCallback callback,
  69. void* context);