uart_echo.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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_serial_control.h>
  8. #include <furi_hal_serial.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. FuriHalSerialHandle* serial_handle;
  22. bool initialized;
  23. } UartEchoApp;
  24. typedef struct {
  25. FuriString* text;
  26. } ListElement;
  27. struct UartDumpModel {
  28. ListElement* list[LINES_ON_SCREEN];
  29. uint8_t line;
  30. char last_char;
  31. bool escape;
  32. };
  33. typedef enum {
  34. WorkerEventReserved = (1 << 0), // Reserved for StreamBuffer internal event
  35. WorkerEventStop = (1 << 1),
  36. WorkerEventRx = (1 << 2),
  37. } WorkerEventFlags;
  38. #define WORKER_EVENTS_MASK (WorkerEventStop | WorkerEventRx)
  39. const NotificationSequence sequence_notification = {
  40. &message_display_backlight_on,
  41. &message_green_255,
  42. &message_delay_10,
  43. NULL,
  44. };