-#!/usr/bin/env python
+#!/usr/bin/env python3
import time
from enviroplus import gas
-#!/usr/bin/env python
+#!/usr/bin/env python3
import time
import colorsys
from PIL import Image
from PIL import ImageDraw
from PIL import ImageFont
+from fonts.ttf import RobotoMedium as UserFont
import logging
logging.basicConfig(
img = Image.new('RGB', (WIDTH, HEIGHT), color=(0, 0, 0))
draw = ImageDraw.Draw(img)
path = os.path.dirname(os.path.realpath(__file__))
-font = ImageFont.truetype(path + "/fonts/Asap/Asap-Bold.ttf", 20)
+font_size = 20
+font = ImageFont.truetype(UserFont, FontSize)
message = ""
# Tuning factor for compensation. Decrease this number to adjust the
# temperature down, and increase to adjust up
-factor = 0.8
+factor = 2.25
cpu_temps = [get_cpu_temperature()] * 5
-#!/usr/bin/env python
+#!/usr/bin/env python3
import time
import colorsys
from PIL import Image
from PIL import ImageDraw
from PIL import ImageFont
+from fonts.ttf import RobotoMedium as UserFont
import logging
logging.basicConfig(
# Set up canvas and font
img = Image.new('RGB', (WIDTH, HEIGHT), color=(0, 0, 0))
draw = ImageDraw.Draw(img)
-path = os.path.dirname(os.path.realpath(__file__))
-font = ImageFont.truetype(path + "/fonts/Asap/Asap-Bold.ttf", 20)
+font_size = 20
+font = ImageFont.truetype(UserFont, font_size)
message = ""
# Tuning factor for compensation. Decrease this number to adjust the
# temperature down, and increase to adjust up
-factor = 0.8
+factor = 2.25
cpu_temps = [get_cpu_temperature()] * 5
-#!/usr/bin/env python
+#!/usr/bin/env python3
import time
import colorsys
from PIL import Image
from PIL import ImageDraw
from PIL import ImageFont
+from fonts.ttf import RobotoMedium as UserFont
import logging
logging.basicConfig(
# Set up canvas and font
img = Image.new('RGB', (WIDTH, HEIGHT), color=(0, 0, 0))
draw = ImageDraw.Draw(img)
-path = os.path.dirname(os.path.realpath(__file__))
-font = ImageFont.truetype(path + "/fonts/Asap/Asap-Bold.ttf", 20)
-smallfont = ImageFont.truetype(path + "/fonts/Asap/Asap-Bold.ttf", 10)
+font_size_small = 10
+font_size_large = 20
+font = ImageFont.truetype(UserFont, font_size_large)
+smallfont = ImageFont.truetype(UserFont, font_size_small)
x_offset = 2
y_offset = 2
draw.rectangle((0, 0, WIDTH, HEIGHT), (0, 0, 0))
column_count = 2
row_count = (len(variables)/column_count)
- for i in xrange(len(variables)):
+ for i in range(len(variables)):
variable = variables[i]
data_value = values[variable][-1]
unit = units[i]
message = "{}: {:.1f} {}".format(variable[:4], data_value, unit)
lim = limits[i]
rgb = palette[0]
- for j in xrange(len(lim)):
+ for j in range(len(lim)):
if data_value > lim[j]:
rgb = palette[j+1]
draw.text((x, y), message, font=smallfont, fill=rgb)
# Tuning factor for compensation. Decrease this number to adjust the
# temperature down, and increase to adjust up
-factor = 1.95
+factor = 2.25
cpu_temps = [get_cpu_temperature()] * 5
-#!/usr/bin/env python
+#!/usr/bin/env python3
import time
from bme280 import BME280
# Tuning factor for compensation. Decrease this number to adjust the
# temperature down, and increase to adjust up
-factor = 0.8
+factor = 2.25
cpu_temps = [get_cpu_temperature()] * 5
+++ /dev/null
-Copyright 2016 The Asap Project Authors (omnibus.type@gmail.com)\r
-\r
-This Font Software is licensed under the SIL Open Font License, Version 1.1.\r
-This license is copied below, and is also available with a FAQ at:\r
-http://scripts.sil.org/OFL\r
-\r
-\r
------------------------------------------------------------\r
-SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007\r
------------------------------------------------------------\r
-\r
-PREAMBLE\r
-The goals of the Open Font License (OFL) are to stimulate worldwide\r
-development of collaborative font projects, to support the font creation\r
-efforts of academic and linguistic communities, and to provide a free and\r
-open framework in which fonts may be shared and improved in partnership\r
-with others.\r
-\r
-The OFL allows the licensed fonts to be used, studied, modified and\r
-redistributed freely as long as they are not sold by themselves. The\r
-fonts, including any derivative works, can be bundled, embedded, \r
-redistributed and/or sold with any software provided that any reserved\r
-names are not used by derivative works. The fonts and derivatives,\r
-however, cannot be released under any other type of license. The\r
-requirement for fonts to remain under this license does not apply\r
-to any document created using the fonts or their derivatives.\r
-\r
-DEFINITIONS\r
-"Font Software" refers to the set of files released by the Copyright\r
-Holder(s) under this license and clearly marked as such. This may\r
-include source files, build scripts and documentation.\r
-\r
-"Reserved Font Name" refers to any names specified as such after the\r
-copyright statement(s).\r
-\r
-"Original Version" refers to the collection of Font Software components as\r
-distributed by the Copyright Holder(s).\r
-\r
-"Modified Version" refers to any derivative made by adding to, deleting,\r
-or substituting -- in part or in whole -- any of the components of the\r
-Original Version, by changing formats or by porting the Font Software to a\r
-new environment.\r
-\r
-"Author" refers to any designer, engineer, programmer, technical\r
-writer or other person who contributed to the Font Software.\r
-\r
-PERMISSION & CONDITIONS\r
-Permission is hereby granted, free of charge, to any person obtaining\r
-a copy of the Font Software, to use, study, copy, merge, embed, modify,\r
-redistribute, and sell modified and unmodified copies of the Font\r
-Software, subject to the following conditions:\r
-\r
-1) Neither the Font Software nor any of its individual components,\r
-in Original or Modified Versions, may be sold by itself.\r
-\r
-2) Original or Modified Versions of the Font Software may be bundled,\r
-redistributed and/or sold with any software, provided that each copy\r
-contains the above copyright notice and this license. These can be\r
-included either as stand-alone text files, human-readable headers or\r
-in the appropriate machine-readable metadata fields within text or\r
-binary files as long as those fields can be easily viewed by the user.\r
-\r
-3) No Modified Version of the Font Software may use the Reserved Font\r
-Name(s) unless explicit written permission is granted by the corresponding\r
-Copyright Holder. This restriction only applies to the primary font name as\r
-presented to the users.\r
-\r
-4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font\r
-Software shall not be used to promote, endorse or advertise any\r
-Modified Version, except to acknowledge the contribution(s) of the\r
-Copyright Holder(s) and the Author(s) or with their explicit written\r
-permission.\r
-\r
-5) The Font Software, modified or unmodified, in part or in whole,\r
-must be distributed entirely under this license, and must not be\r
-distributed under any other license. The requirement for fonts to\r
-remain under this license does not apply to any document created\r
-using the Font Software.\r
-\r
-TERMINATION\r
-This license becomes null and void if any of the above conditions are\r
-not met.\r
-\r
-DISCLAIMER\r
-THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF\r
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT\r
-OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE\r
-COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,\r
-INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL\r
-DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\r
-FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM\r
-OTHER DEALINGS IN THE FONT SOFTWARE.\r
-#!/usr/bin/env python
+#!/usr/bin/env python3
import time
from enviroplus import gas
-#!/usr/bin/env python
+#!/usr/bin/env python3
import ST7735
from PIL import Image, ImageDraw, ImageFont
+from fonts.ttf import RobotoMedium as UserFont
import logging
logging.basicConfig(
# Text settings.
font_size = 25
-font = ImageFont.truetype("fonts/Asap/Asap-Bold.ttf", font_size)
+font = ImageFont.truetype(UserFont, font_size)
text_colour = (255, 255, 255)
back_colour = (0, 170, 170)
-#!/usr/bin/env python
+#!/usr/bin/env python3
import time
import logging
-#!/usr/bin/env python
+#!/usr/bin/env python3
import requests
import ST7735
from pms5003 import PMS5003, ReadTimeoutError
from subprocess import PIPE, Popen, check_output
from PIL import Image, ImageDraw, ImageFont
+from fonts.ttf import RobotoMedium as UserFont
try:
from smbus2 import SMBus
def get_cpu_temperature():
process = Popen(['vcgencmd', 'measure_temp'], stdout=PIPE, universal_newlines=True)
output, _error = process.communicate()
- output = output.decode()
return float(output[output.index('=') + 1:output.rindex("'")])
# Compensation factor for temperature
-comp_factor = 1.2
+comp_factor = 2.25
# Raspberry Pi ID to send to Luftdaten
id = "raspi-" + get_serial_number()
# Text settings
font_size = 16
-font = ImageFont.truetype("fonts/Asap/Asap-Bold.ttf", font_size)
+font = ImageFont.truetype(UserFont, font_size)
# Display Raspberry Pi serial and Wi-Fi status
print("Raspberry Pi serial: {}".format(get_serial_number()))
-#!/usr/bin/env python
+#!/usr/bin/env python3
import time
from pms5003 import PMS5003, ReadTimeoutError
#!/usr/bin/env python3
+import os
import time
import numpy
import colorsys
from ltr559 import LTR559
import pytz
-from astral import Astral
+from astral.geocoder import database, lookup
+from astral.sun import sun
from datetime import datetime, timedelta
try:
"""Calculate the progress through the current sun/moon period (i.e day or
night) from the last sunrise or sunset, given a datetime object 't'."""
- a = Astral()
- city = a[city_name]
+ city = lookup(city_name, database())
# Datetime objects for yesterday, today, tomorrow
today = dt.date()
tomorrow = today + timedelta(1)
# Sun objects for yesterfay, today, tomorrow
- sun_yesterday = city.sun(date=yesterday, local=True)
- sun = city.sun(date=today, local=True)
- sun_tomorrow = city.sun(date=tomorrow, local=True)
+ sun_yesterday = sun(city.observer, date=yesterday)
+ sun_today = sun(city.observer, date=today)
+ sun_tomorrow = sun(city.observer, date=tomorrow)
# Work out sunset yesterday, sunrise/sunset today, and sunrise tomorrow
sunset_yesterday = sun_yesterday["sunset"]
- sunrise_today = sun["sunrise"]
- sunset_today = sun["sunset"]
+ sunrise_today = sun_today["sunrise"]
+ sunset_today = sun_today["sunset"]
sunrise_tomorrow = sun_tomorrow["sunrise"]
# Work out lengths of day or night period and progress through period
bus = SMBus(1)
bme280 = BME280(i2c_dev=bus)
-min_temp = bme280.get_temperature()
-max_temp = bme280.get_temperature()
+min_temp = None
+max_temp = None
factor = 2.25
cpu_temps = [get_cpu_temperature()] * 5
interval = 1
trend = "-"
+# Keep track of time elapsed
+start_time = time.time()
+
while True:
+ path = os.path.dirname(os.path.realpath(__file__))
dt = datetime.now()
-# dt += timedelta(minutes=5)
progress, period, day = sun_moon_time(dt, city_name, time_zone)
background = draw_background(progress, period, day)
# Time.
+ time_elapsed = time.time() - start_time
date_string = dt.strftime("%d %b %y").lstrip('0')
time_string = dt.strftime("%H:%M")
img = overlay_text(background, (0 + margin, 0 + margin), time_string, font_lg)
avg_cpu_temp = sum(cpu_temps) / float(len(cpu_temps))
corr_temperature = temperature - ((avg_cpu_temp - temperature) / factor)
- if corr_temperature < min_temp:
- min_temp = corr_temperature
- elif corr_temperature > max_temp:
- max_temp = corr_temperature
+ if time_elapsed > 30:
+ if min_temp is not None and max_temp is not None:
+ if corr_temperature < min_temp:
+ min_temp = corr_temperature
+ elif corr_temperature > max_temp:
+ max_temp = corr_temperature
+ else:
+ min_temp = corr_temperature
+ max_temp = corr_temperature
temp_string = f"{corr_temperature:.0f}°C"
img = overlay_text(img, (68, 18), temp_string, font_lg, align_right=True)
spacing = font_lg.getsize(temp_string)[1] + 1
- range_string = f"{min_temp:.0f}-{max_temp:.0f}"
+ if min_temp is not None and max_temp is not None:
+ range_string = f"{min_temp:.0f}-{max_temp:.0f}"
+ else:
+ range_string = "------"
img = overlay_text(img, (68, 18 + spacing), range_string, font_sm, align_right=True, rectangle=True)
- temp_icon = Image.open("icons/temperature.png")
+ temp_icon = Image.open(path + "/icons/temperature.png")
img.paste(temp_icon, (margin, 18), mask=temp_icon)
# Humidity
spacing = font_lg.getsize(humidity_string)[1] + 1
humidity_desc = describe_humidity(corr_humidity).upper()
img = overlay_text(img, (68, 48 + spacing), humidity_desc, font_sm, align_right=True, rectangle=True)
- humidity_icon = Image.open("icons/humidity-" + humidity_desc.lower() + ".png")
+ humidity_icon = Image.open(path + "/icons/humidity-" + humidity_desc.lower() + ".png")
img.paste(humidity_icon, (margin, 48), mask=humidity_icon)
# Light
spacing = font_lg.getsize(light_string.replace(",", ""))[1] + 1
light_desc = describe_light(light).upper()
img = overlay_text(img, (WIDTH - margin - 1, 18 + spacing), light_desc, font_sm, align_right=True, rectangle=True)
- light_icon = Image.open("icons/bulb-" + light_desc.lower() + ".png")
+ light_icon = Image.open(path + "/icons/bulb-" + light_desc.lower() + ".png")
img.paste(humidity_icon, (80, 18), mask=light_icon)
# Pressure
pressure_desc = describe_pressure(mean_pressure).upper()
spacing = font_lg.getsize(pressure_string.replace(",", ""))[1] + 1
img = overlay_text(img, (WIDTH - margin - 1, 48 + spacing), pressure_desc, font_sm, align_right=True, rectangle=True)
- pressure_icon = Image.open("icons/weather-" + pressure_desc.lower() + ".png")
+ pressure_icon = Image.open(path + "/icons/weather-" + pressure_desc.lower() + ".png")
img.paste(pressure_icon, (80, 48), mask=pressure_icon)
# Display image
-#!/usr/bin/env python
+#!/usr/bin/env python3
import time
from bme280 import BME280
ltr559
st7735
ads1015
+ fonts
+ font-roboto
+ astral
+ pytz
[flake8]
exclude =
setup(
packages=['enviroplus'],
- install_requires=['setuptools>={}'.format(minimum_version), 'pimoroni-bme280', 'pms5003', 'ltr559', 'st7735', 'ads1015']
+ install_requires=['setuptools>={}'.format(minimum_version), 'pimoroni-bme280', 'pms5003', 'ltr559', 'st7735', 'ads1015', 'fonts', 'font-roboto', 'astral', 'pytz']
)