예제 #1
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()
예제 #2
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)
예제 #3
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)
예제 #4
0
파일: boozer.py 프로젝트: dryicebomb/boozer
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()
예제 #5
0
def scroll_message_once():
    length = scrollphat.buffer_len()

    for i in range(length):
        try:
            scrollphat.scroll()
            time.sleep(0.1)
        except KeyboardInterrupt:
            scrollphat.clear()
            raise
예제 #6
0
    def scroll(self, string=TEST_STRING):

        self.show_str(string)

        length = scrollphat.buffer_len()

        for i in range(length):

            scrollphat.scroll()
            sleep(0.1)
예제 #7
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)
예제 #8
0
파일: main.py 프로젝트: recantha/scroller
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)
예제 #9
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)
예제 #10
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()
예제 #11
0
파일: scrolljob.py 프로젝트: ollej/piapi
 def run(self):
     length = scrollphat.buffer_len()
     if self.options['loop'] == True:
         counter = 0
         while True:
             self.scroll()
             counter += 1
             if counter % length == 0:
                 time.sleep(self.options['sleep'])
     else:
         for i in range(length):
             self.scroll()
         self.sleep()
예제 #12
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)
예제 #13
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)
예제 #14
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'))
예제 #15
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'))
예제 #16
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)
예제 #17
0
                speedkts = 1.944*gpsd.fix.speed

# display speed over ground on scroll pHAT fixed for speeds < 10 kts
# Speeds over 10 kts need to scroll the display. The initial offset of 10
# and extra 7 spaces in the string will allow a complete scroll.

                scrollphat.clear()
                kts = ("{0:0.1f}").format(speedkts)
                if (speedkts < 10.):
                    scrollphat.write_string(kts, 1)
                    scrollphat.update()
                    time.sleep(10)      # set to delta seconds between grabs
                else:
                    scrollphat.write_string(kts+"       ", 10)
                    len = scrollphat.buffer_len()
                    for i in range(len/2+1):
                        scrollphat.scroll()
                        time.sleep(0.3) #sets scrolling speed
                                        # no delay as scrolling takes the time
                track = gpsd.fix.track

# open in append mode and write data, then close files so a system
# crash won't prevent output

# but first correct time to right time zone

                lclhrs = int(utc[11:13])-tzfix
                if (lclhrs<0): lclhrs=lclhrs+24
                lcltm = str(lclhrs)+utc[13:19]
#!/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/text_to_scroll.txt'
             ).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)
예제 #19
0
def main(win):
    direction = "RIGHT"
    snakeX=[2, 1, 0]
    snakeY=[2, 2, 2]
    snakeLength = 3
    score = 0

    gameOver = False
    
    scrollphat.set_brightness(5)
    scrollphat.write_string("      PI SNAKE")
    length = scrollphat.buffer_len()

    for i in range(length):
        scrollphat.scroll()
        time.sleep(0.06)
            
    fruitX = random.randint(0,10)
    fruitY = random.randint(0,4)

    fruitBlink = True

    win.nodelay(True)
    key=""
    while 1:
        if gameOver == False:

            # move snake head forward in the direction its travelling
            if direction == "RIGHT":
                if snakeX[0] < 10:
                    snakeX[0] = snakeX[0] + 1
            if direction == "LEFT":
                if snakeX[0] > 0:
                    snakeX[0] = snakeX[0] - 1
            if direction == "UP":
                if snakeY[0] > 0:
                    snakeY[0] = snakeY[0]- 1
            if direction == "DOWN":
                if snakeY[0] < 4:
                    snakeY[0] = snakeY[0] + 1
                    
            # check if the new head position is illegal
            for i in range(1, snakeLength):
                if snakeX[i] == snakeX[0] and snakeY[i] == snakeY[0]:
                    gameOver = True
                    
            # check if the new head position is at a fruit
            if snakeX[0] == fruitX and snakeY[0] == fruitY:
                snakeLength = snakeLength + 1
                score = score + 1
                snakeX.append(fruitX)
                snakeY.append(fruitY)
                fruitX = random.randint(0,10)
                fruitY = random.randint(0,4)

            time.sleep(0.15)
            scrollphat.clear_buffer()

            # shift all the snake parts forward
            for i in range(1, snakeLength):
                snakeX[snakeLength - i] = snakeX[snakeLength - i - 1]
                snakeY[snakeLength - i] = snakeY[snakeLength - i - 1]

            # draw the snake
            for i in range(0, snakeLength):                                                  
                scrollphat.set_pixel(snakeX[i],snakeY[i],True)

            # blink the fruit
            if fruitBlink:
                scrollphat.set_pixel(fruitX,fruitY,True)
                fruitBlink = False
            else:
                scrollphat.set_pixel(fruitX,fruitY,False)
                fruitBlink = True
                
            scrollphat.update()
        else:
            # game over
            gameOverText = "GAME OVER - SCORE: " + str(score) + " PRESS SPACE TO RESTART"
            time.sleep(0.7)
            scrollphat.clear_buffer()
            scrollphat.write_string(gameOverText,len(gameOverText))
            win.clear()
            win.addstr(gameOverText)
            while True:
                try:
                    scrollphat.scroll()
                    time.sleep(0.07)
                    key = win.getkey()
                    if str(key) == " ":
                        break
                except Exception as e:
                    # No input
                    pass
            direction = "RIGHT"
            snakeX=[2, 1, 0]
            snakeY=[2, 2, 2]
            snakeLength = 3
            score = 0
            gameOver = False

        try:
           key = win.getkey()
           win.clear()
           win.addstr("PI SNAKE - SCORE: ")           
           win.addstr(str(score))
           
           if str(key) == "KEY_RIGHT":
               direction = "RIGHT"
           if str(key) == "KEY_LEFT":
               direction = "LEFT"
           if str(key) == "KEY_UP":
               direction = "UP"
           if str(key) == "KEY_DOWN":
               direction = "DOWN"
               
           if key == os.linesep:
              break
        except Exception as e:
           # No input
           pass
#!/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)

예제 #21
0
def show_text(text: str, speed: float = 20):
    scrollphat.write_string(text, 11)
    for _ in range(scrollphat.buffer_len()):
        scrollphat.scroll()
        time.sleep(1 / speed)
    scrollphat.clear()
예제 #22
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.py \"message\" \npress CTRL-C to exit\n"
    )
    sys.exit(0)

scrollphat.write_string(sys.argv[1], 11)
length = scrollphat.buffer_len()

for i in range(length):
    try:
        scrollphat.scroll()
        time.sleep(0.1)
    except KeyboardInterrupt:
        scrollphat.clear()
        sys.exit(-1)
예제 #23
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)
예제 #24
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)
예제 #25
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.py \"message\" \npress CTRL-C to exit\n")
    sys.exit(0)

scrollphat.write_string(sys.argv[1], 11)
length = scrollphat.buffer_len()

for i in range(length):
    try:
        scrollphat.scroll()
        time.sleep(0.1)
    except KeyboardInterrupt:
        scrollphat.clear()
        sys.exit(-1)