@@ -220,7 +220,7 @@ def _hello(self):
220220 response = '' .join (
221221 filter (lambda x : x in set (string .printable ), str (self .serial_read (23 ).decode (errors = "ignore" ))))
222222 self .serial_flush_input ()
223- logger .debug ("Display ID returned: %s" % response )
223+ logger .debug (f "Display ID returned: { response } " )
224224 while not response .startswith ("chs_" ):
225225 logger .warning ("Display returned invalid or unsupported ID, try again in 1 second" )
226226 time .sleep (1 )
@@ -232,13 +232,13 @@ def _hello(self):
232232
233233 # Note: ID returned by display are not reliable for some models e.g. 2.1" displays return "chs_5inch"
234234 # Rely on width/height for sub-revision detection
235- if self . display_width == 480 and self . display_height == 480 :
236- self . sub_revision = SubRevision .REV_2INCH
237- elif self . display_width == 480 and self . display_height == 800 :
238- self . sub_revision = SubRevision .REV_5INCH
239- elif self . display_width == 480 and self . display_height == 1920 :
240- self .sub_revision = SubRevision .REV_8INCH
241- else :
235+ sub_revisions = {
236+ ( 480 , 480 ): SubRevision .REV_2INCH ,
237+ ( 480 , 800 ): SubRevision . REV_5INCH ,
238+ ( 480 , 1920 ): SubRevision .REV_8INCH
239+ }
240+ self .sub_revision = sub_revisions . get (( self . display_width , self . display_height ), SubRevision .UNKNOWN )
241+ if self . sub_revision == SubRevision . UNKNOWN :
242242 logger .error (f"Unsupported resolution { self .display_width } x{ self .display_height } for revision C" )
243243
244244 # Detect ROM version
0 commit comments