Author Topic: How to program a teensy controller for a matrix keyboard?  (Read 2440 times)

0 Members and 1 Guest are viewing this topic.

Offline berserkfan

  • Thread Starter
  • Posts: 2135
  • Location: Not CONUS Not CONUS Not CONUS Not CONUS
  • changing diapers is more fun than model f assembly
How to program a teensy controller for a matrix keyboard?
« on: Sat, 07 June 2014, 12:05:34 »
Just got a wonderful g80-1950 wired up by another geekhacker.

Unfortunately he cant remember how he originally programmed it. He gave me this document (which I've altered to fit the layout I am trying to use.) But now I can't get scas.exe to process. It keeps saying there's an error on line 26 where the blocking 0 line is.

As I don't really undestand any of the code, and can't find instructions on the teensy docs, I have to ask you guys what to do...

<typed on my new jailhouse blues modded keyboard. some keys keep sticking. ugh! Seems as though I can't do anything right>

btw when word wrap is turned off on my notepad, things look fine, but now my cut-and-paste has resulted in a jumble of text below. I've attached the .sc file and hope someone can give me guidance!

#teensy pin
#F0 ---> x:7
#F1 ---> x:6
#F4 ---> x:5
#F5 ---> x:4
#F6 ---> x:3
#F7 ---> x:2
#B6 ---> x:1


#B0 ---> 1
#B1 ---> 2
#B2 ---> 3
#B3 ---> 4
#E6 ---> 5
#B7 ---> 6
#D0 ---> 7
#D1 ---> 8
#D2 ---> 9
#D3 ---> 10
#C6 ---> 11
#D5 ---> 12
#D4 ---> 13
#C7 ---> 14
#D7 ---> 15
matrix
  #  blocking 0

    sense         PB0      PB1      PB2      PB3      PE6      PB7      PD0      PD1      PD2      PD3      PC6      PD5      PD4      PC7      PD7     

    strobe  PB6      UNASSIGNED   UNASSIGNED   UNASSIGNED   UNASSIGNED   UNASSIGNED   UNASSIGNED   UNASSIGNED   UNASSIGNED   UNASSIGNED   UNASSIGNED   UNASSIGNED   UNASSIGNED   LEFT      DOWN      RIGHT
    strobe  PF7      LCTRL      LGUI      LALT      SPACE      SPACE      SPACE      SPACE      SPACE      RALT      RGUI      APP      RCTRL      UNASSIGNED   UP      PAGE_DOWN
    strobe  PF6      LSHIFT      Z      X      C      V      B      K      M      COMMA      PERIOD      SLASH      RSHIFT      UNASSIGNED   DELETE      END
    strobe  PF5      CAPS_LOCK   A      R      S      T      D      H      N      E      I      O      QUOTE      BACKSPACE   ENTER      HOME
    strobe  PF4      TAB      Q      W      F      P      G      J      L      U      Y      SEMICOLON   LEFT_BRACE   RIGHT_BRACE   BACKSLASH   PAGE_UP
    strobe  PF1      BACK_QUOTE   1      2      3      4      5      6      7      8      9      0      MINUS      EQUAL      INSERT      PAUSE
    Strobe  PF0      ESC      F1      F2      F3      F4      F5      F6      F7      F8      F9      F10      F11      F12      PRINT      SCROLL_LOCK
END
Most of the modding can be done on your own once you break through the psychological barriers.

Offline dorkvader

  • Posts: 6288
  • Location: Boston area
  • all about the "hack" in "geekhack"
Re: How to program a teensy controller for a matrix keyboard?
« Reply #1 on: Sun, 08 June 2014, 03:21:30 »
Remebre that each line starting with a # is a "comment" and ignored by the code. Figuring out which lines errors are on is easier when you just remove the comments beforehand. I also lined everything up using spaces instead of tabs. I recommend turning word wrap off and scrolling over.

I tried compiling the following code with the command "scas g80-1950.sc g80-1950.scb and got the following:
error at line12: invalid argument: PRINT
Code: [Select]
matrix
    blocking 0
   
    sense      PB0          PB1          PB2          PB3          PE6          PB7          PD0          PD1          PD2          PD3          PC6          PD5          PD4         PC7          PD7     

    strobe  PB6      UNASSIGNED   UNASSIGNED   UNASSIGNED   UNASSIGNED   UNASSIGNED   UNASSIGNED   UNASSIGNED   UNASSIGNED   UNASSIGNED   UNASSIGNED   UNASSIGNED   UNASSIGNED   LEFT        DOWN         RIGHT
    strobe  PF7      LCTRL        LGUI         LALT         SPACE        SPACE        SPACE        SPACE        SPACE        RALT         RGUI         APP          RCTRL        UNASSIGNED  UP           PAGE_DOWN
    strobe  PF6      LSHIFT       Z            X            C            V            B            K            M            COMMA        PERIOD       SLASH        RSHIFT       UNASSIGNED  DELETE       END
    strobe  PF5      CAPS_LOCK    A            R            S            T            D            H            N            E            I            O            QUOTE        BACKSPACE   ENTER        HOME
    strobe  PF4      TAB          Q            W            F            P            G            J            L            U            Y            SEMICOLON    LEFT_BRACE   RIGHT_BRACE BACKSLASH    PAGE_UP
    strobe  PF1      BACK_QUOTE   1            2            3            4            5            6            7            8            9            0            MINUS        EQUAL       INSERT       PAUSE
    Strobe  PF0      ESC          F1           F2           F3           F4           F5           F6           F7           F8           F9           F10          F11          F12         PRINT        SCROLL_LOCK
END

As you can see, on line12 (the last matrix line, there is a keycode "print". According to soarer's documentation, the correct word is "PRINTSCREEN". Fixing this error causes it to compile without errors.

You have to remember that this is an extension of soarer's converter code, so all the keycodes and much of the other documentation is inherited from there. The doc folder of the controller code only has changes / updates / new features specifically related to this: otherwise, refer to the converter code docs at all points.
 
Additionally, it'd be useful to post what version you are running. I am using V1.20 which is the latest at the time of this writing.

Remember to flash it you need to run the following
scas  G80-1950MyVersion.sc  G80-1950MyVersion.scb
scwr G80-1950MyVersion.scb

or (windows only)
scaswr G80-1950MyVersion.sc

Below and attached is the corrected file that compiles properly

Code: [Select]
matrix
    blocking 0
   
    sense      PB0          PB1          PB2          PB3          PE6          PB7          PD0          PD1          PD2          PD3          PC6          PD5          PD4         PC7          PD7     

    strobe  PB6      UNASSIGNED   UNASSIGNED   UNASSIGNED   UNASSIGNED   UNASSIGNED   UNASSIGNED   UNASSIGNED   UNASSIGNED   UNASSIGNED   UNASSIGNED   UNASSIGNED   UNASSIGNED   LEFT        DOWN         RIGHT
    strobe  PF7      LCTRL        LGUI         LALT         SPACE        SPACE        SPACE        SPACE        SPACE        RALT         RGUI         APP          RCTRL        UNASSIGNED  UP           PAGE_DOWN
    strobe  PF6      LSHIFT       Z            X            C            V            B            K            M            COMMA        PERIOD       SLASH        RSHIFT       UNASSIGNED  DELETE       END
    strobe  PF5      CAPS_LOCK    A            R            S            T            D            H            N            E            I            O            QUOTE        BACKSPACE   ENTER        HOME
    strobe  PF4      TAB          Q            W            F            P            G            J            L            U            Y            SEMICOLON    LEFT_BRACE   RIGHT_BRACE BACKSLASH    PAGE_UP
    strobe  PF1      BACK_QUOTE   1            2            3            4            5            6            7            8            9            0            MINUS        EQUAL       INSERT       PAUSE
    Strobe  PF0      ESC          F1           F2           F3           F4           F5           F6           F7           F8           F9           F10          F11          F12         PRINTSCREEN  SCROLL_LOCK
END
"No errors. Wrote G80-1950_1.scb"

Looks like your matrix is flipped vertically. The following code should also work fine and also be easier to read. It really shows off the power of soarer's code:
Code: [Select]
matrix
    blocking 0
   
    sense      PB0          PB1          PB2          PB3          PE6          PB7          PD0          PD1          PD2          PD3          PC6          PD5          PD4         PC7          PD7     

    Strobe  PF0      ESC          F1           F2           F3           F4           F5           F6           F7           F8           F9           F10          F11          F12         PRINTSCREEN  SCROLL_LOCK
    strobe  PF1      BACK_QUOTE   1            2            3            4            5            6            7            8            9            0            MINUS        EQUAL       INSERT       PAUSE
    strobe  PF4      TAB          Q            W            F            P            G            J            L            U            Y            SEMICOLON    LEFT_BRACE   RIGHT_BRACE BACKSLASH    PAGE_UP
    strobe  PF5      CAPS_LOCK    A            R            S            T            D            H            N            E            I            O            QUOTE        BACKSPACE   ENTER        HOME
    strobe  PF6      LSHIFT       Z            X            C            V            B            K            M            COMMA        PERIOD       SLASH        RSHIFT       UNASSIGNED  DELETE       END
    strobe  PF7      LCTRL        LGUI         LALT         SPACE        SPACE        SPACE        SPACE        SPACE        RALT         RGUI         APP          RCTRL        UNASSIGNED  UP           PAGE_DOWN
    strobe  PB6      UNASSIGNED   UNASSIGNED   UNASSIGNED   UNASSIGNED   UNASSIGNED   UNASSIGNED   UNASSIGNED   UNASSIGNED   UNASSIGNED   UNASSIGNED   UNASSIGNED   UNASSIGNED   LEFT        DOWN         RIGHT
END
« Last Edit: Sun, 08 June 2014, 03:28:44 by dorkvader »

Offline berserkfan

  • Thread Starter
  • Posts: 2135
  • Location: Not CONUS Not CONUS Not CONUS Not CONUS
  • changing diapers is more fun than model f assembly
Re: How to program a teensy controller for a matrix keyboard?
« Reply #2 on: Sun, 08 June 2014, 11:37:01 »
THANK YOU SOARER, DORKVADER AND ALL WHO HAVE WORKED SO HARD FOR THIS!


Got it up and running. Turns out I was using the wrong version, 1.10 versus 1.20! 1.20 has documentation for mini matrixes. A big lesson for me. Being non tech I lack the habit of checking the version in advance. Matrix stuff does not work with 1.10.

Everyone please consult this link in future. I am locking the thread so that we don't have too many threads on matrix programming.
http://geekhack.org/index.php?topic=50437.0
Most of the modding can be done on your own once you break through the psychological barriers.