Subversion Repositories Projects

Compare Revisions

Regard whitespace Rev 1436 → Rev 1437

/C-OSD/trunk/max7456_software_spi.c
1,5 → 1,5
/****************************************************************************
* Copyright (C) 2009-2011 by Claas Anders "CaScAdE" Rathje *
* Copyright (C) 2009-2012 by Claas Anders "CaScAdE" Rathje *
* admiralcascade@gmail.com *
* Project-URL: http://www.mylifesucks.de/oss/c-osd/ *
* *
30,7 → 30,7
 
char conv_array[7]; // general array for number -> char conversation
 
int pow(int a, int b) {
int int_pow(int a, int b) {
if (b <= 0) return 1;
int res = 1;
while (b-- > 0) res *= a;
86,9 → 86,9
* write a <character> to <address> of MAX7456 display memory
*/
void write_char(uint16_t address, char character) {
spi_send_byte(0x05, (address & 0xFF00) >> 8); // DMAH
spi_send_byte(0x06, (address & 0x00FF)); // DMAL
spi_send_byte(0x07, character); // DMDI
spi_send_byte(MAX7456_DMAH, (address & 0xFF00) >> 8);
spi_send_byte(MAX7456_DMAL, (address & 0x00FF));
spi_send_byte(MAX7456_DMDI, character);
}
 
/**
101,10 → 101,10
write_char(memory_address++, 0);
}*/
// clear all display-mem (DMM)
spi_send_byte(0x04, 0b01000100);
spi_send_byte(MAX7456_DMM, 0b01000100);
 
// clearing takes 12uS according to maxim so lets wait longer
_delay_us(20);
// clearing takes 20us according to maxim so lets wait longer
_delay_us(21);
}
 
 
129,19 → 129,19
* with <data>.
*/
void learn_char(uint8_t number, unsigned char* data) {
// select character to write (CMAH)
spi_send_byte(0x09, number);
// select character to write
spi_send_byte(MAX7456_CMAH, number);
 
for (uint8_t i = 0; i < 54; i++) {
// select 4pixel byte of char (CMAL)
spi_send_byte(0x0A, i);
// select 4pixel byte of char
spi_send_byte(MAX7456_CMAL, i);
 
// write 4pixel byte of char (CMDI)
spi_send_byte(0x0B, data[i]);
// write 4pixel byte of char
spi_send_byte(MAX7456_CMDI, data[i]);
}
 
// write to the NVM array from the shadow RAM (CMM)
spi_send_byte(0x08, 0b10100000);
// write to the NVM array from the shadow RAM
spi_send_byte(MAX7456_CMM, 0b10100000);
 
// according to maxim writing to nvram takes about 12ms, lets wait longer
_delay_ms(120);
156,9 → 156,9
void write_char_att(uint16_t address, char attribute) {
// the only important part is that the DMAH[1] is set
// so we add 2 which binary is the 2nd lowest byte
spi_send_byte(0x05, ((address & 0xFF00) >> 8) | 2); // DMAH
spi_send_byte(0x06, (address & 0x00FF)); // DMAL
spi_send_byte(0x07, attribute); // DMDI
spi_send_byte(MAX7456_DMAH, ((address & 0xFF00) >> 8) | 2);
spi_send_byte(MAX7456_DMAL, (address & 0x00FF));
spi_send_byte(MAX7456_DMDI, attribute);
}
 
/**
246,8 → 246,8
* <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) {
if (number >= pow(10, length)) {
number = pow(10, length) - 1;
if (number >= int_pow(10, length)) {
number = int_pow(10, length) - 1;
}
itoa(number, conv_array, 10);
for (uint8_t i = 0; i < length - strlen(conv_array); i++) {
263,10 → 263,10
* <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) {
if (number <= -pow(10, length)) {
number = -pow(10, length) + 1;
} else if (number >= pow(10, length)) {
number = pow(10, length) - 1;
if (number <= -int_pow(10, length)) {
number = -int_pow(10, length) + 1;
} else if (number >= int_pow(10, length)) {
number = int_pow(10, length) - 1;
}
 
itoa(number, conv_array, 10);
285,8 → 285,8
* <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) {
if (number >= pow(10, length)) {
number = pow(10, length) - 1;
if (number >= int_pow(10, length)) {
number = int_pow(10, length) - 1;
}
itoa(number, conv_array, 10);
uint8_t len = strlen(conv_array);
315,8 → 315,8
* <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) {
if (number >= pow(10, length)) {
number = pow(10, length) - 1;
if (number >= int_pow(10, length)) {
number = int_pow(10, length) - 1;
}
itoa(number, conv_array, 10);
uint8_t len = strlen(conv_array);