created look for hole option

This commit is contained in:
Adam Saudagar 2021-12-20 11:57:55 +05:30
parent 814ca1e0d5
commit f31fa11804
2 changed files with 14 additions and 6 deletions

View File

@ -35,7 +35,6 @@ class FullAuto(IEngine):
from fishy.engine.fullautofisher.test import Test
super().__init__(gui_ref)
self._hole_found_flag = False
self._curr_rotate_y = 0
self.fisher = SemiFisherEngine(None)
@ -175,20 +174,22 @@ class FullAuto(IEngine):
return True
def look_for_hole(self) -> bool:
self._hole_found_flag = False
valid_states = [fishing_mode.State.LOOKING, fishing_mode.State.FISHING]
_hole_found_flag = FishingMode.CurrentMode in valid_states
if not config.get("look_for_hole", 1):
return _hole_found_flag
t = 0
while not self._hole_found_flag and t <= 2.5:
while not _hole_found_flag and t <= 2.5:
direction = -1 if t > 1.25 else 1
mse.move(0, FullAuto.rotate_by*direction)
time.sleep(0.05)
t += 0.05
self._hole_found_flag = FishingMode.CurrentMode in valid_states
_hole_found_flag = FishingMode.CurrentMode in valid_states
self._curr_rotate_y = t
return self._hole_found_flag
return _hole_found_flag
def rotate_back(self):
while self._curr_rotate_y > 0.01:

View File

@ -48,10 +48,12 @@ def start_fullfisher_config(gui: 'GUI'):
config.set("full_auto_mode", mode_var.get())
edit_cb['state'] = "normal" if config.get("full_auto_mode", 0) == FullAutoMode.Recorder.value else "disable"
# todo repetitive code fix
file_name_label = tk.StringVar(value=file_name())
mode_var = tk.IntVar(value=config.get("full_auto_mode", 0))
edit_var = tk.IntVar(value=config.get("edit_recorder_mode", 0))
tabout_var = tk.IntVar(value=config.get("tabout_stop", 1))
look_for_hole = tk.IntVar(value=config.get("look_for_hole", 1))
row = 0
ttk.Label(controls_frame, text="Calibration: ").grid(row=row, column=0, pady=(5, 0))
@ -78,6 +80,11 @@ def start_fullfisher_config(gui: 'GUI'):
row += 1
ttk.Label(controls_frame, text="Look for hole: ").grid(row=row, column=0)
ttk.Checkbutton(controls_frame, variable=look_for_hole, command=lambda: config.set("look_for_hole", look_for_hole.get())).grid(row=row, column=1, pady=(5, 0))
row += 1
ttk.Label(controls_frame, text="Fishy file: ").grid(row=row, column=0, rowspan=2)
ttk.Button(controls_frame, text="Select", command=select_file).grid(row=row, column=1, pady=(5, 0))
row += 1