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):
252
252
mcp .output (7 , not color & 0x02 )
253
253
mcp .output (8 , not color & 0x04 )
254
254
255
+ def buttonPressed (self , buttonname ):
256
+ if (buttonname > self .LEFT ):
257
+ return false
258
+
259
+ return not mcp .input (buttonname )
260
+
255
261
256
262
if __name__ == '__main__' :
257
263
@@ -268,19 +274,19 @@ def backlight(self, color):
268
274
lcd .message ("Adafruit RGB LCD\n Plate w/Keypad!" )
269
275
sleep (1 )
270
276
while 1 :
271
- if (not mcp . input (lcd .LEFT )):
277
+ if (lcd . buttonPressed (lcd .LEFT )):
272
278
lcd .backlight (lcd .RED )
273
279
274
- if (not mcp . input (lcd .UP )):
280
+ if (lcd . buttonPressed (lcd .UP )):
275
281
lcd .backlight (lcd .BLUE )
276
282
277
- if (not mcp . input (lcd .DOWN )):
283
+ if (lcd . buttonPressed (lcd .DOWN )):
278
284
lcd .backlight (lcd .GREEN )
279
285
280
- if (not mcp . input (lcd .RIGHT )):
286
+ if (lcd . buttonPressed (lcd .RIGHT )):
281
287
lcd .backlight (lcd .VIOLET )
282
288
283
- if (not mcp . input (lcd .SELECT )):
289
+ if (lcd . buttonPressed (lcd .SELECT )):
284
290
lcd .backlight (lcd .ON )
285
291
286
292
You can’t perform that action at this time.
0 commit comments