@@ -28,7 +28,7 @@ class Command:
2828 DISPLAY_BITMAP = 197
2929
3030
31- def SendReg (ser , cmd , x , y , ex , ey ):
31+ def SendReg (ser : serial . Serial , cmd : int , x : int , y : int , ex : int , ey : int ):
3232 byteBuffer = bytearray (6 )
3333 byteBuffer [0 ] = (x >> 2 )
3434 byteBuffer [1 ] = (((x & 3 ) << 6 ) + (y >> 4 ))
@@ -39,28 +39,28 @@ def SendReg(ser, cmd, x, y, ex, ey):
3939 ser .write (bytes (byteBuffer ))
4040
4141
42- def Reset (ser ):
42+ def Reset (ser : serial . Serial ):
4343 SendReg (ser , Command .RESET , 0 , 0 , 0 , 0 )
4444
4545
46- def Clear (ser ):
46+ def Clear (ser : serial . Serial ):
4747 SendReg (ser , Command .CLEAR , 0 , 0 , 0 , 0 )
4848
4949
50- def ScreenOff (ser ):
50+ def ScreenOff (ser : serial . Serial ):
5151 SendReg (ser , Command .SCREEN_OFF , 0 , 0 , 0 , 0 )
5252
5353
54- def ScreenOn (ser ):
54+ def ScreenOn (ser : serial . Serial ):
5555 SendReg (ser , Command .SCREEN_ON , 0 , 0 , 0 , 0 )
5656
5757
58- def SetBrightness (ser , level ):
58+ def SetBrightness (ser : serial . Serial , level : int ):
5959 # Level : 0 (brightest) - 255 (darkest)
6060 SendReg (ser , Command .SET_BRIGHTNESS , level , 0 , 0 , 0 )
6161
6262
63- def DisplayPILImage (ser , image , x , y ):
63+ def DisplayPILImage (ser : serial . Serial , image : Image , x : int , y : int ):
6464 image_height = image .size [1 ]
6565 image_width = image .size [0 ]
6666
@@ -89,17 +89,17 @@ def DisplayPILImage(ser, image, x, y):
8989 sleep (0.01 ) # Wait 10 ms after picture display
9090
9191
92- def DisplayBitmap (ser , bitmap_path , x = 0 , y = 0 ):
92+ def DisplayBitmap (ser : serial . Serial , bitmap_path : str , x = 0 , y = 0 ):
9393 image = Image .open (bitmap_path )
9494 DisplayPILImage (ser , image , x , y )
9595
9696
97- def DisplayText (ser , text , x = 0 , y = 0 ,
97+ def DisplayText (ser : serial . Serial , text : str , x = 0 , y = 0 ,
9898 font = "roboto/Roboto-Regular.ttf" ,
9999 font_size = 20 ,
100100 font_color = (0 , 0 , 0 ),
101101 background_color = (255 , 255 , 255 ),
102- background_image = None ):
102+ background_image : str = None ):
103103 # Convert text to bitmap using PIL and display it
104104 # Provide the background image path to display text with transparent background
105105
@@ -122,11 +122,12 @@ def DisplayText(ser, text, x=0, y=0,
122122 DisplayPILImage (ser , text_image , x , y )
123123
124124
125- def DisplayProgressBar (ser , x , y , width , height , min_value = 0 , max_value = 100 , value = 50 ,
125+ def DisplayProgressBar (ser : serial .Serial , x : int , y : int , width : int , height : int , min_value = 0 , max_value = 100 ,
126+ value = 50 ,
126127 bar_color = (0 , 0 , 0 ),
127128 bar_outline = True ,
128129 background_color = (255 , 255 , 255 ),
129- background_image = None ):
130+ background_image : str = None ):
130131 # Generate a progress bar and display it
131132 # Provide the background image path to display progress bar with transparent background
132133
0 commit comments