camera_suite_view_camera.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. #pragma once
  2. #include <furi.h>
  3. #include <furi_hal.h>
  4. #include <furi_hal_serial_control.h>
  5. #include <furi_hal_serial.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. #ifdef xtreme_settings
  18. /**
  19. * Enable the following line for "Xtreme Firmware" & "Xtreme Apps" (Flipper-XFW).
  20. *
  21. * @see https://github.com/Flipper-XFW/Xtreme-Firmware
  22. * @see https://github.com/Flipper-XFW/Xtreme-Apps
  23. */
  24. #define UART_CH (xtreme_settings.uart_esp_channel)
  25. #elif momentum_settings
  26. /**
  27. * Enable the following line for "Momentum Firmware" & "Momentum Apps".
  28. *
  29. * @see https://github.com/Next-Flip/Momentum-Firmware
  30. * @see https://github.com/Next-Flip/Momentum-Apps
  31. */
  32. #define UART_CH (momentum_settings.uart_esp_channel)
  33. #else
  34. #define UART_CH (FuriHalSerialIdUsart)
  35. #endif
  36. #define BITMAP_HEADER_LENGTH 62
  37. #define FRAME_BIT_DEPTH 1
  38. #define FRAME_BUFFER_LENGTH 1024
  39. #define FRAME_HEIGHT 64
  40. #define FRAME_WIDTH 128
  41. #define HEADER_LENGTH 3 // 'Y', ':', and row identifier
  42. #define LAST_ROW_INDEX 1008
  43. #define RING_BUFFER_LENGTH 19
  44. #define ROW_BUFFER_LENGTH 16
  45. static const unsigned char bitmap_header[BITMAP_HEADER_LENGTH] = {
  46. 0x42, 0x4D, 0x3E, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3E, 0x00, 0x00, 0x00, 0x28, 0x00,
  47. 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00,
  48. 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  49. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x00};
  50. typedef enum {
  51. WorkerEventReserved = (1 << 0), // Reserved for StreamBuffer internal event
  52. WorkerEventStop = (1 << 1),
  53. WorkerEventRx = (1 << 2),
  54. } WorkerEventFlags;
  55. #define CAMERA_WORKER_EVENTS_MASK (WorkerEventStop | WorkerEventRx)
  56. // Forward declaration
  57. typedef void (*CameraSuiteViewCameraCallback)(CameraSuiteCustomEvent event, void* context);
  58. typedef struct CameraSuiteViewCamera {
  59. CameraSuiteViewCameraCallback callback;
  60. FuriStreamBuffer* camera_rx_stream;
  61. FuriHalSerialHandle* serial_handle;
  62. FuriThread* camera_worker_thread;
  63. NotificationApp* notification;
  64. View* view;
  65. void* context;
  66. } CameraSuiteViewCamera;
  67. typedef struct UartDumpModel {
  68. bool is_dithering_enabled;
  69. bool is_initialized;
  70. bool is_inverted;
  71. int rotation_angle;
  72. uint32_t orientation;
  73. uint8_t pixels[FRAME_BUFFER_LENGTH];
  74. uint8_t ringbuffer_index;
  75. uint8_t row_identifier;
  76. uint8_t row_ringbuffer[RING_BUFFER_LENGTH];
  77. } UartDumpModel;
  78. // Function Prototypes
  79. CameraSuiteViewCamera* camera_suite_view_camera_alloc();
  80. View* camera_suite_view_camera_get_view(CameraSuiteViewCamera* camera_suite_static);
  81. void camera_suite_view_camera_free(CameraSuiteViewCamera* camera_suite_static);
  82. void camera_suite_view_camera_set_callback(
  83. CameraSuiteViewCamera* camera_suite_view_camera,
  84. CameraSuiteViewCameraCallback callback,
  85. void* context);