instead of attaching the last read weight value to shot states, collect all weight measurements, then linearly interpolate them to the shot state timestamps. This better preserves data from the scale, and produces smoother graphs.
currently, the total weight of the shot is determined by the weight reading attached to the last shot state. For high flow rate shots, this results in the total weight shown in Visualizer being significantly less than reality; a few grams of coffee might still be "in flight" when the machine goes back into the idle state. This PR adds code to wait up to two seconds for the (weight) flow rate to drop to ~0 before saving the shot.
Weight flow graphs are made smoother by applying a Savitzky-Golay filter to the complete set of weight measurements after the shot is finished, then linearly interpolating to shot state timestamps. Unlike my first attempt, this attempt is done in pure Dart with no additional dependencies–after attempting to rebase the Rust attempt on main, I can totally see what you didn't want the additional dependencies added 😅. Since Dart doesn't seem to have a matrix algebra lib that supports linear convolution, the implementation here is done numerically instead. The performance loss isn't going to matter when we're working with such small data sets.
This is a second attempt at https://github.com/obiwan007/despresso/pull/176. Quick recap of the changes:
main
, I can totally see what you didn't want the additional dependencies added 😅. Since Dart doesn't seem to have a matrix algebra lib that supports linear convolution, the implementation here is done numerically instead. The performance loss isn't going to matter when we're working with such small data sets.