gps_uart.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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 { KNOTS, KPH, MPH, INVALID } SpeedUnit;
  24. typedef enum {
  25. CHANGE_BAUDRATE,
  26. CHANGE_BACKLIGHT,
  27. CHANGE_DEEPSLEEP,
  28. CHANGE_SPEEDUNIT,
  29. NORMAL
  30. } ViewState;
  31. typedef struct {
  32. FuriMutex* mutex;
  33. FuriThread* thread;
  34. FuriStreamBuffer* rx_stream;
  35. uint8_t rx_buf[RX_BUF_SIZE];
  36. NotificationApp* notifications;
  37. uint32_t baudrate;
  38. bool backlight_on;
  39. bool deep_sleep_enabled;
  40. SpeedUnit speed_units;
  41. ViewState view_state;
  42. FuriHalSerialHandle* serial_handle;
  43. GpsStatus status;
  44. } GpsUart;
  45. void gps_uart_init_thread(GpsUart* gps_uart);
  46. void gps_uart_deinit_thread(GpsUart* gps_uart);
  47. GpsUart* gps_uart_enable();
  48. void gps_uart_disable(GpsUart* gps_uart);