84,7 → 84,6 |
|
/** |
* auto config some stuff on startup, currently only battery cells |
* TODO: this is testing stuff, strings should go progmem and so on... |
*/ |
void init_cosd(uint8_t UBat) { |
clear(); |
178,69 → 177,91 |
/** |
* helper function for flag display |
*/ |
void onoff(uint8_t line, uint8_t onoff) { |
void onoff(uint8_t col, uint8_t line, uint8_t onoff) { |
if (onoff) { |
write_ascii_string_pgm(23, line, PSTR("ON ")); |
write_ascii_string_pgm(col, line, PSTR("ON ")); |
} else { |
write_ascii_string_pgm(23, line, PSTR("OFF")); |
write_ascii_string_pgm(col, line, PSTR("OFF")); |
} |
} |
|
|
/** |
* helper function for menu updating |
*/ |
void config_menu_drawings(uint8_t chosen) { |
uint8_t line = 2; |
static uint8_t old_y = 0; |
uint8_t x = MENU_LEFT, y = MENU_TOP, line = MENU_TOP; |
|
// clear prevoius _cursor_ |
//write_char_xy(3, line + ((chosen + 11) % 12), 0x00); |
for (uint8_t x = 2; x < 28; x++) { |
write_char_att_xy(x, line + ((chosen + 11) % 12), 0); |
write_char_att_xy(x, line + chosen, BLACKBG | INVERT); |
if (chosen > 5 && chosen < 12) { // right |
x = MENU_MIDDLE; |
y = chosen - 6 + MENU_TOP; |
} else if (chosen < 7) { |
y = chosen + MENU_TOP; |
} else { |
y = chosen - 6 + MENU_TOP; |
} |
|
// clear prevoius _cursor_ and draw current |
for (uint8_t myx = MENU_LEFT; myx < 29; myx++) { |
write_char_att_xy(myx, old_y, 0); |
if (myx > x - 1 && myx < x + 14) { |
write_char_att_xy(myx, y, BLACKBG | INVERT); |
} |
}; |
// draw current _cursor_ |
//write_char_xy(3, line + chosen, 0xD9); |
|
|
write_ascii_string_pgm(4, line, PSTR("Video Mode")); |
write_ascii_string_pgm(MENU_LEFT, line, PSTR("Video")); |
if (COSD_FLAGS_CONFIG & COSD_FLAG_NTSC) { |
write_ascii_string_pgm(23, line, VM_NTSC); |
write_ascii_string_pgm(MENU_LEFT + 10, line, VM_NTSC); |
} else { |
write_ascii_string_pgm(23, line, VM_PAL); |
write_ascii_string_pgm(MENU_LEFT + 10, line, VM_PAL); |
} |
|
write_ascii_string_pgm(4, ++line, PSTR("Full HUD")); |
onoff(line, COSD_FLAGS_MODES & COSD_FLAG_HUD); |
write_ascii_string_pgm(MENU_LEFT, ++line, PSTR("Full HUD")); |
onoff(MENU_LEFT + 10, line, COSD_FLAGS_MODES & COSD_FLAG_HUD); |
|
write_ascii_string_pgm(4, ++line, PSTR("Art Horizon in HUD")); |
onoff(line, COSD_FLAGS_MODES & COSD_FLAG_ARTHORIZON); |
write_ascii_string_pgm(MENU_LEFT, ++line, PSTR("Horizon")); |
onoff(MENU_LEFT + 10, line, COSD_FLAGS_MODES & COSD_FLAG_ARTHORIZON); |
|
write_ascii_string_pgm(MENU_LEFT, ++line, PSTR("Aggr.Hor.")); |
onoff(MENU_LEFT + 10, line, COSD_FLAGS_MODES & COSD_FLAG_AGGRHORIZON); |
|
write_ascii_string_pgm(4, ++line, PSTR("Big Vario bar")); |
onoff(line, COSD_FLAGS_MODES & COSD_FLAG_BIGVARIO); |
write_ascii_string_pgm(MENU_LEFT, ++line, PSTR("Stats")); |
onoff(MENU_LEFT + 10, line, COSD_FLAGS_MODES & COSD_FLAG_STATS); |
|
write_ascii_string_pgm(4, ++line, PSTR("Statistics")); |
onoff(line, COSD_FLAGS_MODES & COSD_FLAG_STATS); |
write_ascii_string_pgm(MENU_LEFT, ++line, PSTR("A by FC")); |
onoff(MENU_LEFT + 10, line, COSD_FLAGS_MODES & COSD_FLAG_FCCURRENT); |
|
write_ascii_string_pgm(4, ++line, PSTR("Current by FC")); |
onoff(line, COSD_FLAGS_MODES & COSD_FLAG_FCCURRENT); |
// 2nd col |
line = 2; |
|
write_ascii_string_pgm(4, ++line, PSTR("Voltage by C-Strom")); |
onoff(line, COSD_FLAGS_MODES & COSD_FLAG_STROMVOLT); |
|
write_ascii_string_pgm(4, ++line, PSTR("Reset uptime")); |
write_ascii_string_pgm(MENU_MIDDLE, line, PSTR("V C-Strom")); |
onoff(MENU_MIDDLE + 10, line, COSD_FLAGS_MODES & COSD_FLAG_STROMVOLT); |
|
write_ascii_string_pgm(4, ++line, PSTR("Display Mode")); |
write_ascii_string_pgm(18, line, (const char *) (pgm_read_word(&(mode->desc)))); |
|
write_ascii_string_pgm(4, ++line, PSTR("Height by")); |
write_ascii_string_pgm(MENU_MIDDLE, ++line, PSTR("Height by")); |
if (COSD_FLAGS_CONFIG & COSD_FLAG_GPSHEIGHT) { |
write_ascii_string_pgm(20, line, PSTR(" GPS")); |
write_ascii_string_pgm(MENU_MIDDLE + 10, line, PSTR(" GPS")); |
} else { |
write_ascii_string_pgm(20, line, PSTR("BARO")); |
write_ascii_string_pgm(MENU_MIDDLE + 10, line, PSTR("BARO")); |
} |
|
write_ascii_string_pgm(4, ++line, PSTR("Save config")); |
write_ascii_string_pgm(4, ++line, PSTR("EXIT")); |
write_ascii_string_pgm(MENU_MIDDLE, ++line, PSTR("Feet/mph")); |
onoff(MENU_MIDDLE + 10, line, COSD_FLAGS_CONFIG & COSD_FLAG_FEET); |
|
write_ascii_string_pgm(MENU_MIDDLE, ++line, PSTR("Big Vario")); |
onoff(MENU_MIDDLE + 10, line, COSD_FLAGS_MODES & COSD_FLAG_BIGVARIO); |
|
|
// bottom |
write_ascii_string_pgm(MENU_LEFT, 9, PSTR("Reset uptime")); |
|
write_ascii_string_pgm(MENU_LEFT, 10, PSTR("Display Mode")); |
write_ascii_string_pgm(18, 10, (const char *) (pgm_read_word(&(mode->desc)))); |
|
write_ascii_string_pgm(MENU_LEFT, 11, PSTR("Save config")); |
write_ascii_string_pgm(MENU_LEFT, 12, PSTR("EXIT")); |
|
old_y = y; |
} |
|
/** |
247,7 → 268,7 |
* some sort of clicking response in the menu |
*/ |
void config_menu_doclick(uint8_t chosen) { |
write_ascii_string_pgm(4, chosen + 2, PSTR("DONE ")); |
write_ascii_string_pgm(MENU_LEFT, chosen + MENU_TOP - 6, PSTR("DONE ")); |
_delay_ms(500); |
config_menu_drawings(chosen); |
} |
273,7 → 294,8 |
|
while (inmenu) { |
if (s2_pressed()) { |
chosen = (chosen + 1) % 12; |
chosen = (chosen + 1) % 17; |
if (chosen == 10) chosen = 13; // SKIP unused menu space for now |
config_menu_drawings(chosen); |
_delay_ms(500); |
} else if (s1_pressed()) { |
292,41 → 314,39 |
|
bottom_line = 14; |
} |
config_menu_drawings(chosen); |
break; |
case 1: // full HUD |
COSD_FLAGS_MODES ^= COSD_FLAG_HUD; |
config_menu_drawings(chosen); |
break; |
case 2: // art horizon |
COSD_FLAGS_MODES ^= COSD_FLAG_ARTHORIZON; |
config_menu_drawings(chosen); |
break; |
case 3: // big vario |
COSD_FLAGS_MODES ^= COSD_FLAG_BIGVARIO; |
config_menu_drawings(chosen); |
case 3: // aggressiva horizon |
COSD_FLAGS_MODES ^= COSD_FLAG_AGGRHORIZON; |
break; |
case 4: // statistics |
COSD_FLAGS_MODES ^= COSD_FLAG_STATS; |
config_menu_drawings(chosen); |
break; |
/*case 5: // warnings |
COSD_FLAGS_MODES ^= COSD_FLAG_WARNINGS; |
config_menu_drawings(chosen); |
break;*/ |
case 5: // current by fc |
COSD_FLAGS_MODES ^= COSD_FLAG_FCCURRENT; |
config_menu_drawings(chosen); |
break; |
case 6: // 2nd voltage by c-strom |
COSD_FLAGS_MODES ^= COSD_FLAG_STROMVOLT; |
config_menu_drawings(chosen); |
break; |
case 7: // reset uptime |
case 7: // GPS or BARO height |
COSD_FLAGS_CONFIG ^= COSD_FLAG_GPSHEIGHT; |
break; |
case 8: // Feet and mph? |
COSD_FLAGS_CONFIG ^= COSD_FLAG_FEET; |
break; |
case 9: // big vario |
COSD_FLAGS_MODES ^= COSD_FLAG_BIGVARIO; |
break; |
case 13: // reset uptime |
uptime = 0; |
config_menu_doclick(chosen); |
config_menu_doclick(chosen); |
break; |
case 8: // change mode |
case 14: // change mode |
#if FCONLY |
COSD_DISPLAYMODE = (COSD_DISPLAYMODE + 1) % (sizeof(fcdisplaymodes) / sizeof(displaymode_t)); |
mode = fcdisplaymodes; |
338,20 → 358,17 |
mode += COSD_DISPLAYMODE; |
osd_ncmode = (int(*)(void)) pgm_read_word(&mode->dfun); |
#endif |
config_menu_drawings(chosen); |
break; |
case 9: // GPS or BARO height |
COSD_FLAGS_CONFIG ^= COSD_FLAG_GPSHEIGHT; |
config_menu_drawings(chosen); |
break; |
case 10: // save |
case 15: // save |
save_eeprom(); |
config_menu_doclick(chosen); |
config_menu_doclick(chosen); |
break; |
case 11: // exit |
case 16: // exit |
inmenu = 0; |
config_menu_doclick(chosen); |
break; |
} |
config_menu_drawings(chosen); |
_delay_ms(250); |
} |
} |