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_OSD/AP_OSD_Backend.h>
|
2018-06-24 08:17:05 -03:00
|
|
|
#include <AP_Common/Bitmask.h>
|
2018-06-23 04:11:05 -03:00
|
|
|
|
2020-10-19 17:30:08 -03:00
|
|
|
#if HAL_WITH_OSD_BITMAP
|
2019-09-16 18:35:45 -03:00
|
|
|
class AP_OSD_MAX7456 : public AP_OSD_Backend
|
|
|
|
{
|
2018-06-23 04:11:05 -03:00
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
static AP_OSD_Backend *probe(AP_OSD &osd, AP_HAL::OwnPtr<AP_HAL::Device> dev);
|
|
|
|
|
|
|
|
//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-06-23 04:11:05 -03:00
|
|
|
|
|
|
|
//initilize display port and underlying hardware
|
2018-06-24 07:45:58 -03:00
|
|
|
bool init() override;
|
2018-06-23 04:11:05 -03:00
|
|
|
|
|
|
|
//flush framebuffer to screen
|
2018-06-24 07:45:58 -03:00
|
|
|
void flush() override;
|
2018-06-23 04:11:05 -03:00
|
|
|
|
|
|
|
//clear framebuffer
|
2018-06-24 07:45:58 -03:00
|
|
|
void clear() override;
|
2018-06-23 04:11:05 -03:00
|
|
|
|
2020-07-20 07:48:37 -03:00
|
|
|
// return a correction factor used to display angles correctly
|
2023-07-07 15:30:54 -03:00
|
|
|
float get_aspect_ratio_correction() const override;
|
|
|
|
|
|
|
|
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_MAX7456;
|
|
|
|
}
|
2020-07-20 07:48:37 -03:00
|
|
|
|
2018-06-23 04:11:05 -03:00
|
|
|
private:
|
|
|
|
|
|
|
|
//constructor
|
|
|
|
AP_OSD_MAX7456(AP_OSD &osd, AP_HAL::OwnPtr<AP_HAL::Device> dev);
|
|
|
|
|
|
|
|
void buffer_add_cmd(uint8_t reg, uint8_t arg);
|
|
|
|
|
|
|
|
bool update_font();
|
|
|
|
|
2018-06-25 18:22:11 -03:00
|
|
|
bool check_font_char(uint8_t chr, const uint8_t* font_data);
|
|
|
|
|
|
|
|
bool update_font_char(uint8_t chr, const uint8_t* font_data);
|
|
|
|
|
2018-06-23 04:11:05 -03:00
|
|
|
void check_reinit();
|
|
|
|
|
|
|
|
void reinit();
|
|
|
|
|
|
|
|
void transfer_frame();
|
|
|
|
|
2018-07-11 19:13:44 -03:00
|
|
|
bool is_dirty(uint8_t x, uint8_t y);
|
|
|
|
|
2018-06-23 04:11:05 -03:00
|
|
|
AP_HAL::OwnPtr<AP_HAL::Device> _dev;
|
|
|
|
|
|
|
|
uint8_t video_signal_reg;
|
|
|
|
bool initialized;
|
2018-07-09 06:30:21 -03:00
|
|
|
uint8_t last_font;
|
2018-07-09 19:50:30 -03:00
|
|
|
int8_t last_v_offset;
|
|
|
|
int8_t last_h_offset;
|
2018-06-23 04:11:05 -03:00
|
|
|
|
2018-06-24 08:17:05 -03:00
|
|
|
static const uint8_t video_lines_ntsc = 13;
|
|
|
|
static const uint8_t video_lines_pal = 16;
|
|
|
|
static const uint8_t video_columns = 30;
|
2018-07-09 17:51:15 -03:00
|
|
|
static const uint16_t spi_buffer_size = 512;
|
2018-06-25 18:26:21 -03:00
|
|
|
|
2018-06-24 08:17:05 -03:00
|
|
|
uint8_t frame[video_lines_pal][video_columns];
|
2018-06-23 04:11:05 -03:00
|
|
|
|
|
|
|
//frame already transfered to max
|
|
|
|
//used to optimize number of characters updated
|
2018-06-24 08:17:05 -03:00
|
|
|
uint8_t shadow_frame[video_lines_pal][video_columns];
|
2018-06-23 04:11:05 -03:00
|
|
|
|
2018-06-24 07:54:25 -03:00
|
|
|
uint8_t buffer[spi_buffer_size];
|
2018-06-23 04:11:05 -03:00
|
|
|
int buffer_offset;
|
|
|
|
|
|
|
|
uint32_t last_signal_check;
|
|
|
|
uint32_t video_detect_time;
|
|
|
|
|
2018-06-24 08:17:05 -03:00
|
|
|
uint16_t video_lines;
|
2018-06-23 04:11:05 -03:00
|
|
|
};
|
2020-10-19 17:30:08 -03:00
|
|
|
#endif // HAL_WITH_OSD_BITMAP
|