File tree Expand file tree Collapse file tree 1 file changed +11
-5
lines changed Expand file tree Collapse file tree 1 file changed +11
-5
lines changed Original file line number Diff line number Diff line change @@ -252,6 +252,12 @@ def backlight(self, color):
252252 mcp .output (7 , not color & 0x02 )
253253 mcp .output (8 , not color & 0x04 )
254254
255+ def buttonPressed (self , buttonname ):
256+ if (buttonname > self .LEFT ):
257+ return false
258+
259+ return not mcp .input (buttonname )
260+
255261
256262if __name__ == '__main__' :
257263
@@ -268,19 +274,19 @@ def backlight(self, color):
268274 lcd .message ("Adafruit RGB LCD\n Plate w/Keypad!" )
269275 sleep (1 )
270276 while 1 :
271- if (not mcp . input (lcd .LEFT )):
277+ if (lcd . buttonPressed (lcd .LEFT )):
272278 lcd .backlight (lcd .RED )
273279
274- if (not mcp . input (lcd .UP )):
280+ if (lcd . buttonPressed (lcd .UP )):
275281 lcd .backlight (lcd .BLUE )
276282
277- if (not mcp . input (lcd .DOWN )):
283+ if (lcd . buttonPressed (lcd .DOWN )):
278284 lcd .backlight (lcd .GREEN )
279285
280- if (not mcp . input (lcd .RIGHT )):
286+ if (lcd . buttonPressed (lcd .RIGHT )):
281287 lcd .backlight (lcd .VIOLET )
282288
283- if (not mcp . input (lcd .SELECT )):
289+ if (lcd . buttonPressed (lcd .SELECT )):
284290 lcd .backlight (lcd .ON )
285291
286292
You can’t perform that action at this time.
0 commit comments