Bake Mate - Pi Chef Blog #8 - The software needs a little more cooking
Status Update:
I managed to get most of it to work! There are a few non-critical bugs, but it works well enough.
Picking up from yesterday's post Bake Mate - Pi Chef Blog #7 - Code Prep, which covered the organization of all the software components, I've included a screen capture of the program in action:
On the left is the Python Shell, in the middle is the IDLE (the Python IDE), and on the right is the .json file for the recipe that was selected.
I start the Bake Mate GUI application (based on Python/tkinter), and go to the screen that lets me select the recipe. The app automatically searches for valid .json files in the recipe directory, parses data from them and displays the valid recipes in a list. Selecting a particular recipe in the list will cause the application to display a short snippet of information to the right, which is parsed from the description field in the .json file. As you can see, I've not included too many details as it's a work in progress.
Selecting a recipe will take the user to the Scale Page, where the scaling ratio for the recipe can be selected. This page is also a work in progress, and I plan on displaying some useful information in the empty place on the left.
Clicking 'Start' here will take the user to the actual steps of mixing/baking.
- In this case, step 1 is a simple 'do' instruction to keep the baking tin ready. This data is obtained from the .json file on the right; have a look at the first element of the Steps array.
- Clicking on 'Next" moves us to Step 2. Step 2 is a 'addm' instruction (as can be seen in the .json file). The Python app detects this and automatically changes the layout of the page to the template for the 'addm' instruction type, and populates the fields with data from the step in the .json file. The ingredient, its unit and value are parsed and displayed.
Also on this screen is a ProgressBar which will tell the user how much more of an ingredient needs to be added. I've not tested it out by connecting it to the weighing scale yet, but the plan is to take a reading from the weighing scale, so some math on it (to account for the weight of the bowl & previously added ingredients), and update the values in realtime. I used dummy values in the video demonstration.
- Step 3 is similar. The app parses data from the json file and populates the fields with data.
- The following few steps work the same way. The app checks the type of instruction in the next step and displays the required screen (all are addm in this case).
- Step 6 is to add Vanilla Essence (Typo in the video ). Since the amount added is usually a few drops and too small to measure, the weight is not measured. This instruction is 'addnm - add non-measurable'
- Step 7 is a 'do' instruction. In this case, it reminds the user to preheat the oven.
- Step 8 is also a 'do' instruction.
- Step 9 is the 'bake' instruction. The json file contains the duration & temperature that is required. As you can see, temperature is stored as Gas Mark 5 in the json file, but is automatically detected and converted to 190C in the UI. I haven't yet integrated the MAX31856 libraries (which I hope won't be too much trouble). I want to include a matplotlib graph on this screen, but I'll need to see how I can rearrange everything: a 2.4" display is small to begin with.
I did have a little trouble managing the code today because Python threw a bunch of import errors since. I fixed this by consolidating most of the code. The main application (that contains the layouts and code for the UI) is close to 700 lines long (~27KB), and the modules that handle parsing the json files & converting units aren't big: 100 lines (6 KB) and 70 lines (1 KB) respectively.
To Do:
- Try it out on the Pi 3. I've been developing on Windows 10, and will need to try running the code on the Raspberry Pi 3. This shouldn't be much of a problem because Python ports without too much trouble.
- It's time to mix hardware & software. I'll need to wire up the HX711 (load cell amplifier) and MAX31856 (thermocouple converter) and test it out.
- Adding advanced conversion features: lookup tables for densities & weights of different ingredients.
- Finalize the GUI.
Top Comments