#!/usr/bin/python

from datetime import timedelta

# ===========================================================================
# Clockatoo - Text Example
# ===========================================================================
with open('/proc/uptime', 'r') as f:
	uptime_seconds = float(f.readline().split()[0])
	uptime_string = str(timedelta(seconds = uptime_seconds))

from Raspi_7Segment import SevenSegment
segment = SevenSegment(address=0x70)
segment.writeTextString('hello world',0.2)
segment.writeTextString('uptime ' + uptime_string,0.2)
#!/usr/bin/python

import time
import datetime
from Raspi_7Segment import SevenSegment

# ===========================================================================
# Clock Example
# ===========================================================================
segment = SevenSegment(address=0x70)

print "Press CTRL+Z to exit"

# Continually update the time on a 4 char, 7-segment display
while True:
    now = datetime.datetime.now()
    hour = now.hour
    minute = now.minute
    second = now.second
    # Set hours
    segment.writeDigit(0, int(hour / 10))  # Tens
    segment.writeDigit(1, hour % 10)  # Ones
    # Set minutes
    segment.writeDigit(3, int(minute / 10))  # Tens
    segment.writeDigit(4, minute % 10)  # Ones
    # Toggle color
    segment.setColon(second % 2)  # Toggle colon at 1Hz
    # Wait one second
    time.sleep(1)
#!/usr/bin/python

import time
import datetime
from Raspi_7Segment import SevenSegment

# ===========================================================================
# Clockatoo - Clock Example
# ===========================================================================
segment = SevenSegment(address=0x70)

print "Press CTRL+Z to exit"
segment.writeTextString('welcome to clockatoo - press ctrl-z to exit',0.2)

# Continually update the time on a 4 char, 7-segment display
while(True):
  now = datetime.datetime.now()
  hour = now.hour
  minute = now.minute
  second = now.second
  # Set hours
  segment.writeDigit(0, int(hour / 10))     # Tens
  segment.writeDigit(1, hour % 10)          # Ones
  # Set minutes
  segment.writeDigit(3, int(minute / 10))   # Tens
  segment.writeDigit(4, minute % 10)        # Ones
  # Toggle color
  segment.setColon(second % 2)              # Toggle colon at 1Hz
  # Wait one second
  time.sleep(1)