Close

Updates

A project log for SilviaPiPID

Rebuilding an old Arduino Based PID for a Rancilio Silvia with a PI Zero and Rust

David P SmithDavid P Smith 05/07/2021 at 12:420 Comments

It's been a little while since I've put much of an update in here.

I've spent some time refactoring Lovett to get the overall program flow in a better state. I've adopted a strong redux pattern for handling program state changes.  There are three major functional container structs. WindowViewer which contains the program views, the Store, which holds the program's state tree and handles reducers, and the Model Scheduler, which (theoretically) would handle starting up program threads as needed. The lines indicate message busses of the type indicated but the diamonds. Event messages indicate what has occurred in the program and they are routed to the dispatcher which determine what action or actions need to be send to the Store. The store runs the reducer code to produce the latest version of the program State. State messages are then relayed to Views in the Window Viewer and to the Model Scheduler and its model treads (should they need state).

I would love to work on a better State element subscriber system. I currently have filters as a stand-in, so that State RXs will only see new State trees based on the conditions they supply. But this still ends up passing an entire state tree to various places that don't require it, and passes deeper state change detection back to the recipient structs, which seems a little inefficient.

I have also been working on a implementing basic configuration as a static struct. This required tapping into the laxy_static crate to define how the static config could be built up at runtime. The config object is static so it can be read anywhere at anytime without having to pass it along as a value everywhere, which could become a bit onerous. Currently the config object holds two things, the font vector and the color palette. 

Moving the font vector to a static config was the tactic I took to address another issue. I wanted to use the font in multiple places, but re-loading multiple copies of a font at a few mb each was eating up ram much faster than I had realized. Moving it to a single instance shared in the program got the ram usage back down to normal.

Discussions