LCD_IO 0

Using connection mode 0:

To use connection mode 0, a subroutine to write a byte to the LCD must be provided.

Optionally, another subroutine to read a byte from the LCD can also be defined. If the LCD was to be read, the function LCDReadByte would be set to the name of a function that reads the LCD and returns the data byte from the LCD. If there is no way (or no requirement) to read from the LCD, then the LCD_NO_RW constant must be set.

In connection mode 0, the LCD_RS constant will be set automatically to an unused bit variable. The higher level LCD commands (such as Print and Locate) will set it, and the subroutine is responsible for writing to the LCD. The subroutine should handle the process and then set the RS pin on the LCD appropriately.

Relevant Constants:

Specific constants are used to control settings for the Liquid Crystal Display routines included with GCBASIC. To set these constants the main program should specific constants to support the connection mode using #define.

When using connection mode 0 only one constant must be set - all others are optional or can be ignored.

Constant Name Controls Value

LCD_IO

The I/O mode.

0

Example:

    #chip 16F877A, 20

    ' Connection mode 0: every byte written to the LCD is handled by a custom
    ' subroutine instead of GCBASIC's built-in LCD_IO wiring. This example's
    ' subroutine sends the byte over I2C to a remote LCD driver.
    #define LCD_IO 0
    #define LCD_NO_RW
    #define LCDWriteByte MySendToLCD

    cls
    print "Hello World."          ' <<< the print instruction this page documents

    end

    Sub MySendToLCD(In MyLCDByte)

        'Uses I2C.
        'Sends an address byte (128), then a control byte where bit 4 is the
        'state of the RS pin, then a data byte, which is sent to the LCD.

        ControlByte = 0
        If LCD_RS = On Then ControlByte.4 = On

        I2CStart
        I2CSend 128
        I2CSend ControlByte
        I2CSend MyLCDByte
        I2CStop

        'Allow time for the receiver to update the LCD.
        Wait 5 ms

    End Sub

Key line: print "Hello World." — exercises the connection exactly like any other LCD_IO mode; LCDWriteByte transparently calls MySendToLCD for every byte print sends, so higher-level commands need no special handling for connection mode 0.

See the separate sections of the Help file for the specifics of each Connection Mode.

See Also:

  • LCD_IO 1 — 1-wire, via a 74HC595 shift register
  • LCD_IO 2 — 2-wire shift register, deprecated
  • LCD_IO 2_74xx164 — 2-wire via 74HC164/74LS164, the preferred 2-wire method
  • LCD_IO 2_74xx174 — 2-wire via 74LS174, deprecated
  • LCD_IO 3 — 3-wire shift register with an added Enable line
  • LCD_IO 4 — 4-bit parallel connection
  • LCD_IO 8 — 8-bit parallel connection
  • LCD_IO 10 — I2C via a PCF8574/PCF8574A I/O expander
  • LCD_IO 12 — I2C via a Ywmjkdz-layout adapter
  • LCD_IO 14 — SPI expander
  • LCD_IO 16 — PIC16LF72 SPI expander
  • LCD_IO 107 — K107 serial adapter