From a9ff16988fb6f20c8cd08e8a858dd125c08e9df6 Mon Sep 17 00:00:00 2001 From: mattbk Date: Sat, 24 Feb 2024 22:40:19 -0600 Subject: [PATCH] Rough out hardware differences. --- platformio.ini | 16 ++++++++++++++++ src/main.cpp | 47 +++++++++++++++++++++++++++++++++++++---------- 2 files changed, 53 insertions(+), 10 deletions(-) diff --git a/platformio.ini b/platformio.ini index 9e0a284..787d646 100644 --- a/platformio.ini +++ b/platformio.ini @@ -8,7 +8,10 @@ ; Please visit documentation for the other options and examples ; https://docs.platformio.org/page/projectconf.html +[platformio] + [env:metro] +build_flags = -D ARDUINO1 platform = atmelavr board = metro framework = arduino @@ -17,3 +20,16 @@ lib_deps = paulstoffregen/Encoder@^1.4.4 adafruit/Adafruit GFX Library@^1.11.9 adafruit/Adafruit SSD1306@^2.5.9 + +[env:esp32doit-devkit-v1] +build_flags = -D ESP32DOIT +platform = espressif32 +board = esp32doit-devkit-v1 +framework = arduino +upload_speed = 921600 +monitor_speed = 115200 +lib_deps = + etherkit/Etherkit Si5351@^2.1.4 + adafruit/Adafruit GFX Library@^1.11.9 + adafruit/Adafruit SSD1306@^2.5.9 + igorantolic/Ai Esp32 Rotary Encoder@^1.6 diff --git a/src/main.cpp b/src/main.cpp index 4d4cc3f..6435d94 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -5,7 +5,7 @@ ***********************************************************************************************************/ //Libraries -#include //IDE Standard +#include //IDE Standard #include //Ben Buxton https://github.com/brianlow/Rotary #include //Etherkit https://github.com/etherkit/Si5351Arduino #include //Adafruit GFX https://github.com/adafruit/Adafruit-GFX-Library @@ -13,9 +13,26 @@ //User preferences //------------------------------------------------------------------------------------------------------------ +#ifdef ESP32DOIT //use the ESP32 DEVKIT DOIT environment +#pragma "ESP32DOIT" //show in console on build +#define board 1 //Define board #define IF 0 //Enter your IF frequency, ex: 455 = 455kHz, 10700 = 10.7MHz, 0 = to direct convert receiver or RF generator, + will add and - will subtract IF offfset. #define BAND_INIT 7 //Enter your initial Band (1-21) at startup, ex: 1 = Freq Generator, 2 = 800kHz (MW), 7 = 7.2MHz (40m), 11 = 14.1MHz (20m). -#define XT_CAL_F 33000 //Si5351 calibration factor, adjust to get exatcly 10MHz. Increasing this value will decreases the frequency and vice versa. +#define XT_CAL_F 33000 //Si5351 calibration factor, adjust to get exatcly 10MHz. Increasing this value will decreases the frequency and vice versa. +#define S_GAIN 303 //Adjust the sensitivity of Signal Meter A/D input: 101 = 500mv; 202 = 1v; 303 = 1.5v; 404 = 2v; 505 = 2.5v; 1010 = 5v (max). +#define tunestep 32 //The pin used by tune step push button. +#define band 33 //The pin used by band selector push button. +#define rx_tx 5 //The pin used by RX / TX selector switch, RX = switch open, TX = switch closed to GND. When in TX, the IF value is not considered. +#define adc 4 //The pin used by Signal Meter A/D input. +#define rotary1 34 //First pin for rotary encoder. +#define rotary2 35 //Second pin for rotary encoder. + +#else // use the ARDUINO1 environment +#pragma "ARDUINO1" //show in console on build +#define board 0 //Define board +#define IF 0 //Enter your IF frequency, ex: 455 = 455kHz, 10700 = 10.7MHz, 0 = to direct convert receiver or RF generator, + will add and - will subtract IF offfset. +#define BAND_INIT 7 //Enter your initial Band (1-21) at startup, ex: 1 = Freq Generator, 2 = 800kHz (MW), 7 = 7.2MHz (40m), 11 = 14.1MHz (20m). +#define XT_CAL_F 33000 //Si5351 calibration factor, adjust to get exatcly 10MHz. Increasing this value will decreases the frequency and vice versa. #define S_GAIN 303 //Adjust the sensitivity of Signal Meter A/D input: 101 = 500mv; 202 = 1v; 303 = 1.5v; 404 = 2v; 505 = 2.5v; 1010 = 5v (max). #define tunestep A0 //The pin used by tune step push button. #define band A1 //The pin used by band selector push button. @@ -23,6 +40,8 @@ #define adc A3 //The pin used by Signal Meter A/D input. #define rotary1 2 //First pin for rotary encoder. #define rotary2 3 //Second pin for rotary encoder. + +#endif //------------------------------------------------------------------------------------------------------------ Rotary r = Rotary(rotary1, rotary2); @@ -56,11 +75,15 @@ void set_frequency(short dir) { } } -ISR(PCINT2_vect) { - char result = r.process(); - if (result == DIR_CW) set_frequency(1); - else if (result == DIR_CCW) set_frequency(-1); -} +#ifdef ESP32DOIT //use the ESP32 DEVKIT DOIT environment + //TODO +#else + ISR(PCINT2_vect) { + char result = r.process(); + if (result == DIR_CW) set_frequency(1); + else if (result == DIR_CCW) set_frequency(-1); + } +#endif void tunegen() { si5351.set_freq((freq + (interfreq * 1000ULL)) * 100ULL, SI5351_CLK0); @@ -257,9 +280,13 @@ void setup() { si5351.output_enable(SI5351_CLK1, 0); si5351.output_enable(SI5351_CLK2, 0); - PCICR |= (1 << PCIE2); - PCMSK2 |= (1 << PCINT18) | (1 << PCINT19); - sei(); + #ifdef ESP32DOIT + //TODO + #else + PCICR |= (1 << PCIE2); + PCMSK2 |= (1 << PCINT18) | (1 << PCINT19); + sei(); + #endif count = BAND_INIT; bandpresets();