import pygame, sys, time, datetime, calendar, random, platform, serial from pygame.locals import * import os import subprocess import math import logging from os import listdir AppInfo = ['LAIOS - Project Speedforce / Ryzen',0,0,540] size = [480,320] centerx=(480/2) centery=(320/2) ArduinoComm=serial.Serial(port='/dev/ttyAMA0',baudrate=9600,parity=serial.PARITY_NONE,stopbits=serial.STOPBITS_ONE,bytesize=serial.EIGHTBITS,timeout=1) #------------------------------------------------------------------------------------------------------------------------------ #Menu Constructor MENU_POWER = ['Power Control','Power History'] MENU_RGB = ['Rgb Control','Mode Select','Custom Mode'] MENU_ENV = ['Environmental','Fan Control','System Temp'] MENU_AIS = ['A.I. System','Amazon Alexa','Google Assistant','Neural Network'] MENU_MUSIC = ['Music Player','Sync'] MENU_STATUS = ['System Status',',CPU','Memory','Storage','Network'] MENU_PREFS = ['Preferences','Startup'] MENU_SOCIAL = ['Social Notifications','Facebook','Twitter','Instagram','Snapchat'] MENU_CRYPTOMINING =['Crypto-Mining','Mining Control'] MENU_ROOT = [MENU_RGB,MENU_ENV,MENU_AIS,MENU_MUSIC,MENU_STATUS,MENU_SOCIAL,MENU_CRYPTOMINING,MENU_PREFS,MENU_POWER] #------------------------------------------------------------------------------------------------------------------------------ RgbMode=["0",'Classic Fade','Strober','Mystic Fade','Solid'] red = [255,0,0] white = [255,255,255] grey= [128,128,128] darkblue = [0,0,115] deepskyblue = [0,191,255] darkblue = [0,0,139] green = [0,255,0] black = [0,0,0] blue = [0,0,255] pink = [255,200,200] lightsalmon= [255,160,122] salmon= [250,128,114] darksalmon= [233,150,122] lightcoral= [240,128,128] indianred= [205,92,92] crimson= [220,20,60] firebrick= [178,34,34] red= [255,0,0] darkred= [139,0,0] coral= [255,127,80] tomato= [255,99,71] orangered= [255,69,0] gold= [255,215,0] orange= [255,165,0] darkorange= [255,140,0] lightyellow= [255,255,224] lemonchiffon= [255,250,205] lightgoldenrodyellow= [250,250,210] papayawhip= [255,239,213] moccasin= [255,228,181] peachpuff= [255,218,185] palegoldenrod= [238,232,170] khaki= [240,230,140] darkkhaki= [189,183,107] yellow= [255,255,0] lawngreen= [124,252,0] chartreuse= [127,255,0] limegreen= [50,205,50] lime= [0,255,0] forestgreen= [34,139,34] green= [0,128,0] darkgreen= [0,100,0] greenyellow= [173,255,47] yellowgreen= [154,205,50] springgreen= [0,255,127] mediumspringgreen= [0,250,154] lightgreen= [144,238,144] palegreen= [152,251,152] darkseagreen= [143,188,143] mediumseagreen= [60,179,113] seagreen= [46,139,87] olive= [128,128,0] darkolivegreen= [85,107,47] olivedrab= [107,142,35] lightcyan= [224,255,255] cyan= [0,255,255] aquamarine= [127,255,212] mediumaquamarine= [102,205,170] paleturquoise= [175,238,238] turquoise= [64,224,208] mediumturquoise= [72,209,204] darkturquoise= [0,206,209] lightseagreen= [32,178,170] cadetblue= [95,158,160] darkcyan= [0,139,139] teal= [0,128,128] powderblue= [176,224,230] lightblue= [173,216,230] lightskyblue= [135,206,250] skyblue= [135,206,235] deepskyblue= [0,191,255] lightsteelblue= [176,196,222] dodgerblue= [30,144,255] cornflowerblue= [100,149,237] steelblue= [70,130,180] royalblue= [65,105,225] blue= [0,0,255] mediumblue= [0,0,205] darkblue= [0,0,139] navy= [0,0,128] midnightblue= [25,25,112] mediumslateblue= [123,104,238] slateblue= [106,90,205] darkslateblue= [72,61,139] lavender= [230,230,250] thistle= [216,191,216] plum= [221,160,221] violet= [238,130,238] orchid= [218,112,214] fuchsia= [255,0,255] magenta= [255,0,255] mediumorchid= [186,85,211] mediumpurple= [147,112,219] blueviolet= [138,43,226] darkviolet= [148,0,211] darkorchid= [153,50,204] darkmagenta= [139,0,139] purple= [128,0,128] indigo= [75,0,130] pink= [255,192,203] lightpink= [255,182,193] hotpink= [255,105,180] deeppink= [255,20,147] palevioletred= [219,112,147] mediumvioletred= [199,21,133] white= [255,255,255] snow= [255,250,250] honeydew= [240,255,240] mintcream= [245,255,250] azure= [240,255,255] aliceblue= [240,248,255] ghostwhite= [248,248,255] whitesmoke= [245,245,245] seashell= [255,245,238] beige= [245,245,220] oldlace= [253,245,230] floralwhite= [255,250,240] ivory= [255,255,240] antiquewhite= [250,235,215] linen= [250,240,230] lavenderblush= [255,240,245] mistyrose= [255,228,225] gainsboro= [220,220,220] lightgray= [211,211,211] silver= [192,192,192] darkgray= [169,169,169] gray= [128,128,128] dimgray= [105,105,105] lightslategray= [119,136,153] slategray= [112,128,144] darkslategray= [47,79,79] cornsilk= [255,248,220] blanchedalmond= [255,235,205] bisque= [255,228,196] navajowhite= [255,222,173] wheat= [245,222,179] burlywood= [222,184,135] tan= [210,180,140] rosybrown= [188,143,143] sandybrown= [244,164,96] goldenrod= [218,165,32] peru= [205,133,63] chocolate= [210,105,30] saddlebrown= [139,69,19] sienna= [160,82,45] brown= [165,42,42] maroon= [128,0,0] RgbColor=3 PColor=white randor = [random.randint(0,256),random.randint(0,256),random.randint(0,256)] backgroundcolor = darkblue foregroundcolor = white clock = pygame.time.Clock() bgimages=os.listdir("sfimages") bimageindex=2 bgimage=pygame.image.load('sfimages/'+bgimages[bimageindex]) systemTime = [0,0,0] sysUpTime = [0,0,0] cursec = 0 presec = 0 now = datetime.datetime.now() systemTime[0] = now.hour systemTime[1] = now.minute systemTime[2] = now.second pbarp=0.00 pbarv=0.00 counter=0.00 IDX_MAINMENU = 0 IDX_SUBMENU = 0 FLG_EDITMODE=False FLG_FIRSTRUN=True FLG_SETTINGSCHANGED=True SYS_UIMODE = 0 SYS_SUBUIPANEL = 7 TMR_UIMODE = [0,20] TMR_SYSINFO = [0,120] TMR_WEATERUPDATE = [0,800] TMR_CACTIVITY = [0,120] TMR_SUBUIMODE = [0,10] RGB_ENABLED=True RGB_MODE=1 RGB_RANDOM=False RGB_BASECOLOR=3 RGB_RED=random.randrange(0,255) RGB_GREEN=random.randrange(0,255) RGB_BLUE=random.randrange(0,255) RGB_RFADE=5 RGB_GFADE=5 RGB_BFADE=5 EFFECT_RANDOMRGB=[RGB_RED,RGB_GREEN,RGB_BLUE] SYS_BACKIMAGE=7 SYS_THEME=0 SYS_FONT="astroneo" SYS_DISPLAYFULLSCREEN=False SETT_THEME=["Theme","Custom"] SETT_SCREENSAVER=["Screensaver","None"] SETT_WALLPAPER=["Wallpaper","TechWorld"] SETT_FONT=["Font","AstroNeo"] STAT_TOTALMEM="" STAT_FREEMEM="" STAT_SWAPMEM="" STAT_CPUTEMP="" STAT_HDDINFO=[0,0,0,0] STAT_NASINFO=[0,0,0,0] STAT_IPADDR="" STAT_CPUUSAGE="" STAT_SYSACTIVE= True STAT_AVS_STATE="Disabled" STAT_GAS_STATE="Disabled" STAT_ENN_STATE="Disabled" ftime = 0.0 animpos=480 #------------------------------------------------------------------------------------------------------- pygame.init() pygame.mouse.set_visible(False) fonts=pygame.font.get_fonts() SYS_FONT_BASIC = pygame.font.SysFont(None, 35) SYS_FONT_BASIC_LARGE = pygame.font.SysFont(None, 30) SYS_FONT_HEADER = pygame.font.SysFont(SYS_FONT,30) SYS_FONT_ATTRACT_1 = pygame.font.SysFont(SYS_FONT,38) SYS_FONT_ATTRACT_2 = pygame.font.SysFont(SYS_FONT,26) SYS_FONT_ATTRACT_3 = pygame.font.SysFont(SYS_FONT,20) SYS_FONT_BASIC_SMALL = pygame.font.SysFont(None,10) SYS_FONT_BASIC_MED = pygame.font.SysFont(None,25) cpos=240 #------------------------------------------------------------------------------------------------------- if (SYS_DISPLAYFULLSCREEN==True): screen = pygame.display.set_mode((size),pygame.FULLSCREEN) else: screen = pygame.display.set_mode((size)) #------------------------------------------------------------------------------------------------------- logo=pygame.image.load('AIlogo3.png').convert() IMG_FACEBOOK=pygame.image.load('sfimages/facebook-9.png').convert() logo.set_colorkey((255,0,255)) result=False def procmarqueepos(): global animpos animpos=animpos-2 if (animpos==-480): animpos=480 return animpos def getprocessid(): d = os.popen("ps -ef") fileopen = True while (fileopen): line = d.readline() data = (line.split()[1:8]) if (data[6]=="bash"): fileopen=False def procprefengine(cmd,preftable): if (cmd==0): return if (cmd==1): prefsfile = open("spprefs.ini","w+") prefsfile.write ("SYS_GAST_Stat="+str(STAT_GAS_STATE)+'\n') prefsfile.write ("SYS_THEME="+str(SYS_THEME)+'\n') prefsfile.write ("SYS_FONT="+str(SYS_FONT)+'\n') prefsfile.write ("SYS_DISPLAYFULLSCREEN="+str(SYS_DISPLAYFULLSCREEN)+'\n') prefsfile.write ("SYS_AVS_Stat="+str(STAT_AVS_STATE)+'\n') prefsfile.write ("RGB_Enabled="+str(RGB_ENABLED)+'\n') prefsfile.write ("SYS_FontMain="+str("astroneo")+'\n') prefsfile.close() def debuglogentry(ty): debuglog = open("spfdev_log.tdb","a+") if(ty==0): debuglog.write ("Debug Run " + now.strftime("%A") + " " + str(now.month) + "/" + str(now.day) + "/" + str(now.year) + ' ' + str(systemTime[0]) + ':' + str(systemTime[1]).zfill(2) + ':' + str(systemTime[2]).zfill(2) + ' ' + time.strftime("%p") +'\n') if(ty==1): debuglog.write ("Debug Run - Normal Exit - " + (str(sysUpTime[0]).zfill(2) + ':' + str(sysUpTime[1]).zfill(2) + ':' + str(sysUpTime[2]).zfill(2) +'\n')) debuglog.close() def rgtext(tvar): if (tvar=="Enabled"): return (green) else: return(red) def gwtext(pval): if (pval==False): return(grey) else: return(white) def doeditcontrol(): if (FLG_EDITMODE==True): drawTX('[Esc]: Cancel',15,275,SYS_FONT_BASIC_MED,foregroundcolor,backgroundcolor,"exact") drawTX('[Enter]: Save',350,275,SYS_FONT_BASIC_MED,foregroundcolor,backgroundcolor,"exact") else: drawTX('[Enter]: Edit',50,275,SYS_FONT_BASIC_MED,foregroundcolor,backgroundcolor,"center") def progresscircle(x,y,r,cval,fcol,bcol,vcol): cpos=[x,y] lpos=[x,y] scpos=[x+1,y+1] slpos=[x+1,y+1] crad=r progend=[(crad * math.cos(math.radians(cval-90))+x),(crad * math.sin(math.radians(cval-90))+y)] progstart=[(crad * math.cos(math.radians(-90))+x),(crad * math.sin(math.radians(-90))+y)] pygame.draw.circle(screen,bcol,scpos,crad, 0) pygame.draw.circle(screen,fcol,cpos,crad, 1) for fv in range (0,cval): pfill=[(crad * math.cos(math.radians((fv)-90))+x),(crad * math.sin(math.radians((fv)-90))+y)] pygame.draw.aaline(screen,vcol,lpos,pfill) pygame.draw.aaline(screen,fcol,lpos,progstart) pygame.draw.aaline(screen,fcol,lpos,progend) def progressbar(x,y,w,h,cv,mv,ty,borderc,fillc,bcolor,alignc): if(alignc==1): x=centerx-(w/2) xf=x+1 yf=y+1 hf=h-2 wf=w-2 pbarv=float(cv*(100/mv)) if (ty==0): #Horizontal pygame.draw.rect(screen, black, (xf,yf,w,h),2) pygame.draw.rect(screen, borderc, (x,y,w,h),1) pygame.draw.rect(screen, bcolor, (xf,yf,w-2,hf)) pygame.draw.rect(screen, fillc, (xf,yf,pbarv,hf)) if (ty==1): #Vertical pygame.draw.rect(screen, black, (xf,yf,h,w),2) pygame.draw.rect(screen, borderc, (x,y,h,w),1) pygame.draw.rect(screen, bcolor, (xf,yf,hf,wf)) pygame.draw.rect(screen, fillc, (xf,yf+98,hf,2-pbarv)) def startgast(): GAST_Stat="Disabled" def startaws(): AVS_Stat = "Disabled" Alexaproc=subprocess.Popen("sudo bash /home/pi/startsample.sh",shell=True,stdout=subprocess.PIPE) AVS_Stat = "Enabled" def dotime(timeobject): timeobject[2]+=1 if (timeobject[2]==60): timeobject[2]=0 timeobject[1]+=1 if (timeobject[1]==60): timeobject[1]=0 timeobject[0]+=1 def procinterrupt(func,timerobject): global result if (func==0): timerobject[0]+=1 if (func==1): if (timerobject[0]==timerobject[1]): result=True else: result=False return(result) def getsysinfo(): global STAT_IPADDR global STAT_TOTALMEM global STAT_FREEMEM global STAT_SWAPMEM global STAT_CPUTEMP global STAT_HDDINFO global STAT_NASINFO global STAT_CPUUSAGE arg="ip route list" p=subprocess.Popen(arg,shell=True,stdout=subprocess.PIPE) data = p.communicate() split_data = data[0].split() STAT_IPADDR = split_data[split_data.index("src")+1] s = subprocess.check_output(["free","-m"]) lines = s.split("\n") STAT_TOTALMEM = str((int(lines[1].split()[1]))) STAT_FREEMEM = str((int(lines[1].split()[3]))) STAT_SWAPMEM = str((int(lines[2].split()[3]))) ctemp = subprocess.check_output(['/opt/vc/bin/vcgencmd','measure_temp']) STAT_CPUTEMP = str(float(ctemp.split("=")[1][:-3])) d = os.popen("df -h") line = d.readline() line = d.readline() disk = (line.split()[1:6]) STAT_HDDINFO = [disk[0],disk[1],disk[2],disk[3]] line = d.readline() line = d.readline() line = d.readline() line = d.readline() line = d.readline() line = d.readline() line = d.readline() line = d.readline() nasi = (line.split()[1:6]) STAT_NASINFO = [nasi[0],nasi[1],nasi[2],nasi[3]] t = os.popen("top") row = t.readline() row = t.readline() row = t.readline() data = (row.split()[1:60]) STAT_CPUUSAGE = float(str(row[28])) #+ str(row[29]) + str(row[30]) + str(row[69]) + str(row[70]) + str(row[71])) def randomcolor(): randcol = [random.randint(0,255),random.randint(0,255),random.randint(0,255)] return (randcol) def drawTX(dtext,xp,yp,dfont,forec,backc,align): if (align=="center"): text = dfont.render(dtext, True, (black), None) textx = text.get_width() xpos=(480/2)-(textx/2)+2 ypos=yp+2 screen.blit(text, [xpos,ypos]) text = dfont.render(dtext, True, (forec), None) xpos=(480/2)-(textx/2) ypos=yp screen.blit(text, [xpos,ypos]) if (align=="exact"): text = dfont.render(dtext, True, (black), None) textx = text.get_width() xpos=int(xp+2) ypos=yp+2 screen.blit(text, [xpos,ypos]) text = dfont.render(dtext, True, (forec), None) xpos=int(xp) ypos=yp screen.blit(text, [xpos,ypos]) def drawUI(forecolor,backcolor,uimodeindex): global RGB_RED global RGB_GREEN global RGB_BLUE global EFFECT_RANDOMRGB screen.blit(bgimage,[0,0]) if (uimodeindex==0): RGB_RED=random.randrange(0,255) RGB_GREEN=random.randrange(0,255) RGB_BLUE=random.randrange(0,255) EFFECT_RANDOMRGB=[RGB_RED,RGB_GREEN,RGB_BLUE] drawTX('Project',procmarqueepos(),centery-38,SYS_FONT_ATTRACT_2,forecolor,backcolor,"center") drawTX('Homebound',procmarqueepos(),centery-10,SYS_FONT_ATTRACT_1,EFFECT_RANDOMRGB,backcolor,"exact") drawTX('DetroitCityG Industries',centerx,centery+23,SYS_FONT_BASIC_MED,forecolor,backcolor,"center") drawTX('Rev. ' + str(AppInfo[1]) +'.' + str(AppInfo[2]).zfill(2) + '.' + str(AppInfo[3]).zfill(4),centerx,centery-150,SYS_FONT_BASIC_MED,forecolor,backcolor,"center") drawTX('Controls ' ,20,10,SYS_FONT_BASIC_MED,forecolor,backcolor,"exact") drawTX('About ' ,410,10,SYS_FONT_BASIC_MED,forecolor,backcolor,"exact") drawTX('H: ' + (str(sysUpTime[0]).zfill(2) + ' M: ' + str(sysUpTime[1]).zfill(2) + ' S: ' + str(sysUpTime[2]).zfill(2)),centerx,centery+138,SYS_FONT_BASIC_LARGE,forecolor,backcolor,"center") screen.blit(logo,(centerx-(logo.get_width()/2),centery-125)) if (SYS_SUBUIPANEL==0): drawTX('System Memory',centerx,centery+75,SYS_FONT_BASIC,forecolor,backcolor,"center") drawTX(('Total: ' + str(STAT_TOTALMEM) + ' MB Free ' + str(STAT_FREEMEM)+' MB'),centerx,centery+100,SYS_FONT_BASIC,forecolor,backcolor,"center") if (SYS_SUBUIPANEL==1): drawTX('Local Storage',centerx,centery+75,SYS_FONT_BASIC,forecolor,backcolor,"center") drawTX(('Total: ' + str(STAT_HDDINFO[0]) + ' Used: ' + str(STAT_HDDINFO[3])),centerx,centery+100,SYS_FONT_BASIC,forecolor,backcolor,"center") if (SYS_SUBUIPANEL==2): drawTX('NAS Storage',centerx,centery+75,SYS_FONT_BASIC,forecolor,backcolor,"center") drawTX(('Total: ' + str(STAT_NASINFO[0]) + ' Used: ' + str(STAT_NASINFO[3])),centerx,centery+100,SYS_FONT_BASIC,forecolor,backcolor,"center") if (SYS_SUBUIPANEL==3): drawTX('Local Network',centerx,centery+75,SYS_FONT_BASIC,forecolor,backcolor,"center") drawTX(STAT_IPADDR + ' - 255.255.255.0',centerx,centery+100,SYS_FONT_BASIC,forecolor,backcolor,"center") if (SYS_SUBUIPANEL==4): drawTX('Current Time',centerx,centery+75,SYS_FONT_BASIC,forecolor,backcolor,"center") drawTX((now.strftime("%A") + ' ' + str(now.month) + '/' + str(now.day) + '/' + str(now.year) + ' ' + str(systemTime[0]) + ':' + str(systemTime[1]).zfill(2) + ':' + str(systemTime[2]).zfill(2) + ' ' + time.strftime("%p")),centerx,centery+100,SYS_FONT_BASIC,forecolor,backcolor,"center") if (SYS_SUBUIPANEL==5): drawTX('CPU Usage: '+ str(STAT_CPUUSAGE)+'%',centerx,centery+75,SYS_FONT_BASIC,forecolor,backcolor,"center") progressbar(195,275,100,12,STAT_CPUUSAGE,100,0,white,green,black,1) if (SYS_SUBUIPANEL==6): drawTX('Minecraft Server (Offline)',centerx,centery+75,SYS_FONT_BASIC,forecolor,backcolor,"center") drawTX('0/20',centerx,centery+100,SYS_FONT_BASIC_MED,forecolor,backcolor,"center") if (SYS_SUBUIPANEL==7): drawTX('Test Panel with Progress Bar',0,centery+75,SYS_FONT_BASIC,forecolor,backcolor,"center") progressbar(195,275,100,12,random.randrange(0,100),60,0,white,green,black,1) if (uimodeindex==1): drawTX((now.strftime("%A") + ' ' + str(now.month) + '/' + str(now.day) + '/' + str(now.year) + ' ' + str(systemTime[0]) + ':' + str(systemTime[1]).zfill(2) + ':' + str(systemTime[2]).zfill(2) + ' ' + time.strftime("%p")),centerx,centery-157,SYS_FONT_BASIC_MED,forecolor,backcolor,"center") drawTX('Project Speedforce Powered by L.A.I.O.S.',centerx,centery+140,SYS_FONT_BASIC_MED,forecolor,backcolor,"center") drawTX((MENU_ROOT[IDX_MAINMENU][IDX_SUBMENU]),centerx,centery-128,SYS_FONT_ATTRACT_3,forecolor,backcolor,"center") pygame.draw.rect(screen, white, (0, 25, 480, 275,),1) if (IDX_MAINMENU==0): if (IDX_SUBMENU==0): drawTX('RGB Enable:',50,75,SYS_FONT_BASIC_MED,forecolor,backcolor,"exact") drawTX('Enabled',320,75,SYS_FONT_BASIC_MED,gwtext(FLG_EDITMODE),backcolor,"exact") drawTX('RGB Mode: ',50,100,SYS_FONT_BASIC_MED,forecolor,backcolor,"exact") drawTX(str(RgbMode[1]),320,100,SYS_FONT_BASIC_MED,gwtext(FLG_EDITMODE),backcolor,"exact") drawTX('Random Colors: ',50,125,SYS_FONT_BASIC_MED,forecolor,backcolor,"exact") drawTX(('Disabled'),320,125,SYS_FONT_BASIC_MED,gwtext(FLG_EDITMODE),backcolor,"exact") drawTX('Base Color: ',50,150,SYS_FONT_BASIC_MED,forecolor,backcolor,"exact") drawTX(('...'),320,150,SYS_FONT_BASIC_MED,gwtext(FLG_EDITMODE),backcolor,"exact") doeditcontrol() if (IDX_MAINMENU==2 and IDX_SUBMENU==0): drawTX('Project Speedforce is not affiliated nor sponsored by',25,75,SYS_FONT_BASIC_MED,forecolor,backcolor,"exact") drawTX('Amazon or Google. Software employed and used',25,100,SYS_FONT_BASIC_MED,forecolor,backcolor,"exact") drawTX('is provided via openly available APIs.',25,125,SYS_FONT_BASIC_MED,forecolor,backcolor,"exact") drawTX('All software unless otherwise noted is not marked.',25,150,SYS_FONT_BASIC_MED,forecolor,backcolor,"exact") drawTX('for public distribution.',25,175,SYS_FONT_BASIC_MED,forecolor,backcolor,"exact") if (IDX_MAINMENU==2): if (IDX_SUBMENU==1): drawTX('Alexa Voice Services:',50,75,SYS_FONT_BASIC_MED,forecolor,backcolor,"exact") drawTX(STAT_AVS_STATE,320,75,SYS_FONT_BASIC_MED,rgtext(STAT_AVS_STATE),backcolor,"exact") if (IDX_SUBMENU==2): drawTX('Google Assistant:',50,75,SYS_FONT_BASIC_MED,forecolor,backcolor,"exact") drawTX(STAT_GAS_STATE,320,75,SYS_FONT_BASIC_MED,rgtext(STAT_GAS_STATE),backcolor,"exact") if (IDX_SUBMENU==3): drawTX('Embedded Neural Network',50,75,SYS_FONT_BASIC_MED,forecolor,backcolor,"exact") drawTX(STAT_ENN_STATE,320,75,SYS_FONT_BASIC_MED,rgtext(STAT_GAS_STATE),backcolor,"exact") if (IDX_MAINMENU==7): if (IDX_SUBMENU==0): drawTX(SETT_THEME[0]+':',50,75,SYS_FONT_BASIC_MED,forecolor,backcolor,"exact") drawTX(SETT_THEME[1],320,75,SYS_FONT_BASIC_MED,gwtext(FLG_EDITMODE),backcolor,"exact") drawTX(SETT_SCREENSAVER[0]+':',50,100,SYS_FONT_BASIC_MED,forecolor,backcolor,"exact") drawTX(SETT_SCREENSAVER[1],320,100,SYS_FONT_BASIC_MED,gwtext(FLG_EDITMODE),backcolor,"exact") drawTX(SETT_FONT[0] +':',50,125,SYS_FONT_BASIC_MED,forecolor,backcolor,"exact") drawTX(SETT_FONT[1],320,125,SYS_FONT_BASIC_MED,gwtext(FLG_EDITMODE),backcolor,"exact") drawTX(SETT_WALLPAPER[0]+':',50,150,SYS_FONT_BASIC_MED,forecolor,backcolor,"exact") drawTX(SETT_WALLPAPER[1],320,150,SYS_FONT_BASIC_MED,gwtext(FLG_EDITMODE),backcolor,"exact") doeditcontrol() if (IDX_SUBMENU==1): drawTX('Startup',50,75,SYS_FONT_BASIC_MED,forecolor,backcolor,"exact") if (IDX_MAINMENU==6): if (IDX_SUBMENU==0): drawTX('Rate:',50,75,SYS_FONT_BASIC_MED,forecolor,backcolor,"exact") drawTX('63Gh/s',320,75,SYS_FONT_BASIC_MED,forecolor,backcolor,"exact") drawTX('BTC:',50,100,SYS_FONT_BASIC_MED,forecolor,backcolor,"exact") drawTX('0.00000313',320,100,SYS_FONT_BASIC_MED,forecolor,backcolor,"exact") drawTX('Value:',50,125,SYS_FONT_BASIC_MED,forecolor,backcolor,"exact") drawTX('$0.011',320,125,SYS_FONT_BASIC_MED,forecolor,backcolor,"exact") if (uimodeindex==3): drawTX('Test Screen:',50,75,SYS_FONT_BASIC_MED,forecolor,backcolor,"exact") progressbar(160,80,100,12,random.randrange(0,100),60,0,white,green,black,0) screen.blit(IMG_FACEBOOK,(centerx,centery)) progresscircle(150,200,50,random.randrange(0,360),white,grey,green) pygame.display.update() # Main Loop -------------------------------------------------------------------------------------------- if (FLG_FIRSTRUN): #getweather() getsysinfo() debuglogentry(0) while STAT_SYSACTIVE: ftime+=1 FLG_FIRSTRUN=False if (ftime==60): ftime=0 pygame.time.delay(25) drawUI(foregroundcolor,backgroundcolor,SYS_UIMODE) now = datetime.datetime.now() systemTime[0] = now.hour systemTime[1] = now.minute systemTime[2] = now.second if (systemTime[0] >= 12): systemTime[0] = now.hour-12 if (systemTime[0]==0): systemTime[0]+=1 cursec=now.second if (presec==cursec): systemTime[2] = now.second else: presec=cursec procinterrupt(0,(TMR_UIMODE)) procinterrupt(0,TMR_SYSINFO) procinterrupt(0,TMR_SUBUIMODE) procinterrupt(0,TMR_CACTIVITY) dotime(sysUpTime) if (procinterrupt(1,TMR_UIMODE)): TMR_UIMODE[0]=0 SYS_UIMODE=0 if (procinterrupt(1,TMR_CACTIVITY)): TMR_UIMODE[0]=0 SYS_UIMODE=0 if (procinterrupt(1,TMR_SYSINFO)): TMR_SYSINFO[0]=0 getsysinfo() if (procinterrupt(1,TMR_SUBUIMODE)): TMR_SUBUIMODE[0]=0 SYS_SUBUIPANEL+=1 if (SYS_SUBUIPANEL>=8): SYS_SUBUIPANEL=0 for event in pygame.event.get(): if (event.type==pygame.QUIT): STAT_SYSYACTIVE=False if (event.type==pygame.KEYDOWN): if (event.key==pygame.K_ESCAPE): if (SYS_UIMODE==0): STAT_SYSYACTIVE=False if (FLG_EDITMODE==False): SYS_UIMODE=0 else: FLG_EDITMODE=False if (event.key==pygame.K_F2): SYS_UIMODE=2 TMR_UIMODE[0]=0 if (event.key==pygame.K_F3): SYS_UIMODE=3 TMR_UIMODE[0]=0 if (event.key==pygame.K_F1): SYS_UIMODE=1 TMR_UIMODE[0]=0 IDX_MAINMENU=0 IDX_SUBMENU=0 if (event.key==pygame.K_F12): STAT_SYSACTIVE=0 if (event.key==pygame.K_RETURN): if (FLG_EDITMODE==False): FLG_EDITMODE=True else: if (FLG_SETTINGSCHANGED==True): procprefengine(1,"Test") FLG_EDITMODE=False if (SYS_UIMODE==1): if (event.key==pygame.K_RIGHT): TMR_UIMODE[0]=0 if (IDX_MAINMENU==len(MENU_ROOT)-1): IDX_MAINMENU=len(MENU_ROOT)-1 else: IDX_MAINMENU+=1 IDX_SUBMENU=0 if (event.key==pygame.K_LEFT): TMR_UIMODE[0]=0 if (IDX_MAINMENU==0): IDX_MAINMENU=0 else: IDX_MAINMENU-=1 IDX_SUBMENU=0 if (event.key==pygame.K_UP): TMR_UIMODE[0]=0 if (IDX_SUBMENU==0): IDX_SUBMENU=0 else: IDX_SUBMENU-=1 if (event.key==pygame.K_DOWN): TMR_UIMODE[0]=0 if (IDX_SUBMENU==len(MENU_ROOT[IDX_MAINMENU])-1): IDX_SUBMENU=len(MENU_ROOT[IDX_MAINMENU])-1 else: IDX_SUBMENU+= 1 #End Program / Garbage Collection ArduinoComm.close pygame.quit() sys.exit()