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
def y_button_func(): global is_recording global recording while True: y_button.wait_for_press() is_recording = True backlight.hue(1) time.sleep(.3) y_button.wait_for_press() is_recording = False backlight.hue(0) print('start recording playback: ',recording) loop = LiveLoop(play_recording, (recording,)) loop.start() recording = [] time.sleep(.3)
def reader_proc(queue): # Create rows rows = [" "," "," "] backlight.hue(0.01) while True: # Move rows up rows[2] = rows[1] rows[1] = rows[0] newtext = queue.get() # Ignore repeded messages while newtext == rows[0]: newtext = queue.get() rows[0] = newtext print("1: %s" % rows[2]) print("2: %s" % rows[1]) print("3: %s" % rows[0]) lcd.set_cursor_position(4,2) lcd.write(rows[0] + " ") lcd.set_cursor_position(4,1) lcd.write(rows[1] + " ") lcd.set_cursor_position(4,0) lcd.write(rows[2] + " ") time.sleep(1)
import datetime from gpiozero import DigitalInputDevice timestamp = datetime.datetime.now() print(timestamp) did = DigitalInputDevice(5) didv = did.value print("Digital input is: " + str(didv)) lcd.clear() lcd.set_contrast(50) huestr = input("Enter Hue Value from 0.0 to 1.0: ") backlight.hue(float(huestr)) lcd.set_cursor_position(0, 0) lcd.write("Line 0") lcd.set_cursor_position(0, 2) lcd.write("Line 2") for x in range(0, 101): foo = x / 10.0 lcd.set_cursor_position(0, 1) string = "Line 1 {0}".format(foo) # print (string) lcd.write(string) backlight.set_graph(foo / 10.0) time.sleep(0.02)
print("dfm_cell: ", dfm_cell) print("lrm_cell: ", lrm_cell) did = DigitalInputDevice(5) index = 0 jndex = 0 last_st = 0 excount = 0 st = 2 gen_start_time = 0.0 server_address = ('10.0.0.48', 10137) nn = datetime.datetime.now() lcd.set_contrast(50) backlight.hue(0.5) backlight.set_graph(0.0) lcd.set_cursor_position(0, 0) lcd.write("Monitor Starting") # 1234567890123456 lcd.set_cursor_position(0, 1) lcd.write(nn.strftime("%a %b %d %H:%M")) lcd.set_cursor_position(0, 2) lcd.write(" ") # 1234567890123456 print("Startup: about to send text to DFM cell [" + str(datetime.datetime.now()) + "]") body = "Generator monitor program launching" ###send_sms(dfm_cell, body, twilio_user, twilio_pass, twilio_num, twilio_acct)
Thread(target=b_button_func).start() Thread(target=y_button_func).start() Thread(target=k_button_func).start() Thread(target=g_button_func).start() Thread(target=json_listen).start() print("I'm a good boy.") pitch = .5 try: while True: if not us_off: pitch_ = pitch_sensor.distance if .01 < pitch_ < .8: pitch = pitch_ / .8 print(pitch) if is_recording: recording.append((pitch, synth)) else: backlight.hue(pitch) play_note(pitch, amp, synth) #amp_ = amp_sensor.distance #if .1 < amp_ < .9: # amp = amp_ except KeyboardInterrupt: LiveLoop.kill_all()
from dot3k.menu import Menu, MenuOption from dothat import backlight, lcd, touch import RPi.GPIO as GPIO import time import random import line import json GPIO.setmode(GPIO.BCM) GPIO.setup(26, GPIO.IN) backlight.hue(0.8) class App: def __init__(self): self.structure = {} with open('local.json') as f: self.cards = json.load(f) self.config = self.cards['CONFIG'] self.cards = self.formatCards(self.cards) for subject in self.cards: for topic in self.cards[subject]: self.cards[subject][topic] = self.CardSession( self, self.cards[subject][topic], subject + "." + topic) print(self.config['favorites'])
lcd.set_contrast(parameters['contrast']) elif command == 'setCursorPosition': lcd.set_cursor_position(parameters['column'], parameters['row']) elif command == 'write': lcd.write(parameters['value']) elif command == 'createCharacter': lcd.create_char(parameters['memoryPosition'], parameters['map']) elif command == 'writeCharacter': lcd.write(chr(parameters['memoryPosition'])) elif component == 'Backlight': if command == 'turnOff': backlight.off() 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 == 'setZoneToRGB': backlight.single_rgb(parameters['zoneIndex'], parameters['red'], parameters['green'], parameters['blue']) elif command == 'setLeftToRGB': backlight.left_rgb(parameters['red'], parameters['green'], parameters['blue'])
lcd.set_contrast(parameters['contrast']) elif command == 'setCursorPosition': lcd.set_cursor_position(parameters['column'], parameters['row']) elif command == 'write': lcd.write(parameters['value']) elif command == 'createCharacter': lcd.create_char(parameters['memoryPosition'], parameters['map']) elif command == 'writeCharacter': lcd.write(chr(parameters['memoryPosition'])) elif component == 'Backlight': if command == 'turnOff': backlight.off() 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 == 'setZoneToRGB': backlight.single_rgb(parameters['zoneIndex'], 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':