Skip to content

Commit

Permalink
median: read_mt: mark all-zero samples invalid
Browse files Browse the repository at this point in the history
the median filter "waits" depth/2 samples until it has enough data to do
it's math. The first depth/2 samples after pen-down aren't valid. We set
them to zero, but actually served them to the user as valid samples.

This fixes this behaviour for ts_read_mt() only.

Fixes #95
  • Loading branch information
merge committed May 4, 2017
1 parent 7dea41f commit 5974266
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions plugins/median.c
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@ static int median_read_mt(struct tslib_module_info *inf,
memset(c->delay_mt[j],
0,
sizeof(struct ts_sample_mt) * c->size);

c->withsamples_mt[j] = 0;
#ifdef DEBUG
printf("MEDIAN: Pen Up\n");
Expand All @@ -315,6 +316,11 @@ static int median_read_mt(struct tslib_module_info *inf,
printf("MEDIAN: Pen Down\n");
#endif
}

if (cpress != 0 && c->withsamples_mt[j] <= c->size / 2) {
samp[i][j].valid = -1;
c->withsamples_mt[j]++;
}
}
}

Expand Down

0 comments on commit 5974266

Please sign in to comment.