85,6 → 85,10 |
uint8_t top_line = 1; |
uint8_t bottom_line = 14; |
|
// battery voltages |
uint8_t min_voltage = 0; |
uint8_t max_voltage = 0; |
|
// Flags |
uint8_t COSD_FLAGS = 0; |
|
453,6 → 457,36 |
Decode64(); |
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; |
} |
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); |
|
542,16 → 576,17 |
} |
|
// bottom line |
draw_battery(2, bottom_line, naviData.UBat); |
draw_battery(2, bottom_line, min_voltage, naviData.UBat, max_voltage); |
write_ndigit_number_u_10th(3, bottom_line, naviData.UBat, 100, 0); |
if (naviData.UBat <= UBAT_WRN && last_UBat > UBAT_WRN) { |
if (naviData.UBat <= min_voltage && last_UBat > min_voltage) { |
for (uint8_t x = 2; x < 8; x++) |
write_char_att_xy(x, bottom_line, BLINK); |
} else { |
} else if (naviData.UBat > min_voltage && last_UBat < min_voltage) { |
for (uint8_t x = 2; x < 8; x++) |
write_char_att_xy(x, bottom_line, 0); |
} |
|
// remember last values |
last_UBat = naviData.UBat; |
|
write_time(8, bottom_line, uptime); |
write_time(15, bottom_line, naviData.FlyingTime); |