2020-08-04 17:38:43 -03:00
|
|
|
/*
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
/*
|
|
|
|
MSP version 1 and 2 protocol library, based on betaflight/iNav implementations
|
|
|
|
code by Alex Apostoli
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <AP_OSD/AP_OSD.h>
|
|
|
|
|
|
|
|
#include "AP_MSP_Telem_Backend.h"
|
|
|
|
|
|
|
|
#if HAL_MSP_ENABLED
|
|
|
|
|
|
|
|
#define MSP_MAX_INSTANCES 3
|
|
|
|
#define MSP_OSD_START 2048
|
|
|
|
#define MSP_OSD_STEP_X 1
|
|
|
|
#define MSP_OSD_STEP_Y 32
|
|
|
|
#define MSP_OSD_POS(osd_setting) (MSP_OSD_START + osd_setting->xpos*MSP_OSD_STEP_X + osd_setting->ypos*MSP_OSD_STEP_Y)
|
|
|
|
|
|
|
|
class AP_MSP
|
|
|
|
{
|
|
|
|
friend class AP_MSP_Telem_Generic;
|
|
|
|
friend class AP_MSP_Telem_DJI;
|
|
|
|
friend class AP_MSP_Telem_Backend;
|
2021-08-06 12:53:33 -03:00
|
|
|
#if HAL_WITH_MSP_DISPLAYPORT
|
|
|
|
friend class AP_MSP_Telem_DisplayPort;
|
|
|
|
friend class AP_OSD_MSP_DisplayPort;
|
|
|
|
#endif
|
2020-08-04 17:38:43 -03:00
|
|
|
public:
|
|
|
|
AP_MSP();
|
|
|
|
|
|
|
|
/* Do not allow copies */
|
2022-09-30 06:50:43 -03:00
|
|
|
CLASS_NO_COPY(AP_MSP);
|
2020-08-04 17:38:43 -03:00
|
|
|
|
|
|
|
// User settable parameters
|
|
|
|
static const struct AP_Param::GroupInfo var_info[];
|
|
|
|
|
|
|
|
// init - perform required initialisation
|
|
|
|
void init();
|
|
|
|
|
2021-09-06 11:07:39 -03:00
|
|
|
enum class Option : uint8_t {
|
|
|
|
TELEMETRY_MODE = 1U<<0,
|
|
|
|
TELEMETRY_DISABLE_DJI_WORKAROUNDS = 1U<<1,
|
|
|
|
DISPLAYPORT_BTFL_SYMBOLS = 1U<<2,
|
2021-08-06 12:53:33 -03:00
|
|
|
};
|
|
|
|
|
2021-09-06 11:07:39 -03:00
|
|
|
bool is_option_enabled(const Option option) const;
|
2021-08-06 12:53:33 -03:00
|
|
|
|
2020-08-04 17:38:43 -03:00
|
|
|
static AP_MSP *get_singleton(void)
|
|
|
|
{
|
|
|
|
return _singleton;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
AP_MSP_Telem_Backend *_backends[MSP_MAX_INSTANCES];
|
|
|
|
|
|
|
|
AP_Int8 _options;
|
|
|
|
AP_Int8 _cellcount;
|
|
|
|
|
|
|
|
// these are the osd items we support for MSP OSD
|
2020-09-01 04:55:36 -03:00
|
|
|
AP_OSD_Setting* _osd_item_settings[MSP::OSD_ITEM_COUNT];
|
|
|
|
MSP::osd_config_t _osd_config;
|
2020-08-04 17:38:43 -03:00
|
|
|
|
|
|
|
struct {
|
2021-09-06 11:07:39 -03:00
|
|
|
bool flashing_on; // OSD item flashing support @1.4Hz
|
|
|
|
bool slow_flashing_on; // OSD item flashing support @0.5H
|
2020-08-04 17:38:43 -03:00
|
|
|
uint8_t last_flight_mode = 255;
|
|
|
|
uint32_t last_flight_mode_change_ms;
|
|
|
|
bool flight_mode_focus; // do we need to steal focus from text messages
|
|
|
|
bool osd_initialized; // for one time osd initialization
|
|
|
|
uint8_t backend_count; // actual count of active bacends
|
2021-09-06 11:07:39 -03:00
|
|
|
uint8_t current_screen; // defaults to screen 0
|
2020-08-04 17:38:43 -03:00
|
|
|
} _msp_status;
|
|
|
|
|
|
|
|
bool init_backend(uint8_t backend_idx, AP_HAL::UARTDriver *uart, AP_SerialManager::SerialProtocol protocol);
|
2021-09-06 11:07:39 -03:00
|
|
|
void update_osd_item_settings();
|
2020-08-04 17:38:43 -03:00
|
|
|
void loop(void);
|
2021-08-06 12:53:33 -03:00
|
|
|
AP_MSP_Telem_Backend* find_protocol(const AP_SerialManager::SerialProtocol protocol) const;
|
2020-08-04 17:38:43 -03:00
|
|
|
|
|
|
|
static AP_MSP *_singleton;
|
|
|
|
};
|
|
|
|
|
|
|
|
namespace AP
|
|
|
|
{
|
|
|
|
AP_MSP *msp();
|
|
|
|
};
|
|
|
|
|
2020-09-01 04:55:36 -03:00
|
|
|
#endif //HAL_MSP_ENABLED
|