tuning
This commit is contained in:
parent
74abec0096
commit
863e07d89e
|
@ -13,10 +13,12 @@ class FlipdotSender(object):
|
||||||
C_BLACK = 0
|
C_BLACK = 0
|
||||||
C_WHITE = 255
|
C_WHITE = 255
|
||||||
|
|
||||||
def __init__(self, udphost, udpport, img_size=(80,16), font_size=11,
|
def __init__(self, udphost, udpport, img_size=(80,16), font_size=8, font_size_scroll=12,
|
||||||
font_offset1=(0,-2), font_offset2=(0,6),
|
font_offset1=(0,-1), font_offset2=(0,7),
|
||||||
font_family='/usr/share/fonts/gnu-free/FreeMono.ttf',
|
#font_family='/usr/share/fonts/gnu-free/FreeMono.ttf',
|
||||||
|
font_family='/usr/share/fonts/truetype/ttf-dejavu/DejaVuSansMono.ttf',
|
||||||
#font_family='/usr/share/fonts/truetype/freefont/FreeMono.ttf',
|
#font_family='/usr/share/fonts/truetype/freefont/FreeMono.ttf',
|
||||||
|
|
||||||
chars_per_line=11):
|
chars_per_line=11):
|
||||||
'''
|
'''
|
||||||
Constructor
|
Constructor
|
||||||
|
@ -28,6 +30,7 @@ class FlipdotSender(object):
|
||||||
self._udpport = udpport
|
self._udpport = udpport
|
||||||
self._img_size = img_size
|
self._img_size = img_size
|
||||||
self._font_size = font_size
|
self._font_size = font_size
|
||||||
|
self._font_size_scroll = font_size_scroll
|
||||||
self._font_offset1 = font_offset1
|
self._font_offset1 = font_offset1
|
||||||
self._font_offset2 = font_offset2
|
self._font_offset2 = font_offset2
|
||||||
self._font_family = font_family
|
self._font_family = font_family
|
||||||
|
@ -72,14 +75,14 @@ class FlipdotSender(object):
|
||||||
splitted_text = text.split("|")
|
splitted_text = text.split("|")
|
||||||
|
|
||||||
draw.text(self._font_offset1, splitted_text[0], font=font, fill=FlipdotSender.C_WHITE)
|
draw.text(self._font_offset1, splitted_text[0], font=font, fill=FlipdotSender.C_WHITE)
|
||||||
if not splitted_text[1] is None:
|
if len(splitted_text)>1:
|
||||||
draw.text(self._font_offset2, splitted_text[1], font=font, fill=FlipdotSender.C_WHITE)
|
draw.text(self._font_offset2, splitted_text[1], font=font, fill=FlipdotSender.C_WHITE)
|
||||||
|
|
||||||
self._send(image)
|
self._send(image)
|
||||||
|
|
||||||
def send_marquee(self, str, speed=3):
|
def send_marquee(self, str, speed=3):
|
||||||
offset = self._img_size[0]
|
offset = self._img_size[0]
|
||||||
font = ImageFont.truetype(self._font_family, self._font_size)
|
font = ImageFont.truetype(self._font_family, self._font_size_scroll)
|
||||||
|
|
||||||
while offset >= -font.getsize(str)[0]-speed:
|
while offset >= -font.getsize(str)[0]-speed:
|
||||||
image = Image.new("RGBA", self._img_size, FlipdotSender.C_BLACK)
|
image = Image.new("RGBA", self._img_size, FlipdotSender.C_BLACK)
|
||||||
|
|
|
@ -15,9 +15,15 @@ def on_message(client, userdata, msg):
|
||||||
|
|
||||||
if msg.topic == "raum2/flipdot/scroll":
|
if msg.topic == "raum2/flipdot/scroll":
|
||||||
payload = msg.payload.decode("utf-8")
|
payload = msg.payload.decode("utf-8")
|
||||||
speed = int(payload[0])
|
|
||||||
|
if (payload[0]).isdigit():
|
||||||
|
speed = int(payload[0])
|
||||||
|
text = payload[1:]
|
||||||
|
else:
|
||||||
|
speed = 3
|
||||||
|
text = payload
|
||||||
|
|
||||||
flipdot.send_marquee(payload[1:], speed)
|
flipdot.send_marquee(text, speed)
|
||||||
if msg.topic == "raum2/flipdot/text":
|
if msg.topic == "raum2/flipdot/text":
|
||||||
payload = msg.payload.decode("utf-8")
|
payload = msg.payload.decode("utf-8")
|
||||||
flipdot.send_text(payload)
|
flipdot.send_text(payload)
|
||||||
|
|
Loading…
Reference in New Issue