Pages: [1]   Go Down
Author Topic: BV4618 LCD, but Keypad not working  (Read 706 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 30
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi all,

I've got a BV4618 with keypad and lcd, but I can't for the life of me get the keypad working. I've had it working once, and then it stopped working and I can't spot what's different. Can anyone help?

My basic code is as so...

Code:
#include <bv4618_I.h>
#include <Wire.h>

BV4618_I di(0x31);

void setup()
{
  // set up display geometry
  di.setdisplay(4,20);
  // set up keyboard scan codes, alter the above constant array
  // this will depend on how the keypad has been wired
  const char kb[]={0x7d,0xee,0xed,0xeb,0xde,0xdd,0xdb,0xbe,0xbd,0xbb,0xe7,0xd7,0xb7,0x77,0x7e,0x7b}; 
  di.setkeycodes(kb);
  // clear screen
  di.cls();
}

void loop()
{
char tmp;

  di.puts("Display Test");
  di.rowcol(2,1);
  while(1) {
    if(!di.keyint()) {
      tmp=di.key();
      if(tmp > 9) tmp+='A'-10;
      else tmp+='0';
      di.putch(tmp);
      di.putch(' ');
    }
   }
  while(1);
}

...which is essentially the sample code. One thing I've noticed is the address I need to use to get the lcd working (0x31) is different to the one in lots of the sample code (0x42) and to what comes up when the lcd starts up (0x62) - but this seems to be the only one that works for the screen. Any advice very gratefully received!

M.
Logged

Western New York, USA
Offline Offline
Faraday Member
**
Karma: 25
Posts: 4108
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
One thing I've noticed is the address I need to use to get the lcd working (0x31) is different to the one in lots of the sample code (0x42)

and to what comes up when the lcd starts up (0x62) - but this seems to be the only one that works for the screen. Any advice very gratefully

received!
Disclaimer:  I do not have one of these devices so this is based on a quick look at the BV4618 datasheet.

There is some confusing information about addressing in Section 8 on page 6 of the datasheet.  They are using the terms '8bit address' and '7bit address' which, in my opinion, is not correct.  I2C devices use a 7 bit address, PERIOD.  In use this seven bit address is shifted to the left and the newly available low bit is used to signify the direction of dataflow.  This 8 bits of information is no longer an address, it is a command that contains seven bits of address information and one bit of data direction information.

In your case the I2C address is the seven bit value 0110001, which can be expressed as B00110001 or 0x31.
When writing to the device the seven address bits are shifted to the left and a '0' is tacked on to the end to give B01100010 or 0x62.
When reading fron the device the seven address bits are shifted to the left and a '1' is tacked on to the end to give B01100011 or 0x63.

Look at the note at the very end of your datasheet.  Your device saves what they call the 'address' of the device but what is actually the shifted address with the data direction bit cleared. 

Don
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 30
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks for that. Weirdly, now when I boot my build up, it's displaying an address of 0xFF - and I now have to use 0xFF to access it. Not sure if this floating address is part of the problem...
Logged

Western New York, USA
Offline Offline
Faraday Member
**
Karma: 25
Posts: 4108
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Thanks for that. Weirdly, now when I boot my build up, it's displaying an address of 0xFF - and I now have to use 0xFF to access it.
There is some information about changing the I2C address near the bottom of page 11.  I have yet to decipher it all since I can't find any Zorkian to English translation information.  It does say, however, that it must always be an even number since it is actually what they are calling the '8 bit write address' (the seven bit I2C address with the least significant bit low to indicate 'write').

This means that the 0x31 that you are specifying in your code and the 0xFF that you are reading are both illegal.  Perhaps you should start over after doing a Hardware Reset.


Don
Logged

Pages: [1]   Go Up
Jump to: