mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-04-24 03:29:57 -07:00
SubGHz: Rework GPS as plugin, fix VGM (#5)
- Streamlined atomic init and deinit - Load from plugin into RAM dynamically - Don't attempt load if VGM / Expansion is connected - Deduplicated some code, cleaned up some other bits
This commit is contained in:
@@ -1,25 +1,18 @@
|
||||
#include <furi_hal.h>
|
||||
#include <momentum/momentum.h>
|
||||
#include <expansion/expansion.h>
|
||||
#pragma once
|
||||
|
||||
#define UART_CH (momentum_settings.uart_nmea_channel)
|
||||
#include <furi_hal.h>
|
||||
#include <flipper_application/flipper_application.h>
|
||||
|
||||
#define RX_BUF_SIZE 1024
|
||||
|
||||
typedef enum {
|
||||
WorkerEvtStop = (1 << 0),
|
||||
WorkerEvtRxDone = (1 << 1),
|
||||
} WorkerEvtFlags;
|
||||
typedef struct SubGhzGPS SubGhzGPS;
|
||||
|
||||
#define WORKER_ALL_RX_EVENTS (WorkerEvtStop | WorkerEvtRxDone)
|
||||
|
||||
typedef struct {
|
||||
Expansion* expansion;
|
||||
struct SubGhzGPS {
|
||||
FlipperApplication* plugin_app;
|
||||
FuriThread* thread;
|
||||
FuriStreamBuffer* rx_stream;
|
||||
uint8_t rx_buf[RX_BUF_SIZE];
|
||||
FuriHalSerialHandle* serial_handle;
|
||||
|
||||
FuriTimer* timer;
|
||||
|
||||
float latitude;
|
||||
@@ -28,73 +21,40 @@ typedef struct {
|
||||
uint8_t fix_second;
|
||||
uint8_t fix_minute;
|
||||
uint8_t fix_hour;
|
||||
} SubGhzGPS;
|
||||
|
||||
/**
|
||||
* Deinitialize SubGhzGPS object
|
||||
* To be used by plugin handler
|
||||
*
|
||||
* @param subghz_gps SubGhzGPS object
|
||||
* @return void
|
||||
*/
|
||||
void (*deinit)(SubGhzGPS* subghz_gps);
|
||||
|
||||
/**
|
||||
* Get description for signal info
|
||||
*
|
||||
* @param subghz_gps SubGhzGPS object
|
||||
* @param descr Output string
|
||||
* @param latitude Latitude
|
||||
* @param longitude Longitude
|
||||
* @return void
|
||||
*/
|
||||
void (*get_descr)(SubGhzGPS* subghz_gps, FuriString* descr, float latitude, float longitude);
|
||||
};
|
||||
|
||||
/**
|
||||
* Initialize SubGhzGPS object
|
||||
*
|
||||
* Initialize SubGhzGPS plugin
|
||||
* Fails and returns NULL if Expansion is connected
|
||||
*
|
||||
* @return SubGhzGPS* SubGhzGPS object
|
||||
*/
|
||||
SubGhzGPS* subghz_gps_init();
|
||||
SubGhzGPS* subghz_gps_plugin_init();
|
||||
|
||||
/**
|
||||
* Deinitialize SubGhzGPS object
|
||||
* Deinitialize SubGhzGPS plugin
|
||||
*
|
||||
* @param subghz_gps SubGhzGPS object
|
||||
* @return void
|
||||
*/
|
||||
void subghz_gps_deinit(SubGhzGPS* subghz_gps);
|
||||
|
||||
/**
|
||||
* Start GPS thread
|
||||
*
|
||||
* @param subghz_gps SubGhzGPS object
|
||||
* @return void
|
||||
*/
|
||||
void subghz_gps_start(SubGhzGPS* subghz_gps);
|
||||
|
||||
/**
|
||||
* Stop GPS thread
|
||||
*
|
||||
* @param subghz_gps SubGhzGPS object
|
||||
* @return void
|
||||
*/
|
||||
void subghz_gps_stop(SubGhzGPS* subghz_gps);
|
||||
|
||||
/**
|
||||
* Set baudrate for GPS
|
||||
*
|
||||
* @param baudrate Baudrate
|
||||
* @return void
|
||||
*/
|
||||
void subghz_gps_set_baudrate(SubGhzGPS* subghz_gps, uint32_t baudrate);
|
||||
|
||||
/**
|
||||
* Convert degree to radian
|
||||
*
|
||||
* @param deg Degree
|
||||
* @return double Radian
|
||||
*/
|
||||
double subghz_gps_deg2rad(double deg);
|
||||
|
||||
/**
|
||||
* Calculate distance between two coordinates
|
||||
*
|
||||
* @param lat1d Latitude 1
|
||||
* @param lon1d Longitude 1
|
||||
* @param lat2d Latitude 2
|
||||
* @param lon2d Longitude 2
|
||||
* @return double Distance in km
|
||||
*/
|
||||
double subghz_gps_calc_distance(double lat1d, double lon1d, double lat2d, double lon2d);
|
||||
|
||||
/**
|
||||
* Calculate angle between two coordinates
|
||||
*
|
||||
* @param lat1 Latitude 1
|
||||
* @param lon1 Longitude 1
|
||||
* @param lat2 Latitude 2
|
||||
* @param lon2 Longitude 2
|
||||
* @return double Angle in degree
|
||||
*/
|
||||
double subghz_gps_calc_angle(double lat1, double lon1, double lat2, double lon2);
|
||||
void subghz_gps_plugin_deinit(SubGhzGPS* subghz_gps);
|
||||
|
||||
Reference in New Issue
Block a user