uart_echo.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. 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. FuriHalSerialHandle* serial_handle;
  38. bool initialized;
  39. } UartEchoApp;
  40. typedef struct {
  41. FuriString* text;
  42. } ListElement;
  43. struct UartDumpModel {
  44. ListElement* list[LINES_ON_SCREEN];
  45. uint8_t line;
  46. char last_char;
  47. bool escape;
  48. };
  49. typedef enum {
  50. WorkerEventReserved = (1 << 0), // Reserved for StreamBuffer internal event
  51. WorkerEventStop = (1 << 1),
  52. WorkerEventRx = (1 << 2),
  53. } WorkerEventFlags;
  54. #define WORKER_EVENTS_MASK (WorkerEventStop | WorkerEventRx)
  55. /*const NotificationSequence sequence_notification = {
  56. &message_display_backlight_on,
  57. &message_green_255,
  58. &message_delay_10,
  59. NULL,
  60. };*/