Arduino question?
Bruce Labitt
bruce.labitt at myfairpoint.net
Fri May 3 16:56:25 EDT 2019
Can I ask an Arduino/C/C++ question here? If not, where is a decent
place to ask? Full code is just under 50KB (unzipped).
It's a "Variable was not declared in this scope" problem. Basically, I'm
in over my head at the moment. I'm not a good structured programmer -
so let's get that out of the way. I'm a hack, in the worst sense...
Everything was working... when I had a huge file. I then decided, wow,
this is a mess, lets break this up a bit into modules, so that it is
more supportable and debug-able (for myself). If anyone is remotely
interested, it is a homebrew radar based chronograph. I've got most of
the pieces working (or at least it worked before I recently busted
things). The 100KHz sampling using DMA, the ping pong floating point 1K
FFT's running in 'real' time, and some display stuff. Separately, I
have a live update of a tft screen (320x240) running with the FFT
output. I'm running on an ARM M4F processor, but using the Arduino
IDE. The Arduino way of doing things is a little confusing to me, to be
honest. It hides a lot of things.
Ok, here is the error.
/home/bruce/Arduino/adcdmafftM4bruce/adcdmafft/adcdmafftm4/moreutils.ino:
In function 'void doMedian(float*, float*, int)':
moreutils:14:3: error: 'RunningMedian' was not declared in this scope
RunningMedian samples = RunningMedian(medianlength);
^
moreutils:14:17: error: expected ';' before 'samples'
RunningMedian samples = RunningMedian(medianlength);
^
moreutils:16:5: error: 'samples' was not declared in this scope
samples.add(abuf[i]);
^
exit status 1
'RunningMedian' was not declared in this scope
The code in moreutils.ino is:
// additional processing
#include "moreutils.h"
void doMedian( float abuf[], float runmed[], int medianlength) { //
needs work!
RunningMedian samples = RunningMedian(medianlength);
for (int i=0; i< FFT_SIZE/2; i++) {
samples.add(abuf[i]);
if (i>medianlength-1) {
runmed[i-medianlength] = samples.getMedian();
// don't put value until the circ buffer is filled
}
}
for (int i= (FFT_SIZE/2 -medianlength-7); i< (FFT_SIZE/2); i++) {
runmed[i] = runmed[FFT_SIZE/4]; // hack for now
// at tail end of median there are some bizarre numbers. root
cause has not been
// determined, so we just fill the last samples from 'something close'
}
}
Inside of moreutils.h, is #include RunningMedian.h with an
#ifndef/#define/#include statement, to prevent multiple includes of the
same file (RunningMedian.h).
I'm really kind of confused as to where I need to do the declaration.
In
https://github.com/RobTillaart/Arduino/blob/master/libraries/RunningMedian/examples/RunningMedian/RunningMedian.ino
the declaration is simply done prior to setup. Snippet below
#include <RunningMedian.h>
RunningMedian samples = RunningMedian(5);
RunningMedian samples2 = RunningMedian(9);
void setup() {
...
}
void loop() {
use samples here...
}
I'm sure this is trivial for most of you - but I'm both perplexed and
stuck. If one of you kind souls could help me, I'd greatly appreciate
it. I'd even travel to see someone if that would work out better.
TIA, Bruce
More information about the gnhlug-discuss
mailing list