gps_uart.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #pragma once
  2. #include <furi_hal.h>
  3. #include <notification/notification_messages.h>
  4. #include <xtreme.h>
  5. #define UART_CH \
  6. (xtreme_settings.uart_nmea_channel == UARTDefault ? FuriHalUartIdUSART1 : FuriHalUartIdLPUART1)
  7. #define RX_BUF_SIZE 1024
  8. static const int gps_baudrates[6] = {4800, 9600, 19200, 38400, 57600, 115200};
  9. static int current_gps_baudrate = 1;
  10. typedef struct {
  11. bool valid;
  12. float latitude;
  13. float longitude;
  14. float speed;
  15. float course;
  16. float altitude;
  17. char altitude_units;
  18. int fix_quality;
  19. int satellites_tracked;
  20. int time_hours;
  21. int time_minutes;
  22. int time_seconds;
  23. } GpsStatus;
  24. typedef enum { KNOTS, KPH, MPH, INVALID } SpeedUnit;
  25. typedef enum {
  26. CHANGE_BAUDRATE,
  27. CHANGE_BACKLIGHT,
  28. CHANGE_DEEPSLEEP,
  29. CHANGE_SPEEDUNIT,
  30. NORMAL
  31. } ViewState;
  32. typedef struct {
  33. FuriMutex* mutex;
  34. FuriThread* thread;
  35. FuriStreamBuffer* rx_stream;
  36. uint8_t rx_buf[RX_BUF_SIZE];
  37. NotificationApp* notifications;
  38. uint32_t baudrate;
  39. bool backlight_enabled;
  40. bool deep_sleep_enabled;
  41. SpeedUnit speed_units;
  42. ViewState view_state;
  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);