@@ -34,11 +34,12 @@ class Mode(Enum):
3434
3535
3636class Fluepdot :
37- def __init__ (self , baseURL : str , width : int = 115 , height : int = 16 ):
37+ def __init__ (self , baseURL : str , width : int = 115 , height : int = 16 , flipped : bool = False ):
3838 self .baseURL = baseURL
3939 self .width = width
4040 self .height = height
4141 self .fonts : Optional [List [str ]] = None
42+ self .flipped : bool = flipped
4243
4344 def set_url (self , url : str ):
4445 self .baseURL = url
@@ -60,9 +61,14 @@ def get_size(self) -> tuple[int, int]:
6061
6162 def get_frame (self ) -> List [str ]:
6263 r = self ._get (frameURL )
63- return r .text .split ('\n ' )
64+ if self .flipped :
65+ return r .text [- 2 ::- 1 ].split ('\n ' )
66+ return r .text .split ('\n ' )[:- 1 ]
6467
6568 def get_pixel (self , x : int = 0 , y : int = 0 ) -> bool | None :
69+ if self .flipped :
70+ y = self .height - 1 - y
71+ x = self .width - 1 - x
6672 r = self ._get (pixelURL , get = {"x" : x , "y" : y })
6773 rtn = True if r .text == "X" else False if r .text == " " else None
6874 return rtn
@@ -77,6 +83,9 @@ def get_mode(self) -> Mode:
7783 return Mode (int (r .text ))
7884
7985 def post_text (self , text : str , x : int = 0 , y : int = 0 , font : str = "DejaVuSans12" ) -> Response :
86+ if self .flipped :
87+ self ._post (textURL , get = {"x" : x , "y" : y , "font" : font }, post = text )
88+ return self .post_frame_raw (frame = "\n " .join (self .get_frame ())+ "\n " )
8089 return self ._post (textURL , get = {"x" : x , "y" : y , "font" : font }, post = text )
8190
8291 def post_frame_raw (self , frame : str ) -> Response :
@@ -139,10 +148,18 @@ def post_frame(self, frame: List[List[bool]], center: bool = False) -> Response:
139148
140149
141150 def set_pixel (self , x : int = 0 , y : int = 0 ) -> Response :
151+ y = self .height - 1 - y
152+ if self .flipped :
153+ x = self .width - 1 - x
154+ y = self .height - 1 - y
142155 return self ._post (pixelURL , get = {"x" : x , "y" : y })
143156
144157
145158 def unset_pixel (self , x : int = 0 , y : int = 0 ) -> Response :
159+ y = self .height - 1 - y
160+ if self .flipped :
161+ y = self .height - 1 - y
162+ x = self .width - 1 - x
146163 return self ._delete (pixelURL , get = {"x" : x , "y" : y })
147164
148165 def set_mode (self , mode : Mode = Mode .FULL ) -> Response :
0 commit comments