So hab ich mein Display angeschlossen:Code:// bis in the display state. see PCF8574 in schematic // 0: Power // 1: RS // 2: RW // 3: CS (enable) // 4: D4 // 5: D5 // 6: D6 // 7: D7 // function set 4 bit // this needs to be done without the add_command function g_buffer[0] = 0x21; g_buffer[1] = 0x21 | (1<<3); g_buffer[2] = 0x21; twi.write_to_slave(avr::display_address, g_buffer, 3); state++; case 7: return check_twi(state); case 8: curr_pos = 0; add_command(0,0,0x24); // function set line (enable ext. F); add_command(0,0,0x09); // set 4 line mode add_command(0,0,0x20); // disable extended function again twi.write_to_slave(avr::display_address, g_buffer, curr_pos); state++; return false; case 9: return check_twi(state); case 10: // init done curr_pos = 0; add_command(0,0,0x0F); // display on add_command(0,0,0x01); // clear display add_command(0,0,0x06); // entry mode set twi.write_to_slave(avr::display_address, g_buffer, curr_pos); state++; return false;
https://www.roboternetz.de/community...l=1#post604859
add_command macht:
Das bedeutet für dich:Code:void add_command(unsigned char rs, unsigned char rw, unsigned char value) { unsigned char out = 0x01; // always power // high nibble out |= (value & 0xF0); // rs and rw flags if (rs) out |= (1<<1); if (rw) out |= (1<<2); // toggle e out |= (1<<3); g_buffer[curr_pos++] = out; out &= ~(1<<3); g_buffer[curr_pos++] = out; // low nibble out &= 0x0F; out |= ((value & 0x0F) << 4); // toggle e out |= (1<<3); g_buffer[curr_pos++] = out; out &= ~(1<<3); g_buffer[curr_pos++] = out; }
RS = low / RW = low
// function set
- Display D5 hochnehmen
- E high
- E low
// add_command(0,0,0x24) // function set line (enable ext. F);
- out nibble=2
- E high
- E low
- out nibble=4
- E high
- E low
Du siehst also wie du das umsetzen kannst...
Das hier ist der Kern meiner Displayroutine.
Gruß
Georg







Zitieren

Lesezeichen