/C-OSD/trunk/CHANGE.LOG |
---|
18,6 → 18,10 |
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
****************************************************************************/ |
20090408-0035 |
*rewrote number->display functions |
*fixed height bug (uint vs int) |
20090407-2100 |
+added request of OSD data, disrequest of debug data and uptime reset to menu |
-removed the uptime-reset binding from S2 |
/C-OSD/trunk/default/Makefile |
---|
13,7 → 13,7 |
## Compile options common for all C compilation units. |
CFLAGS = $(COMMON) |
CFLAGS += -Wall -gdwarf-2 -std=gnu99 -DF_CPU=16000000UL -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums |
CFLAGS += -Wall -gdwarf-2 -std=gnu99 -DF_CPU=16000000UL -O2 -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums |
CFLAGS += -MD -MP -MT $(*F).o -MF dep/$(@F).d |
## Assembly specific flags |
49,10 → 49,10 |
usart1.o: ../usart1.c |
$(CC) $(INCLUDES) $(CFLAGS) -c $< |
max7456_software_spi.o: ../max7456_software_spi.c |
$(CC) $(INCLUDES) $(CFLAGS) -c $< |
##Link |
$(TARGET): $(OBJECTS) |
$(CC) $(LDFLAGS) $(OBJECTS) $(LINKONLYOBJECTS) $(LIBDIRS) $(LIBS) -o $(TARGET) |
77,4 → 77,4 |
## Other dependencies |
-include $(shell mkdir dep 2>/dev/null) $(wildcard dep/*) |
-include $(shell mkdir dep 2>/dev/null) $(wildcard dep/*) |
/C-OSD/trunk/main.c |
---|
541,6 → 541,10 |
char* directions[8] = {"NE", "E ", "SE", "S ", "SW", "W ", "NW", "N "}; |
char arrowdir[8] = {218, 217, 224, 223, 222, 221, 220, 219}; |
/*write_ndigit_number_s_10th(5, 10, 1, 100, 0); |
write_ndigit_number_s_10th(5, 11, -1, 100, 0); |
write_ndigit_number_s_10th(5, 12, -11, 100, 0);*/ |
while (1) { |
// write icons at init or after menu/mode-switch |
if (!(COSD_FLAGS & COSD_ICONS_WRITTEN) && (COSD_FLAGS & COSD_FLAG_HUD)) { |
573,9 → 577,9 |
naviData = *((NaviData_t*) pRxData); |
// first line |
write_3digit_number_u(2, top_line, (uint16_t) (((uint32_t) naviData.GroundSpeed * 36) / 1000)); |
write_ndigit_number_u(2, top_line, (uint16_t) (((uint32_t) naviData.GroundSpeed * 36) / 1000), 100, 0); |
write_3digit_number_u(7, top_line, naviData.RC_Quality); |
write_ndigit_number_u(7, top_line, naviData.RC_Quality, 100, 0); |
if (naviData.RC_Quality <= RCLVL_WRN && last_RC_Quality > RCLVL_WRN) { |
for (uint8_t x = 0; x < 4; x++) |
write_char_att_xy(7 + x, top_line, BLINK); |
585,7 → 589,7 |
} |
last_RC_Quality = naviData.RC_Quality; |
write_3digit_number_u(13, top_line, naviData.CompassHeading); |
write_ndigit_number_u(13, top_line, naviData.CompassHeading, 100, 0); |
write_ascii_string(17, top_line, directions[heading_conv(naviData.CompassHeading)]); |
602,12 → 606,13 |
} |
//note:lephisto:according to several sources it's /30 |
if (naviData.Altimeter > 300) { |
if (naviData.Altimeter > 300 || naviData.Altimeter < -300) { |
// above 10m only write full meters |
write_number_s(22, top_line, naviData.Altimeter / 30); |
write_ndigit_number_s(23, top_line, naviData.Altimeter / 30, 1000, 0); |
} else { |
// up to 10m write meters.dm |
write_number_u_10th(21, top_line, naviData.Altimeter / 3); |
//write_number_u_10th(21, top_line, naviData.Altimeter / 3); |
write_ndigit_number_s_10th(23, top_line, naviData.Altimeter / 3, 100, 0); |
} |
// seccond line |
617,7 → 622,7 |
uint16_t heading_home = (naviData.HomePositionDeviation.Bearing + 360 - naviData.CompassHeading) % 360; |
write_char_xy(27, top_line + 1, arrowdir[heading_conv(heading_home)]); |
write_number_s(22, top_line + 1, naviData.HomePositionDeviation.Distance / 100); |
write_ndigit_number_u(24, top_line + 1, naviData.HomePositionDeviation.Distance / 100, 100, 0); |
// center |
if (naviData.MKFlags & FLAG_MOTOR_RUN) { // should be engines running |
633,16 → 638,16 |
// stats |
if (COSD_FLAGS & COSD_FLAG_STATS) { |
write_ascii_string_pgm(2, 5, stats_item_pointers[0]); // max Altitude |
write_number_s(17, 5, max_Altimeter / 30); |
write_ndigit_number_s(18, 5, max_Altimeter / 30, 1000, 0); |
write_char_xy(22, 5, 204); // small meters m |
write_ascii_string_pgm(2, 6, stats_item_pointers[1]); // max Speed |
write_3digit_number_u(19, 6, (uint16_t) (((uint32_t) max_GroundSpeed * 36) / 1000)); |
write_ndigit_number_u(19, 6, (uint16_t) (((uint32_t) max_GroundSpeed * 36) / 1000), 100, 0); |
write_char_xy(22, 6, 203); // km/h |
write_ascii_string_pgm(2, 7, stats_item_pointers[2]); // max Distance |
write_number_s(17, 7, max_Distance / 100); |
write_ndigit_number_u(19, 7, max_Distance / 100, 100, 0); |
write_char_xy(22, 7, 204); // small meters m |
write_ascii_string_pgm(2, 8, stats_item_pointers[3]); // min voltage |
write_number_u_10th(16, 8, min_UBat); |
write_ndigit_number_u_10th(18, 8, min_UBat, 100, 0); |
write_ascii_string(22, 8, "V"); // voltage |
write_ascii_string_pgm(2, 9, stats_item_pointers[4]); // max time |
write_time(16, 9, max_FlyingTime); |
653,7 → 658,7 |
} |
// bottom line |
write_number_u_10th(0, bottom_line, naviData.UBat); |
write_ndigit_number_u_10th(2, bottom_line, naviData.UBat, 100, 0); |
if (naviData.UBat <= UBAT_WRN && last_UBat > UBAT_WRN) { |
for (uint8_t x = 0; x < 7; x++) |
write_char_att_xy(x, bottom_line, BLINK); |
665,7 → 670,7 |
write_time(8, bottom_line, uptime); |
write_time(16, bottom_line, naviData.FlyingTime); |
write_3digit_number_u(23, bottom_line, naviData.SatsInUse); |
write_ndigit_number_u(24, bottom_line, naviData.SatsInUse, 10, 0); |
if (naviData.NCFlags & NC_FLAG_CH) { |
write_char_xy(27, bottom_line, 231); // gps ch |
/C-OSD/trunk/max7456_software_spi.c |
---|
147,123 → 147,150 |
} |
/** |
* Write only the last three digits of a <number> at <x>/<y> to MAX7456 |
* display memory. takes full 16bit numbers as well for stuff |
* like compass only taking three characters (values <= 999) |
* Write only some digits of a unsigned <number> at <x>/<y> to MAX7456 display memory |
* <num> represents the largest multiple of 10 that will still be displayable as |
* the first digit, so num = 10 will be 0-99 and so on |
* <pad> = 1 will cause blank spaced to be filled up with zeros e.g. 007 instead of 7 |
*/ |
void write_3digit_number_u(uint8_t x, uint8_t y, uint16_t number) { |
uint16_t num = 100; |
uint8_t started = 0; |
void write_ndigit_number_u(uint8_t x, uint8_t y, uint16_t number, int16_t num, uint8_t pad) { |
// if number is largar than 99[..]9 we must decrease it |
while (number >= (num * 10)) { |
number -= num * 10; |
} |
while (num > 0) { |
uint8_t b = number / num; |
if (b > 0 || started || num == 1) { |
write_ascii_char((x++)+(y * 30), '0' + b); |
started = 1; |
} else { |
write_ascii_char((x++)+(y * 30), 0); |
} |
number -= b * num; |
uint8_t started = 0; |
num /= 10; |
} |
while (num > 0) { |
uint8_t b = number / num; |
if (b > 0 || started || num == 1) { |
write_ascii_char((x++)+(y * 30), '0' + b); |
started = 1; |
} else { |
if (pad) write_ascii_char((x++)+(y * 30), '0'); |
else write_ascii_char((x++)+(y * 30), 0); |
} |
number -= b * num; |
num /= 10; |
} |
} |
/** |
* Write only the last two digits of a number at <x>/<y> to MAX7456 |
* display memory. takes full 16bit numbers as well for stuff |
* like seconds only taking two characters (values <= 99) |
* Since this is used for seconds only and it looks better, there |
* is a trading 0 attached |
* Write only some digits of a signed <number> at <x>/<y> to MAX7456 display memory |
* <num> represents the largest multiple of 10 that will still be displayable as |
* the first digit, so num = 10 will be 0-99 and so on |
* <pad> = 1 will cause blank spaced to be filled up with zeros e.g. 007 instead of 7 |
*/ |
void write_2digit_number_u(uint8_t x, uint8_t y, uint16_t number) { |
uint16_t num = 10; |
uint8_t started = 0; |
void write_ndigit_number_s(uint8_t x, uint8_t y, int16_t number, int16_t num, uint8_t pad) { |
if (((uint16_t) number) > 32767) { |
number = number - 65536; |
num *= -1; |
while (num > 0) { |
uint8_t b = number / num; |
if (b > 0 || started || num == 1) { |
write_ascii_char((x++)+(y * 30), '0' + b); |
started = 1; |
} else { |
write_ascii_char((x++)+(y * 30), '0'); |
} |
number -= b * num; |
// if number is smaller than -99[..]9 we must increase it |
while (number <= (num * 10)) { |
number -= num * 10; |
} |
num /= 10; |
} |
} |
uint8_t started = 0; |
/** |
* write a unsigned number as /10th at <x>/<y> to MAX7456 display memory |
*/ |
void write_number_u_10th(uint8_t x, uint8_t y, uint16_t number) { |
uint16_t num = 10000; |
uint8_t started = 0; |
while (num < 0) { |
uint8_t b = number / num; |
if (pad) write_ascii_char((x)+(y * 30), '0'); |
if (b > 0 || started || num == 1) { |
if (!started) write_char((x - 1)+(y * 30), 0x49); |
write_ascii_char((x++)+(y * 30), '0' + b); |
started = 1; |
} else { |
write_ascii_char((x++)+(y * 30), 0); |
} |
number -= b * num; |
while (num > 0) { |
uint8_t b = number / num; |
if (b > 0 || started || num == 1) { |
if ((num / 10) == 0) write_char((x++)+(y * 30), 65); |
write_ascii_char((x++)+(y * 30), '0' + b); |
started = 1; |
} else { |
write_ascii_char((x++)+(y * 30), 0); |
} |
number -= b * num; |
num /= 10; |
num /= 10; |
} |
} else { |
write_char((x)+(y * 30), 0); |
write_ndigit_number_u(x, y, number, num, pad); |
} |
} |
/** |
* write a unsigned number at <x>/<y> to MAX7456 display memory |
* Write only some digits of a unsigned <number> at <x>/<y> to MAX7456 display memory |
* as /10th of the value |
* <num> represents the largest multiple of 10 that will still be displayable as |
* the first digit, so num = 10 will be 0-99 and so on |
* <pad> = 1 will cause blank spaced to be filled up with zeros e.g. 007 instead of 7 |
*/ |
void write_number_u(uint8_t x, uint8_t y, uint16_t number) { |
uint16_t num = 10000; |
uint8_t started = 0; |
void write_ndigit_number_u_10th(uint8_t x, uint8_t y, uint16_t number, int16_t num, uint8_t pad) { |
// if number is largar than 99[..]9 we must decrease it |
while (number >= (num * 10)) { |
number -= num * 10; |
} |
while (num > 0) { |
uint8_t b = number / num; |
if (b > 0 || started || num == 1) { |
write_ascii_char((x++)+(y * 30), '0' + b); |
started = 1; |
} else { |
write_ascii_char((x++)+(y * 30), 0); |
} |
number -= b * num; |
uint8_t started = 0; |
while (num > 0) { |
uint8_t b = number / num; |
if (b > 0 || started || num == 1) { |
if ((num / 10) == 0) { |
if (!started) write_ascii_char((x - 1)+(y * 30), '0'); |
write_char((x++)+(y * 30), 65); // decimal point |
} |
write_ascii_char((x++)+(y * 30), '0' + b); |
started = 1; |
} else { |
if (pad) write_ascii_char((x++)+(y * 30), '0'); |
else write_ascii_char((x++)+(y * 30), ' '); |
} |
number -= b * num; |
num /= 10; |
} |
num /= 10; |
} |
} |
/** |
* write a signed number at <x>/<y> to MAX7456 display memory |
* Write only some digits of a signed <number> at <x>/<y> to MAX7456 display memory |
* as /10th of the value |
* <num> represents the largest multiple of 10 that will still be displayable as |
* the first digit, so num = 10 will be 0-99 and so on |
* <pad> = 1 will cause blank spaced to be filled up with zeros e.g. 007 instead of 7 |
*/ |
void write_number_s(uint8_t x, uint8_t y, int16_t w) { |
if (((uint16_t) w) > 32767) { |
w = w - 65536; |
void write_ndigit_number_s_10th(uint8_t x, uint8_t y, int16_t number, int16_t num, uint8_t pad) { |
if (((uint16_t) number) > 32767) { |
number = number - 65536; |
num *= -1; |
int16_t num = -10000; |
uint8_t started = 0; |
// if number is smaller than -99[..]9 we must increase it |
while (number <= (num * 10)) { |
number -= num * 10; |
} |
while (num < 0) { |
uint8_t b = w / num; |
if (b > 0 || started || num == 1) { |
if (!started) write_char((x - 1)+(y * 30), 0x49); |
write_ascii_char((x++)+(y * 30), '0' + b); |
started = 1; |
} else { |
write_ascii_char((x++)+(y * 30), 0); |
} |
w -= b * num; |
uint8_t started = 0; |
num /= 10; |
} |
} else { |
while (num < 0) { |
uint8_t b = number / num; |
if (pad) write_ascii_char((x)+(y * 30), '0'); |
if (b > 0 || started || num == 1) { |
if ((num / 10) == 0) { |
if (!started) { |
write_ascii_char((x - 2)+(y * 30), '-'); |
write_ascii_char((x - 1)+(y * 30), '0'); |
} |
write_char((x++)+(y * 30), 65); // decimal point |
} else if (!started) { |
write_char((x - 1)+(y * 30), 0x49); // minus |
} |
write_ascii_char((x++)+(y * 30), '0' + b); |
started = 1; |
} else { |
write_ascii_char((x++)+(y * 30), 0); |
} |
number -= b * num; |
num /= 10; |
} |
} else { |
write_char((x)+(y * 30), 0); |
write_number_u(x, y, w); |
write_ndigit_number_u_10th(x, y, number, num, pad); |
} |
} |
273,9 → 300,9 |
void write_time(uint8_t x, uint8_t y, uint16_t seconds) { |
uint16_t min = seconds / 60; |
seconds -= min * 60; |
write_3digit_number_u(x, y, min); |
write_ndigit_number_u(x, y, min, 100, 0); |
write_char_xy(x + 3, y, 68); |
write_2digit_number_u(x + 4, y, seconds); |
write_ndigit_number_u(x + 4, y, seconds, 10, 1); |
} |
/** |
/C-OSD/trunk/max7456_software_spi.h |
---|
84,34 → 84,38 |
void write_ascii_string_pgm(uint8_t, uint8_t, char*); |
/** |
* Write only the last three digits of a <number> at <x>/<y> to MAX7456 |
* display memory. takes full 16bit numbers as well for stuff |
* like compass only taking three characters (values <= 999) |
* Write only some digits of a unsigned <number> at <x>/<y> to MAX7456 display memory |
* <num> represents the largest multiple of 10 that will still be displayable as |
* the first digit, so num = 10 will be 0-99 and so on |
* <pad> = 1 will cause blank spaced to be filled up with zeros e.g. 007 instead of 7 |
*/ |
void write_3digit_number_u(uint8_t, uint8_t, uint16_t); |
void write_ndigit_number_u(uint8_t, uint8_t, uint16_t, int16_t, uint8_t); |
/** |
* Write only the last two digits of a number at <x>/<y> to MAX7456 |
* display memory. takes full 16bit numbers as well for stuff |
* like seconds only taking two characters (values <= 99) |
* Since this is used for seconds only and it looks better, there |
* is a trading 0 attached |
* Write only some digits of a signed <number> at <x>/<y> to MAX7456 display memory |
* <num> represents the largest multiple of 10 that will still be displayable as |
* the first digit, so num = 10 will be 0-99 and so on |
* <pad> = 1 will cause blank spaced to be filled up with zeros e.g. 007 instead of 7 |
*/ |
void write_2digit_number_u(uint8_t, uint8_t, uint16_t); |
/** |
* write a unsigned number as /10th at <x>/<y> to MAX7456 display memory |
*/ |
void write_number_u_10th(uint8_t, uint8_t, uint16_t); |
void write_ndigit_number_s(uint8_t, uint8_t, int16_t, int16_t, uint8_t); |
/** |
* write a unsigned number at <x>/<y> to MAX7456 display memory |
* Write only some digits of a unsigned <number> at <x>/<y> to MAX7456 display memory |
* as /10th of the value |
* <num> represents the largest multiple of 10 that will still be displayable as |
* the first digit, so num = 10 will be 0-99 and so on |
* <pad> = 1 will cause blank spaced to be filled up with zeros e.g. 00.7 instead of .7 |
*/ |
void write_number_u(uint8_t, uint8_t, uint16_t); |
void write_ndigit_number_u_10th(uint8_t, uint8_t, uint16_t, int16_t, uint8_t); |
/** |
* write a signed number at <x>/<y> to MAX7456 display memory |
* Write only some digits of a signed <number> at <x>/<y> to MAX7456 display memory |
* as /10th of the value |
* <num> represents the largest multiple of 10 that will still be displayable as |
* the first digit, so num = 10 will be 0-99 and so on |
* <pad> = 1 will cause blank spaced to be filled up with zeros e.g. 00.7 instead of .7 |
*/ |
void write_number_s(uint8_t, uint8_t, int16_t); |
void write_ndigit_number_s_10th(uint8_t, uint8_t, int16_t, int16_t, uint8_t); |
/** |
* write <seconds> as human readable time at <x>/<y> to MAX7456 display mem |