예제 #1
0
class ClockThread(threading.Thread):
    def __init__(self, settings):
        threading.Thread.__init__(self)
        self.segment = SevenSegment(address=0x70)
        self.stopping = False
        # self.settings = Settings.Settings()
        self.settings = settings
        self.colon = 0

    def stop(self):
        self.segment.disp.clear()
        self.stopping = True

    def run(self):
        while (not self.stopping):
            now = datetime.datetime.now(pytz.timezone(self.settings.get('timezone')))
            # hour = now.hour
            hour = int(now.strftime("%I").lstrip("0"))

            minute = now.minute
            second = now.second

            # Set hours
            self.segment.writeDigit(0, int(hour / 10))  # Tens
            self.segment.writeDigit(1, hour % 10)  # Ones
            # Set minutes
            self.segment.writeDigit(3, int(minute / 10))  # Tens
            self.segment.writeDigit(4, minute % 10)  # Ones
            # Toggle colon
            self.segment.writeDigitRaw(2, self.colon)
            self.colon = self.colon ^ 0x2

            time.sleep(1)
def write_temp_to_7segment (temp):
  segment = SevenSegment(address=0x71)
  hundreds = int (temp / 100)
  if (hundreds > 0):
      segment.writeDigit(1, hundreds)            # Hundreds 
  temp = temp - (hundreds * 100)
  segment.writeDigit(3, int(temp / 10))      # tens
  segment.writeDigit(4, int(temp % 10))      # ones 
예제 #3
0
class ClockThread(threading.Thread):

   def __init__(self):
      threading.Thread.__init__(self)
      self.segment = SevenSegment(address=0x70)
      self.stopping=False

   def stop(self):
      self.segment.disp.clear()
      self.stopping=True

   def run(self):
      while(not self.stopping):
          now = datetime.datetime.now(pytz.timezone('America/Los_Angeles'))
          hour = now.hour

          minute = now.minute
          second = now.second

          # Set hours
          self.segment.writeDigit(0, int(hour / 10))     # Tens
          self.segment.writeDigit(1, hour % 10)          # Ones
          # Set minutes
          self.segment.writeDigit(3, int(minute / 10))   # Tens
          self.segment.writeDigit(4, minute % 10)        # Ones

          time.sleep(1)
예제 #4
0
 def __init__(self, settings):
     threading.Thread.__init__(self)
     self.segment = SevenSegment(address=0x70)
     self.stopping = False
     # self.settings = Settings.Settings()
     self.settings = settings
     self.colon = 0
예제 #5
0
class ClockThread (threading.Thread):
	
	def __init__(self):
		threading.Thread.__init__(self)
		self._segment = SevenSegment(address=0x70)
		self._segment.disp.clear()
		self.ended = False
		
	@property
	def segment(self):
		return self._segment
		
	@property
	def hour(self):
		return self._hour
		
	@property
	def minute(self):
		return self._minute
	
	def end(self):
		self._segment.disp.clear()
		self.ended = True
	
	def run(self):
		while(self.ended != True):
			now = datetime.datetime.now()
			hour = now.hour
			minute = now.minute
			second = now.second
			
			self._hour = hour
			self._minute = minute
			
			hourTensPlace = int(hour / 10)
			hourOnesPlace = hour % 10
			minuteTensPlace = int(minute / 10)
			minuteOnesPlace = minute % 10
			
			self._segment.writeDigit(0, hourTensPlace)
			self._segment.writeDigit(1, hourOnesPlace)
			self._segment.writeDigit(3, minuteTensPlace)
			self._segment.writeDigit(4, minuteOnesPlace)
		self._segment.disp.clear()
		logger.info('Clock is powering down')
예제 #6
0
class SevenSegDisplay:

  def __init__(self, num_digits=4, address=0x70):
    self.num_digits = num_digits
    self.digit = 0
    self.seg = SevenSegment(address)

  def setup(self):
    return None

  def cleanup(self):
    return None

  def start(self):
    self.digit = 0

  def latch(self):
    return None

  def send_raw(self, segments):
    self.seg.writeDigitRaw(self.digit, segments)
    self.digit += 1
    # digits 2 is the colon, skip 
    if self.digit == 2:
      self.digit += 1

  def output(self, value):
    """ Outputs a string or a integer number onto 7-segment display."""
    raw = sevenseg.text(value, self.num_digits)
    self.start()
    for c in raw:
      self.send_raw(c)

  def blank(self):
    """ Blanks the display (all LED off). """
    raw = sevenseg.blanks(self.num_digits)
    self.start()
    for c in raw:
      self.send_raw(c)
#!/usr/bin/python

from Adafruit_7Segment import SevenSegment
import RPi.GPIO as io

#io.setmode(io.BCM)
segment = SevenSegment(address=0x70)

while True:
	position = raw_input('Position: ')
	if position == 'end': break
	elif position == 'clear':
		position = raw_input('Position: ')
		if position == 'all': segment.clear()
		else: segment.clear(int(position))
	else:
		number = raw_input('Number: ')
		'if len(number) == 1:'
		segment.writeDigit(int(position) , int(number))
		'else: print ''Must be digit'
	print segment.getBuffer()
segment.clear()
예제 #8
0
import RPi.GPIO as GPIO
import time
import datetime
from Adafruit_7Segment import SevenSegment
import os

GPIO.setmode(GPIO.BCM)
segment = SevenSegment(address=0x70)
GPIO.setup(18, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(16, GPIO.OUT)

while True:
    input_state = GPIO.input(18)
    if input_state == False:
        print('Button Pressed')
        segment.writeDigit(0, 0)
        segment.writeDigit(1, 0)
        segment.writeDigit(2, 0)
        segment.writeDigit(3, 1)
        time.sleep(0.2)
        GPIO.output(16, True)
    else:
        segment.writeDigit(0, 0)
        segment.writeDigit(1, 0)
        segment.writeDigit(2, 0)
        segment.writeDigit(3, 2)
        GPIO.output(16, False)
#!/usr/bin/python

import RPi.GPIO as GPIO
import time

sevenseg = True

if sevenseg:
    from Adafruit_7Segment import SevenSegment
    segment = SevenSegment(address=0x70)

GPIO.setmode(GPIO.BCM)

delay = 5  #milliseconds

#Setup Stepper Motor
coil_A_1_pin = 4
coil_A_2_pin = 17
coil_B_1_pin = 23
coil_B_2_pin = 24
GPIO.setup(coil_A_1_pin, GPIO.OUT)
GPIO.setup(coil_A_2_pin, GPIO.OUT)
GPIO.setup(coil_B_1_pin, GPIO.OUT)
GPIO.setup(coil_B_2_pin, GPIO.OUT)

#Setup Buttons
stepCWPin = 18
stepCCWPin = 25
GPIO.setup(stepCCWPin, GPIO.IN)
GPIO.setup(stepCWPin, GPIO.IN)
예제 #10
0
 def __init__(self):
     threading.Thread.__init__(self)
     self.segment = SevenSegment(address=0x70)
     self.stopping = False
예제 #11
0
	def __init__(self):
		threading.Thread.__init__(self)
		self._segment = SevenSegment(address=0x70)
		self._segment.disp.clear()
		self.ended = False
예제 #12
0
import time
from time import sleep

import RPi.GPIO as GPIO
from Adafruit_7Segment import SevenSegment

segment = SevenSegment(address=0x70)

# setup function


def setup():
    GPIO.setmode(GPIO.BCM)
    GPIO.setwarnings(False)
    GPIO.setup(25, GPIO.OUT)      # set output pin 25 as the status LED
    GPIO.setup(22, GPIO.IN)       # set input pin 22 as the start/stop switcher
    GPIO.setup(17, GPIO.IN)       # set input pin 17 as the reset switcher
    global n
    n = 0
    global _n
    _n = 0
    global encount                # button counter
    encount = 0
    global interruptFlag
    interruptFlag = 0


def isr():
    global n
    global interruptFlag
    global _n
예제 #13
0
#!/usr/bin/python

from Adafruit_7Segment import SevenSegment
import spidev
import time
import os
import RPi.GPIO as GPIO

GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM)
GPIO.setup(25,GPIO.OUT)
spi = spidev.SpiDev()
spi.open(0,0)
segment = SevenSegment(address=0x70)
DEBUG=1
print "Press CTRL+Z to exit"

def readadc(adcnum):
    if (adcnum > 7) or (adcnum < 0):
        return -1
    r = spi.xfer2([1,(8+adcnum)<<4,0])
    adcout = ((r[1]&3) << 8) + r[2]
    return adcout
# Light Sensor connected to adc #0
temp_adc = 4

# Continually update the time on a 4 char, 7-segment display
while True:
    GPIO.output(25, True)
    read_adc4 =readadc(temp_adc)
예제 #14
0
             'colon': 2,
           'topleft': 4,
        'bottomleft': 8,
          'topright':16 }
# - We can now set and clear the colon with calls such as
#   disp.setBufferRow(af7s_ledRow, af7s_FLAGS['colon']) #set colon
#   disp.setBufferRow(af7s_ledRow, af7s_FLAGS['blank']) #clear colon

# ===========================================================================
# Clock Example
# ===========================================================================

# instantiate a display controller at address 0x70 (this is the
# default address when no address selection links are soldered)
#
segment = SevenSegment(address=0x70)

print "Press CTRL+C to exit"
try:

  # Continuously update the time displayed
  # - this endless loop contains a 1 second delay
  # - digit displays are overwritten even if they remain unchanged

  # Note: we need to clear the display at startup, and there is also a
  #       a need to blank out the leading digits of the hours after a
  #       rollover from 23:59 or 11:59 back to zero. For convenience,
  #       keep track of previous_hours and then clear the display when
  #       the next hours is numerically < previous_time.
  previous_hours=25  # ensure display is initially cleared
예제 #15
0
# Copyright (c) 2015-2016 Sid Gadkari. All rights reserved.
# Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

# Last Revision Date: 02/15/2016

#!/usr/bin/python

# This script draws '----' and then clears the display of all data.

import time
import datetime
from Adafruit_7Segment import SevenSegment

display = SevenSegment(address=0x70)

# Clear display
display.disp.clear()
display.writeDigitRaw(0, 64)
display.writeDigitRaw(1, 64)
display.writeDigitRaw(3, 64)
display.writeDigitRaw(4, 64)
time.sleep(1)
display.disp.clear()
예제 #16
0
#!/usr/bin/python

import time
import datetime

import Adafruit_GPIO.SPI as SPI
#import Adafruit_MAX31855.MAX31855 as MAX31855
from MAX31855 import MAX31855

from Adafruit_7Segment import SevenSegment
from Adafruit_LEDBackpack import LEDBackpack

segment = SevenSegment(address=0x72)
backpack = LEDBackpack(address=0x72)

backpack.setBrightness(1)

# Define a function to convert celsius to fahrenheit.
def c_to_f(c):
          return c * 9.0 / 5.0 + 32.0

# Raspberry Pi software SPI configuration.
CLK = 24
CS  = 23
DO  = 18
#sensor = MAX31855.MAX31855(CLK, CS, DO)
sensor = MAX31855(CLK, CS, DO)


# ===========================================================================
# Clock Example
예제 #17
0
파일: tune.py 프로젝트: pdp7/beaglebackpack
# Output looks like this:
#
#    A B STATE SEQ DELTA SWITCH
#    1 1   3    2    1    0
#    0 1   2    3    1    0
#    0 0   0    0    1    0
#    1 0   1    1    1    0
#    1 1   3    2    1    0
#    0 1   2    3    1    0

from Adafruit_7Segment import SevenSegment
import gaugette.rotary_encoder
import gaugette.switch
import math

segment = SevenSegment(address=0x70)
segment.disp.setBufferRow(0, 0);
segment.disp.setBufferRow(1, 0);
segment.disp.setBufferRow(2, 0);
segment.disp.setBufferRow(3, 0);
segment.disp.setBufferRow(4, 0);

segment.writeDigit(0, 1);
segment.writeDigit(1, 2);
#segment.writeDigit(2, 0);
segment.writeDigit(3, 3);
segment.writeDigit(4, 4);

if gaugette.platform == 'raspberrypi':
    A_PIN  = 7
    B_PIN  = 9
예제 #18
0
import config
import time
from Adafruit_7Segment import SevenSegment
import urllib2
import json
import subprocess

REFRESH_INTERVAL = 20
SPACE = 0
DASH = 64

segment0 = SevenSegment(address=0x70)
segment1 = SevenSegment(address=0x71)
segment2 = SevenSegment(address=0x72)
segment3 = SevenSegment(address=0x73)

segment0.disp.setBrightness(1)
segment1.disp.setBrightness(1)
segment2.disp.setBrightness(1)
segment3.disp.setBrightness(1)

# K04 is Ballston station
STATION_ID = "K04"
API_KEY = config.api_key
prediction_url = "https://api.wmata.com/StationPrediction.svc/json/GetPrediction"

print "Press CTRL+Z to exit"

# fetch train predictions from WMATA API
def train_predictions():
    response  = urllib2.urlopen(prediction_url + "/" + STATION_ID + "?api_key=" + API_KEY)
예제 #19
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)
예제 #20
0
파일: tsp_timer.py 프로젝트: johngorosz/tsp
#!/usr/bin/python
# tsp_timer
#
# set timer display and handle button press

import RPi.GPIO as GPIO
import time
import datetime
from Adafruit_7Segment import SevenSegment
from Adafruit_LEDBackpack import LEDBackpack

segment = SevenSegment(address=0x73)
backpack = LEDBackpack(address=0x73)

backpack.setBrightness(15)

BUTTON_GPIO = 17

# states constants
STOP = 1
RUN = 2
HOLD = 3

timer_state = STOP
last_timer_state = STOP

hold_time = 0
timer_start = datetime.datetime.now()
run_time = datetime.timedelta(0)

GPIO.setmode(GPIO.BCM)
예제 #21
0
#!/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 color
    segment.setColon(second % 2)  # Toggle colon at 1Hz
    # Wait one second
    time.sleep(1)
예제 #22
0
import gps
import os
import time
import datetime
from Adafruit_7Segment import SevenSegment

os.system("sudo killall gpsd")
os.system("sudo gpsd /dev/ttyUSB0 -F /var/run/gpsd.sock")

segment = SevenSegment(address=0x70)

# Ecouter sur le port 2947 (gpsd) de localhost
session = gps.gps("localhost", "2947")
session.stream(gps.WATCH_ENABLE | gps.WATCH_NEWSTYLE)

while True:
    try:
        report = session.next()
        if report['class'] == 'TPV':
            if hasattr(report, 'speed'):
                print report.speed
                vitesse = report.speed * 3.6
                segment.writeDigit(1, int(vitesse / 10))
                if int(vitesse % 10) == 0: segment.writeDigitRaw(3, 63 + 128)
                if int(vitesse % 10) == 1: segment.writeDigitRaw(3, 6 + 128)
                if int(vitesse % 10) == 2: segment.writeDigitRaw(3, 91 + 128)
                if int(vitesse % 10) == 3: segment.writeDigitRaw(3, 79 + 128)
                if int(vitesse % 10) == 4: segment.writeDigitRaw(3, 102 + 128)
                if int(vitesse % 10) == 5: segment.writeDigitRaw(3, 109 + 128)
                if int(vitesse % 10) == 6: segment.writeDigitRaw(3, 125 + 128)
                if int(vitesse % 10) == 7: segment.writeDigitRaw(3, 7 + 128)
예제 #23
0
import sys
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
예제 #24
0
#!/usr/bin/python

##--Michael duPont (flyinactor91.com)
##--Test program to put numbers and letters onto a seven-segment display

from Adafruit_7Segment import SevenSegment
import RPi.GPIO as io

segment = SevenSegment(address=0x70)

while True:
    position = raw_input('Position: ')
    if position == 'end': break
    elif position == 'clear':
        position = raw_input('Position: ')
        if position == 'all': segment.clear()
        else: segment.clear(int(position))
    else:
        number = raw_input('Number: ')
        'if len(number) == 1:'
        segment.writeDigit(int(position), int(number))
        'else: print ' 'Must be digit'
    print segment.getBuffer()
segment.clear()
import time
from Adafruit_7Segment import SevenSegment

segment0 = SevenSegment(address=0x70)
segment1 = SevenSegment(address=0x71)
segment2 = SevenSegment(address=0x72)
segment3 = SevenSegment(address=0x73)

for i in [0,1,3,4]:
    segment0.writeDigit(i, 8)

for i in [0,1,3,4]:
    segment1.writeDigit(i, 8)

for i in [0,1,3,4]:
    segment2.writeDigit(i, 8)

for i in [0,1,3,4]:
    segment3.writeDigit(i, 8)

예제 #26
0
#!/usr/bin/python

import time
import datetime
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)
예제 #27
0
import sys

os.environ["SDL_FBDEV"] = "/dev/fb1"
pygame.init()
size = 320, 240
screen = pygame.display.set_mode(size)
pygame.mouse.set_visible(0)

#Setup GPIO
GPIO.setmode(GPIO.BCM)
GPIO.setup(4, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(17, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(21, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(22, GPIO.IN, pull_up_down=GPIO.PUD_UP)

segment = SevenSegment(address=0x70)

# Game Grid Matrix
O = 0	#OPEN SPACE
C = 1	#CAR
BF = 2	#BUS (front)
BB = 3	#BUS (back)
T = 4	#Turtle
LF = 5	#Log (front)
LM = 6	#Log (middle)
LB = 7	#Log (back)
TE = 8	#End Target (empty)
TF = 9	#End Target (full)
X = 10	#Unusable Space
OC = 11 #Open Car Space
OL = 12 #Open Log Space
예제 #28
0
#!/usr/bin/python

import time
import datetime
import Adafruit_BMP.BMP085 as BMP085

from Adafruit_7Segment import SevenSegment

segment = SevenSegment(address=0x70)

print "Press CTRL+Z to exit"

sensor = BMP085.BMP085()

presure=sensor.read_pressure()/100;


# Continually update the time on a 4 char, 7-segment display
while(True):
  presure=sensor.read_pressure()/100;
  print(presure)
  segment.writeDigit(0, int(str(presure)[0]),True)     
  segment.writeDigit(1, int(str(presure)[1]))          
  segment.writeDigit(3, int(str(presure)[2]))  
  segment.writeDigit(4, int(str(presure)[3]))                    
  # Wait one second
  time.sleep(1)

# To specify a different operating mode, uncomment one of the following:
# bmp = BMP085(0x77, 0)  # ULTRALOWPOWER Mode
# bmp = BMP085(0x77, 1)  # STANDARD Mode
# bmp = BMP085(0x77, 2)  # HIRES Mode
# bmp = BMP085(0x77, 3)  # ULTRAHIRES Mode

# COSM variables. The API_KEY and FEED are specific to your COSM account and must be changed
API_KEY = "USE_YOUR_API_KEY"
FEED = 987654

API_URL = "/v2/feeds/{feednum}.xml".format(feednum=FEED)


# Initialize a LED display
segment = SevenSegment(address=0x71)

# OUTPUT_IN_F = True
OUTPUT_IN_F = False

LOGGER = True
COUNT = 0

# Continually update the temp on a 4 char, 7-segment display
while True:

    error_tables = {}

    try:

        temp = bmp.readTemperature()
예제 #30
0
#!/usr/bin/python

import time
import datetime
from Adafruit_7Segment import SevenSegment

segment = SevenSegment(address=0x70)

print "Press CTRL+Z to exit."

digit2_colon = 0x02
digit2_dot = 0x10
digit0 = 0

while(True):
  now = datetime.datetime.now()
  hour = now.hour
  minute = now.minute
  second = now.second
  dots = 0x0
  dots = dots^digit2_dot if (hour >= 12) else dots
  dots = dots^digit2_colon if (second % 2) else dots
  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()
예제 #31
0
#!/usr/bin/python
import time
import datetime
import RPi.GPIO as GPIO
from Adafruit_7Segment import SevenSegment

segment = SevenSegment(address=0x70)

# Use BCM GPIO references
# instead of physical pin numbers
GPIO.setmode(GPIO.BCM)

# Define GPIO to use on Pi
GPIO_TRIGGER = 23
GPIO_ECHO = 24

adjustment = 7

# Set pins as output and input
GPIO.setup(GPIO_TRIGGER,GPIO.OUT)  # Trigger
GPIO.setup(GPIO_ECHO,GPIO.IN)      # Echo
while True:
  # Set trigger to False (Low)
  GPIO.output(GPIO_TRIGGER, False)

  # Allow module to settle
  time.sleep(0.5)

  # Send 10us pulse to trigger
  GPIO.output(GPIO_TRIGGER, True)
  time.sleep(0.00001)
#!/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(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
from Adafruit_7Segment import SevenSegment
import time, datetime
import RPi.GPIO as GPIO

switch_pin = 18
GPIO.setmode(GPIO.BCM)
GPIO.setup(switch_pin, GPIO.IN, pull_up_down=GPIO.PUD_UP)
disp = SevenSegment(address=0x70)

time_mode, seconds_mode, date_mode = range(3)
disp_mode = time_mode


def display_time():
    # Get the time by separate parts for the clock display
    now = datetime.datetime.now()
    hour = now.hour
    minute = now.minute
    second = now.second
    # Set hours
    disp.writeDigit(0, int(hour / 10))  # Tens
    disp.writeDigit(1, hour % 10)  # Ones
    # Set minutes
    disp.writeDigit(3, int(minute / 10))  # Tens
    disp.writeDigit(4, minute % 10)  # Ones
    # Toggle colon
    disp.setColon(second % 2)  # Toggle colon at 1Hz


def disply_date():
    now = datetime.datetime.now()
예제 #34
0
__author__ = 'Justin'

# ===========================================================================
# Main clock program
# ===========================================================================

import time
import datetime
from Adafruit_7Segment import SevenSegment
from Adafruit_LEDBackpack import LEDBackpack
from clock_API import ClockAPI

print "Press CTRL+Z to exit"

segment = SevenSegment(address=0x70)
backpack = LEDBackpack()
data = ClockAPI()

backpack.setBrightness(0)

API_data = data.getWeatherCondition('seattle', 'F')

temp = API_data[2]

print datetime.datetime.now()
print API_data
print temp


# Continually update the time on a 4 char, 7-segment display
# while True:
예제 #35
0
# CTA bus tracker
# 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
예제 #36
0
#!/usr/bin/python
import time
import datetime
import RPi.GPIO as GPIO
from Adafruit_7Segment import SevenSegment

segment = SevenSegment(address=0x70)

# Use BCM GPIO references
# instead of physical pin numbers
GPIO.setmode(GPIO.BCM)

# Define GPIO to use on Pi
GPIO_TRIGGER = 23
GPIO_ECHO = 24

adjustment = 7

# Set pins as output and input
GPIO.setup(GPIO_TRIGGER,GPIO.OUT)  # Trigger
GPIO.setup(GPIO_ECHO,GPIO.IN)      # Echo
while True:
  # Set trigger to False (Low)
  GPIO.output(GPIO_TRIGGER, False)

  # Allow module to settle
  time.sleep(0.5)

  # Send 10us pulse to trigger
  GPIO.output(GPIO_TRIGGER, True)
  time.sleep(0.00001)
예제 #37
0
#!/usr/bin/python

##--Michael duPont (flyinactor91.com)
##--Display increasing values on the seven-segment display

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)
예제 #38
0
 def __init__(self):
    threading.Thread.__init__(self)
    self.segment = SevenSegment(address=0x70)
    self.stopping=False
# To specify a different operating mode, uncomment one of the following:
# bmp = BMP085(0x77, 0)  # ULTRALOWPOWER Mode
# bmp = BMP085(0x77, 1)  # STANDARD Mode
# bmp = BMP085(0x77, 2)  # HIRES Mode
# bmp = BMP085(0x77, 3)  # ULTRAHIRES Mode

# COSM variables. The API_KEY and FEED are specific to your COSM account and must be changed 
API_KEY = 'USE_YOUR_API_KEY'
FEED = 987654
 
API_URL = '/v2/feeds/{feednum}.xml' .format(feednum = FEED)


# Initialize a LED display
segment = SevenSegment(address=0x71)

#OUTPUT_IN_F = True
OUTPUT_IN_F = False

LOGGER = True
COUNT = 0

# Continually update the temp on a 4 char, 7-segment display
while(True):
    
    error_tables = {}

    try: 

        temp = bmp.readTemperature()
예제 #40
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import time
import datetime
from time import sleep
import RPi.GPIO as GPIO
from Adafruit_7Segment import SevenSegment
# ===========================================================================
# Clock Example
# ===========================================================================
segment = SevenSegment(address=0x70)
counter = 0
minute = 0

GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)

# input signal, startstop bottom and reset bottom
GPIO.setup(24, GPIO.IN)
GPIO.setup(23, GPIO.IN)
flg = True
while(True):
    reset = GPIO.input(24)
    startstop = GPIO.input(23)
    if reset:
        counter = 0
        minute = 0

    if startstop and flg:
        flg = False
    if startstop and not flg:
예제 #41
0
#!/usr/bin/python

import os
import logging
import math
import requests
import signal
import sys
import time
import datetime
from Adafruit_7Segment import SevenSegment
from astral import Astral

segment = SevenSegment(address=0x77)

APP_HOME = os.path.dirname(os.path.realpath(__file__))
FORMAT = '%(asctime)-15s %(levelname)s:%(message)s'
logging.basicConfig(format=FORMAT,
                    filename=APP_HOME + '/log/clock.err',
                    level=logging.ERROR)
# format=FORMAT, filename=APP_HOME + '/log/clock.log', level=logging.DEBUG)


def receive_signal(signal, frame):
    logging.debug('received signal: %s', signal)
    segment.clear()
    sys.exit(0)


signal.signal(signal.SIGUSR1, receive_signal)
signal.signal(signal.SIGUSR2, receive_signal)
#!/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)
예제 #43
0
	digitCount += 1
	decimalPoint = ((digitCount + 1) == decimal)

	display.writeDigit(3, int(temp / 10), decimalPoint)					# Tens

	#	Set the second digit of the decimal portion
	digitCount += 1
	decimalPoint = ((digitCount + 1) == decimal)

	display.writeDigit(4, temp % 10, decimalPoint)						# Ones

# ===========================================================================
# Clock Example
# ===========================================================================
#	Yellow 4 digit 7-Segment Display at address 0x70
sevenSeg = SevenSegment(address=0x70)

#	Yellow Matrix 8x8 Display at address 0x71
matrix8x8 = EightByEight(address=0x71)

#	Bi-Color Matrix 8x8 Display at address 0x73
#bicolor8x8 = ColorEightByEight(address=0x73)

matrix8x8.setRotation(3)
#bicolor8x8.setRotation(3)

bmp180 = BMP085(address=0x77)

print "Press CTRL+C to exit"

countLimit = 45