示例#1
0
def MakeEFramePicture(epaperserverip="127.0.0.1"):

    #epd = epd7in5b.EPD()
    epd = epd7in5b.EPD(epaperserverip)

    #epd.init()
    #print("Clear...")
    #epd.Clear(0xFF)
    #epd.sleep()

    w = OpenWeatherMap("/var/ram")
    w.FromAuto()

    plugins = [
        (EFrameCalendar(), 0, 0),
        (EFrameTemperature(w), 0, 250),
        (EFrameWeather(w), 0, 565),
        (EFrameClock(), 366, 5),  #366, 640),
    ]

    #HBlackImage = Image.open('..\pic\cat.bmp')
    #HBlackImage = Image.open('..\pic\kettle.bmp')
    #HBlackImage = Image.open('..\pic\jun1_1979_black.bmp')
    #HRedImage = Image.open('..\pic\jun1_1979_red.bmp')

    HBlackImage = Image.new('1', (epd7in5b.EPD_HEIGHT, epd7in5b.EPD_WIDTH),
                            255)
    HRedImage = Image.new('1', (epd7in5b.EPD_HEIGHT, epd7in5b.EPD_WIDTH), 255)

    for (p, x, y) in plugins:
        p.SetPaper(HBlackImage, HRedImage)
        p.Paint(x, y, epd7in5b.EPD_HEIGHT, epd7in5b.EPD_WIDTH, None)

    HBlackImage = HBlackImage.transpose(Image.ROTATE_270)
    HRedImage = HRedImage.transpose(Image.ROTATE_270)

    #try:

    print("EPD Init...")
    epd.init()
    print("EPD Display...")
    epd.display(epd.getbuffer(HBlackImage), epd.getbuffer(HRedImage))
    print("EPD Sleep...")
    epd.sleep()
log = Logger('logChecker.txt')

log.lprint("WeatherDataChecker --- START")

if not os.path.exists(file_path+'wettercomDump.pkl'):
    log.lprint("dump files missing! - quit!")
    quit()

#--------------
# setup weather API for current weather data
#--------------
log.lprint("set up weather APIs")
conf = APIConfig()
conf.loadFromFile(file_path+'openweathermap.conf')
owm = OpenWeatherMap(conf)
fio = ForecastIOAPI(conf)
wcom = WetterCom(conf)

#--------------
# get weather data
#--------------
log.lprint("get current weather")
owm.getCurrentData()
current_data = dm.WeatherSamplePoint(owm.current_weather.date, owm.current_weather.time)
current_data.copyData(owm.current_weather)

#--------------
# load time series data from file
#--------------
log.lprint("load time series data")
示例#3
0
    import epd7in5b_sock as epd7in5b
    from PIL import Image,ImageDraw,ImageFont
    import PIL.ImageOps 

    HOST = "127.0.0.1"
    #HOST = "192.168.0.30"
    epd = epd7in5b.EPD(HOST)


    print("Image size %i,%i" % (epd7in5b.EPD_HEIGHT,epd7in5b.EPD_WIDTH))

    HBlackImage = Image.new('1', ( epd7in5b.EPD_HEIGHT,epd7in5b.EPD_WIDTH), 255)  
    HRedImage = Image.new('1', (epd7in5b.EPD_HEIGHT,epd7in5b.EPD_WIDTH), 255)  
    
    w = OpenWeatherMap()
    w.FromAuto()


    t = EFrameTemperature(w)
    t.SetPaper( HBlackImage, HRedImage)

    t.Paint( 0,0,epd7in5b.EPD_HEIGHT, epd7in5b.EPD_WIDTH, None)



    HBlackImage = HBlackImage.transpose(Image.ROTATE_270)
    HRedImage = HRedImage.transpose(Image.ROTATE_270)
        
        
    print("Init...")
示例#4
0
from flask import Flask, render_template, request
from openweathermap import OpenWeatherMap
from capteur import Capteur

app = Flask(__name__)

meteo = OpenWeatherMap()
sense= Capteur()
PORT=8080

#
@app.route('/', methods=['GET'])
def home():
    sense.mesure()
    sense.get_cpu_temp()
    sense.renderText(str(sense.datas.get("temperature")))
    return render_template("home.html",datas=sense.datas)

#
@app.route('/weather', methods=['GET','POST'])
def weather():
    
    if request.method=="POST":
        city=request.form.get("city")
        if city is not None:
            if meteo.fetchDatas(city):
                # print(meteo.datas.get("name"))
                # print(meteo.datas.get("temperature"))
                # print(meteo.datas.get("pressure"))
                # print(meteo.datas.get("humidity"))
                # print(meteo.datas.get("description"))
#--------------
# setup weather APIs
#--------------
log.lprint("setup weather APIs")
if not os.path.exists(file_path+'openweathermap.conf'):
    log.lprint("conf files missing!")
    quit()

conf = APIConfig()
conf.loadFromFile(file_path+'wettercom.conf')
wCom = WetterCom(conf)

conf2 = APIConfig()
conf2.loadFromFile(file_path+'openweathermap.conf')
owm = OpenWeatherMap(conf2)

conf3 = APIConfig()
conf3.loadFromFile(file_path+'forecastio.conf')
fio = ForecastIOAPI(conf3)

#--------------
# get forecasts
#--------------
log.lprint("get forecasts")
wCom.get_forecast()
owm.get_forecast()
fio.get_forecast()

#--------------
# get time series
log = Logger('logChecker.txt')

log.lprint("WeatherDataChecker --- START")

if not os.path.exists(file_path + 'wettercomDump.pkl'):
    log.lprint("dump files missing! - quit!")
    quit()

#--------------
# setup weather API for current weather data
#--------------
log.lprint("set up weather APIs")
conf = APIConfig()
conf.loadFromFile(file_path + 'openweathermap.conf')
owm = OpenWeatherMap(conf)
fio = ForecastIOAPI(conf)
wcom = WetterCom(conf)

#--------------
# get weather data
#--------------
log.lprint("get current weather")
owm.getCurrentData()
current_data = dm.WeatherSamplePoint(owm.current_weather.date,
                                     owm.current_weather.time)
current_data.copyData(owm.current_weather)

#--------------
# load time series data from file
#--------------
示例#7
0
    HOST = "127.0.0.1"
    epd = epd7in5b.EPD(HOST)

    HBlackimage = Image.new('1', (epd7in5b.EPD_HEIGHT, epd7in5b.EPD_WIDTH),
                            255)
    HRedimage = Image.new('1', (epd7in5b.EPD_HEIGHT, epd7in5b.EPD_WIDTH), 255)
    df = DrawWeather(HBlackimage, HRedimage)

    print("OpenWeatherMap TEST")

    #t = datetime.datetime.now()
    #print(t)

    print("---")

    w = OpenWeatherMap()

    w.FromFile("openweathermap.json")

    #w.FromWWW("openweathermap.json")

    w.PrintAll()
    print("---")

    #fut = t + datetime.timedelta(hours=2)
    #f = w.Get(fut)
    #f.Print()

    df.Draw(550, w)

    HBlackimage = HBlackimage.transpose(Image.ROTATE_270)