camera.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. // TODO
  2. // (DONE) Fix performance when not being charged
  3. // (DONE) Add UART command parsing to Esp32
  4. // (DONE) Prepare application and icon on github
  5. // (DONE) Write snapshots to SD card
  6. // 5. Set a constant refresh rate to the Flipper's display
  7. // 6. Emulate grayscale
  8. // 7. Photo browser app
  9. #include <furi.h>
  10. #include <furi_hal.h>
  11. #include <gui/gui.h>
  12. #include <gui/icon_i.h>
  13. #include <notification/notification.h>
  14. #include <notification/notification_messages.h>
  15. #include <gui/elements.h>
  16. #include <furi_hal_uart.h>
  17. #include <furi_hal_console.h>
  18. #include <gui/view_dispatcher.h>
  19. #include <gui/modules/dialog_ex.h>
  20. #include <storage/filesystem_api_defines.h>
  21. #include <storage/storage.h>
  22. #include <assets_icons.h>
  23. #define THREAD_ALLOC 2048
  24. #define FRAME_WIDTH 128
  25. #define FRAME_HEIGTH 64
  26. #define FRAME_BIT_DEPTH 1
  27. #define FRAME_BUFFER_LENGTH \
  28. (FRAME_WIDTH * FRAME_HEIGTH * FRAME_BIT_DEPTH / 8) // 128*64*1 / 8 = 1024
  29. #define ROW_BUFFER_LENGTH (FRAME_WIDTH / 8) // 128/8 = 16
  30. #define LAST_ROW_INDEX (FRAME_BUFFER_LENGTH - ROW_BUFFER_LENGTH) // 1024 - 16 = 1008
  31. #define RING_BUFFER_LENGTH (ROW_BUFFER_LENGTH + 3) // ROW_BUFFER_LENGTH + Header => 16 + 3 = 19
  32. #define BITMAP_HEADER_LENGTH 62
  33. #define IMAGE_FILE_DIRECTORY_PATH EXT_PATH("DCIM")
  34. static const unsigned char bitmap_header[BITMAP_HEADER_LENGTH] = {
  35. 0x42, 0x4D, 0x3E, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3E, 0x00, 0x00, 0x00, 0x28, 0x00,
  36. 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00,
  37. 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  38. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x00};
  39. typedef struct UartDumpModel UartDumpModel;
  40. typedef struct {
  41. Gui* gui;
  42. NotificationApp* notification;
  43. ViewDispatcher* view_dispatcher;
  44. View* view;
  45. FuriThread* worker_thread;
  46. FuriStreamBuffer* rx_stream;
  47. } UartEchoApp;
  48. struct UartDumpModel {
  49. uint8_t pixels[FRAME_BUFFER_LENGTH];
  50. bool initialized;
  51. //bool marauderInitialized;
  52. uint8_t row_ringbuffer[RING_BUFFER_LENGTH];
  53. uint8_t ringbuffer_index;
  54. };
  55. typedef enum {
  56. WorkerEventReserved = (1 << 0), // Reserved for StreamBuffer internal event
  57. WorkerEventStop = (1 << 1),
  58. WorkerEventRx = (1 << 2),
  59. } WorkerEventFlags;
  60. #define WORKER_EVENTS_MASK (WorkerEventStop | WorkerEventRx)
  61. const NotificationSequence sequence_notification = {
  62. &message_display_backlight_on,
  63. &message_delay_10,
  64. NULL,
  65. };