PaulStoffregen / XPT2046_Touchscreen

Touchscreen Arduino Library for XPT2046 Touch Controller Chip
249 stars 89 forks source link

Allow use to choose a different SPI port and also ability to use my F… #33

Closed KurtE closed 3 years ago

KurtE commented 4 years ago

…lexSPI code

Added the ability to specify a different SPI port on the begin method. like

ts.begin(&SPI1);

And use SPI1 for the touch screen.

Also for T4.x as an experiment I added support to allow you to include my FlexIO library including the FlexSPI object : My library is up at: https://github.com/KurtE/FlexIO_t4

I experimented with my version of Touchpaint_xpt2046;, with using different pins for the touch SPI pins than the display.. On T4.1 I tried using SPI1, with pins that would work for either SPI1 or FlexIO.

For FlexIO I could do:

#define Touch_SCK    27  // B0_10
#define Touch_CS     38  // B1_01
#define Touch_MOSI  26  // B1_00
#define Touch_MISO  39  // B0_11S
FlexIOSPI SPIFLEX(Touch_MOSI, Touch_MISO, Touch_SCK, -1); // Setup on (int mosiPin, int sckPin, int misoPin, int csPin=-1) :
XPT2046_Touchscreen ts(Touch_CS);

And later I would do:

ts.begin(&SPIFLEX);

Or since these are actually SPI1 bpins. could use the defines like before:

#define Touch_SCK    27  // B0_10
#define Touch_CS     38  // B1_01
#define Touch_MOSI  26  // B1_00
#define Touch_MISO  39  // B0_11S
XPT2046_Touchscreen ts(Touch_CS);

And then in setup do:

  SPI1.setMISO(Touch_MISO);
  if (!ts.begin(&SPI1)) {

Which appeared to work.

I tried adding the use of my flexIO library with the syntax like:


#if defined(__IMXRT1062__)
#if __has_include(<FlexIOSPI.h>)
    #include <FlexIOSPI.h>
#endif
#endif
'''
So hopefully should not impact non T4 boards nor ones that don't have my libraries.
KurtE commented 4 years ago

Note: I believe this would address issue #29

PaulStoffregen commented 3 years ago

Can you change the API so it take C++ reference. Like this:

ts.begin(SPI1);

Perfectly fine to use pointers inside the library. Let's just avoid the extra C syntax for the public API.

KurtE commented 3 years ago

Will do.

From: Paul Stoffregen notifications@github.com Sent: Monday, October 05, 2020 4:22 PM To: PaulStoffregen/XPT2046_Touchscreen XPT2046_Touchscreen@noreply.github.com Cc: KurtE kurte@rockisland.com; Author author@noreply.github.com Subject: Re: [PaulStoffregen/XPT2046_Touchscreen] Allow use to choose a different SPI port and also ability to use my F… (#33)

Can you change the API so it take C++ reference. Like this:

ts.begin(SPI1);

Perfectly fine to use pointers inside the library. Let's just avoid the extra C syntax for the public API.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/PaulStoffregen/XPT2046_Touchscreen/pull/33#issuecomment-703940435 , or unsubscribe https://github.com/notifications/unsubscribe-auth/AAL4MQDO5GJ3FFX24YQB6QLSJJIKLANCNFSM4SCKVSRA .

PaulStoffregen commented 3 years ago

Looks great. Thanks!