<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <div class="moz-cite-prefix">Hi Paul,</div>
    <div class="moz-cite-prefix"><br>
    </div>
    <div class="moz-cite-prefix">Based on both your suggestion and a few
      of Bill Freeman's, I found the problem.  It basically was a
      problem with the scope of the #ifndef statement.  The problem was
      that if moreutils was compiled prior to RunningMedian, then
      RunningMedian_h was defined.  Due to an error in placement of the
      #endif statement in RunningMedian.h, the whole body of the header
      file was not read in.  I changed the location of the #endif
      statement in RunningMedian.h so that the body of the header would
      be read.  Problem solved.</div>
    <div class="moz-cite-prefix"><br>
    </div>
    <div class="moz-cite-prefix">So, it was simple... once it was
      pointed out.  Thanks to you both.</div>
    <div class="moz-cite-prefix"><br>
    </div>
    <div class="moz-cite-prefix">I'll still be coming up to the
      MakerSpace on Monday.  I'd like to check out the setup.  There is
      one in Nashua, just wondering how the Manchester one compares.</div>
    <div class="moz-cite-prefix"><br>
    </div>
    <div class="moz-cite-prefix">Regards,</div>
    <div class="moz-cite-prefix">Bruce</div>
    <div class="moz-cite-prefix"><br>
    </div>
    <div class="moz-cite-prefix">On 5/3/19 7:34 PM, Bruce Labitt wrote:<br>
    </div>
    <blockquote type="cite"
      cite="mid:5bd90ee7-ac89-df86-5349-5375e2387b40@myfairpoint.net">
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
      <div class="moz-cite-prefix">Hi Paul,</div>
      <div class="moz-cite-prefix"><br>
      </div>
      <div class="moz-cite-prefix">It seems this is a variant of header
        hell that I am stewing in...  At the moment the project is not
        up on github, as I was under some sort of delusion that this
        might eventually have some commercial value.  I'm not so sure
        about that, but I have put a lot of effort into it so far...</div>
      <div class="moz-cite-prefix"><br>
      </div>
      <div class="moz-cite-prefix">Arduino, does indeed do some funky
        stuff.  If I could figure it out, I'd probably just write my own
        scripts to have things compile in the order I want.  A makefile
        isn't hard.  I just don't know all the crazy locations where
        Arduino stuff is stashed.  Suppose I could poke about.<br>
      </div>
      <div class="moz-cite-prefix"><br>
      </div>
      <div class="moz-cite-prefix">Thanks for the tip on going through
        the #ifndef's.  It's got to be in that neighborhood.  I put in
        the #ifndef stuff to prevent multiple inclusions, which Arduino
        1.8.9 IDE does not seem to like, the compiler squawked at me
        when I tried to do that.  What is puzzling me is that even if I
        put the include #include "RunningMedian.h" in the file, I get
        "nearly" the same error, if I comment out the include.<br>
      </div>
      <div class="moz-cite-prefix"><br>
      </div>
      <div class="moz-cite-prefix">WITH include:</div>
      <div class="moz-cite-prefix">#include "moreutils.h"</div>
      <div class="moz-cite-prefix"><b>#include "RunningMedian.h"</b><br>
      </div>
      <div class="moz-cite-prefix"><tt>home/bruce/Arduino/adcdmafftM4bruce/adcdmafft/adcdmafftm4/moreutils.ino:
          In function 'void doMedian(float*, float*, int)':</tt><tt><br>
        </tt><tt>moreutils:14:3: error: 'RunningMedian' was not declared
          in this scope</tt><tt><br>
        </tt><tt>   RunningMedian samples = RunningMedian(medianlength);</tt><tt><br>
        </tt><tt>   ^</tt><tt><br>
        </tt><tt>moreutils:14:17: error: expected ';' before 'samples'</tt><tt><br>
        </tt><tt>   RunningMedian samples = RunningMedian(medianlength);</tt><tt><br>
        </tt><tt>                 ^</tt><tt><br>
        </tt><tt>moreutils:16:5: error: 'samples' was not declared in
          this scope</tt><tt><br>
        </tt><tt>     samples.add(abuf[i]);</tt><tt><br>
        </tt><tt>     ^</tt><tt><br>
        </tt><tt>exit status 1</tt><tt><br>
        </tt><tt>'RunningMedian' was not declared in this scope</tt></div>
      <div class="moz-cite-prefix"><br>
      </div>
      <div class="moz-cite-prefix">WITHOUT include:</div>
      <div class="moz-cite-prefix">#include "moreutils.h"<br>
      </div>
      <div class="moz-cite-prefix"><tt>/home/bruce/Arduino/adcdmafftM4bruce/adcdmafft/adcdmafftm4/moreutils.ino:
          In function 'void doMedian(float*, float*, int)':</tt><tt><br>
        </tt><tt>moreutils:14:3: error: 'RunningMedian' was not declared
          in this scope</tt><tt><br>
        </tt><tt>   RunningMedian samples = RunningMedian(medianlength);</tt><tt><br>
        </tt><tt>   ^</tt><tt><br>
        </tt><tt>moreutils:14:17: error: expected ';' before 'samples'</tt><tt><br>
        </tt><tt>   RunningMedian samples = RunningMedian(medianlength);</tt><tt><br>
        </tt><tt>                 ^</tt><tt><br>
        </tt><tt>moreutils:16:5: error: 'samples' was not declared in
          this scope</tt><tt><br>
        </tt><tt>     samples.add(abuf[i]);</tt><tt><br>
        </tt><tt>     ^</tt><tt><br>
        </tt><tt>exit status 1</tt><tt><br>
        </tt><tt>'RunningMedian' was not declared in this scope</tt><br>
      </div>
      <div class="moz-cite-prefix"><br>
      </div>
      <div class="moz-cite-prefix">In both cases, the top of the file
        states #include moreutils.h.  And inside of moreutils.h there
        is:<br>
      </div>
      <div class="moz-cite-prefix">#ifndef RunningMedian_h</div>
      <div class="moz-cite-prefix">#define RunningMedian_h</div>
      <div class="moz-cite-prefix">#include "RunningMedian.h"</div>
      <div class="moz-cite-prefix">...</div>
      <div class="moz-cite-prefix">#endif</div>
      <div class="moz-cite-prefix"><br>
      </div>
      <div class="moz-cite-prefix">It's got to be simple, it's got to be
        simple,...  Wish I could see it what it was...<br>
      </div>
      <div class="moz-cite-prefix"><br>
      </div>
      <div class="moz-cite-prefix">I think, I'll come up on Monday.  I
        haven't been to the Manchester Maker Space before.</div>
      <div class="moz-cite-prefix"><br>
      </div>
      <div class="moz-cite-prefix">-Bruce<br>
      </div>
      <div class="moz-cite-prefix"><br>
      </div>
      <div class="moz-cite-prefix">On 5/3/19 6:50 PM, Paul Beaudet
        wrote:<br>
      </div>
      <blockquote type="cite"
cite="mid:CAH4HwSzKRfzvXDRzOgVZ16tkYR7Nucu6=pj1V+8QDv_x6qm8+Q@mail.gmail.com">
        <meta http-equiv="content-type" content="text/html;
          charset=UTF-8">
        <div dir="ltr">
          <div dir="ltr">
            <div>The compiler is basically telling you the library is
              not imported or has yet to be imported for whatever
              reason.<br>
            </div>
            <div><br>
            </div>
            <div>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 &lt;mylibrary.h&gt;", 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.</div>
            <div><br>
            </div>
            <div>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<br>
            </div>
            <div><br>
            </div>
            <div>Do you have a github link to your current project state
              Bruce? <br>
            </div>
            <div><br>
            </div>
            <div>I'm looking back at an older project of mine, it looks
              like I was doing something similar in this one <a
href="https://github.com/PaulBeaudet/SimpleBotSocketIo/blob/master/SimpleBotSocketIo.ino"
                moz-do-not-send="true">https://github.com/PaulBeaudet/SimpleBotSocketIo/blob/master/SimpleBotSocketIo.ino</a> 
              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</div>
            <div><br>
            </div>
            <div>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</div>
            <div><br>
            </div>
            <div>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.<br>
            </div>
            <div><br>
            </div>
            <div>Cheers,</div>
            <div>Paul Beaudet<br>
            </div>
          </div>
        </div>
        <br>
        <div class="gmail_quote">
          <div dir="ltr" class="gmail_attr">On Fri, May 3, 2019 at 4:57
            PM Bruce Labitt &lt;<a
              href="mailto:bruce.labitt@myfairpoint.net"
              moz-do-not-send="true">bruce.labitt@myfairpoint.net</a>&gt;
            wrote:<br>
          </div>
          <blockquote class="gmail_quote" style="margin:0px 0px 0px
            0.8ex;border-left:1px solid
            rgb(204,204,204);padding-left:1ex">Can I ask an
            Arduino/C/C++ question here?  If not, where is a decent <br>
            place to ask?  Full code is just under 50KB (unzipped).<br>
            <br>
            It's a "Variable was not declared in this scope" problem.
            Basically, I'm <br>
            in over my head at the moment.  I'm not a good structured
            programmer - <br>
            so let's get that out of the way.  I'm a hack, in the worst
            sense...<br>
            <br>
            Everything was working... when I had a huge file.  I then
            decided, wow, <br>
            this is a mess, lets break this up a bit into modules, so
            that it is <br>
            more supportable and debug-able (for myself).  If anyone is
            remotely <br>
            interested, it is a homebrew radar based chronograph.  I've
            got most of <br>
            the pieces working (or at least it worked before I recently
            busted <br>
            things).  The 100KHz sampling using DMA, the ping pong
            floating point 1K <br>
            FFT's running in 'real' time, and some display stuff. 
            Separately, I <br>
            have a live update of a tft screen (320x240) running with
            the FFT <br>
            output.  I'm running on an ARM M4F processor, but using the
            Arduino <br>
            IDE.  The Arduino way of doing things is a little confusing
            to me, to be <br>
            honest.  It hides a lot of things.<br>
            <br>
            Ok, here is the error.<br>
            <br>
/home/bruce/Arduino/adcdmafftM4bruce/adcdmafft/adcdmafftm4/moreutils.ino:
            <br>
            In function 'void doMedian(float*, float*, int)':<br>
            moreutils:14:3: error: 'RunningMedian' was not declared in
            this scope<br>
                RunningMedian samples = RunningMedian(medianlength);<br>
                ^<br>
            moreutils:14:17: error: expected ';' before 'samples'<br>
                RunningMedian samples = RunningMedian(medianlength);<br>
                              ^<br>
            moreutils:16:5: error: 'samples' was not declared in this
            scope<br>
                  samples.add(abuf[i]);<br>
                  ^<br>
            exit status 1<br>
            'RunningMedian' was not declared in this scope<br>
            <br>
            The code in moreutils.ino is:<br>
            <br>
            // additional processing<br>
            #include "moreutils.h"<br>
            <br>
            void doMedian( float abuf[], float runmed[], int
            medianlength) {  // <br>
            needs work!<br>
            <br>
               RunningMedian samples = RunningMedian(medianlength);<br>
               for (int i=0; i&lt; FFT_SIZE/2; i++) {<br>
                 samples.add(abuf[i]);<br>
                 if (i&gt;medianlength-1) {<br>
                   runmed[i-medianlength] = samples.getMedian();<br>
                   // don't put value until the circ buffer is filled<br>
                 }<br>
               }<br>
               for (int i= (FFT_SIZE/2 -medianlength-7); i&lt;
            (FFT_SIZE/2); i++) {<br>
                 runmed[i] = runmed[FFT_SIZE/4];  // hack for now<br>
                 // at tail end of median there are some bizarre
            numbers.  root <br>
            cause has not been<br>
                 // determined, so we just fill the last samples from
            'something close'<br>
               }<br>
            }<br>
            <br>
            Inside of moreutils.h, is #include RunningMedian.h with an <br>
            #ifndef/#define/#include statement, to prevent multiple
            includes of the <br>
            same file (RunningMedian.h).<br>
            <br>
            I'm really kind of confused as to where I need to do the
            declaration.<br>
            <br>
            In <br>
            <a
href="https://github.com/RobTillaart/Arduino/blob/master/libraries/RunningMedian/examples/RunningMedian/RunningMedian.ino"
              rel="noreferrer" target="_blank" moz-do-not-send="true">https://github.com/RobTillaart/Arduino/blob/master/libraries/RunningMedian/examples/RunningMedian/RunningMedian.ino</a>
            <br>
            the declaration is simply done prior to setup.  Snippet
            below<br>
            <br>
            #include &lt;RunningMedian.h&gt;<br>
            <br>
            RunningMedian samples = RunningMedian(5);<br>
            <br>
            RunningMedian samples2 = RunningMedian(9);<br>
            <br>
            void setup() {<br>
            <br>
            ...<br>
            <br>
            }<br>
            <br>
            void loop() {<br>
            <br>
            use samples here...<br>
            <br>
            }<br>
            <br>
            I'm sure this is trivial for most of you - but I'm both
            perplexed and <br>
            stuck.  If one of you kind souls could help me, I'd greatly
            appreciate <br>
            it.  I'd even travel to see someone if that would work out
            better.<br>
            <br>
            TIA, Bruce<br>
            <br>
            _______________________________________________<br>
            gnhlug-discuss mailing list<br>
            <a href="mailto:gnhlug-discuss@mail.gnhlug.org"
              target="_blank" moz-do-not-send="true">gnhlug-discuss@mail.gnhlug.org</a><br>
            <a
              href="http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss/"
              rel="noreferrer" target="_blank" moz-do-not-send="true">http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss/</a><br>
          </blockquote>
        </div>
      </blockquote>
      <p><br>
      </p>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <pre class="moz-quote-pre" wrap="">_______________________________________________
gnhlug-discuss mailing list
<a class="moz-txt-link-abbreviated" href="mailto:gnhlug-discuss@mail.gnhlug.org">gnhlug-discuss@mail.gnhlug.org</a>
<a class="moz-txt-link-freetext" href="http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss/">http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss/</a>
</pre>
    </blockquote>
    <p><br>
    </p>
  </body>
</html>