From a0f33e28d369eab2a45cd9bce05b01484f16f1cb Mon Sep 17 00:00:00 2001 From: 9and3r <9and3r@gmail.com> Date: Mon, 28 Jul 2014 00:44:03 +0200 Subject: [PATCH] Configuration -cache -fulscreen --- README.rst | 8 +- mopidy_touchscreen/.idea/workspace.xml | 203 +++++++++++-------------- mopidy_touchscreen/__init__.py | 6 +- mopidy_touchscreen/ext.conf | 7 +- mopidy_touchscreen/screen_manager.py | 3 +- mopidy_touchscreen/touch_screen.py | 26 ++-- 6 files changed, 117 insertions(+), 136 deletions(-) diff --git a/README.rst b/README.rst index 6516ab0..4e38adc 100644 --- a/README.rst +++ b/README.rst @@ -39,9 +39,11 @@ Mopidy-Touchscreen to your Mopidy configuration file:: [touchscreen] enabled = true - screen_width = 800 - screen_height = 600 - cursor = False + screen_width = 320 + screen_height = 240 + cursor = True + fullscreen = False + cache_dir = $XDG_CACHE_DIR/mopidy/touchscreen Features ============= diff --git a/mopidy_touchscreen/.idea/workspace.xml b/mopidy_touchscreen/.idea/workspace.xml index b188935..d9b37c8 100644 --- a/mopidy_touchscreen/.idea/workspace.xml +++ b/mopidy_touchscreen/.idea/workspace.xml @@ -23,70 +23,56 @@ + + + + + + + + + + + + + + + + + + + + - - + + - - + + - - - - - - - - - - - - - - + + - - + + - - + + - - - - - - - - - - - - - - - - - - - - - - @@ -101,21 +87,22 @@ @@ -143,7 +130,6 @@ - @@ -164,6 +150,7 @@ + @@ -333,13 +320,12 @@ - + - @@ -349,6 +335,7 @@ + @@ -377,14 +364,6 @@ - - - - - - - - @@ -396,7 +375,6 @@ - @@ -434,7 +412,6 @@ - @@ -464,7 +441,6 @@ - @@ -502,7 +478,6 @@ - @@ -533,7 +508,6 @@ - @@ -571,7 +545,6 @@ - @@ -689,13 +662,6 @@ - - - - - - - @@ -703,19 +669,31 @@ - + - - - + + - + - - - + + + + + + + + + + + + + + + + @@ -723,54 +701,49 @@ - - - + + + + + + + + + + + + + + + + + + + + + + + + - - + + - + - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/mopidy_touchscreen/__init__.py b/mopidy_touchscreen/__init__.py index 1044841..02ae29d 100644 --- a/mopidy_touchscreen/__init__.py +++ b/mopidy_touchscreen/__init__.py @@ -26,9 +26,11 @@ class Extension(ext.Extension): def get_config_schema(self): schema = super(Extension, self).get_config_schema() - schema['screen_width'] = config.Integer() - schema['screen_height'] = config.Integer() + schema['screen_width'] = config.Integer(minimum=1) + schema['screen_height'] = config.Integer(minimum=1) schema['cursor'] = config.Boolean() + schema['fullscreen'] = config.Boolean() + schema['cache_dir'] = config.Path() return schema def setup(self, registry): diff --git a/mopidy_touchscreen/ext.conf b/mopidy_touchscreen/ext.conf index 259a24f..7e3ebf2 100644 --- a/mopidy_touchscreen/ext.conf +++ b/mopidy_touchscreen/ext.conf @@ -1,4 +1,7 @@ [touchscreen] enabled = true -# TODO: Add additional config values and their default values here, or remove -# this comment entirely. \ No newline at end of file +screen_width = 320 +screen_height = 240 +cursor = True +fullscreen = False +cache_dir = $XDG_CACHE_DIR/mopidy/touchscreen \ No newline at end of file diff --git a/mopidy_touchscreen/screen_manager.py b/mopidy_touchscreen/screen_manager.py index fdf90de..b586bd1 100644 --- a/mopidy_touchscreen/screen_manager.py +++ b/mopidy_touchscreen/screen_manager.py @@ -109,7 +109,8 @@ class ScreenManager(): logger.error("erreproduzitzen") elif key == "mute": mute = not self.core.playback.mute.get() - self.backend.tell({'action':'mute','value':mute}) + self.core.playback.set_mute(mute) + #self.backend.tell({'action':'mute','value':mute}) elif key == "random": logger.error(self.core.tracklist.random) self.core.tracklist.random = not self.core.tracklist.random diff --git a/mopidy_touchscreen/touch_screen.py b/mopidy_touchscreen/touch_screen.py index ccaee0e..d1fe6cd 100644 --- a/mopidy_touchscreen/touch_screen.py +++ b/mopidy_touchscreen/touch_screen.py @@ -4,7 +4,6 @@ import logging from threading import Thread import pygame from .screen_manager import ScreenManager -from pygame.locals import * from mopidy import core @@ -20,27 +19,28 @@ class TouchScreen(pykka.ThreadingActor, core.CoreListener): logger.error(self.backend) self.core = core self.running = False - #self.screen_size=(320, 240) - try: - self.screen_size = (config['touchscreen']['screen_width'],config['touchscreen']['screen_height']) - except KeyError: - self.screen_size=(320, 240) - logger.warning("Screen size not defined. Using default size: " + str(self.screen_size)) + self.screen_size = (config['touchscreen']['screen_width'], config['touchscreen']['screen_height']) + self.cache_dir = config['touchscreen']['cache_dir'] + self.fullscreen = config['touchscreen']['fullscreen'] pygame.init() - try: - pygame.mouse.set_visible(config['touchscreen']['cursor']) - except KeyError: - pygame.mouse.set_visible(True) + pygame.mouse.set_visible(config['touchscreen']['cursor']) self.screen_manager = ScreenManager(self.screen_size,self.core, self.backend) def start_thread(self): clock = pygame.time.Clock() - screen = pygame.display.set_mode(self.screen_size) + if self.fullscreen: + screen = pygame.display.set_mode(self.screen_size, pygame.FULLSCREEN) + else: + screen = pygame.display.set_mode(self.screen_size) while self.running: clock.tick(15) - screen.blit(self.screen_manager.update(),(0,0)) + screen.blit(self.screen_manager.update(), (0, 0)) pygame.display.flip() for event in pygame.event.get(): + if event.type == pygame.QUIT: + self.running = False + if event.type == pygame.KEYUP and event.key == pygame.K_q: + self.running = False self.screen_manager.event(event) pygame.quit()