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_HAL/HAL.h>
|
|
|
|
#include <AP_OSD/AP_OSD.h>
|
2020-11-12 20:03:37 -04:00
|
|
|
#include <AP_Filesystem/AP_Filesystem.h>
|
2018-06-23 04:11:05 -03:00
|
|
|
|
|
|
|
|
2019-09-16 18:35:45 -03:00
|
|
|
class AP_OSD_Backend
|
|
|
|
{
|
2018-06-23 04:11:05 -03:00
|
|
|
|
|
|
|
public:
|
|
|
|
//constructor
|
|
|
|
AP_OSD_Backend(AP_OSD &osd): _osd(osd) {};
|
|
|
|
|
|
|
|
//destructor
|
|
|
|
virtual ~AP_OSD_Backend(void) {}
|
|
|
|
|
|
|
|
//draw given text to framebuffer
|
2018-07-11 19:13:44 -03:00
|
|
|
virtual void write(uint8_t x, uint8_t y, const char* text) = 0;
|
2018-06-23 04:11:05 -03:00
|
|
|
|
|
|
|
//draw formatted text to framebuffer
|
2021-06-07 21:42:31 -03:00
|
|
|
virtual void write(uint8_t x, uint8_t y, bool blink, const char *fmt, ...) FMT_PRINTF(5, 6);
|
2018-06-23 04:11:05 -03:00
|
|
|
|
|
|
|
//initilize framebuffer and underlying hardware
|
|
|
|
virtual bool init() = 0;
|
|
|
|
|
|
|
|
//update screen
|
|
|
|
virtual void flush() = 0;
|
|
|
|
|
2020-07-20 07:48:37 -03:00
|
|
|
// return a correction factor used to display angles correctly
|
|
|
|
virtual float get_aspect_ratio_correction() const {return 1;}
|
|
|
|
|
2018-06-23 04:11:05 -03:00
|
|
|
//clear screen
|
2018-07-11 19:13:44 -03:00
|
|
|
//should match hw blink
|
|
|
|
virtual void clear()
|
|
|
|
{
|
|
|
|
blink_phase = (blink_phase+1)%4;
|
2018-06-23 04:11:05 -03:00
|
|
|
};
|
|
|
|
|
2018-07-08 19:32:29 -03:00
|
|
|
AP_OSD * get_osd()
|
|
|
|
{
|
|
|
|
return &_osd;
|
|
|
|
}
|
|
|
|
|
2018-06-23 04:11:05 -03:00
|
|
|
protected:
|
|
|
|
AP_OSD& _osd;
|
|
|
|
|
2018-07-09 05:08:47 -03:00
|
|
|
// get font choice
|
2018-07-11 19:13:44 -03:00
|
|
|
uint8_t get_font_num(void) const
|
|
|
|
{
|
|
|
|
return (uint8_t)_osd.font_num.get();
|
|
|
|
}
|
|
|
|
|
|
|
|
//check option
|
2021-02-01 12:26:32 -04:00
|
|
|
bool check_option(uint32_t option) const
|
2018-07-11 19:13:44 -03:00
|
|
|
{
|
|
|
|
return (_osd.options & option) != 0;
|
|
|
|
}
|
2018-07-09 05:08:47 -03:00
|
|
|
|
2020-11-12 20:03:37 -04:00
|
|
|
// load a font from sdcard or ROMFS
|
|
|
|
FileData *load_font_data(uint8_t font_num);
|
|
|
|
|
2018-07-11 19:13:44 -03:00
|
|
|
int8_t blink_phase;
|
2020-07-20 07:48:37 -03:00
|
|
|
|
|
|
|
enum vid_format {
|
|
|
|
FORMAT_UNKNOWN = 0,
|
|
|
|
FORMAT_NTSC = 1,
|
|
|
|
FORMAT_PAL = 2,
|
|
|
|
} _format;
|
2018-06-23 04:11:05 -03:00
|
|
|
};
|
|
|
|
|
|
|
|
|