-
Notifications
You must be signed in to change notification settings - Fork 84
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
make Composite screen with image and text #104
Conversation
Thanks for this. Do you have any description of how it works so that we can add it to the readme? |
What does the change on line 23 of textpos.py do? |
the change on textPos allow Composite to extend textPos Composite extend TextPos, so all textPos method are available (for text).
(sorry for my english,... ) |
So how would you use composite.py? And how would you use textpos.py now? Can you provide some specific examples to help us with testing? Thanks |
here some code i use : import forecastio
import time
from datetime import datetime
import numpy as np
import colorsys
import sys
from composite import Composite
class HourSet():
def __init__(self, tmax,tmin,t,p,icon):
self.tmax = tmax
self.tmin = tmin
self.t = t
self.p = p
self.icon = icon
api_key = "SOME_API_KEY_FROM_darksky.net"
lat = 47.34638
lng = 0.45873
wait = 1800
screen = Composite(False)
hour = dict()
hour[4] = HourSet(0,0,0,0,'clear')
hour[8] = HourSet(0,0,0,0,'clear')
hour[12] = HourSet(0,0,0,0,'clear')
screen.AddImage('./icons/'+hour[4].icon+'.bmp',0, 0,(50,50),'i'+str(4))
text4 = "Maintenant\n T:"+str(hour[4].t)+" \ P:"+str(hour[4].p)+"%"
screen.AddText(text4,50,0,20,'t'+str(4))
screen.AddImage('./icons/'+hour[8].icon+'.bmp',0, 60,(50,50),'i'+str(8))
text8 = "+6h\n T:"+str(hour[8].t)+" \ P:"+str(hour[8].p)+"%"
screen.AddText(text8,50,60,20,'t'+str(8))
screen.AddImage('./icons/'+hour[12].icon+'.bmp',0, 120,(50,50),'i'+str(12))
text12 = "+10h\n T:"+str(hour[12].t)+" \ P:"+str(hour[12].p)+"%"
screen.AddText(text12,50,120,20,'t'+str(12))
while True:
try:
temp = np.array([])
rain = 0
forecast = forecastio.load_forecast(api_key, lat, lng)
byHour = forecast.hourly()
compteurHour = 0
icon = byHour.data[0].icon
for hourlyData in byHour.data[:12]:
if(hourlyData.precipProbability > rain):
icon = hourlyData.icon
rain = round(hourlyData.precipProbability*100)
# rain.append(hourlyData.precipProbability)
temp = np.append(temp, hourlyData.temperature)
compteurHour = compteurHour + 1
if(compteurHour % 4 == 0):
hour[compteurHour].t = round(np.median(temp),1)
hour[compteurHour].tmax = tMax = round(temp.max(),1)
hour[compteurHour].tmin = tMax = round(temp.min(),1)
hour[compteurHour].p = rain
hour[compteurHour].icon = icon
temp = np.array([])
rain = 0
screen.UpdateImg('i'+str(4),'./icons/'+hour[4].icon+'.bmp')
text4 = "Maintenant\n T:"+str(hour[4].t)+" \ P:"+str(hour[4].p)+"%"
screen.UpdateText('t'+str(4),text4)
screen.UpdateImg('i'+str(8),'./icons/'+hour[8].icon+'.bmp')
text8 = "+6h\n T:"+str(hour[8].t)+" \ P:"+str(hour[8].p)+"%"
screen.UpdateText('t'+str(8),text8)
screen.UpdateImg('i'+str(12),'./icons/'+hour[12].icon+'.bmp')
text12 = "+10h\n T:"+str(hour[12].t)+" \ P:"+str(hour[12].p)+"%"
screen.UpdateText('t'+str(12),text12)
screen.WriteAll()
time.sleep(wait)
except KeyboardInterrupt:
screen.Clear();
sys.exit(-1) |
Ok thanks we will take a look at this in more detail next week.
Still struggling to see how it would be used exactly to say write an image
stored at /user/image.png and overlay that with the text "hello world"
Perhaps providing a more generic example lone that would help?
Can it be used from the command line at all?
Perhaps there could be a good way to combine papirus-write and papirus-draw
into one command later on.
…On 1 Apr 2017 3:14 pm, "PeuX" ***@***.***> wrote:
here some code i use :
i use an externalised composite and textPos (they are in my project folder
)
import forecastioimport timefrom datetime import datetimeimport numpy as npimport colorsysimport sysfrom composite import Composite
class HourSet():
def __init__(self, tmax,tmin,t,p,icon):
self.tmax = tmax
self.tmin = tmin
self.t = t
self.p = p
self.icon = icon
api_key = "SOME_API_KEY_FROM_darksky.net"
lat = 47.34638
lng = 0.45873
wait = 1800
screen = Composite(False)
hour = dict()
hour[4] = HourSet(0,0,0,0,'clear')
hour[8] = HourSet(0,0,0,0,'clear')
hour[12] = HourSet(0,0,0,0,'clear')
screen.AddImage('./icons/'+hour[4].icon+'.bmp',0, 0,(50,50),'i'+str(4))
text4 = "Maintenant\n T:"+str(hour[4].t)+" \ P:"+str(hour[4].p)+"%"
screen.AddText(text4,50,0,20,'t'+str(4))
screen.AddImage('./icons/'+hour[8].icon+'.bmp',0, 60,(50,50),'i'+str(8))
text8 = "+6h\n T:"+str(hour[8].t)+" \ P:"+str(hour[8].p)+"%"
screen.AddText(text8,50,60,20,'t'+str(8))
screen.AddImage('./icons/'+hour[12].icon+'.bmp',0, 120,(50,50),'i'+str(12))
text12 = "+10h\n T:"+str(hour[12].t)+" \ P:"+str(hour[12].p)+"%"
screen.AddText(text12,50,120,20,'t'+str(12))
while True:
try:
temp = np.array([])
rain = 0
forecast = forecastio.load_forecast(api_key, lat, lng)
byHour = forecast.hourly()
compteurHour = 0
icon = byHour.data[0].icon
for hourlyData in byHour.data[:12]:
if(hourlyData.precipProbability > rain):
icon = hourlyData.icon
rain = round(hourlyData.precipProbability*100)
# rain.append(hourlyData.precipProbability)
temp = np.append(temp, hourlyData.temperature)
compteurHour = compteurHour + 1
if(compteurHour % 4 == 0):
hour[compteurHour].t = round(np.median(temp),1)
hour[compteurHour].tmax = tMax = round(temp.max(),1)
hour[compteurHour].tmin = tMax = round(temp.min(),1)
hour[compteurHour].p = rain
hour[compteurHour].icon = icon
temp = np.array([])
rain = 0
screen.UpdateImg('i'+str(4),'./icons/'+hour[4].icon+'.bmp')
text4 = "Maintenant\n T:"+str(hour[4].t)+" \ P:"+str(hour[4].p)+"%"
screen.UpdateText('t'+str(4),text4)
screen.UpdateImg('i'+str(8),'./icons/'+hour[8].icon+'.bmp')
text8 = "+6h\n T:"+str(hour[8].t)+" \ P:"+str(hour[8].p)+"%"
screen.UpdateText('t'+str(8),text8)
screen.UpdateImg('i'+str(12),'./icons/'+hour[12].icon+'.bmp')
text12 = "+10h\n T:"+str(hour[12].t)+" \ P:"+str(hour[12].p)+"%"
screen.UpdateText('t'+str(12),text12)
screen.WriteAll()
time.sleep(wait)
except KeyboardInterrupt:
screen.Clear();
sys.exit(-1)
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#104 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/ADNCugZkANhoSa7SGi_NeKzJkxweytThks5rrlungaJpZM4MwauQ>
.
|
here some basic usage from papirus import PapirusComposite
screen = PapirusComposite()
screen.AddImage('./icons/rain.bmp',0, 0,(20,20),"img_weather")
screen.AddText("text rain",50,0,20,'txt_weather')
screen.UpdateImg("img_weather",'./icons/clear.bmp')
screen.UpdateText("txt_weather","text clear") For the command-line, i don't know how that work... |
Do you think it's possible to save the content as a temporary image and then rotate it by 180 degree? |
Hi @PeuX , really nice class!
Many thanks for your contribution! |
- Change papirus/composit.py to by more consistent whith textpos - add composite to __init__.py - provide demo in bin/papirus-composite-write (a really small demo)
Fantastic @PeuX , thanks. |
This doesn't work on current release. When will it be live? |
Could you be more specific? We pulled the code in last week and tested it.
…On 22 May 2017 17:21, "vanillabrand" ***@***.***> wrote:
This doesn't work on current release. When will it be live?
—
You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub
<#104 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/APUu19bAJJtRrabA-7TK_RjsXbThmofFks5r8bX1gaJpZM4MwauQ>
.
|
The PapirusComposite class inherits from PapirusTextPos. The code in the PapirusComposite init function requires the PapirusTextPos class to inherit from object (so called new class). |
@francesco-vannini did we test this? it is working ok now? |
this is an extended TextPos to create composite screen with image and text.
PapirusComposite exemple