Subversion Repositories Projects

Compare Revisions

Ignore whitespace Rev 471 → Rev 474

/C-OSD/trunk/CHANGE.LOG
18,6 → 18,9
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
****************************************************************************/
 
20090523-1150
+pal/ntsc changable in menu (applied immedeately!)
 
20090519-2245
*mah corrected
+config gets saved now (menu item!)
/C-OSD/trunk/config.c
55,29 → 55,34
char ee_message1[] PROGMEM = "No saved Data in EEPROM";
char* ee_msg[] PROGMEM = {ee_message0, ee_message1};
 
// video modes
char VM_PAL[] PROGMEM = "PAL ";
char VM_NTSC[] PROGMEM = "NTSC";
 
// menu strings to progmem
char menu_item0[] PROGMEM = "Full HUD";
char menu_item1[] PROGMEM = "Art.Horizon in HUD";
char menu_item2[] PROGMEM = "Big Vario bar";
char menu_item3[] PROGMEM = "Statistics";
char menu_item4[] PROGMEM = "Warnings"; // TODO: do it!
char menu_item5[] PROGMEM = "Reset uptime";
char menu_item6[] PROGMEM = "Request OSD-data";
char menu_item7[] PROGMEM = "Disable Debug-data";
char menu_item8[] PROGMEM = "Save config";
char menu_item9[] PROGMEM = "EXIT";
char menu_item0[] PROGMEM = "Video Mode";
char menu_item1[] PROGMEM = "Full HUD";
char menu_item2[] PROGMEM = "Art.Horizon in HUD";
char menu_item3[] PROGMEM = "Big Vario bar";
char menu_item4[] PROGMEM = "Statistics";
char menu_item5[] PROGMEM = "Warnings"; // TODO: do it!
char menu_item6[] PROGMEM = "Reset uptime";
char menu_item7[] PROGMEM = "Request OSD-data";
char menu_item8[] PROGMEM = "Disable Debug-data";
char menu_item9[] PROGMEM = "Save config";
char menu_item10[] PROGMEM = "EXIT";
char* menu[] = {menu_item0, menu_item1, menu_item2, menu_item3, menu_item4,
menu_item5, menu_item6, menu_item7, menu_item8, menu_item9};
menu_item5, menu_item6, menu_item7, menu_item8, menu_item9, menu_item10};
 
/**
* read data saved in eeprom
* read data saved in eeprom, print out message if <verbose> is set
*/
void get_eeprom() {
void get_eeprom(uint8_t verbose) {
if (eeprom_read_byte(&ee_checkbyte1) == CHECKBYTE1 && eeprom_read_byte(&ee_checkbyte2) == CHECKBYTE2) {
write_ascii_string_pgm(2, 9, ee_msg[0]); // Loading data
if (verbose) write_ascii_string_pgm(2, 9, ee_msg[0]); // Loading data
COSD_FLAGS = eeprom_read_byte(&ee_COSD_FLAGS);
} else {
write_ascii_string_pgm(2, 9, ee_msg[1]); // No data found
if (verbose) write_ascii_string_pgm(2, 9, ee_msg[1]); // No data found
}
}
 
128,8 → 133,15
//write_ascii_string(2, 7, "Max Voltage :");
write_ndigit_number_s_10th(20, 7, max_voltage, 100, 0);
 
get_eeprom();
get_eeprom(1);
 
//write_ascii_string_pgm(23, 2, vm[COSD_FLAGS & COSD_FLAG_NTSC]);
if (COSD_FLAGS & COSD_FLAG_NTSC) {
write_ascii_string_pgm(23, 2, VM_NTSC);
} else {
write_ascii_string_pgm(23, 2, VM_PAL);
}
 
_delay_ms(200);
clear();
// update flags to paint display again because of clear
145,9 → 157,16
*/
void config_menu_drawings(uint8_t chosen) {
// clear prevoius _cursor_
write_ascii_string(3, (chosen + 3) % 9, " ");
write_ascii_string(3, (chosen + 2) % 10, " ");
// draw current _cursor_
write_ascii_string(3, chosen + 3, ">");
write_ascii_string(3, chosen + 2, ">");
 
if (COSD_FLAGS & COSD_FLAG_NTSC) {
write_ascii_string_pgm(23, 2, VM_NTSC);
} else {
write_ascii_string_pgm(23, 2, VM_PAL);
}
if (COSD_FLAGS & COSD_FLAG_HUD) {
write_ascii_string_pgm(23, 3, ON);
} else {
179,9 → 198,9
* some sort of clicking response in the menu
*/
void config_menu_doclick(uint8_t chosen, char** menu) {
write_ascii_string(4, chosen + 3, "DONE ");
write_ascii_string(4, chosen + 2, "DONE ");
_delay_ms(500);
write_ascii_string_pgm(4, chosen + 3, menu[chosen]);
write_ascii_string_pgm(4, chosen + 2, menu[chosen]);
}
 
/**
196,57 → 215,74
 
uint8_t inmenu = 1;
uint8_t chosen = 0;
write_ascii_string(6, 2, "C-OSD Config Menu");
write_ascii_string(6, 1, "C-OSD Config Menu");
 
// wait a bit before doing stuff so user has chance to release button
_delay_ms(250);
 
write_ascii_string_pgm(4, 3, menu[0]);
write_ascii_string_pgm(4, 4, menu[1]);
write_ascii_string_pgm(4, 5, menu[2]);
write_ascii_string_pgm(4, 6, menu[3]);
write_ascii_string_pgm(4, 7, menu[4]);
write_ascii_string_pgm(4, 8, menu[5]);
write_ascii_string_pgm(4, 9, menu[6]);
write_ascii_string_pgm(4, 10, menu[7]);
write_ascii_string_pgm(4, 11, menu[8]);
write_ascii_string_pgm(4, 12, menu[9]);
write_ascii_string_pgm(4, 2, menu[0]);
write_ascii_string_pgm(4, 3, menu[1]);
write_ascii_string_pgm(4, 4, menu[2]);
write_ascii_string_pgm(4, 5, menu[3]);
write_ascii_string_pgm(4, 6, menu[4]);
write_ascii_string_pgm(4, 7, menu[5]);
write_ascii_string_pgm(4, 8, menu[6]);
write_ascii_string_pgm(4, 9, menu[7]);
write_ascii_string_pgm(4, 10, menu[8]);
write_ascii_string_pgm(4, 11, menu[9]);
write_ascii_string_pgm(4, 12, menu[10]);
 
config_menu_drawings(chosen);
 
while (inmenu) {
if (s2_pressed()) {
write_ascii_string(3, chosen + 3, " ");
chosen = (chosen + 1) % 10;
write_ascii_string(3, chosen + 3, ">");
write_ascii_string(3, chosen + 2, " ");
chosen = (chosen + 1) % 11;
write_ascii_string(3, chosen + 2, ">");
_delay_ms(500);
} else if (s1_pressed()) {
switch (chosen) {
case 0: // full HUD
COSD_FLAGS ^= COSD_FLAG_NTSC;
// Setup Video Mode
if (COSD_FLAGS & COSD_FLAG_NTSC) {
// NTSC + enable display immediately (VM0)
spi_send_byte(0x00, 0b00001000);
 
bottom_line = 12;
} else {
// PAL + enable display immediately (VM0)
spi_send_byte(0x00, 0b01001000);
 
bottom_line = 14;
}
config_menu_drawings(chosen);
break;
case 1: // full HUD
COSD_FLAGS ^= COSD_FLAG_HUD;
config_menu_drawings(chosen);
break;
case 1: // art horizon
case 2: // art horizon
COSD_FLAGS ^= COSD_FLAG_ARTHORIZON;
config_menu_drawings(chosen);
break;
case 2: // big vario
case 3: // big vario
COSD_FLAGS ^= COSD_FLAG_BIGVARIO;
config_menu_drawings(chosen);
break;
case 3: // statistics
case 4: // statistics
COSD_FLAGS ^= COSD_FLAG_STATS;
config_menu_drawings(chosen);
break;
case 4: // warnings
case 5: // warnings
COSD_FLAGS ^= COSD_FLAG_WARNINGS;
config_menu_drawings(chosen);
break;
case 5: // reset uptime
case 6: // reset uptime
uptime = 0;
config_menu_doclick(chosen, menu);
break;
case 6: // re-request OSD data
case 7: // re-request OSD data
#if FCONLY
// request data ever 100ms from FC;
usart1_request_mk_data(0, 'd', 100);
259,17 → 295,17
#endif
config_menu_doclick(chosen, menu);
break;
case 7: // disable debug data
case 8: // disable debug data
// disable sending of debug data
// may result in smoother ddata display
usart1_request_mk_data(0, 'd', 0);
config_menu_doclick(chosen, menu);
break;
case 8: // save
case 9: // save
save_eeprom();
config_menu_doclick(chosen, menu);
break;
case 9: // exit
case 10: // exit
inmenu = 0;
break;
}
/C-OSD/trunk/config.h
24,10 → 24,22
extern uint8_t COSD_FLAGS, COSD_FLAGS2;
extern uint8_t min_voltage;
extern uint8_t max_voltage;
extern uint8_t bottom_line;
 
extern volatile uint16_t uptime;
 
/**
* read data saved in eeprom, print out message if <verbose> is set
*/
void init_cosd(uint8_t);
 
/**
* a simple config menu tryout
*/
void config_menu(void);
 
/**
* read data saved in eeprom, print out message if <verbose> is set
*/
void get_eeprom(uint8_t);
 
/C-OSD/trunk/main.c
163,13 → 163,6
DDRC &= ~(1 << PC5); // PC5 input (SET)
PORTC |= (1 << PC5); // pullup
 
// set up top and bottom lines
if (COSD_FLAGS & COSD_FLAG_NTSC) {
bottom_line = 12;
} else {
bottom_line = 14;
}
 
// reset the MAX7456 to be sure any undefined states do no harm
MAX_RESET_LOW
MAX_RESET_HIGH
177,26 → 170,31
// give the FC/NC and the maxim time to come up
LED4_ON
_delay_ms(2000);
 
LED4_OFF
 
 
//Pushing NEW chars to the MAX7456
#if (WRITECHARS != -1)
// DISABLE display (VM0)
spi_send_byte(0x00, 0b00000000);
// DISABLE display (VM0)
spi_send_byte(0x00, 0b00000000);
#include "characters.c"
#else
// read out config for NTSC/PAL distinguishing
get_eeprom(0);
#endif
 
// Setup Video Mode
if (COSD_FLAGS & COSD_FLAG_NTSC) {
// NTSC + enable display immediately (VM0)
spi_send_byte(0x00, 0b00001000);
} else {
// PAL + enable display immediately (VM0)
spi_send_byte(0x00, 0b01001000);
}
// Setup Video Mode
if (COSD_FLAGS & COSD_FLAG_NTSC) {
// NTSC + enable display immediately (VM0)
spi_send_byte(0x00, 0b00001000);
 
bottom_line = 12;
} else {
// PAL + enable display immediately (VM0)
spi_send_byte(0x00, 0b01001000);
 
bottom_line = 14;
}
 
/*// clear all display-mem (DMM)
spi_send_byte(0x04, 0b00000100);
 
284,6 → 282,7
//ampere_wasted = *((int32_t *) &spi_cmd_buffer + 3);
// if this is the first receival we should print the small A
if (!(COSD_FLAGS2 & COSD_FLAG_STROMREC)) {
clear();
COSD_FLAGS2 &= ~COSD_ICONS_WRITTEN;
// update this flag
COSD_FLAGS2 |= COSD_FLAG_STROMREC;
/C-OSD/trunk/osd_fcmode_default.c
49,7 → 49,7
if (debugData.Analog[5] > max_Altimeter) max_Altimeter = debugData.Analog[5];
 
if (COSD_FLAGS & COSD_FLAG_ARTHORIZON) {
draw_artificial_horizon(top_line + 2, bottom_line - 1, debugData.Analog[0], debugData.Analog[1]);
draw_artificial_horizon(top_line + 2, bottom_line - 1, debugData.Analog[0], debugData.Analog[1]);
}
 
// pre-bottom line
/C-OSD/trunk/osd_ncmode_default.c
93,7 → 93,11
COSD_FLAGS2 &= ~COSD_ICONS_WRITTEN;
}
if (COSD_FLAGS & COSD_FLAG_ARTHORIZON) {
draw_artificial_horizon(top_line + 2, bottom_line - 1, naviData.AngleNick, naviData.AngleRoll);
if (COSD_FLAGS2 & COSD_FLAG_STROMREC) {
draw_artificial_horizon(top_line + 2, bottom_line - 2, naviData.AngleNick, naviData.AngleRoll);
} else {
draw_artificial_horizon(top_line + 2, bottom_line - 1, naviData.AngleNick, naviData.AngleRoll);
}
}
// motors are on, assume we were/are flying
COSD_FLAGS2 |= COSD_WASFLYING;
126,7 → 130,11
write_ascii_string_pgm(2, ++line, stats_item_pointers[6]); // latitude
write_gps_pos(15, line, naviData.CurrentPosition.Latitude);
} else if (COSD_FLAGS & COSD_FLAG_ARTHORIZON) { // if no stats there is space horizon
draw_artificial_horizon(top_line + 2, bottom_line - 1, naviData.AngleNick, naviData.AngleRoll);
if (COSD_FLAGS2 & COSD_FLAG_STROMREC) {
draw_artificial_horizon(top_line + 2, bottom_line - 2, naviData.AngleNick, naviData.AngleRoll);
} else {
draw_artificial_horizon(top_line + 2, bottom_line - 1, naviData.AngleNick, naviData.AngleRoll);
}
}
}
if (COSD_FLAGS & COSD_FLAG_BIGVARIO) {