Hi all,
I'm build a Spectrum analyser based on the UNO chip and Sparkfun Spectrum shield, the prototype is working fine with a small OLED I2C display, but I I want to use on my final board one of this 1.8" 128x160 SPI TFT display based on ST7735 chipset. I have tested with both the Arduino TFT libs and with Adafruit, the latter seems to work better in this case. I draw bars to visualise the 14 levels (7 Left + 7 right.) My problem is that the redraw of the bars is very sketchy, I'm positive is not resource issues on ATMEGA, is plenty and it works fine with my OLED version. Do you think I'm expecting too much from this display, in the ST7735 Datasheet I don't see major issues.
Thanks,
Ermanno
I attached the code here:
/******************************************************************************
SparkFun Spectrum Shield Demo
Bands: 63Hz / 160Hz / 400Hz / 1kHz / 2.5kHz / 6.25kHz / 16kHZ
*********************************************************************************/
// Libraries required
//#include <Arduino.h>
#include <Adafruit_GFX.h> // Core graphics library
#include <Adafruit_ST7735.h> // Hardware-specific library for ST7735
#include <SPI.h>
// TFT 1.8" Display 128x160 pins and type
#define TFT_CS 10
#define TFT_RST 9 // Or set to -1 and connect to Arduino RESET pin
#define TFT_DC 8
// PIN 11 (MOSI) and 13(SCK) are used for SPI
Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_RST);
//Declare Spectrum Shield pin connections
#define STROBE 4
#define RESET 5
#define DC_One A0 // Left Channel
#define DC_Two A1 // Right Channel
//Define variables
int freq_amp, i, left, right;
int Frequencies_One[7];
int Frequencies_Two[7];
#define ARRAYSIZE 8
int left_pos[ARRAYSIZE] = { 121 , 113 , 105 , 97 , 89 , 81 , 73 }; // portrait
int right_pos[ARRAYSIZE] = { 48 , 40 , 32 , 24 , 16 , 8 , 0}; // portrait
void setup() {
// TFT initializer for 1.8" TFT screen:
tft.initR(INITR_BLACKTAB); // Init ST7735S chip
//Set spectrum Shield pin configurations
pinMode(STROBE, OUTPUT);
pinMode(RESET, OUTPUT);
pinMode(DC_One, INPUT);
pinMode(DC_Two, INPUT);
//Initialize Spectrum Analyzers
digitalWrite(STROBE, LOW);
digitalWrite(RESET, LOW);
delay(5);
//Serial.begin(115200);
//delay(1000);
tft.fillScreen(ST77XX_BLACK);
}
void loop() {
digitalWrite(RESET, HIGH);
delayMicroseconds(200);
digitalWrite(RESET, LOW);
delayMicroseconds(200);
//Read frequencies for each band
for (freq_amp = 0; freq_amp < 7; freq_amp++)
{
digitalWrite(STROBE, HIGH);
delayMicroseconds(50);
digitalWrite(STROBE, LOW);
delayMicroseconds(50);
Frequencies_Two[freq_amp] = analogRead(DC_Two); //Right Channel
right = map(Frequencies_One[freq_amp], 60, 1023, 0, 159);
Frequencies_One[freq_amp] = analogRead(DC_One); //Left Channel
left = map(Frequencies_One[freq_amp], 60, 1023, 0, 159);
tft.fillRect(right_pos[freq_amp], 0, 7, right, ST77XX_GREEN);
tft.fillRect(left_pos[freq_amp], 0, 7, left, ST77XX_GREEN);
}
delayMicroseconds(400);
tft.fillScreen(ST77XX_BLACK);
}