Example #1
0
    def __init__(self, bot=None):
        self.inky_display = auto(ask_user=True, verbose=True)
        self.resolution = (self.inky_display.WIDTH, self.inky_display.HEIGHT)
        self.img = Image.new("L", self.resolution)
        self.draw = ImageDraw.Draw(self.img)

        self.bot = bot
        self.touchmodule = None
        self.cmds = {}

        self.color = self.inky_display.BLACK

        if bot is not None:
            self.fetch_cmds(bot)
            self.update_display()
Example #2
0
    def __init__(self):
        global inky_available
        if inky_available:
            try:
                self._display = auto()
            except Exception:
                # traceback.print_exc()
                inky_available = False

        # add some attributes to simulated object
        if not inky_available:
            self._display = Options()
            self._display.width = 600
            self._display.height = 448
            self._display.WHITE = (255, 255, 255)
            self._display.BLACK = (0, 0, 0)
            self._display.RED = (255, 0, 0)
            self._display.YELLOW = (255, 255, 0)
            self._display.GREEN = (0, 128, 0)
            self._display.BLUE = (0, 0, 255)
            self._display.ORANGE = (255, 165, 0)

        # application objects
        if inky_available:
            self._image = Image.new(
                "P", (self._display.width, self._display.height),
                color=self._display.WHITE)
        else:
            self._image = Image.new(
                "RGB", (self._display.width, self._display.height),
                color=self._display.WHITE)
        self._canvas = ImageDraw.Draw(self._image)

        # font and text
        self._font = ImageFont.truetype(
            "/usr/share/fonts/truetype/dejavu/DejaVuSans-Oblique.ttf", 50)
        self._text = "\u03C0"
        self._text_size = self._canvas.textsize(self._text,
                                                self._font,
                                                spacing=0)

        # colors
        self._colors = [
            self._display.WHITE, self._display.BLACK, self._display.RED,
            self._display.YELLOW, self._display.GREEN, self._display.BLUE,
            self._display.ORANGE
        ]
Example #3
0
 def __init__(self):
     try:
         self.inkyphat = auto(ask_user=False, verbose=True)
     except TypeError:
         raise TypeError("You need to update the Inky library to >= v1.1.0")
     self.inkyphat.h_flip = True
     self.inkyphat.v_flip = True
     self.width = 250
     self.height = 122
     self.image = Image.new("P", (self.width, self.height), 0)
     self.image.putpalette([
         0,
         0,
         0,
         255,
         255,
         255,
     ])
     self.draw = ImageDraw.Draw(self.image)
     self.initFonts()
Example #4
0
    def initialize(self):
        logging.info("initializing inky display")

        if self.config['color'] == 'fastAndFurious':
            logging.info("Initializing Inky in 2-color FAST MODE")
            logging.info(
                "THIS MAY BE POTENTIALLY DANGEROUS. NO WARRANTY IS PROVIDED")
            logging.info("USE THIS DISPLAY IN THIS MODE AT YOUR OWN RISK")

            from pwnagotchi.ui.hw.libs.inkyphat.inkyphatfast import InkyPHATFast
            self._display = InkyPHATFast('black')
            self._display.set_border(InkyPHATFast.BLACK)
        elif self.config['color'] == 'auto':
            from inky.auto import auto
            self._display = auto()
            self._display.set_border(self._display.BLACK)
            self._layout['width'] = self._display.WIDTH
            self._layout['height'] = self._display.HEIGHT
        else:
            from inky import InkyPHAT
            self._display = InkyPHAT(self.config['color'])
            self._display.set_border(InkyPHAT.BLACK)
Example #5
0
 def display(self, image: PillowImage):
     board = auto()
     board.set_image(image.invert().render())
     board.show()
Example #6
0
import argparse

from PIL import Image, ImageFont, ImageDraw
from font_hanken_grotesk import HankenGroteskBold, HankenGroteskMedium
from font_intuitive import Intuitive
from inky.auto import auto

print("""Inky pHAT/wHAT: Hello... my name is:

Use Inky pHAT/wHAT as a personalised name badge!

""")

try:
    inky_display = auto(ask_user=True, verbose=True)
except TypeError:
    raise TypeError("You need to update the Inky library to >= v1.1.0")

parser = argparse.ArgumentParser()
parser.add_argument('--name', '-n', type=str, required=True, help="Your name")
args, _ = parser.parse_known_args()

# inky_display.set_rotation(180)
try:
    inky_display.set_border(inky_display.RED)
except NotImplementedError:
    pass

# Figure out scaling for display size
Example #7
0
from dotenv import load_dotenv
import fetch_calendar
import fetch_formatted_text
from inky.auto import auto
import os
import time

# loads environment variables froma .gitignore'd .env file
load_dotenv()
# RC calendar token from .env
token = os.getenv('ICS_TOKEN')

inky_display = auto()

inked_name = ''
inked_location = ''
inked_start = ''
inked_end = ''

while True:
    event = fetch_calendar.getNextEvent(token)

    if not event:
        print("No more events today")
    else:
        if event['name'] == inked_name and event[
                'location'] == inked_location and event[
                    'start'] == inked_start and event['end'] == inked_end:
            print("We've already drawn this one to the display!")
        else:
            inked_name = event['name']
Example #8
0
#!/usr/bin/env python3
import time

from inky.auto import auto

inky = auto(ask_user=True, verbose=True)

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 #9
0
# -*- coding: utf-8 -*-
from __future__ import absolute_import, unicode_literals

import octoprint.plugin
from inky.auto import auto
from PIL import Image

inky = auto()
inky.setup()


class OctoInkyPlugin(octoprint.plugin.StartupPlugin):
    def on_after_startup(self):
        startup_image = Image.open(
            os.path.join(self.get_plugin_data_folder(),
                         "static/img/phat/startup.png"))
        inky.set_image(startup_image)
        inky.show(busy_wait=False)
        self._logger.info("Inky PHAT should be initialised!")


#TODO
#test this works!
#create B&W, B&W&R, B&W&R image for startup
#start handling states and creating images using PIL
Example #10
0
from inky.auto import auto
board = auto()

board.colour
board.resolution
Example #11
0
def imp():
    """Return real or fake impression depending on our platform."""
    if "arm" in platform.platform():
        return auto()  # nocov
    else:
        return FakeImpression()