diff --git a/README.rst b/README.rst index 60038cd..771c91d 100644 --- a/README.rst +++ b/README.rst @@ -20,6 +20,8 @@ Mopidy-Touchscreen Mopidy extension to show info on a display and control from it +.. image:: http://i60.tinypic.com/i4l0fq.jpg + Installation ============ @@ -39,7 +41,7 @@ Before starting Mopidy, you must add configuration for Mopidy-Touchscreen to your Mopidy configuration file:: [touchscreen] - # TODO: Add example of extension config + enabled = true Project resources @@ -56,4 +58,4 @@ Changelog v0.1.0 (UNRELEASED) ---------------------------------------- -- Initial release. \ No newline at end of file +- Initial release. diff --git a/mopidy_touchscreen/.idea/workspace.xml b/mopidy_touchscreen/.idea/workspace.xml index f5c583b..01b7c9e 100644 --- a/mopidy_touchscreen/.idea/workspace.xml +++ b/mopidy_touchscreen/.idea/workspace.xml @@ -26,8 +26,8 @@ - - + + @@ -36,8 +36,18 @@ - - + + + + + + + + + + + + @@ -46,30 +56,8 @@ - - - - - - - - - - - - - - - - - - - - - - - - + + @@ -86,21 +74,21 @@ @@ -128,6 +116,7 @@ + @@ -148,7 +137,6 @@ - @@ -318,14 +306,14 @@ - + - + @@ -333,11 +321,11 @@ - + - + @@ -362,6 +350,69 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -390,9 +441,7 @@ - - - + @@ -400,7 +449,6 @@ - @@ -423,9 +471,7 @@ - - - + @@ -441,7 +487,6 @@ - @@ -464,9 +509,7 @@ - - - + @@ -482,7 +525,6 @@ - @@ -498,9 +540,7 @@ - - - + @@ -523,7 +563,6 @@ - @@ -539,9 +578,7 @@ - - - + @@ -564,7 +601,6 @@ - @@ -572,9 +608,7 @@ - - - + @@ -590,7 +624,6 @@ - @@ -598,9 +631,7 @@ - - - + @@ -616,7 +647,6 @@ - @@ -624,9 +654,7 @@ - - - + @@ -642,7 +670,6 @@ - @@ -658,14 +685,6 @@ - - - - - - - - @@ -676,44 +695,48 @@ - + - - - + + + + + + + + + - - + + - - + + + + + + + + + + - - - - - - - - - - - - + + diff --git a/mopidy_touchscreen/main_screen.py b/mopidy_touchscreen/main_screen.py index 27c97c2..7ca472a 100644 --- a/mopidy_touchscreen/main_screen.py +++ b/mopidy_touchscreen/main_screen.py @@ -17,7 +17,7 @@ logger = logging.getLogger(__name__) class MainScreen(): - def __init__(self,size,manager,cache,core, fonts): + def __init__(self, size, manager, cache, core, fonts): self.core = core self.size = size self.base_size = self.size[1]/8 @@ -112,4 +112,18 @@ class MainScreen(): if event.direction == TouchManager.left: self.core.playback.next() elif event.direction == TouchManager.right: - self.core.playback.previous() \ No newline at end of file + self.core.playback.previous() + elif event.direction == TouchManager.up: + volume = self.core.playback.volume.get() + 10 + if volume > 100: + volume = 100 + self.manager.backend.tell({'action':'volume','value':volume}) + self.manager.volume_changed(volume) + elif event.direction == TouchManager.down: + volume = self.core.playback.volume.get() - 10 + if volume < 0: + volume = 0 + self.manager.backend.tell({'action':'volume','value':volume}) + self.manager.volume_changed(volume) + + diff --git a/mopidy_touchscreen/screen_manager.py b/mopidy_touchscreen/screen_manager.py index 416a6f6..14d1566 100644 --- a/mopidy_touchscreen/screen_manager.py +++ b/mopidy_touchscreen/screen_manager.py @@ -66,6 +66,13 @@ class ScreenManager(): else: self.core.playback.play() logger.error("erreproduzitzen") + elif key == "mute": + mute = not self.core.playback.mute.get() + 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 + #self.backend.tell({'action':'random','value':random}) self.screens[0].touch_event(touch_event) def volume_changed(self, volume): @@ -77,4 +84,5 @@ class ScreenManager(): else: self.screen_objects_manager.get_touch_object("pause_play").set_text(u" \u25B8",True) - + def mute_changed(self, mute): + self.touch_text_manager.get_touch_object("mute").set_active(mute) diff --git a/mopidy_touchscreen/screen_objects.py b/mopidy_touchscreen/screen_objects.py index 53dd0aa..d8d677a 100644 --- a/mopidy_touchscreen/screen_objects.py +++ b/mopidy_touchscreen/screen_objects.py @@ -127,6 +127,9 @@ class TouchObject(BaseItem): def is_pos_inside(self, pos): return self.rect_in_pos.collidepoint(pos) + def set_active(self, active): + self.active = active + class TouchAndTextItem(TouchObject, TextItem): def __init__(self, font, text, pos, color,text_size): @@ -136,6 +139,14 @@ class TouchAndTextItem(TouchObject, TextItem): def update(self): TextItem.update() + def set_active(self, active): + self.active = active + if active: + color = (0,150,255) + else: + color = (255,255,255) + TextItem.__init__(self.font,self.text,self.pos,self.pos2,color,self.text_size) + class Progressbar(TouchObject, TextItem): def __init__(self,font,text, pos, pos2, max,size, value_text): diff --git a/mopidy_touchscreen/touch_manager.py b/mopidy_touchscreen/touch_manager.py index c3563a2..fd27757 100644 --- a/mopidy_touchscreen/touch_manager.py +++ b/mopidy_touchscreen/touch_manager.py @@ -39,10 +39,8 @@ class TouchManager(): elif abs(self.down_pos[1] - self.up_pos[1]) > self.min_swipe_move: return TouchEvent(TouchManager.swipe, self.down_pos, self.up_pos, True) elif self.down_pos[1] - self.up_pos[1] < self.max_move_margin: - logger.error("hemen nago") logger.error( abs(self.down_pos[1] - self.up_pos[1])) if abs(self.down_pos[0] - self.up_pos[0]) > self.min_swipe_move: - logger.error("kaixo") return TouchEvent(TouchManager.swipe, self.down_pos, self.up_pos, False) diff --git a/mopidy_touchscreen/touch_screen.py b/mopidy_touchscreen/touch_screen.py index e450c1f..cea82ba 100644 --- a/mopidy_touchscreen/touch_screen.py +++ b/mopidy_touchscreen/touch_screen.py @@ -20,8 +20,8 @@ class TouchScreen(pykka.ThreadingActor, core.CoreListener): logger.error(self.backend) self.core = core self.running = False - self.screen_size=(320, 240) - #self.screen_size=(800, 600) + #self.screen_size=(320, 240) + self.screen_size=(800, 600) pygame.init() self.screen_manager = ScreenManager(self.screen_size,self.core, self.backend) diff --git a/mopidy_touchscreen/touch_screen_backend.py b/mopidy_touchscreen/touch_screen_backend.py index dcb8dc1..67e61af 100644 --- a/mopidy_touchscreen/touch_screen_backend.py +++ b/mopidy_touchscreen/touch_screen_backend.py @@ -12,7 +12,10 @@ class TouchScreenBackend(pykka.ThreadingActor, backend.Backend): logger.error("backend funciona") def on_receive(self, message): - logger.error("heldu naiz") - if message['action'] == 'volume': - logger.error("bolumena aldatzen") - self.audio.set_volume(message['value']) \ No newline at end of file + action = message['action'] + if action == 'volume': + self.audio.set_volume(message['value']) + elif action == "mute": + self.audio.set_mute(message['value']) + elif action == "random": + self.audio.set_random(message['value']) \ No newline at end of file