def __init__(self):

        self.name = 'ScrollPhat'
        log_str('init {}'.format(self.__module__))

        self.rotation = SCROLL_ROTATION

        scrollphat.set_rotate(self.rotation)

        self.hour = int(datetime.now().strftime("%H"))

        if 9 <= self.hour <= 17:
            self.brightness = HIGH.scrollphat
            self.brightness_setting = 'day'

        elif 18 <= self.hour <= 23 or 0 <= self.hour <= 8:
            self.brightness = LOW.scrollphat
            self.brightness_setting = 'night'

        else:
            self.brightness = self.brightness

        log_str('scrollphat brightness: {} - {}: {}'.format(
            self.brightness, self.brightness_setting, self.hour))
        scrollphat.set_brightness(self.brightness)
Exemple #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)
#!/usr/bin/env python

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:
#   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()
Exemple #4
0

def flash():
    scrollphat.set_pixels(lambda x, y: 1, True)
    time.sleep(0.1)
    scrollphat.clear()
    time.sleep(0.1)


total_time = (minutes * 60)
popov = total_time / 5.0

start = time.time()

scrollphat.clear()
scrollphat.set_rotate(True)
scrollphat.set_brightness(1)

blinkstate = False
elapsed = 0

while total_time > elapsed:
    try:
        elapsed = time.time() - start
        # print elapsed

        blinkstate = not blinkstate
        blinker_line = (int)(elapsed / popov)
        # print blinker_line
        scrollphat.clear_buffer()
#!/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)
#!/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)
        default=4)
    args = parser.parse_args()
    temp = get_cpu_temperature()
    client = docker.from_env()
    nb_containers = len(client.containers.list())
    if args.verbose:
        print('monitor.py - program wrote by FX')
        print('Last modification: 02-may-2020')
        print('Verbosity mode turned on')
        print('Press Ctrl+C to exit!')
        print('Brightness: ' + str(args.brightness))
        print('CPU temperature: ' + str(temp))
        print('Rotate: ' + str(args.rotate))
        print('Interval: ' + str(args.interval))
        print('Number of docker containers running: ' + str(nb_containers))
    scrollphat.set_rotate(args.rotate)
    scrollphat.set_brightness(args.brightness)

    prev_temp = 0
    prev_load = 0
    prev_nb_containers = 0
    while True:
        try:
            # Display the temperature
            temp = get_cpu_temperature()
            if (temp > prev_temp):
                for x in range(int(temp / 80 * 11)):
                    scrollphat.set_pixel(x, args.temperature, 1)
            elif (temp < prev_temp):
                for x in range(int(temp / 80 * 11), int(prev_temp / 80 * 11)):
                    scrollphat.set_pixel(x, args.temperature, 0)
#!/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 forecastio as f
import scrollphat as s
import time as t
from apikey import api_key

lat = 53.768983
lng = -2.764714

s.set_brightness(2)
s.set_rotate(True)
forecast = f.load_forecast(api_key, lat, lng, units='si')
current_forecast = forecast.currently()
start_time = t.time()

while True:
    try:
        temp = str(int(round(current_forecast.d['apparentTemperature'])))
        temp_str = temp + '\'C '
        summary = current_forecast.d['summary'].upper()
        hour = t.strftime('%H')
        minute = t.strftime('%M')

        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
    def __init__(self, game):

        self.brightness = 5

        scrollphat.set_brightness(self.brightness)
        scrollphat.set_rotate(True)
#!/usr/bin/env python

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()
Exemple #12
0
#!/usr/bin/env python

import scrollphat
import time

scrollphat.set_brightness(10)
scrollphat.set_rotate(scrollphat.ROTATE_180)
scrollphat.write_string("My name is Alexa aka Cannibalistic Avocado. ")

while True:
    scrollphat.scroll()
    time.sleep(.1)

Exemple #13
0
import datetime
import sys
import time
import scrollphat

scrollphat.set_brightness(2)
scrollphat.set_rotate(
    True
)  #to sit the zero flat with the usb cable on the top you have to set this as true to rotate the message

while True:
    now = datetime.datetime.now()
    print(now.strftime("%Y-%m-%d %H:%M:&S"))
    birthday = datetime.datetime(
        YYYY, M, D, 0, 0
    )  #replace this with the day you want to use - time not important for this application
    print(birthday.strftime("%Y-%m-%d %H:%M:&S"))
    delta = birthday - now
    print(delta.days)
    #cause we're doing sleeps need +1
    if delta.days + 1 < 1:
        message = "Happy birthday Phina!!!   "
        scroll_delta = 1
    else:
        message = str(delta.days + 1)
        scroll_delta = 0  #because days is a short message don't need to scroll it
    print(message)
    scrollphat.write_string(message)
    length = scrollphat.buffer_len()
    for i in range(length):
        try:
Exemple #14
0
 def set_rotate(self):
     if self.options['rotate'] is not None:
         scrollphat.set_rotate(self.options['rotate'])