Beispiel #1
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()
Beispiel #2
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()
Beispiel #3
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)
Beispiel #4
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()
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/")
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_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)
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()
Beispiel #9
0
def test():
  print("Testing")
  l.clear()
  l.write("Jedi oder Sith?")
  x = 0

  while True:
    	x+=1

    	b.sweep( (x%360)/360.0)
    	sleep(0.01)
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)
Beispiel #11
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)
Beispiel #12
0
def detect():
	try:
		card= rfidiot.card
	except:
		throwexception()

	args= rfidiot.args

	card.info('multiselect v0.1n')
	card.settagtype(card.ALL)
	
	if(card.uid != None):
		lcd.clear()
		lcd.write(card.uid)
		lcd.set_cursor_position(0,1)
		lcd.write(card.tagtype)
Beispiel #13
0
    def run(self):
        CMPFUNC = CFUNCTYPE(None, c_int, c_int, POINTER(c_ubyte), c_int,
                            c_void_p)
        cmp_func = CMPFUNC(self.callbackfunction)
        lib.tdInit()
        lib.tdRegisterDeviceEvent(cmp_func, 0)

        lcd.clear()
        lcd.set_cursor_position(0, 1)
        lcd.write('Waiting...')
        backlight.off()
        backlight.graph_off()

        print 'Started'
        while True:
            time.sleep(1)
Beispiel #14
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)
Beispiel #15
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)
Beispiel #16
0
    def redraw(self):
        if not self._icons_setup:
            self.setup_icons()

        self.recorder.update_dispatcher_status()
        lcd.clear()

        if self.state == self.state_idle:
            self.redraw_idle()
        elif self.state == self.state_recording:
            self.redraw_recording()
        elif self.state == self.state_metadata:
            self.redraw_metadata()
        elif self.state == self.state_file_exists:
            self.redraw_file_exists()
        elif self.state == self.state_complete:
            self.redraw_complete()
def _message(code, credit_balance=None):
    message_lock.acquire()
    _message_output(code)
    lcd.clear()
    lcd.write(message_code[code])
    if credit_balance is not None:
        lcd.set_cursor_position(0, 2)
        lcd.write(" ")
        lcd.write(balance)
        credit_balance_string = locale.format('%.2f',
                                              credit_balance,
                                              monetary=True)
        lcd.set_cursor_position(lcd.COLS - len(credit_balance_string) - 1, 2)
        lcd.write(credit_balance_string)
        lcd.write(" ")
    time.sleep(2.5)
    message_lock.release()
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)
Beispiel #19
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"
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)
Beispiel #21
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")
Beispiel #22
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()
Beispiel #23
0
  def run(self):
    # update the ip address
    eth0_address = [i['addr'] for i in ifaddresses("eth0").setdefault(AF_INET, [{'addr':'No IP addr'}] )]

    # check if internet connection
    try:
      s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
      s.connect(("google.com",80))
      s.close()
      status = " up"
    except:
      status = "dwn"
    lcd.clear()
    lcd.set_cursor_position(0,2)
    lcd.write(eth0_address[0])
    lcd.set_cursor_position(13,2)
    lcd.write(status)

    print "update ip " + eth0_address[0] + status

    time.sleep(1)
Beispiel #24
0
def tidyup():
    backlight.off()
    lcd.clear()
Beispiel #25
0
def handle_up(ch, evt):
    print("Up pressed!")
    lcd.clear()
    backlight.rgb(255, 0, 0)
    lcd.write("Up up and away!")
Beispiel #26
0
def handle_left(ch,evt):
  print("Left pressed!")
  l.clear()
  b.rgb(0,0,255)
  l.write("Leftie left left!")
Beispiel #27
0
def handle_button(ch,evt):
  print("Button pressed!")
  l.clear()
  b.rgb(255,255,255)
  l.write("Ouch!")
Beispiel #28
0
def handle_cancel(ch, evt):
    print("Cancel pressed!")
    lcd.clear()
    backlight.rgb(0, 0, 0)
    lcd.write("Boom!")
Beispiel #29
0
def handle_up(ch,evt):
  print("Up pressed!")
  l.clear()
  b.rgb(255,0,0)
  l.write("Up up and away!")
Beispiel #30
0
def handle_left(ch, evt):
    print("Left pressed!")
    l.clear()
    b.rgb(0, 0, 255)
    l.write("Leftie left left!")
Beispiel #31
0
def handle_right(ch, evt):
    print("Right pressed!")
    lcd.clear()
    backlight.rgb(0, 255, 255)
    lcd.write("Rightie tighty!")
def handle_up(ch,evt):
    print("Playing BBC Radio 2")
    l.clear()
    b.rgb(255,0,255)
    l.write("BBC Radio 2")
    player(radio2)
def handle_down(ch,evt):
    print("Playing BBC 6 Music")
    l.clear()
    b.rgb(87,145,146)
    l.write("BBC 6 Music")
    player(radio6)
def handle_cancel(ch,evt):
    print("Stopping Music")
    l.clear()
    b.rgb(0,0,0)
    stop()
Beispiel #35
0
def handle_button(ch, evt):
    print("Button pressed!")
    l.clear()
    b.rgb(255, 255, 255)
    l.write("Ouch!")
Beispiel #36
0
def handle_cancel(ch, evt):
    print("Cancel pressed!")
    l.clear()
    b.rgb(0, 0, 0)
    l.write("Boom!")
Beispiel #37
0
def handle_down(ch, evt):
    print("Down pressed!")
    lcd.clear()
    backlight.rgb(0, 255, 0)
    lcd.write("Down down doobie down!")
Beispiel #38
0
def handle_down(ch, evt):
    print("Down pressed!")
    l.clear()
    b.rgb(0, 255, 0)
    l.write("Down down doobie down!")
Beispiel #39
0
def handle_left(ch, evt):
    print("Left pressed!")
    lcd.clear()
    backlight.rgb(0, 0, 255)
    lcd.write("Leftie left left!")
Beispiel #40
0
def handle_up(ch, evt):
    print("Up pressed!")
    l.clear()
    b.rgb(255, 0, 0)
    l.write("Up up and away!")
Beispiel #41
0
def handle_button(ch, evt):
    print("Button pressed!")
    lcd.clear()
    backlight.rgb(255, 255, 255)
    lcd.write("Ouch!")
import dothat.lcd as lcd
import dothat.backlight as backlight
import time
from datetime import datetime
import subprocess

while True:
    lcd.clear()
    backlight.rgb(0, 255, 0)
    try:
        hostname = subprocess.check_output(['hostname']).split()[0]
        ip = subprocess.check_output(['hostname', '-I']).split()[0]
        t = '{:%H:%M:%S}'.format(datetime.now())
        lcd.write(hostname)
        lcd.set_cursor_position(0, 1)
        lcd.write(ip)
        lcd.set_cursor_position(0, 2)
        lcd.write(t)
    except:
        backlight.rgb(255, 0, 0)
    time.sleep(1)
Beispiel #43
0
def signal_handler(sig, frame):
    backlight.off()
    lcd.clear()
    sys.exit(0)
def reset():
	lcd.clear()
	backlight.graph_off()
	backlight.off()
Beispiel #45
0
def handle_down(ch,evt):
  print("Down pressed!")
  l.clear()
  b.rgb(0,255,0)
  l.write("Down down doobie down!")
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)
Beispiel #47
0
def handle_right(ch,evt):
  print("Right pressed!")
  l.clear()
  b.rgb(0,255,255)
  l.write("Rightie tighty!")
Beispiel #48
0
    def redraw(self, menu):
        """
          The output to the LCD looks as follows

          |Mon 01 Jan 16:35| |Mon 01 Jan 16.35|
          |[1] Now 0d7h25m | |[1] In 04d5h25m |
          |Event descriptio| |Event descriptio|

          Line 1: constantly updating clock. Time seperator blinks between : and .
          Line 2: Event number in square brackets
                  Ongoing events show "Now", an arrow and time to end of event.
                  Upcoming events show "In", and a countdown to start of event.
          Line 3: Event description. "All Day:" is appended if it's an all day event.
                  Will scroll if the line doesn't fully fit on the screen.
        """

        # Start by seeing if we need to be in a reminder state
        reminderactive=0
        for reminder in self.reminders:
            timenow=datetime.datetime.now(self.localtz)
            if (timenow > reminder['start'] and timenow < reminder['end']):
                reminderactive=1

        # Decide what to do with the graph LEDs and set them 
        graphstates = self.CalculateGraph(reminderactive)
        for x in range(6):
          backlight.graph_set_led_state(x,graphstates[x])

        # If it's time for a refresh because an event's ended, do a background refresh
        if (datetime.datetime.now(self.localtz) > self.nextrefresh):
            thread.start_new_thread(self.BgUpdateCalendar,())
            return

        # If maxevents is zero, we have no events due to an error or an empty calendar
        if (self.maxevents == 0):
            menu.write_option(
                row=0,
                text="No events!",
                scroll=False
            )
            menu.write_option(
                row=1,
                text="Rechecking at",
                scroll=False
            )
            menu.write_option(
                row=2,
                text=str(self.nextrefresh.time().replace(microsecond=0)),
                scroll=False
            )
            return

        # If there's a calendar update happening, say so and do nothing else.
        # Don't update if the screensave is active..
        if (self.updating_calendar == 1 and self.screensave==0):
            menu.write_option(
                row=0,
                text="Please Wait",
                scroll=False
            )
            menu.write_option(
                row=1,
                text="Updating",
                scroll=False
            )
            menu.write_option(
                row=2,
                text="Calendar",
                scroll=False
            )
            return


        # Do nothing if the screen is turned off
        if (self.screensave == 1):
            return

        # If the idle timer has been reached, turn the screen off 
        if ((time.time() - self.idletimer) > self.idletimeout):
            lcd.clear()
            self.screensave = 1
            backlight.rgb(0,0,0)
            return

        # A screensave state of 2 means we need to activate the screen/
        # Restore the backlight to the last saved RGB values.
        if (self.screensave == 2):
            backlight.rgb(self.red,self.green,self.blue)

        # Either the displayed event has been changed, or the time has moved on a minute
        # In both cases, we need to recalculate the countdown strings
        if ((self.d_event != self.c_event) or (datetime.datetime.now().minute != self.last_update)):

            # Create timediff items so we can see when the start and finish are relative to now
            self.timetoevent=self.events[self.d_event]['estart_dt'] - datetime.datetime.now(self.localtz)
            self.timetoend=self.events[self.d_event]['eend_dt'] - datetime.datetime.now(self.localtz)

            # Calculate days/hours/mins remaining till event start
            self.tte_days = self.timetoevent.days
            self.tte_secs = self.timetoevent.seconds
            self.tte_hours = (self.tte_secs // 3600)
            # +1 minute because we're not counting seconds
            self.tte_mins = ((self.tte_secs % 3600) // 60) + 1
            # Though this does introduce a kettle of worms that 1h60m is a possible result.
            if (self.tte_mins == 60):
                self.tte_hours = self.tte_hours + 1
                self.tte_mins = 0
  
            # Calculate days/hours/mins remaining till event finish
            self.ttee_days = self.timetoend.days
            self.ttee_secs = self.timetoend.seconds
            self.ttee_hours = (self.ttee_secs // 3600)
            # +1 minute because we're not counting seconds
            self.ttee_mins = ((self.ttee_secs % 3600) // 60) + 1
            # Though this does introduce a kettle of worms that 1h60m is a possible result.
            if (self.ttee_mins == 60):
              self.ttee_hours = self.ttee_hours + 1
              self.ttee_mins = 0

            # Update state to reflect the event and the timestamp we've calculated for
            self.c_event = self.d_event
            self.last_update = datetime.datetime.now().minute
  
        # If the number of days to the event is positive, the event is upcoming.
        # Work out how long we have till the event starts.
        # If it's negative, the event has already started, so instead we work out how long till the end
        if (self.tte_days >= 0):
            # If it's over a week away, just show days remaining
            if (self.tte_days > 7):
                countdown = ("[" + str(self.d_event+1) + "] in " + str(self.tte_days) + "d" )
            else:
                countdown=("[" + str(self.d_event+1) + "] in " + str(self.tte_days) + "d" + 
                    str(self.tte_hours) + "h" + str(self.tte_mins) + "m" )
            start = self.events[self.d_event]['estart_dt'].astimezone(self.localtz).strftime("%H:%M")
        else:
            # Recreate the arrow character when we know we need to use it. Just to be safe.
            # Just show days if it's not finishing in less than a week :)
            lcd.create_char(1, self.arrow)
            if (self.ttee_days > 7):
              countdown= "["+ str(self.d_event+1) + "] Now\x01" + str(self.ttee_days) + "d" 
            else:
              countdown= ("["+ str(self.d_event+1) + "] Now\x01" + str(self.ttee_days) + "d" + 
                  str(self.ttee_hours) + "h" + str(self.ttee_mins) + "m" )
            start = ""

        # If the event is less than 300 minutes away (5 hours), vary the backlight
        # Hue values 0.0 -> 0.3 give us a decent green -> red transition.
        # Take the number of seconds left, divide by 60 to give us minutes remaining
        # then divide by 1,000 to give us 0.3 at 300 mins left ~~> 0.0 at 0 mins.
        # Use the provided hue_to_rgb() function to do the maths for us, and set the
        # backlight accordingly.
        if (self.tte_days == 0 and (float(self.tte_secs) / 60) < 300):
            rgb = backlight.hue_to_rgb(float(self.tte_secs)/60000)
            self.SetRGB(rgb[0], rgb[1], rgb[2])
        else:
            self.SetRGB(self.defaultR, self.defaultG, self.defaultB)

        # Pick out the event summary
        if (self.events[self.d_event]['allday_flag'] == True):
            summary = "All Day:" + self.events[self.d_event]['summary']
        else:
            summary = start + " " + self.events[self.d_event]['summary']

        # We don't need to bother scrolling events with short names
        if (len(summary) < 16):
            scrollsummary = False
        else:
            scrollsummary = True
        
        #  When the clock's active, we use a custom character for the colon
        #  We redefine this character every other second so the top dot is
        #  missing. Which gives us a nice 'blinking' top dot in the time :)
        animframe = (datetime.datetime.now().second % 2)
        lcd.create_char(2, self.clockanim[animframe])
        # datetime.now returns local time, so this behaves correctly
        clockstring=datetime.datetime.now(self.localtz).strftime('%a %d %b %H\x02%M')

        # Write the menu rows
        menu.write_option(
          row=0,
          text=clockstring,
          scroll=False
        )
        menu.write_option(
          row=1,
          text=countdown,
          scroll=False
        )
        menu.write_option(
          row=2,
          text=summary,
          scroll=scrollsummary
        )
Beispiel #49
0
def handle_cancel(ch,evt):
  print("Cancel pressed!")
  l.clear()
  b.rgb(0,0,0)
  l.write("Boom!")
def on_message(client, userdata, msg):
    """Handle incoming messages."""
    # print("Topic:", msg.topic + '  :  Message: ' + msg.payload)
    print(str(msg.topic), str(msg.payload))

    if str(msg.topic) == "orchestra/cue":
        """Handle RTTTL song cue command."""
        lcd.set_cursor_position(0, 0)
        lcd.write("Now playing:".ljust(16))
        """Handle incoming playback cue."""
        notedict = {
            "C": 36,
            "C#": 37,
            "D": 38,
            "D#": 39,
            "E": 40,
            "F": 41,
            "F#": 42,
            "G": 43,
            "G#": 44,
            "A": 45,
            "A#": 46,
            "B": 47
        }
        channeldict = {
            "C": 0,
            "C#": 0,
            "D": 1,
            "D#": 1,
            "E": 2,
            "F": 3,
            "F#": 3,
            "G": 4,
            "G#": 4,
            "A": 5,
            "A#": 5,
            "B": 6
        }

        tune = RTTTL(msg.payload)

        # tune is now an object storing a sequence of note frequencies and durations.
        # Iterate through that and handle each note to play back the song:

        for freq, msec in tune.notes():
            # print(freq, msec)
            if freq != 0.0:
                note, oct = freq_to_note(
                    freq
                )  # Get note name and octave number from the frequency.
                print(note, oct)
                play_beats = list(
                    "00000000")  # fresh playlist. List so mutable.
                # Set the glockenspiel channel from the note name. Wrap around octaves since we only have 1 physically.
                play_beats[channeldict[note]] = "1"
                playset(
                    ''.join(play_beats))  # Command the glockenspiel over MQTT
                handle_note(
                    notedict[note],
                    oct)  # Synthesise note via pygame for direct playback
                sleep(msec / 1000.0)  # Pause for the note duration.
            else:
                print('Rest!')
                sleep(
                    msec / 1000.0
                )  # Pause for the rest duration (note frequency is zero).

        # Make sure the last note plays
        sleep(0.3)
        print(">>> Playback complete!")
        lcd.clear()
        lcd.set_cursor_position(0, 0)
        lcd.write("POISED READY")

    elif str(msg.topic) == "orchestra/song":
        print("Song title received")
        # Display song title on the HAT
        lcd.set_cursor_position(0, 1)
        lcd.write(str(msg.payload[:16]).ljust(16))

    elif str(msg.topic) == "orchestra/handle":
        lcd.set_cursor_position(0, 2)
        # Display song requester
        lcd.write("For: " + str(msg.payload[:11]).ljust(11))

    else:
        print("Well, that didn't work")
Beispiel #51
0
#!/usr/bin/env python

import dothat.lcd as lcd

print("""
This example shows a basic "Hello World" on the LCD.
You should see "Hello World" displayed on your LCD!

Press CTRL+C to exit.
""")

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

def player(radio):
    global p
    p = vlc.MediaPlayer(radio)
    p.play()

def stop():
    p.stop()
    b.rgb(255,0,0)
    l.write("S T O P")
    b.graph_off()

#MAIN BODY

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

@j.on(j.DOWN)
def handle_down(ch,evt):
    print("Playing BBC 6 Music")
    l.clear()
    b.rgb(87,145,146)