From eea619aab5f5334a3c56150056c25f6041f4d008 Mon Sep 17 00:00:00 2001 From: Tyler Spadgenske Date: Wed, 6 Apr 2016 11:42:00 -0500 Subject: [PATCH] 0.5.4 --- src/main.py | 38 +++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/src/main.py b/src/main.py index 5630225..a056cc2 100644 --- a/src/main.py +++ b/src/main.py @@ -11,8 +11,10 @@ current version of TYOS. If higher, you can update. To get your version of TYOS run the command sudo python /home/pi/tyos/src/main.py --version ''' +VERSION = '0.5.4' -VERSION = '0.5.2' +#Set to True if you do not want the time modified off the FONA +USE_RAW_TIME = False import pygame, sys, os, time, datetime, traceback, warnings from pygame.locals import * @@ -30,7 +32,7 @@ def __init__(self): if arg == '--version': print 'TYOS VERSION ' + VERSION sys.exit() - + self.VERSION = VERSION if self.POWER_FONA: import power @@ -42,7 +44,7 @@ def __init__(self): self.fona.connect() self.set_audio() - + #Setup some important objects self.scope = framebuffer.pyscope() self.toolbar = toolbar.Toolbar(self.fona) @@ -118,7 +120,7 @@ def set_audio(self): except: if not os.path.exists('/home/pi/tyos/configure'):#If configure directory doesn't exist, create one os.mkdir('/home/pi/tyos/configure') - + self.audio_file = open('/home/pi/tyos/configure/audio.conf', 'w+')#Create config file and add some lines self.audio_file.write('#Audio config file\n') self.audio_file.write('mode=1\n') @@ -135,23 +137,25 @@ def set_audio(self): file[i] = file[i].rstrip() if 'mode' in file[i]: #Extract audio mode: 1=Built in, 0=External mode = file[i] - + mode = mode.split('=') mode = mode[1] - + self.fona.transmit('AT+CHFA=' + mode) - + def blit_time(self): #Convert to 12 hour time then blit it to surface t = time.strftime("%H:%M") - if int(t[0] + t[1]) > 12: - t = str(int(t[0] + t[1]) - 12) + t[-3:] + + if USE_RAW_TIME == False: + if int(t[0] + t[1]) > 12: + t = str(int(t[0] + t[1]) - 12) + t[-3:] t = t.lstrip('0') - + self.clock_text = self.font.render(t, True, self.WHITE, self.BLACK) self.surface.blit(self.clock_text, self.images['rects'][1]) - + def home(self): while True: #handle events and clock @@ -175,12 +179,12 @@ def home(self): if self.reciever.call_coming: self.apps.app_to_open = None self.apps.blit_logo = True - + #Update if necessary if self.update: self.blit(self.images, self.rectangles, self.reception_bars, self.bat_left) self.update = False - + def blit(self, surfaces, rects, reception, bat): self.surface.fill(self.WHITE) @@ -193,7 +197,7 @@ def blit(self, surfaces, rects, reception, bat): for rect, surface in zip(self.apps.app_objects[self.apps.app_to_open].blit['rects'], self.apps.app_objects[self.apps.app_to_open].blit['surfaces']): self.surface.blit(surface, rect) - + #Blit all rectangles for rect, color in zip(rects['rects'], rects['colors']): pygame.draw.rect(self.surface, color, rect) @@ -208,7 +212,7 @@ def blit(self, surfaces, rects, reception, bat): #Blit battery Percentage self.surface.blit(bat['surface'], bat['rects']) - + #Blit logo if self.apps.blit_logo: self.surface.blit(self.logo, self.logo_rect) @@ -231,11 +235,11 @@ def handle_events(self): self.app_bar = self.apps.check(event) if self.reciever.call_coming: self.reciever.get_events(event) - + phone = tyos() try: phone.home() #E.T Reference - + except KeyboardInterrupt: print print 'Closing TYOS ' + phone.VERSION