Example #1
0
def on_sensor_data(channel, data):
    print(channel, data)
    val = float(r.get_key(data+".temp"))
    print(str(val))

    scrollphat.write_string( str(round(val))[:2] )
    scrollphat.update()
Example #2
0
 def displayText(text):
     scrollphat.clear()
     scrollphat.write_string(text)
     for i in range(0, scrollphat.buffer_len() - 11):
         scrollphat.scroll()
         sleep(0.1)
     scrollphat.clear()
Example #3
0
    def scroll_message(self):

        time_count_par_sec = 1 / self.lotate_time_sec
        time_count_limit = time_count_par_sec * self.update_time_sec
        time_count = time_count_limit
        while True:
            try:
                if time_count >= time_count_limit:
                    print("")
                    print(" --- Check... ---")
                    time_count = 0
                    if self.get_weather_days(self.check_days):
                        print(" --- Update... ---")
                        self.add_optional_signal_output("start")
                        self.add_get_weather_time_output()
                        self.add_optional_signal_output("end")
                        self.get_weather_info()
                        scrollphat.write_string(self.output)
                        scrollphat.update()
                    else:
                        print(" --- No Update... ---")
                        print("   Updated: " + self.pub_date)
                        print(" --------------------")
                scrollphat.scroll()
                scrollphat.update()
                time.sleep(self.lotate_time_sec)
                time_count += 1

            except KeyboardInterrupt:
                print("\nInterrupted Ctrl + C !!\n")
                return
Example #4
0
    def run(self):
        global current_value
        next_value = 0.0
        scrollphat.set_rotate(True)

        while self.running:

            if next_value == 0.0:
                next_value_string = ""
            else:
                next_value_string = self.format_value(current_value)

            if current_value == 0.0:
                curr_value_string = "Loading.."
            else:
                curr_value_string = self.format_value(next_value)
                next_value = current_value

            string_to_display = curr_value_string + next_value_string

            scrollphat.write_string(string_to_display)
            length = scrollphat.buffer_len()

            for i in range(length):
                scrollphat.scroll()
                time.sleep(0.15)
Example #5
0
 async def poll_queue(self) -> None:
     while True:
         text = await self.queue.get()
         scrollphat.clear()
         scrollphat.write_string(text, 11)
         for _ in range(scrollphat.buffer_len()):
             scrollphat.scroll()
             await asyncio.sleep(self.period)
Example #6
0
def display(message):
    if scrollphat_connected:
        scrollphat.clear()
        scrollphat.write_string(message + "       ", 11)
        for i in range(0, scrollphat.buffer_len() - 11):
            scrollphat.scroll()
            time.sleep(0.08)
    else:
        print(message)
        time.sleep(0.1)
def display(message):
    if scrollphat_connected:
        scrollphat.clear()
        scrollphat.write_string(message + "       ", 11)
        for i in range(0, scrollphat.buffer_len() - 11):
            scrollphat.scroll()
            time.sleep(0.08)
    else:
        print(message)
        time.sleep(0.1)
Example #8
0
def scroll_once(msg):
    scrollphat.write_string(msg, 11)
    length = scrollphat.buffer_len()

    for i in range(length):
        try:
            scrollphat.scroll()
            time.sleep(0.1)
        except KeyboardInterrupt:
            scrollphat.clear()
def scroll_message(output):
    scrollphat.write_string(output)
    scrollphat.update()

    while(True):
        try:
            scrollphat.scroll()
            scrollphat.update()
            time.sleep(0.2)
        except KeyboardInterrupt:
            return
Example #10
0
async def poll_queue() -> None:
    if not HAS_SCROLLPHAT:
        return

    while True:
        text = await QUEUE.get()
        scrollphat.clear()
        scrollphat.write_string(text, 11)
        for _ in range(scrollphat.buffer_len()):
            scrollphat.scroll()
            await asyncio.sleep(1 / SPEED)
Example #11
0
def scroll_message(output):
    scrollphat.write_string(output)
    scrollphat.update()

    while (True):
        try:
            scrollphat.scroll()
            scrollphat.update()
            time.sleep(0.2)
        except KeyboardInterrupt:
            return
Example #12
0
def print_tweet(tweet):
    scrollphat.clear()
    scrollphat.set_brightness(7)
    scrollphat.write_string(tweet)
    x = 0
    # scroll the message twice
    while x < (scrollphat.buffer_len()*2):
        scrollphat.scroll()
        sleep(0.1)
        x += 1
    scrollphat.clear()
Example #13
0
def print_to_all_devices(text, code=None):

    if debug_on:
        if output_device == 0:
            print(text)
        elif output_device == 1:
            # scrollphat
            print(text)
            if code != None:
                scrollphat.clear()
                scrollphat.write_string(code)
            pass
Example #14
0
def test_scrollphat():
    import scrollphat
    scrollphat.set_brightness(2)

    scrollphat.write_string("BOOZER", 11)
    length = scrollphat.buffer_len()

    for i in range(length):
        try:
            scrollphat.scroll()
            time.sleep(0.1)
        except KeyboardInterrupt:
            scrollphat.clear()
            sys.exit(-1)
Example #15
0
def destroy():  # Shutdown GPIO and Cleanup modules
    print "\n... Shutting Down...\n"
    scrollphat.clear()  # Shutdown Scroll pHat
    scrollphat.write_string("Ext")
    DalekV2Drive.stop()  # Make sure Bot is not moving when program exits
    DalekV2Drive.cleanup()  # Shutdown all motor control
    global camera  # Allow Access to PiCamera Object
    if camera._check_camera_open() == True:
        camera.close()  # Shutdown Pi Camera
    global wii
    wii.rumble = 1
    time.sleep(0.5)
    wii.rumble = 0
    scrollphat.clear()  # Clear Scroll pHat
    GPIO.cleanup()  # Release GPIO resource
Example #16
0
def set_output_device(_dalekDebugOutputDevice):
    """ 
    sets the output device 
    default is stout/command line only
    "scollphat" adds the bots display as well as stout
    """
    global output_device

    if _dalekDebugOutputDevice == "scrollphat":

        scrollphat.clear()
        scrollphat.write_string("BOT")
        output_device = 1
        debug_on = True  # assume that as it is set,  use it.
    else:
        output_device = 0
Example #17
0
    def textScroll(self, text):
        '''Displays a text at the scroll-pHAT'''

        if self.args.verbose:
            print('Running Twitter.textScroll, text: %s' % text)

        scrollphat.write_string(text, 11)
        length = scrollphat.buffer_len()

        for i in range(length):
            try:
                scrollphat.scroll()
                time.sleep(self.args.pause_text_scroll)
            except KeyboardInterrupt:
                scrollphat.clear()
                sys.exit(-1)
  def run(self):
    global currency_value
    next_value = 0.0
    while running:

      curr_value_string = "{:7.2f}".format( round( next_value,      2 ) ) + self.symbol + " "
      next_value_string = "{:7.2f}".format( round( currency_value,  2 ) ) + self.symbol + " "

      next_value = currency_value

      string_to_display = curr_value_string + next_value_string

      scrollphat.write_string( string_to_display )
      string_length = self.count_letters( curr_value_string )
      for _ in range( string_length ):
        scrollphat.scroll()
        time.sleep(0.1)
Example #19
0
def led_status(buttonPin):
	global option, RED, YELLOW, BLUE, GREEN, LED
	if GPIO.input(buttonPin) == GPIO.HIGH:

		print ("LED OFF")
	else:
		print ("LED ON")
		time_hour = int(strftime("%H", time.localtime()))
		say_greeting(time_hour)
		if option == 1:
			LED = GREEN
			current = say_clock()
			cur_time = strftime("%H:%M", time.localtime())

			current =  cur_time + "     " + current

		elif option == 2:
			LED=RED
			current = say_date()

		elif option == 3:
			LED = YELLOW
			current = say_weather() 

		print current

		scrollphat.set_brightness(4)
		while True:
		    try:
			GPIO.output(LED, GPIO.HIGH)
			scrollphat.write_string(current ) 
			scrollphat.scroll()
			time.sleep(0.1)
			GPIO.output(LED, GPIO.LOW)
			if GPIO.input(buttonPin) == GPIO.HIGH:
				raise KeyboardInterrupt()
		    except KeyboardInterrupt:
			play_sound("stop")
			scrollphat.clear()
			GPIO.output(LED, GPIO.LOW)
			option += 1
			if option > 3:
				option = 1

			return
    def scrollphat_output(days, hours, minutes, seconds, total):
        global start_seconds
        start_seconds = start_seconds or total

        bar = int(5 * (float(total) / start_seconds))

        scrollphat.clear_buffer()
        s = str(seconds)
        indent = 2
        if len(s) == 1:
            indent = 4

        scrollphat.write_string(s, indent)

        for y in range(bar):
            scrollphat.set_pixel(0, y, 1)

        scrollphat.update()
Example #21
0
def destroy():                 # Shutdown GPIO and Cleanup modules

    global soundvolume         # Allow access to sound volume
        
    print ('\n... Shutting Down...\n')
    scrollphat.clear()         # Shutdown Scroll pHat
    scrollphat.write_string('Ext')
    DalekV2Drive.stop()        # Make sure Bot is not moving when program exits
    DalekV2Drive.cleanup()     # Shutdown all motor control
    global wii                 # Allow access to the wii object
    wii.rumble = 1
    time.sleep(0.5)
    wii.rumble = 0
    cv2.destroyAllWindows()    # Shutdown any open windows
    volumesetting = '"--volume=' + str(soundvolume) +'"'
    subprocess.Popen(['mplayer',volumesetting, 'Sound/Grow_stronger.mp3'], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    time.sleep(7)
    scrollphat.clear()         # Clear Scroll pHat
    GPIO.cleanup()             # Release GPIO resource
Example #22
0
    def run(self):
        global currency_value
        next_value = 0.0
        while running:

            curr_value_string = "{:7.2f}".format(round(next_value,
                                                       2)) + self.symbol + " "
            next_value_string = "{:7.2f}".format(round(currency_value,
                                                       2)) + self.symbol + " "

            next_value = currency_value

            string_to_display = curr_value_string + next_value_string

            scrollphat.write_string(string_to_display)
            string_length = self.count_letters(curr_value_string)
            for _ in range(string_length):
                scrollphat.scroll()
                time.sleep(0.1)
Example #23
0
def update(count):

    global last

    scrollphat.set_pixel(10, 4, 0)

    if count == None:

        scrollphat.clear()
        scrollphat.write_string("----")

    else:

        if count != last:

            scrollphat.clear()
            scrollphat.write_string(str(count))

            last = count
    def draw(self, game):

        text = game.get_scroller_text()

        if text != '':

           scrollphat.write_string(text)
           scrollphat.scroll()
           time.sleep(0.06)

        else:

            scrollphat.clear()

            for x, y in game.get_pixels():
                pixel = int(x), int(y)
                scrollphat.set_pixel(pixel[0], pixel[1], 1)

            scrollphat.update()
Example #25
0
def update(count):

    global last

    scrollphat.set_pixel(10,4,0)

    if count == None:

        scrollphat.clear()
        scrollphat.write_string("----")

    else:

        if count != last:

            scrollphat.clear()
            scrollphat.write_string(str(count))

            last = count
Example #26
0
def scrollText(text):
    """Scroll some text on the display once"""
    print("Displaying text: " + text)
    scrollphat.clear()
    # Write the text to the display, the extra space is to make scrolling look better.
    length = scrollphat.write_string("   " + text)
    for i in range(length - matrix_length):
        scrollphat.scroll()
        time.sleep(0.1)
    scrollphat.clear()
Example #27
0
 def on_success(self, data):
     if 'text' in data:
         h = HTMLParser.HTMLParser()
         user = data['user']['screen_name'].encode('utf-8')
         raw_tweet = h.unescape(data['text'])
         tweet = self.remove_link('     @{}: {}'.format(user.encode('utf-8'), raw_tweet.encode('utf-8')))
         if enable_scrollphat == True:
             scrollphat.write_string(tweet.upper())
             status_length = scrollphat.buffer_len()
             while status_length > 0:
                 scrollphat.scroll()
                 time.sleep(0.1)
                 status_length -= 1
             scrollphat.clear()
         else:
             try:
                 # i can't figure out how to print things reliably on windows with this crapping itself
                 print unicode(tweet).encode('ascii')
             except:
                 print '     @{}: Could not display tweet'.format(user.encode('utf-8'))
Example #28
0
 def on_success(self, data):
     if 'text' in data:
         h = HTMLParser.HTMLParser()
         user = data['user']['screen_name'].encode('utf-8')
         raw_tweet = h.unescape(data['text'])
         tweet = self.remove_link('     @{}: {}'.format(
             user.encode('utf-8'), raw_tweet.encode('utf-8')))
         if enable_scrollphat == True:
             scrollphat.write_string(tweet.upper())
             status_length = scrollphat.buffer_len()
             while status_length > 0:
                 scrollphat.scroll()
                 time.sleep(0.1)
                 status_length -= 1
             scrollphat.clear()
         else:
             try:
                 # i can't figure out how to print things reliably on windows with this crapping itself
                 print unicode(tweet).encode('ascii')
             except:
                 print '     @{}: Could not display tweet'.format(
                     user.encode('utf-8'))
Example #29
0
    def play_song(self, song_dict):
        stream_url = self.api.get_stream_url(song_dict['trackId'])
        self.player = self.vlc.media_player_new()
        media = self.vlc.media_new(stream_url)
        self.player.set_media(media)
        self.player.play()

        song_string = ""
        if (song_dict['source'] == '2'):
            song_string = self.get_song_details(song_dict)
        else:
            song_string = self.get_local_song_details(song_dict['trackId'])

        print("Playing...",song_string)
        
        if enable_display:
            scrollphat.clear()
            scrollphat.write_string(" "*5+song_string)

            if not self.thread_running:
                thread = Thread(target=self.scroll_string)
                thread.start()

        self.playing = True
Example #30
0
def setupwii():
    # Connect Wiimote
    print '\n\nPress & hold 1 + 2 on your Wii Remote now ...\n\n'
    scrollphat.clear()  # Shutdown Scroll pHat
    scrollphat.write_string("1+2")

    # Connect to the Wii Remote. If it times out
    # then quit.
    global wii

    try:
        wii = cwiid.Wiimote()
    except RuntimeError:
        print 'Error opening wiimote connection'
        scrollphat.clear()  # Shutdown Scroll pHat
        scrollphat.write_string("Err")
        time.sleep(0.5)
        return False

    print 'Wii Remote connected...\n'
    wii.rumble = 1
    time.sleep(0.1)
    wii.rumble = 0

    wii.led = 1
    time.sleep(0.75)
    wii.led = 2
    time.sleep(0.75)
    wii.led = 4
    time.sleep(0.75)
    wii.led = 8
    time.sleep(0.75)
    battery = int(wii.state['battery'] / 25)

    if battery == 4:
        wii.led = 8
    elif battery == 3:
        wii.led = 4
    elif battery == 2:
        wii.led = 2
    else:
        wii.led = 1

    wii.rumble = 1
    time.sleep(0.1)
    wii.rumble = 0

    scrollphat.clear()  # Shutdown Scroll pHat
    scrollphat.write_string("Gd")

    print '\nPress some buttons!\n'
    print 'Press PLUS and MINUS together to disconnect and quit.\n'

    return True
import os

try:
    import psutil
except ImportError:
    sys.exit(
        "This script requires the psutil module\nInstall with: sudo pip install psutil"
    )

import scrollphat

scrollphat.set_brightness(20)

cpu_temp = 0


def get_cpu_temperature():
    process = os.popen('vcgencmd measure_temp').readline()
    return (process.replace("temp=", "").replace("'C\n", ""))


while True:
    try:
        cpu_temp = int(float(get_cpu_temperature()))
        print(cpu_temp)
        scrollphat.write_string(str(cpu_temp) + "C")
        time.sleep(3)
    except KeyboardInterrupt:
        scrollphat.clear()
        sys.exit(-1)
import scrollphat as sp
import sys
import time
import random
from random import randint

sp.set_rotate(True)
sp.set_brightness(10)

lines = open('text_to_scroll.txt').read().splitlines()

while True:
    myline = random.choice(lines)
    spacer = "   -   "
    random_spacer = randint(3,5)
    random_spacer_length = len(spacer) * random_spacer
    text_length = len(myline)

    sp.write_string((spacer * random_spacer) + random.choice(lines) + (spacer * random_spacer))
        
    length = (text_length + (random_spacer_length * 2) * 5) # pixels to scroll, in total.
    print length

    for x in range(0,length):
        try:
            sp.scroll()
            time.sleep(0.075)
        except KeyboardInterrupt:
            sp.clear()
            sys.exit(-1)
Example #33
0
#!/usr/bin/env python

import scrollphat
import time
import sys

msg=raw_input("Please enter your message: ")

for letter in msg:
  scrollphat.write_string(letter)
  time.sleep(0.7)
  scrollphat.clear()
Example #34
0
import lsm_ada
from time import sleep
import scrollphat
import sys
import time

lsm = lsm_ada.Adafruit_LSM303()
counter =0
while True:
   acc = lsm.read()
   a_x = acc[0][0]
   a_y = acc[0][1]
   a_z = acc[0][2]
   m_x = acc[1][0]
   m_y = acc[1][1]
   m_z = acc[1][2]
   
   if a_x > -900:
     counter +=1
   print(acc)
   sleep(0.1)
   scrollphat.write_string(str(counter))


   scrollphat.scroll()
   time.sleep(0.1)
from random import randint

sp.set_rotate(True)
sp.set_brightness(10)

lines = open('text_to_scroll.txt').read().splitlines()

#while True:
#   try:
myline = random.choice(lines)
spacer = "   -   "
random_spacer = randint(3, 5)
random_spacer_length = len(spacer) * random_spacer
text_length = len(myline)

sp.write_string((spacer * random_spacer) + random.choice(lines) +
                (spacer * random_spacer))

length = (text_length + (random_spacer_length * 2) * 5
          )  # pixels to scroll, in total.
print length

for x in range(0, length):
    try:
        sp.scroll()
        time.sleep(0.075)
    except KeyboardInterrupt:
        sp.clear()
        sys.exit(-1)

print "finished"
#!/usr/bin/env python

import scrollphat as sp
import sys, time, random, math
from random import randint

sp.set_rotate(False)
sp.set_brightness(50)

lines = open('/home/pi/Pimoroni/scrollphat/my_scrolls/boomkat_output_file').read().splitlines()

#while True:
try:        
    line_to_scroll = random.choice(lines)
    sp.write_string("      " + line_to_scroll + "     ")
    string_length = sp.buffer_len()
    while string_length > 0:
        sp.scroll()
        time.sleep(0.065)
        string_length -= 1
except KeyboardInterrupt:
    sp.clear()
    sys.exit(-1)

import scrollphat
scrollphat.write_string("Hello world")
Example #38
0
#!/usr/bin/env python

import scrollphat
import sys
import time

if len(sys.argv) != 2:
    print("\nusage: python simple-text-scroll.py\"message\" \npress CTRL-C to exit\n")
    sys.exit(0)

scrollphat.write_string(sys.argv[1] + " ")

while True:
    try:
        scrollphat.scroll()
        time.sleep(0.1)
    except KeyboardInterrupt:
        scrollphat.clear()
        sys.exit(-1)
        def get_day_sufx(dNum):        # Work out "st", "nd", "rd" or "th"
            if dNum == ("1","21","31"):
                return "st"
            if dNum == ("2","22"):
                return "nd"
            if dNum == ("3","23"):
                return "rd"
            else:
                return "th"

        sufx = get_day_sufx(dNum)   # Run above, supply date, create suffix
        dNam = time.strftime("%A")  # Day name
        mnth = time.strftime("%B")  # Month name (full)
        year = time.strftime("%Y")  # Year (4 digits)
        hour = time.strftime("%H")  # Hours (24 hours)
        mins = time.strftime("%M")  # Minutes
        secs = time.strftime("%S")  # Seconds

        # Assemble all the variables into a single string
        assembled = " " + dNam + " " + dNum + sufx + " " + mnth + " " + year + "    " + hour + ":" + mins + ":" + secs + "    "

        scrollphat.set_brightness(10)      # Readable brightness?
        scrollphat.write_string(assembled) # Create the string for the pHAT
        scrollphat.scroll()                # Scroll the string
        time.sleep(0.1)                    # Control the speed

    except KeyboardInterrupt: # Stop script if "Ctrl+C" is pressed
        scrollphat.clear()    # Clear pHAT display before exiting
        sys.exit(-1)
Example #40
0
#!/usr/bin/env python

import sys
import time

import scrollphat


scrollphat.set_brightness(2)

if len(sys.argv) != 2:
    print("\nusage: python simple-text-scroll-rotated.py \"message\" \npress CTRL-C to exit\n")
    sys.exit(0)

scrollphat.set_rotate(True)
scrollphat.write_string(sys.argv[1], 11)

while True:
    try:
        scrollphat.scroll()
        time.sleep(0.1)
    except KeyboardInterrupt:
        scrollphat.clear()
        sys.exit(-1)
Example #41
0
#!/usr/bin/env python

import scrollphat
import sys
import time

if(len(sys.argv) == 1):
    print "Type a number in under 999 as an argument."
    sys.exit(-1)
val = int(sys.argv[1])

if(val > 999):
    print "Number must be under 999 to fit on screen"
    sys.exit(-1)

scrollphat.set_brightness(7)

for x in range(1, val+1):
	scrollphat.write_string(str(x))
	time.sleep(0.35)
Example #42
0
		display_str = hour + ":" + minute + "  " + temp_str + summary

		# 'M' and 'W' take 6 spaces, rather than 4
		num_m = display_str.count('M')
		num_w = display_str.count('W')
		neg = display_str.count('-')
                # Each letter takes 4 LEDs to display (including trailing space)
                # -1 because the degree symbol only takes 2 LEDs
		# -1 because colon symbol only takes 2 LEDs
		# -2 for each space added to string
                # -11 because they are shown before we need to scroll
                # -1 because there's no trailing space after last letter
		scroll_len = len(display_str)*4 - 1 - 1 - 4 - 11 - 1 + 2*(num_m+num_w) - 1*neg

		s.clear()
		s.write_string(display_str)
		t.sleep(1)
		for i in range(scroll_len):
			t.sleep(0.08)
			s.scroll()
		t.sleep(0.5)

                # Update the weather forecast every 5 minutes
		if ((t.time() - start_time) > 5*60):
			try:
				forecast = f.load_forecast(api_key, lat, lng, units='si')
				current_forecast = forecast.currently()
			except:
				pass
			start_time = t.time()
			print(t.asctime()[11:-5], '\r')
 def POST(self):
     deserialized = json.loads(web.data())
     scrollphat.write_string(deserialized["message"] + "    ")
     scrollphat.set_brightness(deserialized["brightness"])
     if not scrollThread.is_alive():
         scrollThread.start()
Example #44
0
    val += "        " + d['entries'][2]['title']
    # Tidy & shorten the message for the scroll display
    val = val.replace("Maximum", "Max")
    val = val.replace("Minimum", "Min")
    val = val.replace("Temperature: ", "")
    val = val.replace(u"\u00B0", "")
    val = val.replace(",", "")
    val = val.replace("(", "")
    val = val.replace(")", "")
    return val


timeout = get_timeout()
count = 0
msg = get_wet()
scrollphat.write_string(msg)

while True:
    try:
        scrollphat.scroll()
        time.sleep(pause)

        if (count > timeout):
            msg = get_wet()
            scrollphat.write_string(msg)
            timeout = get_timeout()
            count = 0
        else:
            count = count + 1
    except KeyboardInterrupt:
        scrollphat.clear()
Example #45
0
#!/usr/bin/env python

import scrollphat
import sys
import time

if (len(sys.argv) == 1):
    print "Type a number in under 999 as an argument."
    sys.exit(-1)
val = int(sys.argv[1])

if (val > 999):
    print "Number must be under 999 to fit on screen"
    sys.exit(-1)

scrollphat.set_brightness(7)

for x in range(1, val + 1):
    scrollphat.write_string(str(x))
    time.sleep(0.35)
Example #46
0
        ip = json_data['ip']
    return ip


def get_ip(mode):
    return get_public_ip() if mode == "public" else get_internal_ip()


#    return mode == "public" ? get_public_ip() : get_internal_ip()

address_mode = "public"
if (len(sys.argv) == 2):
    address_mode = sys.argv[1]

ip = get_ip(address_mode)

print(address_mode + " IP Address: " + str(ip))

scrollphat.set_brightness(3)

while True:
    try:
        scrollphat.clear()
        scrollphat.write_string("IP: " + str(ip) + "    ")
        for i in range(0, scrollphat.buffer_len() - 11):
            scrollphat.scroll()
            time.sleep(0.1)
    except KeyboardInterrupt:
        scrollphat.clear()
        sys.exit(-1)
Example #47
0
#!/usr/bin/env python

import scrollphat
import time
import sys

scrollphat.write_string("Hello, World");

while True:
  try:
      scrollphat.scroll()
      time.sleep(0.3)
    except KeyboardInterrupt:
    scrollphat.clear()
    sys.exit(-1)
      
#!/usr/bin/env python

import scrollphat
import sys
import time

if len(sys.argv) != 2:
    print("\nusage: python simple-text-scroll-rotated.py \"message\" \npress CTRL-C to exit\n")
    sys.exit(0)

scrollphat.set_rotate(True)
scrollphat.write_string("    " + sys.argv[1])

while True:
    try:
        scrollphat.scroll()
        time.sleep(0.1)
    except KeyboardInterrupt:
        scrollphat.clear()
        sys.exit(-1)
Example #49
0
#!/usr/bin/env python

import math
import time
import scrollphat
import sys

def millis():
    return int(round(time.time() * 1000))

scrollphat.set_brightness(2)
scrollphat.write_string("Mark Lane  |||  SportTrax  |||  marklane.ml  |||  ") #Leave x number of blank spaces to prevent overlap

while True:
    try:
        scrollphat.scroll()
        time.sleep(0.1)
    except KeyboardInterrupt:
        scrollphat.clear()
        sys.exit(-1)
Example #50
0
#!/usr/bin/env python

import math
import time
import scrollphat
import sys


def millis():
    return int(round(time.time() * 1000))


scrollphat.set_brightness(2)
scrollphat.write_string(
    "Sammy Herring  |||  SportTrax  |||  sherring.me  |||  "
)  #Leave x number of blank spaces to prevent overlap

while True:
    try:
        scrollphat.scroll()
        time.sleep(0.1)
    except KeyboardInterrupt:
        scrollphat.clear()
        sys.exit(-1)
 def show(self, total):
     val = total
     if total > 999:
         val = 999
     scrollphat.write_string(str(val))
Example #52
0
  while True:
    my_delta = datetime.datetime(year=YEAR,month=1,day=1,hour=0,minute=0) - datetime.datetime.now()
    days_left = math.floor(my_delta.days + (my_delta.seconds/86400))
    hours_left = math.ceil((my_delta.days * 24) + (my_delta.seconds/3600))
    minutes_left = math.ceil((my_delta.days * 24 * 60) + (my_delta.seconds/60))
    seconds_left = math.ceil((my_delta.days * 24 * 3600) + my_delta.seconds)
    if hours_left >= 55:
      count_string = '{0}D'.format(days_left)
    elif minutes_left >= 60:
      count_string = '{0}H'.format(hours_left)
    elif seconds_left >= 60:
      count_string = '{0}M'.format(minutes_left)
    else:
      count_string = '{0}S'.format(seconds_left)
    if count_string != last_time:
      scrollphat.clear_buffer()
      for i in range(11):
        scrollphat.scroll()
        time.sleep(0.01)
      scrollphat.clear_buffer()
      scrollphat.write_string(count_string, 11)
      for i in range(scrollphat.buffer_len()-12):
        scrollphat.scroll()
        time.sleep(0.05)
      last_time = count_string
      time.sleep(0.2)

except KeyboardInterrupt:
  scrollphat.clear()
  sys.exit(-1)
Example #53
0
            scrollphat.clear()
            scrollphat.write_string(str(count))

            last = count

def process():

    try:

        params = {"key": apiKey}
        r = requests.get(server, params=params, timeout=5)
        count = int(r.text)
        update(count)

    except:

        status(1)
        #update(None)


if __name__ == "__main__":

    scrollphat.set_brightness(brightness)
    scrollphat.write_string("0")

    while True:

        process()
        time.sleep(updatePeriod)
Example #54
0
    val +="        " + d['entries'][1]['title']
    val +="        " + d['entries'][2]['title']
# Tidy & shorten the message for the scroll display
    val = val.replace("Maximum", "Max")
    val = val.replace("Minimum", "Min")
    val = val.replace("Temperature: ", "")
    val = val.replace(u"\u00B0","")
    val = val.replace(",", "")
    val = val.replace("(", "")
    val = val.replace(")", "")
    return val

timeout = get_timeout()
count = 0
msg = get_wet()
scrollphat.write_string(msg)

while True:
    try:
        scrollphat.scroll()
        time.sleep(pause)

        if(count > timeout):
            msg = get_wet()
            scrollphat.write_string(msg)
            timeout = get_timeout()
            count = 0
        else:
            count = count+ 1
    except KeyboardInterrupt:
        scrollphat.clear()
#!/usr/bin/env python

import math
import time
import scrollphat
import sys

def millis():
    return int(round(time.time() * 1000))

scrollphat.set_brightness(2)
scrollphat.write_string("Sammy Herring  |||  SportTrax  |||  sherring.me  |||  ") #Leave x number of blank spaces to prevent overlap

while True:
    try:
        scrollphat.scroll()
        time.sleep(0.1)
    except KeyboardInterrupt:
        scrollphat.clear()
        sys.exit(-1)
Example #56
0
        json_data = json.loads(res.text)

        # this response also contains rich geo-location data
        ip = json_data['ip']
    return ip

def get_ip(mode):
    return get_public_ip() if mode == "public" else get_internal_ip()
#    return mode == "public" ? get_public_ip() : get_internal_ip()
    
address_mode = "public"
if(len(sys.argv) == 2):
    address_mode = sys.argv[1]

ip = get_ip(address_mode)

print(address_mode + " IP Address: " +str(ip))

scrollphat.set_brightness(3)

while True:	
    try:
        scrollphat.clear()
        scrollphat.write_string("IP: " + str(ip) + "    ")
        for i in range(0, scrollphat.buffer_len() - 11):
            scrollphat.scroll()
            time.sleep(0.1)
    except KeyboardInterrupt:
        scrollphat.clear()
        sys.exit(-1)
import scrollphat as hat
import time

str = 'Merry Christmas   '
hat.set_brightness(2)
hat.write_string(str)

# for i in range(len(str) * 5):
#     hat.scroll()
#     time.sleep(0.150)

hat.graph([2, 4, 6, 8, 10, 8, 6, 4, 2, 0, 3])
hat.update()