RobTillaart / RunningMedian

Arduino library to determine the running median by means of a circular buffer.
MIT License
46 stars 9 forks source link

Is it possible to create an array of runningMedian to call them in a for loop ? #17

Closed Speedy2k closed 2 years ago

Speedy2k commented 2 years ago

Hi, i need to create an array of running median to access them in a for loop, is it possible? Like this:

RunningMedian outTempCMed[5];

setup(){
    for(size_t i = 0; i < 5; i++){
        outTempCMed[i] = RunningMedian(20);
    }
}

Is this something possible ??

Thanx a lot!

RobTillaart commented 2 years ago

Thanks for this good question. It should be possible, need to think about the exact syntax.

RobTillaart commented 2 years ago

Oops wrong button (phones are not ideal to navigate github)

RobTillaart commented 2 years ago

Added an example - https://github.com/RobTillaart/RunningMedian/tree/master/examples/RunningMedian_array There might be more ways to do it.

RobTillaart commented 2 years ago

(updated your question with code tags so it looks better)

initializing could also be done

RunningMedian RM[4] = { RunningMedian(5),RunningMedian(5),RunningMedian(5),RunningMedian(5) };
RobTillaart commented 2 years ago

If you use an array of pointers you can initiialize the array in setup()

See - https://github.com/RobTillaart/RunningMedian/tree/master/examples/RunningMedian_array_pointer

Speedy2k commented 2 years ago

Thanx a lot it is awesome!! I will have to use the pointer version!! I was aware of the version without the pointer but if we use a external variable for the array length it is not useable!!

RobTillaart commented 2 years ago

Good to hear it works,

RobTillaart commented 2 years ago

AS the problem is solved I close the issue