#include <stdlib.h>
#include <avr/io.h>
#include <avr/pgmspace.h>
#include <util/delay.h>
#include "lcd.h"
void writeCustomChars(const PROGMEM unsigned char customChars[][8], uint8_t customCharOffset){
lcd_command(_BV(LCD_CGRAM)); /* set CG RAM start address 0*/
for (uint8_t i = customCharOffset; i < customCharOffset + 5; i++){
for(uint8_t j = 0; j < 8; j++)
lcd_data(pgm_read_byte_near(&customChars[i][j]));
}
}
void printDDRAMcustomChars(void){
for(uint8_t i = 0; i < 4; i++){
lcd_gotoxy(2, i);
for(uint8_t j = 0; j < 5; j++){
lcd_putc(j);
}
}
}
int main(void){
static const PROGMEM unsigned char customChars[20][8] = {
{
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01 //begin of row 1
},
{
0x00, 0x03, 0x07, 0x0e, 0x0e, 0x1c, 0x18, 0x18
},
{
0x0e, 0x1f, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00
},
{
0x00, 0x18, 0x1c, 0x1e, 0x1e, 0x07, 0x03, 0x03
},
{
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x18 //end of row 1
},
{
0x03, 0x03, 0x07, 0x07, 0x07, 0x0f, 0x0f, 0x0f //begin of row 2
},
{
0x10, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00
},
{
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
},
{
0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00
},
{
0x18, 0x18, 0x1c, 0x1c, 0x1c, 0x1e, 0x1e, 0x1e //end of row 2
},
{
0x0f, 0x0f, 0x0f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f //begin of row 3
},
{
0x00, 0x1f, 0x1f, 0x1f, 0x00, 0x00, 0x00, 0x00
},
{
0x00, 0x00, 0x1b, 0x1f, 0x1f, 0x04, 0x00, 0x00
},
{
0x00, 0x1f, 0x1f, 0x1f, 0x00, 0x00, 0x00, 0x00
},
{
0x1e, 0x1e, 0x1e, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f //end of row 3
},
{
0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f //begin of row 4
},
{
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
},
{
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
},
{
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
},
{
0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f //end of row 4
}
};
lcd_init(LCD_DISP_ON);
lcd_clrscr();
for(uint8_t i = 1; i <= 20; i++){
writeCustomChars(customChars, i);
if( !(i % 5) )
printDDRAMcustomChars();
}
for(;;){
}
}
I2luY2x1ZGUgPHN0ZGxpYi5oPgojaW5jbHVkZSA8YXZyL2lvLmg+CiNpbmNsdWRlIDxhdnIvcGdtc3BhY2UuaD4KI2luY2x1ZGUgPHV0aWwvZGVsYXkuaD4KI2luY2x1ZGUgImxjZC5oIgoKdm9pZCB3cml0ZUN1c3RvbUNoYXJzKGNvbnN0IFBST0dNRU0gdW5zaWduZWQgY2hhciBjdXN0b21DaGFyc1tdWzhdLCB1aW50OF90IGN1c3RvbUNoYXJPZmZzZXQpewoKICAgbGNkX2NvbW1hbmQoX0JWKExDRF9DR1JBTSkpOyAgLyogc2V0IENHIFJBTSBzdGFydCBhZGRyZXNzIDAqLwoKICAgZm9yICh1aW50OF90IGkgPSBjdXN0b21DaGFyT2Zmc2V0OyBpIDwgY3VzdG9tQ2hhck9mZnNldCArIDU7IGkrKyl7CiAgICAgIGZvcih1aW50OF90IGogPSAwOyBqIDwgODsgaisrKQogICAgICAgICBsY2RfZGF0YShwZ21fcmVhZF9ieXRlX25lYXIoJmN1c3RvbUNoYXJzW2ldW2pdKSk7CiAgIH0KfQoKdm9pZCBwcmludEREUkFNY3VzdG9tQ2hhcnModm9pZCl7CiAgIGZvcih1aW50OF90IGkgPSAwOyBpIDwgNDsgaSsrKXsKICAgICAgbGNkX2dvdG94eSgyLCBpKTsKICAgICAgZm9yKHVpbnQ4X3QgaiA9IDA7IGogPCA1OyBqKyspewogICAgICAgICBsY2RfcHV0YyhqKTsKICAgICAgfQogICB9Cn0KCmludCBtYWluKHZvaWQpewogICBzdGF0aWMgY29uc3QgUFJPR01FTSB1bnNpZ25lZCBjaGFyIGN1c3RvbUNoYXJzWzIwXVs4XSA9IHsKICAgICAgewogICAgICAgICAweDAwLCAweDAwLCAweDAwLCAweDAwLCAweDAwLCAweDAwLCAweDAxLCAweDAxIC8vYmVnaW4gb2Ygcm93IDEKICAgICAgfSwKICAgICAgewogICAgICAgICAweDAwLCAweDAzLCAweDA3LCAweDBlLCAweDBlLCAweDFjLCAweDE4LCAweDE4CiAgICAgIH0sCiAgICAgIHsKICAgICAgICAgMHgwZSwgMHgxZiwgMHgxZiwgMHgwMCwgMHgwMCwgMHgwMCwgMHgwMCwgMHgwMAogICAgICB9LAogICAgICB7CiAgICAgICAgIDB4MDAsIDB4MTgsIDB4MWMsIDB4MWUsIDB4MWUsIDB4MDcsIDB4MDMsIDB4MDMKICAgICAgfSwKICAgICAgewogICAgICAgICAweDAwLCAweDAwLCAweDAwLCAweDAwLCAweDAwLCAweDAwLCAweDEwLCAweDE4IC8vZW5kIG9mIHJvdyAxCiAgICAgIH0sCiAgICAgIHsKICAgICAgICAgMHgwMywgMHgwMywgMHgwNywgMHgwNywgMHgwNywgMHgwZiwgMHgwZiwgMHgwZiAvL2JlZ2luIG9mIHJvdyAyCiAgICAgIH0sCiAgICAgIHsKICAgICAgICAgMHgxMCwgMHgxMCwgMHgxMCwgMHgwMCwgMHgwMCwgMHgwMCwgMHgwMCwgMHgwMAogICAgICB9LAogICAgICB7CiAgICAgICAgIDB4MDAsIDB4MDAsIDB4MDAsIDB4MDAsIDB4MDAsIDB4MDAsIDB4MDAsIDB4MDAKICAgICAgfSwKICAgICAgewogICAgICAgICAweDAxLCAweDAxLCAweDAxLCAweDAwLCAweDAwLCAweDAwLCAweDAwLCAweDAwCiAgICAgIH0sCiAgICAgIHsKICAgICAgICAgMHgxOCwgMHgxOCwgMHgxYywgMHgxYywgMHgxYywgMHgxZSwgMHgxZSwgMHgxZSAvL2VuZCBvZiByb3cgMgogICAgICB9LAogICAgICB7CiAgICAgICAgIDB4MGYsIDB4MGYsIDB4MGYsIDB4MWYsIDB4MWYsIDB4MWYsIDB4MWYsIDB4MWYgLy9iZWdpbiBvZiByb3cgMwogICAgICB9LAogICAgICB7CiAgICAgICAgIDB4MDAsIDB4MWYsIDB4MWYsIDB4MWYsIDB4MDAsIDB4MDAsIDB4MDAsIDB4MDAKICAgICAgfSwKICAgICAgewogICAgICAgICAweDAwLCAweDAwLCAweDFiLCAweDFmLCAweDFmLCAweDA0LCAweDAwLCAweDAwCiAgICAgIH0sCiAgICAgIHsKICAgICAgICAgMHgwMCwgMHgxZiwgMHgxZiwgMHgxZiwgMHgwMCwgMHgwMCwgMHgwMCwgMHgwMAogICAgICB9LAogICAgICB7CiAgICAgICAgIDB4MWUsIDB4MWUsIDB4MWUsIDB4MWYsIDB4MWYsIDB4MWYsIDB4MWYsIDB4MWYgLy9lbmQgb2Ygcm93IDMKICAgICAgfSwKICAgICAgewogICAgICAgICAweDFmLCAweDFmLCAweDFmLCAweDFmLCAweDFmLCAweDFmLCAweDFmLCAweDFmIC8vYmVnaW4gb2Ygcm93IDQKICAgICAgfSwKICAgICAgewogICAgICAgICAweDAwLCAweDAwLCAweDAwLCAweDAwLCAweDAwLCAweDAwLCAweDAwLCAweDAwCiAgICAgIH0sCiAgICAgIHsKICAgICAgICAgMHgwMCwgMHgwMCwgMHgwMCwgMHgwMCwgMHgwMCwgMHgwMCwgMHgwMCwgMHgwMAogICAgICB9LAogICAgICB7CiAgICAgICAgIDB4MDAsIDB4MDAsIDB4MDAsIDB4MDAsIDB4MDAsIDB4MDAsIDB4MDAsIDB4MDAKICAgICAgfSwKICAgICAgewogICAgICAgICAweDFmLCAweDFmLCAweDFmLCAweDFmLCAweDFmLCAweDFmLCAweDFmLCAweDFmIC8vZW5kIG9mIHJvdyA0CiAgICAgIH0KICAgfTsKCiAgIGxjZF9pbml0KExDRF9ESVNQX09OKTsKICAgbGNkX2NscnNjcigpOwoKICAgZm9yKHVpbnQ4X3QgaSA9IDE7IGkgPD0gMjA7IGkrKyl7CiAgICAgIHdyaXRlQ3VzdG9tQ2hhcnMoY3VzdG9tQ2hhcnMsIGkpOwogICAgICBpZiggIShpICUgNSkgKQogICAgICAgICBwcmludEREUkFNY3VzdG9tQ2hhcnMoKTsKICAgfQoKICAgZm9yKDs7KXsKCiAgIH0KfQo=