From 9653af5501bb8e35fa84544862e753fe1db1a25b Mon Sep 17 00:00:00 2001 From: Johannes Mockenhaupt Date: Sat, 15 Jul 2017 17:09:04 +0200 Subject: [PATCH] RuffyScripter.navigateToMenu: detect if we're wrapping around not finding a menu (likely because it's hidden) --- .../de/jotomo/ruffyscripter/RuffyScripter.java | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/de/jotomo/ruffyscripter/RuffyScripter.java b/app/src/main/java/de/jotomo/ruffyscripter/RuffyScripter.java index c58f43d95c..0e5f06d05c 100644 --- a/app/src/main/java/de/jotomo/ruffyscripter/RuffyScripter.java +++ b/app/src/main/java/de/jotomo/ruffyscripter/RuffyScripter.java @@ -282,19 +282,17 @@ public class RuffyScripter { } public void navigateToMenu(MenuType desiredMenu) { - // TODO menu var might not have been initialized if this is called to early - // though that's gonna be a problem for all code; - // wait during init till this is set? create a getter for currentMenu to do this? MenuType startedFrom = currentMenu.getType(); + boolean movedOnce = false; while (currentMenu.getType() != desiredMenu) { - MenuType currentType = currentMenu.getType(); -/* if (currentType == startedFrom) { - // TODO don't trigger right away, that's always a match ;-) - // failed to find the menu, after going through all the menus, bail out - throw new CommandException(false, null, "Menu not found searching for " + desiredMenu); - }*/ + MenuType currentMenuType = currentMenu.getType(); + if (movedOnce && currentMenuType == startedFrom) { + throw new CommandException().message("Menu not found searching for " + desiredMenu + + ". Check menu settings on your pump to ensure it's not hidden."); + } pressMenuKey(); - waitForMenuToBeLeft(currentType); + waitForMenuToBeLeft(currentMenuType); + movedOnce = true; } }