hades.models.special
Class TextLCD

java.lang.Object
  extended byhades.simulator.SimObject
      extended byhades.models.special.TextLCD
All Implemented Interfaces:
java.lang.Cloneable, ContextToolTip, java.io.Serializable, Simulatable, Wakeable

public class TextLCD
extends SimObject
implements Simulatable, Wakeable

TextLCD is the model of a generic character-based liquid-crystal dot-matrix display with 2x40 characters. The specification was taken from the RS data library, "alphanumeric dot matrix liquid crystal displays", F19357, 1995, but should be valid for most off-the-shelf LCD controllers.

The model implements all commands from display initialization to scrolling, four-bit data interface, to character-generator writes and reads.

Note that the read-command timing is implemented exactly as specified, that is, the data hold time after enable goes high is about 30 nsec. This may lead to problems with 'sloppy' controllers which sample the data outputs after enable went high (e.g. Arizona Microchip AN587).

See Also:
Serialized Form

Field Summary
protected  int active_memory
           
protected  int BIT_D0
           
protected  int BIT_D1
           
protected  int BIT_D2
           
protected  int BIT_D3
           
protected  int BIT_D4
           
protected  int BIT_D5
           
protected  int BIT_D6
           
protected  int BIT_D7
           
protected  int BIT_RS
           
protected  int BIT_RW
           
protected  boolean busy
           
protected  int cg_address
           
protected  int CG_MEMORY
           
protected  int CMD_CG_ADDR
           
protected  int CMD_CLEAR
           
protected  int CMD_CURSOR_HOME
           
protected  int CMD_DATA_ADDR
           
protected  int CMD_DISPLAY_ON
           
protected  int CMD_ENTRY_MODE
           
protected  int CMD_FUNCTION
           
protected  int CMD_IDLE
           
protected  int CMD_READ_BUSY
           
protected  int CMD_READ_RAM
           
protected  int CMD_SHIFT_MOVE
           
protected  int CMD_WRITE_RAM
           
protected  int command_old
           
protected  int command_word
           
(package private)  javax.swing.JPanel controlPanel
           
protected  int data_address
           
protected  int DATA_MEMORY
           
(package private)  boolean debug
           
(package private)  javax.swing.JCheckBox debugCheckbox
           
protected  boolean decrement_mode
           
protected  boolean four_bit_first
           
protected  boolean four_bit_mode
           
protected  boolean incr_not_decr
           
(package private)  TextLCDCanvas lcdCanvas
           
protected  int n_cols
           
protected  int n_rows
           
protected  PortStdLogic1164 port_D0
           
protected  PortStdLogic1164 port_D1
           
protected  PortStdLogic1164 port_D2
           
protected  PortStdLogic1164 port_D3
           
protected  PortStdLogic1164 port_D4
           
protected  PortStdLogic1164 port_D5
           
protected  PortStdLogic1164 port_D6
           
protected  PortStdLogic1164 port_D7
           
protected  PortStdLogic1164 port_E
           
protected  PortStdLogic1164 port_RS
           
protected  PortStdLogic1164 port_RW
           
protected  PortStdLogic1164 port_VO
           
protected  boolean shift_not_move
           
protected  Label symbolTypeLabel
           
protected  double T_CG_ADDR
           
protected  double T_CLEAR
           
protected  double T_CURSOR_HOME
           
protected  double T_DATA_ADDR
           
protected  double T_DISPLAY_ON
           
protected  double T_ENTRY_MODE
           
protected  double T_FUNCTION
           
protected  double T_INITIALIZE
           
protected  double T_READ_RAM
           
protected  double T_SHIFT_MOVE
           
protected  double T_WRITE_RAM
           
(package private)  java.awt.Image theIcon
           
(package private)  javax.swing.JFrame topFrame
           
protected  StdLogic1164 value_0
           
protected  StdLogic1164 value_1
           
protected  StdLogic1164 value_H
           
protected  StdLogic1164 value_X
           
 
Fields inherited from class hades.simulator.SimObject
classloader, console, editor, name, parent, ports, propertySheet, simulator, symbol, versionId, visible
 
Constructor Summary
TextLCD()
          the TextLCD default constructor.
 
Method Summary
(package private)  void buildControlPanel()
           
(package private)  void buildGUI()
           
(package private)  void buildGUICallbacks()
           
 void changeName()
           
 void configure()
          create and display a 'ConfigDialog' to set the parameters for a SimObject.
 SimObject copy()
          copy(): create an (empty) clone of the current TextLCD
 void decode(int command)
           
 void decrementDataAddress()
           
 void doClearDisplay()
          00 0000 0001
 void doCursorHome()
          00 0000 001X
 void doInitialize()
           
 void doReadBusy()
          01 BF AAA AAAA
 void doReadData()
          11 DDDD DDDD
 void doSetCGAddress()
          00 01AA AAAA
 void doSetDataAddress()
          00 1AAA AAAA
 void doSetDisplayOn()
          00 0000 1DCB
 void doSetEntryMode()
          00 0000 01IS
 void doSetFunction()
          00 001D NFXX
 void doShiftMove()
          00 0001 SRXX
 void doWriteData()
          10 DDDD DDDD
 void elaborate(java.lang.Object arg)
          elaborate(): We assign a '0' to all our outputs.
 void evaluate(java.lang.Object arg)
          evaluate(): This LCD controller is sensitive to the falling edge on the enable signal (port_E) only, when the R/S, R/W, and data signals are sampled.
 boolean getLocalDebug()
           
 java.awt.Component getPropertySheet()
          return a reference to the 'property sheet' or configuration window for this SimObject.
 java.lang.String getToolTip(java.awt.Point position, long millis)
          construct a (short) tool tip message for a SimObject.
 java.lang.String hex(int i)
           
 void incrementDataAddress()
           
 boolean initialize(java.lang.String s)
          initialize a SimObject from a String.
static void main(java.lang.String[] argv)
          main(): simple selftest of the TextLCD's GUI
 void mousePressed(java.awt.event.MouseEvent me)
          react to a MouseEvent.
 void msg(java.lang.String s)
          msg()
 int readAddress()
           
 int readData()
          retrieve the data at the current address from the data RAM of CG RAM, whichever is selected.
 void setBusyFor(double delta_t)
           
 void setCGAddress(int address)
           
 void setDataAddress(int address)
           
 void setLocalDebug(boolean b)
           
 void setName(java.lang.String name)
          set the name of this SimObject.
 void setSymbol(Symbol s)
           
static void sleep(int millis)
           
 java.lang.String toString()
          toString() - the usual info method
 void updateCGAddress()
           
 void updateDataAddress()
           
 void wakeup(java.lang.Object arg)
          called in reaction to our setBusyFor() calls.
 void write(java.io.PrintWriter ps)
           
 void writeData(int value)
          write 'value' into the current address of the data RAM or CG RAM, whichever is selected.
 
Methods inherited from class hades.simulator.SimObject
constructDynamicSymbol, getBindkey, getClassLoader, getDebug, getEditor, getExternalResources, getFullName, getName, getParent, getPort, getPorts, getResourceAsStream, getSimulator, getSymbol, getSymbolResourceName, getVersionId, isVisible, keyPressed, message, needsDynamicSymbol, needsExternalResources, setClassLoader, setConsole, setDebug, setEditor, setParent, setPorts, setSimulator, setVersionId, setVisible, tearDown
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface hades.simulator.Simulatable
message
 

Field Detail

debug

boolean debug

port_RS

protected PortStdLogic1164 port_RS

port_RW

protected PortStdLogic1164 port_RW

port_E

protected PortStdLogic1164 port_E

port_D7

protected PortStdLogic1164 port_D7

port_D6

protected PortStdLogic1164 port_D6

port_D5

protected PortStdLogic1164 port_D5

port_D4

protected PortStdLogic1164 port_D4

port_D3

protected PortStdLogic1164 port_D3

port_D2

protected PortStdLogic1164 port_D2

port_D1

protected PortStdLogic1164 port_D1

port_D0

protected PortStdLogic1164 port_D0

port_VO

protected PortStdLogic1164 port_VO

value_0

protected StdLogic1164 value_0

value_1

protected StdLogic1164 value_1

value_X

protected StdLogic1164 value_X

value_H

protected StdLogic1164 value_H

symbolTypeLabel

protected Label symbolTypeLabel

n_rows

protected int n_rows

n_cols

protected int n_cols

DATA_MEMORY

protected final int DATA_MEMORY
See Also:
Constant Field Values

CG_MEMORY

protected final int CG_MEMORY
See Also:
Constant Field Values

BIT_RS

protected final int BIT_RS
See Also:
Constant Field Values

BIT_RW

protected final int BIT_RW
See Also:
Constant Field Values

BIT_D7

protected final int BIT_D7
See Also:
Constant Field Values

BIT_D6

protected final int BIT_D6
See Also:
Constant Field Values

BIT_D5

protected final int BIT_D5
See Also:
Constant Field Values

BIT_D4

protected final int BIT_D4
See Also:
Constant Field Values

BIT_D3

protected final int BIT_D3
See Also:
Constant Field Values

BIT_D2

protected final int BIT_D2
See Also:
Constant Field Values

BIT_D1

protected final int BIT_D1
See Also:
Constant Field Values

BIT_D0

protected final int BIT_D0
See Also:
Constant Field Values

CMD_IDLE

protected final int CMD_IDLE
See Also:
Constant Field Values

CMD_CLEAR

protected final int CMD_CLEAR
See Also:
Constant Field Values

CMD_CURSOR_HOME

protected final int CMD_CURSOR_HOME
See Also:
Constant Field Values

CMD_ENTRY_MODE

protected final int CMD_ENTRY_MODE
See Also:
Constant Field Values

CMD_DISPLAY_ON

protected final int CMD_DISPLAY_ON
See Also:
Constant Field Values

CMD_SHIFT_MOVE

protected final int CMD_SHIFT_MOVE
See Also:
Constant Field Values

CMD_FUNCTION

protected final int CMD_FUNCTION
See Also:
Constant Field Values

CMD_CG_ADDR

protected final int CMD_CG_ADDR
See Also:
Constant Field Values

CMD_DATA_ADDR

protected final int CMD_DATA_ADDR
See Also:
Constant Field Values

CMD_READ_BUSY

protected final int CMD_READ_BUSY
See Also:
Constant Field Values

CMD_WRITE_RAM

protected final int CMD_WRITE_RAM
See Also:
Constant Field Values

CMD_READ_RAM

protected final int CMD_READ_RAM
See Also:
Constant Field Values

T_INITIALIZE

protected final double T_INITIALIZE
See Also:
Constant Field Values

T_CLEAR

protected final double T_CLEAR
See Also:
Constant Field Values

T_CURSOR_HOME

protected final double T_CURSOR_HOME
See Also:
Constant Field Values

T_ENTRY_MODE

protected final double T_ENTRY_MODE
See Also:
Constant Field Values

T_DISPLAY_ON

protected final double T_DISPLAY_ON
See Also:
Constant Field Values

T_SHIFT_MOVE

protected final double T_SHIFT_MOVE
See Also:
Constant Field Values

T_FUNCTION

protected final double T_FUNCTION
See Also:
Constant Field Values

T_CG_ADDR

protected final double T_CG_ADDR
See Also:
Constant Field Values

T_DATA_ADDR

protected final double T_DATA_ADDR
See Also:
Constant Field Values

T_WRITE_RAM

protected final double T_WRITE_RAM
See Also:
Constant Field Values

T_READ_RAM

protected final double T_READ_RAM
See Also:
Constant Field Values

command_word

protected int command_word

command_old

protected int command_old

cg_address

protected int cg_address

data_address

protected int data_address

active_memory

protected int active_memory

busy

protected boolean busy

incr_not_decr

protected boolean incr_not_decr

decrement_mode

protected boolean decrement_mode

shift_not_move

protected boolean shift_not_move

four_bit_mode

protected boolean four_bit_mode

four_bit_first

protected boolean four_bit_first

lcdCanvas

TextLCDCanvas lcdCanvas

topFrame

javax.swing.JFrame topFrame

controlPanel

javax.swing.JPanel controlPanel

debugCheckbox

javax.swing.JCheckBox debugCheckbox

theIcon

java.awt.Image theIcon
Constructor Detail

TextLCD

public TextLCD()
the TextLCD default constructor. This will also prepare the GUI.

Method Detail

setSymbol

public void setSymbol(Symbol s)
Overrides:
setSymbol in class SimObject

setName

public void setName(java.lang.String name)
Description copied from class: SimObject
set the name of this SimObject. If there is a Symbol for this SimObject, we also try to set the InstanceLabel in the Symbol.

To avoid consistency problems, when the user changes a SimObject's name interactively, we also try to enforce a unique name.

Overrides:
setName in class SimObject

setLocalDebug

public void setLocalDebug(boolean b)

getLocalDebug

public boolean getLocalDebug()

doInitialize

public void doInitialize()

doClearDisplay

public void doClearDisplay()
00 0000 0001


doCursorHome

public void doCursorHome()
00 0000 001X


doSetEntryMode

public void doSetEntryMode()
00 0000 01IS


doSetDisplayOn

public void doSetDisplayOn()
00 0000 1DCB


doShiftMove

public void doShiftMove()
00 0001 SRXX


doSetFunction

public void doSetFunction()
00 001D NFXX

Do some ugly things to our internal state: select 4/8 bit input mode, ignore font selection, check for user reset via multiple setFunction commands.


doSetCGAddress

public void doSetCGAddress()
00 01AA AAAA


doSetDataAddress

public void doSetDataAddress()
00 1AAA AAAA


doReadBusy

public void doReadBusy()
01 BF AAA AAAA


doWriteData

public void doWriteData()
10 DDDD DDDD


doReadData

public void doReadData()
11 DDDD DDDD


setCGAddress

public void setCGAddress(int address)

setDataAddress

public void setDataAddress(int address)

writeData

public void writeData(int value)
write 'value' into the current address of the data RAM or CG RAM, whichever is selected. Afterwards, update address and cursor position, depending on the parameters for cursor move/shift, etc.

Note that writes to the CG RAM are currently not implemented.


updateDataAddress

public void updateDataAddress()

incrementDataAddress

public void incrementDataAddress()

decrementDataAddress

public void decrementDataAddress()

updateCGAddress

public void updateCGAddress()

readData

public int readData()
retrieve the data at the current address from the data RAM of CG RAM, whichever is selected.

Note that reads from the CG RAM are currently not implemented.


readAddress

public int readAddress()

buildGUI

void buildGUI()

buildControlPanel

void buildControlPanel()

buildGUICallbacks

void buildGUICallbacks()

changeName

public void changeName()

write

public void write(java.io.PrintWriter ps)
Overrides:
write in class SimObject

initialize

public boolean initialize(java.lang.String s)
Description copied from class: SimObject
initialize a SimObject from a String. The method returns true once all required data has been read. Until then, you should repeatedly call initialize() with additional Strings.

Overrides:
initialize in class SimObject

getPropertySheet

public java.awt.Component getPropertySheet()
Description copied from class: SimObject
return a reference to the 'property sheet' or configuration window for this SimObject. We cast the return value to an AWT Component, but typically you can expect either a hades.gui.PropertySheet or an java.awt.Window (Dialog or Frame).

Overrides:
getPropertySheet in class SimObject

configure

public void configure()
Description copied from class: SimObject
create and display a 'ConfigDialog' to set the parameters for a SimObject. The default ConfigDialog for the base class (SimObject) itself is empty except for the 'instance name' of the SimObject.

Overrides:
configure in class SimObject

mousePressed

public void mousePressed(java.awt.event.MouseEvent me)
Description copied from class: SimObject
react to a MouseEvent. The base SimObject ignores MouseEvents.

Note that the HADES schematic editor will also deliver jfig.canvas.FigCanvasEvent object, which also include the world-coordinates of the Event.

Overrides:
mousePressed in class SimObject

elaborate

public void elaborate(java.lang.Object arg)
elaborate(): We assign a '0' to all our outputs.

Specified by:
elaborate in interface Simulatable
Overrides:
elaborate in class SimObject
Parameters:
arg - This parameter is ignored by TextLCD

evaluate

public void evaluate(java.lang.Object arg)
evaluate(): This LCD controller is sensitive to the falling edge on the enable signal (port_E) only, when the R/S, R/W, and data signals are sampled.

Also, note that the enable pulse duration must be at least 450 nsec, and that all commands except 'read busy flag' are ignored while the controller is busy servicing an older command.

See the data-sheet for details of controller commands and operation.

Specified by:
evaluate in interface Simulatable
Overrides:
evaluate in class SimObject
Parameters:
arg - An arbitrary and unused object

decode

public void decode(int command)

copy

public SimObject copy()
copy(): create an (empty) clone of the current TextLCD

Overrides:
copy in class SimObject

setBusyFor

public void setBusyFor(double delta_t)

wakeup

public void wakeup(java.lang.Object arg)
called in reaction to our setBusyFor() calls. Clear our internal busy flag. The 'arg' argument is not used.

Specified by:
wakeup in interface Wakeable

getToolTip

public java.lang.String getToolTip(java.awt.Point position,
                                   long millis)
Description copied from class: SimObject
construct a (short) tool tip message for a SimObject. This method should be overridden as needed.

Specified by:
getToolTip in interface ContextToolTip
Overrides:
getToolTip in class SimObject

hex

public java.lang.String hex(int i)

toString

public java.lang.String toString()
toString() - the usual info method

Overrides:
toString in class SimObject

msg

public void msg(java.lang.String s)
msg()


sleep

public static void sleep(int millis)

main

public static void main(java.lang.String[] argv)
main(): simple selftest of the TextLCD's GUI