From 38c4d4b2b083e34d19e064de36b6dc564d6ebc85 Mon Sep 17 00:00:00 2001 From: langolierz Date: Fri, 10 Nov 2017 22:38:09 +0000 Subject: [PATCH] getting display working --- README.md | 2 +- data_centre.py | 2 +- display_centre.py | 72 +++++++++++++++++++++---------------------- display_data.json | 2 +- next_bank_number.json | 2 +- pi_dev_mode.json | 1 + video_centre.py | 2 +- 7 files changed, 41 insertions(+), 42 deletions(-) create mode 100644 pi_dev_mode.json diff --git a/README.md b/README.md index d4a1a14..70cdaa4 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ a diy videolooper for py/pi - change keyboard layout : sudo raspi-config => localiation options => change keyboard layout => generic 104 => english us => english us => the default for => no compose => no then sudo reboot -(for reading video lengths :) sudo apt-get ffmpeg and pip install ffprobe +(for reading video lengths :) sudo apt-get install ffmpeg and pip install ffprobe (needed a sudo apt-get update in there the second time too) note that to set up the file to browser you will have to create a fle called path_to_browser.json and put in it "your/path/to/browser" diff --git a/data_centre.py b/data_centre.py index ac666f7..a84579c 100644 --- a/data_centre.py +++ b/data_centre.py @@ -55,7 +55,7 @@ logger = setup_logging() ######## sets paths and constants ######## PATH_TO_DATA_OBJECTS = get_the_current_dir_path() -PATH_TO_BROWSER = get_path_to_browser() #'/media/pi/TIM' #get_the_current_dir_path() #TODO replace this with pi path name when i know what makes sense +PATH_TO_BROWSER = get_path_to_browser() EMPTY_BANK = dict(name='',location='',length=-1,start=-1,end=-1) ####<<<< data methods for browser tab >>>>##### diff --git a/display_centre.py b/display_centre.py index f6a04bc..aba450e 100644 --- a/display_centre.py +++ b/display_centre.py @@ -11,12 +11,11 @@ import tkFont import video_centre import data_centre -VIDEO_DISPLAY_TEXT = 'NOW [{}] {} NEXT [{}] {}' -VIDEO_DISPLAY_BANNER_LIST = [ - '[', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', ']'] +VIDEO_DISPLAY_TEXT = 'NOW [{}] {} NEXT [{}] {}' + VIDEO_DISPLAY_BANNER_TEXT = '{} {} {}' -SELECTOR_WIDTH = 0.35 -ROW_OFFSET = 8.0 +SELECTOR_WIDTH = 0.28 +ROW_OFFSET = 6.0 MAX_LINES = 5 browser_start_index = 0 @@ -25,17 +24,11 @@ browser_index = 0 tk = Tk() -label_position_value = StringVar() -label_position_value.set('Current Position: --:--') -label_length_value = StringVar() -label_length_value.set('Video Length: --:--') frame = Frame(tk, width=500, height=400) -label_position = Label(tk, textvariable=label_position_value) -label_length = Label(tk, textvariable=label_length_value) + video_driver = video_centre.video_driver(frame) -label_length.pack() -label_position.pack() + # our data store data_object = data_centre.data() @@ -52,28 +45,27 @@ display_mode = 'BROWSER' def load_display(display): load_title(display) - load_divider(display) + #load_divider(display) load_player(display) - load_divider(display) + #load_divider(display) if display_mode == 'BROWSER': load_browser(display) elif display_mode == 'SETTINGS': pass # load_settings(display) else: load_looper(display) - load_divider(display) - + #load_divider(display) display.pack() def load_title(display): - display.insert(END, '======== r_e_c_u_r ======== \n') - display.tag_add("TITLE", 1.9, 1.18) + display.insert(END, '================ r_e_c_u_r ================ \n') + display.tag_add("TITLE", 1.17, 1.26) def load_divider(display): - display.insert(END, '---------------- \n') + display.insert(END, '------------------------------------------- \n') def load_player(display): @@ -81,19 +73,19 @@ def load_player(display): end_of_text = float("3." + str(len(text))) end_of_banner = float("3." + str(len(banner))) display.insert(END, text + '\n') - display.tag_add("PLAYER_INFO", 3.0, end_of_text) + display.tag_add("PLAYER_INFO", 2.0, end_of_text) display.insert(END, banner + '\n') - display.tag_add("PLAYER_INFO", 4.0, end_of_banner) + display.tag_add("PLAYER_INFO", 3.0, end_of_banner) def load_looper(display): bank_info = data_centre.get_all_looper_data_for_display() - display.insert(END, '------ ------ \n') - display.insert(END, '{:>10} {:>20} {:>10} {:>10} {:>10} \n'.format( + display.insert(END, '--------------- --------------- \n') + display.insert(END, '{:>3} {:>10} {:>3} {:>3} {:>3} \n'.format( 'bank no', 'name', 'length', 'start', 'end')) for bank in bank_info: - display.insert(END, '{:>10} {:>20} {:>10} {:>10} {:>10} \n'.format( + display.insert(END, '{:>3} {:>10} {:>3} {:>3} {:>3} \n'.format( bank[0], bank[1], bank[2], bank[3], bank[4])) @@ -109,7 +101,7 @@ def get_text_for_video_display(): def create_video_display_banner(duration, video_length): - banner_list = ['[', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', + banner_list = ['[', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', ']'] max = len(banner_list) - 1 if duration <= 0: @@ -129,15 +121,15 @@ def load_browser(self): global browser_start_index global browser_list line_count = 0 - display.insert(END, '------ ------ \n') - display.insert(END, '{:50} {:20} \n'.format('path', 'bank')) + display.insert(END, '---------------- ---------------- \n') + display.insert(END, '{:35} {:5} \n'.format('path', 'bank')) for index in range(len(browser_list)): if line_count >= MAX_LINES: break if index >= browser_start_index: path = browser_list[index] - display.insert(END, '{:50} {:20} \n'.format(path[0], path[1])) + display.insert(END, '{:35} {:5} \n'.format(path[0], path[1])) line_count = line_count + 1 @@ -180,12 +172,14 @@ def deselect_current_browser_index(): ROW_OFFSET + SELECTOR_WIDTH + browser_index) def refresh_display(): + display.configure(state='normal') display.delete(1.0, END) load_display(display) + display.configure(state='disable') if display_mode == "BROWSER": select_current_browser_index() -display = Text(tk, bg="black", fg="white") +display = Text(tk, bg="black", fg="white", font=('courier', 14)) display.tag_configure("SELECT", background="white", foreground="black") display.tag_configure("TITLE", background="black", foreground="red") display.tag_configure("PLAYER_INFO", background="black", foreground="yellow") @@ -255,18 +249,22 @@ def backspace_key(event): def update_screen(): refresh_display() + display.focus_set() tk.after(1000, update_screen) +def callback(event): + frame.focus_set() + print "clicked at", event.x, event.y -frame.bind("", key) -frame.bind("", up_key) -frame.bind("", down_key) -frame.bind("", backspace_key) -frame.bind("", num_lock_key) - +display.bind("", key) +display.bind("", up_key) +display.bind("", down_key) +display.bind("", backspace_key) +display.bind("", num_lock_key) +display.bind("", callback) frame.pack() -frame.focus_set() +tk.attributes("-fullscreen", True) tk.after(1000, update_screen) tk.mainloop() diff --git a/display_data.json b/display_data.json index 7a36d35..d26d6bf 100644 --- a/display_data.json +++ b/display_data.json @@ -1 +1 @@ -[{"start": -1, "length": 4, "end": -1, "location": "/media/pi/TIM/samplerloop3s.mp4", "name": "samplerloop3s.mp4"}, {"start": -1, "length": 5, "end": -1, "location": "/media/pi/TIM/samplerloop3s2.mp4", "name": "samplerloop3s2.mp4"}, {"start": -1, "length": 3, "end": -1, "location": "/media/pi/TIM/samplerloop3s3.mp4", "name": "samplerloop3s3.mp4"}, {"start": -1, "length": 4, "end": -1, "location": "/media/pi/TIM/samplerloop3s.mp4", "name": "samplerloop3s.mp4"}, {"start": -1, "length": -1, "end": -1, "location": "", "name": ""}, {"start": -1, "length": -1, "end": -1, "location": "", "name": ""}, {"start": -1, "length": -1, "end": -1, "location": "", "name": ""}, {"start": -1, "length": -1, "end": -1, "location": "", "name": ""}, {"start": -1, "length": -1, "end": -1, "location": "", "name": ""}, {"start": -1, "length": -1, "end": -1, "location": "", "name": ""}, {"start": -1, "length": -1, "end": -1, "location": "", "name": ""}, {"start": -1, "length": -1, "end": -1, "location": "", "name": ""}, {"start": -1, "length": -1, "end": -1, "location": "", "name": ""}, {"start": -1, "length": -1, "end": -1, "location": "", "name": ""}, {"start": -1, "length": -1, "end": -1, "location": "", "name": ""}] \ No newline at end of file +[{"start": -1, "length": 4, "end": -1, "location": "/media/pi/TIM1/samplerloop3s.mp4", "name": "samplerloop3s.mp4"}, {"start": -1, "length": 5, "end": -1, "location": "/media/pi/TIM1/samplerloop3s2.mp4", "name": "samplerloop3s2.mp4"}, {"start": -1, "length": 3, "end": -1, "location": "/media/pi/TIM1/samplerloop3s3.mp4", "name": "samplerloop3s3.mp4"}, {"start": -1, "length": 3, "end": -1, "location": "/media/pi/TIM1/samplerloop3s3.mp4", "name": "samplerloop3s3.mp4"}, {"start": -1, "length": 3, "end": -1, "location": "/media/pi/TIM1/samplerloop3s3.mp4", "name": "samplerloop3s3.mp4"}, {"start": -1, "length": 26, "end": -1, "location": "/media/pi/TIM1/TRASHPALACEVIDEOS/01_trashpalaceintro.mp4", "name": "01_trashpalaceintro.mp4"}, {"start": -1, "length": 97, "end": -1, "location": "/media/pi/TIM1/TRASHPALACEVIDEOS/04_THEORY_OF_OBSCURITY.mp4", "name": "04_THEORY_OF_OBSCURITY.mp4"}, {"start": -1, "length": -1, "end": -1, "location": "", "name": ""}, {"start": -1, "length": -1, "end": -1, "location": "", "name": ""}, {"start": -1, "length": -1, "end": -1, "location": "", "name": ""}, {"start": -1, "length": -1, "end": -1, "location": "", "name": ""}, {"start": -1, "length": -1, "end": -1, "location": "", "name": ""}, {"start": -1, "length": -1, "end": -1, "location": "", "name": ""}, {"start": -1, "length": -1, "end": -1, "location": "", "name": ""}, {"start": -1, "length": -1, "end": -1, "location": "", "name": ""}] \ No newline at end of file diff --git a/next_bank_number.json b/next_bank_number.json index 56a6051..62f9457 100644 --- a/next_bank_number.json +++ b/next_bank_number.json @@ -1 +1 @@ -1 \ No newline at end of file +6 \ No newline at end of file diff --git a/pi_dev_mode.json b/pi_dev_mode.json new file mode 100644 index 0000000..fb404a7 --- /dev/null +++ b/pi_dev_mode.json @@ -0,0 +1 @@ +"hdmi" \ No newline at end of file diff --git a/video_centre.py b/video_centre.py index 737fcbe..90beb4c 100644 --- a/video_centre.py +++ b/video_centre.py @@ -141,7 +141,7 @@ class video_player(object): logger.info('{} is loading now {}'.format( self.name,self.location )) self.omx.load(self.location, 'after-first-frame', - '--win 0,0,400,400 --no-osd --display 5', '') + '--win 250,350,800,800 --no-osd --display 5', '') def get_context_for_this_player(self): next_context = data_centre.get_next_context()