Example #1
0
def test_init_7colour_setup(spidev, smbus2, GPIO):
    """Test initialisation and setup of 7-colour Inky.

    Verify our expectations for GPIO setup in order to catch regressions.

    """
    from inky.inky_uc8159 import Inky

    # TODO: _busy_wait should timeout after N seconds
    GPIO.input.return_value = GPIO.LOW

    inky = Inky()
    inky.setup()

    # Check GPIO setup
    GPIO.setwarnings.assert_called_with(False)
    GPIO.setmode.assert_called_with(GPIO.BCM)
    GPIO.setup.assert_has_calls([
        mock.call(inky.dc_pin, GPIO.OUT, initial=GPIO.LOW, pull_up_down=GPIO.PUD_OFF),
        mock.call(inky.reset_pin, GPIO.OUT, initial=GPIO.HIGH, pull_up_down=GPIO.PUD_OFF),
        mock.call(inky.busy_pin, GPIO.IN, pull_up_down=GPIO.PUD_OFF)
    ])

    # Check device will been reset
    GPIO.output.assert_has_calls([
        mock.call(inky.reset_pin, GPIO.LOW),
        mock.call(inky.reset_pin, GPIO.HIGH)
    ])

    # Check API will been opened
    spidev.SpiDev().open.assert_called_with(0, inky.cs_channel)
Example #2
0
def test_init_7colour_setup_no_gpio(spidev, smbus2):
    from inky.inky_uc8159 import Inky

    inky = Inky()

    with pytest.raises(ImportError):
        inky.setup()
Example #3
0
def clear_inky():
    inky = Inky()

    for _ in range(4):
        for y in range(inky.height - 1):
            for x in range(inky.width - 1):
                inky.set_pixel(x, y, CLEAN)

        inky.show()
        time.sleep(1.0)
Example #4
0
def test_init_7colour_setup_no_gpio(spidev, smbus2):
    """Test initialisation and setup of 7-colour Inky.

    Verify an error is raised when RPi.GPIO is not present.

    """
    from inky.inky_uc8159 import Inky

    inky = Inky()

    with pytest.raises(ImportError):
        inky.setup()
Example #5
0
def test_eeprom_7color_5_7_inch(spidev, smbus2_eeprom, PIL):
    """Test EEPROM for 7color 5.7" Inky"""
    from inky.inky_uc8159 import Inky
    from inky.eeprom import EPDType

    eeprom_data = EPDType(600, 448, 0, 0, 14).encode()

    smbus2_eeprom.SMBus(1).read_i2c_block_data.return_value = eeprom_data

    inky = Inky()

    assert inky.resolution == (600, 448)
Example #6
0
#!/usr/bin/env python3
import time

from inky.inky_uc8159 import Inky

inky = Inky()

colors = ['Black', 'White', 'Green', 'Blue', 'Red', 'Yellow', 'Orange']

for color in range(7):
    print("Color: {}".format(colors[color]))
    for y in range(inky.height):
        for x in range(inky.width):
            inky.set_pixel(x, y, color)
    inky.set_border(color)
    inky.show()
    time.sleep(5.0)
Example #7
0
deviceRef = db.reference("devices").child(serial)

deviceRef.update({
    "last-boot": datetime.now().isoformat(),
    "network-adapters": ips,
    "public-ip": wanip
})

settingsRef = deviceRef.child("settings")
settings = settingsRef.get()
print(settings)

if (settings == None):
    settings = {}

inky_display = Inky()

if ("wanted-time" not in settings):
    nowTmp = datetime.now().__add__(timedelta(hours=1))
    now = ceil_dt(nowTmp, timedelta(minutes=15))
    settings["wanted-time"] = now.isoformat()
    settingsRef.update(settings)

#setDisplayTimer(settings)

BUTTONS = [5, 6, 16, 24]
LABELS = ['A', 'B', 'C', 'D']
GPIO.setmode(GPIO.BCM)
GPIO.setup(BUTTONS, GPIO.IN, pull_up_down=GPIO.PUD_UP)

Example #8
0
 def __init__(self, saturation=0.5):
     self.inky = Inky()
     self.saturation = saturation
Example #9
0
import os
import json
from PIL import Image, ImageDraw, ImageFont
from inky.inky_uc8159 import Inky
from datetime import datetime as dt
from bots.orgbot import get_org_image
from bots.twitterbot import get_tweet_img
from bots.twitterbot import get_recent_care_tweet
from bots.pomodorobot import get_pomodoro_time
from bots.pomodorobot import get_pomodoro
from bots.calendarbot import get_next_event
from bots.calendarbot import get_event_img

# Inky display information
inky_display = Inky()  # Global because only one inky to pass around...

DESATURATED_PALETTE = (
    0,
    0,
    0,
    255,
    255,
    255,
    0,
    255,
    0,
    0,
    0,
    255,
    255,
    0,