//MCU to 2x16LCD pinout connection
// MCU A5, A4, A3, A2, A1, A0
// LCD E R/S D7 D6 D5 D4
uint16_t lcd_init_buf[]={
0x03,0x23,0x03, // init 0x03
0x03,0x23,0x03,
0x03,0x23,0x03,
0x02,0x22,0x02, // init 0x02
0x02,0x22,0x02, // init 0x28 -2
0x08,0x28,0x08, // init 0x28 -8
0x00,0x20,0x00, // init 0x0C -0
0x0C,0x2C,0x0C, // init 0x0C -C
0x00,0x20,0x00, // init 0x01 -0
0x01,0x21,0x01, // init 0x01 -1
0x00,0x20,0x00, // init 0x06 -0
0x06,0x26,0x06, // init 0x06 -6
//FORMAT for sending command to the LCD
//for example to send a 0xYZ as a command
//we need to translate it to the 6 bytes as follows
//0x0Y,0x2Y,0x0Y, // init 0xYZ -Y
//0x0Z,0x2Z,0x0Z, // init 0xYZ -Z
};
#define LCD_INIT_BUFLEN (((sizeof(lcd_init_buf)) / 2) -1)
uint16_t dma_lcd_buf[]={
0x28,0x08, // CMD 0x80 -8 ilk satirbasi
0x20,0x00, // CMD 0x80 -0
0x34,0x14, // DATA 1M
0x31,0x11, // DATA 1L
0x34,0x14, // DATA 2M
0x31,0x11, // DATA 2L
0x34,0x14, // DATA 3M
0x31,0x11, // DATA 3L
0x34,0x14, // DATA 4M
0x31,0x11, // DATA 4L
0x34,0x14, // DATA 5M
0x31,0x11, // DATA 5L
0x34,0x14, // DATA 6M
0x31,0x11, // DATA 6L
0x34,0x14, // DATA 7M
0x31,0x11, // DATA 7L
0x34,0x14, // DATA 8M
0x31,0x11, // DATA 8L
0x34,0x14, // DATA 9M
0x31,0x11, // DATA 9L
0x34,0x14, // DATA 10M
0x31,0x11, // DATA 10L
0x34,0x14, // DATA 11M
0x31,0x11, // DATA 11L
0x34,0x14, // DATA 12M
0x31,0x11, // DATA 12L
0x34,0x14, // DATA 13M
0x31,0x11, // DATA 13L
0x34,0x14, // DATA 14M
0x31,0x11, // DATA 14L
0x34,0x14, // DATA 15M
0x31,0x11, // DATA 15L
0x34,0x14, // DATA 16M
0x31,0x11, // DATA 16L
0x2C,0xC0, // CMD C0-C ikinci satirbasi
0x20,0x00, // CMD C0-0
0x34,0x14, // DATA 1M
0x32,0x12, // DATA 1L
0x34,0x14, // DATA 2M
0x32,0x12, // DATA 2L
0x34,0x14, // DATA 3M
0x32,0x12, // DATA 3L
0x34,0x14, // DATA 4M
0x32,0x12, // DATA 4L
0x34,0x14, // DATA 5M
0x32,0x12, // DATA 5L
0x34,0x14, // DATA 6M
0x32,0x12, // DATA 6L
0x34,0x14, // DATA 7M
0x32,0x12, // DATA 7L
0x34,0x14, // DATA 8M
0x32,0x12, // DATA 8L
0x34,0x14, // DATA 9M
0x32,0x12, // DATA 9L
0x34,0x14, // DATA 10M
0x32,0x12, // DATA 10L
0x34,0x14, // DATA 11M
0x32,0x12, // DATA 11L
0x34,0x14, // DATA 12M
0x32,0x12, // DATA 12L
0x34,0x14, // DATA 13M
0x32,0x12, // DATA 13L
0x34,0x14, // DATA 14M
0x32,0x12, // DATA 14L
0x34,0x14, // DATA 15M
0x32,0x12, // DATA 15L
0x34,0x14, // DATA 16M
0x32,0x12, // DATA 16L
};
#define LCD_BUFLEN ( (sizeof(dma_lcd_buf) / 2) )//- 1)
char user_lcd_buf[32];
void lcd_bufbuf()
{
//FORMAT for sending DATA to the LCD
//for example to send a 0xYZ as a DATA
//we need to translate it to the 4 bytes as follows
//0x3Y,0x1Y, // 0xYZ -Y
//0x3Z,0x1Z, // 0xYZ -Z
uint16_t h_nibble,l_nibble,i=0,j;
for(j=4;j<((4*16)+4);)
{
h_nibble = ( (user_lcd_buf[i] & 0xF0) >> 4);
dma_lcd_buf[j++] = (h_nibble | 0x30);
dma_lcd_buf[j++] = (h_nibble | 0x10);
l_nibble = ( (user_lcd_buf[i++] & 0x0F) );
dma_lcd_buf[j++] = (l_nibble | 0x30);
dma_lcd_buf[j++] = (l_nibble | 0x10);
}
for(j=4*16+4+4;j<4*16+4+4+4*16;)
{
h_nibble = ( (user_lcd_buf[i] & 0xF0) >> 4);
dma_lcd_buf[j++] = (h_nibble | 0x30);
dma_lcd_buf[j++] = (h_nibble | 0x10);
l_nibble = ( (user_lcd_buf[i++] & 0x0F) );
dma_lcd_buf[j++] = (l_nibble | 0x30);
dma_lcd_buf[j++] = (l_nibble | 0x10);
}
}