|
Post by jethronull on Apr 26, 2014 13:00:06 GMT -8
It's nice having the FT800 run calibration automatically the first time and then remembering the data. But what about when you need to rotate the screen? The auto-calibration runs before you can make the REG_ROTATE call, so now the calibration is upside down for the screen. Does anyone know a way to make the rotate call before the auto-calibration, or read and reverse the calibration data, or test for calibration data and use that to force calibration if needed, ?
I know I could probably make the rotation change in the GD2 library and avoid all this hassle but I like to keep libraries standard.
Also, what's the difference between self_calibrate and cmd_calibrate, if any?
TIA
|
|
|
Post by jamesbowman on Apr 26, 2014 16:23:01 GMT -8
I think this should work, it's really just the code copied out of GD.begin().
GD.begin(~GD_CALIBRATE); // initialize but do not calibrate GD.wr(REG_ROTATE, 0);
if (EEPROM.read(0) != 0x7c) { GD.self_calibrate(); for (int i = 0; i < 24; i++) EEPROM.write(1 + i, GD.rd(REG_TOUCH_TRANSFORM_A + i)); EEPROM.write(0, 0x7c); // is written! } else { for (int i = 0; i < 24; i++) GD.wr(REG_TOUCH_TRANSFORM_A + i, EEPROM.read(1 + i)); }
|
|
|
Post by jethronull on Apr 26, 2014 18:17:51 GMT -8
That looks exactly what I need, thanks. Unfortunately it doesn't like GDTR reference. I see it defined as Static in GD2.cpp. Can it be moved or duplicated in my code to make this work?
TIA
|
|
|
Post by jamesbowman on Apr 26, 2014 18:24:02 GMT -8
Aha yes... I changed the GDTR references to GD in the original post.
|
|
|
Post by jethronull on Apr 26, 2014 19:09:14 GMT -8
Got it. Just one more prob (I think): I modified GD.begin(~GD_CALIBRATE) to GD.begin(~GD_STORAGE | ~GD_CALIBRATE) so that I could keep the startup reliable (remember I don't have SD support), but that doesn't work as expected. Before this new rotation/calibration mod the ~GD_STORAGE had worked a charm on keeping startup reliable (that and the ConnectEve has a Power Down line which I toggle on power up). But it doesn't seem to want to work with ~GD_CALIBRATE. Depending on which way round they are (I think) I either still get the FT800 calibration or very iffy boots.
|
|
|
Post by jamesbowman on Apr 27, 2014 7:19:05 GMT -8
GD.begin() takes a bitmask. The default is to initialize everything. So to switch off calibration: GD.begin(~GD_CALIBRATE); and to switch off storage: GD.begin(~GD_STORAGE); and to switch off both: GD.begin(~(GD_STORAGE | GD_CALIBRATE));
or equally: GD.begin(~GD_STORAGE & ~GD_CALIBRATE); by De Morgan's.
|
|
|
Post by jethronull on Apr 27, 2014 10:46:11 GMT -8
Perfect, I doff my cap to you sire.
|
|
jum
New Member
Posts: 6
|
Post by jum on Jul 12, 2014 2:36:25 GMT -8
Thanks, I used the rotated screen code above because after I had built the Gamediuno 2 into my project box I found the screen was upside down (doh!).
Note that I had to force the self_calibration the first time by temporarily replacing:
if (EEPROM.read(0) != 0x7c) {
with
if (true)
(as the 0x7c had already been written by a previous calibration)
|
|
|
Post by hala on Oct 22, 2016 22:59:31 GMT -8
regards I want to make the calibration of FT800 automatic. I use arduino IN PROGRAMMING whats is the code I should use instead of FTImpl.Cmd_Calibrate(0);
|
|
|
Post by jamesbowman on Oct 23, 2016 7:53:05 GMT -8
The equivalent for GD2 is "GD.self_calibrate()"
Here is the code you can use instead of GD2.begin(), which stores or loads the calibrations:
GD.begin(~GD_CALIBRATE); GD.wr(REG_ROTATE, 0); // flip the display 180 degrees if (EEPROM.read(0) != 0x7c) { GD.self_calibrate(); for (int i = 0; i < 24; i++) EEPROM.write(1 + i, GD.rd(REG_TOUCH_TRANSFORM_A + i)); EEPROM.write(0, 0x7c); } else { for (int i = 0; i < 24; i++) GD.wr(REG_TOUCH_TRANSFORM_A + i, EEPROM.read(1 + i)); }
|
|
|
Post by hala on Oct 23, 2016 21:22:51 GMT -8
my code in arduino ,, when using your code i got error
|
|
|
Post by hala on Oct 23, 2016 21:26:23 GMT -8
I found this code in library but I can't define the correct values I should use so I don't know if this code is right FT_Trans::Write(REG_TOUCH_ADC_MODE,AdcMode); FT_Trans::Write16(REG_TOUCH_CHARGE,Charge); FT_Trans::Write(REG_TOUCH_SETTLE,Settle); FT_Trans::Write16(REG_TOUCH_OVERSAMPLE,Oversample); FT_Trans::Write(REG_TOUCH_RZTHRESH,RZTreshold);
|
|