element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      • Japan
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Vietnam
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Pi Chef Design Challenge
  • Challenges & Projects
  • Design Challenges
  • Pi Chef Design Challenge
  • More
  • Cancel
Pi Chef Design Challenge
Blog Bake Mate - Pi Chef Blog #7 - Code Prep
  • Blog
  • Forum
  • Documents
  • Polls
  • Files
  • Events
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: avnrdf
  • Date Created: 8 Mar 2018 5:01 PM Date Created
  • Views 782 views
  • Likes 7 likes
  • Comments 3 comments
  • pi_chef
  • bakemate
  • pi chef - bake mate
  • pi chef design challenge
  • pi chef
Related
Recommended

Bake Mate - Pi Chef Blog #7 - Code Prep

avnrdf
avnrdf
8 Mar 2018

Bake Mate - Pi Chef Blog #7 - Code Prep

 

Status Update:

I got back to working on the software, which is something I've been avoiding the past few weeks (I got distracted with the hardware!). I made pretty significant progress over the past few days, and I hope to get it working over the upcoming weekend. Once that is done, I'll focus on making the GUI nicer, and then move on to implementing more features.

 

Software:

Picking up from where I last left off (Bake Mate - Pi Chef Blog #3 - RPi3 setup & recipe JSON format), I did a lot more work on the Python application & figured out how I'll be integrating everything together.

 

Here's the plan:

image

This ended up being a lot more complicated than I originally envisioned at the time of my application, and is definitely the largest Python application ever built in the history of the universe by me, but it's been a fun & learning experience.

As I mentioned in Blog Post 3, the recipes are stored in a particular format in .json files, and are parsed accordingly.

 

 

Start Page:

This one is the simplest of all, and just contains a splash screen.

Menu Page:

This one isn't really needed at this point because I haven't started working on the part that lets the user create a recipe, which I hope to do soon. For now, the user presses on the button to "View Recipes"

Select Recipe

This page displays a list of all the recipes in the folder, along with a short description of the selected recipe.

Scale Page:

After selecting the recipe, the user gets an option to scale the quantity. The application will automatically handle the 'new' weights of every ingredient, which makes everything easier.

When this page is displayed, a Python module called "thisRecipe" gets initialized with a bunch of values which will be used to keep track of the progress as the recipe progresses. This module will be used as a global variable that can be accessed by all the classes (which contain data for each page of the GUI).

 

#thisrecipe.py


file="s"


name = "default name"
description = "default description"


scale_factor = 1.0
#default values, which get overwritten with values from the actual recipe
servings = 14
cooktime = 14


nsteps = 1
cur_step = 0


zero_weight = 0;
weight_done = 0;
step_weight_to_add = 0;


cur_step_type = ""
next_step_type = ""

 

Now that the first few pages are done, we move on to the pages that will actually display each step of the recipe.

I've broken the steps down into the 4 more probable types: add measurable ingredient, add non-measurable ingredient, do (basic instructions like mixing etc.) & bake. These should be sufficient for baking, and I could always add more types if I ever encounter a recipe that needs it.

 

Each page will have a unique GUI and backend. The page for "add measureable ingredient" will need to access the data from the weighing scale using the HX711 library which I've already covered and tested, and the page for "bake " will contain a timer and will need to access oven temperature using the MAX31856 library. Each of these pages will also need to parse the required data from the step in the JSON file: weight or temperature. Naturally, all four of these pages have been designed as templates so that they can be reused: at each step the required data is parsed and displayed in the respective field.

 

To keep track of each step, I use variables that are declared in thisrecipe.py. Since the four 'step' pages might be required in any random order (since it depends entirely on the recipe), I decided to implement it in a manner that certain tasks are performed when the particular page is first called (the enter tasks) and when it is left (the exit tasks).

The first time a page is invoked, it'll look at the current instruction number (in thisrecipe.py) and parse the required data from that particular step (weight, text etc.).

Once the task of the page is done, the user presses on the "Next" button, which executes the exit tasks. The exit tasks basically increment the value of cur_step, and parse the instruction type of the next (upcoming step) from the JSON file. If the next step is a "addm", the next page that is called is of the "add measureable " type; if it is a "do", the next page will be a "do" type; and so on.

 

Have a look at the block diagram: the order in which the pages are invoked depends entirely on the recipe, and at the end of every step, the next page type is determined, and automatically invoked. Throughout the process, thisRecipe.py is used to keep track of the current step. Another parameter that needs to be tracked is the weight detected on the weighing scale so that the weight at each step can be calculated (similar to how tare works).

 

Here are the screen captures: the StartPage, the MenuPage, Select Recipe & Scale Page, Add Measureable Ingredient & The Bake Page:

 

imageimage imageimageimage

 

 

 

  • Sign in to reply

Top Comments

  • genebren
    genebren over 7 years ago +2
    Great update. The menus are looking pretty good. The plan looks like you are moving in the right direction. Keep up the good work! Gene
  • DAB
    DAB over 7 years ago +1
    Nice update. DAB
  • three-phase
    three-phase over 7 years ago +1
    Nice clear displays and a good overall layout of the concept in the block diagram. Kind regards
  • three-phase
    three-phase over 7 years ago

    Nice clear displays and a good overall layout of the concept in the block diagram.

     

    Kind regards

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • genebren
    genebren over 7 years ago

    Great update.  The menus are looking pretty good.  The plan looks like you are moving in the right direction.

    Keep up the good work!
    Gene

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • DAB
    DAB over 7 years ago

    Nice update.

     

    DAB

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube