hades.models.special
Class TextLCDCanvas

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjavax.swing.JComponent
              extended byhades.models.special.TextLCDCanvas
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable

public class TextLCDCanvas
extends javax.swing.JComponent

a GUI component for a LCD dot-matrix display, with up two 2 lines of 40 chars each. The display controller always has 80 bytes of internal RAM, with additional cursor address and a 'base address' for scrolling.

The memory layout is different for one-line or two-line operation. For one-line operation, valid addresses are 0x00 .. 0x4F, with a window of 8/16/20/40 characters visible. Use the shift-display instructions to move (=scroll) the visible window. Address above 0x80 are wrapped around to the 0x .. 0x7F range, invalid address accesses are ignored and result in a warning message.

For two-line operation, valid addresses are 0x00 .. 0x27 and 0x40 .. 0x67. As in one-line mode, the display window of 8/16/20/40 characters can be moved (scrolled) by the shift instructions.

See Also:
Serialized Form

Nested Class Summary
protected  class TextLCDCanvas.BlinkTimer
           
 
Nested classes inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Container
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
TextLCDCanvas(int n_rows, int n_cols)
           
 
Method Summary
 void clearDisplay()
           
 int countColums()
           
 int countRows()
           
 void createBlinkTimer()
           
 void createBufferImage()
           
 void cursorHome()
           
 void enableCursor(boolean b)
           
 void enableCursorBlinking(boolean b)
           
 void enableDisplay(boolean b)
           
 boolean getAutoRepaintEnable()
           
 int getColumn(int address)
          calculate the display column corresponding to address.
 int getCursorAddress()
           
 int getDataAt(int addr)
          return the internal memory data of 'addr'.
 int getDataAt(int row, int column)
           
 java.awt.Dimension getMinimumSize()
           
 int getPixelX(int address)
           
 int getPixelY(int address)
           
 java.awt.Dimension getPreferredSize()
           
 int getRow(int address)
          calculate the display row (0 or 1) corresponding to address.
 void hideCursor(int address)
           
 void initializeData()
           
 void initializeHamburgData()
           
 boolean isDoubleBuffered()
           
 boolean isOpaque()
           
 boolean isVisibleAddress(int address)
           
 void loadCharacterMatrix(java.lang.String resourcename)
          load the image file with the full character matrix (ROM).
 void loadDefaultColors()
           
static void main(java.lang.String[] argv)
           
 void moveCursorLeft()
           
 void moveCursorRight()
           
static void msg(java.lang.String msg)
           
 void paintComponent(java.awt.Graphics g)
           
 int readCGRam(int address)
           
 void repaintAt(int address)
           
 void rotateLeft()
           
 void rotateRight()
           
 void selectTwoLines(boolean b)
           
 void selectUnderlineCursor(boolean b)
           
 void setAutoRepaintDelay(int millis)
           
 void setAutoRepaintEnable(boolean b)
           
 void setBaseAddress(int address)
           
 void setCursorAddress(int address)
           
 void setDataAt(int address, int value)
           
 void setSize(int rows, int columns)
          set a new size for this LCD.
 void showCursor(int address)
           
 void update(java.awt.Graphics g)
           
 void updateBufferImage(java.awt.Graphics g)
           
 void writeCGRam(int address, int value)
          write to character generator RAM area.
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getNextFocusableComponent, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, updateUI
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TextLCDCanvas

public TextLCDCanvas(int n_rows,
                     int n_cols)
Method Detail

countRows

public int countRows()

countColums

public int countColums()

setSize

public void setSize(int rows,
                    int columns)
set a new size for this LCD. Note that you should call repaint() after calling this method, and you probably need to call pack() or reshape() for the AWT/Swing container of the LCDCanvas, too.


initializeData

public void initializeData()

initializeHamburgData

public void initializeHamburgData()

clearDisplay

public void clearDisplay()

enableDisplay

public void enableDisplay(boolean b)

selectTwoLines

public void selectTwoLines(boolean b)

enableCursor

public void enableCursor(boolean b)

selectUnderlineCursor

public void selectUnderlineCursor(boolean b)

enableCursorBlinking

public void enableCursorBlinking(boolean b)

setCursorAddress

public void setCursorAddress(int address)

getCursorAddress

public int getCursorAddress()

cursorHome

public void cursorHome()

moveCursorLeft

public void moveCursorLeft()

moveCursorRight

public void moveCursorRight()

setBaseAddress

public void setBaseAddress(int address)

rotateLeft

public void rotateLeft()

rotateRight

public void rotateRight()

createBlinkTimer

public void createBlinkTimer()

loadDefaultColors

public void loadDefaultColors()

loadCharacterMatrix

public void loadCharacterMatrix(java.lang.String resourcename)
load the image file with the full character matrix (ROM). All standard characters are modeled, and all user-definable positions are free. However, we use position 0x1F to store an additional 'underline cursor' bitmap.


createBufferImage

public void createBufferImage()

setDataAt

public void setDataAt(int address,
                      int value)

getDataAt

public int getDataAt(int addr)
return the internal memory data of 'addr'. Note that memory addresses are 0x00 to 0x4F for one-line operation and 0x00 to 0x27 and 0x40 to 0x67 for two-line operation. Accesses outside the valid address ranges return zero.


getDataAt

public int getDataAt(int row,
                     int column)

getRow

public int getRow(int address)
calculate the display row (0 or 1) corresponding to address. The row can only be '1' in two-line operation with an address larger than 0x40.


getColumn

public int getColumn(int address)
calculate the display column corresponding to address. In one-line operation, this depends on the address and the value of the base_address due to shifting.

Note that the resulting column may not be visible on displays smaller than 40 chars wide.


getPixelX

public int getPixelX(int address)

getPixelY

public int getPixelY(int address)

isVisibleAddress

public boolean isVisibleAddress(int address)

update

public void update(java.awt.Graphics g)

isOpaque

public boolean isOpaque()

isDoubleBuffered

public boolean isDoubleBuffered()

paintComponent

public void paintComponent(java.awt.Graphics g)

updateBufferImage

public void updateBufferImage(java.awt.Graphics g)

repaintAt

public void repaintAt(int address)

hideCursor

public void hideCursor(int address)

showCursor

public void showCursor(int address)

getMinimumSize

public java.awt.Dimension getMinimumSize()

getPreferredSize

public java.awt.Dimension getPreferredSize()

getAutoRepaintEnable

public boolean getAutoRepaintEnable()

setAutoRepaintEnable

public void setAutoRepaintEnable(boolean b)

setAutoRepaintDelay

public void setAutoRepaintDelay(int millis)

writeCGRam

public void writeCGRam(int address,
                       int value)
write to character generator RAM area. Accessible are the characters codes 0000x000 to 0000x111, where the 8 rows of character 0000x000 correspond to the CGRAM addresses 000 000 to 000 111, and character 0000x111 correspdond to CGRAM 111 000 to 111 111. All 8 bits of 'value' are written to the CG data area, but only the lower 5 bits are actually visible.


readCGRam

public int readCGRam(int address)

msg

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

main

public static void main(java.lang.String[] argv)