LCDDogm

Module NameLCDDogm
Import NameDogm

The LCD module is designed to support the EA DOG series LCD. The interface is compatible with the Hitachi HD44780 LCD controller.

Options

Program Examples

SetBacklight

  Sub SetBacklight(value As UShort)
  • value - Backlight value, in the range 0..1023.

Set the LCD Plus backlight. The backlight is connected to the PWM pin D3.

GetBacklight

 Function GetBacklight() As UShort

Return the current backlight value.

SetContrast

 Sub SetContrast(value As Byte)
  • value - Contrast value, in the range 0..32.

Sets the LCD contrast.

GetContrast

 Function GetContrast() As Byte

Return the current contrast value.

WriteCommand

  Sub WriteCommand(cmd As Byte)
  • cmd - Command byte to write.

Write a command to the LCD. The command byte can be:

  • cmdCGRAM
  • cmdDDRAM
  • cmdClear
  • cmdHome
  • cmdCursorOff
  • cmdCursorOn
  • cmdBlinkOn
  • cmdBlinkOff
  • cmdMoveLeft
  • cmdMoveRight

SetCursor

  Sub SetCursor(line As Byte, column As Byte)
  • line - LCD line number. The line number starts at 1.
  • column - LCD column. The column number starts at 1.

Set the cursor to line and column.

Write

 Compound Sub Write(item)
  • item - Item to write. Can be a byte, string or constant byte array.

Write one or more items to the LCD.

WriteAt

 Compound Sub WriteAt(line As Byte, column As Byte, item)
  • line - LCD line number. The line number starts at 1.
  • column - LCD column. The column number starts at 1.
  • item - Item to write. Can be a byte, string or constant byte array.

Write one or more items to the LCD at location line, column.

Clear

 Sub Clear()

Clear the LCD screen.

#option LCD_DOGM

Sets the LCD to support either two or three line mode. For example,

#option LCD_DOGM = DOGM_162 ' 2 line LCD support
#option LCD_DOGM = DOGM_163 ' 3 line LCD support

#option LCD_INTERFACE

The LCD_INTERFACE option sets the module to either 4 or 8 bit mode. The default is 4 bit mode. For 8 bit mode, the default pins are:

#option LCD_D0 = D0
#option LCD_D1 = D1
#option LCD_D2 = D2
#option LCD_D3 = D3
#option LCD_D4 = D4
#option LCD_D5 = D5
#option LCD_D6 = D6
#option LCD_D7 = D7

Note that using 8 bit mode requires the user to disable the hardware UART, which is by default connected to pins D0 and D1. If using 4 bit mode, the default pins are:

#option LCD_D0 = D4
#option LCD_D1 = D5
#option LCD_D2 = D6
#option LCD_D3 = D7

#option LCD_RS

The LCD reset pin. Default is D8.

#option LCD_EN

The LCD enable pin. Default is D9

#option LCD_COMMAND_US

The LCD_COMMAND_US option sets the delay value after a command write. Values can be ranged between 1 and 65535. If the LCD_COMMAND_US option is not used, it defaults to 2000.

#option LCD_DATA_US

The LCD_DATA_US option sets the delay value after a data write. Values can be ranged between 1 and 255. If the LCD_DATA_US option is not used, it defaults to 50.

#option LCD_INIT_DELAY

The LCD_INIT_DELAY option sets the delay (ms) before the module is initialised. Values can be ranged between 0 and 1000. If LCD_INIT_DELAY option is not used, it defaults to 100.

Counter Example


' file imports...
imports LCDDogm                     

' main program entry point...
sub Main()

   ' set backlight...
   Dogm.SetBacklight(100)

   ' clear the LCD and display counter value...
   Dogm.Clear   
   dim elapsed as ushort = 0 
   while true
      Dogm.WriteAt(1,4,"Firewing")
      Dogm.WriteAt(2,1,"Counter = ", Str(elapsed,5))
      elapsed += 1
      delayms(1000) 
   end while
end sub