114,6 → 114,7 |
/* ########################################################################## |
* Interrupt handler |
* ##########################################################################*/ |
|
/** |
* handler for undefined Interrupts |
* if not defined AVR will reset in case any unhandled interrupts occur |
126,6 → 127,7 |
/* ########################################################################## |
* timer stuff |
* ##########################################################################*/ |
|
/** |
* timer kicks in every 1000uS ^= 1ms |
*/ |
295,7 → 297,45 |
sei(); |
} |
|
/** |
* auto config some stuff on startup, currently only battery cells |
* TODO: this is testing stuff, strings should go progmem and so on... |
*/ |
void auto_config(uint8_t UBat, uint8_t* min_UBat) { |
clear(); |
// fix for min_bat glitch caused by data only gathered during motors up |
*min_UBat = UBat; |
write_ascii_string(2, 2, "C-OSD Initialisation"); |
#if FCONLY |
write_ascii_string(2, 3, "FC only Mode"); |
#else |
write_ascii_string(2, 3, "NaviCtrl Mode"); |
#endif |
uint8_t cellnum = 0; |
if (CELL_NUM == -1) { |
write_ascii_string(2, 5, "Guessing Number of Cells"); |
do { |
cellnum++; |
} while (UBat > ((cellnum * CELL_VOLT_MAX) + 10)); |
} else { |
cellnum = CELL_NUM; |
} |
min_voltage = cellnum * CELL_VOLT_MIN; |
max_voltage = cellnum * CELL_VOLT_MAX; |
write_ascii_string(2, 7, "Number of Cells:"); |
write_ndigit_number_u(21, 7, cellnum, 1, 0); |
write_ascii_string(2, 8, "Warn Voltage :"); |
write_ndigit_number_s_10th(20, 8, min_voltage, 100, 0); |
write_ascii_string(2, 9, "Max Voltage :"); |
write_ndigit_number_s_10th(20, 9, max_voltage, 100, 0); |
_delay_ms(200); |
clear(); |
// update flags to paint display again because of clear |
COSD_FLAGS &= ~COSD_ICONS_WRITTEN; |
} |
|
#endif // ends !(ALLCHARSDEBUG|(WRITECHARS != -1)) |
|
/* ########################################################################## |
* MAIN |
* ##########################################################################*/ |
355,7 → 395,6 |
// DISABLE display (VM0) |
spi_send_byte(0x00, 0b00000000); |
#include "characters.c" |
|
#endif |
|
// Setup Video Mode |
406,7 → 445,6 |
// clear serial screen |
//usart1_puts("\x1B[2J\x1B[H"); |
//usart1_puts("hello world!\r\n"); |
|
#if FCONLY |
// request data ever 100ms from FC; |
usart1_request_mk_data(0, 'd', 100); |
462,8 → 500,12 |
if (rxd_buffer[2] == 'D') { // FC Data |
Decode64(); |
debugData = *((DebugOut_t*) pRxData); |
write_ascii_string(2, 2, "FCONLY MODE"); |
|
// init on first data retrival, distinguished by last battery :) |
if (last_UBat == 255) { |
auto_config(debugData.Analog[9], &min_UBat); |
} |
|
write_ndigit_number_u(7, top_line, debugData.Analog[10], 100, 0); |
if (debugData.Analog[10] <= RCLVL_WRN && last_RC_Quality > RCLVL_WRN) { |
for (uint8_t x = 0; x < 4; x++) |
483,6 → 525,10 |
write_ndigit_number_s_10th(23, top_line, debugData.Analog[5] / 3, 100, 0); |
} |
|
if (COSD_FLAGS & COSD_FLAG_ARTHORIZON) { |
draw_artificial_horizon(top_line + 2, bottom_line - 1, naviData.AngleNick, naviData.AngleRoll); |
} |
|
draw_battery(2, bottom_line, min_voltage, debugData.Analog[9], max_voltage); |
write_ndigit_number_u_10th(3, bottom_line, debugData.Analog[9], 100, 0); |
if (debugData.Analog[9] <= min_voltage && last_UBat > min_voltage) { |
511,34 → 557,9 |
naviData = *((NaviData_t*) pRxData); |
|
// init on first data retrival, distinguished by last battery :) |
// TODO: this is testing stuff, strings should go progmem and so on... |
if (last_UBat == 255) { |
clear(); |
// fix for min_bat glitch caused by data only gathered during motors up |
min_UBat = naviData.UBat; |
write_ascii_string(2, 2, "C-OSD Initialisation"); |
uint8_t cellnum = 0; |
if (CELL_NUM == -1) { |
write_ascii_string(2, 5, "Guessing Number of Cells"); |
do { |
cellnum++; |
} while (naviData.UBat > ((cellnum * CELL_VOLT_MAX) + 10)); |
} else { |
cellnum = CELL_NUM; |
auto_config(naviData.UBat, &min_UBat); |
} |
min_voltage = cellnum * CELL_VOLT_MIN; |
max_voltage = cellnum * CELL_VOLT_MAX; |
write_ascii_string(2, 7, "Number of Cells:"); |
write_ndigit_number_u(21, 7, cellnum, 1, 0); |
write_ascii_string(2, 8, "Warn Voltage :"); |
write_ndigit_number_s_10th(20, 8, min_voltage, 100, 0); |
write_ascii_string(2, 9, "Max Voltage :"); |
write_ndigit_number_s_10th(20, 9, max_voltage, 100, 0); |
_delay_ms(200); |
clear(); |
// update flags to paint display again because of clear |
COSD_FLAGS &= ~COSD_ICONS_WRITTEN; |
} |
|
// first line |
write_ndigit_number_u(2, top_line, (uint16_t) (((uint32_t) naviData.GroundSpeed * (uint32_t)9) / (uint32_t)250), 100, 0); |