Skip to content
This repository was archived by the owner on Sep 30, 2019. It is now read-only.

Commit 2c9ffd7

Browse files
committed
Merge pull request #122 from gooligumelec/master
Added getKeys() method to read key presses recorded by HT16K33 keyscan
2 parents 5ca6809 + c6bbb56 commit 2c9ffd7

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

Adafruit_LEDBackpack/Adafruit_LEDBackpack.py

+9-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ class LEDBackpack:
1616
__HT16K33_REGISTER_SYSTEM_SETUP = 0x20
1717
__HT16K33_REGISTER_DIMMING = 0xE0
1818

19+
# Data base addresses
20+
__HT16K33_ADDRESS_KEY_DATA = 0x40
21+
1922
# Blink rate
2023
__HT16K33_BLINKRATE_OFF = 0x00
2124
__HT16K33_BLINKRATE_2HZ = 0x01
@@ -83,11 +86,16 @@ def writeDisplay(self):
8386
bytes.append((item >> 8) & 0xFF)
8487
self.i2c.writeList(0x00, bytes)
8588

89+
def getKeys(self, row):
90+
"Returns a row of scanned key press values as a single 13-bit value (K13:K1)"
91+
if (row > 2):
92+
return
93+
return self.i2c.readU16(self.__HT16K33_ADDRESS_KEY_DATA + row*2)
94+
8695
def clear(self, update=True):
8796
"Clears the display memory"
8897
self.__buffer = [ 0, 0, 0, 0, 0, 0, 0, 0 ]
8998
if (update):
9099
self.writeDisplay()
91100

92101
led = LEDBackpack(0x70)
93-

0 commit comments

Comments
 (0)