It would be possible to get very deep into signal processing techniques and complex math, but you have to ask yourself if it is really necessary?
If this display is a simple instantaneous numeric output, used for "indication only" rather than say a continuous graph or data log (i.e. you do not need to reconstruct the signal), then it would often be perfectly acceptable, to simply take a periodic average rather than a moving average. Since that requires no history storage, you can average over as many samples as you wish, and this would be determined by the required frequency of display update.
It is not clever, but it is often adequate for the task. Here's an example and a test simulation of its use.
class cPeriodicMean
{
public :
cPeriodicMean( int period ) : m_mean(0),
m_period(period),
m_count(0),
m_sum(0)
{
// empty
}
void addSample( int sample )
{
m_sum += sample ;
m_count++ ;
if( m_count == m_period )
{
m_mean = m_sum / m_period ;
m_count = 0 ;
m_sum = 0 ;
}
}
int getMean()
{
return m_mean ;
}
private :
int m_mean ;
int m_period ;
int m_count ;
int m_sum ;
} ;
// Test Simulation
#include <cstdlib>
#include <cstdio>
#include <windows.h> // for Sleep to simulate sample rate
int main()
{
// Average over 100 samples
cPeriodicMean voltage_monitor( 100 ) ;
for(;;)
{
// Simulate 4000mV +/- 50mV input
int sample = 4000 + (std::rand() % 100) - 50 ;
voltage_monitor.addSample( sample ) ;
// Simulate 100Hz sample rate
Sleep(10) ;
// Current output
int millivolts = voltage_monitor.getMean() ;
printf( "\r%d millivolts ", millivolts ) ;
}
}
A refinement of this technique that will produce even smoother output but generate results at the same frequency would be use the periodic mean output as input to your moving average filter. If you were to use my 100 samples per second example with the 100 sample period, and then put it through your 15 sample moving average, you will have used 15 seconds worth of sampling data while still getting a result every second, with little additional memory usage.
Obviously you can change the period, the moving average length, and the sampling rate to get the results you need at the update frequency you need. I suggest that you take as many samples as you can for the period for which you need an update, then make the moving average as long as you wish to afford.