mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2024-12-03 11:24:10 +01:00
*float sprintf
*h/v deadbands
This commit is contained in:
parent
a3b9451bcd
commit
a9cfc4a0af
@ -16,15 +16,12 @@ int32_t osdgenInitialize(void);
|
|||||||
// Size of an array (num items.)
|
// Size of an array (num items.)
|
||||||
#define SIZEOF_ARRAY(x) (sizeof(x) / sizeof((x)[0]))
|
#define SIZEOF_ARRAY(x) (sizeof(x) / sizeof((x)[0]))
|
||||||
|
|
||||||
|
|
||||||
#define DISP_HEIGHT GRAPHICS_HEIGHT_REAL
|
|
||||||
#define DISP_WIDTH GRAPHICS_WIDTH_REAL
|
|
||||||
#define HUD_VSCALE_FLAG_CLEAR 1
|
#define HUD_VSCALE_FLAG_CLEAR 1
|
||||||
#define HUD_VSCALE_FLAG_NO_NEGATIVE 2
|
#define HUD_VSCALE_FLAG_NO_NEGATIVE 2
|
||||||
|
|
||||||
// Macros for computing addresses and bit positions.
|
// Macros for computing addresses and bit positions.
|
||||||
// NOTE: /16 in y is because we are addressing by word not byte.
|
// NOTE: /16 in y is because we are addressing by word not byte.
|
||||||
#define CALC_BUFF_ADDR(x, y) (((x) / 8) + ((y) * (DISP_WIDTH / 8)))
|
#define CALC_BUFF_ADDR(x, y) (((x) / 8) + ((y) * (GRAPHICS_WIDTH_REAL / 8)))
|
||||||
#define CALC_BIT_IN_WORD(x) ((x) & 7)
|
#define CALC_BIT_IN_WORD(x) ((x) & 7)
|
||||||
#define DEBUG_DELAY
|
#define DEBUG_DELAY
|
||||||
// Macro for writing a word with a mode (NAND = clear, OR = set, XOR = toggle)
|
// Macro for writing a word with a mode (NAND = clear, OR = set, XOR = toggle)
|
||||||
@ -108,14 +105,19 @@ struct FontDimensions
|
|||||||
#define MAX3(a, b, c) MAX(a, MAX(b, c))
|
#define MAX3(a, b, c) MAX(a, MAX(b, c))
|
||||||
#define MIN3(a, b, c) MIN(a, MIN(b, c))
|
#define MIN3(a, b, c) MIN(a, MIN(b, c))
|
||||||
|
|
||||||
|
// Apply DeadBand
|
||||||
|
#define APPLY_DEADBAND(x, y) { x = (x)+GRAPHICS_HDEADBAND; y=(y)+GRAPHICS_VDEADBAND; }
|
||||||
|
#define APPLY_VDEADBAND(y) ((y)+GRAPHICS_VDEADBAND)
|
||||||
|
#define APPLY_HDEADBAND(x) ((x)+GRAPHICS_HDEADBAND)
|
||||||
|
|
||||||
// Check if coordinates are valid. If not, return.
|
// Check if coordinates are valid. If not, return.
|
||||||
#define CHECK_COORDS(x, y) if(x < 0 || x >= DISP_WIDTH || y < 0 || y >= DISP_HEIGHT) return;
|
#define CHECK_COORDS(x, y) if(x < 0 || x >= GRAPHICS_WIDTH_REAL || y < 0 || y >= GRAPHICS_HEIGHT_REAL) return;
|
||||||
#define CHECK_COORD_X(x) if(x < 0 || x >= DISP_WIDTH) return;
|
#define CHECK_COORD_X(x) if(x < 0 || x >= GRAPHICS_WIDTH_REAL) return;
|
||||||
#define CHECK_COORD_Y(y) if(y < 0 || y >= DISP_HEIGHT) return;
|
#define CHECK_COORD_Y(y) if(y < 0 || y >= GRAPHICS_HEIGHT_REAL) return;
|
||||||
|
|
||||||
// Clip coordinates out of range.
|
// Clip coordinates out of range.
|
||||||
#define CLIP_COORD_X(x) { x = MAX(0, MIN(x, DISP_WIDTH)); }
|
#define CLIP_COORD_X(x) { x = MAX(0, MIN(x, GRAPHICS_WIDTH_REAL)); }
|
||||||
#define CLIP_COORD_Y(y) { y = MAX(0, MIN(y, DISP_HEIGHT)); }
|
#define CLIP_COORD_Y(y) { y = MAX(0, MIN(y, GRAPHICS_HEIGHT_REAL)); }
|
||||||
#define CLIP_COORDS(x, y) { CLIP_COORD_X(x); CLIP_COORD_Y(y); }
|
#define CLIP_COORDS(x, y) { CLIP_COORD_X(x); CLIP_COORD_Y(y); }
|
||||||
|
|
||||||
// Macro to swap two variables using XOR swap.
|
// Macro to swap two variables using XOR swap.
|
||||||
@ -124,7 +126,6 @@ struct FontDimensions
|
|||||||
|
|
||||||
// Line triggering
|
// Line triggering
|
||||||
#define LAST_LINE 312 //625/2 //PAL
|
#define LAST_LINE 312 //625/2 //PAL
|
||||||
#define UPDATE_LINE GRAPHICS_LINE+GRAPHICS_HEIGHT_REAL+1
|
|
||||||
//#define LAST_LINE 525/2 //NTSC
|
//#define LAST_LINE 525/2 //NTSC
|
||||||
|
|
||||||
// Global vars
|
// Global vars
|
||||||
|
@ -69,7 +69,7 @@ extern uint8_t *disp_buffer_level;
|
|||||||
extern uint8_t *disp_buffer_mask;
|
extern uint8_t *disp_buffer_mask;
|
||||||
|
|
||||||
|
|
||||||
TTime time;
|
TTime timex;
|
||||||
|
|
||||||
// ****************
|
// ****************
|
||||||
// Private functions
|
// Private functions
|
||||||
@ -114,67 +114,6 @@ struct splashEntry splash[3] = {
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// simple routines
|
|
||||||
/*
|
|
||||||
uint8_t getCharData(uint16_t charPos) {
|
|
||||||
if (charPos >= CHAR_ARRAY_OFFSET && charPos < CHAR_ARRAY_MAX) {
|
|
||||||
return (oem6x8[charPos - CHAR_ARRAY_OFFSET]);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return 0x00;
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
|
|
||||||
// prints text into draw_buffer_level, 8x2
|
|
||||||
/*uint8_t printTextFB(uint16_t x, uint16_t y, const char* str) {
|
|
||||||
uint8_t length = strlen(str);
|
|
||||||
if (x + length >= TEXT_LINE_MAX_CHARS) {
|
|
||||||
length = TEXT_LINE_MAX_CHARS;
|
|
||||||
}
|
|
||||||
for(uint8_t i = 0; i < TEXT_CHAR_HEIGHT; i++)
|
|
||||||
{
|
|
||||||
uint8_t c=0;
|
|
||||||
uint16_t charPos;
|
|
||||||
for(int j=0; j<length; j+=2)
|
|
||||||
{
|
|
||||||
uint16_t word=0;
|
|
||||||
charPos = str[j] * TEXT_CHAR_HEIGHT + i;
|
|
||||||
word = getCharData(charPos)<<8;
|
|
||||||
charPos = str[j+1] * TEXT_CHAR_HEIGHT + i;
|
|
||||||
word |= getCharData(charPos);
|
|
||||||
draw_buffer_level[((y+i)*GRAPHICS_WIDTH)+(x + c)] = word;
|
|
||||||
c++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return length;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t printText16(uint16_t x, uint16_t y, const char* str) {
|
|
||||||
|
|
||||||
uint8_t length = strlen(str);
|
|
||||||
|
|
||||||
for(int j=0; j<length; j++)
|
|
||||||
{
|
|
||||||
write_char16(str[j],12*j+x,y);
|
|
||||||
}
|
|
||||||
|
|
||||||
return length;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
uint8_t printCharFB(uint16_t ch, uint16_t x, uint16_t y) {
|
|
||||||
for(uint8_t i = 0; i < 18; i++)
|
|
||||||
{
|
|
||||||
uint8_t c=0;
|
|
||||||
draw_buffer_level[((y+i)*GRAPHICS_WIDTH)+(x+c)] = font_frame16x18[ch*18+i];
|
|
||||||
draw_buffer_mask[((y+i)*GRAPHICS_WIDTH)+(x+c)] = font_mask16x18[ch*18+i];
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
uint16_t mirror(uint16_t source)
|
uint16_t mirror(uint16_t source)
|
||||||
{
|
{
|
||||||
int result = ((source & 0x8000) >> 7) | ((source & 0x4000) >> 5) |
|
int result = ((source & 0x8000) >> 7) | ((source & 0x4000) >> 5) |
|
||||||
@ -195,6 +134,10 @@ void clearGraphics() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void copyimage(uint16_t offsetx, uint16_t offsety, int image) {
|
void copyimage(uint16_t offsetx, uint16_t offsety, int image) {
|
||||||
|
//check top/left position
|
||||||
|
if (!validPos(offsetx, offsety)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
struct splashEntry splash_info;
|
struct splashEntry splash_info;
|
||||||
splash_info = splash[image];
|
splash_info = splash[image];
|
||||||
offsetx=offsetx/8;
|
offsetx=offsetx/8;
|
||||||
@ -207,7 +150,7 @@ void copyimage(uint16_t offsetx, uint16_t offsety, int image) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint8_t validPos(uint16_t x, uint16_t y) {
|
uint8_t validPos(uint16_t x, uint16_t y) {
|
||||||
if (x >= GRAPHICS_WIDTH_REAL || y >= GRAPHICS_HEIGHT) {
|
if ( x < GRAPHICS_HDEADBAND || x >= GRAPHICS_WIDTH_REAL || y >= GRAPHICS_HEIGHT_REAL) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
@ -634,7 +577,7 @@ void write_vline(uint8_t *buff, unsigned int x, unsigned int y0, unsigned int y1
|
|||||||
uint16_t mask = 1 << (7 - bitnum);
|
uint16_t mask = 1 << (7 - bitnum);
|
||||||
/* Run from addr0 to addr1 placing pixels. Increment by the number
|
/* Run from addr0 to addr1 placing pixels. Increment by the number
|
||||||
* of words n each graphics line. */
|
* of words n each graphics line. */
|
||||||
for(a = addr0; a <= addr1; a += DISP_WIDTH / 8)
|
for(a = addr0; a <= addr1; a += GRAPHICS_WIDTH_REAL / 8)
|
||||||
{
|
{
|
||||||
WRITE_WORD_MODE(buff, a, mask, mode);
|
WRITE_WORD_MODE(buff, a, mask, mode);
|
||||||
}
|
}
|
||||||
@ -721,7 +664,7 @@ void write_filled_rectangle(uint8_t *buff, unsigned int x, unsigned int y, unsig
|
|||||||
while(height--)
|
while(height--)
|
||||||
{
|
{
|
||||||
WRITE_WORD_MODE(buff, addr0, mask, mode);
|
WRITE_WORD_MODE(buff, addr0, mask, mode);
|
||||||
addr0 += DISP_WIDTH / 8;
|
addr0 += GRAPHICS_WIDTH_REAL / 8;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Otherwise we need to write the edges and then the middle repeatedly.
|
// Otherwise we need to write the edges and then the middle repeatedly.
|
||||||
@ -737,8 +680,8 @@ void write_filled_rectangle(uint8_t *buff, unsigned int x, unsigned int y, unsig
|
|||||||
{
|
{
|
||||||
WRITE_WORD_MODE(buff, addr0, mask_l, mode);
|
WRITE_WORD_MODE(buff, addr0, mask_l, mode);
|
||||||
WRITE_WORD_MODE(buff, addr1, mask_r, mode);
|
WRITE_WORD_MODE(buff, addr1, mask_r, mode);
|
||||||
addr0 += DISP_WIDTH / 8;
|
addr0 += GRAPHICS_WIDTH_REAL / 8;
|
||||||
addr1 += DISP_WIDTH / 8;
|
addr1 += GRAPHICS_WIDTH_REAL / 8;
|
||||||
yy++;
|
yy++;
|
||||||
}
|
}
|
||||||
// Now write 0xffff words from start+1 to end-1 for each row.
|
// Now write 0xffff words from start+1 to end-1 for each row.
|
||||||
@ -751,8 +694,8 @@ void write_filled_rectangle(uint8_t *buff, unsigned int x, unsigned int y, unsig
|
|||||||
{
|
{
|
||||||
WRITE_WORD_MODE(buff, i, 0xff, mode);
|
WRITE_WORD_MODE(buff, i, 0xff, mode);
|
||||||
}
|
}
|
||||||
addr0 += DISP_WIDTH / 8;
|
addr0 += GRAPHICS_WIDTH_REAL / 8;
|
||||||
addr1 += DISP_WIDTH / 8;
|
addr1 += GRAPHICS_WIDTH_REAL / 8;
|
||||||
yy++;
|
yy++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1276,7 +1219,7 @@ void write_char16(char ch, unsigned int x, unsigned int y, int font)
|
|||||||
// wide for now. Support for large characters may be added in future.
|
// wide for now. Support for large characters may be added in future.
|
||||||
{
|
{
|
||||||
// Ensure we don't overflow.
|
// Ensure we don't overflow.
|
||||||
if(x + wbit > DISP_WIDTH)
|
if(x + wbit > GRAPHICS_WIDTH_REAL)
|
||||||
return;
|
return;
|
||||||
// Load data pointer.
|
// Load data pointer.
|
||||||
row = ch * font_info.height;
|
row = ch * font_info.height;
|
||||||
@ -1290,7 +1233,7 @@ void write_char16(char ch, unsigned int x, unsigned int y, int font)
|
|||||||
write_word_misaligned_OR(draw_buffer_mask, font_mask12x18[row] << xshift, addr, wbit);
|
write_word_misaligned_OR(draw_buffer_mask, font_mask12x18[row] << xshift, addr, wbit);
|
||||||
else
|
else
|
||||||
write_word_misaligned_OR(draw_buffer_mask, font_mask8x10[row] << xshift, addr, wbit);
|
write_word_misaligned_OR(draw_buffer_mask, font_mask8x10[row] << xshift, addr, wbit);
|
||||||
addr += DISP_WIDTH / 8;
|
addr += GRAPHICS_WIDTH_REAL / 8;
|
||||||
row++;
|
row++;
|
||||||
}
|
}
|
||||||
// Level bits are more complicated. We need to set or clear
|
// Level bits are more complicated. We need to set or clear
|
||||||
@ -1319,7 +1262,7 @@ void write_char16(char ch, unsigned int x, unsigned int y, int font)
|
|||||||
// If we're not bold write the AND mask.
|
// If we're not bold write the AND mask.
|
||||||
//if(!(flags & FONT_BOLD))
|
//if(!(flags & FONT_BOLD))
|
||||||
write_word_misaligned_NAND(draw_buffer_level, and_mask, addr, wbit);
|
write_word_misaligned_NAND(draw_buffer_level, and_mask, addr, wbit);
|
||||||
addr += DISP_WIDTH / 8;
|
addr += GRAPHICS_WIDTH_REAL / 8;
|
||||||
row++;
|
row++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1360,7 +1303,7 @@ void write_char(char ch, unsigned int x, unsigned int y, int flags, int font)
|
|||||||
if(font_info.width <= 8)
|
if(font_info.width <= 8)
|
||||||
{
|
{
|
||||||
// Ensure we don't overflow.
|
// Ensure we don't overflow.
|
||||||
if(x + wbit > DISP_WIDTH)
|
if(x + wbit > GRAPHICS_WIDTH_REAL)
|
||||||
return;
|
return;
|
||||||
// Load data pointer.
|
// Load data pointer.
|
||||||
row = lookup * font_info.height * 2;
|
row = lookup * font_info.height * 2;
|
||||||
@ -1371,7 +1314,7 @@ void write_char(char ch, unsigned int x, unsigned int y, int flags, int font)
|
|||||||
for(yy = y; yy < y + font_info.height; yy++)
|
for(yy = y; yy < y + font_info.height; yy++)
|
||||||
{
|
{
|
||||||
write_word_misaligned_OR(draw_buffer_mask, font_info.data[row] << xshift, addr, wbit);
|
write_word_misaligned_OR(draw_buffer_mask, font_info.data[row] << xshift, addr, wbit);
|
||||||
addr += DISP_WIDTH / 8;
|
addr += GRAPHICS_WIDTH_REAL / 8;
|
||||||
row++;
|
row++;
|
||||||
}
|
}
|
||||||
// Level bits are more complicated. We need to set or clear
|
// Level bits are more complicated. We need to set or clear
|
||||||
@ -1391,7 +1334,7 @@ void write_char(char ch, unsigned int x, unsigned int y, int flags, int font)
|
|||||||
// If we're not bold write the AND mask.
|
// If we're not bold write the AND mask.
|
||||||
//if(!(flags & FONT_BOLD))
|
//if(!(flags & FONT_BOLD))
|
||||||
write_word_misaligned_NAND(draw_buffer_level, and_mask, addr, wbit);
|
write_word_misaligned_NAND(draw_buffer_level, and_mask, addr, wbit);
|
||||||
addr += DISP_WIDTH / 8;
|
addr += GRAPHICS_WIDTH_REAL / 8;
|
||||||
row++;
|
row++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1474,7 +1417,7 @@ void write_string(char *str, unsigned int x, unsigned int y, unsigned int xs, un
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(xx >= 0 && xx < DISP_WIDTH)
|
if(xx >= 0 && xx < GRAPHICS_WIDTH_REAL)
|
||||||
{
|
{
|
||||||
if(font_info.id<2)
|
if(font_info.id<2)
|
||||||
write_char(*str, xx, yy, flags, font);
|
write_char(*str, xx, yy, flags, font);
|
||||||
@ -1773,44 +1716,11 @@ void drawBattery(uint16_t x, uint16_t y, uint8_t battery, uint16_t size)
|
|||||||
|
|
||||||
void printTime(uint16_t x, uint16_t y) {
|
void printTime(uint16_t x, uint16_t y) {
|
||||||
char temp[9]={0};
|
char temp[9]={0};
|
||||||
sprintf(temp,"%02d:%02d:%02d",time.hour,time.min,time.sec);
|
sprintf(temp,"%02d:%02d:%02d",timex.hour,timex.min,timex.sec);
|
||||||
//printTextFB(x,y,temp);
|
//printTextFB(x,y,temp);
|
||||||
write_string(temp, x, y, 0, 0, TEXT_VA_TOP, TEXT_HA_LEFT, 0, 3);
|
write_string(temp, x, y, 0, 0, TEXT_VA_TOP, TEXT_HA_LEFT, 0, 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setAttitudeOsd(int16_t pitch, int16_t roll, int16_t yaw)
|
|
||||||
{
|
|
||||||
m_pitch=pitch;
|
|
||||||
m_roll=roll;
|
|
||||||
m_yaw=yaw;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setGpsOsd(uint8_t status, int32_t lat, int32_t lon, float alt, float spd)
|
|
||||||
{
|
|
||||||
m_gpsStatus=status;
|
|
||||||
m_gpsLat=lat;
|
|
||||||
m_gpsLon=lon;
|
|
||||||
m_gpsAlt=alt;
|
|
||||||
m_gpsSpd=spd;
|
|
||||||
}
|
|
||||||
|
|
||||||
void introText(){
|
|
||||||
//printTextFB((GRAPHICS_WIDTH_REAL/2 - 40)/16,GRAPHICS_HEIGHT_REAL-10,"ver 0.1");
|
|
||||||
write_string("ver 0.2", (GRAPHICS_WIDTH_REAL/2),GRAPHICS_HEIGHT_REAL-20, 0, 0, TEXT_VA_TOP, TEXT_HA_CENTER, 0, 3);
|
|
||||||
}
|
|
||||||
|
|
||||||
void introGraphics() {
|
|
||||||
/* logo */
|
|
||||||
int image=0;
|
|
||||||
struct splashEntry splash_info;
|
|
||||||
splash_info = splash[image];
|
|
||||||
|
|
||||||
copyimage(GRAPHICS_WIDTH_REAL/2-(splash_info.width)/2, GRAPHICS_HEIGHT_REAL/2-(splash_info.height)/2,image);
|
|
||||||
|
|
||||||
/* frame */
|
|
||||||
drawBox(0,0,GRAPHICS_WIDTH_REAL-2,GRAPHICS_HEIGHT_REAL-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
void drawAltitude(uint16_t x, uint16_t y, int16_t alt, uint8_t dir) {
|
void drawAltitude(uint16_t x, uint16_t y, int16_t alt, uint8_t dir) {
|
||||||
|
|
||||||
@ -1863,12 +1773,12 @@ void hud_draw_vertical_scale(int v, int range, int halign, int x, int y, int hei
|
|||||||
}
|
}
|
||||||
else if(halign == +1)
|
else if(halign == +1)
|
||||||
{
|
{
|
||||||
majtick_start = DISP_WIDTH - x - 1;
|
majtick_start = GRAPHICS_WIDTH_REAL - x - 1;
|
||||||
majtick_end = DISP_WIDTH - x - majtick_len - 1;
|
majtick_end = GRAPHICS_WIDTH_REAL - x - majtick_len - 1;
|
||||||
mintick_start = DISP_WIDTH - x - 1;
|
mintick_start = GRAPHICS_WIDTH_REAL - x - 1;
|
||||||
mintick_end = DISP_WIDTH - x - mintick_len - 1;
|
mintick_end = GRAPHICS_WIDTH_REAL - x - mintick_len - 1;
|
||||||
boundtick_start = DISP_WIDTH - x - 1;
|
boundtick_start = GRAPHICS_WIDTH_REAL - x - 1;
|
||||||
boundtick_end = DISP_WIDTH - x - boundtick_len - 1;
|
boundtick_end = GRAPHICS_WIDTH_REAL - x - boundtick_len - 1;
|
||||||
}
|
}
|
||||||
// Retrieve width of large font (font #0); from this calculate the x spacing.
|
// Retrieve width of large font (font #0); from this calculate the x spacing.
|
||||||
fetch_font_info(0, 0, &font_info, NULL);
|
fetch_font_info(0, 0, &font_info, NULL);
|
||||||
@ -2075,7 +1985,45 @@ void hud_draw_linear_compass(int v, int range, int width, int x, int y, int mint
|
|||||||
headingstr[3] = 0;
|
headingstr[3] = 0;
|
||||||
write_string(headingstr, x + 1, majtick_start + textoffset+2, 0, 0, TEXT_VA_MIDDLE, TEXT_HA_CENTER, 1, 3);
|
write_string(headingstr, x + 1, majtick_start + textoffset+2, 0, 0, TEXT_VA_MIDDLE, TEXT_HA_CENTER, 1, 3);
|
||||||
}
|
}
|
||||||
|
// CORE draw routines end here
|
||||||
|
|
||||||
|
void setAttitudeOsd(int16_t pitch, int16_t roll, int16_t yaw)
|
||||||
|
{
|
||||||
|
m_pitch=pitch;
|
||||||
|
m_roll=roll;
|
||||||
|
m_yaw=yaw;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setGpsOsd(uint8_t status, int32_t lat, int32_t lon, float alt, float spd)
|
||||||
|
{
|
||||||
|
m_gpsStatus=status;
|
||||||
|
m_gpsLat=lat;
|
||||||
|
m_gpsLon=lon;
|
||||||
|
m_gpsAlt=alt;
|
||||||
|
m_gpsSpd=spd;
|
||||||
|
}
|
||||||
|
|
||||||
|
void introText(){
|
||||||
|
write_string("ver 0.2", APPLY_HDEADBAND((GRAPHICS_RIGHT/2)),APPLY_VDEADBAND(GRAPHICS_BOTTOM-10), 0, 0, TEXT_VA_BOTTOM, TEXT_HA_CENTER, 0, 3);
|
||||||
|
}
|
||||||
|
|
||||||
|
void introGraphics() {
|
||||||
|
/* logo */
|
||||||
|
int image=0;
|
||||||
|
struct splashEntry splash_info;
|
||||||
|
splash_info = splash[image];
|
||||||
|
|
||||||
|
copyimage(APPLY_HDEADBAND(GRAPHICS_RIGHT/2-(splash_info.width)/2), APPLY_VDEADBAND(GRAPHICS_BOTTOM/2-(splash_info.height)/2),image);
|
||||||
|
|
||||||
|
/* frame */
|
||||||
|
drawBox(APPLY_HDEADBAND(0),APPLY_VDEADBAND(0),APPLY_HDEADBAND(GRAPHICS_RIGHT-8),APPLY_VDEADBAND(GRAPHICS_BOTTOM));
|
||||||
|
|
||||||
|
// Must mask out last half-word because SPI keeps clocking it out otherwise
|
||||||
|
for (uint32_t i = 0; i < 8; i++) {
|
||||||
|
write_vline( draw_buffer_level,GRAPHICS_WIDTH_REAL-i-1,0,GRAPHICS_HEIGHT_REAL-1,0);
|
||||||
|
write_vline( draw_buffer_mask,GRAPHICS_WIDTH_REAL-i-1,0,GRAPHICS_HEIGHT_REAL-1,0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void calcHomeArrow(void)
|
void calcHomeArrow(void)
|
||||||
{
|
{
|
||||||
@ -2141,16 +2089,16 @@ void calcHomeArrow(void)
|
|||||||
|
|
||||||
char temp[50]={0};
|
char temp[50]={0};
|
||||||
sprintf(temp,"hea:%d",(int)brng);
|
sprintf(temp,"hea:%d",(int)brng);
|
||||||
write_string(temp, 130, 5, 0, 0, TEXT_VA_TOP, TEXT_HA_LEFT, 0, 2);
|
write_string(temp, APPLY_HDEADBAND(GRAPHICS_RIGHT/2-30), APPLY_VDEADBAND(30), 0, 0, TEXT_VA_TOP, TEXT_HA_LEFT, 0, 2);
|
||||||
sprintf(temp,"ele:%d",(int)elevation);
|
sprintf(temp,"ele:%d",(int)elevation);
|
||||||
write_string(temp, 130, 5+10, 0, 0, TEXT_VA_TOP, TEXT_HA_LEFT, 0, 2);
|
write_string(temp, APPLY_HDEADBAND(GRAPHICS_RIGHT/2-30), APPLY_VDEADBAND(30+10), 0, 0, TEXT_VA_TOP, TEXT_HA_LEFT, 0, 2);
|
||||||
sprintf(temp,"dis:%d",(int)d);
|
sprintf(temp,"dis:%d",(int)d);
|
||||||
write_string(temp, 130, 5+10+10, 0, 0, TEXT_VA_TOP, TEXT_HA_LEFT, 0, 2);
|
write_string(temp, APPLY_HDEADBAND(GRAPHICS_RIGHT/2-30), APPLY_VDEADBAND(30+10+10), 0, 0, TEXT_VA_TOP, TEXT_HA_LEFT, 0, 2);
|
||||||
sprintf(temp,"u2g:%d",(int)u2g);
|
sprintf(temp,"u2g:%d",(int)u2g);
|
||||||
write_string(temp, 130, 5+10+10+10, 0, 0, TEXT_VA_TOP, TEXT_HA_LEFT, 0, 2);
|
write_string(temp, APPLY_HDEADBAND(GRAPHICS_RIGHT/2-30), APPLY_VDEADBAND(30+10+10+10), 0, 0, TEXT_VA_TOP, TEXT_HA_LEFT, 0, 2);
|
||||||
|
|
||||||
sprintf(temp,"%c%c",(int)(u2g/22.5f)*2+0x90,(int)(u2g/22.5f)*2+0x91);
|
sprintf(temp,"%c%c",(int)(u2g/22.5f)*2+0x90,(int)(u2g/22.5f)*2+0x91);
|
||||||
write_string(temp,200,10+10+10, 0, 0, TEXT_VA_TOP, TEXT_HA_LEFT, 0, 3);
|
write_string(temp, APPLY_HDEADBAND(250), APPLY_VDEADBAND(40+10+10), 0, 0, TEXT_VA_TOP, TEXT_HA_LEFT, 0, 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
int lama=10;
|
int lama=10;
|
||||||
@ -2192,7 +2140,7 @@ void updateGraphics() {
|
|||||||
char temps[20]={0};
|
char temps[20]={0};
|
||||||
sprintf(temps,"HOME NOT SET");
|
sprintf(temps,"HOME NOT SET");
|
||||||
//printTextFB(x,y,temp);
|
//printTextFB(x,y,temp);
|
||||||
write_string(temps, GRAPHICS_WIDTH_REAL/2-((12*12)/2), GRAPHICS_HEIGHT_REAL/2-18/2, 0, 0, TEXT_VA_TOP, TEXT_HA_LEFT, 0, 3);
|
write_string(temps, APPLY_HDEADBAND(GRAPHICS_RIGHT/2), (GRAPHICS_BOTTOM/2), 0, 0, TEXT_VA_TOP, TEXT_HA_CENTER, 0, 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t disp = 0;
|
uint32_t disp = 0;
|
||||||
@ -2207,24 +2155,17 @@ void updateGraphics() {
|
|||||||
char temp[50]={0};
|
char temp[50]={0};
|
||||||
memset(temp, ' ', 40);
|
memset(temp, ' ', 40);
|
||||||
sprintf(temp,"Lat:%11.7f",gpsData.Latitude/10000000.0f);
|
sprintf(temp,"Lat:%11.7f",gpsData.Latitude/10000000.0f);
|
||||||
write_string(temp, 170, GRAPHICS_HEIGHT_REAL-30, 0, 0, TEXT_VA_BOTTOM, TEXT_HA_LEFT, 0, 3);
|
write_string(temp, APPLY_HDEADBAND(20), APPLY_VDEADBAND(GRAPHICS_BOTTOM-30), 0, 0, TEXT_VA_BOTTOM, TEXT_HA_LEFT, 0, 3);
|
||||||
sprintf(temp,"Lon:%11.7f",gpsData.Longitude/10000000.0f);
|
sprintf(temp,"Lon:%11.7f",gpsData.Longitude/10000000.0f);
|
||||||
write_string(temp, 170, GRAPHICS_HEIGHT_REAL-10, 0, 0, TEXT_VA_BOTTOM, TEXT_HA_LEFT, 0, 3);
|
write_string(temp, APPLY_HDEADBAND(20), APPLY_VDEADBAND(GRAPHICS_BOTTOM-10), 0, 0, TEXT_VA_BOTTOM, TEXT_HA_LEFT, 0, 3);
|
||||||
sprintf(temp,"Sat:%d",(int)gpsData.Satellites);
|
sprintf(temp,"Sat:%d",(int)gpsData.Satellites);
|
||||||
write_string(temp, GRAPHICS_WIDTH_REAL-40, 30, 0, 0, TEXT_VA_TOP, TEXT_HA_RIGHT, 0, 2);
|
write_string(temp, APPLY_HDEADBAND(GRAPHICS_RIGHT-40), APPLY_VDEADBAND(30), 0, 0, TEXT_VA_TOP, TEXT_HA_RIGHT, 0, 2);
|
||||||
|
|
||||||
/* Print ADC voltage FLIGHT*/
|
/* Print ADC voltage FLIGHT*/
|
||||||
sprintf(temp,"V:%4.2fV",(PIOS_ADC_PinGet(2)*3.0f*6.1f/4096.0f));
|
sprintf(temp,"V:%5.2fV",(PIOS_ADC_PinGet(2)*3*6.1f/4096));
|
||||||
write_string(temp, 170, 20, 0, 0, TEXT_VA_TOP, TEXT_HA_LEFT, 0, 3);
|
write_string(temp, APPLY_HDEADBAND(20), APPLY_VDEADBAND(20), 0, 0, TEXT_VA_TOP, TEXT_HA_LEFT, 0, 3);
|
||||||
|
|
||||||
calcHomeArrow();
|
calcHomeArrow();
|
||||||
|
|
||||||
write_vline( draw_buffer_level,GRAPHICS_WIDTH_REAL-12,0,GRAPHICS_HEIGHT_REAL-1,1);
|
|
||||||
write_vline( draw_buffer_mask,GRAPHICS_WIDTH_REAL-12,0,GRAPHICS_HEIGHT_REAL-1,1);
|
|
||||||
|
|
||||||
// Last pixel
|
|
||||||
write_vline( draw_buffer_level,GRAPHICS_WIDTH_REAL-1,0,GRAPHICS_HEIGHT_REAL-1,0);
|
|
||||||
write_vline( draw_buffer_mask,GRAPHICS_WIDTH_REAL-1,0,GRAPHICS_HEIGHT_REAL-1,0);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
@ -2266,7 +2207,7 @@ void updateGraphics() {
|
|||||||
//if(OsdSettings.Attitude == OSDSETTINGS_ATTITUDE_ENABLED)
|
//if(OsdSettings.Attitude == OSDSETTINGS_ATTITUDE_ENABLED)
|
||||||
if(0)
|
if(0)
|
||||||
{
|
{
|
||||||
drawAttitude(OsdSettings.AttitudeSetup[OSDSETTINGS_ATTITUDESETUP_X],OsdSettings.AttitudeSetup[OSDSETTINGS_ATTITUDESETUP_Y],attitude.Pitch,attitude.Roll,96);
|
drawAttitude(APPLY_HDEADBAND(OsdSettings.AttitudeSetup[OSDSETTINGS_ATTITUDESETUP_X]),APPLY_VDEADBAND(OsdSettings.AttitudeSetup[OSDSETTINGS_ATTITUDESETUP_Y]),attitude.Pitch,attitude.Roll,96);
|
||||||
}
|
}
|
||||||
//write_string("Hello OP-OSD", 60, 12, 1, 0, TEXT_VA_TOP, TEXT_HA_LEFT, 0, 0);
|
//write_string("Hello OP-OSD", 60, 12, 1, 0, TEXT_VA_TOP, TEXT_HA_LEFT, 0, 0);
|
||||||
//printText16( 60, 12,"Hello OP-OSD");
|
//printText16( 60, 12,"Hello OP-OSD");
|
||||||
@ -2274,42 +2215,42 @@ void updateGraphics() {
|
|||||||
char temp[50]={0};
|
char temp[50]={0};
|
||||||
memset(temp, ' ', 40);
|
memset(temp, ' ', 40);
|
||||||
sprintf(temp,"Lat:%11.7f",gpsData.Latitude/10000000.0f);
|
sprintf(temp,"Lat:%11.7f",gpsData.Latitude/10000000.0f);
|
||||||
write_string(temp, 5, 5, 0, 0, TEXT_VA_TOP, TEXT_HA_LEFT, 0, 2);
|
write_string(temp, APPLY_HDEADBAND(5), APPLY_VDEADBAND(5), 0, 0, TEXT_VA_TOP, TEXT_HA_LEFT, 0, 2);
|
||||||
sprintf(temp,"Lon:%11.7f",gpsData.Longitude/10000000.0f);
|
sprintf(temp,"Lon:%11.7f",gpsData.Longitude/10000000.0f);
|
||||||
write_string(temp, 5, 15, 0, 0, TEXT_VA_TOP, TEXT_HA_LEFT, 0, 2);
|
write_string(temp, APPLY_HDEADBAND(5), APPLY_VDEADBAND(15), 0, 0, TEXT_VA_TOP, TEXT_HA_LEFT, 0, 2);
|
||||||
sprintf(temp,"Fix:%d",(int)gpsData.Status);
|
sprintf(temp,"Fix:%d",(int)gpsData.Status);
|
||||||
write_string(temp, 5, 25, 0, 0, TEXT_VA_TOP, TEXT_HA_LEFT, 0, 2);
|
write_string(temp, APPLY_HDEADBAND(5), APPLY_VDEADBAND(25), 0, 0, TEXT_VA_TOP, TEXT_HA_LEFT, 0, 2);
|
||||||
sprintf(temp,"Sat:%d",(int)gpsData.Satellites);
|
sprintf(temp,"Sat:%d",(int)gpsData.Satellites);
|
||||||
write_string(temp, 5, 35, 0, 0, TEXT_VA_TOP, TEXT_HA_LEFT, 0, 2);
|
write_string(temp, APPLY_HDEADBAND(5), APPLY_VDEADBAND(35), 0, 0, TEXT_VA_TOP, TEXT_HA_LEFT, 0, 2);
|
||||||
|
|
||||||
|
|
||||||
/* Print RTC time */
|
/* Print RTC time */
|
||||||
if(OsdSettings.Time == OSDSETTINGS_TIME_ENABLED)
|
if(OsdSettings.Time == OSDSETTINGS_TIME_ENABLED)
|
||||||
{
|
{
|
||||||
printTime(OsdSettings.TimeSetup[OSDSETTINGS_TIMESETUP_X],OsdSettings.TimeSetup[OSDSETTINGS_TIMESETUP_Y]);
|
printTime(APPLY_HDEADBAND(OsdSettings.TimeSetup[OSDSETTINGS_TIMESETUP_X]),APPLY_VDEADBAND(OsdSettings.TimeSetup[OSDSETTINGS_TIMESETUP_Y]));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Print Number of detected video Lines */
|
/* Print Number of detected video Lines */
|
||||||
sprintf(temp,"Lines:%4d",PIOS_Video_GetOSDLines());
|
sprintf(temp,"Lines:%4d",PIOS_Video_GetOSDLines());
|
||||||
write_string(temp, (GRAPHICS_WIDTH_REAL - 2),5, 0, 0, TEXT_VA_TOP, TEXT_HA_RIGHT, 0, 2);
|
write_string(temp, APPLY_HDEADBAND((GRAPHICS_RIGHT - 2)),APPLY_VDEADBAND(5), 0, 0, TEXT_VA_TOP, TEXT_HA_RIGHT, 0, 2);
|
||||||
|
|
||||||
/* Print ADC voltage */
|
/* Print ADC voltage */
|
||||||
//sprintf(temp,"Rssi:%4dV",(int)(PIOS_ADC_PinGet(4)*3000/4096));
|
//sprintf(temp,"Rssi:%4dV",(int)(PIOS_ADC_PinGet(4)*3000/4096));
|
||||||
//write_string(temp, (GRAPHICS_WIDTH_REAL - 2),15, 0, 0, TEXT_VA_TOP, TEXT_HA_RIGHT, 0, 2);
|
//write_string(temp, (GRAPHICS_WIDTH_REAL - 2),15, 0, 0, TEXT_VA_TOP, TEXT_HA_RIGHT, 0, 2);
|
||||||
sprintf(temp,"Rssi:%4.2fV",(PIOS_ADC_PinGet(4)*3.0f/4096.0f));
|
sprintf(temp,"Rssi:%4.2fV",(PIOS_ADC_PinGet(4)*3.0f/4096.0f));
|
||||||
write_string(temp, (GRAPHICS_WIDTH_REAL - 2),15, 0, 0, TEXT_VA_TOP, TEXT_HA_RIGHT, 0, 2);
|
write_string(temp, APPLY_HDEADBAND((GRAPHICS_RIGHT - 2)),APPLY_VDEADBAND(15), 0, 0, TEXT_VA_TOP, TEXT_HA_RIGHT, 0, 2);
|
||||||
|
|
||||||
/* Print CPU temperature */
|
/* Print CPU temperature */
|
||||||
sprintf(temp,"Temp:%4.2fC",(PIOS_ADC_PinGet(6)*0.29296875f-264));
|
sprintf(temp,"Temp:%4.2fC",(PIOS_ADC_PinGet(6)*0.29296875f-264));
|
||||||
write_string(temp, (GRAPHICS_WIDTH_REAL - 2),25, 0, 0, TEXT_VA_TOP, TEXT_HA_RIGHT, 0, 2);
|
write_string(temp, APPLY_HDEADBAND((GRAPHICS_RIGHT - 2)),APPLY_VDEADBAND(25), 0, 0, TEXT_VA_TOP, TEXT_HA_RIGHT, 0, 2);
|
||||||
|
|
||||||
/* Print ADC voltage FLIGHT*/
|
/* Print ADC voltage FLIGHT*/
|
||||||
sprintf(temp,"FltV:%4.2fV",(PIOS_ADC_PinGet(2)*3.0f*6.1f/4096.0f));
|
sprintf(temp,"FltV:%4.2fV",(PIOS_ADC_PinGet(2)*3.0f*6.1f/4096.0f));
|
||||||
write_string(temp, (GRAPHICS_WIDTH_REAL - 2),35, 0, 0, TEXT_VA_TOP, TEXT_HA_RIGHT, 0, 2);
|
write_string(temp, APPLY_HDEADBAND((GRAPHICS_RIGHT - 2)),APPLY_VDEADBAND(35), 0, 0, TEXT_VA_TOP, TEXT_HA_RIGHT, 0, 2);
|
||||||
|
|
||||||
/* Print ADC voltage VIDEO*/
|
/* Print ADC voltage VIDEO*/
|
||||||
sprintf(temp,"VidV:%4.2fV",(PIOS_ADC_PinGet(3)*3.0f*6.1f/4096.0f));
|
sprintf(temp,"VidV:%4.2fV",(PIOS_ADC_PinGet(3)*3.0f*6.1f/4096.0f));
|
||||||
write_string(temp, (GRAPHICS_WIDTH_REAL - 2),45, 0, 0, TEXT_VA_TOP, TEXT_HA_RIGHT, 0, 2);
|
write_string(temp, APPLY_HDEADBAND((GRAPHICS_RIGHT - 2)),APPLY_VDEADBAND(45), 0, 0, TEXT_VA_TOP, TEXT_HA_RIGHT, 0, 2);
|
||||||
|
|
||||||
/* Print ADC voltage RSSI */
|
/* Print ADC voltage RSSI */
|
||||||
//sprintf(temp,"Curr:%4dA",(int)(PIOS_ADC_PinGet(0)*300*61/4096));
|
//sprintf(temp,"Curr:%4dA",(int)(PIOS_ADC_PinGet(0)*300*61/4096));
|
||||||
@ -2333,7 +2274,7 @@ void updateGraphics() {
|
|||||||
//if(OsdSettings.Battery == OSDSETTINGS_BATTERY_ENABLED)
|
//if(OsdSettings.Battery == OSDSETTINGS_BATTERY_ENABLED)
|
||||||
if(0)
|
if(0)
|
||||||
{
|
{
|
||||||
drawBattery(OsdSettings.BatterySetup[OSDSETTINGS_BATTERYSETUP_X],OsdSettings.BatterySetup[OSDSETTINGS_BATTERYSETUP_Y],m_batt,16);
|
drawBattery(APPLY_HDEADBAND(OsdSettings.BatterySetup[OSDSETTINGS_BATTERYSETUP_X]),APPLY_VDEADBAND(OsdSettings.BatterySetup[OSDSETTINGS_BATTERYSETUP_Y]),m_batt,16);
|
||||||
}
|
}
|
||||||
|
|
||||||
//drawAltitude(200,50,m_alt,dir);
|
//drawAltitude(200,50,m_alt,dir);
|
||||||
@ -2344,24 +2285,24 @@ void updateGraphics() {
|
|||||||
// Draw airspeed (left side.)
|
// Draw airspeed (left side.)
|
||||||
if(OsdSettings.Speed == OSDSETTINGS_SPEED_ENABLED)
|
if(OsdSettings.Speed == OSDSETTINGS_SPEED_ENABLED)
|
||||||
{
|
{
|
||||||
hud_draw_vertical_scale((int)m_gpsSpd, 100, -1, OsdSettings.SpeedSetup[OSDSETTINGS_SPEEDSETUP_X],
|
hud_draw_vertical_scale((int)m_gpsSpd, 100, -1, APPLY_HDEADBAND(OsdSettings.SpeedSetup[OSDSETTINGS_SPEEDSETUP_X]),
|
||||||
OsdSettings.SpeedSetup[OSDSETTINGS_SPEEDSETUP_Y], 100, 10, 20, 7, 12, 15, 1000, HUD_VSCALE_FLAG_NO_NEGATIVE);
|
APPLY_VDEADBAND(OsdSettings.SpeedSetup[OSDSETTINGS_SPEEDSETUP_Y]), 100, 10, 20, 7, 12, 15, 1000, HUD_VSCALE_FLAG_NO_NEGATIVE);
|
||||||
}
|
}
|
||||||
// Draw altimeter (right side.)
|
// Draw altimeter (right side.)
|
||||||
if(OsdSettings.Altitude == OSDSETTINGS_ALTITUDE_ENABLED)
|
if(OsdSettings.Altitude == OSDSETTINGS_ALTITUDE_ENABLED)
|
||||||
{
|
{
|
||||||
hud_draw_vertical_scale((int)m_gpsAlt, 200, +1, OsdSettings.AltitudeSetup[OSDSETTINGS_ALTITUDESETUP_X],
|
hud_draw_vertical_scale((int)m_gpsAlt, 200, +1, APPLY_HDEADBAND(OsdSettings.AltitudeSetup[OSDSETTINGS_ALTITUDESETUP_X]),
|
||||||
OsdSettings.AltitudeSetup[OSDSETTINGS_ALTITUDESETUP_Y], 100, 20, 100, 7, 12, 15, 500, 0);
|
APPLY_VDEADBAND(OsdSettings.AltitudeSetup[OSDSETTINGS_ALTITUDESETUP_Y]), 100, 20, 100, 7, 12, 15, 500, 0);
|
||||||
}
|
}
|
||||||
// Draw compass.
|
// Draw compass.
|
||||||
if(OsdSettings.Heading == OSDSETTINGS_HEADING_ENABLED)
|
if(OsdSettings.Heading == OSDSETTINGS_HEADING_ENABLED)
|
||||||
{
|
{
|
||||||
if(m_yaw<0) {
|
if(m_yaw<0) {
|
||||||
hud_draw_linear_compass(360+m_yaw, 150, 120, OsdSettings.HeadingSetup[OSDSETTINGS_HEADINGSETUP_X],
|
hud_draw_linear_compass(360+m_yaw, 150, 120, APPLY_HDEADBAND(OsdSettings.HeadingSetup[OSDSETTINGS_HEADINGSETUP_X]),
|
||||||
OsdSettings.HeadingSetup[OSDSETTINGS_HEADINGSETUP_Y], 15, 30, 7, 12, 0);
|
APPLY_VDEADBAND(OsdSettings.HeadingSetup[OSDSETTINGS_HEADINGSETUP_Y]), 15, 30, 7, 12, 0);
|
||||||
} else {
|
} else {
|
||||||
hud_draw_linear_compass(m_yaw, 150, 120, OsdSettings.HeadingSetup[OSDSETTINGS_HEADINGSETUP_X],
|
hud_draw_linear_compass(m_yaw, 150, 120, APPLY_HDEADBAND(OsdSettings.HeadingSetup[OSDSETTINGS_HEADINGSETUP_X]),
|
||||||
OsdSettings.HeadingSetup[OSDSETTINGS_HEADINGSETUP_Y], 15, 30, 7, 12, 0);
|
APPLY_VDEADBAND(OsdSettings.HeadingSetup[OSDSETTINGS_HEADINGSETUP_Y]), 15, 30, 7, 12, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//write_filled_rectangle(draw_buffer_level,20,20,30,30,1);
|
//write_filled_rectangle(draw_buffer_level,20,20,30,30,1);
|
||||||
@ -2379,13 +2320,12 @@ void updateGraphics() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Must mask out last half-word because SPI keeps clocking it out otherwise
|
// Must mask out last half-word because SPI keeps clocking it out otherwise
|
||||||
for (uint32_t i = 0; i < 16; i++) {
|
for (uint32_t i = 0; i < 8; i++) {
|
||||||
write_vline( draw_buffer_level,GRAPHICS_WIDTH_REAL-i-1,0,GRAPHICS_HEIGHT_REAL-1,0);
|
write_vline( draw_buffer_level,GRAPHICS_WIDTH_REAL-i-1,0,GRAPHICS_HEIGHT_REAL-1,0);
|
||||||
write_vline( draw_buffer_mask,GRAPHICS_WIDTH_REAL-i-1,0,GRAPHICS_HEIGHT_REAL-1,0);
|
write_vline( draw_buffer_mask,GRAPHICS_WIDTH_REAL-i-1,0,GRAPHICS_HEIGHT_REAL-1,0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void updateOnceEveryFrame() {
|
void updateOnceEveryFrame() {
|
||||||
clearGraphics();
|
clearGraphics();
|
||||||
updateGraphics();
|
updateGraphics();
|
||||||
@ -2441,8 +2381,6 @@ MODULE_INITCALL(osdgenInitialize, osdgenStart)
|
|||||||
static void osdgenTask(void *parameters)
|
static void osdgenTask(void *parameters)
|
||||||
{
|
{
|
||||||
portTickType lastSysTime;
|
portTickType lastSysTime;
|
||||||
AttitudeActualData attitude;
|
|
||||||
GPSPositionData gpsData;
|
|
||||||
// Loop forever
|
// Loop forever
|
||||||
lastSysTime = xTaskGetTickCount();
|
lastSysTime = xTaskGetTickCount();
|
||||||
|
|
||||||
@ -2469,10 +2407,6 @@ static void osdgenTask(void *parameters)
|
|||||||
{
|
{
|
||||||
if( xSemaphoreTake( osdSemaphore, LONG_TIME ) == pdTRUE )
|
if( xSemaphoreTake( osdSemaphore, LONG_TIME ) == pdTRUE )
|
||||||
{
|
{
|
||||||
GPSPositionGet(&gpsData);
|
|
||||||
AttitudeActualGet(&attitude);
|
|
||||||
setAttitudeOsd((int16_t)attitude.Pitch,(int16_t)attitude.Roll,(int16_t)attitude.Yaw);
|
|
||||||
setGpsOsd(gpsData.Status,gpsData.Latitude,gpsData.Longitude,gpsData.Altitude,gpsData.Groundspeed);
|
|
||||||
updateOnceEveryFrame();
|
updateOnceEveryFrame();
|
||||||
}
|
}
|
||||||
//xSemaphoreTake(osdSemaphore, portMAX_DELAY);
|
//xSemaphoreTake(osdSemaphore, portMAX_DELAY);
|
||||||
|
@ -160,8 +160,8 @@ SRC += $(OPUAVSYNTHDIR)/osdsettings.c
|
|||||||
## PIOS Hardware (Common)
|
## PIOS Hardware (Common)
|
||||||
SRC += $(PIOSCOMMON)/pios_com.c
|
SRC += $(PIOSCOMMON)/pios_com.c
|
||||||
#SRC += $(PIOSCOMMON)/pios_hmc5843.c
|
#SRC += $(PIOSCOMMON)/pios_hmc5843.c
|
||||||
SRC += $(PIOSCOMMON)/printf-stdarg.c
|
#SRC += $(PIOSCOMMON)/printf-stdarg.c
|
||||||
#SRC += $(PIOSCOMMON)/printf2.c
|
SRC += $(PIOSCOMMON)/printf2.c
|
||||||
SRC += $(PIOSCOMMON)/pios_crc.c
|
SRC += $(PIOSCOMMON)/pios_crc.c
|
||||||
SRC += $(PIOSCOMMON)/pios_video.c
|
SRC += $(PIOSCOMMON)/pios_video.c
|
||||||
SRC += $(PIOSCOMMON)/pios_usb_desc_hid_cdc.c
|
SRC += $(PIOSCOMMON)/pios_usb_desc_hid_cdc.c
|
||||||
|
@ -683,17 +683,17 @@ static void Clock(uint32_t spektrum_id) {
|
|||||||
++supv_timer;
|
++supv_timer;
|
||||||
if(supv_timer >= 625) {
|
if(supv_timer >= 625) {
|
||||||
supv_timer = 0;
|
supv_timer = 0;
|
||||||
time.sec++;
|
timex.sec++;
|
||||||
}
|
}
|
||||||
if (time.sec >= 60) {
|
if (timex.sec >= 60) {
|
||||||
time.sec = 0;
|
timex.sec = 0;
|
||||||
time.min++;
|
timex.min++;
|
||||||
}
|
}
|
||||||
if (time.min >= 60) {
|
if (timex.min >= 60) {
|
||||||
time.min = 0;
|
timex.min = 0;
|
||||||
time.hour++;
|
timex.hour++;
|
||||||
}
|
}
|
||||||
if (time.hour >= 99) {
|
if (timex.hour >= 99) {
|
||||||
time.hour = 0;
|
timex.hour = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -56,24 +56,204 @@ static uint use_leading_plus = 0 ;
|
|||||||
/* for caddr_t (typedef char * caddr_t;) */
|
/* for caddr_t (typedef char * caddr_t;) */
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
extern int __HEAP_START;
|
//* NEWLIB STUBS *//
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <sys/unistd.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <sys/times.h>
|
||||||
|
#include <errno.h>
|
||||||
|
|
||||||
|
/*==============================================================================
|
||||||
|
* Environment variables.
|
||||||
|
* A pointer to a list of environment variables and their values. For a minimal
|
||||||
|
* environment, this empty list is adequate:
|
||||||
|
*/
|
||||||
|
char *__env[1] = { 0 };
|
||||||
|
char **environ = __env;
|
||||||
|
|
||||||
|
/*==============================================================================
|
||||||
|
* Close a file.
|
||||||
|
*/
|
||||||
|
int _close(int file)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*==============================================================================
|
||||||
|
* Transfer control to a new process.
|
||||||
|
*/
|
||||||
|
int _execve(char *name, char **argv, char **env)
|
||||||
|
{
|
||||||
|
errno = ENOMEM;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*==============================================================================
|
||||||
|
* Exit a program without cleaning up files.
|
||||||
|
*/
|
||||||
|
void _exit( int code )
|
||||||
|
{
|
||||||
|
/* Should we force a system reset? */
|
||||||
|
while( 1 )
|
||||||
|
{
|
||||||
|
;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*==============================================================================
|
||||||
|
* Create a new process.
|
||||||
|
*/
|
||||||
|
int _fork(void)
|
||||||
|
{
|
||||||
|
errno = EAGAIN;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*==============================================================================
|
||||||
|
* Status of an open file.
|
||||||
|
*/
|
||||||
|
int _fstat(int file, struct stat *st)
|
||||||
|
{
|
||||||
|
st->st_mode = S_IFCHR;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*==============================================================================
|
||||||
|
* Process-ID
|
||||||
|
*/
|
||||||
|
int _getpid(void)
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*==============================================================================
|
||||||
|
* Query whether output stream is a terminal.
|
||||||
|
*/
|
||||||
|
int _isatty(int file)
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*==============================================================================
|
||||||
|
* Send a signal.
|
||||||
|
*/
|
||||||
|
int _kill(int pid, int sig)
|
||||||
|
{
|
||||||
|
errno = EINVAL;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*==============================================================================
|
||||||
|
* Establish a new name for an existing file.
|
||||||
|
*/
|
||||||
|
int _link(char *old, char *new)
|
||||||
|
{
|
||||||
|
errno = EMLINK;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*==============================================================================
|
||||||
|
* Set position in a file.
|
||||||
|
*/
|
||||||
|
int _lseek(int file, int ptr, int dir)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*==============================================================================
|
||||||
|
* Open a file.
|
||||||
|
*/
|
||||||
|
int _open(const char *name, int flags, int mode)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*==============================================================================
|
||||||
|
* Read from a file.
|
||||||
|
*/
|
||||||
|
int _read(int file, char *ptr, int len)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*==============================================================================
|
||||||
|
* Write to a file. libc subroutines will use this system routine for output to
|
||||||
|
* all files, including stdout—so if you need to generate any output, for
|
||||||
|
* example to a serial port for debugging, you should make your minimal write
|
||||||
|
* capable of doing this.
|
||||||
|
*/
|
||||||
|
int _write_r( void * reent, int file, char * ptr, int len )
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*==============================================================================
|
||||||
|
* Increase program data space. As malloc and related functions depend on this,
|
||||||
|
* it is useful to have a working implementation. The following suffices for a
|
||||||
|
* standalone system; it exploits the symbol _end automatically defined by the
|
||||||
|
* GNU linker.
|
||||||
|
*/
|
||||||
caddr_t _sbrk(int incr)
|
caddr_t _sbrk(int incr)
|
||||||
{
|
{
|
||||||
static unsigned char *heap = NULL;
|
extern char _end; /* Defined by the linker */
|
||||||
unsigned char *prev_heap;
|
static char *heap_end;
|
||||||
|
char *prev_heap_end;
|
||||||
|
char * stack_ptr;
|
||||||
|
|
||||||
if (heap == NULL) {
|
if (heap_end == 0)
|
||||||
heap = (unsigned char *)&__HEAP_START;
|
{
|
||||||
|
heap_end = &_end;
|
||||||
}
|
}
|
||||||
prev_heap = heap;
|
|
||||||
/* check removed to show basic approach */
|
|
||||||
|
|
||||||
heap += incr;
|
prev_heap_end = heap_end;
|
||||||
|
asm volatile ("MRS %0, msp" : "=r" (stack_ptr) );
|
||||||
return (caddr_t) prev_heap;
|
if (heap_end + incr > stack_ptr)
|
||||||
|
{
|
||||||
|
_write_r ((void *)0, 1, "Heap and stack collision\n", 25);
|
||||||
|
_exit (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
heap_end += incr;
|
||||||
|
return (caddr_t) prev_heap_end;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*==============================================================================
|
||||||
|
* Status of a file (by name).
|
||||||
|
*/
|
||||||
|
int _stat(char *file, struct stat *st)
|
||||||
|
{
|
||||||
|
st->st_mode = S_IFCHR;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*==============================================================================
|
||||||
|
* Timing information for current process.
|
||||||
|
*/
|
||||||
|
int _times(struct tms *buf)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*==============================================================================
|
||||||
|
* Remove a file's directory entry.
|
||||||
|
*/
|
||||||
|
int _unlink(char *name)
|
||||||
|
{
|
||||||
|
errno = ENOENT;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*==============================================================================
|
||||||
|
* Wait for a child process.
|
||||||
|
*/
|
||||||
|
int _wait(int *status)
|
||||||
|
{
|
||||||
|
errno = ECHILD;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
//* NEWLIB STUBS *//
|
||||||
|
|
||||||
|
|
||||||
//****************************************************************************
|
//****************************************************************************
|
||||||
static void printchar (char **str, int c)
|
static void printchar (char **str, int c)
|
||||||
{
|
{
|
||||||
|
@ -22,8 +22,8 @@ LINKER_SCRIPTS_BL = $(PIOS_DEVLIB)/link_STM32F4xx_BL_memory.ld \
|
|||||||
CDEFS += -DSTM32F4XX
|
CDEFS += -DSTM32F4XX
|
||||||
CDEFS += -DHSE_VALUE=$(OSCILLATOR_FREQ)
|
CDEFS += -DHSE_VALUE=$(OSCILLATOR_FREQ)
|
||||||
CDEFS += -DUSE_STDPERIPH_DRIVER
|
CDEFS += -DUSE_STDPERIPH_DRIVER
|
||||||
ARCHFLAGS += -mcpu=cortex-m4 -mthumb -mfpu=fpv4-sp-d16 -mfloat-abi=softfp
|
#ARCHFLAGS += -mcpu=cortex-m4 -mthumb -mfpu=fpv4-sp-d16 -mfloat-abi=softfp
|
||||||
#ARCHFLAGS += -mcpu=cortex-m4 -march=armv7e-m -mfpu=fpv4-sp-d16 -mfloat-abi=hard
|
ARCHFLAGS += -mcpu=cortex-m4 -march=armv7e-m -mfpu=fpv4-sp-d16 -mfloat-abi=hard
|
||||||
|
|
||||||
#
|
#
|
||||||
# PIOS device library source and includes
|
# PIOS device library source and includes
|
||||||
|
@ -48,7 +48,9 @@ SECTIONS
|
|||||||
} > FLASH
|
} > FLASH
|
||||||
.ARM.exidx :
|
.ARM.exidx :
|
||||||
{
|
{
|
||||||
|
__exidx_start = .;
|
||||||
*(.ARM.exidx* .gnu.linkonce.armexidx.*)
|
*(.ARM.exidx* .gnu.linkonce.armexidx.*)
|
||||||
|
__exidx_end = .;
|
||||||
} > FLASH
|
} > FLASH
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -108,7 +110,6 @@ SECTIONS
|
|||||||
PROVIDE ( _end = _ebss ) ;
|
PROVIDE ( _end = _ebss ) ;
|
||||||
} > SRAM
|
} > SRAM
|
||||||
|
|
||||||
/*PROVIDE(__HEAP_START = _end );*/
|
|
||||||
/*
|
/*
|
||||||
* The heap consumes the remainder of the SRAM.
|
* The heap consumes the remainder of the SRAM.
|
||||||
*/
|
*/
|
||||||
|
@ -62,7 +62,7 @@ typedef struct {
|
|||||||
uint8_t hour;
|
uint8_t hour;
|
||||||
} TTime;
|
} TTime;
|
||||||
|
|
||||||
extern TTime time;
|
extern TTime timex;
|
||||||
|
|
||||||
extern void PIOS_Video_Init(const struct pios_video_cfg * cfg);
|
extern void PIOS_Video_Init(const struct pios_video_cfg * cfg);
|
||||||
uint16_t PIOS_Video_GetOSDLines(void);
|
uint16_t PIOS_Video_GetOSDLines(void);
|
||||||
@ -72,9 +72,20 @@ extern void PIOS_Vsync_ISR();
|
|||||||
// First OSD line
|
// First OSD line
|
||||||
#define GRAPHICS_LINE 32
|
#define GRAPHICS_LINE 32
|
||||||
|
|
||||||
|
//top/left deadband
|
||||||
|
#define GRAPHICS_HDEADBAND 32
|
||||||
|
#define GRAPHICS_VDEADBAND 0
|
||||||
|
|
||||||
// Real OSD size
|
// Real OSD size
|
||||||
#define GRAPHICS_WIDTH_REAL 360
|
#define GRAPHICS_WIDTH_REAL (336+GRAPHICS_HDEADBAND)
|
||||||
#define GRAPHICS_HEIGHT_REAL 270
|
#define GRAPHICS_HEIGHT_REAL (270+GRAPHICS_VDEADBAND)
|
||||||
|
|
||||||
|
//draw area
|
||||||
|
#define GRAPHICS_TOP 0
|
||||||
|
#define GRAPHICS_LEFT 0
|
||||||
|
#define GRAPHICS_BOTTOM (GRAPHICS_HEIGHT_REAL-GRAPHICS_VDEADBAND-1)
|
||||||
|
#define GRAPHICS_RIGHT (GRAPHICS_WIDTH_REAL-GRAPHICS_HDEADBAND-1)
|
||||||
|
|
||||||
|
|
||||||
#define GRAPHICS_WIDTH (GRAPHICS_WIDTH_REAL/8)
|
#define GRAPHICS_WIDTH (GRAPHICS_WIDTH_REAL/8)
|
||||||
#define GRAPHICS_HEIGHT GRAPHICS_HEIGHT_REAL
|
#define GRAPHICS_HEIGHT GRAPHICS_HEIGHT_REAL
|
||||||
|
Loading…
Reference in New Issue
Block a user