mirror of
https://github.com/cyberboy666/r_e_c_u_r.git
synced 2025-12-05 16:00:06 +01:00
WIP with difference between single and triple 0 press
This commit is contained in:
@@ -142,5 +142,8 @@ class Actions(object):
|
||||
self.message_handler.set_message('INFO', 'must be in dev_mode to change display')
|
||||
|
||||
def run_script(self, script_name):
|
||||
subprocess.call(['./dotfiles/{}.sh'.format(script_name)])
|
||||
try:
|
||||
subprocess.call(['/home/pi/r_e_c_u_r/dotfiles/{}.sh'.format(script_name)])
|
||||
except exception as e:
|
||||
self.message_handler.set_message('ERROR',e.message)
|
||||
|
||||
|
||||
@@ -1 +1 @@
|
||||
[{"start": -1, "location": "/media/pi/TIM/videos_to_play/mushroom-dreams.mp4", "end": 1026.224159, "name": "mushroom-dreams.mp4", "length": 1132.04}, {"start": -1, "location": "/media/pi/TIM/samplerloop3s3.mp4", "end": -1, "name": "samplerloop3s3.mp4", "length": 3.008}, {"start": -1, "location": "/media/pi/TIM/videos_to_play/long_spinning.mp4", "end": -1, "name": "long_spinning.mp4", "length": 804.245}, {"start": -1, "location": "", "end": -1, "name": "", "length": -1}, {"start": -1, "location": "", "end": -1, "name": "", "length": -1}, {"start": -1, "location": "", "end": -1, "name": "", "length": -1}, {"start": -1, "location": "", "end": -1, "name": "", "length": -1}, {"start": -1, "location": "", "end": -1, "name": "", "length": -1}, {"start": -1, "location": "", "end": -1, "name": "", "length": -1}, {"start": -1, "location": "", "end": -1, "name": "", "length": -1}]
|
||||
[{"name": "mushroom-dreams.mp4", "end": -1, "start": 340.722063, "length": 1132.04, "location": "/media/pi/TIM/videos_to_play/mushroom-dreams.mp4"}, {"name": "samplerloop3s3.mp4", "end": -1, "start": 1.750672, "length": 3.008, "location": "/media/pi/TIM/samplerloop3s3.mp4"}, {"name": "long_spinning.mp4", "end": -1, "start": -1, "length": 804.245, "location": "/media/pi/TIM/videos_to_play/long_spinning.mp4"}, {"name": "colour_pixel_02.mp4", "end": 68.500718, "start": 66.892487, "length": 87.04, "location": "/media/pi/TIM/videos_to_play/colour_pixel_02.mp4"}, {"name": "", "end": -1, "start": -1, "length": -1, "location": ""}, {"name": "", "end": -1, "start": -1, "length": -1, "location": ""}, {"name": "", "end": -1, "start": -1, "length": -1, "location": ""}, {"name": "", "end": -1, "start": -1, "length": -1, "location": ""}, {"name": "", "end": -1, "start": -1, "length": -1, "location": ""}, {"name": "", "end": -1, "start": -1, "length": -1, "location": ""}]
|
||||
@@ -1 +1 @@
|
||||
2
|
||||
0
|
||||
@@ -31,7 +31,7 @@ display = Display(tk, video_driver, message_handler, data)
|
||||
# setup the actions
|
||||
actions = Actions(tk, message_handler, data, video_driver, display)
|
||||
|
||||
numpad_input = NumpadInput(message_handler, display, actions, data)
|
||||
numpad_input = NumpadInput(tk, message_handler, display, actions, data)
|
||||
|
||||
frame.pack()
|
||||
tk.attributes("-fullscreen", True)
|
||||
|
||||
@@ -1,12 +1,18 @@
|
||||
import string
|
||||
import datetime
|
||||
|
||||
class NumpadInput(object):
|
||||
def __init__(self, message_handler, display, actions, data):
|
||||
def __init__(self, root, message_handler, display, actions, data):
|
||||
self.root = root
|
||||
self.message_handler = message_handler
|
||||
self.display = display
|
||||
self.actions = actions
|
||||
self.key_mappings = data.get_keypad_mapping_data()
|
||||
self.bind_actions()
|
||||
self.last_0_press_time = datetime.datetime.now()
|
||||
self.last_0_difference = 2000
|
||||
self.number_of_0_represses = 0
|
||||
self.is_triple = False
|
||||
|
||||
def bind_actions(self):
|
||||
self.display.display_text.bind("<Key>", self.on_key_press)
|
||||
@@ -14,8 +20,12 @@ class NumpadInput(object):
|
||||
def on_key_press(self, event):
|
||||
|
||||
numpad = list(string.ascii_lowercase[0:19])
|
||||
if event.char is 's':
|
||||
self.on_0_press()
|
||||
|
||||
if event.char is '.':
|
||||
self.actions.quit_the_program()
|
||||
|
||||
elif event.char in numpad:
|
||||
this_mapping = self.key_mappings[event.char]
|
||||
if self.display.display_mode in this_mapping:
|
||||
@@ -34,5 +44,30 @@ class NumpadInput(object):
|
||||
else:
|
||||
print('{} is not in keypad map'.format(event.char))
|
||||
|
||||
def on_0_press(self):
|
||||
this_press_time = datetime.datetime.now()
|
||||
print('the last 0 press was at {}'.format(self.last_0_press_time))
|
||||
self.last_0_difference = this_press_time - self.last_0_press_time
|
||||
print('the difference between last and now is {}'.format(self.last_0_difference))
|
||||
print('the total dif in secs is {}.'.format(self.last_0_difference.total_seconds()))
|
||||
self.last_0_press_time = this_press_time
|
||||
if (self.last_0_difference.total_seconds() < 0.7):
|
||||
self.number_of_0_represses = self.number_of_0_represses + 1
|
||||
self.last_0_press_time = this_press_time
|
||||
self.root.after(1000, self.respond_to_0_press)
|
||||
|
||||
def respond_to_0_press(self):
|
||||
print('current represses is {},.'.format(self.number_of_0_represses))
|
||||
if(self.number_of_0_represses == 0):
|
||||
print('doing single action now')
|
||||
elif(self.number_of_0_represses == 1):
|
||||
print('waiting for another...')
|
||||
elif(self.number_of_0_represses == 2):
|
||||
print('doing triple action now')
|
||||
self.number_of_0_represses = -10
|
||||
self.root.after(1000, self.set_represses_to_0)
|
||||
|
||||
def set_represses_to_0(self):
|
||||
print('clearing repress from {}'.format(self.number_of_0_represses))
|
||||
self.number_of_0_represses = 0
|
||||
|
||||
|
||||
Reference in New Issue
Block a user