uart_echo.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #include <furi.h>
  2. #include <furi_hal.h>
  3. #include <gui/gui.h>
  4. #include <notification/notification.h>
  5. #include <notification/notification_messages.h>
  6. #include <gui/elements.h>
  7. #include <furi_hal_uart.h>
  8. #include <furi_hal_console.h>
  9. #include <gui/view_dispatcher.h>
  10. #include <gui/modules/dialog_ex.h>
  11. #define LINES_ON_SCREEN 6
  12. #define COLUMNS_ON_SCREEN 21
  13. typedef struct UartDumpModel UartDumpModel;
  14. typedef struct {
  15. Gui* gui;
  16. NotificationApp* notification;
  17. ViewDispatcher* view_dispatcher;
  18. View* view;
  19. FuriThread* worker_thread;
  20. FuriStreamBuffer* rx_stream;
  21. } UartEchoApp;
  22. typedef struct {
  23. FuriString* text;
  24. } ListElement;
  25. struct UartDumpModel {
  26. ListElement* list[LINES_ON_SCREEN];
  27. uint8_t line;
  28. char last_char;
  29. bool escape;
  30. };
  31. typedef enum {
  32. WorkerEventReserved = (1 << 0), // Reserved for StreamBuffer internal event
  33. WorkerEventStop = (1 << 1),
  34. WorkerEventRx = (1 << 2),
  35. } WorkerEventFlags;
  36. #define WORKER_EVENTS_MASK (WorkerEventStop | WorkerEventRx)
  37. const NotificationSequence sequence_notification = {
  38. &message_display_backlight_on,
  39. &message_green_255,
  40. &message_delay_10,
  41. NULL,
  42. };