2018-07-01 07:09:51 -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
|
|
|
|
|
|
|
|
#ifdef WITH_SITL_OSD
|
|
|
|
|
|
|
|
#include <AP_OSD/AP_OSD_Backend.h>
|
2018-07-01 20:35:18 -03:00
|
|
|
|
|
|
|
#ifdef HAVE_SFML_GRAPHICS_H
|
|
|
|
#include <SFML/Graphics.h>
|
|
|
|
#else
|
2018-07-01 07:09:51 -03:00
|
|
|
#include <SFML/Graphics.hpp>
|
2018-07-01 20:35:18 -03:00
|
|
|
#endif
|
2018-07-01 07:09:51 -03:00
|
|
|
|
2019-09-16 18:35:45 -03:00
|
|
|
class AP_OSD_SITL : public AP_OSD_Backend
|
|
|
|
{
|
2018-07-01 07:09:51 -03:00
|
|
|
|
|
|
|
public:
|
|
|
|
static AP_OSD_Backend *probe(AP_OSD &osd);
|
|
|
|
|
|
|
|
//draw given text to framebuffer
|
2018-07-11 19:13:44 -03:00
|
|
|
void write(uint8_t x, uint8_t y, const char* text) override;
|
2018-07-01 07:09:51 -03:00
|
|
|
|
2023-07-07 15:30:54 -03:00
|
|
|
//initialize display port and underlying hardware
|
2018-07-01 07:09:51 -03:00
|
|
|
bool init() override;
|
|
|
|
|
|
|
|
//flush framebuffer to screen
|
|
|
|
void flush() override;
|
|
|
|
|
|
|
|
//clear framebuffer
|
|
|
|
void clear() override;
|
|
|
|
|
2023-07-07 15:30:54 -03:00
|
|
|
bool is_compatible_with_backend_type(AP_OSD::osd_types type) const override {
|
|
|
|
switch(type) {
|
|
|
|
case AP_OSD::osd_types::OSD_MAX7456:
|
|
|
|
case AP_OSD::osd_types::OSD_SITL:
|
|
|
|
return false;
|
|
|
|
case AP_OSD::osd_types::OSD_NONE:
|
|
|
|
case AP_OSD::osd_types::OSD_TXONLY:
|
|
|
|
case AP_OSD::osd_types::OSD_MSP:
|
|
|
|
case AP_OSD::osd_types::OSD_MSP_DISPLAYPORT:
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
AP_OSD::osd_types get_backend_type() const override {
|
|
|
|
return AP_OSD::osd_types::OSD_SITL;
|
|
|
|
}
|
2018-07-01 07:09:51 -03:00
|
|
|
private:
|
|
|
|
//constructor
|
|
|
|
AP_OSD_SITL(AP_OSD &osd);
|
|
|
|
|
|
|
|
sf::RenderWindow *w;
|
|
|
|
|
|
|
|
sf::Texture font[256];
|
2018-07-09 07:48:59 -03:00
|
|
|
uint8_t last_font;
|
2018-07-01 07:09:51 -03:00
|
|
|
|
|
|
|
// setup to match MAX7456 layout
|
|
|
|
static const uint8_t char_width = 12;
|
|
|
|
static const uint8_t char_height = 18;
|
|
|
|
static const uint8_t video_lines = 16; // PAL
|
|
|
|
static const uint8_t video_cols = 30;
|
2018-07-04 18:42:15 -03:00
|
|
|
static const uint8_t char_spacing = 0;
|
2018-07-01 07:09:51 -03:00
|
|
|
|
|
|
|
// scaling factor to make it easier to read
|
|
|
|
static const uint8_t char_scale = 2;
|
2018-07-08 19:32:29 -03:00
|
|
|
|
2018-07-01 07:09:51 -03:00
|
|
|
uint8_t buffer[video_lines][video_cols];
|
|
|
|
|
2018-07-04 06:30:30 -03:00
|
|
|
void update_thread();
|
|
|
|
static void *update_thread_start(void *obj);
|
2018-07-01 07:09:51 -03:00
|
|
|
void load_font();
|
2018-07-04 06:30:30 -03:00
|
|
|
|
|
|
|
pthread_t thread;
|
2018-10-11 20:35:04 -03:00
|
|
|
HAL_Semaphore mutex;
|
2018-07-04 06:30:30 -03:00
|
|
|
uint32_t counter;
|
|
|
|
uint32_t last_counter;
|
2018-07-01 07:09:51 -03:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // WITH_SITL_OSD
|