2022-08-11 12:46:36 +00:00
|
|
|
##
|
|
|
|
# @filename : main.cpp
|
|
|
|
# @brief : 7.5inch e-paper display demo
|
|
|
|
# @author : Yehui from Waveshare
|
|
|
|
#
|
|
|
|
# Copyright (C) Waveshare July 28 2017
|
|
|
|
#
|
|
|
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
# of this software and associated documnetation files (the "Software"), to deal
|
|
|
|
# in the Software without restriction, including without limitation the rights
|
|
|
|
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
# copies of the Software, and to permit persons to whom the Software is
|
|
|
|
# furished to do so, subject to the following conditions:
|
|
|
|
#
|
|
|
|
# The above copyright notice and this permission notice shall be included in
|
|
|
|
# all copies or substantial portions of the Software.
|
|
|
|
#
|
|
|
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
# FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
# LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
# THE SOFTWARE.
|
|
|
|
##
|
|
|
|
|
|
|
|
from datetime import datetime, timedelta
|
|
|
|
import io
|
|
|
|
import locale
|
|
|
|
import os.path
|
|
|
|
import time
|
|
|
|
|
|
|
|
locale.setlocale(locale.LC_ALL, 'fr_FR.UTF-8')
|
|
|
|
|
|
|
|
from PIL import Image, ImageDraw, ImageFont
|
|
|
|
|
|
|
|
def main():
|
|
|
|
image = Image.new('1', (480, 800), 255)
|
|
|
|
#image = Image.new('RGB', (480, 800), 'white')
|
|
|
|
draw = ImageDraw.Draw(image)
|
|
|
|
|
|
|
|
import modules
|
|
|
|
config = modules.Config()
|
|
|
|
|
|
|
|
# Weather
|
|
|
|
|
|
|
|
# Toolbar
|
|
|
|
from modules.weather import WeatherToolbarModule
|
|
|
|
image.paste(WeatherToolbarModule().draw_module(config, 480, 50), (0, 0))
|
|
|
|
|
|
|
|
# Current Weather
|
|
|
|
from modules.weather import WeatherJumboCurrentModule
|
|
|
|
image.paste(WeatherJumboCurrentModule().draw_module(config, 480, 150), (0, 50))
|
|
|
|
|
|
|
|
# rule
|
|
|
|
image.paste(modules.RuleModule().draw_module(config, 480, 1), (0, 192))
|
|
|
|
|
|
|
|
# pluie
|
|
|
|
from modules.weather import WeatherRainModule
|
|
|
|
image.paste(WeatherRainModule().draw_module(config, 480/2, 100), (0, 205))
|
|
|
|
|
|
|
|
# sunrise/moonrise
|
|
|
|
from modules.weather import WeatherSunMoonModule
|
|
|
|
image.paste(WeatherSunMoonModule().draw_module(config, int(480/2), 100), (int(480/2), 205))
|
|
|
|
|
|
|
|
# weekly weather
|
|
|
|
from modules.weather import WeeklyWeatherModule
|
|
|
|
image.paste(WeeklyWeatherModule().draw_module(config, int(480/1.6), 275), (480-int(480/1.6), 305))
|
|
|
|
|
2022-08-11 14:09:01 +00:00
|
|
|
# alerts
|
|
|
|
from modules.weather import WeatherAlertsModule
|
|
|
|
mod = WeatherAlertsModule().draw_module(config, 480, 200)
|
|
|
|
image.paste(mod, (0, 580-mod.height-5), mod)
|
|
|
|
|
2022-08-11 12:46:36 +00:00
|
|
|
# températures
|
|
|
|
from modules.weather import WeatherTemperatureModule
|
|
|
|
image.paste(WeatherTemperatureModule().draw_module(config, 480, 200), (0, 580))
|
|
|
|
|
|
|
|
fnt = ImageFont.truetype(config.fnt_R_path, 11)
|
|
|
|
draw.text(
|
|
|
|
(5, 798),
|
|
|
|
"Dernière génération le " + datetime.now().strftime("%c"),
|
|
|
|
fill="black", anchor="lb", font=fnt
|
|
|
|
)
|
|
|
|
|
|
|
|
try:
|
|
|
|
import epd7in5
|
|
|
|
|
|
|
|
epd = epd7in5.EPD()
|
|
|
|
epd.init()
|
|
|
|
print("initialized")
|
|
|
|
|
|
|
|
epd.display(epd.getbuffer(image))
|
|
|
|
|
|
|
|
print("time to sleep")
|
|
|
|
epd.sleep()
|
|
|
|
|
|
|
|
except:
|
|
|
|
image.save("screen.png")
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
main()
|