mirror of
https://github.com/clockworkpi/launcher.git
synced 2025-12-13 02:08:50 +01:00
commit
a5e73a2cec
1
.gitignore
vendored
1
.gitignore
vendored
@ -2,4 +2,5 @@ retroarch-core-options.cfg
|
||||
*.lpl
|
||||
*.swp
|
||||
.bsv
|
||||
*.pyc
|
||||
sys.py/.powerlevel
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -373,6 +373,7 @@ class WifiList(Page):
|
||||
self._CanvasHWND = None
|
||||
|
||||
def ShowBox(self,msg):
|
||||
|
||||
self._MsgBox._Text = msg
|
||||
self._ShowingMessageBox = True
|
||||
self._Screen.Draw()
|
||||
@ -471,6 +472,7 @@ class WifiList(Page):
|
||||
self._PrevWicdState = state
|
||||
|
||||
def SetConnectingStatus(self,fast):
|
||||
|
||||
wireless_connecting = self._Wireless.CheckIfWirelessConnecting()
|
||||
|
||||
"""
|
||||
@ -526,6 +528,9 @@ class WifiList(Page):
|
||||
return True
|
||||
|
||||
def DbusDaemonStatusChangedSig(self,state=None,info=None):
|
||||
if self._Screen._CurrentPage != self:
|
||||
return
|
||||
|
||||
print("in DbusDaemonStatusChangedSig")
|
||||
"""
|
||||
dbus.UInt32(2L)
|
||||
|
||||
Binary file not shown.
@ -1 +0,0 @@
|
||||
balance_saving
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
116
sys.py/UI/counter_screen.py
Normal file
116
sys.py/UI/counter_screen.py
Normal file
@ -0,0 +1,116 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import pygame
|
||||
import gobject
|
||||
import commands
|
||||
## local package import
|
||||
from constants import Width,Height,RUNSYS
|
||||
from label import Label
|
||||
from fonts import fonts
|
||||
from full_screen import FullScreen
|
||||
|
||||
import config
|
||||
|
||||
class CounterScreen(FullScreen):
|
||||
|
||||
_CounterFont = fonts["varela120"]
|
||||
_TextFont1 = fonts["varela15"]
|
||||
_TextFont2 = fonts["varela12"]
|
||||
|
||||
_TopLabel = None
|
||||
_BottomLabel = None
|
||||
_NumberLabel = None
|
||||
|
||||
_BGColor = pygame.Color(0,0,0)
|
||||
_FGColor = pygame.Color(255,255,255)
|
||||
|
||||
_Counting = False
|
||||
_Number = 10
|
||||
_GobjectIntervalId = -1
|
||||
|
||||
_inter_counter = 0
|
||||
|
||||
def GObjectInterval(self):
|
||||
|
||||
self._inter_counter+=1
|
||||
|
||||
if self._Number == 0:
|
||||
self._Counting = False
|
||||
print("do the real shutdown")
|
||||
if config.CurKeySet != "PC":
|
||||
cmdpath = "feh --bg-center gameshell/wallpaper/seeyou.png;"
|
||||
cmdpath += "sleep 3;"
|
||||
cmdpath += "sudo halt -p"
|
||||
pygame.event.post( pygame.event.Event(RUNSYS, message=cmdpath))
|
||||
return False
|
||||
|
||||
if self._inter_counter >= 10:
|
||||
self._Number -= 1
|
||||
if self._Number < 0:
|
||||
self._Number = 0
|
||||
print("sub Number %d " % self._Number)
|
||||
self._inter_counter = 0
|
||||
|
||||
self.Draw()
|
||||
self.SwapAndShow()
|
||||
|
||||
|
||||
if self._inter_counter == 2:
|
||||
commands.getstatusoutput("echo 0 > /proc/driver/led1")
|
||||
#turn off
|
||||
|
||||
elif self._inter_counter == 7:
|
||||
commands.getstatusoutput("echo 1 > /proc/driver/led1")
|
||||
#turn on
|
||||
|
||||
return self._Counting
|
||||
|
||||
def StartCounter(self):
|
||||
if self._Counting == True:
|
||||
return
|
||||
|
||||
self._Number = 10
|
||||
self._Counting = True
|
||||
|
||||
self._GobjectIntervalId = gobject.timeout_add(100,self.GObjectInterval)
|
||||
|
||||
def StopCounter(self):
|
||||
if self._Counting == False:
|
||||
return
|
||||
self._Counting = False
|
||||
self._Number = 10
|
||||
commands.getstatusoutput("echo 0 > /proc/driver/led1")
|
||||
|
||||
if self._GobjectIntervalId != -1:
|
||||
gobject.source_remove(self._GobjectIntervalId)
|
||||
self._GobjectIntervalId = -1
|
||||
|
||||
def Init(self):
|
||||
self._CanvasHWND = pygame.Surface((self._Width,self._Height))
|
||||
self._TopLabel = Label()
|
||||
self._TopLabel.SetCanvasHWND(self._CanvasHWND)
|
||||
self._TopLabel.Init("System shutdown in", self._TextFont1, self._FGColor)
|
||||
|
||||
self._BottomLabel = Label()
|
||||
self._BottomLabel.SetCanvasHWND(self._CanvasHWND)
|
||||
self._BottomLabel.Init("Press any key to stop countdown", self._TextFont2, self._FGColor)
|
||||
|
||||
self._NumberLabel = Label()
|
||||
self._NumberLabel.SetCanvasHWND(self._CanvasHWND)
|
||||
self._NumberLabel.Init(str(self._Number), self._CounterFont, self._FGColor)
|
||||
|
||||
def Draw(self):
|
||||
self._CanvasHWND.fill( self._BGColor )
|
||||
|
||||
self._TopLabel.NewCoord(Width/2, 15)
|
||||
self._TopLabel.DrawCenter()
|
||||
|
||||
self._BottomLabel.NewCoord(Width/2, Height-15)
|
||||
self._BottomLabel.DrawCenter()
|
||||
|
||||
self._NumberLabel.NewCoord(Width/2,Height/2)
|
||||
self._NumberLabel.SetText(str(self._Number))
|
||||
self._NumberLabel.DrawCenter()
|
||||
|
||||
|
||||
|
||||
@ -38,6 +38,7 @@ fonts["varela27"] = pygame.font.Font(fonts_path["varela"],27)
|
||||
fonts["varela28"] = pygame.font.Font(fonts_path["varela"],28)
|
||||
fonts["varela34"] = pygame.font.Font(fonts_path["varela"],34)
|
||||
fonts["varela40"] = pygame.font.Font(fonts_path["varela"],40)
|
||||
fonts["varela120"] = pygame.font.Font(fonts_path["varela"],120)
|
||||
|
||||
fonts["veramono25"] = pygame.font.Font(fonts_path["veramono"],25)
|
||||
fonts["veramono24"] = pygame.font.Font(fonts_path["veramono"],24)
|
||||
|
||||
38
sys.py/UI/full_screen.py
Normal file
38
sys.py/UI/full_screen.py
Normal file
@ -0,0 +1,38 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import pygame
|
||||
#from sys import exit
|
||||
#import os
|
||||
#import sys
|
||||
|
||||
#from libs import easing
|
||||
#from datetime import datetime
|
||||
|
||||
#from beeprint import pp
|
||||
|
||||
## local package import
|
||||
from constants import Width,Height
|
||||
|
||||
|
||||
class FullScreen(object):
|
||||
_PosX = 0
|
||||
_PosY = 0
|
||||
_Width = Width
|
||||
_Height = Height
|
||||
_CanvasHWND = None
|
||||
_HWND = None
|
||||
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
def Init(self):
|
||||
pass
|
||||
|
||||
def SwapAndShow(self):
|
||||
if self._HWND != None:
|
||||
self._HWND.blit(self._CanvasHWND,(self._PosX,self._PosY,self._Width,self._Height))
|
||||
pygame.display.update()
|
||||
|
||||
def Draw(self):
|
||||
pass
|
||||
|
||||
@ -4,6 +4,8 @@ import pygame
|
||||
|
||||
#import base64
|
||||
#from beeprint import pp
|
||||
from constants import Width,Height
|
||||
from util_funcs import midRect
|
||||
|
||||
class Label:
|
||||
_PosX=0
|
||||
@ -50,6 +52,11 @@ class Label:
|
||||
def SetCanvasHWND(self,_canvashwnd):
|
||||
self._CanvasHWND = _canvashwnd
|
||||
|
||||
def DrawCenter(self,bold=False):
|
||||
self._FontObj.set_bold(bold) ## avoing same font tangling set_bold to others
|
||||
my_text = self._FontObj.render( self._Text,True,self._Color)
|
||||
self._CanvasHWND.blit(my_text,midRect(self._PosX,self._PosY,self._Width,self._Height,Width,Height))
|
||||
|
||||
def Draw(self,bold=False):
|
||||
self._FontObj.set_bold(bold) ## avoing same font tangling set_bold to others
|
||||
my_text = self._FontObj.render( self._Text,True,self._Color)
|
||||
|
||||
@ -26,6 +26,7 @@ from untitled_icon import UntitledIcon
|
||||
from Emulator import MyEmulator
|
||||
|
||||
from skin_manager import SkinManager
|
||||
from counter_screen import CounterScreen
|
||||
|
||||
class MessageBox(Label):
|
||||
_Parent = None
|
||||
@ -135,7 +136,8 @@ class MainScreen(object):
|
||||
_MsgBoxFont = fonts["veramono20"]
|
||||
_IconFont = fonts["varela15"]
|
||||
_SkinManager = None
|
||||
|
||||
|
||||
_CounterScreen = None
|
||||
|
||||
def __init__(self):
|
||||
self._Pages = []
|
||||
@ -149,6 +151,12 @@ class MainScreen(object):
|
||||
|
||||
self._SkinManager = SkinManager()
|
||||
self._SkinManager.Init()
|
||||
|
||||
self._CounterScreen = CounterScreen()
|
||||
self._CounterScreen._HWND = self._HWND
|
||||
|
||||
self._CounterScreen.Init()
|
||||
|
||||
|
||||
def FartherPages(self):
|
||||
self._PageMax = len(self._Pages)
|
||||
@ -510,14 +518,17 @@ class MainScreen(object):
|
||||
self.EasingAllPageRight()
|
||||
#self.SwapAndShow()
|
||||
"""
|
||||
|
||||
if event.key == pygame.K_t:
|
||||
self.DrawRun()
|
||||
self.SwapAndShow()
|
||||
|
||||
"""
|
||||
if event.key == CurKeys["Space"]:
|
||||
self.Draw()
|
||||
self.SwapAndShow()
|
||||
|
||||
self._CounterScreen.Draw()
|
||||
self._CounterScreen.SwapAndShow()
|
||||
self._CounterScreen.StartCounter()
|
||||
"""
|
||||
## leave rest to Pages
|
||||
current_page_key_down_cb = getattr(self._CurrentPage,"KeyDown",None)
|
||||
if current_page_key_down_cb != None:
|
||||
|
||||
@ -59,14 +59,13 @@ class TitleBar:
|
||||
self.SyncSoundVolume()
|
||||
self.UpdateWifiStrength()
|
||||
SwapAndShow()
|
||||
else:
|
||||
print("TitleBar Gobjectroundrobin")
|
||||
elif self._InLowBackLight >= 0:
|
||||
self._InLowBackLight+=1
|
||||
|
||||
if self._InLowBackLight > 10:
|
||||
self.CheckBatteryStat()
|
||||
self.SyncSoundVolume()
|
||||
self.UpdateWifiStrength()
|
||||
SwapAndShow()
|
||||
self._InLowBackLight = 0
|
||||
|
||||
return True
|
||||
|
||||
@ -19,7 +19,7 @@ SKIN="default"
|
||||
## three timer values in seconds: dim screen, close screen,PowerOff
|
||||
## zero means no action
|
||||
PowerLevels = {}
|
||||
PowerLevels["supersaving"] = [10,30,100]
|
||||
PowerLevels["supersaving"] = [10,30,120]
|
||||
PowerLevels["powersaving"] = [40,120,300]
|
||||
PowerLevels["balance_saving"] = [40,0,0]
|
||||
|
||||
|
||||
@ -76,7 +76,12 @@ def gobject_loop():
|
||||
|
||||
def RestoreLastBackLightBrightness(main_screen):
|
||||
global last_brt,passout_time_stage
|
||||
|
||||
|
||||
main_screen._CounterScreen.StopCounter()
|
||||
|
||||
passout_time_stage = 0
|
||||
main_screen._TitleBar._InLowBackLight = -1
|
||||
|
||||
if last_brt == -1:
|
||||
return
|
||||
|
||||
@ -96,10 +101,7 @@ def RestoreLastBackLightBrightness(main_screen):
|
||||
f.truncate()
|
||||
f.close()
|
||||
last_brt = -1
|
||||
main_screen._TitleBar._InLowBackLight = -1
|
||||
passout_time_stage = 0
|
||||
else:
|
||||
|
||||
else:
|
||||
f.close()
|
||||
return
|
||||
|
||||
@ -132,7 +134,7 @@ def InspectionTeam(main_screen):
|
||||
f.truncate()
|
||||
f.close()
|
||||
|
||||
main_screen._TitleBar._InLowBackLight = 0
|
||||
main_screen._TitleBar._InLowBackLight = 0
|
||||
|
||||
if time_2 != 0:
|
||||
passout_time_stage = 1 # next
|
||||
@ -152,21 +154,36 @@ def InspectionTeam(main_screen):
|
||||
f.write(str(brt))
|
||||
f.truncate()
|
||||
f.close()
|
||||
main_screen._TitleBar._InLowBackLight = 0
|
||||
|
||||
main_screen._TitleBar._InLowBackLight = 0
|
||||
|
||||
if time_3 != 0:
|
||||
passout_time_stage = 2 # next
|
||||
everytime_keydown = cur_time
|
||||
|
||||
elif cur_time - everytime_keydown > time_3 and passout_time_stage == 2:
|
||||
print("Power Off now")
|
||||
|
||||
if config.CurKeySet != "PC":
|
||||
cmdpath = "sudo halt -p"
|
||||
pygame.event.post( pygame.event.Event(RUNSYS, message=cmdpath))
|
||||
print("Power Off counting down")
|
||||
|
||||
passout_time_stage = 0
|
||||
everytime_keydown = cur_time
|
||||
main_screen._CounterScreen.Draw()
|
||||
main_screen._CounterScreen.SwapAndShow()
|
||||
main_screen._CounterScreen.StartCounter()
|
||||
|
||||
|
||||
try:
|
||||
f = open(config.BackLight,"r+")
|
||||
except IOError:
|
||||
pass
|
||||
else:
|
||||
with f:
|
||||
brt = last_brt
|
||||
f.seek(0)
|
||||
f.write(str(brt))
|
||||
f.truncate()
|
||||
f.close()
|
||||
|
||||
main_screen._TitleBar._InLowBackLight = 0
|
||||
|
||||
passout_time_stage = 4
|
||||
|
||||
return True
|
||||
|
||||
@ -186,7 +203,9 @@ def event_process(event,main_screen):
|
||||
pygame.event.clear(GMEVT)
|
||||
return
|
||||
if event.type == RUNEVT:
|
||||
|
||||
everytime_keydown = time.time()
|
||||
RestoreLastBackLightBrightness(main_screen)
|
||||
|
||||
if config.DontLeave==True:
|
||||
os.chdir(GetExePath())
|
||||
os.system( "/bin/sh -c "+event.message)
|
||||
@ -209,6 +228,8 @@ def event_process(event,main_screen):
|
||||
return
|
||||
|
||||
if event.type == RUNSYS:
|
||||
everytime_keydown = time.time()
|
||||
RestoreLastBackLightBrightness(main_screen)
|
||||
if config.DontLeave==True:
|
||||
os.chdir(GetExePath())
|
||||
os.system( "/bin/sh -c "+event.message)
|
||||
@ -226,7 +247,6 @@ def event_process(event,main_screen):
|
||||
|
||||
if event.type == POWEROPT:
|
||||
everytime_keydown = time.time()
|
||||
RestoreLastBackLightBrightness(main_screen)
|
||||
|
||||
return
|
||||
if event.type == pygame.KEYUP:
|
||||
@ -273,6 +293,7 @@ def event_process(event,main_screen):
|
||||
###########################################################
|
||||
if event.key == pygame.K_ESCAPE:
|
||||
pygame.event.clear()
|
||||
|
||||
|
||||
key_down_cb = getattr(main_screen,"KeyDown",None)
|
||||
if key_down_cb != None:
|
||||
@ -368,6 +389,7 @@ def big_loop():
|
||||
main_screen.ReadTheDirIntoPages("../Menu",0,None)
|
||||
main_screen.FartherPages()
|
||||
|
||||
|
||||
title_bar._SkinManager = main_screen._SkinManager
|
||||
foot_bar._SkinManager = main_screen._SkinManager
|
||||
|
||||
@ -385,7 +407,7 @@ def big_loop():
|
||||
gobject.timeout_add(3000,title_bar.GObjectRoundRobin)
|
||||
|
||||
|
||||
socket_thread(main_screen)
|
||||
# socket_thread(main_screen)
|
||||
|
||||
gobject_loop()
|
||||
|
||||
@ -402,7 +424,7 @@ if __name__ == '__main__':
|
||||
screen = pygame.display.set_mode(SCREEN_SIZE, 0, 32)
|
||||
|
||||
pygame.event.set_allowed(None)
|
||||
pygame.event.set_allowed([pygame.KEYDOWN,pygame.KEYUP,GMEVT,RUNEVT,RUNSYS])
|
||||
pygame.event.set_allowed([pygame.KEYDOWN,pygame.KEYUP,GMEVT,RUNEVT,RUNSYS,POWEROPT])
|
||||
|
||||
pygame.key.set_repeat(DT+DT*6+DT/2, DT+DT*3+DT/2)
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user