gps_uart.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #pragma once
  2. #include <furi_hal.h>
  3. #include <notification/notification_messages.h>
  4. #include <momentum/momentum.h>
  5. #define RX_BUF_SIZE 1024
  6. #define UART_CH (momentum_settings.uart_nmea_channel)
  7. static const int gps_baudrates[6] = {4800, 9600, 19200, 38400, 57600, 115200};
  8. static int current_gps_baudrate = 1;
  9. typedef struct {
  10. bool valid;
  11. float latitude;
  12. float longitude;
  13. float speed;
  14. float course;
  15. float altitude;
  16. char altitude_units;
  17. int fix_quality;
  18. int satellites_tracked;
  19. int time_hours;
  20. int time_minutes;
  21. int time_seconds;
  22. } GpsStatus;
  23. typedef enum {
  24. KNOTS,
  25. KPH,
  26. MPH,
  27. INVALID
  28. } SpeedUnit;
  29. typedef enum {
  30. CHANGE_BAUDRATE,
  31. CHANGE_BACKLIGHT,
  32. CHANGE_DEEPSLEEP,
  33. CHANGE_SPEEDUNIT,
  34. NORMAL
  35. } ViewState;
  36. typedef struct {
  37. FuriMutex* mutex;
  38. FuriThread* thread;
  39. FuriStreamBuffer* rx_stream;
  40. uint8_t rx_buf[RX_BUF_SIZE];
  41. NotificationApp* notifications;
  42. uint32_t baudrate;
  43. bool backlight_on;
  44. bool deep_sleep_enabled;
  45. SpeedUnit speed_units;
  46. ViewState view_state;
  47. FuriHalSerialHandle* serial_handle;
  48. GpsStatus status;
  49. } GpsUart;
  50. void gps_uart_init_thread(GpsUart* gps_uart);
  51. void gps_uart_deinit_thread(GpsUart* gps_uart);
  52. GpsUart* gps_uart_enable();
  53. void gps_uart_disable(GpsUart* gps_uart);