#define clcd_bus PORTC
#define enable (clcd_bus |= 0x04)
#define disable (clcd_bus &= 0xFB)
void clcd_inst(unsigned char Data) {
clcd_bus = Data & 0xF0;
enable;
disable;
clcd_bus = (Data << 4) & 0xF0;
enable;
disable;
_delay_ms(1);
}
void clcd_byte(unsigned char Data) {
clcd_bus = (Data & 0xF0) | 0x01;
enable;
disable;
clcd_bus = ((Data << 4) & 0xF0) | 0x01;
enable;
disable;
_delay_ms(1);
}
void clcd_bytes(char X, char Y, unsigned char *Str) {
unsigned char Position = 0;
if(Y == 0)
Position = 0x80 + X;
else if(Y == 1)
Position = 0xC0 + X;
else if(Y == 2)
Position = 0x94 + X;
else
Position = 0xD4 + X;
clcd_inst(Position);
do {
clcd_byte(*Str);
Str++;
} while(*Str);
}
void clcd_init(void) {
clcd_inst(0x28);
_delay_ms(10);
clcd_inst(0x28);
_delay_ms(10);
clcd_inst(0x0C);
clcd_inst(0x06);
clcd_inst(0x02);
clcd_inst(0x01);
_delay_ms(10);
}