camera_suite_view_camera.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. typedef struct UartDumpModel {
  39. bool initialized;
  40. int rotation_angle;
  41. uint8_t pixels[FRAME_BUFFER_LENGTH];
  42. uint8_t ringbuffer_index;
  43. uint8_t row_ringbuffer[RING_BUFFER_LENGTH];
  44. uint8_t row_identifier;
  45. } UartDumpModel;
  46. typedef struct CameraSuiteViewCamera CameraSuiteViewCamera;
  47. // Callback
  48. typedef void (*CameraSuiteViewCameraCallback)(CameraSuiteCustomEvent event, void* context);
  49. // Function Prototypes
  50. CameraSuiteViewCamera* camera_suite_view_camera_alloc();
  51. void camera_suite_view_camera_free(CameraSuiteViewCamera* camera_suite_static);
  52. View* camera_suite_view_camera_get_view(CameraSuiteViewCamera* camera_suite_static);
  53. void camera_suite_view_camera_set_callback(
  54. CameraSuiteViewCamera* camera_suite_view_camera,
  55. CameraSuiteViewCameraCallback callback,
  56. void* context);