Esempio n. 1
0
    def on_print_progress(self, storage, path, progress):
        lcd.clear()
        start = path.rfind('/')
        end = path.rfind('.')
        # Just want the file name, no path or extension.
        # The rfind gets us the deepest directory so we can truncate that off the string
        # It also gets us the index of the file extension
        # The code below will substring any directories off the path, and remove the extention
        if (start == -1):
            start = 0
        if (end == -1):
            end = path.len() - 1
        lcd.write(path[start:end])
        backlight.set_graph(progress / 100.0)
        backlight.rgb(0, 0, 255)
        backlight.update()
        lcd.set_cursor_position(0, 1)
        lcd.write('Completed: ' + str(progress) + '%')

        if progress == 1:
            self.start_date = time.time()

        if progress > 10 and progress < 100:
            now = time.time()
            elapsed = now - self.start_date
            average = elapsed / (progress - 1)
            remaining = int((100 - progress) * average)
            remaining = str(datetime.timedelta(seconds=remaining))
            lcd.set_cursor_position(0, 2)
            lcd.write('ETC: ')
            lcd.write(remaining)

        if progress == 100:
            self.JobIsDone(lcd)
Esempio n. 2
0
	def redraw(self, menu):
		lcd.clear()
		lcd.set_cursor_position(3,1)
		lcd.write("Bye (^_^)/")
		for x in reversed(range(127)):
			backlight.rgb(0, x * 2, 0)
		lcd.clear()
		sys.exit(0)
Esempio n. 3
0
def lcdInfo(lcdMessage, line, rgb=""):

    lcd.set_cursor_position(0, line)
    lcd.write(lcdMessage)
    if rgb == "red":
        backlight.rgb(200, 0, 0)
    if rgb == "green":
        backlight.rgb(0, 200, 0)
 def redraw(self, menu):
     print "Bye ;)"
     lcd.clear()
     lcd.set_cursor_position(4, 1)
     lcd.write("Bye Bye!")
     time.sleep(2)
     lcd.clear()
     backlight.rgb(0, 0, 0)
     sys.exit()
    def redraw(self, menu):
        print "Bye ;)"
	lcd.clear()
	lcd.set_cursor_position(4,1)
	lcd.write("Bye Bye!")
	time.sleep(2)
	lcd.clear()
	backlight.rgb(0,0,0)
	sys.exit()
Esempio n. 6
0
 def JobIsDone(self, localLcd):
     lcd.clear()
     backlight.rgb(255, 255, 255)
     localLcd.write('Job is Done!')
     for i in range(0, 100):
         backlight.set_graph((100 - i) / 100.0)
         time.sleep(0.05)
     backlight.update()
     lcd.clear()
     lcd.write('Ready for the   next job')
Esempio n. 7
0
def handle_button(pin):
    global ButtonStatus
    global loopcount
    if ButtonStatus == 'On':
        backlight.off()
        ButtonStatus = 'Off'
    else:
        loopcount = 0
        backlight.rgb(229, 0, 255)
        ButtonStatus = 'On'
Esempio n. 8
0
def handle_down(pin):
    global loopcount
    loopcount = 0
    lcd.clear()
    backlight.rgb(255, 0, 0)
    lcd.write("Shutting Down!")
    time.sleep(1)
    os.system('systemctl poweroff')
    sys.exit()
    time.sleep(2)
Esempio n. 9
0
def handle_up(pin):
    global screen_on
    global reset_initiated
    print("Up pressed!")
    #print(screen_on)

    if screen_on:
        backlight.rgb(0, 0, 0)
        screen_on = False
    else:
        backlight.rgb(200, 200, 200)
        screen_on = True

    reset_initiated = False
Esempio n. 10
0
def handle_up(pin):
    global screen_on
    global reset_initiated
    print("Up pressed!")
    #print(screen_on)

    if screen_on:
        backlight.rgb(0, 0, 0)
        screen_on = False
    else:
        backlight.rgb(200, 200, 200)
        screen_on = True

    reset_initiated = False
Esempio n. 11
0
	def handle_press (pin):
		global camera_running

		lcd.clear()
		lcd.write("Stopping camera...")
		backlight.rgb(0, 0, 0)
		sleep(0.5)
		print "Stopping camera..."
		camera_running = False

		camera.terminate()
		camera.join()

		lcd.clear()
		lcd.write("Camera stopped...")
		sleep(0.5)
		print "Camera stopped..."
def display():
    forecast = darksky.Forecast(api_key, latitude, longitude, units=units)
    current = forecast.currently
    temp = current.temperature
    temp = str(temp)
    humidity = current.humidity * 100
    humidity = str(humidity)
    rain = current.precipProbability * 100
    rain = str(rain)
    uvIndex = current.uvIndex
    uv = str(uvIndex)
    if uvIndex <= 2.9:
        backlight.rgb(90, 148, 35)  # Green (low)
    elif (uvIndex >= 3) and (uvIndex <= 5.9):
        backlight.rgb(241, 227, 54)  # Yellow (moderate)
    elif (uvIndex >= 6) and (uvIndex <= 7.9):
        backlight.rgb(217, 90, 18)  # Orange (high)
    elif (uvIndex >= 8) and (uvIndex <= 10.9):
        backlight.rgb(185, 2, 34)  # Red (very high)
    else:
        backlight.rgb(99, 74, 195)  # Violet (extreme)
    try:
        lcd.clear()
        lcd.set_cursor_position(0, 0)
        print("Temperture: " + temp + " C")
        lcd.write("Temp: " + temp + "\xf2C")
        lcd.set_cursor_position(0, 1)
        print("Humidity: " + humidity + "%")
        lcd.write("Humidity: " + humidity + "%")
        lcd.set_cursor_position(0, 2)
        print("Rain: " + rain + "%")
        lcd.write("Rain: " + rain + "%")
        print("UV Index: " + uv + "")
    except:
        lcd.write("Connection Error")

    # Press the button on the joystick to exit
    @nav.on(nav.BUTTON)
    def handle_button(pin):
        lcd.clear()
        backlight.rgb(0, 0, 0)
        backlight.set_graph(0)
        os._exit(1)
Esempio n. 13
0
def init_animation():
	hourglass = [
		[0x1F,0x11,0x11,0x11,0x11,0x11,0x11,0x1F],[0x1F,0x1F,0x11,0x11,0x11,0x11,0x11,0x1F],
		[0x1F,0x1F,0x1F,0x11,0x11,0x11,0x11,0x1F],[0x1F,0x1F,0x1F,0x1F,0x11,0x11,0x11,0x1F],
		[0x1F,0x11,0x1F,0x1F,0x1F,0x11,0x11,0x1F],[0x1F,0x11,0x11,0x1F,0x1F,0x1F,0x11,0x1F],
		[0x1F,0x11,0x11,0x11,0x1F,0x1F,0x1F,0x1F],[0x1F,0x11,0x11,0x11,0x11,0x1F,0x1F,0x1F],
		[0x1F,0x11,0x11,0x11,0x11,0x11,0x1F,0x1F],[0x1F,0x11,0x11,0x11,0x11,0x11,0x11,0x1F]
	]
	greetingtext = [
	#	"- - - - - - - - ",
		"     Welcome    ",
		"       To       ",
		"    Yuki-Chan   "
	]
	
	dotc = 0
	texti = 0
	for x in range(127):
		backlight.rgb(x / 2, x * 2, x / 2)
		"""
		lcd.create_char(0, getAnimFrame(hourglass, 5))
		lcd.clear()
		lcd.set_cursor_position(15,2)
		lcd.write(chr(0))
		"""
		lcd.set_cursor_position(0,1)
		lcd.write(greetingtext[texti])
		
		if dotc > 30:
			texti = (texti + 1) % len(greetingtext)
			dotc = 0
		else:
			dotc += 1
		
		lcd.set_cursor_position(6,2)
		for i in range(dotc / 10):
			lcd.write(".")

	lcd.clear()
Esempio n. 14
0
	def color(self, temp):
		try: 
			if temp <= self.midtemp:
				increment = int((temp - self.mintemp)  * self.step)
				green = 0 + increment
				blue = 255 - increment
				red = 0
				backlight.rgb(red, green, blue)
			elif temp > self.midtemp:
				increment = int((temp - self.midtemp)  * self.step)
				green = 255 - increment
				red = 0 + increment
				blue = 0
				backlight.rgb(red, green, blue)
		except:
			backlight.rgb(255, 255, 255)
			print "exception raised " + sys.exc_info() 
Esempio n. 15
0
def handle_up(pin):
    print("Up pressed!")
    lcd.clear()
    backlight.rgb(255, 0, 0)
    lcd.write("Up up and away!")
Esempio n. 16
0
File: hue.py Progetto: GeorgN/dot3k
#!/usr/bin/env python
import colorsys
import dot3k.backlight as bl

hue = 0

while True:
	r,g,b = colorsys.hsv_to_rgb(hue/360.0,1.0,1.0)
	r,g,b = int(r*255.0), int(g*255.0), int(b*255.0)
	bl.rgb(r,b,g)
	hue += 1
	hue %= 360
Esempio n. 17
0
def handle_button(pin):
  print("Button pressed!")
  l.clear()
  b.rgb(255,255,255)
  l.write("Ouch!")
Esempio n. 18
0
def temp_light(temperature):
    scale = set_temp - 20
    if temperature < 20:
        return [0,0,255]
    else:
        temp_difference = set_temp - temperature
        backlight_colour = int((scale - temp_difference)*(255/scale))
        return [(0 + backlight_colour), 0 , (255 - backlight_colour)]

@joystick.on(joystick.UP)
def handle_up(pin):
    global set_temp
    set_temp += 1

@joystick.on(joystick.DOWN)
def handle_down(pin):
    global set_temp
    set_temp -= 1
    
while True:
    temperature = read_temp()
    lcd_text = "Water temp: " + str(round(temperature, 1)) + "Set temp: " + str(set_temp)
    lcd.clear()
    lcd.write(lcd_text)
    rgb_colours = temp_light(temperature)
    backlight.rgb(rgb_colours[0], rgb_colours[1], rgb_colours[2])
    if temperature >= set_temp:
        bz.on()
    time.sleep(0.5)
Esempio n. 19
0
def doorbell():
    GPIO.remove_event_detect(gpio_bell) # Ignore multiple clicks
    if debug: print("Start of Doorbell function\n") 
    
    # If pushover is enabled, run as thread and continue
    if push_enabled: 
        t_push = threading.Thread(target=pushover, args=())
        t_push.start()

    # If taking pictures is enabled, run as thread and continue
    if pictures_enabled: 
        t_snap = threading.Thread(target=snapper, args=())
        t_snap.start()
    
    # Log the event in the databse
    if debug: print "Doorbell rang at "+ts() 
    log("Someone was at your door.")
    
    if debug: print "Event logged" 
    
    # ####### #
    # Phase 1 # Ringing.
    # ####### #
    
    # Clear LCD and adjust information
    lcd.clear()
    backlight.rgb(0,0,255)
    lcd.set_cursor_position(0,0)
    lcd.write(txt_security)
    lcd.set_cursor_position(0,1)
    lcd.write(txt_ring)
    lcd.set_cursor_position(0,2)
    lcd.write(txt_ring2)
    if debug: print("Text changed, entering wait_loop*2") 
    wait_loop(200)
    if debug: print("Wait loop done") 
    if debug: print("<< Next Phase >>\n") 
    backlight.set_graph(0)
    
    # ####### #
    # Phase 2 # Trying to contact them.
    # ####### #

    # Clear LCD and adjust information
    lcd.clear()
    backlight.rgb(255,153,0)
    lcd.set_cursor_position(0,0)
    lcd.write(txt_wait1)
    lcd.set_cursor_position(0,1)
    lcd.write(txt_wait2)
    lcd.set_cursor_position(0,2)
    lcd.write(txt_wait3)
    if debug: print("Text changed, entering wait_loop*2") 
    wait_loop(100)
    if debug: print("Wait loop done") 
    if debug: print("<< Next Phase >>\n") 
    backlight.set_graph(0)
    
    # ####### #
    # Phase 3 # No one is there.
    # ####### #

    # Clear LCD and adjust information
    lcd.clear()
    backlight.rgb(255,0,0)
    lcd.set_cursor_position(0,0)
    lcd.write(txt_away1)
    lcd.set_cursor_position(0,1)
    lcd.write(txt_away2)
    lcd.set_cursor_position(0,2)
    lcd.write(txt_away3)
    if debug: print("Text changed, entering wait_loop") 
    wait_loop(80)
    if debug: print("<< Next Phase >>\n") 
    backlight.set_graph(0)
    
    # ####### #
    # Phase 4 # Delivery to the neighbors.
    # ####### #

    # Clear LCD and adjust information
    lcd.clear()
    backlight.rgb(0,255,0)
    lcd.set_cursor_position(0,0)
    lcd.write(txt_package1)
    lcd.set_cursor_position(0,1)
    lcd.write(txt_package2)
    lcd.set_cursor_position(0,2)
    lcd.write(txt_package3)
    if debug: print("Text changed, entering sleep") 
    wait_loop(150)
    if debug: print("Wait loop done") 
    if debug: print("<< End of last Phase >>\n") 
    backlight.set_graph(0)
    lcd.clear()
    
    if debug: print("End of Doorbell function\n") 
    GPIO.add_event_detect(gpio_bell,GPIO.FALLING)
Esempio n. 20
0
def handle_right(pin):
    print("Right pressed!")
    lcd.clear()
    backlight.rgb(0, 255, 255)
    lcd.write("Rightie tighty!")
Esempio n. 21
0
        # Add the author's handle below the tweet
        lcd.write("@" + tweet.author.screen_name)

        time.sleep(scroll_speed)
        lcd.clear()


### Twitter Authentication:
auth = tweepy.OAuthHandler(API_KEY, API_SECRET)
auth.set_access_token(ACCESS_KEY, ACCESS_SECRET)

api = tweepy.API(auth)

### LCD Setup:

# Displays a nice shade of blue to show the fact we're dealing with
# twitter!
backlight.rgb(86, 188, 216)

while True:
    try:
        lcd.write("Please Wait" + " " * 5 + "Fetching Tweets")
        most_recent_tweet = api.home_timeline()[0]
        display_tweet(lcd, most_recent_tweet, 0.3)

    except TweepError as error:
        lcd.clear()
        lcd.write("Twitter API     limit reached")
        print "Rate Limit Exceeded", error
        time.sleep(600)  # Wait for ten minutes, then try again.
     if command == 'turnOff':
         backlight.off()
     elif command == 'useRBGMode':
         backlight.use_rbg()
     elif command == 'setBrightnessOfLed':
         backlight.set(parameters['ledIndex'], parameters['brightness'])
     elif command == 'setToHue':
         backlight.hue(parameters['hue'])
     elif command == 'setLeftToHue':
         backlight.left_hue(parameters['hue'])
     elif command == 'setMiddleToHue':
         backlight.mid_hue(parameters['hue'])
     elif command == 'setRightToHue':
         backlight.right_hue(parameters['hue'])
     elif command == 'setToRGB':
         backlight.rgb(parameters['red'], parameters['green'],
                       parameters['blue'])
     elif command == 'setLeftToRGB':
         backlight.left_rgb(parameters['red'], parameters['green'],
                            parameters['blue'])
     elif command == 'setMiddleToRGB':
         backlight.mid_rgb(parameters['red'], parameters['green'],
                           parameters['blue'])
     elif command == 'setRightToRGB':
         backlight.right_rgb(parameters['red'], parameters['green'],
                             parameters['blue'])
 elif component == 'BarGraph':
     if command == 'turnOff':
         backlight.set_graph(0.0)
     elif command == 'setByPercentage':
         backlight.set_graph(float(parameters['percentage']) / 100)
     elif command == 'setBrightnessOfLed':
        lcd.write("Rain: " + rain + "%")
        print("UV Index: " + uv + "")
    except:
        lcd.write("Connection Error")

    # Press the button on the joystick to exit
    @nav.on(nav.BUTTON)
    def handle_button(pin):
        lcd.clear()
        backlight.rgb(0, 0, 0)
        backlight.set_graph(0)
        os._exit(1)


try:
    while True:
        rainWarning()
        display()
        sleep(300)  # 5 minutes
except (KeyboardInterrupt, SystemExit):
    lcd.clear()
    lcd.set_cursor_position(0, 0)
    lcd.write("Exiting...")
    lcd.set_cursor_position(0, 1)
    lcd.write("Goodbye!")
    sleep(2)
    lcd.clear()
    backlight.rgb(0, 0, 0)
    backlight.set_graph(0)
    os._exit(1)
Esempio n. 24
0
def handle_up(pin):
  print("Up pressed!")
  l.clear()
  b.rgb(255,0,0)
  l.write("Up up and away!")
Esempio n. 25
0
        [0x00,0x1f,0x16,0x06,0x00,0x08,0x03,0x1e],
        [0x00,0x1f,0x0b,0x03,0x00,0x04,0x11,0x1f],
        [0x00,0x1f,0x05,0x01,0x00,0x02,0x08,0x07]
]

def get_anim_frame(anim, fps):
  return anim[ int(round(time.time()*fps) % len(anim)) ]

lcd.set_cursor_position(1,0)
lcd.write('Display-o-tron')
lcd.write('      ' + chr(0) + '3000  ')
lcd.create_char(0,get_anim_frame(pirate,4))



while 1:
  backlight.rgb(255,0,0)
  time.sleep(1)
  backlight.rgb(0,255,0)
  time.sleep(1)
  backlight.rgb(0,0,255)
  time.sleep(1)
  backlight.rgb(255,255,255)
  time.sleep(1)
  for i in range(0,360):
    backlight.hue(i/360.0)
    time.sleep(0.01)
  for i in range(0,360):
    backlight.sweep(i/360.0)
    time.sleep(0.01)
Esempio n. 26
0
def handle_down(pin):
  print("Down pressed!")
  l.clear()
  b.rgb(0,255,0)
  l.write("Down down doobie down!")
Esempio n. 27
0
def shutdown_animation():
	lcd.set_cursor_position(3,1)
	lcd.write("Bye (^_^)/")
	for x in reversed(range(127)):
		backlight.rgb(x, x * 2, x)
	lcd.clear()
Esempio n. 28
0
def handle_left(pin):
  print("Left pressed!")
  l.clear()
  b.rgb(0,0,255)
  l.write("Leftie left left!")
Esempio n. 29
0
def handle_down(pin):
    print("Down pressed!")
    lcd.clear()
    backlight.rgb(0, 255, 0)
    lcd.write("Down down doobie down!")
#!/usr/bin/python

import argparse, re, signal, subprocess, sys, time
import dot3k.lcd as lcd
import dot3k.backlight as backlight

killed = False
ip_addr = ''

backlight.rgb(255, 105, 50)


def get_interfaces():
        parser = argparse.ArgumentParser(description='Show IP address \
                of connected network interfaces')
        parser.add_argument('interfaces', type=str, nargs='*',
                            help='Network interfaces to display')

        args = parser.parse_args()
        if not args.interfaces:
                return ['wlan0', 'eth0']

        return args.interfaces


def signal_handler(signal, frame):
        lcd.clear()
        backlight.off()
        sys.exit(0)

def check_output(device):
Esempio n. 31
0
def handle_left(pin):
    print("Left pressed!")
    lcd.clear()
    backlight.rgb(0, 0, 255)
    lcd.write("Leftie left left!")
Esempio n. 32
0
#!/usr/bin/env python

import time

import dot3k.backlight as backlight
import dot3k.lcd as lcd

print("""
This example shows you a feature of the Dot HAT backlight.
You should see the backlight go white, then multi-coloured.

Press CTRL+C to exit.
""")

# Clear the LCD and display Hello World
lcd.clear()
lcd.write("Hello World")

# Set all the backlights to white
backlight.rgb(255, 255, 255)

time.sleep(1)

# Set the backlights independently
backlight.left_rgb(255, 0, 0)
backlight.mid_rgb(255, 0, 255)
backlight.right_rgb(0, 0, 255)

time.sleep(1)
Esempio n. 33
0
def handle_button(pin):
    print("Button pressed!")
    lcd.clear()
    backlight.rgb(255, 255, 255)
    lcd.write("Ouch!")
Esempio n. 34
0
#!/usr/bin/env python

import colorsys

import dot3k.backlight as backlight


print("""
This example shows how to set the backlight to a hue!
It uses colorsys, rather than the built-in hue function, to show you a colour conversion in Python.

Press CTRL+C to exit.
""")


hue = 0

while True:
    r, g, b = [int(x * 255.0) for x in colorsys.hsv_to_rgb(hue / 360.0, 1.0, 1.0)]
    backlight.rgb(r, b, g)
    hue += 1
    hue %= 360
    elif component == 'Backlight':
        if command == 'turnOff':
            backlight.off()
        elif command == 'useRBGMode':
            backlight.use_rbg()
        elif command == 'setBrightnessOfLed':
            backlight.set(parameters['ledIndex'], parameters['brightness'])
        elif command == 'setToHue':
            backlight.hue(parameters['hue'])
        elif command == 'setLeftToHue':
            backlight.left_hue(parameters['hue'])
        elif command == 'setMiddleToHue':
            backlight.mid_hue(parameters['hue'])
        elif command == 'setRightToHue':
            backlight.right_hue(parameters['hue'])
        elif command == 'setToRGB':
            backlight.rgb(parameters['red'], parameters['green'], parameters['blue'])
        elif command == 'setLeftToRGB':
            backlight.left_rgb(parameters['red'], parameters['green'], parameters['blue'])
        elif command == 'setMiddleToRGB':
            backlight.mid_rgb(parameters['red'], parameters['green'], parameters['blue'])
        elif command == 'setRightToRGB':
            backlight.right_rgb(parameters['red'], parameters['green'], parameters['blue'])
    elif component == 'BarGraph':
        if command == 'turnOff':
            backlight.set_graph(0.0)
        elif command == 'setByPercentage':
            backlight.set_graph(float(parameters['percentage']) / 100)
        elif command == 'setBrightnessOfLed':
            backlight.set_bar(parameters['ledIndex'], parameters['brightness'])
Esempio n. 36
0
lcd.write("IP:" + ip)

lcd.set_cursor_position(0, 1)
lcd.write("CPU: ")

lcd.set_cursor_position(13, 1)
lcd.write("IMG")

cpu_sample_count = 200
cpu_samples = [0] * cpu_sample_count
hue = 0.0


lcd.set_contrast(52)

backlight.rgb(200, 200, 200)


camera = picamera.PiCamera();

while True:
    cpu_samples.append(psutil.cpu_percent() / 100.0)
    cpu_samples.pop(0)

    cpu_avg = sum(cpu_samples) / cpu_sample_count

    #turns the white led array to reflect the CPU load 
    backlight.set_graph(cpu_avg)


    lcd.set_cursor_position(0, 0)
Esempio n. 37
0
 def off(self):
     os.system('mpc stop')
     backlight.set_graph(0)
     backlight.rgb(0, 0, 0)
     lcd.clear()
Esempio n. 38
0
def clean_shutdown():
    backlight.set_graph(0)
    backlight.rgb(0, 0, 0)
    lcd.clear()
Esempio n. 39
0
#!/usr/bin/env python
from dot3k import backlight

api_key = 'REPLACE'
api_secret = 'REPLACE'
# blue, use (255,0,0) for red,  (0,0,255) for green
backlight.rgb(0, 255, 0)
currency_code = 'USD'  # EUR / any currency code

# don't change below that line
# ----------------------------------------------------------


from coinbase.wallet.client import Client
client = Client(api_key, api_secret)
client.get_exchange_rates()

bitcoinPrice = client.get_spot_price(currency=currency_code)
ethereumPrice = client.get_spot_price(currency_pair= 'ETH-USD')


# clear LCD
import dothat.lcd as lcd
lcd.clear()

# first line
lcd.set_cursor_position(0, 0)
import datetime
datetime.datetime.now()
dateTimeNow = (datetime.datetime.now())
from time import gmtime, strftime
Esempio n. 40
0
 def __init__(self):
     backlight.rgb(255, 255, 255)
     self.printIt("","startup ...","")
Esempio n. 41
0
from dot3k import lcd 
from dot3k import backlight 
lcd.write("Hello World")
backlight.rgb(255,0,255)
Esempio n. 42
0
def handle_right(pin):
  print("Right pressed!")
  l.clear()
  b.rgb(0,255,255)
  l.write("Rightie tighty!")
Esempio n. 43
0
#!/usr/bin/env python
# -*- coding: UTF-8 -*-

import dot3k.lcd as lcd
import dot3k.backlight as backlight

from nettoyage_du_cache import clear_cache

#Fichier permettant de mettre en font une couleur pour que l'écran soit lisible

#Lumière -- DEBUT --
print("Affichage BLEU CYAN")
backlight.rgb(0, 255, 245)  #Paramètre RGB Lumiere
#Lumière -- FIN --
#!/usr/bin/python

import argparse, re, signal, subprocess, sys, time
import dot3k.lcd as lcd
import dot3k.backlight as backlight

killed = False
ip_addr = ''

backlight.rgb(255, 105, 50)


def get_interfaces():
    parser = argparse.ArgumentParser(description='Show IP address \
                of connected network interfaces')
    parser.add_argument('interfaces',
                        type=str,
                        nargs='*',
                        help='Network interfaces to display')

    args = parser.parse_args()
    if not args.interfaces:
        return ['wlan0', 'eth0']

    return args.interfaces


def signal_handler(signal, frame):
    lcd.clear()
    backlight.off()
    sys.exit(0)
 def handle_button(pin):
     lcd.clear()
     backlight.rgb(0, 0, 0)
     backlight.set_graph(0)
     os._exit(1)
Esempio n. 46
0
File: polar.py Progetto: aejb/polar
#!/usr/bin/env python
import time
from bh1745 import BH1745
import dot3k.lcd as lcd
import dot3k.backlight as backlight

bh1745 = BH1745()
bh1745.setup()
bh1745.set_leds(0)
backlight.rgb(200,200,200)
time.sleep(1.0)

try:
    while True:
        r, g, b, c = bh1745.get_rgbc_raw()
        print('RGBC: {:10.1f} {:10.1f} {:10.1f} {:10.1f}'.format(r, g, b, c))
        # Clear the LCD and display Hello World
        lcd.clear()
        lcd.write('{:10.1f}'.format(c))
        time.sleep(0.1)
        
except KeyboardInterrupt:
    bh1745.set_leds(0)
Esempio n. 47
0
#!/usr/bin/env python
import colorsys
import dot3k.backlight as bl

hue = 0

while True:
    r, g, b = colorsys.hsv_to_rgb(hue / 360.0, 1.0, 1.0)
    r, g, b = int(r * 255.0), int(g * 255.0), int(b * 255.0)
    bl.rgb(r, b, g)
    hue += 1
    hue %= 360
Esempio n. 48
0
def handle_up(pin):
    print("Up pressed!")
    l.clear()
    b.rgb(255, 0, 0)
    l.write("Up up and away!")
Esempio n. 49
0
time.sleep(0.3)
backlight.left_rgb(255, 255, 0)
time.sleep(0.3)
backlight.mid_rgb(255, 255, 0)
time.sleep(0.3)
backlight.right_rgb(255, 255, 0)
time.sleep(0.3)
backlight.left_rgb(255, 255, 255)
time.sleep(0.3)
backlight.mid_rgb(255, 255, 255)
time.sleep(0.3)
backlight.right_rgb(255, 255, 255)
time.sleep(0.3)
lcd.clear()
lcd.write("=DOT3K==========                ==========ready=")
backlight.rgb(0, 0, 255)
time.sleep(0.1)
backlight.rgb(255, 255, 255)
time.sleep(0.1)
backlight.rgb(0, 0, 255)
time.sleep(0.1)
backlight.rgb(255, 255, 255)
time.sleep(0.1)
backlight.rgb(0, 0, 255)
time.sleep(0.1)
backlight.rgb(255, 255, 255)
time.sleep(0.1)
backlight.rgb(0, 0, 255)
time.sleep(0.1)
backlight.rgb(255, 255, 255)
time.sleep(0.1)
Esempio n. 50
0
def handle_down(pin):
    print("Down pressed!")
    l.clear()
    b.rgb(0, 255, 0)
    l.write("Down down doobie down!")
Esempio n. 51
0
        return [0, 0, 255]
    else:
        temp_difference = set_temp - temperature
        backlight_colour = int((scale - temp_difference) * (255 / scale))
        return [(0 + backlight_colour), 0, (255 - backlight_colour)]


@joystick.on(joystick.UP)
def handle_up(pin):
    global set_temp
    set_temp += 1


@joystick.on(joystick.DOWN)
def handle_down(pin):
    global set_temp
    set_temp -= 1


while True:
    temperature = read_temp()
    lcd_text = "Water temp: " + str(round(temperature,
                                          1)) + "Set temp: " + str(set_temp)
    lcd.clear()
    lcd.write(lcd_text)
    rgb_colours = temp_light(temperature)
    backlight.rgb(rgb_colours[0], rgb_colours[1], rgb_colours[2])
    if temperature >= set_temp:
        bz.on()
    time.sleep(0.5)
Esempio n. 52
0
def handle_left(pin):
    print("Left pressed!")
    l.clear()
    b.rgb(0, 0, 255)
    l.write("Leftie left left!")
Esempio n. 53
0
#!/usr/bin/env python

import dot3k.lcd as lcd
import dot3k.backlight as backlight
import time

# Clear the LCD and display Hello World
lcd.clear()
lcd.write("Hello World")

# Turn off the backlight
backlight.rgb(0,0,0)

"""
set_graph accepts a float between 0.0 and 1.0
and lights up the LEDs accordingly
"""
for i in range(100):
    backlight.set_graph(i/100.0)
    time.sleep(0.05)

"""
set_bar will set a specific bargraph LED to
a brightness between 0 and 255
"""
for i in range(256):
    backlight.set_bar(0,[255-i]*9)
    time.sleep(0.01)

backlight.set_graph(0)
Esempio n. 54
0
def handle_button(pin):
    print("Button pressed!")
    l.clear()
    b.rgb(255, 255, 255)
    l.write("Ouch!")