コード例 #1
0
ファイル: ssccc.py プロジェクト: Osambezy/blinkenbluehouse
 def switchstatus(self, newstatus, param=''):
     if newstatus == 'startup':
         print 'SSCCC running'
         self.blinker = blthreads.EmptyThread(WIDTH, HEIGHT,
                                              self.mcu_socket)
         self.blinker.start()
     elif newstatus == 'off':
         self.blinker.stop()
         self.toggled = WIDTH * HEIGHT * '\x00'
         print 'Switched off'
         self.send(mcuf.packet_alloff(WIDTH, HEIGHT))
     elif newstatus == 'on':
         self.blinker.stop()
         self.toggled = WIDTH * HEIGHT * '\x01'
         print 'All on'
         self.send(mcuf.packet_allon(WIDTH, HEIGHT))
     elif newstatus == 'anim':
         self.blinker.stop()
         print 'Animation mode'
         self.blinker = blthreads.Animation(
             WIDTH, HEIGHT, self.mcu_socket, pl=self.playlist)
         self.blinker.start()
     elif newstatus == 'vu':
         self.blinker.stop()
         print 'VU mode'
     elif newstatus == 'lukas':
         self.blinker.stop()
         print 'Hau-den-Lukas mode'
         self.blinker = blthreads.Lukas(
             WIDTH, HEIGHT, self.mcu_socket, lukas_colum=GAME_COLUMN)
         self.blinker.start()
     elif newstatus == 'interactive':
         self.blinker.stop()
         print 'Interactive mode: ' + param
         if param == 'snake':
             self.blinker = blthreads.SnakeGame(WIDTH, HEIGHT,
                                                self.mcu_socket)
         elif param == 'pong':
             self.blinker = blthreads.PongGame(WIDTH, HEIGHT,
                                               self.mcu_socket, GAME_COLUMN)
         elif param == 'tetris':
             self.blinker = blthreads.TetrisGame(WIDTH, HEIGHT,
                                                 self.mcu_socket)
         elif param == 'maze':
             self.blinker = blthreads.MazeGame(WIDTH, HEIGHT,
                                               self.mcu_socket)
         else:
             print 'unknown game'
             return
         self.blinker.start()
     elif newstatus == 'text':
         self.blinker.stop()
         print 'Text: ' + param
         self.blinker = blthreads.ScrollingText(
             WIDTH, HEIGHT, mcu_socket, text=param)
         self.blinker.start()
     else:
         raise Exception('Unknown status mode: ' + newstatus)
     self.status = newstatus