mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-02-01 13:38:38 -04:00
AP_OSD: allow osd to be disabled
This commit is contained in:
parent
30878553d6
commit
a09c18386e
@ -163,8 +163,14 @@ const AP_Param::GroupInfo AP_OSD::var_info[] = {
|
||||
|
||||
extern const AP_HAL::HAL& hal;
|
||||
|
||||
// singleton instance
|
||||
AP_OSD *AP_OSD::_singleton;
|
||||
|
||||
AP_OSD::AP_OSD()
|
||||
{
|
||||
if (_singleton != nullptr) {
|
||||
AP_HAL::panic("AP_OSD must be singleton");
|
||||
}
|
||||
AP_Param::setup_object_defaults(this, var_info);
|
||||
// default first screen enabled
|
||||
screen[0].enabled = 1;
|
||||
@ -176,6 +182,7 @@ AP_OSD::AP_OSD()
|
||||
osd_type.set_default(HAL_OSD_TYPE_DEFAULT);
|
||||
#endif
|
||||
previous_pwm_screen = -1;
|
||||
_singleton = this;
|
||||
}
|
||||
|
||||
void AP_OSD::init()
|
||||
@ -226,11 +233,14 @@ void AP_OSD::osd_thread()
|
||||
void AP_OSD::update_osd()
|
||||
{
|
||||
backend->clear();
|
||||
stats();
|
||||
update_current_screen();
|
||||
|
||||
screen[current_screen].set_backend(backend);
|
||||
screen[current_screen].draw();
|
||||
if (!_disable) {
|
||||
stats();
|
||||
update_current_screen();
|
||||
|
||||
screen[current_screen].set_backend(backend);
|
||||
screen[current_screen].draw();
|
||||
}
|
||||
|
||||
backend->flush();
|
||||
}
|
||||
@ -386,3 +396,7 @@ void AP_OSD::set_nav_info(NavInfo &navinfo)
|
||||
// do this without a lock for now
|
||||
nav_info = navinfo;
|
||||
}
|
||||
|
||||
AP_OSD *AP::osd() {
|
||||
return AP_OSD::get_singleton();
|
||||
}
|
||||
|
@ -16,10 +16,15 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AP_HAL/AP_HAL.h>
|
||||
#include <AP_Param/AP_Param.h>
|
||||
#include <AP_Math/AP_Math.h>
|
||||
#include <AP_BLHeli/AP_BLHeli.h>
|
||||
|
||||
#ifndef OSD_ENABLED
|
||||
#define OSD_ENABLED 0
|
||||
#endif
|
||||
|
||||
class AP_OSD_Backend;
|
||||
|
||||
#define AP_OSD_NUM_SCREENS 4
|
||||
@ -196,6 +201,12 @@ public:
|
||||
AP_OSD(const AP_OSD &other) = delete;
|
||||
AP_OSD &operator=(const AP_OSD&) = delete;
|
||||
|
||||
// get singleton instance
|
||||
static AP_OSD *get_singleton()
|
||||
{
|
||||
return _singleton;
|
||||
}
|
||||
|
||||
// init - perform required initialisation
|
||||
void init();
|
||||
|
||||
@ -258,7 +269,14 @@ public:
|
||||
};
|
||||
|
||||
void set_nav_info(NavInfo &nav_info);
|
||||
|
||||
// disable the display
|
||||
void disable() {
|
||||
_disable = true;
|
||||
}
|
||||
// enable the display
|
||||
void enable() {
|
||||
_disable = false;
|
||||
}
|
||||
|
||||
private:
|
||||
void osd_thread();
|
||||
@ -278,6 +296,7 @@ private:
|
||||
int8_t pre_fs_screen;
|
||||
bool was_armed;
|
||||
bool was_failsafe;
|
||||
bool _disable;
|
||||
|
||||
uint32_t last_update_ms;
|
||||
float last_distance_m;
|
||||
@ -286,4 +305,11 @@ private:
|
||||
float max_speed_mps;
|
||||
float max_current_a;
|
||||
float avg_current_a;
|
||||
|
||||
static AP_OSD *_singleton;
|
||||
};
|
||||
|
||||
namespace AP
|
||||
{
|
||||
AP_OSD *osd();
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user