示例#1
0
def display_animated_diagonals():
    (width, height) = scrollphathd.get_shape()
    frame = -1
    started_time = time.time()
    while time.time() - started_time < 15:
        scrollphathd.clear()
        frame = frame + 1 % width
        y_frame = frame
        for x in range(width):
            scrollphathd.set_pixel(x, y_frame, brightness=0.5)
            y_frame = (y_frame + 1) % height
        scrollphathd.show()
        yield
示例#2
0
def display_animated_circle():
    scrollphathd.clear()
    frame = -1
    (width, height) = scrollphathd.get_shape()
    center_x = math.floor(width / 2)
    center_y = math.floor(height / 2)
    started_time = time.time()
    while time.time() - started_time < 15:
        scrollphathd.clear()
        frame = (frame + 1) % 3
        for i in range(5):
            draw_circle(center_x, center_y, (frame + 1) + i * 3)
        scrollphathd.show()
        yield
示例#3
0
def display_animated_cosinus():
    (width, height) = scrollphathd.get_shape()
    frame = -1
    started_time = time.time()
    while time.time() - started_time < 15:
        scrollphathd.clear()
        frame = frame + 1
        for x in range(width):
            x_real = ((x + frame) / width) * 4 * math.pi
            scrollphathd.set_pixel(
                x,
                math.floor(math.cos(x_real) * (height // 2) + height // 2),
                brightness=0.5)
        scrollphathd.show()
        yield
示例#4
0
def display_animated_bars():
    (width, height) = scrollphathd.get_shape()
    frame = -1
    started_time = time.time()
    while time.time() - started_time < 15:
        scrollphathd.clear()
        frame = frame + 1 % width
        for x in range(width // 4):
            for strip in range(2):
                for y in range(height):
                    scrollphathd.set_pixel(
                        ((strip + frame) + x * width // 4) % width,
                        y,
                        brightness=0.5)
        scrollphathd.show()
        yield
示例#5
0
def draw_contrib_data(contrib_data):
    (width, height) = sphd.get_shape()
    first_day_index = len(contrib_data) - width
    weeks_to_draw = contrib_data[first_day_index:]
    brightness_scale = get_brightness_scale(weeks_to_draw)

    for x in range(width):
        for y in range(7):
            week_to_draw = weeks_to_draw[x]
            week = week_to_draw + ([0] * (7 - len(week_to_draw)))
            contrib_count = week[y]
            brightness = round(brightness_scale(contrib_count),
                               2) if contrib_count != 0 else 0
            sphd.set_pixel(x, y, brightness)

    sphd.show()
    def run(self):
        if self._is_enabled is False:
            return
        
        next_interval = self._interval

        if self._currentIndexCountdown < 0:

            if len(self._items) > 0:
                upcoming = self._items.pop()
                if ALL_UPPERCASE:
                    upcoming = upcoming.upper()

                scrollphathd.clear()
                scrollphathd.write_string(upcoming, x=PREFIX_OFFSET, y=0, font=None, letter_spacing=1, brightness=0.2, monospaced=False, fill_background=False)
                scrollphathd.show()

                shape = scrollphathd.get_shape()
                buffer_shape = scrollphathd.get_buffer_shape()
                self._overflow_length = buffer_shape[0] - shape[0]
                logging.info("Autoscroll.run: Decreasing index countdown: {} ({} - {})".format(str(self._overflow_length), shape[0], buffer_shape[0]))
                self._currentIndexCountdown = self._overflow_length

                next_interval = INITIAL_DELAY  # inital delay
            else:
                logging.info("Autoscroll.run: No items to pop..")
                # self.demo()
                
        else:
            logging.info("Autoscroll.run: Just scrolling..")

            # Scroll the buffer content
            scrollphathd.scroll(x=SCROLL_PAGE_SIZE)
            # Show the buffer
            scrollphathd.show()

            self._currentIndexCountdown -= SCROLL_PAGE_SIZE

        # Start a timer
        threading.Timer(next_interval, self.run).start()
示例#7
0
def display_size():
    return json.dumps(scrollphathd.get_shape()), {
        'Content-Type': 'application/json'
    }
示例#8
0
import requests
import scrollphathd
import time

base_url = 'https://pogoleam.orangeninja.com/api/1.0/'
begin_end_pause = 0.5
scroll_delay = 0.01

# Load static data from server
locationData = requests.get(url=base_url + 'locations')
locationNames = {}
for location in locationData.json():
    locationNames[location['_id']] = location['name']
pokemon_names = requests.get(url=base_url + 'pokemon').json()

displ_width = scrollphathd.get_shape()[0]


def display_text(text):
    print text
    t_len = scrollphathd.write_string(text, brightness=0.05)
    scrollphathd.show()
    time.sleep(begin_end_pause)
    for x in range(t_len - displ_width):
        scrollphathd.show()
        scrollphathd.scroll()
        time.sleep(scroll_delay)
    time.sleep(begin_end_pause)
    scrollphathd.clear()
    scrollphathd.show()
示例#9
0
import random
import time
import scrollphathd as scr
from scrollphathd.fonts import font5x7
import buttonshim as btn
import signal
import os

delay = 0.001
delay3 = delay * 100
bright0 = 0.0
bright = 0.3
bright1 = bright
bright2 = bright * 2
bright3 = bright * 3
[width, height] = scr.get_shape()

c = 0

shp_y = 3
shp_y2 = 3
blt_x = 0
blt_x2 = 0
blt_y = 0
blt_y2 = 0
trg_x = 0
trg_x2 = 0
trg_y = 0
trg_y2 = 0

scr.set_brightness(bright)
示例#10
0
if __name__ == '__main__':

    # Set up command line argument parsing
    parser = setup_parser()
    args = parser.parse_args()
    arguments = vars(args)

    scrollphathd.set_clear_on_exit()
    scrollphathd.set_brightness(1)

    # Board rotation
    scrollphathd.rotate(degrees=180)
    # scrollphathd.rotate(arguments.get('rotate'))

    width = scrollphathd.get_shape()[0]
    height = scrollphathd.get_shape()[1]

    presets = {
        "thunderstorm": {
            "amount": .7,
            "brightness": .15,
            "delay": 0,
            "fade": .05,
            "intensity": 1,
            "lightning": .01,
            "safe": .3
        },
        "rain": {
            "amount": .7,
            "brightness": .15,