So I'm trying to troubleshoot a problem I'm having involving code that I didn't write myself.
I'm using this Arduino board:
And I'm using one of these displays:
Code being referenced is located at:
Specifically: arduinomegachess2.ino, gui.h, logic.h and wac.h
The code loads the TouchScreen.h library
Because of the display I'm using, I #define mcufriend480 at the beginning of arduinomegachess2.ino
Now, if I load the code onto a regular Mega2560, and plug the display hat right into it, everything works. But if I load the code on the small Mega (in the Amazon link), and solder all the wires to the same pins, I get a display but touch doesn't work.
Digging into the code, I see this in gui.h:
#include "TouchScreen.h"
int XP = 6, YP = A1, XM = A2, YM = 7;
TouchScreen ts(XP, YP, XM, YM, 300);
TSPoint tp;
If I look in TouchScreen.h, I find:
class TouchScreen {
public:
/**
* @brief Construct a new Touch Screen object
*
* @param xp X+ pin. Must be an analog pin
* @param yp Y+ pin. Must be an analog pin
* @param xm X- pin. Can be a digital pin
* @param ym Y- pin. Can be a digital pin
* @param rx The resistance in ohms between X+ and X- to calibrate pressure
* sensing
*/
TouchScreen(uint8_t xp, uint8_t yp, uint8_t xm, uint8_t ym, uint16_t rx);
So, my first takeaway is that the 4 pins related to the touchscreen function are D7, D7, A1 and A2. My second takeaway is: If xp needs to be an analog pin, how does it work on the regular Mega when xp = D7 ???
So I thought maybe if I move xp to an analog pin on the Mini Mega, that's all it'll take. So I move the wire to A12, edit the code (the quoted section above is the only place in all the files that appears to designate pin 6 to something but maybe I missed something), and load it onto the Mini Mega, the backlight on the display loads up but nothing is displayed.
So now I'm really confused and running out of ideas. I'm on a time crunch to get this project finished in the next few weeks (bday gift). All the other parts are ready to go... all I need is to get this code working properly and then screw it together. So I'm hoping the collective hivemind genius on here can help me. Thanks!