: Class LCDPort

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.dalsemi.comm
Class LCDPort

    java.lang.Object
      |
      +--com.dalsemi.comm.LCDPort

public class LCDPort
extends Object

## LCDPort

### Description

LCDPort is used to write to the LCD display. This class was written and tested using the KS0066U and KS0070B segment drivers/controller. The class can be used as part of a streams based protocol. There are also methods for communicating directly to the LCD display. Using the sendControl and sendData commands you can control the LCD directly without the need for streams.

### DataSheets

Samsung
KS0070B Datasheet
KS0066U Datasheet

### Example Usuage

     LCDPort.sendControl(0x38);  // Set up the display mode
     LCDPort.sendControl(0x0C);  // Turn on display with no cursor
     LCDPort.setAddress(0x20);
     LCDPort.sendControl(1);     // Clear the screen
     LCDPort.setAddress(8);
     LCDPort.sendData((int)85);  // Write a U

Constructor Summary
`LCDPort(int portNum, int stream)` Constructs a new LCDPort.

Method Summary
`void` | `close()` Closes the port and frees up system resources.
`int` | `getOutputBufferSize()` Gets the size of the output buffer.
`OutputStream` | `getOutputStream()` Gets a LCD port Output stream
`void` | `open()` Opens the LCD port for communication.
`static void` | `sendControl(int value)` Sends a control byte to the LCD display.
`static void` | `sendData(int value)` Sends a data byte to the display.
`static void` | `setAddress(int address)` Sets the address for the next write.
`static void` | `setLCDParams(int paramNum, byte[] params, int length)` Sends a parameter to the LCD display.
`static void` | `setNumberOfLines(int num)` Sets the number of lines for the LCD driver.
`static void` | `setShiftDirection(boolean dir)` Sets the direction of shifts.
`static void` | `setShiftInterval(int num_ms)` Sets the interval of the automatic shift in milliseconds.
`static void` | `setShiftMode(boolean on)` Turns automatic shifting on and off.
`void` | `write(byte[] arr)` Writes the array to the LCD port.
`void` | `write(byte[] arr, int offset, int len)` Writes the array to the LCD port.
`void` | `write(int ch)` Writes a byte to the LCD port.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### LCDPort

    public LCDPort(int portNum,
                   int stream)
            throws IOException

  Constructs a new LCDPort.

       LCDPort port = new LCDPort(NativeComm.PORT_LCD, NativeComm.STREAM_STDOUT);

  Parameters:
    `portNum` - the port number of the driver, should be NativeComm.PORT_LCD
    `stream` - the stream to open, only stdout is supported
  Throws:
    IOException - if portNum is not a valid port type or stream type is not valid

Method Detail

### setLCDParams

    public static void setLCDParams(int paramNum,
                                    byte[] params,
                                    int length)

  Sends a parameter to the LCD display. The only parameter currently supported is number of lines. Valid line numbers supported are 1, 2, and 4.
  Example: Set the number of lines to 1

       byte[] b1 = {0x01};
       LCDPort.setLCDParams(1, b1, b1.length);

  Parameters:
    `paramNum` - parameter number (only 1 is supported)
    `params` - the parameter values, currently only number of lines is supported, allowable values include 1, 2 or 4
    `length` - the length of the parameter array

### open

    public void open()

  Opens the LCD port for communication. This method is called from getInputStream and getOutputStream.

### close

    public void close()
               throws IOException

  Closes the port and frees up system resources.
  Throws:
    IOException - if port is not already open.

### write

    public void write(byte[] arr)
               throws IOException

  Writes the array to the LCD port. Bytes are written sequentially. This method blocks until all bytes have been sent.
  Parameters:
    `arr` - the array to be written to the LCD port
  Throws:
    IOException - if port is not open

### write

    public void write(byte[] arr,
                      int offset,
                      int len)
               throws IOException

  Writes the array to the LCD port. Bytes are written sequentially. This method blocks until all bytes have been sent.
  Parameters:
    `arr` - the array to be written
    `offset` - the offset in the array to begin sending
    `len` - the number of bytes to send
  Throws:
    IOException - if port is not open

### write

    public void write(int ch)
               throws IOException

  Writes a byte to the LCD port. This method blocks until the byte has actually been sent.
  Parameters:
    `ch` - the data to be written
  Throws:
    IOException - if port is not open

### getOutputStream

    public OutputStream getOutputStream()
                                 throws IOException

  Gets a LCD port Output stream
  Returns:
    OutputStream
  Throws:
    throws - IOException if unable to open the port

### getOutputBufferSize

    public int getOutputBufferSize()

  Gets the size of the output buffer.
  Returns:
    the size of the output buffer

### setNumberOfLines

    public static void setNumberOfLines(int num)

  Sets the number of lines for the LCD driver.
  Parameters:
    `num` - number of lines

### sendControl

    public static void sendControl(int value)

  Sends a control byte to the LCD display. Refer to the data sheets of the KS0066U and KS0070B for information on control characters. This can be used to set the address, shift, clear, etc.
  Parameters:
    `value` - the control value to be sent

### sendData

    public static void sendData(int value)

  Sends a data byte to the display. This can be used to directly write data to the LCD display.
  Parameters:
    `value` - the byte to be displayed

### setShiftMode

    public static void setShiftMode(boolean on)

  Turns automatic shifting on and off.
  Parameters:
    `on` - set to true to turn shifting on

### setShiftDirection

    public static void setShiftDirection(boolean dir)

  Sets the direction of shifts.
  Parameters:
    `dir` - set to true to shift characters to the left

### setShiftInterval

    public static void setShiftInterval(int num_ms)

  Sets the interval of the automatic shift in milliseconds.
  Parameters:
    `num_ms` - number of milliseconds between shifts

### setAddress

    public static void setAddress(int address)

  Sets the address for the next write. Refer to the data sheets for the KS0066U and KS0070B for information on control characters.
  Parameters:
    `address` - the address for the next write

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD