Skip to content

Commit

Permalink
Passive timer behaviour changed
Browse files Browse the repository at this point in the history
  • Loading branch information
vlad-cool committed Oct 25, 2024
1 parent ec82062 commit 389b1d4
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 23 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ image_build/*.img
image_build/*.z*
image_build/mnt/*
logs
video/*
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
BANANA_IP := 192.168.1.135
BANANA_IP := 192.168.2.12
DRIVER_EXECS := send_pin send_rc5 get_pin get_rc5

.PHONY: release ssh upload clean
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.0.0
1.1.0
50 changes: 29 additions & 21 deletions src/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,17 +233,20 @@ def stop(self):
self.running = False

def start(self):
if self.clear_timer is not None:
self.clear()
if not self.running:
self.prev_time = time.time()
self.running = True

def clear(self):
self.stop()
self.running = False
self.size = 0
self.time = 0
self.coun = "60"
self.prev_time = 0
self.running = False
self.size = 0
self.time = 0
self.coun = "60"
self.prev_time = 0
self.clear_timer = None

def get_time(self):
return int(self.time)
Expand All @@ -254,22 +257,27 @@ def get_size(self):
def get_coun(self):
return self.coun

def update(self):
if not self.running:
return
def update(self, timer_running):
if self.running:
cur_time = time.time()
delta = cur_time - self.prev_time
self.size += 1 * delta / 50
self.size = min(self.size, 1)
self.time += delta
self.prev_time = cur_time

cur_time = time.time()
delta = cur_time - self.prev_time
self.size += 1 * delta / 50
self.size = min(self.size, 1)
self.time += delta
if self.time < 60.0:
self.coun = str(60 - int(self.time) - 0.0001)
if len(self.coun) == 1:
self.coun = " " + self.coun
if self.running:
self.coun = str(60 - int(self.time - 0.0001))
if len(self.coun) == 1:
self.coun = " " + self.coun[0]
else:
self.coun = " 0"
self.prev_time = cur_time
if not timer_running:
if self.clear_timer is None:
self.clear_timer = time.time()
elif time.time() - self.clear_timer > 4:
self.clear()

def __init__(self):
self.clear()
Expand Down Expand Up @@ -611,7 +619,7 @@ def change_weapon_connection_type(_):
gpio_control.button_emu(27, 1)

def passive_stop_card(self, state, btn_id):
if self.root.timer_running != 1 and state == "down":
if self.root.timer_running != 1 and (self.passive_timer.time == 0 or self.passive_timer.time >= 60.0) and state == "down":
self.passive_timer.clear()
match btn_id:
case 1:
Expand Down Expand Up @@ -866,7 +874,7 @@ def get_data(self, _):

root.weapon_connection_type = pins_data.wireless

self.passive_timer.update()
self.passive_timer.update(self.root.timer_running)
root.passive_size = self.passive_timer.get_size()
root.passive_time = self.passive_timer.get_time()
root.passive_coun = self.passive_timer.get_coun()
Expand Down Expand Up @@ -907,7 +915,7 @@ def get_data(self, _):
if self.root.timer_running != 1:
self.passive_timer.clear()
case IrKeys.LEFT_PASSIVE:
if self.root.timer_running != 1:
if self.root.timer_running != 1 and (self.passive_timer.time == 0 or self.passive_timer.time >= 60.0):
self.passive_timer.clear()
if root.passive_2_state == "normal":
root.passive_2_state = "down"
Expand All @@ -917,7 +925,7 @@ def get_data(self, _):
root.passive_2_state = "normal"
root.passive_1_state = "normal"
case IrKeys.RIGHT_PASSIVE:
if self.root.timer_running != 1:
if self.root.timer_running != 1 and (self.passive_timer.time == 0 or self.passive_timer.time >= 60.0):
self.passive_timer.clear()
if root.passive_4_state == "normal":
root.passive_4_state = "down"
Expand Down

0 comments on commit 389b1d4

Please sign in to comment.