Doh! Found the pin problem with the previous code chunk, but still not working... ugh!
void LCD::tickleEnable() {
// send a pulse to enable PB4
PORTB |= (1 << 4);
delayMicroseconds2(1); // pause 1 ms according to datasheet
PORTB &= ~(1 << 4);
delayMicroseconds2(1); // pause 1 ms according to datasheet
}
void LCD::cmdWriteSet() { //set enable (PB4) low and DI(PB2) low
PORTB &= ~(1 << 4);
delayMicroseconds2(1); // pause 1 ms according to datasheet
PORTB &= ~(1 << 2);
}
byte LCD:
ushNibble(byte value) { //db7=PC2, db6=PC1, db5 = PC0, db4 = PB5
value & 128 ? PORTB |= (1 << 5) : PORTB &= ~(1 << 5);
value <<= 1;
value & 128 ? PORTC |= (1 << 0) : PORTC &= ~(1 << 0);
value <<= 1;
value & 128 ? PORTC |= (1 << 1) : PORTC &= ~(1 << 1);
value <<= 1;
value & 128 ? PORTC |= (1 << 2) : PORTC &= ~(1 << 2);
value <<= 1;
return value;
}
void LCD::LcdCommandWrite(byte value) {
value = pushNibble(value);
cmdWriteSet();
tickleEnable();
value = pushNibble(value);
cmdWriteSet();
tickleEnable();
delay2(5);
}
void LCD::LcdDataWrite(byte value) {
PORTB |= (1 << 4); //di on pb4
value = pushNibble(value);
tickleEnable();
value = pushNibble(value);
tickleEnable();
delay2(5);
}