/* From N6QW using the 160X 128 TFT Color display with the Si5351 Clock Generator. The sketch includes selectable USB/LSB, a Tune function with 988 Hz tone and the Fout is 1X the LO (operating frequency + offset). Modified 11/2018 for the Atlas RX110 and Tx11. This will switch 5 bands and the IF is 5.950 MHz. This sketch has four included files including Rotary.h, Rotary.cpp. si5351.h and si5351.cpp you can find these files on the n6qw website. Also use Arduino 1.8.5 11/2018 TFT pinout information The VCC Pin is not used LED = 3.3 Volts DC SCK = Pin D13 SDA = Pin D11 AO = Pin D9 Reset = Pin D8 CS = Pin D10 GND = Ground Vcc = Not Used Removed: Pulse Input = Pin D6 Removed: Pulse Output = Pin D7 SW = Pin D5 Selects Upper and Lower Sideband Encoder Button = Pin A3 Encoder A = Pin D2 Encoder B = Pin D3 A0 = 80M BSW A1 = 40M BSW A2 = 20M BSW D6 = 15M DSW D7 = 10 BSW */ #include #include #include // Hardware-specific library #include "Rotary.h" #if defined(__SAM3X8E__) #undef __FlashStringHelper::F(string_literal) #define F(string_literal) string_literal #endif #define __CS 10 #define __DC 9 #define __RST 8 #define ENCODER_B 2 // Encoder pin A #define ENCODER_A 3 // Encoder pin B #define ENCODER_BTN A3 // Color definitions #define BLACK 0x0000 #define BLUE 0x001F #define RED 0xF800 #define GREEN 0x07E0 #define CYAN 0x07FF #define MAGENTA 0xF81F #define YELLOW 0xFFE0 #define WHITE 0xFFFF Adafruit_ST7735 display = Adafruit_ST7735(__CS, __DC, __RST); #include "si5351.h" #include "Wire.h" Si5351 si5351; long int frq; int SWBANDS = 0; int_fast32_t rx = 5595000L; // Starting frequency of VFO operating frequency plus offset which is selectable int_fast32_t rx2=1; // variable to hold the updated frequency int_fast32_t increment = 100; // starting VFO update increment in HZ. int_fast32_t bfo = 5595000L; // default offset sideband inversion thus LSB String hertz = " 100"; byte ones,tens,hundreds,thousands,tenthousands,hundredthousands,millions ; //Placeholders int buttonstate = 0; int buttonstate2 = 0; int BSW = 0; const int LED = 5; //Selects Upper or Lower Sideband // STUFF ADDED HERE const int MAXBANDS = 5; // the number of bands we are using const int SWBAND[MAXBANDS]={A0,A1,A2,6,7}; // 80m on A0,40m on A1,20m on A2,15m on D6,10m on D7 const int_fast32_t rxfreqs[MAXBANDS]={9395000L,12795000L,19798000L,26898000L,33948000}; // the default starting frequency for each band int lastband=0; // used to keep track of the last band used // const int TX = 4; //On the Air int backlight =0; int buttonState = 0; int lastButtonState = 0; Rotary r = Rotary(3,2); // sets the pins the rotary encoder uses. Must be interrupt pins. int RunOnce = 1; void setup() { int lp; int pin; Serial.begin(9600); PCICR |= (1 << PCIE2); PCMSK2 |= (1 << PCINT18) | (1 << PCINT19); sei(); //display.begin(); display.initR(INITR_BLACKTAB); display.setRotation(1); // landsacape versus portrait // display.fillScreen(BLACK); pinMode(LED, INPUT); // Selects either USB or LSB````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````[ digitalWrite(LED,HIGH); /* Old pulse code for triggering the band switch pinMode(PULSE, INPUT); digitalWrite(PULSE, HIGH); pinMode(PO, OUTPUT); digitalWrite (PO, LOW); */ for (lp=0;lp 9){display.setCursor(12,10);} else{ display.fillRect(110,0,160,31,BLACK);display .setCursor(12,10);} //eliminate overwrite for < 10 mhz display.setTextSize(3); display.setTextColor(WHITE, BLACK); display.print(millions); //display.print("."); display.print(hundredthousands); display.print(tenthousands); display.print(thousands); display.setTextColor(RED,BLACK); display.setTextSize(3); //display.print("."); display.print(hundreds); display.print(tens); display.print(ones); } ISR(PCINT2_vect) { unsigned char result = r.process(); if (result) { if (result == DIR_CW){rx=rx+(1*increment);} // account that rx = 1 times the frequency else {rx = rx-(1*increment);}; if (rx >=39500000){rx=rx2;}; // UPPER VFO LIMIT = 1X the opearting frequency + offset 160 10 10 Meters if (rx <=200500){rx=rx2;}; // LOWER VFO LIMIT = 1 X the opearting frequency + Offset } } void loop() { //tft.setRotation(1); // landsacape versus portrait CheckBand(); // CheckTX(); CheckSB(); CheckDisplay(); SplashScreen(); RunOnce = 0; display.setCursor(140,35); display.setTextColor(YELLOW); display.setTextSize(1); display.print("Hz"); display.setCursor(104, 46); display.setTextColor(GREEN); display.setTextSize(2); display.print("N6QW"); //*********************************************************************************************** if (rx != rx2){ showFreq(); si5351.set_freq(rx , SI5351_PLL_FIXED, SI5351_CLK0); Serial.println(rx); //si5351.set_freq(bfo , SI5351_PLL_FIXED, SI5351_CLK2); rx2 = rx; display.setCursor(110,35); display.setTextColor(YELLOW); display.setTextSize(1); display.print(hertz); } buttonstate = digitalRead(A3); if(buttonstate == LOW) { setincrement(); //display.drawRect(110, 28, 140,10, BLACK); // This blanks the step rate so no overwriting 80 begin pt, 26 = y axis down start, 111 = end, 10 = thickness display.fillRect(110, 35, 140, 10, BLACK); display.setCursor(110,35); display.setTextColor(BLACK); // blanks out the old setting display.setTextSize(1); display.print(hertz); delay(10); display.setCursor(110,35); display.setTextColor(YELLOW); display.setTextSize(1); display.print(hertz); showFreq(); }; delay(25); /* removed to make way for CheckBand to use digital 6 and 7 buttonState = digitalRead(6); // Pulse input / output connected to the pole on the bandswitch Pin 7 . Put the BSW on the band and hit the momentary PB and the pulse is generated if(buttonState == LOW) { digitalWrite(7, HIGH); delay(50); digitalWrite(7, LOW);} */ }; //************************************************************************************ Bandswitch Check /* CheckBand notes: ** if you wanted to store the last frequency used on this band (instead of the default starting frequency), you could do that easily here too ** just do rxfreqs[lastband]=rx; prior to the lastband=lp; statement. oh.. and delete the const in the rxfreqs declaration up at the top ** of course that will get lost at power off, unless you write it to the arduino's eeprom, but might be nice. */ void CheckBand() { unsigned char lp; // temporary variable we will use to step through each of the bandswitch pins int bandpin; // and temporary variable to store the reading from the current bandpin for (lp=0;lp