Skip to content

Commit 7e0c53a

Browse files
committed
pylint tweaks for pi_keyboard.pi
1 parent 4d76de8 commit 7e0c53a

File tree

1 file changed

+26
-15
lines changed

1 file changed

+26
-15
lines changed

examples/pi_keyboard.py

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -57,27 +57,38 @@
5757
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
5858
# THE SOFTWARE.
5959

60-
import adafruit_mpr121
61-
import board
62-
import busio
6360
import logging
6461
import subprocess
6562
import time
63+
import board
64+
import busio
6665
import uinput
66+
import adafruit_mpr121
6767

6868
# Define mapping of capacitive touch pin presses to keyboard button presses.
69+
70+
# Each line here should define a dict entry that maps the capacitive touch
71+
# input number to an appropriate key press.
72+
#
73+
# For reference the list of possible uinput.KEY_* values you can specify is
74+
# defined in linux/input.h:
75+
# http://www.cs.fsu.edu/~baker/devices/lxr/http/source/linux/include/linux/input.h?v=2.6.11.8
76+
#
77+
# Make sure a cap touch input is defined only once or else the program will
78+
# fail to run!
79+
6980
KEY_MAPPING = {
70-
0: uinput.KEY_UP, # Each line here should define a dict entry
71-
1: uinput.KEY_DOWN, # that maps the capacitive touch input number
72-
2: uinput.KEY_LEFT, # to an appropriate key press.
73-
3: uinput.KEY_RIGHT, #
74-
4: uinput.KEY_B, # For reference the list of possible uinput.KEY_*
75-
5: uinput.KEY_A, # values you can specify is defined in linux/input.h:
76-
6: uinput.KEY_ENTER, # http://www.cs.fsu.edu/~baker/devices/lxr/http/source/linux/include/linux/input.h?v=2.6.11.8
77-
7: uinput.KEY_SPACE, #
78-
} # Make sure a cap touch input is defined only
79-
# once or else the program will fail to run!
81+
0: uinput.KEY_UP,
82+
1: uinput.KEY_DOWN,
83+
2: uinput.KEY_LEFT,
84+
3: uinput.KEY_RIGHT,
85+
4: uinput.KEY_B,
86+
5: uinput.KEY_A,
87+
6: uinput.KEY_ENTER,
88+
7: uinput.KEY_SPACE,
89+
}
8090

91+
# Sleep this long between polling for events:
8192
EVENT_WAIT_SLEEP_SECONDS = 0.25
8293

8394
# Uncomment to enable debug message logging (might slow down key detection).
@@ -103,7 +114,7 @@
103114
# Call is_touched and pass it then number of the input. If it's touched
104115
# it will return True, otherwise it will return False.
105116
if mpr121[pin].value:
106-
logging.debug('Input {0} touched!'.format(pin))
107-
logging.debug('Key: {}'.format(key))
117+
logging.debug('Input %i touched!', pin)
118+
logging.debug('Key: %s', key)
108119
device.emit_click(key)
109120
time.sleep(EVENT_WAIT_SLEEP_SECONDS) # Small delay to keep from spamming output messages.

0 commit comments

Comments
 (0)