uart_echo.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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. bool initialized;
  22. } UartEchoApp;
  23. typedef struct {
  24. FuriString* text;
  25. } ListElement;
  26. struct UartDumpModel {
  27. ListElement* list[LINES_ON_SCREEN];
  28. uint8_t line;
  29. char last_char;
  30. bool escape;
  31. };
  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. const NotificationSequence sequence_notification = {
  39. &message_display_backlight_on,
  40. &message_green_255,
  41. &message_delay_10,
  42. NULL,
  43. };