public void setCursor(int col, int row) throws IOException { int[] rowOffsets = {0x00, 0x40, 0x14, 0x54}; if (row >= numlines) { row = numlines - 1; // we count rows starting w/0 } command(LCD_SETDDRAMADDR | (col + rowOffsets[row])); }
/********** * high level commands, for the user! */ public void clear() throws IOException { command(LCD_CLEARDISPLAY); // clear display, set cursor position to zero delayMicroseconds(2000); // this command takes a long time! }
/*********** * mid level commands, for sending data/cmds */ public void command(int value) throws IOException { send(value, false); }
public void begin(int cols, int lines) throws IOException { begin(cols, lines, LCD_5x8DOTS); }
private void write8bits(int value) throws IOException { for (int i = 0; i < 8; i++) { dataGpios[i].setValue(((value >> i) & 0x01) != 0); } pulseEnable(); }
public void leftToRight() throws IOException { displaymode |= LCD_ENTRYLEFT; command(LCD_ENTRYMODESET | displaymode); }
public void home() throws IOException { command(LCD_RETURNHOME); // set cursor position to zero delayMicroseconds(2000); // this command takes a long time! }
public void write(int value) throws IOException { send(value, true); }
public void blink() throws IOException { displaycontrol |= LCD_BLINKON; command(LCD_DISPLAYCONTROL | displaycontrol); }
public void cursor() throws IOException { displaycontrol |= LCD_CURSORON; command(LCD_DISPLAYCONTROL | displaycontrol); }
public void autoscroll() throws IOException { displaymode |= LCD_ENTRYSHIFTINCREMENT; command(LCD_ENTRYMODESET | displaymode); }
public void noDisplay() throws IOException { displaycontrol &= ~LCD_DISPLAYON; command(LCD_DISPLAYCONTROL | displaycontrol); }
public void noBlink() throws IOException { displaycontrol &= ~LCD_BLINKON; command(LCD_DISPLAYCONTROL | displaycontrol); }
public void rightToLeft() throws IOException { displaymode &= ~LCD_ENTRYLEFT; command(LCD_ENTRYMODESET | displaymode); }
public void noAutoscroll() throws IOException { displaymode &= ~LCD_ENTRYSHIFTINCREMENT; command(LCD_ENTRYMODESET | displaymode); }
public void display() throws IOException { displaycontrol |= LCD_DISPLAYON; command(LCD_DISPLAYCONTROL | displaycontrol); }
public void noCursor() throws IOException { displaycontrol &= ~LCD_CURSORON; command(LCD_DISPLAYCONTROL | displaycontrol); }
public void scrollDisplayLeft() throws IOException { command(LCD_CURSORSHIFT | LCD_DISPLAYMOVE | LCD_MOVELEFT); }
public void scrollDisplayRight() throws IOException { command(LCD_CURSORSHIFT | LCD_DISPLAYMOVE | LCD_MOVERIGHT); }