Porting Arduino-Library RunningMedian

I try to port the following Arduino-Library:

I replace:


#if defined (SPARK)
  #include "application.h"
  #if defined(ARDUINO) && ARDUINO >= 100
    #include "Arduino.h"
    #include "WProgram.h"
  // here could follow some of the includes only needed on Arduino
  // see bellow


but I still get this error:

Build didn’t produce binary Error

What is the best starting point to learn which variables, definitions, functions etc. I need to port.

Thanks in advance for your help.

There are any number of reasons you could get Build didn’t produce binary, but I’ve found that the one that is most surprising to users of the Particle Dev (Atom based IDE) is that it doesn’t only build the file you have open. It builds all of the files in the directory the file you have open contains. So if there are multiple .ino files, it will try to build all of them, encounter multiple setup() and loop() functions and fail. Other reasons are: build exceeds size of flash, and accessing standard C library functions that aren’t implemented.

1 Like

I didn’t have issues compiling for the Photon. Just short of one fix and I can make it available as a library. Will update once it’s up. :wink:

@jensfranke, here it is - https://gist.github.com/kennethlimcp/ac098720c668c297ab0e49646de0ce70

You can copy and paste by adding a new .h and .cpp file to your current app in the Build IDE and test with the example in the .ino. Have fun!


@jensfranke, may I ask why you are using this particular library?

I have a very similar library I call “ChangeDetector” which establishes a standard deviation of sequentially input values, then, returns non-zero if the next input value is outside of the moving average +/- N standard deviations. Here’s the code: https://github.com/mkoistinen/ChangeDetector

It doesn’t calculate the median, but rather the moving average, if this helps you. And, I use this currently with a RedBear Duo, so I’m confident it will work on your project.

Note, I’ve not developed in C++ in nearly 20 years and this is my first ever Arduino code, so, if you have any suggestions, please let me know. One thing I may “borrow” from the RunningMedian code is the dynamic memory allocation for the array. I current have a fixed size of up to 2000 values (but a configurable amount less than that for use, if desired).

1 Like