#!/mnt/usb/wk/jpt/py/bin/python

import time
from serial import Serial
from animations import Led_clock_pointer, Led_clock_flasher
from lib import lcdControl
from lib import SevSeg
from lib import Motion_sensor
from lib.get_data import get_temp
from animations import Seven_segment_clock

motionLogFile = "/mnt/usb/logs/motionLog.log"
device = "/dev/ttyUSB0"
baudrate = 9600
updateintv = .3


if __name__ == "__main__":

    # Set up usb
    usb = Serial(device, baudrate, timeout=2)
    time.sleep(3)
    # init virtual devices
    lcd = lcdControl.Lcd(usb)
    sevdp = SevSeg(usb)
    mtxdp = SevSeg(usb, dev_id=1)
    moss = Motion_sensor(usb, motionLogFile)

    led_clock_pointer_sec = Led_clock_pointer(mtxdp, ring=1)
    led_clock_pointer_min = Led_clock_pointer(mtxdp, pointertype="min", ring=0)
    led_clock_flasher = Led_clock_flasher(mtxdp)
    seven_segment_clock = Seven_segment_clock(sevdp)

    # turn on second display, > note: not sure why 0
    mtxdp.setstate(0)
    # set intensitive
    sevdp.setintensity(8)
    mtxdp.setintensity(0)
    # clear display
    sevdp.clear()
    mtxdp.clear()
    lcd.clear()

    while True:
        # seven_segment_clock update
        seven_segment_clock.update()

        # 8x8 LED matrix
        led_clock_pointer_sec.update()
        led_clock_pointer_min.update()
        led_clock_flasher.update()

        # motion Sensor ck
        moss.update()
        # lcd
        lcd.setCursor(0, 0)
        lcd.print(time.strftime("%d/%m/%y"))
        lcd.setCursor(0, 1)
        lcd.print(time.strftime("%X"))
        hour = time.time()/(60*60) % 24
        # on off cycle
        if(13 < hour < 21):
            lcd.backlight(0)
            mtxdp.setstate(1)
            sevdp.setstate(1)
        else:
            mtxdp.setstate(0)
            sevdp.setstate(0)
            lcd.backlight(1)

        # clock
        time.sleep(updateintv)

@@ -237,16 +237,29 @@
 get_temp
+, get_netstat
 %0Afrom an
@@ -293,16 +293,37 @@
 nt_clock
+%0Afrom sys import argv
 %0A%0Amotion
@@ -418,16 +418,40 @@
 tv = .3%0A
+debug = %22debug%22 in argv%0A
 %0A%0Aif __n
@@ -1473,16 +1473,74 @@
   # lcd%0A
+        netstat = get_netstat()%0A        temp = get_temp()%0A
         
@@ -1581,32 +1581,29 @@
 int(
-time.strftime(%22%25d/%25m/%25y%22
+%22tmp: %7B%7D%22.format(temp
 ))%0A 
@@ -1651,28 +1651,57 @@
 int(
-time.strftime(%22%25X%22))
+%22net: %7B%7D%22.format(netstat))%0A        # on off cycle
 %0A   
@@ -1737,39 +1737,16 @@
 0) %25 24%0A
-        # on off cycle%0A
         
@@ -1762,16 +1762,30 @@
 our %3C 21
+ and not debug
 ):%0A     

debug argv and lcd content update