1
0

2 Commits de1c62eb4c ... ebe4cd2b5b

Autor SHA1 Nachricht Datum
  Matthias Ladkau ebe4cd2b5b feat: Drawing and keyboard input vor 5 Jahren
  Matthias Ladkau 77f939345e feat: Adding inital code for Musikautomat vor 5 Jahren

+ 9 - 0
.gitignore

@@ -0,0 +1,9 @@
+/musikautomat/bin
+/musikautomat/include
+/musikautomat/lib
+/musikautomat/lib64
+/musikautomat/share
+/musikautomat/pyvenv.cfg
+/musikautomat/.mypy_cache
+/musikautomat/__pycache__
+

+ 31 - 0
musikautomat/README.md

@@ -0,0 +1,31 @@
+Musikautomat
+--
+Simple graphical interface for mplayer.
+
+Setup:
+--
+Install:
+- mplayer
+- python3 (version >3.6)
+- python3-pip
+- python3-venv
+
+Setup virtual environment:
+```
+python3 -m venv .
+```
+
+Install dependencies:
+```
+./bin/pip3 install -r requirements.txt
+```
+
+Freeze dependencies:
+```
+./bin/pip3 freeze > requirements.txt
+```
+
+Type check:
+```
+./bin/mypy .
+```

+ 12 - 0
musikautomat/config.yml

@@ -0,0 +1,12 @@
+# Frame buffer device to use for output
+fbdev: /dev/fb2
+
+# Display resolution
+dimx: 128
+dimy: 160
+
+# Config for main display
+playlist: music.yml
+
+# Fontsize for drawing
+fontsize: 12

+ 48 - 0
musikautomat/display.py

@@ -0,0 +1,48 @@
+#!./bin/python3
+
+import yaml
+import pygame # type: ignore
+
+# Color constants
+
+BLACK = (0, 0, 0) 
+GREEN = (0, 255, 0) 
+
+class Display:
+    '''
+    Display object
+    '''
+    def __init__(self, config, pydsp):
+        
+        # Set config values
+        
+        self._dx = config.get("dimx", 128)
+        self._dy = config.get("dimy", 160)
+        self._playlistFile = config.get("playlist", "music.yml")
+        self._pydsp = pydsp # Pygame display object
+        self._fontsize = config.get("fontsize", 12)
+
+        # Set initialisation values
+
+        self._selection_pointer = 0 # Current selected value
+
+
+    def update(self):
+        '''
+        Load the data from the given config file.
+        '''
+        playlist = yaml.safe_load(open(self._playlistFile))
+
+        font = pygame.font.Font('freesansbold.ttf', self._fontsize)
+        drawline = 0 # Line currently drawm
+
+        for i, item in enumerate(playlist.get("playlist", [])):
+            print(item["name"])
+
+            if drawline == self._selection_pointer:
+                text = font.render(item["name"], True, BLACK, GREEN)
+            else:
+                text = font.render(item["name"], True, GREEN, BLACK)
+            
+            self._pydsp.blit(text, (0, drawline * self._fontsize))
+            drawline += 1

+ 56 - 0
musikautomat/main.py

@@ -0,0 +1,56 @@
+#!./bin/python3
+
+import sys, os, time
+import yaml
+
+# Include pygame without support prompt
+# Typing only available from version >= 2.0
+
+os.environ['PYGAME_HIDE_SUPPORT_PROMPT'] = "hide"
+import pygame # type: ignore
+
+from display import Display
+
+# Configuration
+
+config = yaml.safe_load(open("config.yml"))
+
+fbdev = config.get("fbdev", "/dev/fb1")
+dx = config.get("dimx", 128)
+dy = config.get("dimy", 160)
+
+# Initialise pygame
+
+os.environ["SDL_FBDEV"] = fbdev
+pygame.init()
+
+# Create the display
+
+pydsp = pygame.display.set_mode((dx, dy), 0, 32)
+pygame.display.set_caption("Musikautomat")
+pygame.mouse.set_visible(False)
+
+# Initialise state objects
+
+display = Display(config, pydsp)
+display.update()
+clk = pygame.time.Clock()
+
+# Run the game loop
+
+while True:
+    clk.tick(10) # We only need 10 FPS
+
+    for event in pygame.event.get():
+        if event.type == pygame.QUIT:
+            pygame.quit()
+            sys.exit()
+        if event.type == pygame.KEYDOWN:
+            if event.key == pygame.K_LEFT:
+                print("1")
+            if event.key == pygame.K_RIGHT:
+                print("2")
+
+
+
+    pygame.display.update()

+ 47 - 0
musikautomat/music.yml

@@ -0,0 +1,47 @@
+playlist:
+  - name: Domemucke
+    type: stream
+    url: bla
+  - name: Aerosmith
+    type: dir
+    path: foo
+  - name: Pantera
+    type: dir
+    path: foo
+
+  - name: Pantera1
+    type: dir
+    path: foo
+  - name: Pantera2
+    type: dir
+    path: foo
+  - name: Pantera3
+    type: dir
+    path: foo
+  - name: Pantera4
+    type: dir
+    path: foo
+  - name: Pantera5
+    type: dir
+    path: foo
+  - name: Pantera6
+    type: dir
+    path: foo
+  - name: Pantera7
+    type: dir
+    path: foo
+  - name: Pantera8
+    type: dir
+    path: foo
+  - name: Pantera9
+    type: dir
+    path: foo
+  - name: Pantera10
+    type: dir
+    path: foo
+  - name: Pantera11
+    type: dir
+    path: foo
+  - name: Pantera12
+    type: dir
+    path: foo

+ 7 - 0
musikautomat/requirements.txt

@@ -0,0 +1,7 @@
+mypy==0.740
+mypy-extensions==0.4.3
+pkg-resources==0.0.0
+pygame==2.0.0.dev6
+PyYAML==5.1.2
+typed-ast==1.4.0
+typing-extensions==3.7.4.1

display_test/install.txt → old/display_test/install.txt


display_test/test.py → old/display_test/test.py


streaming-client/v1/client.py → old/streaming-client/client.py


streaming-client/v1/install.txt → old/streaming-client/install.txt


streaming-client/v1/mplayer_ctl.py → old/streaming-client/mplayer_ctl.py


streaming-client/v1/web/index.html → old/streaming-client/web/index.html


streaming-client/v1/web/spectre/LICENSE → old/streaming-client/web/spectre/LICENSE


streaming-client/v1/web/spectre/spectre-exp.min.css → old/streaming-client/web/spectre/spectre-exp.min.css


streaming-client/v1/web/spectre/spectre-icons.min.css → old/streaming-client/web/spectre/spectre-icons.min.css


streaming-client/v1/web/spectre/spectre.min.css → old/streaming-client/web/spectre/spectre.min.css


streaming-client/v1/web/thumbnail/radio.xcf → old/streaming-client/web/thumbnail/radio.xcf


streaming-client/v1/web/thumbnail/radio_128.png → old/streaming-client/web/thumbnail/radio_128.png


streaming-client/v1/web/thumbnail/radio_16.gif → old/streaming-client/web/thumbnail/radio_16.gif


streaming-client/v1/web/thumbnail/radio_192.png → old/streaming-client/web/thumbnail/radio_192.png