#!/usr/bin/python

import time
import datetime
from Adafruit_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 colon
  segment.setColon(second % 2)              # Toggle colon at 1Hz
  # Wait one second
  time.sleep(1)
Exemplo n.º 2
0
        lastAmTime = amTime

        if hour > 11:
            hour = hour - 12
            amTime = False
        else:
            amTime = True

        if hour == 0:
            hour = 12

        minute = now.minute
        second = now.second

        #	Turn colon on
        sevenSeg.setColon(True)

        if displayCleared or (lastHour != hour):
            #	Set hours
            if hour > 9:
                sevenSeg.writeDigit(0, int(hour / 10))  # Tens
            else:
                #	Clear the 7 segment display
                sevenSeg.clear()
                displayCleared = True

            sevenSeg.writeDigit(1, hour % 10)  # Ones

        #	Only display if minute has changed or display was cleared
        if displayCleared or (lastMinute != minute):
            #	Set minutes
#!/usr/bin/python

from Adafruit_7Segment import SevenSegment
import time

segment = SevenSegment(address=0x70)
num = 0
rest = float(raw_input('Step: '))
while True:
    segment.setColon((num / 10000) % 2)
    segment.writeDigit(0, (num / 1000) % 10)
    segment.writeDigit(1, (num / 100) % 10)
    segment.writeDigit(3, (num / 10) % 10)
    segment.writeDigit(4, num % 10)
    num += 1
    time.sleep(rest)
Exemplo n.º 4
0
    if startstop and not flg:
        flg = True

    if not flg:
        sleep(1)
        print "stopped"
    else:
        a4 = counter % 10
        a3 = counter / 10
        a2 = minute % 10
        a1 = minute / 10
        segment.writeDigit(4, a4)
        segment.writeDigit(3, a3)
        # segment.writeDigit(1,a2)
        # segment.writeDigit(0,a1)
        segment.setColon(counter % 2)
        segment.writeDigit(1, a2)
        segment.writeDigit(0, a1)
        sleep(1)

        counter = counter + 1
        if counter == 60:
            counter = 0
            minute = minute + 1
    # 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
from Adafruit_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 colon(s) as configured in Adafruit_7Segment.py
  # every second (by using even seconds vs. odd seconds)
  if (second % 2 == 0):                 # reminder = 0 -> even second
    segment.setColon(0)                 # turn colons off
  else:                                 # reminder != 0 -> odd second
    segment.setColon(1)                 # turn colons on
  
  time.sleep(1)                             # Wait one second
#!/usr/bin/python

import time
import datetime
from Adafruit_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 colon
    segment.setColon(second % 2)  # Toggle colon at 1Hz
    # Wait one second
    time.sleep(1)
Exemplo n.º 7
0
        m_floor = math.floor(abs(temp_city))
        logging.debug('m_floor: %s', m_floor)

        hour_tens = int(m_floor / 10)
        logging.debug('hour_tens: %s', hour_tens)

        hour_ones = int(m_floor % 10)
        logging.debug('hour_ones: %s', hour_ones)

        min_tens = int("%.0f" % ((abs(temp_city) - m_floor) * 10))
        logging.debug('min_tens: %s', min_tens)

        if (negative_temp):
            min_ones = 0xE
        else:
            if (FAHRENHEIT):
                min_ones = 0xF
            else:
                min_ones = 0xC

    # Set hours
    segment.writeDigit(0, hour_tens)  # Tens
    segment.writeDigit(1, hour_ones, dot)  # Ones
    # Set minutes
    segment.writeDigit(3, min_tens)  # Tens
    segment.writeDigit(4, min_ones)  # Ones
    # Toggle colon
    segment.setColon(not dot and second % 2)  # Toggle colon at 1Hz
    # Wait one second
    time.sleep(1)
Exemplo n.º 8
0
from Adafruit_7Segment import SevenSegment

segment = SevenSegment(address=0x70)

print "Press CTRL+Z to exit."

digit0 = 0

while(True):
  now = datetime.datetime.now()
  hour = now.hour
  minute = now.minute
  second = now.second
  pm = 1 if (hour >= 12) else 0
  if hour == 0:
    hour = 12
  if hour > 12:
    hour = hour - 12
  if hour >= 10 and digit0 == 0:
    segment.writeDigit(0, 1)
    digit0 = 1
  if hour < 10 and digit0 == 1:
    segment.disp.clear()
    digit0 = 0
  segment.writeDigit(1, hour % 10)
  segment.writeDigit(3, int(minute / 10))
  segment.writeDigit(4, minute % 10, pm)
  segment.setColon(second % 2)
  time.sleep(0.25)

Exemplo n.º 9
0
# www.taylorhokanson.com
# Requires a Raspberry Pi and Adafruit 7-segment display
# Get API key:  http://www.transitchicago.com/developers/traintrackerapply.aspx
# Get bus stop info:  http://www.transitchicago.com/riding_cta/how_to_guides/bustrackerlookup_stoplists.aspx

from bs4 import BeautifulSoup
from lxml import etree
import urllib2
import string
import time
import datetime
from lxml import etree
from Adafruit_7Segment import SevenSegment

segment = SevenSegment(address=0x70)
segment.setColon(False)

# Grand & Noble Eastbound
routeNumber = "your route number goes here"
stopID = "your stop ID goes here" 		
apiKey = "your API key goes here"			
updateFreq = 10

# variables that will hold individual predictions returned by API
predictionString = ""
predictionString2 = ""

# loop that runs forever
while(True):
	# the list we'll store predictions in
	allPredictionsList = list("")	
        print "Pressure:    %.2f hPa" % (pressure / 100.0)
        print "Altitude:    %.2f m" % altitude
        print "Press CTRL+C to exit"
        print ""

        for display_tmp_in_F in [False, True]:

            if display_tmp_in_F:
                if round(temp_in_F * 10.0) < 1000.0:
                    # write degrees
                    segment.writeDigit(0, int(round(temp_in_F) / 10))     # Tens
                    segment.writeDigit(1, int(round(temp_in_F) % 10))          # Ones
                    segment.writeDigit(3, int(int(round(temp_in_F * 10.0)) % 10))   # Tenth
                    segment.writeDigit(4, 15)        # F
                    
                    segment.setColon(1)              # 
                else:
                    # write degrees
                    segment.writeDigit(0, int(round(temp_in_F) / 100))     # Hundreds
                    segment.writeDigit(1, int(round(temp_in_F - 100.0) / 10))      # Tens
                    segment.writeDigit(3, int(round(temp_in_F) % 10))      # Ones
                    segment.writeDigit(4, 15)        # F

                    segment.setColon(0)               

            else:
                # write degrees
                segment.writeDigit(0, int(round(temp) / 10))     # Tens
                segment.writeDigit(1, int(round(temp) % 10))          # Ones
                segment.writeDigit(3, int(int(round(temp * 10.0)) % 10))   # Tenth
                segment.writeDigit(4, 12)        # c
        print "Pressure:    %.2f hPa" % (pressure / 100.0)
        print "Altitude:    %.2f m" % altitude
        print "Press CTRL+C to exit"
        print ""

        for display_tmp_in_F in [False, True]:

            if display_tmp_in_F:
                if round(temp_in_F * 10.0) < 1000.0:
                    # write degrees
                    segment.writeDigit(0, int(round(temp_in_F) / 10))  # Tens
                    segment.writeDigit(1, int(round(temp_in_F) % 10))  # Ones
                    segment.writeDigit(3, int(int(round(temp_in_F * 10.0)) % 10))  # Tenth
                    segment.writeDigit(4, 15)  # F

                    segment.setColon(1)  #
                else:
                    # write degrees
                    segment.writeDigit(0, int(round(temp_in_F) / 100))  # Hundreds
                    segment.writeDigit(1, int(round(temp_in_F - 100.0) / 10))  # Tens
                    segment.writeDigit(3, int(round(temp_in_F) % 10))  # Ones
                    segment.writeDigit(4, 15)  # F

                    segment.setColon(0)

            else:
                # write degrees
                segment.writeDigit(0, int(round(temp) / 10))  # Tens
                segment.writeDigit(1, int(round(temp) % 10))  # Ones
                segment.writeDigit(3, int(int(round(temp * 10.0)) % 10))  # Tenth
                segment.writeDigit(4, 12)  # c
Exemplo n.º 12
0
import time
import signal
from datetime import datetime
from Adafruit_7Segment import SevenSegment

GPIO.setmode(GPIO.BCM)
GPIO.setup(18, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(23, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(24, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(25, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(4, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(17, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(22, GPIO.IN, pull_up_down=GPIO.PUD_UP)

segment = SevenSegment(address=0x70)
segment.setColon(0)
#segment.print_hex(0, '0x40')

def signal_handler(signal, frame):
    print 'You pressed Ctrl+C!'
    sys.exit(0)

def raceStart(channel):
  global dt_RaceStart
  dt_RaceStart = datetime.now()
  #print "Start of race = " + str(dt_RaceStart)
  carFinished("START")

def lane1(channel):
  lane = 1
  carFinished(lane)
Exemplo n.º 13
0
import Adafruit_BBIO.ADC as ADC
import time
import datetime
from Adafruit_7Segment import SevenSegment
segment = SevenSegment(address=0x70)
sensor_pin = 'P9_40'
ADC.setup()
while(True):
    reading = ADC.read(sensor_pin)
    millivolts = reading * 1800
    temp_c = (millivolts - 500) / 10
    segment.writeDigit(0, int(temp_c / 10))
    segment.writeDigit(1, int(temp_c % 10))
    segment.writeDigit(3, 12)
    segment.setColon(1)
    time.sleep(1)
Exemplo n.º 14
0
import Adafruit_BBIO.ADC as ADC
import time
import datetime
from Adafruit_7Segment import SevenSegment

segment = SevenSegment(address=0x70)
sensor_pin = "P9_40"

ADC.setup()

while True:
    reading = ADC.read(sensor_pin)
    millivolts = reading * 1800
    temp_c = (millivolts - 500) / 10

    segment.writeDigit(0, int(temp_c / 10))
    segment.writeDigit(1, int(temp_c % 10))
    segment.writeDigit(3, 12)

    segment.setColon(1)
    time.sleep(1)
Exemplo n.º 15
0
			#	Set minutes
			sevenSeg.writeDigit(3, int(minute / 10))	# Tens
			sevenSeg.writeDigit(4, minute % 10)			# Ones

		#	Only display if time has changed from AM to PM or PM to AM, or the display was cleared
		if displayCleared or (lastAmTime != amTime):
			#	Display the am / pm indicator
			if amTime:
				drawBitMap(matrix8x8, am_bmp)
#				drawBitMap(bicolor8x8, am_bmp, displayColor)
			else:
				drawBitMap(matrix8x8, pm_bmp)
#				drawBitMap(bicolor8x8, pm_bmp, displayColor)

		#	Toggle colon at 1 Hz
		sevenSeg.setColon(second % 2)

		#	Wait one second
		sleep(1)

		#	Count seconds
		count += 1

		lastHour = hour
		lastMinute = minute

		displayCleared = False
		#	End of while(count < countLimit)

	#	Turn colon off
	sevenSeg.setColon(False)