The compiler is basically telling you the library is not imported or has
yet to be imported for whatever reason.

The Arduinoy parts of the compilation process do some weird things behind
the scenes to reorder the code before compiling so that it actually makes
sense. Done with extra .ino files not named the same as the project and
functions after the main loop in said project_name.ino file. Its possible
for an Arduino developer/tinkerer to declare a function after the two
primary loops that use those exact functions before actual deceleration
because of this behavior. Which breaks some expectations of hardened
engineers I think. All in the interest of catering to new people that would
probably be frustrated by a strict order of operation. If this behaviour
rearranges library functions before the "#include <mylibrary.h>", that
might give an unexpected result, but that doesn't seem to be what's going
on here. Under the hood strict order of operations still exist. Arduino
does ultimately use the gcc compiler, though maybe its configured for that
switcharoo magic, I didn't write the code, I've just fallen into the traps.

Extra .ino files in the same folder will be arranged before your main .ino
file, but it could be right before setup. Not sure, its been a while since
I've been regularly working with the Arduino, I could be wrong. The .h file
should be a bit more obvious as to where its included. Bit more explicit

Do you have a github link to your current project state Bruce?

I'm looking back at an older project of mine, it looks like I was doing
something similar in this one
https://github.com/PaulBeaudet/SimpleBotSocketIo/blob/master/SimpleBotSocketIo.ino
I declared a timer library in a .h file then declared and instance of it in
the .ino fille. We demoed that bot at the mini makerfaire in dover, I'm
assuming it compiled and that should be something that's doable

I think you may want to inspect your #ifndef statement a bit more closely
to be sure the RunningMedian data type (library import) is actually being
instantiated after that pre-compilation logic runs its course. Why do you
need to prevent multiple instances from being called? #import should only
call one instance, right? Also, spelling, that's normally my issue.. haha

If you are still having trouble after spending more time with it, feel free
to stop by the Manchester Makerspace Monday during open house (6pm-8pm).
I'll likely be in giving tours, I can take a look with you when tours
simmer down.

Cheers,
Paul Beaudet

On Fri, May 3, 2019 at 4:57 PM Bruce Labitt <bruce.lab...@myfairpoint.net>
wrote:

> 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
>
> _______________________________________________
> gnhlug-discuss mailing list
> gnhlug-discuss@mail.gnhlug.org
> http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss/
>
_______________________________________________
gnhlug-discuss mailing list
gnhlug-discuss@mail.gnhlug.org
http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss/

Reply via email to