Hi Everybody!
I am building a HAM Transceiver-Shield for 23/13/9/6 cm wavelenghs for the Arduino Due. On the shield there ist a MAX2871 PLL_SYnthesizer-Chip, which i want to control over the second SPI, then there also is mixer i have to turn on/off, two SHF-switches to select the right bands and bandpass-filters, and a reflectometer with two A/D - conversters to meassure forwarded and reflected SHF-power. Furtermore i need a rotary-encoder with push-button and the touch-display to show and modify parameters in the menu.
So i am already using up quite a lot of analog and digital pins of the due. Thats also why i want to connect the touch-shield with dupond-cables and make it work, my shield will sit on top of the arduino, the display will be mounted to a metal-case...
I have looked into the GitHub - ImpulseAdventure/Waveshare_ILI9486: Arduino library for Waveshare ILI9486 supporting the Waveshare 3.5" & 4" TFT Touch Shields for Arduino. Includes GFX-compatible API and touchscreen driver resources and was able to compile the examples for the 4'' display and also the ws_graphictest, but only on create.arduino.cc.
On windows 10 and on my Raspberry, some examples didnt compile, i dont know why, but at least i can use create.arduino.cc...
Here is a short example (just a rudimentary test for the menu) with some graphics, which is working, using the ws_graphictest:
//*************************************************************************
// This is a Test, using The WaveShare 4'' Touch display!!!
// (c) 18.10.2019 Werner Pichl, OE7WPA
// Intended to make a useable Touchscrenn Interface for the MAX2871 PLL!
//***********+++++++++++++++++++*****************************************/
//#define TEST_FONTS // Comment out to disable custom fonts
#define USE_FONTS
#include "SPI.h"
#include "Wire.h"
#include "SimpleRotary.h"
#include "Waveshare_ILI9486_GFX.h"
// Waveshare shield has fixed pin mapping (defined by DEV_config.h)
Waveshare_ILI9486_GFX tft = Waveshare_ILI9486_GFX();
uint8_t rotation = 3;
boolean DebuggingMode=1;// If set to 1, Debugging Information to Serial Monitor will be available (115600 Baud), but System will slow down a little bit!
//////////////////////////////////////////////////////////////////
//VERSION INFO TO BE DISPLAYED///////////////////////////////////
char SoftwareVersion0[]="------------------------------------------";
char SoftwareVersion1[]="Waveshare 4'' MenuTest";
char SoftwareVersion2[]="for MAX 2871 Synthesizer Test";
char SoftwareVersion3[]="Software Version 0.90";
char SoftwareVersion4[]="(C) 18.10.2019 OE7WPA, Werner Pichl";
char SoftwareVersion5[]="------------------------------------------";
//////////////////////////////////////////////////////////////////
// STATE OF THE ROTARY ENCODER////////////////////////////////////////////////////////////////////////////////////
// Pin A, Pin B, Button Pin
SimpleRotary rotary(A1,A2,A3);
unsigned int RE_Counter = 0;
unsigned int RE_eval = 0x0 ; // 0 = LEFT(-), 1=RIGHT(+), 2=PRESSED
boolean ReverseEncoderRotation = 0; // Change to 1 if your RotaryEncoder ist rotating in the wrong Direction or try to exchange CLK and DT (As this is no real digital, but only an analog device) !!!!
byte Rotation; //Rotation of the Rotary Encoder (0=No Action, 1=CW, 2=CCW)
unsigned int TimeButtonPressedShort = 20; //Time in Milliseconds for Button pressed short
unsigned long TimeButtonPressedLong = 1000; //Time in Milliseconds for Button pressed long
unsigned long DebounceTimerButtonPressedLong = 900; //Debounce Time for Button Pressed Long
unsigned long TimeButtonPressedVeryLong = 3999; //Time in Milliseconds for Button pressed very long
unsigned long PushTimeMilliSeconds; //Time in Milliseconds of Time the Button was pushed
boolean PressedLong = false ; //True if Button is pressed long
boolean PressedVeryLong = false ; //True if Button is pressed very long
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setup() {
tft.begin();
if (DebuggingMode) Serial.begin(9600);
if (DebuggingMode) Serial.println("ILI9486 Menu Test!");
}
void loop(void) {
ShowInfoScreen();
delay(5000);
tft.fillScreen(ILI9486_BLACK);
int RX=124150000;
int TX=124000000;
ShowRX(0, 0, RX);
ShowTX(0, 50, TX, 1);
ShowShift(0,100,RX,TX);
delay(10000);
//}
}
int ShowInfoScreen() {
tft.setRotation(rotation);
tft.fillScreen(ILI9486_BLACK);
tft.setCursor(0, 0);
tft.setTextColor(ILI9486_YELLOW);
tft.setTextSize(2);
#if defined(USE_FONTS)
tft.setFont(&Font16); // 11x16 vs GFX(2): 6*2x8*2=12x16
#endif
tft.println(SoftwareVersion0);
tft.println(SoftwareVersion1);
tft.println(SoftwareVersion2);
tft.println(SoftwareVersion3);
tft.println(SoftwareVersion4);
tft.println(SoftwareVersion5);
}
int ShowTX(int x, int y, int TX_FREQUENCY, bool TX_ACTIVE) {
if (! TX_ACTIVE) {
tft.fillRect(x, y, 300, 50, ILI9486_BLUE);
tft.setCursor(x+5, y+15);
tft.setTextColor(ILI9486_YELLOW);
tft.setTextSize(3);
#if defined(USE_FONTS)
tft.setFont(&Font24); // 11x16 vs GFX(2): 6*2x8*2=12x16
#endif
}
if (TX_ACTIVE) {
tft.fillRect(x, y, 300, 50, ILI9486_RED);
tft.setCursor(x+5, y+15);
tft.setTextColor(ILI9486_YELLOW);
tft.setTextSize(3);
#if defined(USE_FONTS)
tft.setFont(&Font24); // 11x16 vs GFX(2): 6*2x8*2=12x16
#endif
}
tft.print("TX: ");
tft.print(TX_FREQUENCY);
tft.println(" KHz");
}
int ShowRX(int x, int y, int RX_FREQUENCY) {
tft.fillRect(x, y, 300, 50, ILI9486_GREEN);
tft.setCursor(x+5, y+15);
tft.setTextColor(ILI9486_BLACK);
tft.setTextSize(3);
#if defined(USE_FONTS)
tft.setFont(&Font24); // 11x16 vs GFX(2): 6*2x8*2=12x16
#endif
tft.print("RX: ");
tft.print(RX_FREQUENCY);
tft.println(" KHz");
}
int ShowShift(int x, int y, int RX_FREQUENCY, int TX_FREQUENCY) {
tft.fillRect(x, y, 320, 50, ILI9486_BLUE);
tft.setCursor(x+5, y+15);
tft.setTextColor(ILI9486_BLACK);
tft.setTextSize(3);
#if defined(USE_FONTS)
tft.setFont(&Font24); // 11x16 vs GFX(2): 6*2x8*2=12x16
#endif
tft.print("SHIFT: ");
tft.print(RX_FREQUENCY - TX_FREQUENCY);
tft.println(" KHz");
}
int ShowMenu() {
tft.setRotation(rotation);
tft.fillScreen(ILI9486_BLACK);
tft.fillRect(0, 0, 100, 50, ILI9486_BLUE);
tft.setCursor(0, 0);
tft.setTextColor(ILI9486_WHITE);
tft.setTextSize(1);
#if defined(USE_FONTS)
tft.setFont(&Font8); // 5x8 vs GFX(1): 6*1x8*1=6x8
#endif
tft.println(SoftwareVersion0);
tft.println(SoftwareVersion1);
tft.println(SoftwareVersion2);
tft.println(SoftwareVersion3);
tft.println(SoftwareVersion4);
tft.println(SoftwareVersion5);
tft.setCursor(0, 100);
tft.setTextColor(ILI9486_YELLOW);
tft.setTextSize(2);
#if defined(USE_FONTS)
tft.setFont(&Font16); // 11x16 vs GFX(2): 6*2x8*2=12x16
#endif
tft.println(SoftwareVersion0);
tft.println(SoftwareVersion1);
tft.println(SoftwareVersion2);
tft.println(SoftwareVersion3);
tft.println(SoftwareVersion4);
tft.println(SoftwareVersion5);
tft.fillRect(100, 100, 50, 50, ILI9486_YELLOW);
}
At this moment i am not sure, if the Display uses software or hardware SPI, the shield connects to the due hardware 3x2 SPI header...
In the next step i will investigate, which pins on the due i have to use, at the moment i am using more than i would like to, because i will need every pin available for my transceiver-shield...
With best regards
Werner, OE7WPA