Compare commits
31 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 4ad8806fd1 | |||
| 36c55c08f8 | |||
| b65944ab37 | |||
| 93983bc2f5 | |||
| 1912b4e4af | |||
| f0fa9c8e56 | |||
| f762a10a62 | |||
| 843dda5570 | |||
| 19082db55a | |||
| 7e585ccfe4 | |||
| 41f7a04010 | |||
| 200339dddb | |||
| 5dd47f599b | |||
| cb5b3e21ee | |||
| 2898fdbf68 | |||
| f498099b12 | |||
| d8807f9386 | |||
| 1454e43bcb | |||
| 3ace6b098b | |||
| 28584e361d | |||
| c25c74a0bc | |||
| bf65f35f32 | |||
| 7f83440229 | |||
| 0863125269 | |||
| 93d9f22b10 | |||
| dcba607fc0 | |||
| b6c142a2b9 | |||
| f1961ee5d6 | |||
| ce9261f409 | |||
| 76b411388b | |||
| e7b3c881d0 |
@@ -1,7 +1,9 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import pygame
|
||||
import commands
|
||||
import commands
|
||||
import shutil
|
||||
import os
|
||||
|
||||
from libs.roundrects import aa_round_rect
|
||||
from UI.constants import Width,Height,ICON_TYPES
|
||||
@@ -15,9 +17,105 @@ from UI.icon_pool import MyIconPool
|
||||
from UI.icon_item import IconItem
|
||||
from UI.multi_icon_item import MultiIconItem
|
||||
from UI.multilabel import MultiLabel
|
||||
from UI.confirm_page import ConfirmPage
|
||||
|
||||
class UpdateConfirmPage(ConfirmPage):
|
||||
_ConfirmText = "Apply to RetroArch?"
|
||||
_RetroArchConf = "/home/cpi/.config/retroarch/retroarch.cfg"
|
||||
_LayoutMode = "Unknown"
|
||||
|
||||
def ModifyRetroArchConf(self,keys):
|
||||
|
||||
try:
|
||||
with open(self._RetroArchConf, mode="r") as f:
|
||||
confarr = f.readlines()
|
||||
except:
|
||||
return "retroarch.cfg cannot open."
|
||||
|
||||
bka = bkb = bkx = bky = False
|
||||
try:
|
||||
for i, ln in enumerate(confarr):
|
||||
lnk = ln.split("=")[0].strip()
|
||||
if lnk == "input_player1_a":
|
||||
confarr[i] = "input_player1_a = \"" + keys[0] + "\"\n"
|
||||
bka = True
|
||||
if lnk == "input_player1_b":
|
||||
confarr[i] = "input_player1_b = \"" + keys[1] + "\"\n"
|
||||
bkb = True
|
||||
if lnk == "input_player1_x":
|
||||
confarr[i] = "input_player1_x = \"" + keys[2] + "\"\n"
|
||||
bkx = True
|
||||
if lnk == "input_player1_y":
|
||||
confarr[i] = "input_player1_y = \"" + keys[3] + "\"\n"
|
||||
bky = True
|
||||
except:
|
||||
return "retroarch.cfg cannot parse."
|
||||
|
||||
if bka and bkb and bkx and bky:
|
||||
None
|
||||
else:
|
||||
return "retroarch.cfg validation error."
|
||||
|
||||
try:
|
||||
with open(self._RetroArchConf, mode="w") as f:
|
||||
confarr = f.writelines(confarr)
|
||||
except:
|
||||
return "retroarch.cfg cannot write."
|
||||
|
||||
return "Completed! Your RA keymap: " + self._LayoutMode.upper()
|
||||
|
||||
def KeyDown(self,event):
|
||||
|
||||
def finalizeWithDialog(msg):
|
||||
self._Screen._MsgBox.SetText(msg)
|
||||
self._Screen._MsgBox.Draw()
|
||||
self._Screen.SwapAndShow()
|
||||
return
|
||||
|
||||
if event.key == CurKeys["Menu"] or event.key == CurKeys["A"]:
|
||||
self.ReturnToUpLevelPage()
|
||||
self._Screen.Draw()
|
||||
self._Screen.SwapAndShow()
|
||||
|
||||
if event.key == CurKeys["B"]:
|
||||
|
||||
if self._LayoutMode == "xbox":
|
||||
keymap = ["j","k","u","i"]
|
||||
elif self._LayoutMode == "snes":
|
||||
keymap = ["k","j","i","u"]
|
||||
else:
|
||||
finalizeWithDialog("Internal error.")
|
||||
return
|
||||
print("mode: " + self._LayoutMode)
|
||||
|
||||
if not os.path.isfile(self._RetroArchConf):
|
||||
finalizeWithDialog("retroarch.cfg was not found.")
|
||||
return
|
||||
|
||||
try:
|
||||
shutil.copyfile(self._RetroArchConf, self._RetroArchConf + ".blbak")
|
||||
except:
|
||||
finalizeWithDialog("Cannot create .blbak")
|
||||
return
|
||||
|
||||
finalizeWithDialog(self.ModifyRetroArchConf(keymap))
|
||||
return
|
||||
|
||||
def OnReturnBackCb(self):
|
||||
self.ReturnToUpLevelPage()
|
||||
self._Screen.Draw()
|
||||
self._Screen.SwapAndShow()
|
||||
|
||||
def Draw(self):
|
||||
self.ClearCanvas()
|
||||
self.DrawBG()
|
||||
for i in self._MyList:
|
||||
i.Draw()
|
||||
|
||||
self.Reset()
|
||||
|
||||
class ButtonsLayoutPage(Page):
|
||||
_FootMsg = ["Nav.","","","Back","Toggle"]
|
||||
_FootMsg = ["Nav.","UpdateRetroArch","","Back","Toggle"]
|
||||
_MyList = []
|
||||
_ListFontObj = fonts["varela13"]
|
||||
|
||||
@@ -30,6 +128,7 @@ class ButtonsLayoutPage(Page):
|
||||
|
||||
_DrawOnce = False
|
||||
_Scroller = None
|
||||
_ConfirmPage = None
|
||||
|
||||
_EasingDur = 30
|
||||
|
||||
@@ -72,6 +171,14 @@ class ButtonsLayoutPage(Page):
|
||||
self._Scroller.Init()
|
||||
self._Scroller.SetCanvasHWND(self._HWND)
|
||||
|
||||
self._ConfirmPage = UpdateConfirmPage()
|
||||
self._ConfirmPage._LayoutMode = self.GetButtonsLayoutMode()
|
||||
self._ConfirmPage._Screen = self._Screen
|
||||
self._ConfirmPage._Name = "Overwrite RA conf"
|
||||
self._ConfirmPage._Parent = self
|
||||
self._ConfirmPage.Init()
|
||||
|
||||
|
||||
def ScrollDown(self):
|
||||
dis = 10
|
||||
if abs(self._Scrolled) < (self._BGheight - self._Height)/2 + 0:
|
||||
@@ -137,6 +244,12 @@ class ButtonsLayoutPage(Page):
|
||||
|
||||
if event.key == CurKeys["B"]:
|
||||
self.ToggleMode()
|
||||
|
||||
if event.key == CurKeys["X"]:
|
||||
self._ConfirmPage._LayoutMode = self.GetButtonsLayoutMode()
|
||||
self._Screen.PushPage(self._ConfirmPage)
|
||||
self._Screen.Draw()
|
||||
self._Screen.SwapAndShow()
|
||||
|
||||
def Draw(self):
|
||||
self.ClearCanvas()
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import pygame
|
||||
|
||||
## local UI import
|
||||
import pages
|
||||
import myvars
|
||||
|
||||
def Init(main_screen):
|
||||
pages.InitTimezoneListPage(main_screen)
|
||||
|
||||
def API(main_screen):
|
||||
if main_screen !=None:
|
||||
main_screen.PushCurPage()
|
||||
main_screen.SetCurPage(myvars.TimezoneListPage)
|
||||
main_screen.Draw()
|
||||
main_screen.SwapAndShow()
|
||||
|
||||
|
||||
@@ -0,0 +1,112 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import pygame
|
||||
from libs.roundrects import aa_round_rect
|
||||
|
||||
## local UI import
|
||||
from UI.constants import ICON_TYPES
|
||||
from UI.page import Page
|
||||
from UI.label import Label
|
||||
from UI.fonts import fonts
|
||||
from UI.icon_item import IconItem
|
||||
from UI.util_funcs import midRect
|
||||
|
||||
# a item for List
|
||||
# - - - - - - - - - - - --
|
||||
# | Icon Text..... > |
|
||||
# ------------------------
|
||||
|
||||
import myvars # icons_path
|
||||
|
||||
class ListItemIcon(IconItem):
|
||||
|
||||
_CanvasHWND = None
|
||||
_Parent = None
|
||||
_Width = 18
|
||||
_Height = 18
|
||||
|
||||
def Draw(self):
|
||||
self._CanvasHWND.blit(self._ImgSurf,(self._PosX,self._PosY+(self._Parent._Height-self._Height)/2,self._Width,self._Height))
|
||||
|
||||
|
||||
class ListItemLabel(Label):
|
||||
|
||||
_ActiveColor = pygame.Color(175,90,0)
|
||||
_Active = False
|
||||
def Draw(self):
|
||||
|
||||
self._FontObj.set_bold(self._Active)
|
||||
|
||||
my_text = self._FontObj.render( self._Text,True,self._Color)
|
||||
self._CanvasHWND.blit(my_text,(self._PosX,self._PosY,self._Width,self._Height))
|
||||
|
||||
|
||||
class ListItem(object):
|
||||
_PosX = 0
|
||||
_PosY = 0
|
||||
_Width = 0
|
||||
_Height = 30
|
||||
|
||||
_Labels = {}
|
||||
_Icons = {}
|
||||
_Fonts = {}
|
||||
_MyType = ICON_TYPES["EXE"]
|
||||
_LinkObj = None
|
||||
_Path = ""
|
||||
_Active = False
|
||||
_Parent = None
|
||||
|
||||
_Text = ""
|
||||
def __init__(self):
|
||||
self._Labels = {}
|
||||
self._Icons = {}
|
||||
self._Fonts = {}
|
||||
|
||||
|
||||
def Init(self,text):
|
||||
|
||||
self._Text = text
|
||||
|
||||
l = ListItemLabel()
|
||||
l._PosX = 22
|
||||
l.SetCanvasHWND(self._Parent._CanvasHWND)
|
||||
|
||||
if self._MyType == ICON_TYPES["DIR"]:
|
||||
l.Init(text,self._Fonts["normal"])
|
||||
self._Path = text
|
||||
else:
|
||||
l.Init(text,self._Fonts["normal"])
|
||||
self._Path = text
|
||||
|
||||
|
||||
self._Labels["Text"] = l
|
||||
|
||||
|
||||
def NewCoord(self,x,y):
|
||||
self._PosX = x
|
||||
self._PosY = y
|
||||
|
||||
def Draw(self):
|
||||
|
||||
if self._MyType == ICON_TYPES["DIR"] and self._Path != "[..]":
|
||||
self._Parent._Icons["sys"]._IconIndex = 0
|
||||
self._Parent._Icons["sys"].NewCoord(self._PosX+12,self._PosY+ (self._Height - self._Parent._Icons["sys"]._Height)/2+self._Parent._Icons["sys"]._Height/2)
|
||||
self._Parent._Icons["sys"].Draw()
|
||||
|
||||
if self._MyType == ICON_TYPES["FILE"]:
|
||||
self._Parent._Icons["sys"]._IconIndex = 1
|
||||
self._Parent._Icons["sys"].NewCoord(self._PosX+12,self._PosY+ (self._Height - self._Parent._Icons["sys"]._Height)/2+self._Parent._Icons["sys"]._Height/2)
|
||||
self._Parent._Icons["sys"].Draw()
|
||||
|
||||
if self._Active == True:
|
||||
self._Labels["Text"]._Active = True
|
||||
else:
|
||||
self._Labels["Text"]._Active = False
|
||||
|
||||
|
||||
self._Labels["Text"]._PosY = self._PosY + (self._Height - self._Labels["Text"]._Height)/2
|
||||
|
||||
pygame.draw.line(self._Parent._CanvasHWND,(169,169,169),(self._PosX,self._PosY+self._Height-1),(self._PosX+self._Width,self._PosY+self._Height-1),1)
|
||||
|
||||
self._Labels["Text"].Draw()
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
import logzero
|
||||
|
||||
def get_logger():
|
||||
# Set a custom formatter
|
||||
log_format = '%(color)s[%(levelname)1.1s ' \
|
||||
'%(asctime)s.%(msecs)03d %(module)s:%(lineno)d]' \
|
||||
'%(end_color)s %(message)s'
|
||||
formatter = logzero.LogFormatter(fmt=log_format)
|
||||
logzero.setup_default_logger(formatter=formatter)
|
||||
|
||||
logzero.logfile(
|
||||
'logzero.log',
|
||||
maxBytes=1e6,
|
||||
backupCount=3
|
||||
)
|
||||
return logzero.logger
|
||||
@@ -0,0 +1,5 @@
|
||||
|
||||
|
||||
TimePage = None
|
||||
TimezoneListPage = None
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from timezone_lib_list_page import TimezoneListPage
|
||||
import myvars
|
||||
|
||||
def InitTimePage(main_screen):
|
||||
myvars.TimePage = None
|
||||
|
||||
def InitTimezoneListPage(main_screen):
|
||||
myvars.TimezoneListPage = TimezoneListPage()
|
||||
myvars.TimezoneListPage._Screen = main_screen
|
||||
myvars.TimezoneListPage._Name = "Timezone Selection"
|
||||
myvars.TimezoneListPage.Init()
|
||||
@@ -0,0 +1,333 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import os
|
||||
import subprocess
|
||||
import pygame
|
||||
|
||||
from libs.roundrects import aa_round_rect
|
||||
|
||||
## local UI import
|
||||
from UI.constants import Width,Height,ICON_TYPES
|
||||
from UI.page import Page,PageSelector
|
||||
from UI.label import Label
|
||||
from UI.fonts import fonts
|
||||
from UI.icon_item import IconItem
|
||||
from UI.util_funcs import midRect
|
||||
from UI.keys_def import CurKeys
|
||||
from UI.multi_icon_item import MultiIconItem
|
||||
from UI.icon_pool import MyIconPool
|
||||
from UI.scroller import ListScroller
|
||||
|
||||
from list_item import ListItem
|
||||
|
||||
|
||||
import myvars
|
||||
|
||||
|
||||
class TimeLibStack:
|
||||
def __init__(self):
|
||||
self.stack = list()
|
||||
|
||||
def Push(self,data):
|
||||
if data not in self.stack:
|
||||
self.stack.append(data)
|
||||
return True
|
||||
return False
|
||||
|
||||
def Pop(self):
|
||||
if len(self.stack)<=0:
|
||||
return None,False
|
||||
return self.stack.pop(),True
|
||||
|
||||
def Last(self):
|
||||
idx = len(self.stack) -1
|
||||
if idx < 0:
|
||||
return "/usr/share/zoneinfo/posix"
|
||||
else:
|
||||
return self.stack[ idx ]
|
||||
|
||||
def Length(self):
|
||||
return len(self.stack)
|
||||
|
||||
class ListPageSelector(PageSelector):
|
||||
_BackgroundColor = pygame.Color(131,199,219)
|
||||
|
||||
def __init__(self):
|
||||
self._PosX = 0
|
||||
self._PosY = 0
|
||||
self._Height = 0
|
||||
self._Width = Width
|
||||
|
||||
def AnimateDraw(self,x2,y2):
|
||||
pass
|
||||
|
||||
def Draw(self):
|
||||
idx = self._Parent._PsIndex
|
||||
|
||||
if idx < len(self._Parent._MyList):
|
||||
x = self._Parent._MyList[idx]._PosX+2
|
||||
y = self._Parent._MyList[idx]._PosY+1
|
||||
h = self._Parent._MyList[idx]._Height -3
|
||||
|
||||
self._PosX = x
|
||||
self._PosY = y
|
||||
self._Height = h
|
||||
|
||||
aa_round_rect(self._Parent._CanvasHWND,
|
||||
(x,y,self._Width-4,h),self._BackgroundColor,4,0,self._BackgroundColor)
|
||||
|
||||
|
||||
|
||||
class TimezoneListPage(Page):
|
||||
|
||||
_Icons = {}
|
||||
_Selector=None
|
||||
_FootMsg = ["Nav","","","Back","Select"]
|
||||
_MyList = []
|
||||
_SwapMyList = []
|
||||
_ListFont = fonts["notosanscjk15"]
|
||||
_MyStack = None
|
||||
|
||||
_Scroller = None
|
||||
|
||||
_BGpng = None
|
||||
_BGwidth = 56
|
||||
_BGheight = 70
|
||||
|
||||
def __init__(self):
|
||||
Page.__init__(self)
|
||||
self._Icons = {}
|
||||
self._CanvasHWND = None
|
||||
self._MyList = []
|
||||
self._SwapMyList = []
|
||||
self._MyStack = TimeLibStack()
|
||||
|
||||
def buildDirectoryList(self, path):
|
||||
elements = [
|
||||
{
|
||||
'name': f,
|
||||
'file_path': os.path.join(path, f),
|
||||
'is_file': os.path.isfile(os.path.join(path, f))
|
||||
}
|
||||
for f in os.listdir(path)
|
||||
]
|
||||
return elements
|
||||
|
||||
def SyncList(self,path):
|
||||
|
||||
alist = self.buildDirectoryList(path)
|
||||
if not alist:
|
||||
print("buildDirectoryList empty")
|
||||
return
|
||||
|
||||
self._MyList = []
|
||||
self._SwapMyList = []
|
||||
|
||||
start_x = 0
|
||||
start_y = 0
|
||||
hasparent = 0
|
||||
if self._MyStack.Length() > 0:
|
||||
hasparent = 1
|
||||
li = ListItem()
|
||||
li._Parent = self
|
||||
li._PosX = start_x
|
||||
li._PosY = start_y
|
||||
li._Width = Width
|
||||
li._Fonts["normal"] = self._ListFont
|
||||
li._MyType = ICON_TYPES["DIR"]
|
||||
li.Init("[..]")
|
||||
self._MyList.append(li)
|
||||
|
||||
for i,v in enumerate(sorted(alist)):
|
||||
li = ListItem()
|
||||
li._Parent = self
|
||||
li._PosX = start_x
|
||||
li._PosY = start_y + (i+hasparent)*ListItem._Height
|
||||
li._Width = Width
|
||||
li._Fonts["normal"] = self._ListFont
|
||||
li._MyType = ICON_TYPES["FILE"]
|
||||
|
||||
if not v['is_file']:
|
||||
li._MyType = ICON_TYPES["DIR"]
|
||||
else:
|
||||
li._MyType = ICON_TYPES["FILE"]
|
||||
|
||||
li.Init( v['name'] )
|
||||
li._Path = v["file_path"]
|
||||
|
||||
|
||||
self._MyList.append(li)
|
||||
|
||||
for i in self._MyList:
|
||||
self._SwapMyList.append(i)
|
||||
|
||||
def Init(self):
|
||||
self._PosX = self._Index * self._Screen._Width
|
||||
self._Width = self._Screen._Width
|
||||
self._Height = self._Screen._Height
|
||||
|
||||
self._CanvasHWND = self._Screen._CanvasHWND
|
||||
|
||||
ps = ListPageSelector()
|
||||
ps._Parent = self
|
||||
self._Ps = ps
|
||||
self._PsIndex = 0
|
||||
|
||||
self.SyncList("/usr/share/zoneinfo/posix")
|
||||
|
||||
icon_for_list = MultiIconItem()
|
||||
icon_for_list._ImgSurf = MyIconPool._Icons["sys"]
|
||||
icon_for_list._MyType = ICON_TYPES["STAT"]
|
||||
icon_for_list._Parent = self
|
||||
|
||||
icon_for_list.Adjust(0,0,18,18,0)
|
||||
self._Icons["sys"] = icon_for_list
|
||||
|
||||
|
||||
self._BGpng = IconItem()
|
||||
self._BGpng._ImgSurf = MyIconPool._Icons["empty"]
|
||||
self._BGpng._MyType = ICON_TYPES["STAT"]
|
||||
self._BGpng._Parent = self
|
||||
self._BGpng.AddLabel("No timezones found on system!", fonts["varela22"])
|
||||
self._BGpng.SetLableColor(pygame.Color(204,204,204))
|
||||
self._BGpng.Adjust(0,0,self._BGwidth,self._BGheight,0)
|
||||
|
||||
|
||||
self._Scroller = ListScroller()
|
||||
self._Scroller._Parent = self
|
||||
self._Scroller._PosX = self._Width - 10
|
||||
self._Scroller._PosY = 2
|
||||
self._Scroller.Init()
|
||||
|
||||
|
||||
def ScrollUp(self,Step=1):
|
||||
if len(self._MyList) == 0:
|
||||
return
|
||||
tmp = self._PsIndex
|
||||
self._PsIndex -= Step
|
||||
|
||||
if self._PsIndex < 0:
|
||||
self._PsIndex = 0
|
||||
dy = tmp-self._PsIndex
|
||||
cur_li = self._MyList[self._PsIndex]
|
||||
if cur_li._PosY < 0:
|
||||
for i in range(0, len(self._MyList)):
|
||||
self._MyList[i]._PosY += self._MyList[i]._Height*dy
|
||||
|
||||
|
||||
def ScrollDown(self,Step=1):
|
||||
if len(self._MyList) == 0:
|
||||
return
|
||||
tmp = self._PsIndex
|
||||
self._PsIndex +=Step
|
||||
if self._PsIndex >= len(self._MyList):
|
||||
self._PsIndex = len(self._MyList) -1
|
||||
dy = self._PsIndex - tmp
|
||||
cur_li = self._MyList[self._PsIndex]
|
||||
if cur_li._PosY +cur_li._Height > self._Height:
|
||||
for i in range(0,len(self._MyList)):
|
||||
self._MyList[i]._PosY -= self._MyList[i]._Height*dy
|
||||
|
||||
def Click(self):
|
||||
if len(self._MyList) == 0:
|
||||
return
|
||||
|
||||
cur_li = self._MyList[self._PsIndex]
|
||||
|
||||
if cur_li._MyType == ICON_TYPES["DIR"]:
|
||||
if cur_li._Path == "[..]":
|
||||
self._MyStack.Pop()
|
||||
self.SyncList( self._MyStack.Last() )
|
||||
self._PsIndex = 0
|
||||
else:
|
||||
self._MyStack.Push( self._MyList[self._PsIndex]._Path )
|
||||
self.SyncList( self._MyStack.Last() )
|
||||
self._PsIndex = 0
|
||||
|
||||
if cur_li._MyType == ICON_TYPES["FILE"]: ## set the current timezone
|
||||
subprocess.call(['sudo', 'cp', cur_li._Path, '/etc/localtime'])
|
||||
#copyfile(cur_li._Path, '/etc/localtime')
|
||||
print("add" , cur_li._Path)
|
||||
|
||||
self._Screen.Draw()
|
||||
self._Screen.SwapAndShow()
|
||||
|
||||
def Rescan(self):
|
||||
self.SyncList("/usr/share/zoneinfo/posix")
|
||||
self._PsIndex = 0
|
||||
|
||||
def KeyDown(self,event):
|
||||
|
||||
if event.key == CurKeys["Menu"] or event.key == CurKeys["A"]:
|
||||
|
||||
self.ReturnToUpLevelPage()
|
||||
self._Screen.Draw()
|
||||
self._Screen.SwapAndShow()
|
||||
|
||||
if event.key == CurKeys["Up"]:
|
||||
self.ScrollUp()
|
||||
self._Screen.Draw()
|
||||
self._Screen.SwapAndShow()
|
||||
if event.key == CurKeys["Down"]:
|
||||
self.ScrollDown()
|
||||
self._Screen.Draw()
|
||||
self._Screen.SwapAndShow()
|
||||
|
||||
if event.key == CurKeys["Right"]:
|
||||
self.ScrollDown(Step=5)
|
||||
self._Screen.Draw()
|
||||
self._Screen.SwapAndShow()
|
||||
|
||||
if event.key == CurKeys["Left"]:
|
||||
self.ScrollUp(Step=5)
|
||||
self._Screen.Draw()
|
||||
self._Screen.SwapAndShow()
|
||||
|
||||
if event.key == CurKeys["Enter"]:
|
||||
self.Click()
|
||||
|
||||
def Draw(self):
|
||||
self.ClearCanvas()
|
||||
|
||||
if len(self._MyList) == 0:
|
||||
self._BGpng.NewCoord(self._Width/2,self._Height/2)
|
||||
self._BGpng.Draw()
|
||||
return
|
||||
|
||||
else:
|
||||
if len(self._MyList) * ListItem._Height > self._Height:
|
||||
self._Ps._Width = self._Width - 11
|
||||
|
||||
self._Ps.Draw()
|
||||
for i in self._MyList:
|
||||
if False:
|
||||
i._Active = True
|
||||
else:
|
||||
i._Active = False
|
||||
|
||||
if i._PosY > self._Height + self._Height/2:
|
||||
break
|
||||
|
||||
if i._PosY < 0:
|
||||
continue
|
||||
|
||||
i.Draw()
|
||||
|
||||
self._Scroller.UpdateSize( len(self._MyList)*ListItem._Height, self._PsIndex*ListItem._Height)
|
||||
self._Scroller.Draw()
|
||||
else:
|
||||
self._Ps._Width = self._Width
|
||||
self._Ps.Draw()
|
||||
for i in self._MyList:
|
||||
if False:
|
||||
i._Active = True
|
||||
else:
|
||||
i._Active = False
|
||||
|
||||
if i._PosY > self._Height + self._Height/2:
|
||||
break
|
||||
|
||||
if i._PosY < 0:
|
||||
continue
|
||||
|
||||
i.Draw()
|
||||
@@ -82,6 +82,7 @@ class ListPage(Page):
|
||||
["","Sound","Sound Volume"],
|
||||
["","Brightness","BackLight Brightness"],
|
||||
["","Storage",""],
|
||||
["","Time","Timezone"],
|
||||
["","Update", ""],
|
||||
["","About", "About"],
|
||||
["","PowerOFF","Power off"],
|
||||
|
||||
@@ -3,4 +3,4 @@ ROM_SO=/home/cpi/apps/emulators/mame2003_plus_libretro.so
|
||||
EXT=zip
|
||||
LAUNCHER=retroarch -L
|
||||
TITLE=MAME Roms
|
||||
SO_URL=http://buildbot.libretro.com/nightly/linux/armhf/latest/mame2003_plus_libretro.so.zip
|
||||
SO_URL=https://raw.githubusercontent.com/cuu/emulators/master/mame2003_plus_libretro.so.zip
|
||||
File diff suppressed because it is too large
Load Diff
@@ -3,4 +3,4 @@ ROM_SO=/home/cpi/apps/emulators/mgba_libretro.so
|
||||
EXT=gba,gbx
|
||||
LAUNCHER=retroarch -L
|
||||
TITLE=MGBA Roms
|
||||
SO_URL=http://buildbot.libretro.com/nightly/linux/armhf/latest/mgba_libretro.so.zip
|
||||
SO_URL=https://raw.githubusercontent.com/cuu/emulators/master/mgba_libretro.so.zip
|
||||
|
||||
@@ -3,5 +3,5 @@ ROM_SO=/home/cpi/apps/emulators/nestopia_libretro.so
|
||||
EXT=zip,nes
|
||||
LAUNCHER=retroarch -L
|
||||
TITLE=NESTOPIA Roms
|
||||
SO_URL=http://buildbot.libretro.com/nightly/linux/armhf/latest/nestopia_libretro.so.zip
|
||||
SO_URL=https://raw.githubusercontent.com/cuu/emulators/master/nestopia_libretro.so.zip
|
||||
|
||||
|
||||
@@ -34,21 +34,27 @@ class PIFI(object):
|
||||
_FIRST_SELECTED_BIN = 5
|
||||
_NUMBER_OF_SELECTED_BINS = 1024
|
||||
|
||||
_samples_buffer = None
|
||||
|
||||
def __init__(self):
|
||||
self.sampleSize = self._SAMPLE_SIZE
|
||||
self.samplingRate = self._SAMPLING_RATE
|
||||
|
||||
def GetSpectrum(self,fifoFile,trim_by=10,log_scale=False,div_by=100):
|
||||
def GetSpectrum(self,fifoFile,trim_by=4,log_scale=False,div_by=100):
|
||||
try:
|
||||
rawSamples = os.read(fifoFile,self.sampleSize) # will return empty lines (non-blocking)
|
||||
if len(rawSamples) < 1:
|
||||
# print("Read error")
|
||||
return rawSamples
|
||||
# print("Read error")
|
||||
pass
|
||||
else:
|
||||
self._samples_buffer = rawSamples
|
||||
except Exception,e:
|
||||
pass
|
||||
|
||||
if self._samples_buffer == None:
|
||||
return ""
|
||||
|
||||
data = numpy.fromstring(rawSamples, dtype=numpy.int16)
|
||||
|
||||
data = numpy.fromstring(self._samples_buffer, dtype=numpy.int16)
|
||||
|
||||
data = data * numpy.hanning(len(data))
|
||||
|
||||
@@ -201,7 +207,7 @@ class MPDSpectrumPage(Page):
|
||||
#print("sleeping... 0.01")
|
||||
time.sleep(0.01)
|
||||
self.read_retry+=1
|
||||
if self.read_retry > 40:
|
||||
if self.read_retry > 20:
|
||||
os.close(self._FIFO)
|
||||
self._FIFO = os.open(self._PIFI._MPD_FIFO, os.O_RDONLY | os.O_NONBLOCK)
|
||||
self.read_retry = 0
|
||||
@@ -354,12 +360,14 @@ class MPDSpectrumPage(Page):
|
||||
if len(spects) == 0:
|
||||
return
|
||||
# print("spects:",spects)
|
||||
|
||||
step = int( round( len( spects ) / meterNum) )
|
||||
|
||||
# print(len(spects))
|
||||
self._bbs = []
|
||||
|
||||
a = numpy.logspace(0, 1, num=meterNum,endpoint=True)
|
||||
|
||||
for i in range(0,meterNum):
|
||||
index = int(i*step)
|
||||
index = int(a[i] * step)
|
||||
total = 0
|
||||
|
||||
value = spects[index]
|
||||
@@ -379,7 +387,7 @@ class MPDSpectrumPage(Page):
|
||||
value = 0
|
||||
|
||||
value = value/32768.0
|
||||
value = value * 100
|
||||
value = value * 123
|
||||
value = value % (self._Height-gap-margin_bottom)
|
||||
|
||||
if len(self._vis_values) < len(self._bby):
|
||||
@@ -389,7 +397,8 @@ class MPDSpectrumPage(Page):
|
||||
self._vis_values[i] = value
|
||||
|
||||
|
||||
except Empty:
|
||||
except Exception,e:
|
||||
print(e)
|
||||
return
|
||||
else: # got line
|
||||
if len(self._vis_values) == 0:
|
||||
|
||||
@@ -11,8 +11,8 @@ import config
|
||||
|
||||
class PowerOffConfirmPage(ConfirmPage):
|
||||
|
||||
_ConfirmText = "Confirm Power OFF?"
|
||||
|
||||
_ConfirmText = "Awaiting Input"
|
||||
_FootMsg = ["Nav","Reboot","","Cancel","Shutdown"]
|
||||
|
||||
def CheckBattery(self):
|
||||
try:
|
||||
@@ -59,7 +59,12 @@ class PowerOffConfirmPage(ConfirmPage):
|
||||
|
||||
cmdpath += "sudo halt -p"
|
||||
pygame.event.post( pygame.event.Event(RUNSYS, message=cmdpath))
|
||||
|
||||
|
||||
if event.key == CurKeys["X"]:
|
||||
cmdpath = "feh --bg-center gameshell/wallpaper/seeyou.png;"
|
||||
cmdpath += "sleep 3;"
|
||||
cmdpath += "sudo reboot"
|
||||
pygame.event.post( pygame.event.Event(RUNSYS, message=cmdpath))
|
||||
|
||||
|
||||
class APIOBJ(object):
|
||||
|
||||
+1
-1
@@ -12,7 +12,7 @@ MPD_socket = "/tmp/mpd.socket"
|
||||
|
||||
UPDATE_URL="https://raw.githubusercontent.com/clockworkpi/CPI/master/launcher_ver.json"
|
||||
|
||||
VERSION="stable 1.2"
|
||||
VERSION="stable 1.21"
|
||||
|
||||
SKIN="default"
|
||||
|
||||
|
||||
+2
-2
@@ -422,7 +422,7 @@ def socket_thread(main_screen):
|
||||
if callable( current_page_key_down_cb ):
|
||||
main_screen._CurrentPage.KeyDown(escevent)
|
||||
|
||||
if tokens[0].lower() == "quit":
|
||||
if tokens[0].lower() == "quit": #eg: echo "quit" | socat - UNIX-CONNECT:/tmp/gameshell
|
||||
conn.close()
|
||||
on_exit_cb = getattr(main_screen,"OnExitCb",None)
|
||||
if on_exit_cb != None:
|
||||
@@ -488,7 +488,7 @@ def big_loop():
|
||||
gobject.timeout_add(3000,title_bar.GObjectRoundRobin)
|
||||
|
||||
|
||||
# socket_thread(main_screen)
|
||||
socket_thread(main_screen)
|
||||
|
||||
gobject_loop()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user