camera_suite_view_camera.h 2.8 KB

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