Hello Everyone, I am really scratching my head with this issue, im doing a project with an esp32 wroom and a tft ili9486 320x480.
The lcd and the mcu seem to be working fine with the examples of the Bodmer library, however when i try to do a simple test for a vfo the code does not do whats expected of it.
This first code just iterates a number and prints it on the screen, basic stuff and works fine
#include <SPI.h>
#include <TFT_eSPI.h>
TFT_eSPI tft = TFT_eSPI();
int oldnum;
int num;
void setup() {
tft.init();
tft.setRotation(1);
tft.invertDisplay(0);
tft.fillScreen(TFT_BLACK);
tft.setTextSize(1);
tft.setTextColor(TFT_WHITE);
tft.setCursor(0, 0);
}
void loop() {
num++;
tft.setTextSize(4);
tft.setTextColor(TFT_BLACK);
tft.setCursor(40, 5);
tft.println(oldnum);
tft.setTextColor(TFT_WHITE);
tft.setCursor(40, 5);
tft.println(num);
oldnum = num;
delay(15);
}
however i have been strugling to make this one work:
long int frec = 7000000;
int offset = 10700000;
int oldFrec;
bool change = 1;
int stepS = 100;
#include <si5351.h>
#include <Wire.h>
Si5351 si5351;
#define clk1 33
#define clk2 32
#include <SPI.h>
#include <TFT_eSPI.h>
TFT_eSPI tft = TFT_eSPI();
void setup() {
si5351.set_freq((frec) * SI5351_FREQ_MULT, SI5351_CLK1);
pinMode(23, INPUT_PULLUP);
pinMode(32, INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt(clk2), clock1_ISR, FALLING);
attachInterrupt(digitalPinToInterrupt(clk1), clock1_ISR2, FALLING);
si5351.init(SI5351_CRYSTAL_LOAD_6PF, 0, 0);
si5351.drive_strength(SI5351_CLK1, SI5351_DRIVE_6MA);
si5351.drive_strength(SI5351_CLK0, SI5351_DRIVE_6MA);
si5351.set_freq((10700000) * SI5351_FREQ_MULT, SI5351_CLK0);
tft.init();
tft.setRotation(1);
tft.invertDisplay(0);
tft.fillScreen(TFT_BLACK);
tft.setTextSize(1);
tft.setTextColor(TFT_WHITE);
tft.setCursor(0, 0);
}
void loop() {
if (change) {
updateFreq();
}
}
void clock1_ISR() {
bool dir = digitalRead(clk1);
if (dir == true) {
frec += stepS;
}
if (dir == false) {
frec -= stepS;
}
change = true;
}
void clock1_ISR2() {
bool dir = digitalRead(clk2);
if (dir == true) {
frec -= stepS;
}
if (dir == false) {
frec += stepS;
}
change = true;
}
void updateFreq() {
tft.fillScreen(TFT_BLACK);
tft.setTextSize(4);
tft.setTextColor(TFT_GREEN);
tft.setCursor(40, 5);
tft.println(frec);
oldFrec = frec;
change = false;
si5351.set_freq((frec + offset) * SI5351_FREQ_MULT, SI5351_CLK1);
}
Something weird happens if i initialize the tft before initializing the si5351 on the setup portion(just tested another variant, just declaring a pin input also breaks the lcd functionality), if i do that, the screen just blanks out and does not work.
Here the screen just displays 7000000, which is the starting frequency, when i modify it with the encoder the variable gets changed, i can see that because the frequency changes and then "nothing" else happens, im really confused with this behavior.
I saying "nothing" because i see that the last "0" does something strange the a pixel in the display changes, not sure whats really happening.
Has anyone experienced something similar that can point out what im doing wrong?
