camera_suite_view_camera.h 2.5 KB

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