2.8" Touch Shield (376)

EL Wire/Tape/Panels, LEDs, pixels and strips, LCDs and TFTs, etc products from Adafruit

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
rtropson
 
Posts: 4
Joined: Wed Aug 14, 2013 12:22 pm

2.8" Touch Shield (376)

Post by rtropson »

Hi,
I bought a 2.8: Touch shield and started to program it from scratch for my Arduino Uno (using Arduino 1.0.5 software), but when I try to read the Driver Code Read, instead of 9328h or 9325h, I get 7575
In fact, I was testing whether or not I was properly writing to the registers when I discovered that the high byte and low byte are always identical. After searching other forums, it was suggested by one person that the board I have may be wired for 16/18 bit in stead of 9/8 bit interface timing. Of course I can't take it apart to see if IM1 is set to 1 because the shield is soldered together.

Also, I couldn't use the library with the Arduino 1.0.5 software, it had hundreds of errors, and after playing with it awhile, I deduced that I need some other compiler program. What do I need to use to get the library to work?

After two days of playing with it, I get nothing to happen at all except a blank white screen.

Here is the code I use to read and write to the registers.

void registerWrite(int LcdRegister, int value) // note setDigitalOut must be on
{ int hiValue= value/256;
int writeDelay = 2; // set our delay between writes - to be played with later
digitalWrite(LcdChipSelect,LOW); // in case we had the chip turned off for incoming data!
digitalWrite(LcdRead,HIGH); // see timing page 49 of manual
digitalWrite(LcdWrite,HIGH); // start high. goes low AFTER data is in the register
digitalWrite(LcdRegSelect,LOW); // we are writing to a register
// we are setup to write to a register
// the sequence is write 0
// write register index (i.e. which register)
// write high byte
// write low byte
// to do so, set WR (LcdWrite) Low once value is in Digital outputs, then set high after short delay
setDataValue(0);
digitalWrite(LcdWrite,LOW);
delayMicroseconds(writeDelay);
digitalWrite(LcdWrite,HIGH);

setDataValue(LcdRegister); // write the register index
digitalWrite(LcdWrite,LOW);
delayMicroseconds(writeDelay);
digitalWrite(LcdWrite,HIGH);

digitalWrite(LcdRegSelect,HIGH); // Rs is high to write to the register!!!
delayMicroseconds(writeDelay);

setDataValue(hiValue); // write the high byte (set with first instruction)
digitalWrite(LcdWrite,LOW);
delayMicroseconds(writeDelay);
digitalWrite(LcdWrite,HIGH);

setDataValue(value); // write the low byte setDataValue ignores high byte
digitalWrite(LcdWrite,LOW);
delayMicroseconds(writeDelay);
digitalWrite(LcdWrite,HIGH);
digitalWrite(LcdChipSelect,HIGH);
}

int registerRead(int LcdRegister)
{
byte lobyte = 0;
byte hibyte = 0;
setDigitalOut(); // we first must write
int writeDelay = 2; // set our delay between writes - to be played with later
digitalWrite(LcdChipSelect,LOW); // in case we had the chip turned off for incoming data!
digitalWrite(LcdRead,HIGH); // see timing page 49 of manual
digitalWrite(LcdWrite,HIGH); // start high. goes low AFTER data is in the register
digitalWrite(LcdRegSelect,LOW); // we are writing to a register
// we are setup to write to a register
// the sequence is write 0
// write register index (i.e. which register)
// write high byte
// write low byte
// to do so, set WR (LcdWrite) Low once value is in Digital outputs, then set high after short delay
setDataValue(0);
digitalWrite(LcdWrite,LOW);
delayMicroseconds(writeDelay);
digitalWrite(LcdWrite,HIGH);

setDataValue(LcdRegister); // write the register index
digitalWrite(LcdWrite,LOW);
delayMicroseconds(writeDelay);
digitalWrite(LcdWrite,HIGH);

digitalWrite(LcdRegSelect,HIGH); // Rs is high to read the register!!!
delayMicroseconds(writeDelay);

setDigitalIn(); // we now prepare to read the bytes
digitalWrite(LcdRead,LOW);
delayMicroseconds(writeDelay);
// transfer the bits in from the data
bitWrite(hibyte,0,digitalRead(Data1));
bitWrite(hibyte,1,digitalRead(Data2));
bitWrite(hibyte,2,digitalRead(Data3));
bitWrite(hibyte,3,digitalRead(Data4));
bitWrite(hibyte,4,digitalRead(Data5));
bitWrite(hibyte,5,digitalRead(Data6));
bitWrite(hibyte,6,digitalRead(Data7));
bitWrite(hibyte,7,digitalRead(Data8));
digitalWrite(LcdRead,HIGH);
delayMicroseconds(writeDelay);

digitalWrite(LcdRead,LOW);
delayMicroseconds(writeDelay);
bitWrite(lobyte,0,digitalRead(Data1));
bitWrite(lobyte,1,digitalRead(Data2));
bitWrite(lobyte,2,digitalRead(Data3));
bitWrite(lobyte,3,digitalRead(Data4));
bitWrite(lobyte,4,digitalRead(Data5));
bitWrite(lobyte,5,digitalRead(Data6));
bitWrite(lobyte,6,digitalRead(Data7));
bitWrite(lobyte,7,digitalRead(Data8));
digitalWrite(LcdRead,HIGH);
setDigitalOut(); // return to write state

return hibyte*256+lobyte;
}

User avatar
pburgess
 
Posts: 4161
Joined: Sun Oct 26, 2008 2:29 am

Re: 2.8" Touch Shield (376)

Post by pburgess »

7575 is a valid driver code, indicating a HX8347G LCD driver. My shield has the same.

To use the sample code, you need to install both the Adafruit_TFTLCD and Adafruit_GFX libraries.

What are some of the error messages you're seeing?

User avatar
rtropson
 
Posts: 4
Joined: Wed Aug 14, 2013 12:22 pm

Re: 2.8" Touch Shield (376)

Post by rtropson »

Thanks for your reply.
I guess I didn't pay attention to the fact that it could be 1 of 3 controllers. Yes, I confirmed that I have the HX8347G driver.
I re-did my code and read all the registers to see if they lined up with the driver and they did.
So I rewrote the sequence for writing to the registers and now I have a new problem (and the screen still doesn't do anything but show a blank white screen)
When I write to the registers, they don't always seem to receive the values.
For instance, when I write to register 19h (default value is 0) to change it to 1 (turn on the oscillator) it does fine, but 1Fh(power control) is supposed to be set to D0h and when I read it after writing to it, the value is 51h. Others seem to also misbehave. Since I 'm sure the bits are correct because it can read the register I don't know what is going on.

I did originally install the TFT and GFX libraries, but as I said before, the arduino software compiler doesn't recognize a lot of the code such as macros, and something like in the object oriented programming language dosomething::dosomething() looks like a label to the program.

That is why I'm asking what someone is using for a compiler. Otherwise the library is useless in the state its in. What are you using? Maybe That will get me started.

Here is some new code (startup and write register)


void LcdOn()
{
registerWrite(0x017,0x05); //COLMOD color mode 18Bit/pix RGB 18 Bit/pix System
registerWrite(0x01A,0x03); // Driver voltage LCD 1=min 7= max
registerWrite(0x1B,0x1B); //Gamma Voltage 1B is highest level
registerWrite(0x23,0x80); // VCOMH Voltage2.5 to 5.8V
registerWrite(0x25,0x57); //VMV voltage
registerWrite(0x24,0x2F); //VCOML voltage
registerWrite(0x19,0x01); //Start oscillator - necessary for operation
delay(10);
registerWrite(0x1C,0x03); //Op-Amp current (1-6 allowed)
registerWrite(0x1F,0x88); //STB to zero (off standby)
delay(10);
registerWrite(0x1F,0x80); //DK to zero (DDVDH voltage generation on)
registerWrite(0x1F,0x90); //Step-up circuit 2 for VCL, VGL voltage generation on
registerWrite(0x1F,0xD0); // VCOMG to output to neg voltage
registerWrite(0x38,0x38); //GON DTE (3) on and Display on (8)
delay(10);
//registerWrite(0x3C,0x07); // backight pwm duty
//registerWrite(0x3D,0x07); //backlight
registerWrite(0x28,0x36); //GON DTE (3) on and Display on (6)

registerWrite(0x06,0); // horizontal start position hi byte
registerWrite(0x07,0); // horizontal start position low byte
registerWrite(0x02,0); // vert start hi
registerWrite(0x03,0); //vert start low
registerWrite (0x08,1); // horizontal end pos hi byte
registerWrite(0x09,0x3F);// horizontal end pos low bite
registerWrite(0x04,0); // vert end pos hi byte
registerWrite(0x05,0xEF); //vert end pos low byte0xEF
registerWrite(0x22,0x000); //ready to write to reg 22

}

void registerWrite(int LcdRegister, int value) // note setDigitalOut must be on
{
int writeDelay = 2; // set our delay between writes - to be played with later
digitalWrite(LcdChipSelect,LOW); // in case we had the chip turned off for incoming data!
digitalWrite(LcdRead,HIGH); // see timing page 49 of manual
digitalWrite(LcdWrite,HIGH); // start high. goes low AFTER data is in the register
digitalWrite(LcdRegSelect,LOW); // we are indexing a register, RS is low
// we are setup to write to a register

setDataValue(LcdRegister); // write the register index
digitalWrite(LcdWrite,LOW);
delayMicroseconds(writeDelay);
digitalWrite(LcdWrite,HIGH);

digitalWrite(LcdRegSelect,HIGH); // Rs is high to write to the register
delayMicroseconds(writeDelay);

setDataValue(value); // write the byte
digitalWrite(LcdWrite,LOW);
delayMicroseconds(writeDelay);
digitalWrite(LcdWrite,HIGH);

}

Any help will be appreciated!

User avatar
rtropson
 
Posts: 4
Joined: Wed Aug 14, 2013 12:22 pm

Re: 2.8" Touch Shield (376)

Post by rtropson »

Oh, by the way, I tried it again using the library linked from AdaFruit
and here are my error messages:
I think those are macros?
C:\Program Files (x86)\Arduino\libraries\Robot_Control\ArduinoRobot.cpp: In constructor 'RobotControl::RobotControl()':
C:\Program Files (x86)\Arduino\libraries\Robot_Control\ArduinoRobot.cpp:8: error: 'LCD_CS' was not declared in this scope
C:\Program Files (x86)\Arduino\libraries\Robot_Control\ArduinoRobot.cpp:8: error: 'DC_LCD' was not declared in this scope
C:\Program Files (x86)\Arduino\libraries\Robot_Control\ArduinoRobot.cpp:8: error: 'RST_LCD' was not declared in this scope
C:\Program Files (x86)\Arduino\libraries\Robot_Control\ArduinoRobot.cpp: In member function 'void RobotControl::begin()':
C:\Program Files (x86)\Arduino\libraries\Robot_Control\ArduinoRobot.cpp:18: error: 'MUXA' was not declared in this scope
C:\Program Files (x86)\Arduino\libraries\Robot_Control\ArduinoRobot.cpp:18: error: 'MUXB' was not declared in this scope
C:\Program Files (x86)\Arduino\libraries\Robot_Control\ArduinoRobot.cpp:18: error: 'MUXC' was not declared in this scope
C:\Program Files (x86)\Arduino\libraries\Robot_Control\ArduinoRobot.cpp:18: error: 'MUXD' was not declared in this scope
C:\Program Files (x86)\Arduino\libraries\Robot_Control\ArduinoRobot.cpp:19: error: 'MUX_IN' was not declared in this scope
C:\Program Files (x86)\Arduino\libraries\Robot_Control\ArduinoRobot.cpp:22: error: 'BUZZ' was not declared in this scope
C:\Program Files (x86)\Arduino\libraries\Robot_Control\ArduinoRobot.cpp:25: error: 'Serial1' was not declared in this scope

User avatar
pburgess
 
Posts: 4161
Joined: Sun Oct 26, 2008 2:29 am

Re: 2.8" Touch Shield (376)

Post by pburgess »

Ah yes, that evil Robot_Control bug. Haven't figured out why, but that library causes no end of gas pains with other libraries. Just delete the entire Robot_Control folder (inside the Arduino libraries folder), or ZIP it if you'd like to keep it around for posterity or whatever. Restart the IDE and try again.

User avatar
rtropson
 
Posts: 4
Joined: Wed Aug 14, 2013 12:22 pm

Re: 2.8" Touch Shield (376)

Post by rtropson »

Thank you very much.
Although when I stored the library, I still couldn't compile it, instead I dealt with each error by tweaking the .cpp and .h files until It compiled.
Once it compiled, the test program worked. At least I know the shield works.

I'm disappointed, though, that it takes up 28kbytes of 32kbytes - I need lots of room for programming, so I'm going to try to figure out how to make it smaller.

Thanks again, you have helped me immensely!

Locked
Please be positive and constructive with your questions and comments.

Return to “Glowy things (LCD, LED, TFT, EL) purchased at Adafruit”