First time posting, so please be patient...
I want to use the TVout library to display some data captured through an electret mic, and do an fft later.
After some troubleshooting, I found an "unused" array causes TVout not to display anything.
I'm using the UNO and the working code is below (displays some pixels dancing on the screen).
If I uncomment the wtf line, nothing ever gets to the tv (not even what I send on setup()!!!).
Any ideas will be greatly appreciated, I'm stuck here. The wtf array would be used as imaginary part for the fft or fix_fft function later on.
#include <TVout.h>
#include <fontALL.h>
#include <fix_fft.h>
TVout TV;
const int SCR_HEI = 96;
const int SCR_WID = 120;
const int size = 128;
char data[size];
char oldData[size];
char wtf[size];
char oldHistogram[size];
const int AN_PIN = 0;
void setup() {
TV.begin(NTSC, SCR_WID, SCR_HEI);
TV.select_font(font6x8);
TV.println("luigi");
delay(3000);
for (int i=0; i< size;i++) {
oldHistogram[i] = 0;
oldData[i] = 0;
}
}
void loop() {
int i = 0;
int j,k = 0;
static long tt;
int val;
i = 0;
// ANALOG PIN READING + PLOTTING THE WAVE
while (i < size) {
if (micros() > tt + 100) {
val = analogRead(AN_PIN);
data[i] = val / 4 - 128;
if (i > 0 && i <= SCR_WID) {
int valorYs1 = map(data[i-1], -128, 128, 0, SCR_HEI);
int valorYs0 = map(data[i], -128, 128, 0, SCR_HEI);
// clears line from last loop, draws new line and stores data for next loop
TV.draw_line(i-1, oldData[i-1], i, oldData[i], 0);
TV.draw_line(i-1, valorYs1, i, valorYs0, 1);
oldData[i-1] = valorYs1;
}
// wtf[i] = 0;
i++;
tt = micros();
}
}
}