2018-06-23 04:11:05 -03:00
|
|
|
/*
|
|
|
|
* This file 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 file 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/>.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <AP_Param/AP_Param.h>
|
|
|
|
|
|
|
|
class AP_OSD_Backend;
|
|
|
|
|
2018-06-24 07:00:23 -03:00
|
|
|
#define AP_OSD_NUM_SCREENS 4
|
|
|
|
|
|
|
|
/*
|
|
|
|
class to hold one setting
|
|
|
|
*/
|
|
|
|
class AP_OSD_Setting {
|
|
|
|
public:
|
|
|
|
AP_Int8 enabled;
|
|
|
|
AP_Int8 xpos;
|
|
|
|
AP_Int8 ypos;
|
|
|
|
|
|
|
|
AP_OSD_Setting(bool enabled, uint8_t x, uint8_t y);
|
2018-06-25 18:26:21 -03:00
|
|
|
|
2018-06-24 07:00:23 -03:00
|
|
|
// User settable parameters
|
|
|
|
static const struct AP_Param::GroupInfo var_info[];
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
class to hold one screen of settings
|
|
|
|
*/
|
|
|
|
class AP_OSD_Screen {
|
|
|
|
public:
|
|
|
|
// constructor
|
|
|
|
AP_OSD_Screen();
|
2018-06-25 18:26:21 -03:00
|
|
|
|
2018-06-24 07:00:23 -03:00
|
|
|
void draw(void);
|
|
|
|
|
2018-06-25 18:26:21 -03:00
|
|
|
void set_backend(AP_OSD_Backend *_backend)
|
|
|
|
{
|
|
|
|
backend = _backend;
|
|
|
|
};
|
2018-06-24 07:00:23 -03:00
|
|
|
|
|
|
|
// User settable parameters
|
|
|
|
static const struct AP_Param::GroupInfo var_info[];
|
2018-06-24 07:45:58 -03:00
|
|
|
|
|
|
|
AP_Int8 enabled;
|
2018-06-25 18:25:42 -03:00
|
|
|
AP_Int16 channel_min;
|
|
|
|
AP_Int16 channel_max;
|
|
|
|
|
2018-06-24 07:00:23 -03:00
|
|
|
private:
|
|
|
|
AP_OSD_Backend *backend;
|
|
|
|
|
|
|
|
AP_OSD_Setting altitude{true, 1, 1};
|
|
|
|
AP_OSD_Setting bat_volt{true, 9, 1};
|
|
|
|
AP_OSD_Setting rssi{false, 0, 0};
|
|
|
|
AP_OSD_Setting current{true, 1, 2};
|
|
|
|
AP_OSD_Setting batused{true, 1, 3};
|
|
|
|
AP_OSD_Setting sats{true, 1, 4};
|
|
|
|
AP_OSD_Setting fltmode{true, 12, 14};
|
|
|
|
AP_OSD_Setting message{false, 0, 0};
|
2018-06-26 14:10:57 -03:00
|
|
|
AP_OSD_Setting gspeed{false, 0, 0};
|
2018-06-25 18:26:21 -03:00
|
|
|
|
2018-06-24 07:00:23 -03:00
|
|
|
void draw_altitude(uint8_t x, uint8_t y);
|
|
|
|
void draw_bat_volt(uint8_t x, uint8_t y);
|
|
|
|
void draw_rssi(uint8_t x, uint8_t y);
|
|
|
|
void draw_current(uint8_t x, uint8_t y);
|
|
|
|
void draw_batused(uint8_t x, uint8_t y);
|
|
|
|
void draw_sats(uint8_t x, uint8_t y);
|
|
|
|
void draw_fltmode(uint8_t x, uint8_t y);
|
|
|
|
void draw_message(uint8_t x, uint8_t y);
|
2018-06-26 14:10:57 -03:00
|
|
|
void draw_gspeed(uint8_t x, uint8_t y);
|
2018-06-24 07:00:23 -03:00
|
|
|
};
|
|
|
|
|
2018-06-23 04:11:05 -03:00
|
|
|
class AP_OSD {
|
|
|
|
public:
|
|
|
|
//constructor
|
|
|
|
AP_OSD();
|
|
|
|
|
|
|
|
/* Do not allow copies */
|
|
|
|
AP_OSD(const AP_OSD &other) = delete;
|
|
|
|
AP_OSD &operator=(const AP_OSD&) = delete;
|
|
|
|
|
|
|
|
// init - perform required initialisation
|
|
|
|
void init();
|
|
|
|
|
|
|
|
// User settable parameters
|
|
|
|
static const struct AP_Param::GroupInfo var_info[];
|
|
|
|
|
2018-06-24 07:00:23 -03:00
|
|
|
enum osd_types {
|
|
|
|
OSD_NONE=0,
|
|
|
|
OSD_MAX7456=1,
|
|
|
|
};
|
2018-06-25 18:26:21 -03:00
|
|
|
|
2018-06-24 07:00:23 -03:00
|
|
|
AP_Int8 osd_type;
|
2018-06-25 18:25:42 -03:00
|
|
|
AP_Int8 rc_channel;
|
2018-06-23 04:11:05 -03:00
|
|
|
|
2018-06-24 07:00:23 -03:00
|
|
|
AP_OSD_Screen screen[AP_OSD_NUM_SCREENS];
|
2018-06-23 04:11:05 -03:00
|
|
|
|
|
|
|
private:
|
|
|
|
void timer();
|
|
|
|
void update_osd();
|
2018-06-25 18:25:42 -03:00
|
|
|
void update_current_screen();
|
2018-06-23 04:11:05 -03:00
|
|
|
AP_OSD_Backend *backend;
|
|
|
|
uint32_t last_update_ms;
|
|
|
|
|
2018-06-24 07:00:23 -03:00
|
|
|
uint8_t current_screen;
|
2018-06-23 04:11:05 -03:00
|
|
|
};
|