Merge pull request #3 from langolierz/pi-work

getting display working
This commit is contained in:
langolierz
2017-11-11 19:43:05 +13:00
committed by GitHub
7 changed files with 42 additions and 34 deletions

View File

@@ -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"

View File

@@ -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 >>>>#####

View File

@@ -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
@@ -45,30 +44,28 @@ 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)
if current_message:
load_message(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):
@@ -76,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, '------ <LOOPER> ------ \n')
display.insert(END, '{:>10} {:>20} {:>10} {:>10} {:>10} \n'.format(
display.insert(END, '--------------- <LOOPER> --------------- \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]))
def load_message(display):
@@ -112,7 +109,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:
@@ -132,15 +129,15 @@ def load_browser(self):
global browser_start_index
global browser_list
line_count = 0
display.insert(END, '------ <BROWSER> ------ \n')
display.insert(END, '{:50} {:20} \n'.format('path', 'bank'))
display.insert(END, '---------------- <BROWSER> ---------------- \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
@@ -183,12 +180,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("ERROR_MESSAGE", background="red", foreground="black")
@@ -277,17 +276,24 @@ def backspace_key(event):
def update_screen():
refresh_display()
display.focus_set()
tk.after(1000, update_screen)
frame.bind("<Key>", key)
frame.bind("<Up>", up_key)
frame.bind("<Down>", down_key)
frame.bind("<BackSpace>", backspace_key)
frame.bind("<Num_Lock>", num_lock_key)
def callback(event):
frame.focus_set()
print "clicked at", event.x, event.y
display.bind("<Key>", key)
display.bind("<Up>", up_key)
display.bind("<Down>", down_key)
display.bind("<BackSpace>", backspace_key)
display.bind("<Num_Lock>", num_lock_key)
display.bind("<Button-1>", callback)
frame.pack()
frame.focus_set()
tk.attributes("-fullscreen", True)
tk.after(1000, update_screen)
try:

View File

@@ -1 +1,2 @@
[{"start": -1, "length": 105, "end": -1, "location": "C:\\Users\\Tim\\Documents\\finished_videos/BLACKMASS.mp4", "name": "BLACKMASS.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": ""}, {"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": 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": ""}]

View File

@@ -1 +1 @@
2
0

1
pi_dev_mode.json Normal file
View File

@@ -0,0 +1 @@
"hdmi"

View File

@@ -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()