19,7 → 19,6 |
****************************************************************************/ |
|
#include <avr/io.h> |
|
#include <util/delay.h> |
#include <avr/pgmspace.h> |
#include <string.h> |
66,7 → 65,6 |
MAX_CS_HIGH |
} |
|
|
/** |
* write a <character> to <address> of MAX7456 display memory |
*/ |
76,7 → 74,6 |
spi_send_byte(0x07, character); // DMDI |
} |
|
|
/** |
* clear display memory |
* (also sets 8bit mode) |
86,7 → 83,7 |
for (unsigned int a = 0; a < 480; a++) { |
write_char(memory_address++, 0); |
}*/ |
// clear all display-mem (DMM) |
// clear all display-mem (DMM) |
spi_send_byte(0x04, 0b01000100); |
|
// clearing takes 12uS according to maxim so lets wait longer |
95,6 → 92,7 |
|
|
#if (ALLCHARSDEBUG|(WRITECHARS != -1)) |
|
/** |
* for testing write all chars to screen |
*/ |
101,7 → 99,7 |
void write_all_chars() { |
uint16_t x = 3, y = 2, t = 0; |
while (t < 256) { |
write_char(x++ + y*30, t++); |
write_char(x++ + y * 30, t++); |
if (x > 25) { |
y++; |
x = 3; |
178,13 → 176,13 |
else if (c == ';') c = 67; // remap |
else if (c == ':') c = 68; // remap |
else if (c == ',') c = 69; // remap |
// else if (c == '?') c = 66; // remap |
// else if (c == '\'') c = 70; // remap |
// else if (c == '?') c = 66; // remap |
// else if (c == '\'') c = 70; // remap |
else if (c == '/') c = 71; // remap |
// else if (c == '"') c = 72; // remap |
// else if (c == '<') c = 74; // remap |
// else if (c == '>') c = 75; // remap |
// else if (c == '@') c = 76; // remap |
// else if (c == '"') c = 72; // remap |
// else if (c == '<') c = 74; // remap |
// else if (c == '>') c = 75; // remap |
// else if (c == '@') c = 76; // remap |
write_char(address, c); |
} |
|
202,8 → 200,8 |
* write an ascii <string> from progmen at <x>/<y> to MAX7456 display memory |
*/ |
void write_ascii_string_pgm(uint8_t x, uint8_t y, const char *string) { |
while (pgm_read_byte(string) != 0x00) |
write_ascii_char(((x++)+(y * 30)), pgm_read_byte(string++)); |
while (pgm_read_byte(string) != 0x00) |
write_ascii_char(((x++)+(y * 30)), pgm_read_byte(string++)); |
} |
|
/** |
210,8 → 208,8 |
* write an <string> from progmen at <x>/<y> downwards to MAX7456 display memory |
*/ |
void write_string_pgm_down(uint8_t x, uint8_t y, const char *string, uint8_t length) { |
while (length--) |
write_char((x+(y++ * 30)), pgm_read_byte(string++)); |
while (length--) |
write_char((x + (y++ * 30)), pgm_read_byte(string++)); |
} |
|
/** |
220,12 → 218,12 |
* <pad> = 1 will cause blank spaced to be filled up with zeros e.g. 007 instead of 7 |
*/ |
void write_ndigit_number_u(uint8_t x, uint8_t y, uint16_t number, int16_t length, uint8_t pad) { |
itoa(number, conv_array, 10 ); |
for (uint8_t i = 0; i < length - strlen(conv_array); i++) { |
if (pad) write_char((x++)+(y * 30), 10); |
else write_ascii_char((x++)+(y * 30), 0); |
} |
write_ascii_string(x, y, conv_array); |
itoa(number, conv_array, 10); |
for (uint8_t i = 0; i < length - strlen(conv_array); i++) { |
if (pad) write_char((x++)+(y * 30), 10); |
else write_ascii_char((x++)+(y * 30), 0); |
} |
write_ascii_string(x, y, conv_array); |
} |
|
/** |
234,12 → 232,12 |
* <pad> = 1 will cause blank spaced to be filled up with zeros e.g. 007 instead of 7 |
*/ |
void write_ndigit_number_s(uint8_t x, uint8_t y, int16_t number, int16_t length, uint8_t pad) { |
itoa(number, conv_array, 10 ); |
for (uint8_t i = 0; i < length - strlen(conv_array); i++) { |
if (pad) write_char((x++)+(y * 30), 10); |
else write_ascii_char((x++)+(y * 30), 0); |
} |
write_ascii_string(x, y, conv_array); |
itoa(number, conv_array, 10); |
for (uint8_t i = 0; i < length - strlen(conv_array); i++) { |
if (pad) write_char((x++)+(y * 30), 10); |
else write_ascii_char((x++)+(y * 30), 0); |
} |
write_ascii_string(x, y, conv_array); |
} |
|
/** |
248,25 → 246,25 |
* <pad> = 1 will cause blank spaced to be filled up with zeros e.g. 007 instead of 7 |
*/ |
void write_ndigit_number_u_10th(uint8_t x, uint8_t y, uint16_t number, int16_t length, uint8_t pad) { |
itoa(number, conv_array, 10 ); |
uint8_t len = strlen(conv_array); |
for (uint8_t i = 0; i < length - len; i++) { |
if (pad) write_char((x++)+(y * 30), 10); // zero |
else write_char((x++)+(y * 30), 0); // blank |
} |
char rest = conv_array[len - 1]; |
conv_array[len - 1] = 0; |
if (len == 1) { |
write_char((x-1)+(y * 30), 10); // zero |
} else if (len == 2 && conv_array[0] == '-') { |
write_char((x-1)+(y * 30), 0x49); // minus |
write_char((x)+(y * 30), 10); // zero |
} else { |
write_ascii_string(x, y, conv_array); |
} |
x += len - 1; |
write_char((x++)+(y * 30), 65); // decimal point |
write_ascii_char((x++)+(y * 30), rest); // after dot |
itoa(number, conv_array, 10); |
uint8_t len = strlen(conv_array); |
for (uint8_t i = 0; i < length - len; i++) { |
if (pad) write_char((x++)+(y * 30), 10); // zero |
else write_char((x++)+(y * 30), 0); // blank |
} |
char rest = conv_array[len - 1]; |
conv_array[len - 1] = 0; |
if (len == 1) { |
write_char((x - 1)+(y * 30), 10); // zero |
} else if (len == 2 && conv_array[0] == '-') { |
write_char((x - 1)+(y * 30), 0x49); // minus |
write_char((x)+(y * 30), 10); // zero |
} else { |
write_ascii_string(x, y, conv_array); |
} |
x += len - 1; |
write_char((x++)+(y * 30), 65); // decimal point |
write_ascii_char((x++)+(y * 30), rest); // after dot |
} |
|
/** |
275,25 → 273,25 |
* <pad> = 1 will cause blank spaced to be filled up with zeros e.g. 007 instead of 7 |
*/ |
void write_ndigit_number_s_10th(uint8_t x, uint8_t y, int16_t number, int16_t length, uint8_t pad) { |
itoa(number, conv_array, 10 ); |
uint8_t len = strlen(conv_array); |
for (uint8_t i = 0; i < length - len; i++) { |
if (pad) write_char((x++)+(y * 30), 10); // zero |
else write_char((x++)+(y * 30), 0); // blank |
} |
char rest = conv_array[len - 1]; |
conv_array[len - 1] = 0; |
if (len == 1) { |
write_char((x-1)+(y * 30), 10); // zero |
} else if (len == 2 && conv_array[0] == '-') { |
write_char((x-1)+(y * 30), 0x49); // minus |
write_char((x)+(y * 30), 10); // zero |
} else { |
write_ascii_string(x, y, conv_array); |
} |
x += len - 1; |
write_char((x++)+(y * 30), 65); // decimal point |
write_ascii_char((x++)+(y * 30), rest); // after dot |
itoa(number, conv_array, 10); |
uint8_t len = strlen(conv_array); |
for (uint8_t i = 0; i < length - len; i++) { |
if (pad) write_char((x++)+(y * 30), 10); // zero |
else write_char((x++)+(y * 30), 0); // blank |
} |
char rest = conv_array[len - 1]; |
conv_array[len - 1] = 0; |
if (len == 1) { |
write_char((x - 1)+(y * 30), 10); // zero |
} else if (len == 2 && conv_array[0] == '-') { |
write_char((x - 1)+(y * 30), 0x49); // minus |
write_char((x)+(y * 30), 10); // zero |
} else { |
write_ascii_string(x, y, conv_array); |
} |
x += len - 1; |
write_char((x++)+(y * 30), 65); // decimal point |
write_ascii_char((x++)+(y * 30), rest); // after dot |
} |
|
/** |
311,20 → 309,20 |
* wirte a <position> at <x>/<y> assuming it is a gps position for long-/latitude |
*/ |
void write_gps_pos(uint8_t x, uint8_t y, int32_t position) { |
if (position < 0) { |
position ^= ~0; |
position++; |
write_char_xy(x++, y, 0x49); // minus |
} else { |
write_char_xy(x++, y, 0); // clear ('+' would be nice, maybe later) |
} |
write_ndigit_number_u(x, y, (uint16_t) (position / (int32_t) 10000000), 3, 1); |
write_char_xy(x + 3, y, 65); // decimal point |
position = position - ((position / (int32_t) 10000000) * (int32_t) 10000000); |
write_ndigit_number_u(x + 4, y, (uint16_t) (position / (int32_t) 1000), 4, 1); |
position = position - ((uint16_t) (position / (int32_t) 1000) * (int32_t) 1000); |
write_ndigit_number_u(x + 8, y, (uint16_t) position, 3, 1); |
write_char_xy(x + 11, y, 0xD0); // degree symbol |
if (position < 0) { |
position ^= ~0; |
position++; |
write_char_xy(x++, y, 0x49); // minus |
} else { |
write_char_xy(x++, y, 0); // clear ('+' would be nice, maybe later) |
} |
write_ndigit_number_u(x, y, (uint16_t)(position / (int32_t)10000000), 3, 1); |
write_char_xy(x + 3, y, 65); // decimal point |
position = position - ((position / (int32_t)10000000) * (int32_t)10000000); |
write_ndigit_number_u(x + 4, y, (uint16_t)(position / (int32_t)1000), 4, 1); |
position = position - ((uint16_t)(position / (int32_t)1000) * (int32_t)1000); |
write_ndigit_number_u(x + 8, y, (uint16_t)position, 3, 1); |
write_char_xy(x + 11, y, 0xD0); // degree symbol |
} |
|
#endif |