static unsigned maUpdate(struct MOVING_AVG *maP, unsigned sample)
{
    maP->sampleTotal           -= maP->sample[maP->sampleIdx];
    maP->sampleTotal           += sample;
    maP->sample[maP->sampleIdx] = sample;
    maP->sampleIdx              = (maP->sampleIdx + 1) & 0x0F;

    return (maP->sampleTotal >> 4);
}
