Keybow 2040 - on key numbering rotation

I noticed in the keybow2040.py code there is what looks like an unfinished bit of code commented out for rotating the key/led numbering.

I didn’t have time to dive into it, so I went with a more direct editing method that I’d though I’d share

With the cable at the top/away the default numbering goes from 0 bottom to 3 top, left column first
To change the order to 0 lef to 3 right, top row first (english reading order) two changes must be made
Change #1

# Old code in /lib/keybow2040.py
_PINS = [board.SW0,
        board.SW1,
        board.SW2,
        board.SW3,
        board.SW4,
        board.SW5,
        board.SW6,
        board.SW7,
        board.SW8,
        board.SW9,
        board.SW10,
        board.SW11,
        board.SW12,
        board.SW13,
        board.SW14,
        board.SW15]

becomes

# New code in /lib/keybow2040.py
_PINS = [board.SW3,
        board.SW7,
        board.SW11,
        board.SW15,
        board.SW2,
        board.SW6,
        board.SW10,
        board.SW14,
        board.SW1,
        board.SW5,
        board.SW9,
        board.SW13,
        board.SW0,
        board.SW4,
        board.SW8,
        board.SW12]

and Change #2

# Old code in /lib/keybow2040.py
def number_to_xy(number):
    # Convert a number to an x/y coordinate.
    # uncomment for Bottom left = 0, up = 1+
    x = number % 4 
    y = number // 4

    return (x, y)

becomes

# New code in /lib/keybow2040.py
def number_to_xy(number):
    # Convert a number to an x/y coordinate.
    # uncomment for Bottom left = 0, up = 1+
    x = (15-number) // 4 
    y = number % 4

    return (x, y)

similar manipulations can get you other orientations
I’m not sure why the second change is necessary but I believe it’s because the LEDs are enumerated by the I2C library. if I get around to it I may write a function that will allow arbitrary numbering of keys to allow more options (I’m thinking any arbitrary layout)