|
2 | 2 | Small library to interact with a fluepdot controlled display |
3 | 3 | https://fluepdot.readthedocs.io/en/latest/ |
4 | 4 |
|
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!") |
6 | 9 |
|
7 | 10 | Currently there is no support for changing the timings. |
8 | 11 | """ |
|
11 | 14 | from requests import Response |
12 | 15 | from enum import Enum |
13 | 16 | from typing import Any, Dict, Optional, List |
| 17 | +from time import sleep |
14 | 18 |
|
15 | 19 | GetParam = Dict[str, Any] |
16 | 20 | PostParam = str |
@@ -91,6 +95,42 @@ def post_text(self, text: str, x: int = 0, y: int = 0, font: str = "DejaVuSans12 |
91 | 95 | def post_frame_raw(self, frame: str) -> Response: |
92 | 96 | return self._post(frameURL, post=frame) |
93 | 97 |
|
| 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 | + |
94 | 134 | def post_frame(self, frame: List[List[bool]], center: bool = False) -> Response: |
95 | 135 | data: List[List[str]] = [[" "] * self.width for _ in range(self.height)] |
96 | 136 | x_offset: int = 0 |
|
0 commit comments