Mercurial > circuitpython-lameboy
changeset 1:783f2213f33d draft
Add constants for the buttons
And negate the get_pressed value
| author | Radomir Dopieralski <sheep-devel@sheep.art.pl> |
|---|---|
| date | Thu, 22 Feb 2018 01:28:21 +0100 |
| parents | e091ed56d9df |
| children | 2c172c745298 |
| files | lameboy.py |
| diffstat | 1 files changed, 9 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/lameboy.py Thu Feb 22 01:09:28 2018 +0100 +++ b/lameboy.py Thu Feb 22 01:28:21 2018 +0100 @@ -13,12 +13,20 @@ class Buttons: + UP = 0x80 + LEFT = 0x40 + DOWN = 0x20 + RIGHT = 0x10 + A = 0x08 + B = 0x04 + C = 0x01 + def __init__(self, i2c, address=0x38): self._i2c = i2c self._address = address def get_pressed(self): - return self._i2c.readfrom(self._address, 1)[0] + return self._i2c.readfrom(self._address, 1)[0] ^ 0xff i2c = I2C(-1, sda=Pin(4), scl=Pin(5))
