uart_echo.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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. static const NotificationSequence sequence_alarm = {
  14. &message_display_backlight_on,
  15. &message_red_255,
  16. //&message_vibro_on,
  17. &message_note_d5,
  18. &message_delay_100,
  19. //&message_vibro_off,
  20. &message_sound_off,
  21. &message_note_b4,
  22. &message_delay_50,
  23. &message_sound_off,
  24. &message_display_backlight_off,
  25. //&message_red_0,
  26. //&message_delay_50,
  27. NULL,
  28. };
  29. typedef struct UartDumpModel UartDumpModel;
  30. typedef struct {
  31. Gui* gui;
  32. NotificationApp* notification;
  33. ViewDispatcher* view_dispatcher;
  34. View* view;
  35. FuriThread* worker_thread;
  36. FuriStreamBuffer* rx_stream;
  37. bool initialized;
  38. } UartEchoApp;
  39. typedef struct {
  40. FuriString* text;
  41. } ListElement;
  42. struct UartDumpModel {
  43. ListElement* list[LINES_ON_SCREEN];
  44. uint8_t line;
  45. char last_char;
  46. bool escape;
  47. };
  48. typedef enum {
  49. WorkerEventReserved = (1 << 0), // Reserved for StreamBuffer internal event
  50. WorkerEventStop = (1 << 1),
  51. WorkerEventRx = (1 << 2),
  52. } WorkerEventFlags;
  53. #define WORKER_EVENTS_MASK (WorkerEventStop | WorkerEventRx)
  54. /*const NotificationSequence sequence_notification = {
  55. &message_display_backlight_on,
  56. &message_green_255,
  57. &message_delay_10,
  58. NULL,
  59. };*/