How to use inky - 10 common examples

To help you get started, we’ve selected a few inky examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github evilsocket / pwnagotchi / sdcard / rootfs / root / pwnagotchi / scripts / main.py View on Github external
parser.add_argument('--manual', dest="do_manual", action="store_true", default=False, help="Manual mode.")
parser.add_argument('--clear', dest="do_clear", action="store_true", default=False,
                    help="Clear the ePaper display and exit.")

args = parser.parse_args()

if args.do_clear:
    print("clearing the display ...")
    with open(args.config, 'rt') as fp:
        config = yaml.safe_load(fp)
        cleardisplay = config['ui']['display']['type']
        if cleardisplay in ('inkyphat', 'inky'):
            print("inky display")
            from inky import InkyPHAT

            epd = InkyPHAT(config['ui']['display']['color'])
            epd.set_border(InkyPHAT.BLACK)
            self._render_cb = self._inky_render
        elif cleardisplay in ('papirus', 'papi'):
            print("papirus display")
            from pwnagotchi.ui.papirus.epd import EPD

            os.environ['EPD_SIZE'] = '2.0'
            epd = EPD()
            epd.clear()
        elif cleardisplay in ('waveshare_1', 'ws_1', 'waveshare1', 'ws1'):
            print("waveshare v1 display")
            from pwnagotchi.ui.waveshare.v1.epd2in13 import EPD

            epd = EPD()
            epd.init(epd.lut_full_update)
            epd.Clear(0xFF)
github hxlnt / yesme / yesme2.py View on Github external
for msg in recentmsgs:
    if msg.sid[:1] == "M" and msg.to == TWILIO_PHONE_NUMBER:
        message = client.messages(msg.sid).fetch()
        print(message)
        break
allimgs = client.messages(message.sid).media.list()
for img in allimgs:
    imageuri = (TWILIO_BASE_URI + str(img.uri)).strip(".json'").strip("u'")
    print(imageuri)
try:
    response = requests.get(imageuri, stream=True).raw
except requests.exceptions.RequestException as e:  
    sys.exit(1)
    
# Create inkyPHAT image
inky_display = InkyPHAT("yellow")

# Resize and crop incoming image
originalimage = Image.open(response)
originalimage = originalimage.rotate(90, expand=1)
originalimageW = float(originalimage.size[0])
originalimageH = float(originalimage.size[1])
imgRatio = originalimageW/originalimageH
print(imgRatio)
if (imgRatio >= inky_display.WIDTH/inky_display.HEIGHT):
    originalimage = originalimage.resize((inky_display.HEIGHT, int((1/imgRatio)*inky_display.HEIGHT)), resample=Image.BILINEAR) 
    originalimage = originalimage.crop((0, 0, inky_display.WIDTH, inky_display.HEIGHT))
else:
    originalimage = originalimage.resize((int(imgRatio*inky_display.HEIGHT), inky_display.HEIGHT), resample=Image.BILINEAR)
    originalimage = originalimage.crop(((int((originalimage.size[0]-inky_display.WIDTH)/2), 0, int((originalimage.size[0]-inky_display.WIDTH)/2)+inky_display.WIDTH, inky_display.HEIGHT)))

# Downsample original image
github pimoroni / inky / examples / logo-what.py View on Github external
print("""Inky wHAT: Logo

Displays the Inky wHAT logo.

""")

if len(sys.argv) < 2:
    print("""Usage: {} 
       Valid colours: red, yellow, black
""".format(sys.argv[0]))
    sys.exit(0)

colour = sys.argv[1].lower()

inkywhat = InkyWHAT(colour)

inkywhat.set_border(inkywhat.BLACK)

if colour == 'black':
    img = Image.open("InkyPhat-212x104-bw.png")
else:
    img = Image.open("InkyPhat-212x104.png")

inkywhat.set_image(img)

inkywhat.show()
github evilsocket / pwnagotchi / sdcard / rootfs / root / pwnagotchi / scripts / main.py View on Github external
parser.add_argument('--clear', dest="do_clear", action="store_true", default=False,
                    help="Clear the ePaper display and exit.")

args = parser.parse_args()

if args.do_clear:
    print("clearing the display ...")
    with open(args.config, 'rt') as fp:
        config = yaml.safe_load(fp)
        cleardisplay = config['ui']['display']['type']
        if cleardisplay in ('inkyphat', 'inky'):
            print("inky display")
            from inky import InkyPHAT

            epd = InkyPHAT(config['ui']['display']['color'])
            epd.set_border(InkyPHAT.BLACK)
            self._render_cb = self._inky_render
        elif cleardisplay in ('papirus', 'papi'):
            print("papirus display")
            from pwnagotchi.ui.papirus.epd import EPD

            os.environ['EPD_SIZE'] = '2.0'
            epd = EPD()
            epd.clear()
        elif cleardisplay in ('waveshare_1', 'ws_1', 'waveshare1', 'ws1'):
            print("waveshare v1 display")
            from pwnagotchi.ui.waveshare.v1.epd2in13 import EPD

            epd = EPD()
            epd.init(epd.lut_full_update)
            epd.Clear(0xFF)
        elif cleardisplay in ('waveshare_2', 'ws_2', 'waveshare2', 'ws2'):
github evilsocket / pwnagotchi / pwnagotchi / ui / hw / inky.py View on Github external
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)
        else:
            from inky import InkyPHAT
            self._display = InkyPHAT(self.config['color'])
            self._display.set_border(InkyPHAT.BLACK)
github pimoroni / inky / examples / clean.py View on Github external
""")

# Command line arguments to set display type and colour, and number of cycles to run

parser = argparse.ArgumentParser()
parser.add_argument('--type', '-t', type=str, required=True, choices=["what", "phat"], help="type of display")
parser.add_argument('--colour', '-c', type=str, required=True, choices=["red", "black", "yellow"], help="ePaper display colour")
parser.add_argument('--number', '-n', type=int, required=False, help="number of cycles")
args = parser.parse_args()

colour = args.colour

# Set up the correct display and scaling factors

if args.type == "phat":
    inky_display = InkyPHAT(colour)
elif args.type == "what":
    inky_display = InkyWHAT(colour)

# The number of red / black / white refreshes to run

if args.number:
    cycles = args.number
else:
    cycles = 3

colours = (inky_display.RED, inky_display.BLACK, inky_display.WHITE)
colour_names = (colour, "black", "white")

# Create a new canvas to draw on

img = Image.new("P", (inky_display.WIDTH, inky_display.HEIGHT))
github evilsocket / pwnagotchi / pwnagotchi / ui / hw / inky.py View on Github external
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)
        else:
            from inky import InkyPHAT
            self._display = InkyPHAT(self.config['color'])
            self._display.set_border(InkyPHAT.BLACK)
github hxlnt / yesme / yesme.py View on Github external
from dotenv import load_dotenv
import math
import os
from PIL import Image, ImageOps
import requests
import sys
from twilio.rest import Client
from inky import InkyPHAT

inky_display = InkyPHAT('yellow')
BASEDIR = os.path.abspath(os.path.dirname(__file__))
load_dotenv(os.path.join(BASEDIR, '.env'))

account_sid = os.getenv('TWILIO_ACCOUNT_SID')
auth_token = os.getenv('TWILIO_AUTH_TOKEN')
client = Client(account_sid, auth_token)
TWILIO_BASE_URI = "https://api.twilio.com"
INKY_HEIGHT = 212.00
INKY_WIDTH = 104.00
INKY_RATIO = INKY_HEIGHT/INKY_WIDTH

def recolor(img):
    for y in range(img.size[1]):
        for x in range(img.size[0]):
            pixelMap = img.load()
            if pixelMap[x,y] == (128,128,128) or pixelMap[x,y] == (255,255,255):
github neauoire / inky-hole / main.py View on Github external
try:
  f = urllib2.urlopen('http://pi.hole/admin/api.php')
  json_string = f.read()
  parsed_json = json.loads(json_string)
  adsblocked = parsed_json['ads_blocked_today']
  ratioblocked = parsed_json['ads_percentage_today']
  f.close()
except:
  queries = '?'
  adsblocked = '?'
  ratio = '?'

font = ImageFont.truetype(FredokaOne, 32)

inky_display = InkyPHAT("red")
inky_display.set_border(inky_display.WHITE)

draw.text((20,20), str(adsblocked), inky_display.BLACK, font)
draw.text((20,50), str("%.1f" % round(ratioblocked,2)) + "%", inky_display.BLACK, font)

inky_display.set_image(img)

inky_display.show()
github pimoroni / inky / examples / phat / weather-phat.py View on Github external
""")

# Get the current path

PATH = os.path.dirname(__file__)

# Command line arguments to set display colour

parser = argparse.ArgumentParser()
parser.add_argument('--colour', '-c', type=str, required=True, choices=["red", "black", "yellow"], help="ePaper display colour")
args = parser.parse_args()

# Set up the display

colour = args.colour
inky_display = InkyPHAT(colour)
inky_display.set_border(inky_display.BLACK)

# Details to customise your weather display

CITY = "Sheffield"
COUNTRYCODE = "GB"
WARNING_TEMP = 25.0


# Convert a city name and country code to latitude and longitude
def get_coords(address):
    g = geocoder.arcgis(address)
    coords = g.latlng
    return coords

inky

Inky pHAT Driver

MIT
Latest version published 2 months ago

Package Health Score

72 / 100
Full package analysis

Similar packages