Skip to content

Commit

Permalink
Merge pull request #179 from glenvorel/interface_peripherals
Browse files Browse the repository at this point in the history
Add touch and mouse control
  • Loading branch information
helgeerbe authored Jan 15, 2022
2 parents af9a4f7 + 668d675 commit 09263a9
Show file tree
Hide file tree
Showing 7 changed files with 474 additions and 67 deletions.
30 changes: 28 additions & 2 deletions picframe/config/configuration_example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ viewer:
clock_text_sz: 120 # default=120, clock character size
clock_format: "%I:%M" # default="%I:%M", strftime format for clock string

menu_text_sz: 40 # default=40, menu character size
menu_autohide_tm: 10.0 # default=10.0, time in seconds to show menu before auto hiding (0 disables auto hiding)

model:
pic_dir: "~/Pictures" # default="~/Pictures", root folder for images
deleted_pictures: "~/DeletedPictures" # move deleted pictures here
Expand Down Expand Up @@ -83,7 +86,6 @@ model:
log_level: "WARNING" # default=WARNING, could beDEBUG, INFO, WARNING, ERROR, CRITICAL
log_file: "" # default="" for debugging set this to the path to a file. NB logging messages will
# appended indefinitely so don't forget this. You will need to tidy it up later
use_kbd: False # default=False, just for debug or console start. Crashing when started with systemd

mqtt:
use_mqtt: False # default=False. Set True true, to enable mqtt
Expand All @@ -101,4 +103,28 @@ http:
port: 9000 # port used to serve pages by http server < 1024 requires root which is *bad* idea
use_ssl: False
keyfile: "path/to/key.pem" # private-key
certfile: "path/to/cert.pem" # server certificate
certfile: "path/to/cert.pem" # server certificate

peripherals:
input_type: null # default=null, valid options: {null, "keyboard", "touch", "mouse"}
buttons:
pause: # pause/unpause the show
enable: True # default=True
label: "Pause" # default="Pause"
shortcut: " " # default=" "
display_off: # turn off the display (when off, any input from selected peripheral will turn it back on)
enable: True # default=True
label: "Display off" # default="Display off"
shortcut: "o" # default="o"
location: # shows or hides location information
enable: False # default=False
label: "Location" # default="Location"
shortcut: "l" # default="l"
exit: # exit PictureFrame
enable: False # default=False
label: "Exit" # default="Exit"
shortcut: "e" # default="e"
power_down: # power down the device, uses sudo
enable: False # default=False
label: "Power down" # default="Power down"
shortcut: "p" # default="p"
17 changes: 13 additions & 4 deletions picframe/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import os
import signal
import sys
from picframe.interface_peripherals import InterfacePeripherals

def make_date(txt):
dt = txt.replace('/',':').replace('-',':').replace(',',':').replace('.',':').split(':')
Expand Down Expand Up @@ -42,16 +43,18 @@ def __init__(self, model, viewer):
self.__model = model
self.__viewer = viewer
self.__paused = False
self.__force_navigate = False
self.__next_tm = 0
self.__date_from = make_date('1901/12/15') # TODO This seems to be the minimum date to be handled by date functions
self.__date_to = make_date('2038/1/1')
self.__location_filter = ""
self.__where_clauses = {}
self.__sort_clause = "exif_datetime ASC"
self.publish_state = lambda x, y: None
self.__keep_looping = True
self.keep_looping = True
self.__location_filter = ''
self.__tags_filter = ''
self.__interface_peripherals = None
self.__shutdown_complete = False

@property
Expand All @@ -70,11 +73,13 @@ def paused(self, val:bool):
def next(self):
self.__next_tm = 0
self.__viewer.reset_name_tm()
self.__force_navigate = True

def back(self):
self.__model.set_next_file_to_previous_file()
self.__next_tm = 0
self.__viewer.reset_name_tm()
self.__force_navigate = True

def delete(self):
self.__model.delete_file()
Expand Down Expand Up @@ -278,7 +283,7 @@ def loop(self): #TODO exit loop gracefully and call image_cache.stop()
signal.signal(signal.SIGINT, self.__signal_handler)

#next_check_tm = time.time() + self.__model.get_model_config()['check_dir_tm']
while self.__keep_looping:
while self.keep_looping:

#if self.__next_tm == 0: #TODO double check why these were set when next_tm == 0
# time_delay = 1 # must not be 0
Expand All @@ -289,8 +294,9 @@ def loop(self): #TODO exit loop gracefully and call image_cache.stop()

tm = time.time()
pics = None #get_next_file returns a tuple of two in case paired portraits have been specified
if not self.paused and tm > self.__next_tm:
if not self.paused and tm > self.__next_tm or self.__force_navigate:
self.__next_tm = tm + self.__model.time_delay
self.__force_navigate = False
pics = self.__model.get_next_file()
if pics[0] is None:
self.__next_tm = 0 # skip this image file moved or otherwise not on db
Expand All @@ -313,13 +319,16 @@ def loop(self): #TODO exit loop gracefully and call image_cache.stop()
break
if skip_image:
self.__next_tm = 0
self.__interface_peripherals.check_input()
self.__shutdown_complete = True

def start(self):
self.__viewer.slideshow_start()
self.__interface_peripherals = InterfacePeripherals(self.__model, self.__viewer, self)

def stop(self):
self.__keep_looping = False
self.keep_looping = False
self.__interface_peripherals.stop()
while not self.__shutdown_complete:
time.sleep(0.05) # block until main loop has stopped
self.__model.stop_image_chache() # close db tidily (blocks till closed)
Expand Down
51 changes: 0 additions & 51 deletions picframe/interface_kbd.py

This file was deleted.

Loading

0 comments on commit 09263a9

Please sign in to comment.