21,6 → 21,7 |
#include <avr/io.h> |
#include <util/delay.h> |
#include <avr/pgmspace.h> |
#include "main.h" |
#include "max7456_software_spi.h" |
|
/* ########################################################################## |
56,6 → 57,7 |
MAX_CS_HIGH |
} |
|
|
/** |
* write a <character> to <address> of MAX7456 display memory |
*/ |
65,7 → 67,41 |
spi_send_byte(0x07, character); // DMDI |
} |
|
|
/** |
* clear display memory |
* (also sets 8bit mode) |
*/ |
void clear(void) { |
/*uint16_t memory_address = 0; |
for (unsigned int a = 0; a < 480; a++) { |
write_char(memory_address++, 0); |
}*/ |
// clear all display-mem (DMM) |
spi_send_byte(0x04, 0b01000100); |
|
// clearing takes 12uS according to maxim so lets wait longer |
_delay_us(20); |
} |
|
|
/** |
* for testing write all chars to screen |
*/ |
void write_all_chars() { |
uint16_t x = 3, y = 2, t = 0; |
while (t < 256) { |
write_char(x++ + y*30, t++); |
if (x > 25) { |
y++; |
x = 3; |
} |
} |
} |
|
#if !(ALLCHARSDEBUG|(WRITECHARS != -1)) |
|
/** |
* write a character <attribute> to <address> of MAX7456 display memory |
*/ |
void write_char_att(uint16_t address, char attribute) { |
93,19 → 129,26 |
} |
|
/** |
* clear display memory |
* (also sets 8bit mode) |
* let the MAX7456 learn a new character at <number> |
* with <data>. |
*/ |
void clear(void) { |
/*uint16_t memory_address = 0; |
for (unsigned int a = 0; a < 480; a++) { |
write_char(memory_address++, 0); |
}*/ |
// clear all display-mem (DMM) |
spi_send_byte(0x04, 0b01000100); |
void learn_char(uint8_t number, unsigned char* data) { |
// select character to write (CMAH) |
spi_send_byte(0x09, number); |
|
// clearing takes 12uS according to maxim so lets wait longer |
_delay_us(20); |
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); |
} |
|
/** |
320,43 → 363,6 |
} |
|
/** |
* for testing write all chars to screen |
*/ |
void write_all_chars() { |
uint16_t x = 3, y = 2, t = 0; |
while (t < 256) { |
write_char_xy(x++, y, t++); |
if (x > 25) { |
y++; |
x = 3; |
} |
} |
} |
|
/** |
* 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); |
} |
|
/** |
* 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) { |
375,3 → 381,5 |
write_ndigit_number_u(x + 8, y, (uint16_t) position, 100, 1); |
write_char_xy(x + 11, y, 0xD0); // degree symbol |
} |
|
#endif |