예제 #1
0
파일: main.py 프로젝트: surfbutler/TYOS
    def __init__(self):
        warnings.filterwarnings("ignore")
        for arg in sys.argv:
            if arg == '--power':
                self.POWER_FONA = True
                print 'Powering FONA on...'
            else:
                self.POWER_FONA = False
            if arg == '--version':
                print 'TYOS VERSION ' + VERSION
                sys.exit()
            
        self.VERSION = VERSION
        if self.POWER_FONA:
            import power
            power.Power().toggle()
            time.sleep(10)

        #Setup fona
        self.fona = serialport.SerialPort()
        self.fona.connect()

        self.set_audio()
        
        #Setup some important objects
        self.scope = framebuffer.pyscope()
        self.toolbar = toolbar.Toolbar(self.fona)
        self.apps = apps.App(self.fona)
        self.reciever = receive.Receive(self.fona)

        pygame.init()

        #Setup surface
        self.WINDOWWIDTH = 320
        self.WINDOWHIEGHT = 480
        self.surface = pygame.display.set_mode((self.WINDOWWIDTH, self.WINDOWHIEGHT), pygame.FULLSCREEN)
        pygame.mouse.set_visible(False)

        self.clock = pygame.time.Clock()

        #Colors        R   G   B
        self.BLUE =  (  0,  0,255)
        self.WHITE = (255,255,255)
        self.BLACK = (  0,  0,  0)

        self.surface.fill(self.WHITE)

        self.update = True

        #Setup logo
        self.logo = pygame.image.load('/home/pi/tyos/graphics/logo.png')
        self.logo_rect = self.logo.get_rect()
        self.logo_rect.y = self.surface.get_rect().centery - 50
        self.logo_rect.centerx = self.surface.get_rect().centerx

        #Setup Battery Icon
        self.bat = pygame.image.load('/home/pi/tyos/graphics/bat.png')
        self.bat_rect = self.bat.get_rect()
        self.bat_rect.centery = 15
        self.bat_rect.right = self.WINDOWWIDTH - 10

        #Setup Low Battery Icon
        self.low_bat = pygame.image.load('/home/pi/tyos/graphics/low_bat.png')
        self.low_bat_rect = self.low_bat.get_rect()
        self.low_bat_rect.centery = 380
        self.low_bat_rect.centerx = self.surface.get_rect().centerx

        #Setup App Toolbar
        self.app_toolbar = pygame.Rect(0, 0, 320, 30)

        #Rectangle Dictionary
        self.rectangles = {'rects':[self.app_toolbar], 'colors':[self.BLACK]}
        #Reception Rectangle dictionary
        self.reception_bars = {'rects':[], 'colors':[]}
        #Battery Left Text
        self.bat_left = {'surface':self.toolbar.bat_left, 'rects':self.toolbar.bat_left_rect}

        #Setup fonts
        self.font = pygame.font.Font('/home/pi/tyos/fonts/arial.ttf', 20)

        #Setup clock Text
        self.clock_text = self.font.render('12:00', True, self.WHITE, self.BLACK)
        self.clock_text_rect = self.clock_text.get_rect()
        self.clock_text_rect.centerx = self.surface.get_rect().centerx
        self.clock_text_rect.centery = 15

        #Image Dictionary
        self.images = {'surfaces':[self.bat], 'rects':[self.bat_rect, self.clock_text_rect]}

        self.blit_logo = True
        self.dead_bat = False
예제 #2
0
파일: main.py 프로젝트: zatamite/TYOS
    def __init__(self):
        warnings.filterwarnings("ignore")
        for arg in sys.argv:
            if arg == '--power':
                self.POWER_FONA = True
                print 'Powering FONA on...'
            else:
                self.POWER_FONA = False
            if arg == '--version':
                print 'TYOS VERSION ' + VERSION
                sys.exit()

        self.VERSION = VERSION
        if self.POWER_FONA:
            import power
            power.Power().toggle()
            time.sleep(10)

        #Setup fona
        self.fona = serialport.SerialPort()
        self.fona.connect()

        self.set_audio()

        #Setup some important objects
        self.scope = framebuffer.pyscope()
        self.toolbar = toolbar.Toolbar(self.fona)
        self.apps = apps.App(self.fona)
        self.reciever = receive.Receive(self.fona)

        pygame.init()

        #Setup surface
        self.WINDOWWIDTH = 320
        self.WINDOWHIEGHT = 480
        self.surface = pygame.display.set_mode(
            (self.WINDOWWIDTH, self.WINDOWHIEGHT), pygame.FULLSCREEN)
        pygame.mouse.set_visible(False)

        self.clock = pygame.time.Clock()

        #Colors        R   G   B
        self.BLUE = (0, 0, 255)
        self.WHITE = (255, 255, 255)
        self.BLACK = (0, 0, 0)

        self.surface.fill(self.WHITE)

        self.update = True

        #Setup logo
        self.logo = pygame.image.load('/home/pi/tyos/graphics/logo.png')
        self.logo_rect = self.logo.get_rect()
        self.logo_rect.y = self.surface.get_rect().centery - 50
        self.logo_rect.centerx = self.surface.get_rect().centerx

        #Setup Battery Icon
        self.bat = pygame.image.load('/home/pi/tyos/graphics/bat.png')
        self.bat_rect = self.bat.get_rect()
        self.bat_rect.centery = 15
        self.bat_rect.right = self.WINDOWWIDTH - 10

        #Setup Low Battery Icon
        self.low_bat = pygame.image.load('/home/pi/tyos/graphics/low_bat.png')
        self.low_bat_rect = self.low_bat.get_rect()
        self.low_bat_rect.centery = 380
        self.low_bat_rect.centerx = self.surface.get_rect().centerx

        #Setup App Toolbar
        self.app_toolbar = pygame.Rect(0, 0, 320, 30)

        #Rectangle Dictionary
        self.rectangles = {'rects': [self.app_toolbar], 'colors': [self.BLACK]}
        #Reception Rectangle dictionary
        self.reception_bars = {'rects': [], 'colors': []}
        #Battery Left Text
        self.bat_left = {
            'surface': self.toolbar.bat_left,
            'rects': self.toolbar.bat_left_rect
        }

        #Setup fonts
        self.font = pygame.font.Font('/home/pi/tyos/fonts/arial.ttf', 20)

        #Setup clock Text
        self.clock_text = self.font.render('12:00', True, self.WHITE,
                                           self.BLACK)
        self.clock_text_rect = self.clock_text.get_rect()
        self.clock_text_rect.centerx = self.surface.get_rect().centerx
        self.clock_text_rect.centery = 15

        #Image Dictionary
        self.images = {
            'surfaces': [self.bat],
            'rects': [self.bat_rect, self.clock_text_rect]
        }

        self.blit_logo = True
        self.dead_bat = False