Merge remote-tracking branch 'upstream/main'
This commit is contained in:
@@ -1,5 +1,3 @@
|
||||
#!python3
|
||||
|
||||
"""
|
||||
Third party module template (inkycal-compatible module)
|
||||
|
||||
|
@@ -1,6 +1,3 @@
|
||||
#!python3
|
||||
|
||||
|
||||
"""
|
||||
Custom image class for Inkycal Project
|
||||
Takes care of handling images. Made to be used by other modules to handle
|
||||
@@ -10,9 +7,10 @@ Copyright by aceinnolab
|
||||
"""
|
||||
import logging
|
||||
import os
|
||||
|
||||
import PIL
|
||||
import numpy
|
||||
import requests
|
||||
|
||||
from PIL import Image
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
@@ -114,7 +112,7 @@ class Inkyimage:
|
||||
self.image = image
|
||||
logger.info(f'flipped image by {angle} degrees')
|
||||
|
||||
def autoflip(self, layout:str) -> None:
|
||||
def autoflip(self, layout: str) -> None:
|
||||
"""flips the image automatically to the given layout.
|
||||
|
||||
Args:
|
||||
@@ -215,7 +213,7 @@ class Inkyimage:
|
||||
|
||||
return image1
|
||||
|
||||
def to_palette(self, palette, dither=True) -> (Image, Image):
|
||||
def to_palette(self, palette, dither=True) -> (PIL.Image, PIL.Image):
|
||||
"""Maps an image to a given colour palette.
|
||||
|
||||
Maps each pixel from the image to a colour from the palette.
|
||||
@@ -235,6 +233,7 @@ class Inkyimage:
|
||||
>>> 'bwr' # black-white-red
|
||||
>>> 'bwy' # black-white-yellow
|
||||
>>> 'bw' # black-white
|
||||
>>> '16gray' # 16 shades of gray
|
||||
"""
|
||||
# Check if an image is loaded
|
||||
if self._image_loaded():
|
||||
@@ -252,6 +251,9 @@ class Inkyimage:
|
||||
|
||||
elif palette == 'bw':
|
||||
pal = None
|
||||
elif palette == '16gray':
|
||||
pal = [x for x in range(0, 256, 16)] * 3
|
||||
pal.sort()
|
||||
|
||||
else:
|
||||
logger.error('The given palette is unsupported.')
|
||||
@@ -329,4 +331,3 @@ class Inkyimage:
|
||||
|
||||
if __name__ == '__main__':
|
||||
print(f'running {__name__} in standalone/debug mode')
|
||||
|
||||
|
@@ -1,14 +1,11 @@
|
||||
#!python3
|
||||
|
||||
"""
|
||||
Inkycal Image Module
|
||||
Copyright by aceinnolab
|
||||
"""
|
||||
|
||||
from inkycal.modules.template import inkycal_module
|
||||
from inkycal.custom import *
|
||||
|
||||
from inkycal.modules.inky_image import Inkyimage as Images
|
||||
from inkycal.modules.template import inkycal_module
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -63,6 +60,9 @@ class Inkyimage(inkycal_module):
|
||||
self.palette = config['palette']
|
||||
self.autoflip = config['autoflip']
|
||||
self.orientation = config['orientation']
|
||||
self.dither = True
|
||||
if 'dither' in config and config["dither"] == False:
|
||||
self.dither = False
|
||||
|
||||
# give an OK message
|
||||
print(f'{__name__} loaded')
|
||||
@@ -94,7 +94,7 @@ class Inkyimage(inkycal_module):
|
||||
im.resize(width=im_width, height=im_height)
|
||||
|
||||
# convert images according to specified palette
|
||||
im_black, im_colour = im.to_palette(self.palette)
|
||||
im_black, im_colour = im.to_palette(self.palette, self.dither)
|
||||
|
||||
# with the images now send, clear the current image
|
||||
im.clear()
|
||||
|
@@ -1,17 +1,12 @@
|
||||
#!python3
|
||||
|
||||
"""
|
||||
Inkycal-server module for Inkycal Project
|
||||
by Aterju (https://inkycal.robertsirre.nl/)
|
||||
Copyright by aceinnolab
|
||||
"""
|
||||
|
||||
import requests
|
||||
|
||||
from inkycal.modules.template import inkycal_module
|
||||
from inkycal.custom import *
|
||||
|
||||
from inkycal.modules.inky_image import Inkyimage as Images
|
||||
from inkycal.modules.template import inkycal_module
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
@@ -1,16 +1,13 @@
|
||||
#!python3
|
||||
|
||||
"""
|
||||
Inkycal Slideshow Module
|
||||
Copyright by aceinnolab
|
||||
"""
|
||||
import glob
|
||||
|
||||
from inkycal.modules.template import inkycal_module
|
||||
from inkycal.custom import *
|
||||
|
||||
# PIL has a class named Image, use alias for Inkyimage -> Images
|
||||
from inkycal.modules.inky_image import Inkyimage as Images
|
||||
from inkycal.modules.template import inkycal_module
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
@@ -1,18 +1,16 @@
|
||||
#!python3
|
||||
|
||||
"""
|
||||
Inkycal weather module
|
||||
Copyright by aceinnolab
|
||||
"""
|
||||
|
||||
from inkycal.modules.template import inkycal_module
|
||||
from inkycal.custom import *
|
||||
|
||||
import math
|
||||
import decimal
|
||||
import math
|
||||
|
||||
import arrow
|
||||
|
||||
from inkycal.custom import *
|
||||
from inkycal.custom import OpenWeatherMap
|
||||
from inkycal.modules.template import inkycal_module
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -95,7 +93,7 @@ class Weather(inkycal_module):
|
||||
self.use_beaufort = config['use_beaufort']
|
||||
|
||||
# additional configuration
|
||||
self.owm = OpenWeatherMap(api_key=self.api_key, city_id=self.location, units=config['units'])
|
||||
self.owm = OpenWeatherMap(api_key=self.api_key, city_id=self.location, units=config['units'])
|
||||
self.timezone = get_system_tz()
|
||||
self.locale = config['language']
|
||||
self.weatherfont = ImageFont.truetype(
|
||||
@@ -104,9 +102,8 @@ class Weather(inkycal_module):
|
||||
# give an OK message
|
||||
print(f"{__name__} loaded")
|
||||
|
||||
|
||||
@staticmethod
|
||||
def mps_to_beaufort(meters_per_second:float) -> int:
|
||||
def mps_to_beaufort(meters_per_second: float) -> int:
|
||||
"""Map meters per second to the beaufort scale.
|
||||
|
||||
Args:
|
||||
@@ -120,7 +117,7 @@ class Weather(inkycal_module):
|
||||
return next((i for i, threshold in enumerate(thresholds) if meters_per_second < threshold), 11)
|
||||
|
||||
@staticmethod
|
||||
def mps_to_mph(meters_per_second:float) -> float:
|
||||
def mps_to_mph(meters_per_second: float) -> float:
|
||||
"""Map meters per second to miles per hour, rounded to one decimal place.
|
||||
|
||||
Args:
|
||||
@@ -135,7 +132,7 @@ class Weather(inkycal_module):
|
||||
return round(miles_per_hour, 1)
|
||||
|
||||
@staticmethod
|
||||
def celsius_to_fahrenheit(celsius:int or float):
|
||||
def celsius_to_fahrenheit(celsius: int or float):
|
||||
"""Converts the given temperate from degrees Celsius to Fahrenheit."""
|
||||
fahrenheit = (celsius * 9 / 5) + 32
|
||||
return fahrenheit
|
||||
@@ -180,7 +177,8 @@ class Weather(inkycal_module):
|
||||
4: '\uf0a3',
|
||||
5: '\uf0a7',
|
||||
6: '\uf0aa',
|
||||
7: '\uf0ae'}[int(index) & 7]
|
||||
7: '\uf0ae'
|
||||
}[int(index) & 7]
|
||||
|
||||
def is_negative(temp):
|
||||
"""Check if temp is below freezing point of water (0°C/30°F)
|
||||
@@ -458,8 +456,9 @@ class Weather(inkycal_module):
|
||||
# Create a list containing time-objects for every 3rd hour of the day
|
||||
time_range = list(
|
||||
arrow.Arrow.range('hour',
|
||||
now.shift(days=days_from_today).floor('day'),now.shift(days=days_from_today).ceil('day')
|
||||
))[::3]
|
||||
now.shift(days=days_from_today).floor('day'),
|
||||
now.shift(days=days_from_today).ceil('day')
|
||||
))[::3]
|
||||
|
||||
# Get forecasts for each time-object
|
||||
forecasts = [_ for _ in forecast if arrow.get(_["dt"]) in time_range]
|
||||
@@ -493,7 +492,7 @@ class Weather(inkycal_module):
|
||||
if dec_temp != 0:
|
||||
temperature = f"{round(weather['main']['temp'])}°"
|
||||
else:
|
||||
temperature = f"{round(weather['main']['temp'],ndigits=dec_temp)}°"
|
||||
temperature = f"{round(weather['main']['temp'], ndigits=dec_temp)}°"
|
||||
|
||||
weather_icon = weather["weather"][0]["icon"]
|
||||
humidity = str(weather["main"]["humidity"])
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#!python3
|
||||
|
||||
"""Inkycal module template"""
|
||||
import abc
|
||||
|
||||
from inkycal.custom import *
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user