Skip to content

Commit d359328

Browse files
committed
1.1.0 "Refactored the timer_countdown method in MainWindow class, now its has 10ms accuracy and works as intended"
1 parent 9c01ee6 commit d359328

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

main.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -264,17 +264,18 @@ def click_helper(self, hold_time, up, down):
264264
def timer_countdown(self):
265265
temp = self.click_timer
266266
while True:
267-
time.sleep(1)
268-
temp = temp - 1
269-
print(temp)
267+
self.timer_sleep(
268+
10
269+
) # ? this 10 is in millisecond not second, i found 10 millisecond to be the most accurate
270+
temp = temp - 0.010
270271
if self.__stop_threads:
271272
temp = 0
272273
if temp <= 0:
273274
self.__stop_threads = True
274275
break
275276

276277
def timer_sleep(self, delay):
277-
target = time.perf_counter_ns() + delay * 1000
278+
target = time.perf_counter_ns() + delay * 1000000
278279
while time.perf_counter_ns() < target:
279280
pass # precise timing
280281

0 commit comments

Comments
 (0)