diff --git a/clear_display.py b/clear_display.py new file mode 100644 index 00000000..be726f3f --- /dev/null +++ b/clear_display.py @@ -0,0 +1,12 @@ +""" +Clears the display of any content. +""" +from inkycal import Inkycal + +print("loading Inkycal and display driver...") +inky = Inkycal(render=True) # Initialise Inkycal +print("clearing display...") +inky.calibrate(cycles=1) # Calibrate the display +print("clear complete...") + +print("finished!") diff --git a/docs/inkycal.html b/docs/inkycal.html index 466ee2e5..9fd09ef5 100644 --- a/docs/inkycal.html +++ b/docs/inkycal.html @@ -148,7 +148,7 @@
-calibrate()
+calibrate(cycles=3)

Calibrate the E-Paper display

Uses the Display class to calibrate the display with the default of 3 cycles. After a refresh cycle, a new image is generated and shown.

@@ -466,7 +466,7 @@
-load(path)
+load(path: str) None

loads an image from a URL or filepath.

Args:
    diff --git a/docs/searchindex.js b/docs/searchindex.js index 4fe38877..c1e60763 100644 --- a/docs/searchindex.js +++ b/docs/searchindex.js @@ -1 +1 @@ -Search.setIndex({"docnames": ["about", "dev_doc", "index", "inkycal", "quickstart"], "filenames": ["about.md", "dev_doc.md", "index.rst", "inkycal.rst", "quickstart.md"], "titles": ["About Inkycal", "Developer documentation", "Inkycal documentation", "Inkycal", "Quickstart"], "terms": {"i": [0, 1, 3], "python3": [0, 3], "softwar": 0, "select": [0, 3], "e": [0, 3, 4], "paper": [0, 3], "displai": [0, 2], "It": 0, "": [0, 3], "open": 0, "sourc": 0, "non": [0, 3], "commerci": 0, "fulli": 0, "modular": 0, "user": 0, "friendli": 0, "even": 0, "run": [0, 3], "well": 0, "raspberri": [0, 4], "pi": [0, 3, 4], "zero": 0, "ha": [0, 3], "web": [0, 4], "ui": [0, 4], "which": [0, 3], "take": [0, 3], "care": [0, 3], "ad": 0, "your": [0, 3, 4], "detail": 0, "No": 0, "more": [0, 3, 4], "edit": 0, "file": [0, 2, 3], "yai": 0, "parti": [0, 1], "_": 0, "face": 0, "The": [0, 3], "main": [0, 3], "idea": 0, "behind": 0, "wa": [0, 3], "creat": [0, 1, 2, 3], "dashboard": 0, "blend": 0, "its": 0, "environ": 0, "show": [0, 3], "you": 0, "all": [0, 3], "inform": 0, "without": [0, 3], "have": [0, 3], "look": [0, 3], "them": [0, 3], "up": 0, "sever": 0, "built": 0, "modul": [0, 1, 2, 3], "help": 0, "stai": 0, "organis": 0, "provid": 0, "weather": 0, "forecast": 0, "full": [0, 3], "week": 0, "next": [0, 3], "few": 0, "hour": 0, "get": [0, 3], "latest": [0, 3], "new": [0, 3], "from": [0, 3], "atom": 0, "rss": 0, "feed": 0, "icalendar": [0, 2, 3], "agenda": 0, "mai": 0, "synchronis": 0, "phone": 0, "monthli": 0, "calendar": 0, "also": 0, "event": [0, 3], "sync": 0, "googl": [0, 3], "etc": 0, "fetch": 0, "some": 0, "joke": 0, "form": 0, "smile": 0, "what": 0, "compat": 0, "third": [0, 1], "someth": [0, 3], "miss": 0, "can": [0, 3], "write": [0, 2, 3], "own": 0, "share": 0, "commun": 0, "discord": 0, "case": 0, "re": 0, "pinch": 0, "set": [0, 2, 3], "noob": 0, "welcom": 0, "too": 0, "cours": 0, "develop": [0, 2], "mainli": [0, 1], "aceisac": 0, "univers": 0, "student": 0, "other": [0, 3], "free": 0, "time": [0, 3], "mean": 0, "we": 0, "work": [0, 3], "noth": 0, "doesn": [0, 3], "t": [0, 3], "don": 0, "need": 0, "anyth": 0, "invest": 0, "larg": 0, "amount": 0, "effort": 0, "coffe": 0, "pleas": [0, 4], "support": [0, 3], "via": [0, 4], "donat": 0, "u": 0, "keep": 0, "thi": [0, 1, 3], "project": [0, 3], "aliv": 0, "thank": 0, "who": 1, "wish": 1, "custom": 2, "function": 2, "auto_fonts": [2, 3], "draw_bord": [2, 3], "get_font": [2, 3], "get_system_tz": [2, 3], "internet_avail": [2, 3], "text_wrap": [2, 3], "helper": 2, "class": 2, "inkyimag": [2, 3], "about": 2, "quickstart": 2, "instal": 2, "index": 2, "search": [2, 3], "page": 2, "copyright": 3, "aceinnolab": [3, 4], "settings_path": 3, "str": 3, "none": 3, "render": 3, "bool": 3, "true": 3, "test": 3, "program": 3, "arg": 3, "path": 3, "json": 3, "given": 3, "tri": 3, "boot": 3, "folder": [3, 4], "fals": 3, "imag": 3, "epap": 3, "attribut": 3, "optim": 3, "reduc": 3, "number": 3, "colour": 3, "gener": [3, 4], "improv": 3, "9": 3, "7": 3, "calibr": 3, "us": 3, "default": 3, "3": 3, "cycl": 3, "after": 3, "refresh": 3, "shown": 3, "countdown": 3, "interval_min": 3, "return": 3, "remain": 3, "second": 3, "until": 3, "updat": 3, "async": 3, "nonstop": 3, "mode": 3, "an": 3, "infin": 3, "loop": 3, "assembl": 3, "one": 3, "sleep": 3, "schedul": 3, "issu": 3, "attempt": 3, "import": 3, "name": 3, "load": 3, "config": 3, "each": 3, "initi": 3, "check": 3, "could": 3, "correctli": 3, "found": 3, "instanc": 3, "driver": 3, "model": 3, "allow": 3, "epaper_model": 3, "eas": 3, "font": 3, "max_height": 3, "scale": 3, "80": 3, "height": 3, "fill": 3, "A": 3, "pil": 3, "object": 3, "integ": 3, "repres": 3, "adjust": 3, "should": 3, "modifi": 3, "xy": 3, "size": 3, "radiu": 3, "5": 3, "thick": 3, "1": 3, "shrinkag": 3, "0": 3, "draw": 3, "border": 3, "coordin": 3, "drawn": 3, "usual": 3, "im_black": 3, "im_colour": 3, "tupl": 3, "top": 3, "left": 3, "corner": 3, "g": 3, "32": 3, "100": 3, "where": 3, "x": 3, "co": 3, "ordin": 3, "y": 3, "width": 3, "plain": 3, "rectangl": 3, "round": 3, "pixel": 3, "contain": 3, "decim": 3, "present": 3, "percentag": 3, "shrink": 3, "width_shrink_percentag": 3, "height_shrink_percentag": 3, "2": 3, "10": 3, "20": 3, "print": 3, "avail": 3, "output": 3, "To": 3, "access": 3, "fontfil": 3, "dictionari": 3, "fontnam": 3, "follow": 3, "sytax": 3, "imagefont": 3, "truetyp": 3, "system": 3, "timezon": 3, "extract": 3, "local": 3, "instead": 3, "utc": 3, "arrow": 3, "now": 3, "awar": 3, "tz": 3, "internet": 3, "connect": 3, "com": [3, 4], "timeout": 3, "network": 3, "reach": 3, "establish": 3, "add": 3, "do": 3, "requir": 3, "text": 3, "max_width": 3, "split": 3, "veri": 3, "long": 3, "smaller": 3, "part": 3, "line": 3, "fit": 3, "accur": 3, "calcul": 3, "string": 3, "int": 3, "defin": 3, "maximum": 3, "befor": 3, "chunk": 3, "list": 3, "box_siz": 3, "kwarg": 3, "posit": 3, "specifi": 3, "box": 3, "actual": 3, "option": 3, "align": 3, "center": 3, "right": 3, "autofit": 3, "automat": 3, "increas": 3, "fontsiz": 3, "much": 3, "possibl": 3, "black": 3, "chang": 3, "caus": 3, "rotat": 3, "angl": 3, "anti": 3, "clockwis": 3, "fill_width": 3, "90": 3, "fill_height": 3, "pars": 3, "ical_pars": 3, "moudul": 3, "url": 3, "static": 3, "all_dai": 3, "dai": 3, "els": 3, "clear_ev": 3, "clear": 3, "previous": 3, "get_ev": 3, "timeline_start": 3, "timeline_end": 3, "input": 3, "begin": 3, "timelin": 3, "end": 3, "format": 3, "sort": 3, "date": 3, "load_from_fil": 3, "filepath": 3, "valid": 3, "exampl": 3, "path1": 3, "singl": 3, "OR": 3, "path2": 3, "multipl": 3, "raw": 3, "load_url": 3, "usernam": 3, "password": 3, "url1": 3, "url2": 3, "protect": 3, "show_ev": 3, "fmt": 3, "dd": 3, "mmm": 3, "yy": 3, "hh": 3, "mm": 3, "readabl": 3, "wai": 3, "paramet": 3, "see": 3, "http": [3, 4], "readthedoc": 3, "io": 3, "en": 3, "token": 3, "info": 3, "order": 3, "handl": 3, "made": 3, "inky_imag": 3, "imga": 3, "written": 3, "commonli": 3, "oper": 3, "autoflip": 3, "layout": 3, "flip": 3, "choos": 3, "horizont": 3, "vertic": 3, "In": 3, "greater": 3, "than": 3, "remov": 3, "current": 3, "save": 3, "180": 3, "270": 3, "360": 3, "sampl": 3, "logo": 3, "png": 3, "home": 3, "download": [3, 4], "nice_p": 3, "rais": 3, "filenotfounderror": 3, "except": 3, "when": 3, "oserror": 3, "point": 3, "correct": 3, "typeerror": 3, "start": 3, "htpp": 3, "merg": 3, "image1": 3, "image2": 3, "two": 3, "replac": 3, "white": 3, "first": 3, "transpar": 3, "ones": 3, "Then": 3, "past": 3, "rgba": 3, "preview": 3, "gpicview": 3, "onli": 3, "rapsbian": 3, "desktop": 3, "remove_alpha": 3, "alpha": 3, "band": 3, "resiz": 3, "desir": 3, "to_palett": 3, "palett": 3, "dither": 3, "runner": 3, "venv": 3, "lib": 3, "11": 3, "site": 3, "packag": 3, "py": 3, "map": 3, "below": 3, "solid": 3, "valueerror": 3, "bwr": 3, "red": 3, "bwy": 3, "yellow": 3, "bw": 3, "16grai": 3, "16": 3, "shade": 3, "grai": 3, "directli": 4, "github": 4, "repo": 4, "clone": 4, "git": 4, "go": 4, "cd": 4, "pip3": 4, "navig": 4, "copi": 4, "come": 4, "soon": 4}, "objects": {"inkycal.custom": [[3, 0, 0, "-", "functions"]], "inkycal.custom.functions": [[3, 1, 1, "", "auto_fontsize"], [3, 1, 1, "", "draw_border"], [3, 1, 1, "", "get_fonts"], [3, 1, 1, "", "get_system_tz"], [3, 1, 1, "", "internet_available"], [3, 1, 1, "", "text_wrap"], [3, 1, 1, "", "write"]], "inkycal.display": [[3, 0, 0, "-", "Display"]], "inkycal": [[3, 0, 0, "-", "main"]], "inkycal.main": [[3, 2, 1, "", "Inkycal"]], "inkycal.main.Inkycal": [[3, 3, 1, "", "calibrate"], [3, 3, 1, "", "countdown"], [3, 3, 1, "", "run"], [3, 3, 1, "", "test"]], "inkycal.modules": [[3, 0, 0, "-", "ical_parser"], [3, 0, 0, "-", "inky_image"]], "inkycal.modules.ical_parser": [[3, 2, 1, "", "iCalendar"]], "inkycal.modules.ical_parser.iCalendar": [[3, 3, 1, "", "all_day"], [3, 3, 1, "", "clear_events"], [3, 3, 1, "", "get_events"], [3, 3, 1, "", "get_system_tz"], [3, 3, 1, "", "load_from_file"], [3, 3, 1, "", "load_url"], [3, 3, 1, "", "show_events"], [3, 3, 1, "", "sort"]], "inkycal.modules.inky_image": [[3, 2, 1, "", "Inkyimage"]], "inkycal.modules.inky_image.Inkyimage": [[3, 3, 1, "", "autoflip"], [3, 3, 1, "", "clear"], [3, 3, 1, "", "flip"], [3, 3, 1, "", "load"], [3, 3, 1, "", "merge"], [3, 3, 1, "", "preview"], [3, 3, 1, "", "remove_alpha"], [3, 3, 1, "", "resize"], [3, 3, 1, "", "to_palette"]]}, "objtypes": {"0": "py:module", "1": "py:function", "2": "py:class", "3": "py:method"}, "objnames": {"0": ["py", "module", "Python module"], "1": ["py", "function", "Python function"], "2": ["py", "class", "Python class"], "3": ["py", "method", "Python method"]}, "titleterms": {"about": 0, "inkyc": [0, 2, 3, 4], "develop": 1, "document": [1, 2], "content": 2, "indic": 2, "tabl": 2, "displai": 3, "custom": 3, "function": 3, "helper": 3, "class": 3, "quickstart": 4, "instal": 4, "creat": 4, "set": 4, "file": 4}, "envversion": {"sphinx.domains.c": 3, "sphinx.domains.changeset": 1, "sphinx.domains.citation": 1, "sphinx.domains.cpp": 9, "sphinx.domains.index": 1, "sphinx.domains.javascript": 3, "sphinx.domains.math": 2, "sphinx.domains.python": 4, "sphinx.domains.rst": 2, "sphinx.domains.std": 2, "sphinx": 60}, "alltitles": {"About Inkycal": [[0, "about-inkycal"]], "Developer documentation": [[1, "developer-documentation"]], "Inkycal documentation": [[2, "inkycal-documentation"]], "Contents:": [[2, null]], "Indices and tables": [[2, "indices-and-tables"]], "Inkycal": [[3, "module-inkycal.main"]], "Display": [[3, "module-inkycal.display.Display"]], "Custom functions": [[3, "module-inkycal.custom.functions"]], "Helper classes": [[3, "module-inkycal.modules.ical_parser"]], "Quickstart": [[4, "quickstart"]], "Installing Inkycal": [[4, "installing-inkycal"]], "Creating settings file": [[4, "creating-settings-file"]]}, "indexentries": {"inkycal (class in inkycal.main)": [[3, "inkycal.main.Inkycal"]], "inkyimage (class in inkycal.modules.inky_image)": [[3, "inkycal.modules.inky_image.Inkyimage"]], "all_day() (inkycal.modules.ical_parser.icalendar static method)": [[3, "inkycal.modules.ical_parser.iCalendar.all_day"]], "auto_fontsize() (in module inkycal.custom.functions)": [[3, "inkycal.custom.functions.auto_fontsize"]], "autoflip() (inkycal.modules.inky_image.inkyimage method)": [[3, "inkycal.modules.inky_image.Inkyimage.autoflip"]], "calibrate() (inkycal.main.inkycal method)": [[3, "inkycal.main.Inkycal.calibrate"]], "clear() (inkycal.modules.inky_image.inkyimage method)": [[3, "inkycal.modules.inky_image.Inkyimage.clear"]], "clear_events() (inkycal.modules.ical_parser.icalendar method)": [[3, "inkycal.modules.ical_parser.iCalendar.clear_events"]], "countdown() (inkycal.main.inkycal method)": [[3, "inkycal.main.Inkycal.countdown"]], "draw_border() (in module inkycal.custom.functions)": [[3, "inkycal.custom.functions.draw_border"]], "flip() (inkycal.modules.inky_image.inkyimage method)": [[3, "inkycal.modules.inky_image.Inkyimage.flip"]], "get_events() (inkycal.modules.ical_parser.icalendar method)": [[3, "inkycal.modules.ical_parser.iCalendar.get_events"]], "get_fonts() (in module inkycal.custom.functions)": [[3, "inkycal.custom.functions.get_fonts"]], "get_system_tz() (in module inkycal.custom.functions)": [[3, "inkycal.custom.functions.get_system_tz"]], "get_system_tz() (inkycal.modules.ical_parser.icalendar static method)": [[3, "inkycal.modules.ical_parser.iCalendar.get_system_tz"]], "icalendar (class in inkycal.modules.ical_parser)": [[3, "inkycal.modules.ical_parser.iCalendar"]], "inkycal.custom.functions": [[3, "module-inkycal.custom.functions"]], "inkycal.display.display": [[3, "module-inkycal.display.Display"]], "inkycal.main": [[3, "module-inkycal.main"]], "inkycal.modules.ical_parser": [[3, "module-inkycal.modules.ical_parser"]], "inkycal.modules.inky_image": [[3, "module-inkycal.modules.inky_image"]], "internet_available() (in module inkycal.custom.functions)": [[3, "inkycal.custom.functions.internet_available"]], "load() (inkycal.modules.inky_image.inkyimage method)": [[3, "inkycal.modules.inky_image.Inkyimage.load"]], "load_from_file() (inkycal.modules.ical_parser.icalendar method)": [[3, "inkycal.modules.ical_parser.iCalendar.load_from_file"]], "load_url() (inkycal.modules.ical_parser.icalendar method)": [[3, "inkycal.modules.ical_parser.iCalendar.load_url"]], "merge() (inkycal.modules.inky_image.inkyimage static method)": [[3, "inkycal.modules.inky_image.Inkyimage.merge"]], "module": [[3, "module-inkycal.custom.functions"], [3, "module-inkycal.display.Display"], [3, "module-inkycal.main"], [3, "module-inkycal.modules.ical_parser"], [3, "module-inkycal.modules.inky_image"]], "preview() (inkycal.modules.inky_image.inkyimage static method)": [[3, "inkycal.modules.inky_image.Inkyimage.preview"]], "remove_alpha() (inkycal.modules.inky_image.inkyimage method)": [[3, "inkycal.modules.inky_image.Inkyimage.remove_alpha"]], "resize() (inkycal.modules.inky_image.inkyimage method)": [[3, "inkycal.modules.inky_image.Inkyimage.resize"]], "run() (inkycal.main.inkycal method)": [[3, "inkycal.main.Inkycal.run"]], "show_events() (inkycal.modules.ical_parser.icalendar method)": [[3, "inkycal.modules.ical_parser.iCalendar.show_events"]], "sort() (inkycal.modules.ical_parser.icalendar method)": [[3, "inkycal.modules.ical_parser.iCalendar.sort"]], "test() (inkycal.main.inkycal method)": [[3, "inkycal.main.Inkycal.test"]], "text_wrap() (in module inkycal.custom.functions)": [[3, "inkycal.custom.functions.text_wrap"]], "to_palette() (inkycal.modules.inky_image.inkyimage method)": [[3, "inkycal.modules.inky_image.Inkyimage.to_palette"]], "write() (in module inkycal.custom.functions)": [[3, "inkycal.custom.functions.write"]]}}) \ No newline at end of file +Search.setIndex({"docnames": ["about", "dev_doc", "index", "inkycal", "quickstart"], "filenames": ["about.md", "dev_doc.md", "index.rst", "inkycal.rst", "quickstart.md"], "titles": ["About Inkycal", "Developer documentation", "Inkycal documentation", "Inkycal", "Quickstart"], "terms": {"i": [0, 1, 3], "python3": [0, 3], "softwar": 0, "select": [0, 3], "e": [0, 3, 4], "paper": [0, 3], "displai": [0, 2], "It": 0, "": [0, 3], "open": 0, "sourc": 0, "non": [0, 3], "commerci": 0, "fulli": 0, "modular": 0, "user": 0, "friendli": 0, "even": 0, "run": [0, 3], "well": 0, "raspberri": [0, 4], "pi": [0, 3, 4], "zero": 0, "ha": [0, 3], "web": [0, 4], "ui": [0, 4], "which": [0, 3], "take": [0, 3], "care": [0, 3], "ad": 0, "your": [0, 3, 4], "detail": 0, "No": 0, "more": [0, 3, 4], "edit": 0, "file": [0, 2, 3], "yai": 0, "parti": [0, 1], "_": 0, "face": 0, "The": [0, 3], "main": [0, 3], "idea": 0, "behind": 0, "wa": [0, 3], "creat": [0, 1, 2, 3], "dashboard": 0, "blend": 0, "its": 0, "environ": 0, "show": [0, 3], "you": 0, "all": [0, 3], "inform": 0, "without": [0, 3], "have": [0, 3], "look": [0, 3], "them": [0, 3], "up": 0, "sever": 0, "built": 0, "modul": [0, 1, 2, 3], "help": 0, "stai": 0, "organis": 0, "provid": 0, "weather": 0, "forecast": 0, "full": [0, 3], "week": 0, "next": [0, 3], "few": 0, "hour": 0, "get": [0, 3], "latest": [0, 3], "new": [0, 3], "from": [0, 3], "atom": 0, "rss": 0, "feed": 0, "icalendar": [0, 2, 3], "agenda": 0, "mai": 0, "synchronis": 0, "phone": 0, "monthli": 0, "calendar": 0, "also": 0, "event": [0, 3], "sync": 0, "googl": [0, 3], "etc": 0, "fetch": 0, "some": 0, "joke": 0, "form": 0, "smile": 0, "what": 0, "compat": 0, "third": [0, 1], "someth": [0, 3], "miss": 0, "can": [0, 3], "write": [0, 2, 3], "own": 0, "share": 0, "commun": 0, "discord": 0, "case": 0, "re": 0, "pinch": 0, "set": [0, 2, 3], "noob": 0, "welcom": 0, "too": 0, "cours": 0, "develop": [0, 2], "mainli": [0, 1], "aceisac": 0, "univers": 0, "student": 0, "other": [0, 3], "free": 0, "time": [0, 3], "mean": 0, "we": 0, "work": [0, 3], "noth": 0, "doesn": [0, 3], "t": [0, 3], "don": 0, "need": 0, "anyth": 0, "invest": 0, "larg": 0, "amount": 0, "effort": 0, "coffe": 0, "pleas": [0, 4], "support": [0, 3], "via": [0, 4], "donat": 0, "u": 0, "keep": 0, "thi": [0, 1, 3], "project": [0, 3], "aliv": 0, "thank": 0, "who": 1, "wish": 1, "custom": 2, "function": 2, "auto_fonts": [2, 3], "draw_bord": [2, 3], "get_font": [2, 3], "get_system_tz": [2, 3], "internet_avail": [2, 3], "text_wrap": [2, 3], "helper": 2, "class": 2, "inkyimag": [2, 3], "about": 2, "quickstart": 2, "instal": 2, "index": 2, "search": [2, 3], "page": 2, "copyright": 3, "aceinnolab": [3, 4], "settings_path": 3, "str": 3, "none": 3, "render": 3, "bool": 3, "true": 3, "test": 3, "program": 3, "arg": 3, "path": 3, "json": 3, "given": 3, "tri": 3, "boot": 3, "folder": [3, 4], "fals": 3, "imag": 3, "epap": 3, "attribut": 3, "optim": 3, "reduc": 3, "number": 3, "colour": 3, "gener": [3, 4], "improv": 3, "9": 3, "7": 3, "calibr": 3, "cycl": 3, "3": 3, "us": 3, "default": 3, "after": 3, "refresh": 3, "shown": 3, "countdown": 3, "interval_min": 3, "return": 3, "remain": 3, "second": 3, "until": 3, "updat": 3, "async": 3, "nonstop": 3, "mode": 3, "an": 3, "infin": 3, "loop": 3, "assembl": 3, "one": 3, "sleep": 3, "schedul": 3, "issu": 3, "attempt": 3, "import": 3, "name": 3, "load": 3, "config": 3, "each": 3, "initi": 3, "check": 3, "could": 3, "correctli": 3, "found": 3, "instanc": 3, "driver": 3, "model": 3, "allow": 3, "epaper_model": 3, "eas": 3, "font": 3, "max_height": 3, "scale": 3, "80": 3, "height": 3, "fill": 3, "A": 3, "pil": 3, "object": 3, "integ": 3, "repres": 3, "adjust": 3, "should": 3, "modifi": 3, "xy": 3, "size": 3, "radiu": 3, "5": 3, "thick": 3, "1": 3, "shrinkag": 3, "0": 3, "draw": 3, "border": 3, "coordin": 3, "drawn": 3, "usual": 3, "im_black": 3, "im_colour": 3, "tupl": 3, "top": 3, "left": 3, "corner": 3, "g": 3, "32": 3, "100": 3, "where": 3, "x": 3, "co": 3, "ordin": 3, "y": 3, "width": 3, "plain": 3, "rectangl": 3, "round": 3, "pixel": 3, "contain": 3, "decim": 3, "present": 3, "percentag": 3, "shrink": 3, "width_shrink_percentag": 3, "height_shrink_percentag": 3, "2": 3, "10": 3, "20": 3, "print": 3, "avail": 3, "output": 3, "To": 3, "access": 3, "fontfil": 3, "dictionari": 3, "fontnam": 3, "follow": 3, "sytax": 3, "imagefont": 3, "truetyp": 3, "system": 3, "timezon": 3, "extract": 3, "local": 3, "instead": 3, "utc": 3, "arrow": 3, "now": 3, "awar": 3, "tz": 3, "internet": 3, "connect": 3, "com": [3, 4], "timeout": 3, "network": 3, "reach": 3, "establish": 3, "add": 3, "do": 3, "requir": 3, "text": 3, "max_width": 3, "split": 3, "veri": 3, "long": 3, "smaller": 3, "part": 3, "line": 3, "fit": 3, "accur": 3, "calcul": 3, "string": 3, "int": 3, "defin": 3, "maximum": 3, "befor": 3, "chunk": 3, "list": 3, "box_siz": 3, "kwarg": 3, "posit": 3, "specifi": 3, "box": 3, "actual": 3, "option": 3, "align": 3, "center": 3, "right": 3, "autofit": 3, "automat": 3, "increas": 3, "fontsiz": 3, "much": 3, "possibl": 3, "black": 3, "chang": 3, "caus": 3, "rotat": 3, "angl": 3, "anti": 3, "clockwis": 3, "fill_width": 3, "90": 3, "fill_height": 3, "pars": 3, "ical_pars": 3, "moudul": 3, "url": 3, "static": 3, "all_dai": 3, "dai": 3, "els": 3, "clear_ev": 3, "clear": 3, "previous": 3, "get_ev": 3, "timeline_start": 3, "timeline_end": 3, "input": 3, "begin": 3, "timelin": 3, "end": 3, "format": 3, "sort": 3, "date": 3, "load_from_fil": 3, "filepath": 3, "valid": 3, "exampl": 3, "path1": 3, "singl": 3, "OR": 3, "path2": 3, "multipl": 3, "raw": 3, "load_url": 3, "usernam": 3, "password": 3, "url1": 3, "url2": 3, "protect": 3, "show_ev": 3, "fmt": 3, "dd": 3, "mmm": 3, "yy": 3, "hh": 3, "mm": 3, "readabl": 3, "wai": 3, "paramet": 3, "see": 3, "http": [3, 4], "readthedoc": 3, "io": 3, "en": 3, "token": 3, "info": 3, "order": 3, "handl": 3, "made": 3, "inky_imag": 3, "imga": 3, "written": 3, "commonli": 3, "oper": 3, "autoflip": 3, "layout": 3, "flip": 3, "choos": 3, "horizont": 3, "vertic": 3, "In": 3, "greater": 3, "than": 3, "remov": 3, "current": 3, "save": 3, "180": 3, "270": 3, "360": 3, "sampl": 3, "logo": 3, "png": 3, "home": 3, "download": [3, 4], "nice_p": 3, "rais": 3, "filenotfounderror": 3, "except": 3, "when": 3, "oserror": 3, "point": 3, "correct": 3, "typeerror": 3, "start": 3, "htpp": 3, "merg": 3, "image1": 3, "image2": 3, "two": 3, "replac": 3, "white": 3, "first": 3, "transpar": 3, "ones": 3, "Then": 3, "past": 3, "rgba": 3, "preview": 3, "gpicview": 3, "onli": 3, "rapsbian": 3, "desktop": 3, "remove_alpha": 3, "alpha": 3, "band": 3, "resiz": 3, "desir": 3, "to_palett": 3, "palett": 3, "dither": 3, "runner": 3, "venv": 3, "lib": 3, "11": 3, "site": 3, "packag": 3, "py": 3, "map": 3, "below": 3, "solid": 3, "valueerror": 3, "bwr": 3, "red": 3, "bwy": 3, "yellow": 3, "bw": 3, "16grai": 3, "16": 3, "shade": 3, "grai": 3, "directli": 4, "github": 4, "repo": 4, "clone": 4, "git": 4, "go": 4, "cd": 4, "pip3": 4, "navig": 4, "copi": 4, "come": 4, "soon": 4}, "objects": {"inkycal.custom": [[3, 0, 0, "-", "functions"]], "inkycal.custom.functions": [[3, 1, 1, "", "auto_fontsize"], [3, 1, 1, "", "draw_border"], [3, 1, 1, "", "get_fonts"], [3, 1, 1, "", "get_system_tz"], [3, 1, 1, "", "internet_available"], [3, 1, 1, "", "text_wrap"], [3, 1, 1, "", "write"]], "inkycal.display": [[3, 0, 0, "-", "Display"]], "inkycal": [[3, 0, 0, "-", "main"]], "inkycal.main": [[3, 2, 1, "", "Inkycal"]], "inkycal.main.Inkycal": [[3, 3, 1, "", "calibrate"], [3, 3, 1, "", "countdown"], [3, 3, 1, "", "run"], [3, 3, 1, "", "test"]], "inkycal.modules": [[3, 0, 0, "-", "ical_parser"], [3, 0, 0, "-", "inky_image"]], "inkycal.modules.ical_parser": [[3, 2, 1, "", "iCalendar"]], "inkycal.modules.ical_parser.iCalendar": [[3, 3, 1, "", "all_day"], [3, 3, 1, "", "clear_events"], [3, 3, 1, "", "get_events"], [3, 3, 1, "", "get_system_tz"], [3, 3, 1, "", "load_from_file"], [3, 3, 1, "", "load_url"], [3, 3, 1, "", "show_events"], [3, 3, 1, "", "sort"]], "inkycal.modules.inky_image": [[3, 2, 1, "", "Inkyimage"]], "inkycal.modules.inky_image.Inkyimage": [[3, 3, 1, "", "autoflip"], [3, 3, 1, "", "clear"], [3, 3, 1, "", "flip"], [3, 3, 1, "", "load"], [3, 3, 1, "", "merge"], [3, 3, 1, "", "preview"], [3, 3, 1, "", "remove_alpha"], [3, 3, 1, "", "resize"], [3, 3, 1, "", "to_palette"]]}, "objtypes": {"0": "py:module", "1": "py:function", "2": "py:class", "3": "py:method"}, "objnames": {"0": ["py", "module", "Python module"], "1": ["py", "function", "Python function"], "2": ["py", "class", "Python class"], "3": ["py", "method", "Python method"]}, "titleterms": {"about": 0, "inkyc": [0, 2, 3, 4], "develop": 1, "document": [1, 2], "content": 2, "indic": 2, "tabl": 2, "displai": 3, "custom": 3, "function": 3, "helper": 3, "class": 3, "quickstart": 4, "instal": 4, "creat": 4, "set": 4, "file": 4}, "envversion": {"sphinx.domains.c": 3, "sphinx.domains.changeset": 1, "sphinx.domains.citation": 1, "sphinx.domains.cpp": 9, "sphinx.domains.index": 1, "sphinx.domains.javascript": 3, "sphinx.domains.math": 2, "sphinx.domains.python": 4, "sphinx.domains.rst": 2, "sphinx.domains.std": 2, "sphinx": 60}, "alltitles": {"About Inkycal": [[0, "about-inkycal"]], "Developer documentation": [[1, "developer-documentation"]], "Inkycal documentation": [[2, "inkycal-documentation"]], "Contents:": [[2, null]], "Indices and tables": [[2, "indices-and-tables"]], "Inkycal": [[3, "module-inkycal.main"]], "Display": [[3, "module-inkycal.display.Display"]], "Custom functions": [[3, "module-inkycal.custom.functions"]], "Helper classes": [[3, "module-inkycal.modules.ical_parser"]], "Quickstart": [[4, "quickstart"]], "Installing Inkycal": [[4, "installing-inkycal"]], "Creating settings file": [[4, "creating-settings-file"]]}, "indexentries": {"inkycal (class in inkycal.main)": [[3, "inkycal.main.Inkycal"]], "inkyimage (class in inkycal.modules.inky_image)": [[3, "inkycal.modules.inky_image.Inkyimage"]], "all_day() (inkycal.modules.ical_parser.icalendar static method)": [[3, "inkycal.modules.ical_parser.iCalendar.all_day"]], "auto_fontsize() (in module inkycal.custom.functions)": [[3, "inkycal.custom.functions.auto_fontsize"]], "autoflip() (inkycal.modules.inky_image.inkyimage method)": [[3, "inkycal.modules.inky_image.Inkyimage.autoflip"]], "calibrate() (inkycal.main.inkycal method)": [[3, "inkycal.main.Inkycal.calibrate"]], "clear() (inkycal.modules.inky_image.inkyimage method)": [[3, "inkycal.modules.inky_image.Inkyimage.clear"]], "clear_events() (inkycal.modules.ical_parser.icalendar method)": [[3, "inkycal.modules.ical_parser.iCalendar.clear_events"]], "countdown() (inkycal.main.inkycal method)": [[3, "inkycal.main.Inkycal.countdown"]], "draw_border() (in module inkycal.custom.functions)": [[3, "inkycal.custom.functions.draw_border"]], "flip() (inkycal.modules.inky_image.inkyimage method)": [[3, "inkycal.modules.inky_image.Inkyimage.flip"]], "get_events() (inkycal.modules.ical_parser.icalendar method)": [[3, "inkycal.modules.ical_parser.iCalendar.get_events"]], "get_fonts() (in module inkycal.custom.functions)": [[3, "inkycal.custom.functions.get_fonts"]], "get_system_tz() (in module inkycal.custom.functions)": [[3, "inkycal.custom.functions.get_system_tz"]], "get_system_tz() (inkycal.modules.ical_parser.icalendar static method)": [[3, "inkycal.modules.ical_parser.iCalendar.get_system_tz"]], "icalendar (class in inkycal.modules.ical_parser)": [[3, "inkycal.modules.ical_parser.iCalendar"]], "inkycal.custom.functions": [[3, "module-inkycal.custom.functions"]], "inkycal.display.display": [[3, "module-inkycal.display.Display"]], "inkycal.main": [[3, "module-inkycal.main"]], "inkycal.modules.ical_parser": [[3, "module-inkycal.modules.ical_parser"]], "inkycal.modules.inky_image": [[3, "module-inkycal.modules.inky_image"]], "internet_available() (in module inkycal.custom.functions)": [[3, "inkycal.custom.functions.internet_available"]], "load() (inkycal.modules.inky_image.inkyimage method)": [[3, "inkycal.modules.inky_image.Inkyimage.load"]], "load_from_file() (inkycal.modules.ical_parser.icalendar method)": [[3, "inkycal.modules.ical_parser.iCalendar.load_from_file"]], "load_url() (inkycal.modules.ical_parser.icalendar method)": [[3, "inkycal.modules.ical_parser.iCalendar.load_url"]], "merge() (inkycal.modules.inky_image.inkyimage static method)": [[3, "inkycal.modules.inky_image.Inkyimage.merge"]], "module": [[3, "module-inkycal.custom.functions"], [3, "module-inkycal.display.Display"], [3, "module-inkycal.main"], [3, "module-inkycal.modules.ical_parser"], [3, "module-inkycal.modules.inky_image"]], "preview() (inkycal.modules.inky_image.inkyimage static method)": [[3, "inkycal.modules.inky_image.Inkyimage.preview"]], "remove_alpha() (inkycal.modules.inky_image.inkyimage method)": [[3, "inkycal.modules.inky_image.Inkyimage.remove_alpha"]], "resize() (inkycal.modules.inky_image.inkyimage method)": [[3, "inkycal.modules.inky_image.Inkyimage.resize"]], "run() (inkycal.main.inkycal method)": [[3, "inkycal.main.Inkycal.run"]], "show_events() (inkycal.modules.ical_parser.icalendar method)": [[3, "inkycal.modules.ical_parser.iCalendar.show_events"]], "sort() (inkycal.modules.ical_parser.icalendar method)": [[3, "inkycal.modules.ical_parser.iCalendar.sort"]], "test() (inkycal.main.inkycal method)": [[3, "inkycal.main.Inkycal.test"]], "text_wrap() (in module inkycal.custom.functions)": [[3, "inkycal.custom.functions.text_wrap"]], "to_palette() (inkycal.modules.inky_image.inkyimage method)": [[3, "inkycal.modules.inky_image.Inkyimage.to_palette"]], "write() (in module inkycal.custom.functions)": [[3, "inkycal.custom.functions.write"]]}}) \ No newline at end of file diff --git a/inkycal/main.py b/inkycal/main.py index fe821cb9..7ec97928 100644 --- a/inkycal/main.py +++ b/inkycal/main.py @@ -532,14 +532,14 @@ def _optimize_im(image, threshold=220): image = Image.fromarray(buffer) return image - def calibrate(self): + def calibrate(self, cycles=3): """Calibrate the E-Paper display Uses the Display class to calibrate the display with the default of 3 cycles. After a refresh cycle, a new image is generated and shown. """ - self.Display.calibrate() + self.Display.calibrate(cycles=cycles) def _calibration_check(self): """Calibration scheduler diff --git a/inkycal/modules/__init__.py b/inkycal/modules/__init__.py index 7eb656d0..d82ae99d 100755 --- a/inkycal/modules/__init__.py +++ b/inkycal/modules/__init__.py @@ -11,3 +11,4 @@ from .inkycal_webshot import Webshot from .inkycal_xkcd import Xkcd from .inkycal_fullweather import Fullweather +from .inkycal_tindie import Tindie diff --git a/inkycal/modules/inky_image.py b/inkycal/modules/inky_image.py index a655655e..1580c1af 100755 --- a/inkycal/modules/inky_image.py +++ b/inkycal/modules/inky_image.py @@ -29,7 +29,7 @@ def __init__(self, image=None): # give an OK message logger.info(f'{__name__} loaded') - def load(self, path): + def load(self, path:str) -> None: """loads an image from a URL or filepath. Args: diff --git a/inkycal/modules/inkycal_tindie.py b/inkycal/modules/inkycal_tindie.py new file mode 100755 index 00000000..1f7a7426 --- /dev/null +++ b/inkycal/modules/inkycal_tindie.py @@ -0,0 +1,107 @@ +""" +Tindie module for Inkycal Project +Shows unshipped orders from your Tindie store + +Copyright by aceinnolab +""" +import json + +import arrow + +from inkycal.custom import * +from inkycal.modules.template import inkycal_module + +# Show less logging for request module +logging.getLogger("urllib3").setLevel(logging.WARNING) + +logger = logging.getLogger(__name__) + + +class Tindie(inkycal_module): + """Tindie - show latest orders from your store""" + + def __init__(self, config): + """Initialize inkycal_feeds module""" + + super().__init__(config) + + config = config['config'] + self.api_key = config['api_key'] + self.username = config['username'] + # todo implement mode + # self.mode = config['mode'] # unshipped_orders, shipped_orders, all_orders + + # give an OK message + print(f'{__name__} loaded') + + def generate_image(self): + """Generate image for this module""" + # Define new image size with respect to padding + im_width = int(self.width - (2 * self.padding_left)) + im_height = int(self.height - (2 * self.padding_top)) + im_size = im_width, im_height + logger.info(f'image size: {im_width} x {im_height} px') + + # Create an image for black pixels and one for coloured pixels + im_black = Image.new('RGB', size=im_size, color='white') + im_colour = Image.new('RGB', size=im_size, color='white') + + # Check if internet is available + if internet_available(): + logger.info('Connection test passed') + else: + raise NetworkNotReachableError + + # Set some parameters for formatting feeds + line_spacing = 5 + text_bbox = self.font.getbbox("hg") + line_height = text_bbox[3] + line_spacing + line_width = im_width + max_lines = (im_height // (line_height + line_spacing)) + + logger.debug(f"max_lines: {max_lines}") + + # Calculate padding from top so the lines look centralised + spacing_top = int(im_height % line_height / 2) + + # Calculate line_positions + line_positions = [ + (0, spacing_top + _ * line_height) for _ in range(max_lines)] + + logger.debug(f'line positions: {line_positions}') + + # Make the API call + url = f"https://www.tindie.com/api/v1/order/?format=json&username={self.username}&api_key={self.api_key}" + header = {"accept": "text/json"} + response = requests.get(url, headers=header, params={"shipped": "false", "limit": "50"}) + if response.status_code != 200: + logger.error(f"Failed to get orders, status code: {response.status_code}, reason: {response.reason}") + raise AssertionError("Failed to get orders") + else: + logger.info("Orders received") + + text = [] + + orders = json.loads(response.text)["orders"] + text.append(f"You have {len(orders)} unshipped orders") + previous_date = None + for index, order in enumerate(orders, start=1): + items = order["items"] + date = arrow.get(order["date"]).to("local").format("YY/MM/DD") + if not previous_date or previous_date != date: + text.append(date) + previous_date = date + user_name = order["shipping_name"] + text.append(f"{index}) {user_name} from {order['shipping_country_code']} ordered {len(items)} items!") + + for pos, line in enumerate(text): + if pos > max_lines - 1: + logger.error(f'Ran out of lines! Required {len(text)} lines but only {max_lines} available') + break + if pos == 0: + write(im_colour, line_positions[pos], (line_width, line_height), line, font=self.font, alignment='left') + else: + write(im_black, line_positions[pos], (line_width, line_height), line, font=self.font, alignment='left') + + # Return images for black and colour channels + return im_black, im_colour diff --git a/tests/config.py b/tests/config.py index c3d3b032..f90a4855 100644 --- a/tests/config.py +++ b/tests/config.py @@ -31,6 +31,10 @@ class Config: TEST_SETTINGS_PATH = f"{basedir}/settings.json" + # inkycal_tindie_test + TINDIE_API_KEY = get("TINDIE_API_KEY") + TINDIE_USERNAME = get("TINDIE_USERNAME") + diff --git a/tests/test_inkycal_tindie.py b/tests/test_inkycal_tindie.py new file mode 100755 index 00000000..ff9389c0 --- /dev/null +++ b/tests/test_inkycal_tindie.py @@ -0,0 +1,72 @@ +""" +inkycal_Tindie unittest +""" +import logging +import unittest + +from inkycal.modules import Tindie +from inkycal.modules.inky_image import Inkyimage +from tests import Config + +preview = Inkyimage.preview +merge = Inkyimage.merge + +logger = logging.getLogger(__name__) +logging.basicConfig(level=logging.DEBUG) + +tindie_api_key = Config.TINDIE_API_KEY +tindie_username = Config.TINDIE_USERNAME + +tests = [ + { + "name": "Tindie", + "config": { + "size": [300, 100], + "padding_x": 10, + "padding_y": 10, + "fontsize": 12, + "language": "en", + "api_key": tindie_api_key, + "username": tindie_username, + "mode": "unshipped_orders" + } + }, + { + "name": "Tindie", + "config": { + "size": [300, 150], + "padding_x": 10, + "padding_y": 10, + "fontsize": 12, + "language": "en", + "api_key": tindie_api_key, + "username": tindie_username, + "mode": "unshipped_orders" + } + }, + { + "name": "Tindie", + "config": { + "size": [300, 800], + "padding_x": 10, + "padding_y": 10, + "fontsize": 18, + "language": "en", + "api_key": tindie_api_key, + "username": tindie_username, + "mode": "unshipped_orders" + } + }, +] + + +class TestTindie(unittest.TestCase): + + def test_generate_image(self): + for test in tests: + logger.info(f'test {tests.index(test) + 1} generating image..') + module = Tindie(test) + im_black, im_colour = module.generate_image() + logger.info('OK') + if Config.USE_PREVIEW: + preview(merge(im_black, im_colour))