camera_suite_view_camera.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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. #define BITMAP_HEADER_LENGTH 62
  18. #define FRAME_BIT_DEPTH 1
  19. #define FRAME_BUFFER_LENGTH 1024
  20. #define FRAME_HEIGHT 64
  21. #define FRAME_WIDTH 128
  22. #define HEADER_LENGTH 3 // 'Y', ':', and row identifier
  23. #define LAST_ROW_INDEX 1008
  24. #define RING_BUFFER_LENGTH 19
  25. #define ROW_BUFFER_LENGTH 16
  26. static const unsigned char bitmap_header[BITMAP_HEADER_LENGTH] = {
  27. 0x42, 0x4D, 0x3E, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3E, 0x00, 0x00, 0x00, 0x28, 0x00,
  28. 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00,
  29. 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  30. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x00};
  31. extern const Icon I_DolphinCommon_56x48;
  32. typedef enum {
  33. WorkerEventReserved = (1 << 0), // Reserved for StreamBuffer internal event
  34. WorkerEventStop = (1 << 1),
  35. WorkerEventRx = (1 << 2),
  36. } WorkerEventFlags;
  37. #define WORKER_EVENTS_MASK (WorkerEventStop | WorkerEventRx)
  38. // Forward declaration
  39. typedef void (*CameraSuiteViewCameraCallback)(CameraSuiteCustomEvent event, void* context);
  40. typedef struct CameraSuiteViewCamera {
  41. CameraSuiteViewCameraCallback callback;
  42. FuriStreamBuffer* rx_stream;
  43. FuriThread* worker_thread;
  44. View* view;
  45. void* context;
  46. } CameraSuiteViewCamera;
  47. typedef struct UartDumpModel {
  48. bool initialized;
  49. bool 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. void camera_suite_view_camera_free(CameraSuiteViewCamera* camera_suite_static);
  60. View* camera_suite_view_camera_get_view(CameraSuiteViewCamera* camera_suite_static);
  61. void camera_suite_view_camera_set_callback(
  62. CameraSuiteViewCamera* camera_suite_view_camera,
  63. CameraSuiteViewCameraCallback callback,
  64. void* context);