Forum Rule: Always post complete source code & details to reproduce any issue!
Page 6 of 6 FirstFirst ... 4 5 6
Results 126 to 134 of 134

Thread: ILI9341 and XPT2046 for Teensy Touchscreen 320x240 display

  1. #126
    Junior Member
    Join Date
    Jan 2019
    Posts
    4
    First off, thank you for following up. You're correct there is no evidence of any physical damage but I've been in electronics long enough to know ICs don't show damage often. Anyway, Wiring follows the documentation at PJRC site. VCC red, GND blk, CS TCS yel, RESET brn, DC org, SDI T_DIN grn, SCK pur, T_CLK grey, LED red, SDO T_DO blu, T_IRG org


    Click image for larger version. 

Name:	IMG_0678.jpg 
Views:	10 
Size:	112.6 KB 
ID:	15526

    I hope you see my error.

  2. #127
    Junior Member
    Join Date
    Jan 2019
    Posts
    4
    OK - Guess no one found an error. I discovered that the touch does work correctly after all but just not for Teensy 3.6. Soon as I put it on a Teensy 3.2 all example sketches starting working with problems. I am not sure why this is so but on person told me the CS pin pulse is so fast and short on the 3.6 he had to add a 47p cap to the pin to slow it down enough to work. I did not try this but it might offer why the 3.6 does not work while the 3.2 does.

    So I offer my findings and will stop banging my head against the wall with the 3.6! If someone has a code fix for the Teensy or other ideas to make it work I'd love to hear them.

  3. #128
    Junior Member
    Join Date
    Jan 2019
    Location
    Suburban Hell, AKA, Aloha, OR
    Posts
    5

    Mirrored X/Y Axis issue?

    Hi Everyone!

    I'm trying to build a "simple" encoder based measuring tool using a the IL9341 touch screen I bought from Paul.. I noticed his nifty breakout/test board, hopped over to OSH Park and ordered a set because they were just the thing I needed! Hooked it all up, added IR9341_t3 libraries to Arduino 1.8.7 and ran a few tests - all seems to work, happy days..

    Next step, plagiarize a smarter person's work to hack up a few simple touchscreen buttons.. (I'm building a G-Scale railroad car with speed and distance measuring capabilities.. Well, I'm going to TRY.. ) Anyway, a little googling around lead me to defragster's awesome examples base for the very work I want.. A modest TFT screen to display some formatted data from a capacitive encoder and a touch screen to implement a few buttons to calibrate, reset data and set units and such..

    But when I upload the code examples, they don't seem to work exactly as expected, and the issue SEEMS to be a mirroring of both X and Y axis the touch screen uses...

    IE:, when the "ROT" button is in the upper left corner, I have to touch the lower right corner to activate a rotation.. On a narrower scale, I can see the same effect on buttons in the center.. This is more pronounced on screens where the buttons are even number x even number, but it remains consistent at all times.

    If I touch "Rot", the serial console spits out:
    Code:
    button #20
    button #20
    button #20
    Okay, I pressed it THREE times there..

    It occurred to me as I wrote this that I said "everything works", but that doesn't mean I understand the correct value of "working"!! So, the photo shows the touch coordinates as generated by the "IL9341Test" example.. Is the "upper right" supposed to be the higher numbers and lower left the lowest numbers? I don't know if that's "correct" orientation or not.. The product photo is sort of conviently in the middle, so that's hard to use as a gauge..

    Click image for larger version. 

Name:	orientation.JPG 
Views:	5 
Size:	106.7 KB 
ID:	15756

    My display is version 1.2, the Teensy is a 3.2, the display TFT Display test board does not appear to have a revision. The code base in question is ColorButtonsMark3 pulled from github.

    I'll be upfront - my C-foo is weak at best.. I can see a few rotation key words, but I don't recognize anything that would appear to address my situation..

    So - did I miss something in the RTFM part that would fix this? I'm excited to see what I can come up with using this example base, but I pretty sure I need to understand why it's not working for me first..

    Thanks for any input!!

    Sincerely,

    -ET-
    Last edited by mtrcycllvr; 01-28-2019 at 10:07 AM.

  4. #129
    Junior Member
    Join Date
    Jan 2019
    Location
    Suburban Hell, AKA, Aloha, OR
    Posts
    5
    Quote Originally Posted by mtrcycllvr View Post
    The product photo is sort of conviently in the middle, so that's hard to use as a gauge.
    I so lie.. The product page INDEED shows that my numbers are backwards.. Paul's finger is at the lower left.



    My values for the same position are backwards?

    Click image for larger version. 

Name:	wrong.JPG 
Views:	2 
Size:	109.2 KB 
ID:	15757

    Okay, I answer one of my own questions - can someone suggest why I'm seeing reverse values?

    Thanks so much!!

  5. #130
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    7,817
    The numbers need to be changed with screen rotation. I did a cool map function that can move to any orientation. It looks like your screen is the same orientation there.

    Is this the 'ColorButtonsMark3' code used: Defragster/XPT2046_Touch_Examples … ColorButtonsMark3/ButtonMap.cpp#L31

    That link goes to the map with rotation I did, it needs to be oriented with the screen X,Y to map properly.

  6. #131
    Junior Member
    Join Date
    Jan 2019
    Location
    Suburban Hell, AKA, Aloha, OR
    Posts
    5
    Quote Originally Posted by defragster View Post
    The numbers need to be changed with screen rotation. I did a cool map function that can move to any orientation. It looks like your screen is the same orientation there.

    Is this the 'ColorButtonsMark3' code used: Defragster/XPT2046_Touch_Examples … ColorButtonsMark3/ButtonMap.cpp#L31

    That link goes to the map with rotation I did, it needs to be oriented with the screen X,Y to map properly.
    Ah! I see!

    Code:
    //TS_MAP tsMap[5] = { {200, 3700, 325, 3670 }, { 0, 319, 0, 239 }, { 319, 0, 0, 239 }, { 319, 0, 239, 0 }, { 0, 319, 239, 0 } };
    // wrong orientation for my screen!!
    TS_MAP tsMap[5] = { {3700, 200, 3670, 325 }, { 0, 319, 0, 239 }, { 319, 0, 0, 239 }, { 319, 0, 239, 0 }, { 0, 319, 239, 0 } };
    ...makes your example code run as expected on my screen! On to more hacking of examples!

    Thanks so much for your prompt response!!

    -ET-

  7. #132
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    7,817
    Quote Originally Posted by mtrcycllvr View Post
    Ah! I see!

    Code:
    //TS_MAP tsMap[5] = { {200, 3700, 325, 3670 }, { 0, 319, 0, 239 }, { 319, 0, 0, 239 }, { 319, 0, 239, 0 }, { 0, 319, 239, 0 } };
    // wrong orientation for my screen!!
    TS_MAP tsMap[5] = { {3700, 200, 3670, 325 }, { 0, 319, 0, 239 }, { 319, 0, 0, 239 }, { 319, 0, 239, 0 }, { 0, 319, 239, 0 } };
    ...makes your example code run as expected on my screen! On to more hacking of examples!

    Thanks so much for your prompt response!!

    -ET-
    @mtrcycllvr , hope you are still having Teensy fun - glad I saw your post quickly and you used it to work!

    Just looking back at this code myself and looking closer at this. The goal of the MAP array was to leave the first set of screen Min/Max values unchanged and then index the calculation from there 1,2,3,4 based on screen rotation.

    The swap you did should be the same as setting screen rotation to [3] = { 319, 0, 239, 0 } - that results in the swap of the direction.

    This should be the same if in the source a change of :: int16_t TS_Rotate = 1; to int16_t TS_Rotate = 3;

    Or at RunTime in setup:: ts.ButtonRotate( 3 );

    The goal was allowing the user to rotate the screen and touch with it one or more times after startup without code change.

  8. #133
    Junior Member
    Join Date
    Jan 2019
    Location
    Suburban Hell, AKA, Aloha, OR
    Posts
    5
    Quote Originally Posted by defragster View Post
    @mtrcycllvr , hope you are still having Teensy fun - glad I saw your post quickly and you used it to work!

    Just looking back at this code myself and looking closer at this. The goal of the MAP array was to leave the first set of screen Min/Max values unchanged and then index the calculation from there 1,2,3,4 based on screen rotation.

    The swap you did should be the same as setting screen rotation to [3] = { 319, 0, 239, 0 } - that results in the swap of the direction.

    This should be the same if in the source a change of :: int16_t TS_Rotate = 1; to int16_t TS_Rotate = 3;

    Or at RunTime in setup:: ts.ButtonRotate( 3 );

    The goal was allowing the user to rotate the screen and touch with it one or more times after startup without code change.
    Hey, thanks for the reply and the further distillation! Yeah, see that's the problem, my c-foo is so weak, I couldn't see that, which, well, read on... And I TOTALLY get that your trying to solve the very problem I'm currently facing...

    I'm sorry, I did build a thing, and no, I did not build it from your model.. Of course, now there are RFC's that actually make sense, and I'm kicking myself for not just buckling down and figuring out how to meld your library with my desires in the first place..

    Click image for larger version. 

Name:	IMG_3275.JPG 
Views:	7 
Size:	128.9 KB 
ID:	16193

    So, in the next few days I'm going to take another stab at using your library for a 'version' of my tool that has the sort of flexibility it really could use..

    Your clarification fits nicely with my recent notice of the sticker on the most recent display that suggested pairs of library "orientation" values that had previously escaped my notice..

    Ultimately it's all about me and my general lack of c++-foo.. ;-)

    I'll be sure to poke back here if I get in trouble - honestly, my goal is pretty simple:

    decode/track encoder data
    display data in user selectable scales in a few "formats"
    landscape/portrait mode for said display

    I just got intimidated as I didn't immediately understand much of your code and "thought" my requirements were so simple, they'd NEVER change, right? ;-)

    https://github.com/mtrcycllvr/g-scal...n_distance_car

    Again, thanks.. You may hear more lame questions from me shortly!! The latest circuit boards (not up on github yet) are out for fab, so updated FW is the next big step!

    -ET-

  9. #134
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    7,817
    Glad it is of some value to you - hopefully it will teach you something good. That looks like a very nice build!

    I'm not sure that code is the best example of anything - but it was working as I left it, and when I run it again now … only now looking at it again to integrate the map_code() to suggest inclusion in the lib because that same 2046 touch controller showed up on a new 320x480 display - except it doesn't seem to act as nicely … and my first attempt to port my own code for that has put me off it for a week.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •