Skip to content

Commit 0ad40f3

Browse files
authored
Merge pull request #5 from KS-HTK/feature/scrollframe
Feature/scrollframe
2 parents f6a4d88 + d6dca06 commit 0ad40f3

1 file changed

Lines changed: 41 additions & 1 deletion

File tree

src/fluepdot/fluepdot.py

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22
Small library to interact with a fluepdot controlled display
33
https://fluepdot.readthedocs.io/en/latest/
44
5-
it should only be required to change the baseURL
5+
Usage:
6+
from fluepdot import Fluepdot
7+
fd = Fluepdot("http://module.local")
8+
fd.post_text("Hello World!")
69
710
Currently there is no support for changing the timings.
811
"""
@@ -11,6 +14,7 @@
1114
from requests import Response
1215
from enum import Enum
1316
from typing import Any, Dict, Optional, List
17+
from time import sleep
1418

1519
GetParam = Dict[str, Any]
1620
PostParam = str
@@ -91,6 +95,42 @@ def post_text(self, text: str, x: int = 0, y: int = 0, font: str = "DejaVuSans12
9195
def post_frame_raw(self, frame: str) -> Response:
9296
return self._post(frameURL, post=frame)
9397

98+
def post_scroll_frame_raw(self, frame: str, loop:bool or int=False, sleep_time:int=1) -> None:
99+
"""
100+
Parameters
101+
----------
102+
frame : str
103+
A " " and "X" encoded framestring exactly the length of and 16 lines high
104+
loop : bool or int, optional
105+
if int it will loop the frame with the given number of seperation spaces
106+
if bool:
107+
True: same as with loop=115
108+
False: will scroll the frame from right to left starting at blank and scrolling till blank
109+
sleep_time : int, optional
110+
The number of seconds to wait between steps, by default 1
111+
will be limited by the timing interval of the display
112+
"""
113+
def _extend_frame(line: str) -> str:
114+
return line+(" "*loop)+line[0:115]
115+
def _pad_frame(line: str) -> str:
116+
pad = " "*115
117+
return pad+line+pad
118+
119+
frame = frame.split("\n")
120+
length = len(frame[0])+loop if type(loop) == int else len(frame[0])+115
121+
122+
if type(loop) == int:
123+
frame = list(map(_extend_frame, frame))
124+
else:
125+
frame = list(map(_pad_frame, frame))
126+
127+
_run_once=True
128+
while loop or type(loop)==int or _run_once:
129+
_run_once=False
130+
for i in range(0, length, 2):
131+
self.post_frame_raw("\n".join(l[i:i+115] for l in frame))
132+
sleep(sleep_time)
133+
94134
def post_frame(self, frame: List[List[bool]], center: bool = False) -> Response:
95135
data: List[List[str]] = [[" "] * self.width for _ in range(self.height)]
96136
x_offset: int = 0

0 commit comments

Comments
 (0)