Example #1
0
def light_side():
  print("Light side of the force!")
  l.clear()
  b.rgb(0,0,255)
  l.write("Moege die Macht mit Dir sein, Jedi Meister")
  sleep(10)
  test()
Example #2
0
def main():

	lcd.clear()
	backlight.set_graph(0)
	backlight.rgb(255,255,255)
	lcd.set_cursor_position(1,0)
	lcd.write("MIFARE Cloner")
	lcd.set_cursor_position(3,2)
	lcd.write("by Cypaubr")
	
	time.sleep(3)
	
	lcd.clear()
	backlight.rgb(100,200,255)
	lcd.set_cursor_position(1,0)
	lcd.write("Place your tag")
	lcd.set_cursor_position(2,2)
	lcd.write("PRESS  START")
	
	while True:
		@touch.on(touch.BUTTON)
		def start_detection(ch, evt):
			lcd.clear()
			detect()
		
		@touch.on(touch.CANCEL)
		def cancel_detection(ch, evt):
			lcd.clear()
			lcd.write("Canceling...")
			backlight.rgb(255,0,0)
			time.sleep(1)
			exit(0)
Example #3
0
def cleanup():
    """
       Function called on exit. Just clears the screen and turns all the lights off
    """
    lcd.clear()
    backlight.rgb(0,0,0)
    backlight.graph_off()
Example #4
0
def dark_side():
  print("Dark side of the force!")
  l.clear()
  b.rgb(255,0,0)
  l.write("Ergib dich der dunklen Seite der Macht")
  sleep(10)
  test()
def handle_left(ch,evt):
    print("Left pressed!")
    l.clear()
    l.write("BBC News Feed")
    time.sleep(1)
    l.clear()
    b.rgb(0,0,128)
    feedme("http://feeds.bbci.co.uk/news/rss.xml")
def handle_right(ch,evt):
    print("Right pressed!")
    l.clear()
    b.rgb(0,128,0)
    l.write("Hackaday RSS")
    time.sleep(1)
    l.clear()
    feedme("https://hackaday.com/blog/feed/")
Example #7
0
def assign_selected_sensor():
    global selected_sensor
    selected_sensor = item_deque[0]
    logger.info(selected_sensor.desc)
    lcd.clear()
    backlight.rgb(255, 255, 255)
    lcd.set_cursor_position(0, 0)
    lcd.write(selected_sensor.desc)
    lcd.set_cursor_position(0, 2)
def displayCurrentValues():
    humidity, temperature = Adafruit_DHT.read_retry(sensor, pin)
    color = temp_color(int(temperature))
    backlight.rgb(int(color.red * 255), int(color.green * 255), int(color.blue * 255))
    lcd.set_cursor_position(0, 0)
    lcd.write("Temperatur: " + str(temperature))
    lcd.set_cursor_position(0,1)
    lcd.write("Humidity:   " + str(humidity))
    time.sleep(10.01)
Example #9
0
def handle_down(ch, evt):
    #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')
def displayCurrentValues():
    humidity, temperature = Adafruit_DHT.read_retry(sensor, pin)
    color = temp_color(int(temperature))
    backlight.rgb(int(color.red * 255), int(color.green * 255),
                  int(color.blue * 255))
    lcd.set_cursor_position(0, 0)
    lcd.write("Temperatur: " + str(temperature))
    lcd.set_cursor_position(0, 1)
    lcd.write("Humidity:   " + str(humidity))
    time.sleep(10.01)
Example #11
0
def handle_up(ch, evt):
    settings = (int(filenum), int(shutter))
    temp = settings[0]
    temp += 1 
    print('filenum is {}'.format(int(temp)) )
    l.clear()
    b.rgb(0, 255, 0)
    l.write('filenum is {}'.format(int(temp)))
    global filenum
    filenum = int(temp)
Example #12
0
 def SetRGB(self, red, green, blue):
     """
     Helper function to set the RGB values. Save the RGB values to a state variable 
     and then call the backlight update function. This way, we know the previous backlight
     colour and when we turn the screen back on, we can set the colour as planned.
     """
     self.red = red
     self.green = green
     self.blue = blue
     backlight.rgb(self.red, self.green, self.blue)
Example #13
0
def tophat():
    #controls the raspberry pi HAT display
    lcd.clear(); lcd.set_contrast(50); backlight.set_graph(0)
    if (asoldiers > dsoldiers) and (atotallost != 1):
        backlight.rgb(0,255,0)
    elif (asoldiers <= dsoldiers):
        backlight.rgb(255,0,0)
    lcd.set_cursor_position(0,0); lcd.write("War is hell...")
    lcd.set_cursor_position(0,1); lcd.write("Offense Lost: " + str(atotallost))
    lcd.set_cursor_position(0,2); lcd.write("Defense Lost: " + str(dtotallost))
def handle_down(ch, evt):
    global dtemp, rtemp, display_status
    l.clear()
    b.rgb(128, 128, 0) #blue
    dtemp=dtemp-1
    l.clear()
    l.set_cursor_position(0,1)
    l.write(str(room) + str(dtemp) + chr(223) + 'C')
    time.sleep(1)
    display_status="ON"
    default_display()
Example #15
0
def display_show(text1, text2, text3, light):
	print ("display_show")
	
	if light:
		backlight.rgb(0, 100, 0)
	else:
		backlight.off()

	menu.write_row(0, text1)
	menu.write_row(1, text2)
	menu.write_row(2, text3)
Example #16
0
def speakIPAddress():
    wlan = get_ip_address('wlan0')
    backlight.rgb(0, 255, 0)
    lcd.set_contrast(50)
    lcd.clear()
    lcd.set_cursor_position(2, 0)
    lcd.write("IP Address:")
    lcd.set_cursor_position(1, 1)
    lcd.write(wlan)
    command = "flite -voice rms -t 'My I P address is " + wlan + "' "
    print command
    os.system(command)
Example #17
0
def LCD_update(first = "", second = "Coretec Robotics", third = "", r = 0, g = 225, b = 0):
    print first
    print second
    print third
    backlight.rgb(r, g, b)
    lcd.clear()
    lcd.set_contrast(50)
    lcd.set_cursor_position(0, 0)
    lcd.write(first)
    lcd.set_cursor_position(0, 1)
    lcd.write(second)
    lcd.set_cursor_position(0,2)
    lcd.write(third)
def handle_button(ch,evt):
    print("Button pressed!")
    l.clear()
    b.rgb(0,0,0)
    l.set_cursor_position(0,0)
    l.write("Linux Voice")
    for i in range(256):
      b.left_rgb(i,0,0)
      time.sleep(0.01)
      b.mid_rgb(i,0,0)
      time.sleep(0.01)
      b.right_rgb(i,0,0)
      time.sleep(0.01)
Example #19
0
def backlight(data):
    if data["command"] == "off":
        backlight.off()
        return True
    
    if data["command"] == "sweep":
        backlight.sweep(data["hue"],data["range"])
        return True

    if data["command"] == "hue":
        backlight.hue(data["hue"])
        return True
    if data["command"] == "rgb":
        backlight.rgb(data["r"],data["g"],data["b"])
        return True

    if data["command"] == "left_hue":
        backlight.left_hue(data["hue"])
        return True
    if data["command"] == "left_rgb":
        backlight.left_rgb(data["r"],data["g"],data["b"])
        return True

    if data["command"] == "mid_hue":
        backlight.mid_hue(data["hue"])
        return True
    if data["command"] == "mid_rgb":
        backlight.mid_rgb(data["r"],data["g"],data["b"])
        return True

    if data["command"] == "right_hue":
        backlight.right_hue(data["hue"])
        return True
    if data["command"] == "right_rgb":
        backlight.right_rgb(data["r"],data["g"],data["b"])
        return True

    if data["command"] == "set":
        backlight.set(data["index"],data["value"])
        return True

    if data["command"] == "set_bar":
        backlight.set_bar(data["index"],data["value"])
        return True
    if data["command"] == "set_graph":
        backlight.set(data["value"])
        return True

    if data["command"] == "update":
        backlight.update()
        return True
Example #20
0
def main():
    ip = urlopen('http://ip.42.pl/raw').read()
    lcd.clear()
    lcd.set_contrast(50)
    if ip == '#IPADDRESS':
        backlight.rgb(0, 255, 0)
        lcd.set_cursor_position(0, 0)
        lcd.write("  LINK SECURED")
        lcd.set_cursor_position(0, 1)
        lcd.write(" " + ip)
    else:
        backlight.rgb(255, 0, 0)
        lcd.set_cursor_position(0, 0)
        lcd.write(" LINK UNSECURED")
        lcd.set_cursor_position(0, 1)
        lcd.write(" " + ip)
Example #21
0
def handle_down(ch, evt):
    settings = (int(filenum), int(shutter))
    temp = settings[0]
    if int(temp) == 1:
    	print("Can't do more")
        l.clear()
        b.rgb(255, 0, 0)
        l.write("Can't go lower")
    else:
	temp -= 1
        print('filenum is {}'.format(int(temp)))
        l.clear()
        b.rgb(0, 255, 0)
        l.write('filenum is {}'.format(int(temp)))
	global filenum
	filenum = int(temp)
Example #22
0
def handle_right(ch, evt):
    settings = (int(filenum), int(shutter))
    temp = settings[1]
    if int(temp) == 6000000:
        print("Can't do more")
        l.clear()
        b.rgb(255, 0, 0)
        l.write("Can't go higher")
    else:
        temp = int(temp) + 500000
        print('shutter is {}'.format(int(temp)))
        l.clear()
        b.rgb(0, 0, 255)
        l.write('shutter is {}'.format(int(temp)))
	global shutter
        shutter = int(temp)
Example #23
0
 def set_background_status(self, status):
     if status == BackgroundStatus.Ok:
         backlight.rgb(0, 255, 0)
     elif status == BackgroundStatus.Error:
         backlight.rgb(255, 0, 0)
     elif status == BackgroundStatus.Warn:
         backlight.rgb(255, 255, 0)
     else:
         backlight.rgb(0, 0, 255)
def main():
    # Get the current SSID
    SSID = None
    try:
        SSID = subprocess.check_output(["iwgetid", "-r"]).strip()
    except subprocess.CalledProcessError:
        # If there is no connection subprocess throws a 'CalledProcessError'
        pass

    # Show status on the LCD display
    if SSID is None:
        backlight.rgb(255, 0, 0)
        lcd.clear()
        lcd.write("Not connected")
    else:
        backlight.rgb(0, 255, 0)
        lcd.clear()
        lcd.write("SSID: " + SSID)
def default_display():
	global dtemp, rtemp, heat, display_status, heatc
	l.clear()

	if display_status == "ON":
		b.rgb(128,128,128)
	else:
		b.rgb(0,0,0)

	l.set_cursor_position(0,0)
	l.write(str(room) + str(dtemp) + chr(223) + 'C')
	l.set_cursor_position(0,1)
	l.write("Heating: " + str(heat))
	l.set_cursor_position(0,2)
	x= "Now:" + str(rtemp) + chr(223) + 'C ' + time.strftime("%H:%M")
	l.write(x)

	count_heat()
	time.sleep(1)
Example #26
0
def handle_button(ch, evt):
    #def handle_button(pin):
    global ButtonStatus
    global loopcount
    if ButtonStatus == 'On':
        loopcount = 10
        lcd.clear()
        backlight.off()
        ButtonStatus = 'Off'
        print "Display Off"
    else:
        loopcount = 0
        backlight.rgb(229, 255, 0)
        display_hostname(0)
        display_NIC(1)
        display_WNIC(2)
        graph_CPUTemp(5)
        ButtonStatus = 'On'
        print "Display Off"
Example #27
0
    def change_color(r_in, g_in, b_in, seconds=.5):
        # Make sure back light is at global values
        backlight.rgb(GVars.LED_RED, GVars.LED_GREEN, GVars.LED_BLUE)
        red_delta = abs(GVars.LED_RED - r_in)
        green_delta = abs(GVars.LED_GREEN - g_in)
        blue_delta = abs(GVars.LED_BLUE - b_in)

        ops_per_sec = 32

        # Temp Vars (used to store globals for inter function operations
        r = GVars.LED_RED
        g = GVars.LED_GREEN
        b = GVars.LED_BLUE

        number_of_cycles = int(seconds * ops_per_sec)

        for x in range(0, number_of_cycles):
            # FIXME Doesn't seem to end on correct number, bad math?
            if r_in >= r:
                r += red_delta / number_of_cycles
            else:
                r -= red_delta / number_of_cycles

            if b_in >= b:
                b += blue_delta / number_of_cycles
            else:
                b -= blue_delta / number_of_cycles

            if g_in >= g:
                g += green_delta / number_of_cycles
            else:
                g -= green_delta / number_of_cycles

            # logging.debug(str(r) + '    ' + str(g) + '    ' + str(b))
            backlight.rgb(r, g, b)

            s = 1 / float(ops_per_sec)
            sleep(s)

        GVars.LED_RED = r
        GVars.LED_GREEN = g
        GVars.LED_BLUE = b
Example #28
0
def takelongphoto():
    print("Takeing Photo")
    l.clear()
    b.rgb(255, 255, 255)
    l.write("Taking Photo Don't Move")
    settings = (int(filenum), int(shutter))
    with picamera.PiCamera() as camera:
	camera.resoluion = (1024, 768)
	camera.hflip = True
	camera.vflip = True
	camera.framerate = Fraction(1, 6)
	camera.shutter_speed = settings[1]
	camera.expodure_mode = 'off'
	camera.iso = 100
	sleep(10)
	camera.capture('/home/pi/photo/longexp_{}.jpg'.format(int(settings[0])))
    print("DONE!")
    l.clear()
    b.rgb(0, 255, 255)
    l.write("We are done")
Example #29
0
 def callbackfunction(self, deviceId, method, value, callbackId, context):
     dt = datetime.now()
     sdt = dt.strftime('%Y-%m-%d %H:%M')
     # For some reason the motion sensor sends the same event twice
     if (sdt == self.last_event):
         return
     self.last_event = sdt
     if (deviceId == 7):
         if (method == 1):
             lcd.clear()
             lcd.set_cursor_position(0, 0)
             lcd.write(sdt)
             backlight.rgb(0, 255, 0)
             self.set_leds()
             self.send(sdt)
             print sdt
         if (method == 2):
             lcd.set_cursor_position(0, 1)
             lcd.write('Waiting...')
             backlight.off()
         sys.stdout.flush()
Example #30
0
def temp():
    print 'Starting Temp'
    from dothat import backlight
    from dothat import lcd
    import time

    lcd.set_contrast(50)

    while True:
        tempC = int(open('/sys/class/thermal/thermal_zone0/temp').read()) / 1e3

        # Change backlight if temp changes
        if tempC < 60:
            backlight.rgb(0, 255, 0)
        elif tempC > 70:
            backlight.rgb(255, 0, 0)
        else:
            backlight.rgb(0, 255, 255)

        # Convert Temp to String
        tempF = str(tempC)

        # Write Temp and wait 1 sec.
        lcd.set_cursor_position(0, 0)
        lcd.write("Temp: " + tempF + " C")
        time.sleep(1)
        lcd.clear()

    print 'backlight: finishing'
Example #31
0
def handle_up(ch,evt):
  print("Up pressed!")
  l.clear()
  b.rgb(255,0,0)
  l.write("Up up and away!")
Example #32
0
         LcdItem(METRICS_TOPIC, "Msgs/Sec")]

item_dict = {}
for i in items:
    item_dict[i.topic] = i

item_deque = deque()
for i in item_dict.keys():
    item_deque.append(item_dict[i])

# default sensor
selected_sensor = item_deque[0]

# lcd initialization
lcd.clear()
backlight.rgb(255, 255, 255)
lcd.set_contrast(45)
lcd.clear()


def on_connect(mqtt_client, userdata, flags, rc):
    logger.info("Connected with result code: %s", rc)

    item_dict = userdata[ITEM_DICT]
    for key in item_dict.keys():
        mqtt_client.subscribe(item_dict[key].topic)


def on_message(mqtt_client, userdata, msg):
    item_dict = userdata[ITEM_DICT]
Example #33
0
def handle_cancel(ch, evt):
    print("Cancel pressed!")
    lcd.clear()
    backlight.rgb(0, 0, 0)
    lcd.write("Boom!")
Example #34
0
def handle_button(ch, evt):
    print("Button pressed!")
    lcd.clear()
    backlight.rgb(255, 255, 255)
    lcd.write("Ouch!")
Example #35
0
def handle_right(ch, evt):
    print("Right pressed!")
    lcd.clear()
    backlight.rgb(0, 255, 255)
    lcd.write("Rightie tighty!")
Example #36
0
def handle_left(ch, evt):
    print("Left pressed!")
    lcd.clear()
    backlight.rgb(0, 0, 255)
    lcd.write("Leftie left left!")
Example #37
0
def handle_down(ch, evt):
    print("Down pressed!")
    lcd.clear()
    backlight.rgb(0, 255, 0)
    lcd.write("Down down doobie down!")
Example #38
0
#!/usr/bin/env python
print("""
This basic example display a simple text and terminates executaion immediately.
""")

import dothat.backlight as backlight
import dothat.lcd as lcd

# Turn off led bar
backlight.set_graph(0)

# Set backlight colour to cyan
backlight.rgb(0,255,255)

# Display text in FIRST line of the LCD
lcd.set_cursor_position(0, 0)
lcd.write("Hello world.")

# Display text in SECOND line of the LCD
lcd.set_cursor_position(0, 1)
lcd.write("This is fun!")

# Display text in THIRD line of the LCD
lcd.set_cursor_position(0, 2)
lcd.write(":)")


Example #39
0
def lcd_display(dict, delay=0.1):
    while True:
        try:
            lcd.clear()
            lcd.set_cursor_position(0, 0)
            lcd.write(selected_sensor.desc)
            lcd.set_cursor_position(0, 2)

            val = selected_sensor.value
            if val == "-1":
                backlight.rgb(255, 0, 0)
            else:
                backlight.rgb(255, 255, 255)

            if selected_sensor == dict[LIDAR_LEFT_TOPIC]:
                lcd.write(val + " mm")

            elif selected_sensor == dict[LIDAR_RIGHT_TOPIC]:
                lcd.write(val + " mm")

            elif selected_sensor == dict[LIDAR_FRONT_TOPIC]:
                lcd.write(val + " cm")

            elif selected_sensor == dict[LIDAR_REAR_TOPIC]:
                lcd.write(val + " cm")

            elif selected_sensor == dict[CAMERA_VALUE_TOPIC]:
                lcd.write(val)
                if val == NOT_SEEN:
                    backlight.rgb(255, 0, 0)
                elif val == NOT_ALIGNED:
                    backlight.rgb(0, 0, 255)
                elif val == ALIGNED:
                    backlight.rgb(0, 255, 0)

            elif selected_sensor == dict[HEADING_CALIBRATION_TOPIC]:
                lcd.write(val.replace(" ", "", 10))
                if val == CALIBRATION_BY_VALUES:
                    backlight.rgb(0, 255, 0)

            elif selected_sensor == dict[HEADING_DEGREES_TOPIC]:
                lcd.write(val)

            elif selected_sensor == dict[METRICS_TOPIC]:
                lcd.write(val)

            else:
                lcd.write("")

            time.sleep(delay)

        except BaseException as e:
            logger.error("%s", e, exc_info=True)
            time.sleep(1)
def handle_button(ch, evt):
    print("Confirm settings!")
    l.clear()
    b.rgb(255, 255, 255)
    settings = (int(filenum), int(shutter))
    l.write('filename = %s and shutter = %s' % settings)
Example #41
0
mgtext = MGText()

menu = Menu(
	structure = {
		'MGText Test': mgtext,
	},
	lcd = lcd,
	input_handler = mgtext)

try:
	touch.bind_defaults(menu)
	
	# Trap the Cancel button for our own purposes (to use as a Delete key).
	@touch.on(touch.CANCEL)
	def handle_cancel(ch, evt):
		mgtext.cancel()
	
	backlight.rgb(192, 124, 234)
	menu.right() # Go straight to text-editing
	
	while 1:
		menu.redraw()
		time.sleep(0.05)

except (KeyboardInterrupt, SystemExit):
	reset()
except:
	reset()
	raise
def handle_down(ch,evt):
    print("Playing BBC 6 Music")
    l.clear()
    b.rgb(87,145,146)
    l.write("BBC 6 Music")
    player(radio6)
Example #43
0
from dothat import lcd
from dothat import backlight
from dothat import touch
import time

lcd.clear()

print('''Santa Tracker!

Built by appledeej on Github.

Press CTRL + C to exit.''')

backlight.rgb(255, 0, 0)
backlight.update
time.sleep(1)
backlight.rgb(0, 255, 0)
backlight.update
time.sleep(1)
backlight.rgb(0, 0, 255)
backlight.update
lcd.set_cursor_position(1, 1)  #Startup/splash screen.
lcd.write("Santa Tracker")
lcd.set_cursor_position(1, 2)
lcd.write("appledeej")
lcd.set_cursor_position(1, 0)
lcd.write("Version 0.1")

lcd.clear
backlight.rgb(255, 0, 0)
backlight.update
Example #44
0
def handle_left(ch,evt):
  print("Left pressed!")
  l.clear()
  b.rgb(0,0,255)
  l.write("Leftie left left!")
Example #45
0
def handle_down(ch,evt):
  print("Down pressed!")
  l.clear()
  b.rgb(0,255,0)
  l.write("Down down doobie down!")
Example #46
0
def handle_button(ch,evt):
  print("Button pressed!")
  l.clear()
  b.rgb(255,255,255)
  l.write("Ouch!")
Example #47
0
def handle_right(ch,evt):
  print("Right pressed!")
  l.clear()
  b.rgb(0,255,255)
  l.write("Rightie tighty!")
def handle_cancel(ch,evt):
    print("Stopping Music")
    l.clear()
    b.rgb(0,0,0)
    stop()
Example #49
0
def handle_cancel(ch,evt):
  print("Cancel pressed!")
  l.clear()
  b.rgb(0,0,0)
  l.write("Boom!")
def stop():
    p.stop()
    b.rgb(255,0,0)
    l.write("S T O P")
    b.graph_off()
#!/usr/bin/env python

import dothat.lcd as lcd
import dothat.backlight as backlight
from time import sleep

lcd.set_cursor_position(0, 1)
lcd.write('Happy Christmas!')

#for x in range(50):
#    backlight.hue(x / 50.0)
#    sleep(0.05)

backlight.rgb(0, 255, 0)
def handle_up(ch,evt):
    print("Playing BBC Radio 2")
    l.clear()
    b.rgb(255,0,255)
    l.write("BBC Radio 2")
    player(radio2)