diff --git a/openroast/__init__.py b/openroast/__init__.py index 92ddac4..ac0d3a3 100644 --- a/openroast/__init__.py +++ b/openroast/__init__.py @@ -14,8 +14,9 @@ from openroast.controllers import recipe -roaster = freshroastsr700.freshroastsr700(thermostat=True) recipes = recipe.Recipe() +roaster = freshroastsr700.freshroastsr700( + thermostat=True, state_transition_func=recipes.move_to_next_section) class Openroast(object): diff --git a/openroast/controllers/recipe.py b/openroast/controllers/recipe.py index a22b646..df76af1 100644 --- a/openroast/controllers/recipe.py +++ b/openroast/controllers/recipe.py @@ -101,12 +101,15 @@ def load_current_section(self): self.get_current_section_time(), self.get_current_cooling_status()) - def move_to_next_section(self): - if (self.currentRecipeStep + 1) >= self.get_num_recipe_sections(): - openroast.roaster.idle() + def move_to_next_section(self, roaster, state): + if self.check_recipe_loaded(): + if (self.currentRecipeStep + 1) >= self.get_num_recipe_sections(): + openroast.roaster.idle() + else: + self.currentRecipeStep += 1 + self.load_current_section() else: - self.currentRecipeStep += 1 - self.load_current_section() + openroast.roaster.idle() def get_current_recipe(self): return self.recipe diff --git a/openroast/views/roasttab.py b/openroast/views/roasttab.py index 4abcc78..63d4e9d 100644 --- a/openroast/views/roasttab.py +++ b/openroast/views/roasttab.py @@ -437,7 +437,7 @@ def load_recipe_into_roast_tab(self): self.update_fan_info() def next_section(self): - openroast.recipes.move_to_next_section() + openroast.recipes.move_to_next_section(None, None) self.update_section_time() self.targetTempLabel.setText(str(openroast.roaster.target_temp)) self.update_target_temp()