BV4218 LCD controller and Keypad Interface  
 

Contained within this html page are scripts that will work in conjunction with the VB4221. The BV4221 is a USB to I2C converter so that by connecting the BV4221 to the PC and also to one or more I2C devices, it is possible to control them from this browser document.

There are several documents in the series all of which concentrate on one particular I2C device, the first green and second blue forms are for communicating with the BV4221 and any form or text that follows is for the particular device in question. This text uses BV scripts and so depending on how the browser is configured there may be security warnings. Feel free to view the scripts and use as you like in your own applications.

Because VBScript is used then an IE (Microsoft) compatible browser is required. VBscript can also be made to run stand alone and within Microsoft applications such as Excel and Word. The script in this file should run with little modification.

 
     
  Open COM Port  
  The 'Open Port' button opens the COM port and checks the BV4221 is connected, it will not show an error if the wrong com port is chosen but will indicate if the correct port has been chosen and the BV4221 is connected.
Open COM Port
Com Port Number 1-5:      Port Settings:

   
 
     
  I2C System Commands  
  The next section is common to all I2C BV devices and can be used to interrogate the EEPROM and change the address etc. You will see that address 0 of the EEPROM is the device address.
Common BV, I2C System Functions
<< set device address Firmware version >>
From #Bytes Results
When writing separate hex with comma, e.g. 0a,9,fd,0,3
 From Data
The reset button will just reset but the factory button installs defaults ** Note the address is set back to 0x42 as well.
<< new address EVEN numbers only
 
     

  BV4218 LCD Controller and Keypad Interface  
  The BV4218 is an I2C LCD controller and keypad interface designed to be mounted on the back of an LCD display as shown here. They can be used on top or side mounting displays. This picture shows one connected to a 20 x 2 line display. There is also a plug that can take a standard cross switch keypad for up to 12 keys (3 columns x 4 rows), the keys can be programmed to output any 8 bit number to match the characters on the face of the keys. All of this is controlled with I2C commands.

 

The above picture shows a BV4221 connected to a 20 x 2 display along with a typical keypad. The scripts in this file can write to the display, read from the keypad and also map the keays to output meaningful numbers.

 
     
  BV4218 From  
 

LCD Interface

Nearly all of the functions for writing to the LCD and reading from the keypad are contained within this form. Because LCD's vary the actual scripts of this file may need changing but experimentation with a few displays has found that so far, no changes have been required.

To use the interface, assuming the port is open on the green form, simply enter what you want the see in the text poxes provided. It more than likely that you will need to change the value that moves the display to the second line, the default is C0 (hex) but on 16 line display this is quite often 40. Some trial an error may be needed here.

The send date button uses the VBScript date() and time() functions. This could form the bases of other more exotic system based information, given the right API. Also if connected to the internet the display could show a news feed perhaps?

Keypad Interface

the 'Get Key' button will get the number of keys in the buffer and the value of the read key, provided there are keys in the buffer this value will decrement ready to get the next key. If no keys are in the buffer 0 is returned and the default key presented, usually with a value of 15.

Because it is unknown how the rows and columns will be connected to the interface it is possible to map values to scan codes received when a key is pressed. This can be a bit confusing but here a simple button is provided, use it as follows:

  1. Make sure that the interface is in the factory reset state, you can do this by using the 'factory' button on the blue form above

  2. Press each key in turn starting at 0, press the * and # last then they will be assigned values of 11 & 12.
  3. Press the 'Map keys' button.

There is no feedback to say that it has completed. Test by pressing a couple of known kesy and look at the results.

.

BV4218 LCD & Keypad Interface
Enter Text to display:
Line 1:  << Limit to 16 characters
Line 2:    <<  This command byte in Hex moves to line 2

Key Pad
Number of keys in buffer:   Key Value:

Key Pad Setup
Clear the key buffer and then press each key in ascending order, when finished press the map key button. The keys will then be mapped as they were pressed. Note this will only work from a factory reset condition.