Subversion Repositories Projects

Compare Revisions

Regard whitespace Rev 735 → Rev 736

/C-OSD/trunk/max7456_software_spi.c
27,6 → 27,9
#include "main.h"
#include "max7456_software_spi.h"
 
 
char conv_array[7]; // general array for number -> char conversation
 
/* ##########################################################################
* MAX7456 SPI & Display stuff
* ##########################################################################*/
91,6 → 94,7
}
 
 
#if (ALLCHARSDEBUG|(WRITECHARS != -1))
/**
* for testing write all chars to screen
*/
105,6 → 109,30
}
}
 
/**
* let the MAX7456 learn a new character at <number>
* with <data>.
*/
void learn_char(uint8_t number, unsigned char* data) {
// select character to write (CMAH)
spi_send_byte(0x09, number);
 
for (uint8_t i = 0; i < 54; i++) {
// select 4pixel byte of char (CMAL)
spi_send_byte(0x0A, i);
 
// write 4pixel byte of char (CMDI)
spi_send_byte(0x0B, data[i]);
}
 
// write to the NVM array from the shadow RAM (CMM)
spi_send_byte(0x08, 0b10100000);
 
// according to maxim writing to nvram takes about 12ms, lets wait longer
_delay_ms(120);
}
#endif
 
#if !(ALLCHARSDEBUG|(WRITECHARS != -1))
 
/**
135,29 → 163,6
}
 
/**
* let the MAX7456 learn a new character at <number>
* with <data>.
*/
void learn_char(uint8_t number, unsigned char* data) {
// select character to write (CMAH)
spi_send_byte(0x09, number);
 
for (uint8_t i = 0; i < 54; i++) {
// select 4pixel byte of char (CMAL)
spi_send_byte(0x0A, i);
 
// write 4pixel byte of char (CMDI)
spi_send_byte(0x0B, data[i]);
}
 
// write to the NVM array from the shadow RAM (CMM)
spi_send_byte(0x08, 0b10100000);
 
// according to maxim writing to nvram takes about 12ms, lets wait longer
_delay_ms(120);
}
 
/**
* write an ascii <character> to <address> of MAX7456 display memory
*/
void write_ascii_char(uint16_t address, char c) {
169,17 → 174,17
else if (c == '(') c = 63; // remap
else if (c == ')') c = 64; // remap
else if (c == '.') c = 65; // remap
else if (c == '?') c = 66; // remap
else if (c == '-') c = 73; // remap minus
else if (c == ';') c = 67; // remap
else if (c == ':') c = 68; // remap
else if (c == ',') c = 69; // remap
else if (c == '\'') c = 70; // remap
else if (c == '/') c = 71; // remap
else if (c == '"') c = 72; // remap
else if (c == '-') c = 73; // remap minus
else if (c == '<') c = 74; // remap
else if (c == '>') c = 75; // remap
else if (c == '@') c = 76; // 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
write_char(address, c);
}
 
215,13 → 220,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) {
char s[7];
itoa(number, s, 10 );
for (uint8_t i = 0; i < length - strlen(s); i++) {
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, s);
write_ascii_string(x, y, conv_array);
}
 
/**
230,13 → 234,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) {
char s[7];
itoa(number, s, 10 );
for (uint8_t i = 0; i < length - strlen(s); i++) {
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, s);
write_ascii_string(x, y, conv_array);
}
 
/**
245,22 → 248,21
* <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) {
char s[7];
itoa(number, s, 10 );
uint8_t len = strlen(s);
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 = s[len - 1];
s[len - 1] = 0;
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 && s[0] == '-') {
} 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, s);
write_ascii_string(x, y, conv_array);
}
x += len - 1;
write_char((x++)+(y * 30), 65); // decimal point
273,22 → 275,21
* <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) {
char s[7];
itoa(number, s, 10 );
uint8_t len = strlen(s);
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 = s[len - 1];
s[len - 1] = 0;
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 && s[0] == '-') {
} 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, s);
write_ascii_string(x, y, conv_array);
}
x += len - 1;
write_char((x++)+(y * 30), 65); // decimal point