From b6315f7b0e895435e24169cc09fb548e82bbfb0f Mon Sep 17 00:00:00 2001 From: Thaloria Date: Fri, 14 Oct 2022 20:35:41 +0200 Subject: [PATCH] added pauses to loop management --- combine_main_ui.py | 2 ++ craft_table/main_craft.py | 6 ++++-- crop/main_crop_ui.py | 3 ++- equipment_main_ui.py | 4 +++- farm/main_farm_ui.py | 3 ++- utils.py | 9 +++++++++ 6 files changed, 22 insertions(+), 5 deletions(-) diff --git a/combine_main_ui.py b/combine_main_ui.py index 38a4056..07b6209 100644 --- a/combine_main_ui.py +++ b/combine_main_ui.py @@ -23,8 +23,10 @@ def run(): overlay.run_mode = 'init' continue elif overlay.run_mode == 'started': + cv.waitKey(1000) pass elif overlay.run_mode == 'init': + cv.waitKey(1) continue elif overlay.run_mode == 'paused': continue diff --git a/craft_table/main_craft.py b/craft_table/main_craft.py index 73c885f..f282213 100644 --- a/craft_table/main_craft.py +++ b/craft_table/main_craft.py @@ -2,7 +2,7 @@ from time import time import sys import cv2 as cv import keyboard -from utils import get_click_point, dig_point, check_for_ok_button, check_for_craft_button +from utils import get_click_point, dig_point, check_for_craft_ok_button, check_for_craft_button import pydirectinput from craft_overlay import CraftOverlay from config_file import UserConfigs @@ -26,8 +26,9 @@ def run(): overlay.run_mode = 'init' continue elif overlay.run_mode == 'started': - cv.waitKey(500) + cv.waitKey(1000) elif overlay.run_mode == 'init': + cv.waitKey(1) continue elif overlay.run_mode == 'finished': overlay.update_status_label("finished", "0") @@ -308,6 +309,7 @@ def run(): vision_stun = Vision() # odig_overlay = DiggingOverlay(config) check_for_craft_button(capture_window2, vision_stun, capture_config) + check_for_craft_ok_button(capture_window2, vision_stun) run_counter = run_counter + 1 overlay.update_status_label(mode, run_target - run_counter) #check_for_ok_button(capture_window, vision_stun, capture_config) diff --git a/crop/main_crop_ui.py b/crop/main_crop_ui.py index f94fcfc..8b362b4 100644 --- a/crop/main_crop_ui.py +++ b/crop/main_crop_ui.py @@ -15,8 +15,9 @@ def run(): overlay.run_mode = 'init' continue elif overlay.run_mode == 'started': - cv.waitKey(500) + cv.waitKey(1000) elif overlay.run_mode == 'init': + cv.waitKey(1) continue else: # boelk diff --git a/equipment_main_ui.py b/equipment_main_ui.py index c931dee..0a23876 100644 --- a/equipment_main_ui.py +++ b/equipment_main_ui.py @@ -35,8 +35,10 @@ def run(): overlay.run_mode = 'init' continue elif overlay.run_mode == 'started': + cv.waitKey(1000) pass elif overlay.run_mode == 'init': + cv.waitKey(1) continue elif overlay.run_mode == 'paused': continue @@ -129,7 +131,7 @@ def run(): while True: if overlay.run_mode == 'paused': - # cv.waitKey(500) + cv.waitKey(1) if (time() - loop_time_p) >= 5: loop_time_p = time() print("pausing") diff --git a/farm/main_farm_ui.py b/farm/main_farm_ui.py index 93be0af..2be0056 100644 --- a/farm/main_farm_ui.py +++ b/farm/main_farm_ui.py @@ -15,8 +15,9 @@ def run(): overlay.run_mode = 'init' continue elif overlay.run_mode == 'started': - cv.waitKey(500) + cv.waitKey(1000) elif overlay.run_mode == 'init': + cv.waitKey(1) continue else: # boelk diff --git a/utils.py b/utils.py index 1eb06af..68c68b4 100644 --- a/utils.py +++ b/utils.py @@ -183,6 +183,15 @@ def check_for_craft_button(cap_win, vis, conf): for pointi in pointis: dig_point(pointi[0], pointi[1], 150) +def check_for_craft_ok_button(cap_win, vis): + screenshot = cap_win.get_screenshot() + rectangles = vis.find(screenshot, cv.imread("ok_button.jpg", cv.IMREAD_UNCHANGED), 0.5, 1) + offset_left = 0 + offset_down = 0 + if len(rectangles) == 1: + pointis = vis.get_click_points(rectangles) + for pointi in pointis: + dig_point(pointi[0] + offset_left, pointi[1] + offset_down, 150) def get_click_point(rectangle): # Loop over all the rectangles