|
@@ -31,6 +31,7 @@ from time import sleep
|
|
from urllib.parse import urlparse
|
|
from urllib.parse import urlparse
|
|
import subprocess
|
|
import subprocess
|
|
import hashlib
|
|
import hashlib
|
|
|
|
+import glob
|
|
|
|
|
|
# ABCMeta
|
|
# ABCMeta
|
|
from abc import ABCMeta, abstractmethod
|
|
from abc import ABCMeta, abstractmethod
|
|
@@ -115,6 +116,7 @@ class Message():
|
|
INDICATOR = 8 # 'indicate'
|
|
INDICATOR = 8 # 'indicate'
|
|
MPC_REPLY = 9 # 'mpc_reply'
|
|
MPC_REPLY = 9 # 'mpc_reply'
|
|
VOLUME = 10 # 'volume'
|
|
VOLUME = 10 # 'volume'
|
|
|
|
+ SYSMENU = 11 # 'sysmenu'
|
|
|
|
|
|
def __init__(self, sender, message, param):
|
|
def __init__(self, sender, message, param):
|
|
self.__sender = sender
|
|
self.__sender = sender
|
|
@@ -334,6 +336,62 @@ class Playlist(Worker):
|
|
return True
|
|
return True
|
|
return True
|
|
return True
|
|
|
|
|
|
|
|
+# system menu
|
|
|
|
+class SysMenu(Worker):
|
|
|
|
+
|
|
|
|
+ active = False
|
|
|
|
+
|
|
|
|
+ def __init__(self, pm):
|
|
|
|
+ super().__init__(pm)
|
|
|
|
+
|
|
|
|
+ def receiveMessage(self, message):
|
|
|
|
+ if message.getMessage() == Message.SYSMENU:
|
|
|
|
+ if self.active == False:
|
|
|
|
+ self.active = True
|
|
|
|
+ image = Image.new('RGB', (LCD.WIDTH, LCD.HEIGHT), 0)
|
|
|
|
+ jpfont = ImageFont.truetype(DEFAULT_FONT, 14, encoding="unic");
|
|
|
|
+ draw = ImageDraw.Draw(image)
|
|
|
|
+
|
|
|
|
+ draw.text((0,0) , '1:再起動' , font=jpfont, fill='#FFFFFF')
|
|
|
|
+ draw.text((0,16) , '2:シャットダウン', font=jpfont, fill='#FFFFFF')
|
|
|
|
+ draw.text((0,32) , '3:キャッシュ消去', font=jpfont, fill='#FFFFFF')
|
|
|
|
+ draw.text((0,144), '0:中止' , font=jpfont, fill='#FFFFFF')
|
|
|
|
+
|
|
|
|
+ item = LCDItem(image)
|
|
|
|
+ self.playermain.lcd.displayItem(item, lock=True)
|
|
|
|
+ return False
|
|
|
|
+
|
|
|
|
+ elif message.getMessage() == Message.RCONTROL and self.active:
|
|
|
|
+ c = message.getParam()
|
|
|
|
+ if c in '0123':
|
|
|
|
+ if c == '1': # reboot
|
|
|
|
+ os.system('/sbin/reboot')
|
|
|
|
+ self.active = False
|
|
|
|
+ self.sendMessage(Message(self, Message.MENUOFF, None ))
|
|
|
|
+ elif c == '2': # shutdown
|
|
|
|
+ os.system('/sbin/poweroff')
|
|
|
|
+ self.active = False
|
|
|
|
+ self.sendMessage(Message(self, Message.MENUOFF, None ))
|
|
|
|
+ elif c == '3': # cache clear
|
|
|
|
+ cache_dir = AlbumArt.TEMP_DIR
|
|
|
|
+ [os.remove(f) for f in glob.glob(cache_dir+'/*' )]
|
|
|
|
+ self.active = False
|
|
|
|
+ self.sendMessage(Message(self, Message.MENUOFF, None ))
|
|
|
|
+ elif c == '0': # cacnel
|
|
|
|
+ self.active = False
|
|
|
|
+ self.sendMessage(Message(self, Message.MENUOFF, None ))
|
|
|
|
+
|
|
|
|
+ elif c == 'menu': # メインメニューに戻る
|
|
|
|
+ self.active = False
|
|
|
|
+ self.playermain.lcd.release()
|
|
|
|
+ return True
|
|
|
|
+
|
|
|
|
+ if self.active == False:
|
|
|
|
+ self.playermain.lcd.release()
|
|
|
|
+ return False
|
|
|
|
+ return True
|
|
|
|
+ return True
|
|
|
|
+
|
|
|
|
|
|
# MainMenu Worker
|
|
# MainMenu Worker
|
|
class MainMenu(Worker):
|
|
class MainMenu(Worker):
|
|
@@ -404,8 +462,8 @@ class MainMenu(Worker):
|
|
draw.text((0,112), '8:アーティスト選択', font=font,fill='#FFFFFF')
|
|
draw.text((0,112), '8:アーティスト選択', font=font,fill='#FFFFFF')
|
|
|
|
|
|
draw.text((0,128), '9:DBアップデート', font=font,fill='#FFFFFF')
|
|
draw.text((0,128), '9:DBアップデート', font=font,fill='#FFFFFF')
|
|
|
|
+ draw.text((0,144), '0:システムメニュー', font=font,fill='#FFFFFF')
|
|
|
|
|
|
-# self.sendMessage(Message(self, Message.MENUON, None ))
|
|
|
|
item = LCDItem(image, pos=LCDItem.FULL)
|
|
item = LCDItem(image, pos=LCDItem.FULL)
|
|
self.playermain.lcd.displayItem(item,lock=True)
|
|
self.playermain.lcd.displayItem(item,lock=True)
|
|
self.active = True
|
|
self.active = True
|
|
@@ -468,6 +526,11 @@ class MainMenu(Worker):
|
|
self.sendMessage(Message(self, Message.MPC, {'command':'update', 'arg': None} ))
|
|
self.sendMessage(Message(self, Message.MPC, {'command':'update', 'arg': None} ))
|
|
self.active = False
|
|
self.active = False
|
|
self.sendMessage(Message(self, Message.MENUOFF, None ))
|
|
self.sendMessage(Message(self, Message.MENUOFF, None ))
|
|
|
|
+
|
|
|
|
+ elif c == '0': # sysmenu
|
|
|
|
+ self.sendMessage(Message(self, Message.SYSMENU, None))
|
|
|
|
+ self.active = False
|
|
|
|
+
|
|
if self.active == False:
|
|
if self.active == False:
|
|
self.playermain.lcd.release()
|
|
self.playermain.lcd.release()
|
|
return False
|
|
return False
|
|
@@ -1230,6 +1293,10 @@ class PlayerMain(Master, threading.Thread):
|
|
sw = Switches(self)
|
|
sw = Switches(self)
|
|
self.workers.append(sw)
|
|
self.workers.append(sw)
|
|
|
|
|
|
|
|
+ # SystemMenu
|
|
|
|
+ sm = SysMenu(self)
|
|
|
|
+ self.workers.append(sm)
|
|
|
|
+
|
|
# Playlist
|
|
# Playlist
|
|
ps = Playlist(self)
|
|
ps = Playlist(self)
|
|
self.workers.append(ps)
|
|
self.workers.append(ps)
|