ardupilot/libraries/AP_OSD/AP_OSD_MAX7456.h

88 lines
2.3 KiB
C
Raw Normal View History

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>
#include <AP_Common/Bitmask.h>
2018-06-23 04:11:05 -03:00
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
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
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();
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();
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;
int8_t last_v_offset;
int8_t last_h_offset;
2018-06-23 04:11: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;
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
uint8_t shadow_frame[video_lines_pal][video_columns];
2018-06-23 04:11:05 -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;
uint16_t video_lines;
2018-06-23 04:11:05 -03:00
};