I have this exact TFT: 4inch TFT Touch Shield - Waveshare Wiki
It provides an example for the Arduino Uno (see ‘Demo code’ on the linked page).
That example works as expected with my Uno - plug it in, upload the sketch, and everything is great.
What I’d like to do now is get this working with a ‘plain’ AVR, not a full Arduino. To accomplish that, I wired up an atmega1284p dip to one of these on a breadboard… and then kind of drew a blank on how to approach the software side of the problem.
The problem here is that I’m not clear on how or how completely I should translate the Arduino firmware to my AVR. There are several dependencies used by this module, like SPI, Wire, and probably some others that are part of the Arduino build chain. So if I want to run the code on a non-Arduino, I’d need to do one of these:
- make my non-Arduino into an Arduino (to clarify - I want to keep the chip the same, but somehow put Arduino firmware on it),
- modify my code to use these parts of the Arduino firmware,
- or replace these dependencies with atmega1284p compatible functional equivalents.
As a straightforward way of getting to the meat of my problem, I copied the touch demo code, changed the .ino file to main.cpp, and tried compiling with avr-gcc. Obviously without my compiler knowing the path to any Arduino dependencies, this caused everything to blow up. But this is the starting point for this problem I imagine, I’m just not sure which of those three options I listed above is the most sane.
Could anyone provide guidance on which option to pick and then maybe some starting advice for going down the correct path?
Thanks!