@@ -30,11 +30,12 @@ class Mode(Enum):
3030
3131
3232class Fluepdot :
33- def __init__ (self , baseURL : str , width : int = 115 , height : int = 16 ):
33+ def __init__ (self , baseURL : str , width : int = 115 , height : int = 16 , flipped : bool = False ):
3434 self .baseURL = baseURL
3535 self .width = width
3636 self .height = height
3737 self .fonts : Optional [List [str ]] = None
38+ self .flipped : bool = flipped
3839
3940 def set_url (self , url : str ):
4041 self .baseURL = url
@@ -56,9 +57,14 @@ def get_size(self) -> tuple[int, int]:
5657
5758 def get_frame (self ) -> List [str ]:
5859 r = self ._get (frameURL )
59- return r .text .split ('\n ' )
60+ if self .flipped :
61+ return r .text [- 2 ::- 1 ].split ('\n ' )
62+ return r .text .split ('\n ' )[:- 1 ]
6063
6164 def get_pixel (self , x : int = 0 , y : int = 0 ) -> bool | None :
65+ if self .flipped :
66+ y = self .height - 1 - y
67+ x = self .width - 1 - x
6268 r = self ._get (pixelURL , get = {"x" : x , "y" : y })
6369 rtn = True if r .text == "X" else False if r .text == " " else None
6470 return rtn
@@ -73,6 +79,9 @@ def get_mode(self) -> Mode:
7379 return Mode (int (r .text ))
7480
7581 def post_text (self , text : str , x : int = 0 , y : int = 0 , font : str = "DejaVuSans12" ) -> Response :
82+ if self .flipped :
83+ self ._post (textURL , get = {"x" : x , "y" : y , "font" : font }, post = text )
84+ return self .post_frame_raw (frame = "\n " .join (self .get_frame ())+ "\n " )
7685 return self ._post (textURL , get = {"x" : x , "y" : y , "font" : font }, post = text )
7786
7887 def post_frame_raw (self , frame : str ) -> Response :
@@ -98,9 +107,17 @@ def post_frame(self, frame: List[List[bool]], center: bool = False) -> Response:
98107 return self ._post (frameURL , post = outStr )
99108
100109 def set_pixel (self , x : int = 0 , y : int = 0 ) -> Response :
110+ y = self .height - 1 - y
111+ if self .flipped :
112+ x = self .width - 1 - x
113+ y = self .height - 1 - y
101114 return self ._post (pixelURL , get = {"x" : x , "y" : y })
102115
103116 def unset_pixel (self , x : int = 0 , y : int = 0 ) -> Response :
117+ y = self .height - 1 - y
118+ if self .flipped :
119+ y = self .height - 1 - y
120+ x = self .width - 1 - x
104121 return self ._delete (pixelURL , get = {"x" : x , "y" : y })
105122
106123 def set_mode (self , mode : Mode = Mode .FULL ) -> Response :
0 commit comments