def __init__(self, address=0x70, bus=Adafruit_I2C.getPiI2CBusNumber(), debug=False): self.i2c = Adafruit_I2C(address, bus) self.address = address self.debug = debug # Turn the oscillator on self.i2c.write8(self.__HT16K33_REGISTER_SYSTEM_SETUP | 0x01, 0x00) # Turn blink off self.setBlinkRate(self.__HT16K33_BLINKRATE_OFF) # Set maximum brightness self.setBrightness(15) # Clear the screen self.clear()
#!/usr/bin/python import time import datetime from Adafruit_7Segment import SevenSegment from Adafruit_I2C import Adafruit_I2C # =========================================================================== # Clock Example # =========================================================================== i2CBus = Adafruit_I2C.getPiI2CBusNumber() # if using this example with a BeagleBone, uncomment the line below and specify # which I2C Bus the backpack is connected on. If connected to I2C1 (Header P9, # pin 17 & 18) specify 1, if connected to I2C2 (Header P9, pin 19 & 20) specify 3. # WARNING: if using with a BeagleBone use a logic-level convertor such as this one # https://www.adafruit.com/products/757 # i2CBus = 1 | 3 segment = SevenSegment(address=0x70, bus=i2CBus) 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
#camera.crop = sizeData[sizeMode][2] camera.crop = (0.0, 0.0, 1.0, 1.0) # Leave raw format at default YUV, don't touch, don't set to RGB! # Load all icons at startup. for file in os.listdir(iconPath): if fnmatch.fnmatch(file, '*.png'): icons.append(Icon(file.split('.')[0])) # Initialize I2C try: # print "Initialize I2C" AdaI2C = Adafruit_I2C(0x36) Adafruit_I2C.__init__(AdaI2C, 0x36) AdaI2C.address = 0x36 # SparkFun "Fuel Gauge" AdaI2C.bus = smbus.SMBus(Adafruit_I2C.getPiI2CBusNumber()) Adafruit_I2C.write16(AdaI2C, 0xFE, 0x0054) # POR register Adafruit_I2C.write16(AdaI2C, 0x0C, 0x00FE) # RCOMP register time.sleep(10) # Initialize GPIO GPIO.setmode(GPIO.BCM) GPIO.setup(17, GPIO.IN) # Monitor Charging Status LED on LiPo Charger GPIO.setup(18, GPIO.OUT) # Controls an Alarm LED during last 20% Battey Life GPIO.output(18, GPIO.HIGH) updFuelGauge() getFuelLevel() # print "Default I2C bus is accessible" except: # print "Error accessing default I2C bus" pass
def __init__(self, address=0x70, bus=Adafruit_I2C.getPiI2CBusNumber(), debug=False): if (debug): print "Initializing a new instance of LEDBackpack at 0x%02X" % address self.disp = LEDBackpack(address=address, bus=bus, debug=debug)