#!/usr/bin/env python import scrollphathd try: while True: for x in range(18): scrollphathd.fill(0.1, 0, 0, x, 7) scrollphathd.show() for x in range(18): scrollphathd.fill(0, 0, 0, x, 7) scrollphathd.show() except KeyboardInterrupt: scrollphathd.fill(0) scrollphathd.show()
while True: i += 2 s = math.sin(i / 50.0) * 2.0 + 6.0 for x in range(0, 17): for y in range(0, 7): v = 0.3 + (0.3 * math.sin((x * s) + i / 4.0) * math.cos((y * s) + i / 4.0)) scrollphathd.pixel(x, y, v) time.sleep(0.01) scrollphathd.show() if i>620: break #gamma DELAY = 0.0001 i = 0 while True: i=i+1 for x in range(255): scrollphathd.fill(x/255.0, 0, 0, 17, 7) scrollphathd.show() time.sleep(DELAY) for x in reversed(range(255)): scrollphathd.fill(x/255.0, 0, 0, 17, 7) scrollphathd.show() time.sleep(DELAY) if i>2: break
if ALARM_ENABLED and current_time.hour == ALARM_HOUR and current_time.minute == ALARM_MIN: if alarm_status == AlarmStatus.WAITING: logger.debug('Begin alarm') alarm_status = AlarmStatus.PLAYING alarm_play_obj = alarm_sound.play() else: alarm_status = AlarmStatus.WAITING if alarm_status == AlarmStatus.PLAYING and not alarm_play_obj.is_playing( ): logger.debug('Playing sound file') alarm_play_obj = alarm_sound.play() if alarm_status == AlarmStatus.PLAYING and current_time.second % 2 == 0: scrollphathd.fill(BRIGHTNESS, x=0, y=6, width=17, height=1) if (alarm_status == AlarmStatus.STOPPED or alarm_status == AlarmStatus.WAITING ) and alarm_play_obj and alarm_play_obj.is_playing(): logger.debug("Stoppng sound file") alarm_play_obj.stop() if ((current_time.hour >= DISPLAY_ON_HOUR and current_time.hour < DISPLAY_OFF_HOUR) or alarm_status == AlarmStatus.PLAYING or (current_time - last_button_press).total_seconds() <= BUTTON_DISPLAY_DURATION): # Display the time display_hour = ((current_time.hour - 1) % 12) + 1 scrollphathd.write_string("{:>2}:{:0>2}".format(
#!/usr/bin/env python import time import scrollphathd DELAY = 0.0001 try: while True: for x in range(255): scrollphathd.fill(x / 255.0, 0, 0, 15, 7) scrollphathd.show() time.sleep(DELAY) for x in reversed(range(255)): scrollphathd.fill(x / 255.0, 0, 0, 15, 7) scrollphathd.show() time.sleep(DELAY) except KeyboardInterrupt: scrollphathd.fill(0) scrollphathd.show()
#!/usr/bin/env python #Displays a specific text import signal import scrollphathd from scrollphathd.fonts import font3x5 scrollphathd.set_brightness(0.3) scrollphathd.fill(1, 0, 0, 17, 7) scrollphathd.write_string("Ahoy!", y=1, font=font3x5, brightness=0) scrollphathd.show() signal.pause()
import json import urllib url = 'https://www.bitstamp.net/api/v2/ticker/btcusd/' BRIGHTNESS = 0.2 last = 0 while True: latest = float(json.load(urllib.urlopen(url))['last']) print(latest) scrollphathd.clear() scrollphathd.fill(0, 0, 0, 50, 14) # a nice big canvas to work with if latest > last: scrollphathd.scroll_to(0, 0) scrollphathd.write_string('%s ' % int(last), 0, 0, font5x5, 1, BRIGHTNESS) scrollphathd.write_string('%s ' % int(latest), 0, 7, font5x5, 1, BRIGHTNESS) for c in range(8): scrollphathd.show() scrollphathd.scroll(0, 1) time.sleep(0.05) if latest < last: scrollphathd.write_string('%s ' % int(latest), 0, 0, font5x5, 1, BRIGHTNESS)
#!/usr/bin/env python import time import scrollphathd scrollphathd.pixel(0, 0, 0.5) try: while True: scrollphathd.scroll(1, 1) scrollphathd.show() time.sleep(0.1) except KeyboardInterrupt: scrollphathd.fill(0) scrollphathd.show()
offset_left = 0 # Get message from MESSAGEHD file created by create-message.sh lines = get_msg(MESSAGEHD_FILE) if DEBUG == 1: print("{}{} {} {}[{}] {} {} {} {}:{} {}[DEBUG]{} Show lines >{}<".format( color.END, get_date_stamp(), LOCALHOST, __file__, os.getpid(), SCRIPT_VERSION, get_line_no(), USER, UID, GID, color.BOLD, color.END, lines)) # Code from Pimoroni scrollphathd/examples/advanced-scrolling.py # Draw each line in lines to the Scroll pHAT HD buffer # scrollphathd.write_string returns the length of the written string in pixels # we can use this length to calculate the offset of the next line # and will also use it later for the scrolling effect. lengths = [0] * len(lines) # scrollphathd.fill(0, 0, 0) #25 This is what fixed incident #25 if DEBUG == 1: print( "{}{} {} {}[{}] {} {} {} {}:{} {}[DEBUG]{} Before 'for' loop; lengths >{}< offset_left >{}< line_height >{}<" .format(color.END, get_date_stamp(), LOCALHOST, __file__, os.getpid(), SCRIPT_VERSION, get_line_no(), USER, UID, GID, color.BOLD, color.END, lengths, offset_left, line_height)) #25 for line, text in enumerate(lines): lengths[line] = scrollphathd.write_string(text, x=offset_left, y=line_height * line) offset_left += lengths[line] if DEBUG == 1: print( "{}{} {} {}[{}] {} {} {} {}:{} {}[DEBUG]{} After 'for' loop; lengths >{}< offset_left >{}< line_height >{}<" .format(color.END, get_date_stamp(), LOCALHOST, __file__, os.getpid(),
import time import scrollphathd as sphd def screenClear(): sphd.clear() sphd.show() sphd.fill(1,0,0,17,7) sphd.show() time.sleep(100) #screenClear() #sphd.fill(1,0,0,0) #sphd.show() #time.sleep(1) #screenClear() #sphd.fill(1,0,0,0) #sphd.show() #time.sleep(1) #screenClear()