Skip to content

Instantly share code, notes, and snippets.

@MusicalCreeper01
Created November 11, 2016 05:06
Show Gist options
  • Save MusicalCreeper01/2ddfb3603c49e2d6b1b37afef28f3bb9 to your computer and use it in GitHub Desktop.
Save MusicalCreeper01/2ddfb3603c49e2d6b1b37afef28f3bb9 to your computer and use it in GitHub Desktop.
#!/usr/bin/python
# example driver for BM017 and TCS34725
import time
import smbus
from Adafruit_I2C import Adafruit_I2C
from PC_BM017CS import BM017
import Tkinter
top = Tkinter.Tk()
bm017 = BM017(True)
bm017.debug = False
bm017.readStatus()
bm017.isBM017There()
bm017.setInterrupt(True)
while True:
bm017.getColors()
clear = bm017.clear_color
red = bm017.red_color
blue = bm017.blue_color
green = bm017.green_color
print "c: %s r: %s g: %s b: %s" % (clear, red, green, blue)
if zero != 0:
#convert to RGB(0-255)
red = red * 255 / clear
green = green * 255 / clear
blue = blue * 255 / clear
#red *= 256
else:
red = 0;
green = 0;
blue = 0;
mycolor = '#%02x%02x%02x' % (red, green, blue)
top.configure(bg=mycolor)
top.update()
#bm017.readStatus()
#bm017.disableDevice()
#bm017.setIntegrationTimeAndGain(0x00, 0x03)
#bm017.getColors()
#bm017.readStatus()
#bm017.readStatus()
# this will turn on the LED if LEDON is connected to INT and LEDVDD is connected to VDD_LED
#bm017.setInterrupt(True)
#time.sleep(5.0)
#bm017.setInterrupt(False)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment