Line data Source code
1 : #pragma once 2 : 3 : #include "AP_Frsky_Backend.h" 4 : 5 : #if AP_FRSKY_SPORT_TELEM_ENABLED 6 : 7 : class AP_Frsky_SPort : public AP_Frsky_Backend 8 : { 9 : 10 : public: 11 : 12 4 : AP_Frsky_SPort(AP_HAL::UARTDriver *port) : AP_Frsky_Backend(port) { 13 4 : singleton = this; 14 4 : } 15 : 16 : /* Do not allow copies */ 17 : CLASS_NO_COPY(AP_Frsky_SPort); 18 : 19 : void send() override; 20 : // send an sport packet by responding to the specified polled sensor 21 : bool sport_telemetry_push(const uint8_t sensor, const uint8_t frame, const uint16_t appid, const int32_t data); 22 : // utility method to pack numbers in a compact size 23 : uint16_t prep_number(int32_t const number, const uint8_t digits, const uint8_t power); 24 : 25 0 : static AP_Frsky_SPort *get_singleton(void) { 26 0 : return singleton; 27 : } 28 : 29 : protected: 30 : 31 : void send_sport_frame(uint8_t frame, uint16_t appid, uint32_t data); 32 : 33 : struct { 34 : bool send_latitude; 35 : bool send_airspeed; // toggles 0x5005 between airspeed and groundspeed 36 : uint32_t gps_lng_sample; 37 : uint8_t new_byte; 38 : } _passthrough; 39 : 40 : uint32_t calc_gps_latlng(bool &send_latitude); 41 : static uint8_t calc_sensor_id(const uint8_t physical_id); 42 : 43 : struct { 44 : sport_packet_t packet; 45 : bool pending = false; 46 : HAL_Semaphore sem; 47 : } _sport_push_buffer; 48 : 49 : private: 50 : 51 : struct { 52 : bool sport_status; 53 : bool gps_refresh; 54 : bool vario_refresh; 55 : uint8_t fas_call; 56 : uint8_t gps_call; 57 : uint8_t vario_call; 58 : uint8_t various_call; 59 : uint8_t rpm_call; 60 : } _SPort; 61 : 62 : static AP_Frsky_SPort *singleton; 63 : 64 : }; 65 : 66 : namespace AP { 67 : AP_Frsky_SPort *frsky_sport(); 68 : }; 69 : 70 : #endif // AP_FRSKY_SPORT_TELEM_ENABLED