Commits

alv...@moveeel  committed 403109a

Lightning: logging e iniciação da conexão agora estão fora da função

  • Participants
  • Parent commits c7c8649

Comments (0)

Files changed (1)

File lightning_talk/lightning.py

         self.arduino.digital_write(self.red_pin, firmata.HIGH)
         self.arduino.digital_write(self.green_pin, firmata.HIGH)
 
+handler = logging.Handler()
+def print_log(log_object):
+    print time.time(), log_object.msg
+handler.emit = print_log
+log = logging.Logger('sinal')
+log.addHandler(handler)
+
+sinal = Sinal(port=glob.glob('/dev/ttyUSB*')[0], red_pin=7, green_pin=8)
 
 def start_talk():
-    handler = logging.Handler()
-    def print_log(log_object):
-        print time.time(), log_object.msg
-    handler.emit = print_log
-    log = logging.Logger('sinal')
-    log.addHandler(handler)
-
-    sinal = Sinal(port=glob.glob('/dev/ttyUSB*')[0], red_pin=7, green_pin=8)
     sinal.turn_off_all()
     log.debug('starting...')