Author Topic: Editing TMK for teensy  (Read 2973 times)

0 Members and 1 Guest are viewing this topic.

Offline Un4tural

  • Thread Starter
  • Posts: 9
Editing TMK for teensy
« on: Mon, 29 February 2016, 11:28:42 »
Hello,

Little background for this, i got a zm-k500, now i know its not MX switches, but it seemed like a nice piece for a project at 12£ shipped (faulty controller, a row of keys on the controller weren't responding) so i took switches off (don't do this it is a utter total pain in the arse) so i wired it up in a matrix, 17x6 (1 corner key can stay unused or ill purpose it for something else once i get a hang of this, as top row is 18 keys few multimedia ones)

anyways, so teensy is wired up (though i did use pin #13 which i believe i shouldn't have as it's something with onboard LED). going to edit the matrix.c for phantom keyboard, as layout is relatively similar i realized i know jack sh*t about the programming (assumed i could just reassign keys) anyways, i figured how to reassign keys to positions in matrix, however, i need to ask how the PIN # corresponds to letter+number for the firmware matrix.c file. is it B1-7 C1-7 D 1-7 for corresponding 0-6 7-14 15-22 etc. pins on teensy? also the select_col portion of code as well, could anyone explain or point me in the right direction on how that would need to be changed?

basically I'm completely green at the programing and not sure on how to change rows to correspond to different columns in the matrix.c file so keymap is easier to edit? i followed this https://deskthority.net/workshop-f7/how-to-build-your-very-own-keyboard-firmware-t7177.html#p141148 but i might be too thick or something to figure it out on my own.

also i assume i need to move the 1 column onto different pin than 13?

http://imgur.com/a/butm9

Offline regack

  • Posts: 660
  • Location: Thessia
Re: Editing TMK for teensy
« Reply #1 on: Mon, 29 February 2016, 13:09:57 »
I'm not sure how to help you, maybe someone else can, but that looks like a Teensy-LC.  I know nothing about the Teensy-LC other than it uses an ARM Cortex M0.  I'm not sure what you have to do to get TMK with Chibios running.

Offline suicidal_orange

  • * Global Moderator
  • Posts: 4771
  • Location: England
Re: Editing TMK for teensy
« Reply #2 on: Mon, 29 February 2016, 13:10:57 »
The pins for all Teensy models are detailed here - which one do you have?  The one used in the guide you linked is a 2.0 which has the pins labeled A1 or D5 while you saying pin 13 is on a corner and the C I can make out in your pic makes it seem like you have an LC. 

The 3.x and LC Teensy's use a different chip which I'm not sure is supported by TMK so you may have a problem...
120/100g linear Zealio R1  
GMK Hyperfuse
'Split everything' perfection  
MX Clear
SA Hack'd by Geeks     
EasyAVR mod

Offline Un4tural

  • Thread Starter
  • Posts: 9
Re: Editing TMK for teensy
« Reply #3 on: Mon, 29 February 2016, 13:29:08 »
bloody hell, yes it is an LC, sorry forgot to mention, got it cause one of the guides listed it as working. TMK has a one key LC in the configurations, but adding a whole keyboard and matrix etc. is well well above my head.

anything to put on LC to get it to work then? it has enough pins as far as i can tell. i don't mind some typing work, as long as things aren't too complex as i am novice at this.

was going to get a raspberry, but i couldn't find anything i could use it for in the keyboard, also it is rather  overkill, then again saying my keyboard has more ram than some phones would be quite neat.


Offline suicidal_orange

  • * Global Moderator
  • Posts: 4771
  • Location: England
Re: Editing TMK for teensy
« Reply #4 on: Mon, 29 February 2016, 14:49:00 »
If it works it works, just a matter of stitching the controller bit from the 1 key with a full matrix.  Work out your pin names and where they're connected that's a good start :)
120/100g linear Zealio R1  
GMK Hyperfuse
'Split everything' perfection  
MX Clear
SA Hack'd by Geeks     
EasyAVR mod

Offline Un4tural

  • Thread Starter
  • Posts: 9
Re: Editing TMK for teensy
« Reply #5 on: Mon, 29 February 2016, 15:08:11 »
well seems i'll need to learn C to do much of anything. No expert but the teensy_lc_onekay matrix.c is for a button that prints out certain text once pressed. i suppose could be a fun "smash in case need password" big red usb button. for pins 2&5?

Anyone have something more complete than the single button i could add to (multiple row matrix.c etc. ? made for keypad?) I've seen that keyboard someone built from 2 pieces both having a teensy i think, maybe those are LC, that i could likely use! otherwise this will be quite a lot larger bite than i thought!  :eek:

also if i wanted to reference say matrix.c from phantom to use, it uses different layout (ports etc.) where LC i think only has pins 0-26 which might make it easier for me. maybe.

thanks for assistance so far, if anyone has anything useful do throw it my way please!

Offline flabbergast

  • Posts: 234
  • Location: UK
Re: Editing TMK for teensy
« Reply #6 on: Tue, 01 March 2016, 06:57:45 »
Have a look the TMK sources for WhiteFox, that one has a full matrix and uses the same syntax as Teensy LC should use.
You'll need to change the things like 'GPIOB, 4' - for Teensy LC you can use syntax 'TEENSY_PIN12_IOPORT, TEENSY_PIN12' for that. See the instructions that come with the onekey example.

EDIT: Also, you can have a look at the sources for a 2x3 matrix (keytester) that I wired to a Teensy 3.2.
« Last Edit: Tue, 01 March 2016, 07:04:07 by flabbergast »

Offline Un4tural

  • Thread Starter
  • Posts: 9
Re: Editing TMK for teensy
« Reply #7 on: Tue, 01 March 2016, 10:51:54 »
trying to edit whitefox matrix.c stuck on

  // read col data: { PTD0, PTD1, PTD4, PTD5, PTD6, PTD7, PTC1, PTC2 }
        data = ((palReadPort(GPIOC) & 0x06UL) << 5) |
               ((palReadPort(GPIOD) & 0xF0UL) >> 2) |
                (palReadPort(GPIOD) & 0x03UL);

since ports on teensy LC are separate for each pin? so i cannot do IOPORT only, do i list them all separately? what do i do with the hex address and << >> operators... I've changed config.h to 6row 17col and added case0-16 (pin 25-8 skipping 13) with column sense for pins 0-5 (basically replaced all the GBIOx # with TEENSY_PIN#_IOPORT, TEENSY_PIN#.

something like this?
        data =
      ((palReadPad(TEENSY_PIN0_IOPORT, TEENSY_PIN0)==PAL_HIGH) ? 0 : (1<<0))
      ((palReadPad(TEENSY_PIN1_IOPORT, TEENSY_PIN1)==PAL_HIGH) ? 0 : (1<<1))
      ((palReadPad(TEENSY_PIN2_IOPORT, TEENSY_PIN2)==PAL_HIGH) ? 0 : (1<<2))
      ((palReadPad(TEENSY_PIN3_IOPORT, TEENSY_PIN3)==PAL_HIGH) ? 0 : (1<<3))
      ((palReadPad(TEENSY_PIN4_IOPORT, TEENSY_PIN4)==PAL_HIGH) ? 0 : (1<<4))
      ((palReadPad(TEENSY_PIN5_IOPORT, TEENSY_PIN5)==PAL_HIGH) ? 0 : (1<<5));

so if pin0 is high (1) it returns 0, if pin1 is high then it returns 1 etc.? should be few | somewhere but i think i can do this! maybe. looking at your 2x3 matrix as reference for this bit.

if this in theory works on teensy LC, i just need to reconfigure keymap_common.h to have 6x17 configuration and then map the keys. easy peasy, sadly i am way dumb at this. wish i paid attention in programming classes in highschool, also wish they taught C and not writing a different formula every week in TURBO PASCAL.

now if world worked way i imagine it i'd be set but... i don't know nearly enough to have any faith in this working.
« Last Edit: Tue, 01 March 2016, 10:54:46 by Un4tural »

Offline flabbergast

  • Posts: 234
  • Location: UK
Re: Editing TMK for teensy
« Reply #8 on: Tue, 01 March 2016, 11:24:28 »
You're on the right track. The result in 'data' should be number, which if written in the binary form, it says which columns are activated. Bit0 corresponds to column 0, bit 1 to column 1, etc.

So the deal is to write an expression which does this.

Some info about C syntax:
 - '<<' is 'bit shift'. So (1<<3) means 'take 1 and bitwise shift by 3 to the left'. So (1<<3) = 0b1000 = 8.
 - '|' is 'bitwise or'. So (1<<3) | (1<<1) = 0b1000 | 0b0010 = 0b1010 = 10.
 - '( CONDITION ? A : B )' is an expression which results to 'A' if CONDITION is true, and to 'B' otherwise.

So, for example, from the 2x3 matrix code:
Code: [Select]
/* Returns status of switches(1:on, 0:off) */
static matrix_row_t read_cols(void)
{
    return(   ((palReadPad(TEENSY_PIN19_IOPORT, TEENSY_PIN19)==PAL_HIGH) ? 0 : (1<<0))
            | ((palReadPad(TEENSY_PIN17_IOPORT, TEENSY_PIN17)==PAL_HIGH) ? 0 : (1<<1))
            | ((palReadPad(TEENSY_PIN16_IOPORT, TEENSY_PIN16)==PAL_HIGH) ? 0 : (1<<2)));
}
On this one, a column is active if it is LOW (logical 0). The columns are wired to Teensy pins 19, 17, 16 respectively.
Say, for example, that somethings in column 1 and column 0 are pressed, nothing in column 2 is pressed. Then the expression inside the return( ... ) evaluates to (using the rules above):
 ( FALSE ? 0 : (1<<0) ) | ( FALSE ? 0 : (1<<1) ) | ( TRUE ? 0 : (1<<2) ) = (1<<0) | (1<<1) | 0 = 0b001 | 0b010 | 0b000 = 0b011
So it is exactly saying that columns 0 and 1 are active, whereas column 2 is not.

Offline Un4tural

  • Thread Starter
  • Posts: 9
Re: Editing TMK for teensy
« Reply #9 on: Tue, 01 March 2016, 12:38:41 »
well didn't think it'd be this easy i suppose. I'll call it a day with this for today, i assume i can't just use your formatting for it for data = and need to work something out to make it give for each pin what the formulas in original were giving with the  & 0x06UL) << 5) part, considering it originally has 8 col pins, but port D has 6 and port C has 2 pins for columns, ((palReadPort(GPIOC) & 0x06UL) << 5) should give 2 different answers for data... i guess It's supposed to give 8bit value for each column? so can i take an easy way out and assign a bit to each pin that will give data the answer it wants, minus 2 columns which i wont use, (palReadPad(TEENSY_PIN1_IOPORT, TEENSY_PIN1) = 000001) essentially me giving answer instead of being clever like whitefox and using a formula to determine it... maybe...  :eek:

i think it'd be easier to go learn C and get back to this than try to reverse engineer someone else's work with no knowledge. why each i assume hex number has UL at end though? 0x06 would be 110 in binary, pin 1/2 would give 01 or 10 in hex, meaning it either gives 100000 or 0 as result?

ill call it a day with this and tackle it further tomorrow, if i could just assign there values to pins it'd be great tho.

Offline flabbergast

  • Posts: 234
  • Location: UK
Re: Editing TMK for teensy
« Reply #10 on: Tue, 01 March 2016, 15:01:50 »
You can use whatever expression gives you the right result. Whitefox code does this in a more tricky way, to save a few cycles and function calls. I'd recommend starting with the 2x3-type code.

But what you write is correct, palReadPort returns a 32bit value which contains the status of all 32 pins associated with that port (e.g. palReadPort(GPIOC) is the status of all the pins from C0 up to C31. Some of those may not be physically present on the chip of course.).

The 'UL' stands for 'unsigned long', which means a 32bit number. The point is that that's the way to tell the C compiler that the constant that's written down represents a 32bit number, not (say) an 8bit number. So 6UL is just 6. But we are doing a 'bitwise AND' with a 32bit number, so just to make sure that the compiler understands that the '6' is also a 32bit number.

Offline flabbergast

  • Posts: 234
  • Location: UK
Re: Editing TMK for teensy
« Reply #11 on: Wed, 02 March 2016, 03:52:19 »
If you're stuck, I can write a matrix.c and keymap for you, if you describe the matrix for me (i.e. which row/col is wired to which pin).

Offline Un4tural

  • Thread Starter
  • Posts: 9
Re: Editing TMK for teensy
« Reply #12 on: Wed, 02 March 2016, 04:54:11 »
That'd be very generous, but i'll struggle on for a little longer, I'm sure i could make the keymap, that bit doesn't seem too difficult, plus it seems like a lot of tedious changing row/col positions. i think i changed the pins etc. correctly, hopefully it's clever enough to realise it has more rows less columns(changed the config to 6x17 too) I'll struggle for a bit longer, i think pins are good, except for the data = part, need to make it send what it expects for pin 0-5 so keymap receives these and it's maybe honky dory. i suppose i need the pin 32bit values for the row pins. can't figure out yet what the value is expected for each pin in the original though.
matrix.c
More
#include <stdint.h>
#include <stdbool.h>
#include <string.h>
#include "hal.h"
#include "timer.h"
#include "wait.h"
#include "print.h"
#include "debug.h"
#include "matrix.h"


/*
 * Matt3o's WhiteFox
 * Column pins are input with internal pull-down. Row pins are output and strobe with high.
 * Key is high or 1 when it turns on.
 *
 *     col: { PTD0, PTD1, PTD4, PTD5, PTD6, PTD7, PTC1, PTC2 }
 *     row: { PTB2, PTB3, PTB18, PTB19, PTC0, PTC8, PTC9, PTC10, PTC11 }
 */
/* matrix state(1:on, 0:off) */
static matrix_row_t matrix[MATRIX_ROWS];
static matrix_row_t matrix_debouncing[MATRIX_ROWS];
static bool debouncing = false;
static uint16_t debouncing_time = 0;


void matrix_init(void)
{
    debug_matrix = true;
    /* Column(sense) */
    palSetPadMode(TEENSY_PIN0_IOPORT, TEENSY_PIN0,  PAL_MODE_INPUT_PULLDOWN);
    palSetPadMode(TEENSY_PIN1_IOPORT, TEENSY_PIN1,  PAL_MODE_INPUT_PULLDOWN);
    palSetPadMode(TEENSY_PIN2_IOPORT, TEENSY_PIN2,  PAL_MODE_INPUT_PULLDOWN);
    palSetPadMode(TEENSY_PIN3_IOPORT, TEENSY_PIN3,  PAL_MODE_INPUT_PULLDOWN);
    palSetPadMode(TEENSY_PIN4_IOPORT, TEENSY_PIN4,  PAL_MODE_INPUT_PULLDOWN);
    palSetPadMode(TEENSY_PIN5_IOPORT, TEENSY_PIN5,  PAL_MODE_INPUT_PULLDOWN);

    /* Row(strobe) */
    palSetPadMode(TEENSY_PIN25_IOPORT, TEENSY_PIN25, PAL_MODE_OUTPUT_PUSHPULL);
    palSetPadMode(TEENSY_PIN24_IOPORT, TEENSY_PIN24, PAL_MODE_OUTPUT_PUSHPULL);
    palSetPadMode(TEENSY_PIN23_IOPORT, TEENSY_PIN23, PAL_MODE_OUTPUT_PUSHPULL);
    palSetPadMode(TEENSY_PIN22_IOPORT, TEENSY_PIN22, PAL_MODE_OUTPUT_PUSHPULL);
    palSetPadMode(TEENSY_PIN21_IOPORT, TEENSY_PIN21, PAL_MODE_OUTPUT_PUSHPULL);
    palSetPadMode(TEENSY_PIN20_IOPORT, TEENSY_PIN20, PAL_MODE_OUTPUT_PUSHPULL);
    palSetPadMode(TEENSY_PIN19_IOPORT, TEENSY_PIN19, PAL_MODE_OUTPUT_PUSHPULL);
    palSetPadMode(TEENSY_PIN18_IOPORT, TEENSY_PIN18, PAL_MODE_OUTPUT_PUSHPULL);
    palSetPadMode(TEENSY_PIN17_IOPORT, TEENSY_PIN17, PAL_MODE_OUTPUT_PUSHPULL);
   palSetPadMode(TEENSY_PIN16_IOPORT, TEENSY_PIN16, PAL_MODE_OUTPUT_PUSHPULL);
   palSetPadMode(TEENSY_PIN15_IOPORT, TEENSY_PIN15, PAL_MODE_OUTPUT_PUSHPULL);
   palSetPadMode(TEENSY_PIN14_IOPORT, TEENSY_PIN14, PAL_MODE_OUTPUT_PUSHPULL);
   palSetPadMode(TEENSY_PIN12_IOPORT, TEENSY_PIN12, PAL_MODE_OUTPUT_PUSHPULL);
   palSetPadMode(TEENSY_PIN11_IOPORT, TEENSY_PIN11, PAL_MODE_OUTPUT_PUSHPULL);
   palSetPadMode(TEENSY_PIN10_IOPORT, TEENSY_PIN10, PAL_MODE_OUTPUT_PUSHPULL);
   palSetPadMode(TEENSY_PIN9_IOPORT, TEENSY_PIN9, PAL_MODE_OUTPUT_PUSHPULL);
   palSetPadMode(TEENSY_PIN8_IOPORT, TEENSY_PIN8, PAL_MODE_OUTPUT_PUSHPULL);

    memset(matrix, 0, MATRIX_ROWS);
    memset(matrix_debouncing, 0, MATRIX_ROWS);
}

uint8_t matrix_scan(void)
{
    for (int row = 0; row < MATRIX_ROWS; row++) {
        matrix_row_t data = 0;

        // strobe row
        switch (row) {
            case 0: palSetPad(TEENSY_PIN25_IOPORT, TEENSY_PIN25);    break;
            case 1: palSetPad(TEENSY_PIN24_IOPORT, TEENSY_PIN24);    break;
            case 2: palSetPad(TEENSY_PIN23_IOPORT, TEENSY_PIN23);   break;
            case 3: palSetPad(TEENSY_PIN22_IOPORT, TEENSY_PIN22);   break;
            case 4: palSetPad(TEENSY_PIN21_IOPORT, TEENSY_PIN21);    break;
            case 5: palSetPad(TEENSY_PIN20_IOPORT, TEENSY_PIN20);    break;
            case 6: palSetPad(TEENSY_PIN19_IOPORT, TEENSY_PIN19);    break;
            case 7: palSetPad(TEENSY_PIN18_IOPORT, TEENSY_PIN18);   break;
            case 8: palSetPad(TEENSY_PIN17_IOPORT, TEENSY_PIN17);   break;
         case 9: palSetPad(TEENSY_PIN16_IOPORT, TEENSY_PIN16);   break;
         case 10: palSetPad(TEENSY_PIN15_IOPORT, TEENSY_PIN15);   break;
         case 11: palSetPad(TEENSY_PIN14_IOPORT, TEENSY_PIN14);   break;
         case 13: palSetPad(TEENSY_PIN12_IOPORT, TEENSY_PIN12);   break;
         case 14: palSetPad(TEENSY_PIN11_IOPORT, TEENSY_PIN11);   break;
         case 15: palSetPad(TEENSY_PIN10_IOPORT, TEENSY_PIN10);   break;
         case 16: palSetPad(TEENSY_PIN9_IOPORT, TEENSY_PIN9);   break;
        }

        wait_us(1); // need wait to settle pin state

        // read col data: { PTD0, PTD1, PTD4, PTD5, PTD6, PTD7, PTC1, PTC2 }
        data =
      ((palReadPort(TEENSY_PIN0_IOPORT, TEENSY_PIN0) = 0x00UL))
      |((palReadPad(TEENSY_PIN1_IOPORT, TEENSY_PIN1) = 0x40UL))
      |((palReadPad(TEENSY_PIN2_IOPORT, TEENSY_PIN2) & 0x06UL) << 5))
      |((palReadPad(TEENSY_PIN3_IOPORT, TEENSY_PIN3) & 0x06UL) << 5))
      |((palReadPad(TEENSY_PIN4_IOPORT, TEENSY_PIN4) & 0x06UL) << 5))
      |((palReadPad(TEENSY_PIN5_IOPORT, TEENSY_PIN5) & 0x06UL) << 5));

        // un-strobe row
        switch (row) {
            case 0: palClearPad(TEENSY_PIN25_IOPORT, TEENSY_PIN25);  break;
            case 1: palClearPad(TEENSY_PIN24_IOPORT, TEENSY_PIN24);  break;
            case 2: palClearPad(TEENSY_PIN23_IOPORT, TEENSY_PIN23); break;
            case 3: palClearPad(TEENSY_PIN22_IOPORT, TEENSY_PIN22); break;
            case 4: palClearPad(TEENSY_PIN21_IOPORT, TEENSY_PIN21);  break;
            case 5: palClearPad(TEENSY_PIN20_IOPORT, TEENSY_PIN20);  break;
            case 6: palClearPad(TEENSY_PIN19_IOPORT, TEENSY_PIN19);  break;
            case 7: palClearPad(TEENSY_PIN18_IOPORT, TEENSY_PIN18); break;
            case 8: palClearPad(TEENSY_PIN17_IOPORT, TEENSY_PIN17); break;
         case 9: palClearPad(TEENSY_PIN16_IOPORT, TEENSY_PIN16);   break;
         case 10: palClearPad(TEENSY_PIN15_IOPORT, TEENSY_PIN15);   break;
         case 11: palClearPad(TEENSY_PIN14_IOPORT, TEENSY_PIN14);   break;
         case 12: palClearPad(TEENSY_PIN12_IOPORT, TEENSY_PIN12);   break;
         case 13: palClearPad(TEENSY_PIN11_IOPORT, TEENSY_PIN11);   break;
         case 14: palClearPad(TEENSY_PIN10_IOPORT, TEENSY_PIN10);   break;
         case 15: palClearPad(TEENSY_PIN9_IOPORT, TEENSY_PIN9);   break;
         case 16: palClearPad(TEENSY_PIN8_IOPORT, TEENSY_PIN8);   break;
        }

        if (matrix_debouncing[row] != data) {
            matrix_debouncing[row] = data;
            debouncing = true;
            debouncing_time = timer_read();
        }
    }

    if (debouncing && timer_elapsed(debouncing_time) > DEBOUNCE) {
        for (int row = 0; row < MATRIX_ROWS; row++) {
            matrix[row] = matrix_debouncing[row];
        }
        debouncing = false;
    }
    return 1;
}

bool matrix_is_on(uint8_t row, uint8_t col)
{
    return (matrix[row] & (1<<col));
}

matrix_row_t matrix_get_row(uint8_t row)
{
    return matrix[row];
}

void matrix_print(void)
{
    xprintf("\nr/c 01234567\n");
    for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
        xprintf("%X0: ", row);
        matrix_row_t data = matrix_get_row(row);
        for (int col = 0; col < MATRIX_COLS; col++) {
            if (data & (1<<col))
                xprintf("1");
            else
                xprintf("0");
        }
        xprintf("\n");
    }
}

also doesn't seem to compile, but ill tackle it when the time comes i suppose, could be a windows 10 thing.
https://gyazo.com/22b619a86e9c5f30eb007d5b79f4bfb4

attached what my wiring looks like, for a better idea on what it should look like. skipped pin 13 because something to do with it being tied to internal LED. having 2 more pins, i guess i could add that corner key that is missing and make it a backlight enable or something, if i ever get that far, to adding LEDs for backlight.

huge thanks for the help so far by the way, couldn't have gotten as far otherwise.

Offline flabbergast

  • Posts: 234
  • Location: UK
Re: Editing TMK for teensy
« Reply #13 on: Wed, 02 March 2016, 05:15:28 »
A couple of things:
 - the error is indeed a windows 10 thing (something with msys or cygwin not working properly). It is not a compilation error as such.
 - the way your matrix is wired (based on the photos you posted), I think you should sense the columns (not rows), have them set up as INPUT_PULLUP (not PULLDOWN), and strobe rows (with 'enabled' being LOW, so palClearPad to strobe and palSetPad to unstrobe).
 - the data part would look like this:
Code: [Select]
    data = ((palReadPad(TEENSY_PIN25_IOPORT, TEENSY_PIN25)==PAL_HIGH) ? 0 : (1UL<<0))
         | ((palReadPad(TEENSY_PIN24_IOPORT, TEENSY_PIN24)==PAL_HIGH) ? 0 : (1UL<<1))
         | ((palReadPad(TEENSY_PIN23_IOPORT, TEENSY_PIN23)==PAL_HIGH) ? 0 : (1UL<<2))
         | ((palReadPad(TEENSY_PIN22_IOPORT, TEENSY_PIN22)==PAL_HIGH) ? 0 : (1UL<<3))
         | ((palReadPad(TEENSY_PIN21_IOPORT, TEENSY_PIN21)==PAL_HIGH) ? 0 : (1UL<<4))
         | ((palReadPad(TEENSY_PIN20_IOPORT, TEENSY_PIN20)==PAL_HIGH) ? 0 : (1UL<<5))
         | ((palReadPad(TEENSY_PIN19_IOPORT, TEENSY_PIN19)==PAL_HIGH) ? 0 : (1UL<<6))
         | ((palReadPad(TEENSY_PIN18_IOPORT, TEENSY_PIN18)==PAL_HIGH) ? 0 : (1UL<<7))
         | ((palReadPad(TEENSY_PIN17_IOPORT, TEENSY_PIN17)==PAL_HIGH) ? 0 : (1UL<<8))
         | ((palReadPad(TEENSY_PIN16_IOPORT, TEENSY_PIN16)==PAL_HIGH) ? 0 : (1UL<<9))
         | ((palReadPad(TEENSY_PIN15_IOPORT, TEENSY_PIN15)==PAL_HIGH) ? 0 : (1UL<<10))
         | ((palReadPad(TEENSY_PIN14_IOPORT, TEENSY_PIN14)==PAL_HIGH) ? 0 : (1UL<<11))
         | ((palReadPad(TEENSY_PIN12_IOPORT, TEENSY_PIN12)==PAL_HIGH) ? 0 : (1UL<<12))
         | ((palReadPad(TEENSY_PIN11_IOPORT, TEENSY_PIN11)==PAL_HIGH) ? 0 : (1UL<<13))
         | ((palReadPad(TEENSY_PIN10_IOPORT, TEENSY_PIN10)==PAL_HIGH) ? 0 : (1UL<<14))
         | ((palReadPad(TEENSY_PIN9_IOPORT,  TEENSY_PIN9) ==PAL_HIGH) ? 0 : (1UL<<15))
         | ((palReadPad(TEENSY_PIN8_IOPORT,  TEENSY_PIN8) ==PAL_HIGH) ? 0 : (1UL<<16));

Offline Un4tural

  • Thread Starter
  • Posts: 9
Re: Editing TMK for teensy
« Reply #14 on: Wed, 02 March 2016, 07:11:49 »
so change places columns and rows in the matrix.c? strobing over the 6 pins rather than 17, then sensing the 17 pins, instead of the 6, so i change the column 6 pins to PULLUP, still input, keep the 17 as PUSHPULL? shouldn't i change the 17 pins to INPUT_PULLUP then and the 6 row pins to OUTPUT, swapping them places, or it doesn't matter that they're output for sensing?

More
#include <stdint.h>
#include <stdbool.h>
#include <string.h>
#include "hal.h"
#include "timer.h"
#include "wait.h"
#include "print.h"
#include "debug.h"
#include "matrix.h"


/*
 * Matt3o's WhiteFox
 * Column pins are input with internal pull-down. Row pins are output and strobe with high.
 * Key is high or 1 when it turns on.
 *
 *     col: { PTD0, PTD1, PTD4, PTD5, PTD6, PTD7, PTC1, PTC2 }
 *     row: { PTB2, PTB3, PTB18, PTB19, PTC0, PTC8, PTC9, PTC10, PTC11 }
 */
/* matrix state(1:on, 0:off) */
static matrix_row_t matrix[MATRIX_ROWS];
static matrix_row_t matrix_debouncing[MATRIX_ROWS];
static bool debouncing = false;
static uint16_t debouncing_time = 0;


void matrix_init(void)
{
    debug_matrix = true;
    /* Column(strobe) */
    palSetPadMode(TEENSY_PIN0_IOPORT, TEENSY_PIN0,  PAL_MODE_INPUT_PULLUP);
    palSetPadMode(TEENSY_PIN1_IOPORT, TEENSY_PIN1,  PAL_MODE_INPUT_PULLUP);
    palSetPadMode(TEENSY_PIN2_IOPORT, TEENSY_PIN2,  PAL_MODE_INPUT_PULLUP);
    palSetPadMode(TEENSY_PIN3_IOPORT, TEENSY_PIN3,  PAL_MODE_INPUT_PULLUP);
    palSetPadMode(TEENSY_PIN4_IOPORT, TEENSY_PIN4,  PAL_MODE_INPUT_PULLUP);
    palSetPadMode(TEENSY_PIN5_IOPORT, TEENSY_PIN5,  PAL_MODE_INPUT_PULLUP);

    /* Row(sense) */
    palSetPadMode(TEENSY_PIN25_IOPORT, TEENSY_PIN25, PAL_MODE_OUTPUT_PUSHPULL);
    palSetPadMode(TEENSY_PIN24_IOPORT, TEENSY_PIN24, PAL_MODE_OUTPUT_PUSHPULL);
    palSetPadMode(TEENSY_PIN23_IOPORT, TEENSY_PIN23, PAL_MODE_OUTPUT_PUSHPULL);
    palSetPadMode(TEENSY_PIN22_IOPORT, TEENSY_PIN22, PAL_MODE_OUTPUT_PUSHPULL);
    palSetPadMode(TEENSY_PIN21_IOPORT, TEENSY_PIN21, PAL_MODE_OUTPUT_PUSHPULL);
    palSetPadMode(TEENSY_PIN20_IOPORT, TEENSY_PIN20, PAL_MODE_OUTPUT_PUSHPULL);
    palSetPadMode(TEENSY_PIN19_IOPORT, TEENSY_PIN19, PAL_MODE_OUTPUT_PUSHPULL);
    palSetPadMode(TEENSY_PIN18_IOPORT, TEENSY_PIN18, PAL_MODE_OUTPUT_PUSHPULL);
    palSetPadMode(TEENSY_PIN17_IOPORT, TEENSY_PIN17, PAL_MODE_OUTPUT_PUSHPULL);
   palSetPadMode(TEENSY_PIN16_IOPORT, TEENSY_PIN16, PAL_MODE_OUTPUT_PUSHPULL);
   palSetPadMode(TEENSY_PIN15_IOPORT, TEENSY_PIN15, PAL_MODE_OUTPUT_PUSHPULL);
   palSetPadMode(TEENSY_PIN14_IOPORT, TEENSY_PIN14, PAL_MODE_OUTPUT_PUSHPULL);
   palSetPadMode(TEENSY_PIN12_IOPORT, TEENSY_PIN12, PAL_MODE_OUTPUT_PUSHPULL);
   palSetPadMode(TEENSY_PIN11_IOPORT, TEENSY_PIN11, PAL_MODE_OUTPUT_PUSHPULL);
   palSetPadMode(TEENSY_PIN10_IOPORT, TEENSY_PIN10, PAL_MODE_OUTPUT_PUSHPULL);
   palSetPadMode(TEENSY_PIN9_IOPORT, TEENSY_PIN9, PAL_MODE_OUTPUT_PUSHPULL);
   palSetPadMode(TEENSY_PIN8_IOPORT, TEENSY_PIN8, PAL_MODE_OUTPUT_PUSHPULL);

    memset(matrix, 0, MATRIX_ROWS);
    memset(matrix_debouncing, 0, MATRIX_ROWS);
}

uint8_t matrix_scan(void)
{
    for (int row = 0; row < MATRIX_ROWS; row++) {
        matrix_row_t data = 0;

        // strobe row
        switch (row) {
            case 0: palSetPad(TEENSY_PIN5_IOPORT, TEENSY_PIN5);   break;
            case 1: palSetPad(TEENSY_PIN4_IOPORT, TEENSY_PIN4);   break;
            case 2: palSetPad(TEENSY_PIN3_IOPORT, TEENSY_PIN3);   break;
            case 3: palSetPad(TEENSY_PIN2_IOPORT, TEENSY_PIN2);   break;
            case 4: palSetPad(TEENSY_PIN1_IOPORT, TEENSY_PIN1);   break;
            case 5: palSetPad(TEENSY_PIN0_IOPORT, TEENSY_PIN0);   break;
        }

        wait_us(1); // need wait to settle pin state

        // read col data: { PTD0, PTD1, PTD4, PTD5, PTD6, PTD7, PTC1, PTC2 }
         data =
       ((palReadPad(TEENSY_PIN25_IOPORT, TEENSY_PIN25)==PAL_HIGH) ? 0 : (1UL<<0))
         | ((palReadPad(TEENSY_PIN24_IOPORT, TEENSY_PIN24)==PAL_HIGH) ? 0 : (1UL<<1))
         | ((palReadPad(TEENSY_PIN23_IOPORT, TEENSY_PIN23)==PAL_HIGH) ? 0 : (1UL<<2))
         | ((palReadPad(TEENSY_PIN22_IOPORT, TEENSY_PIN22)==PAL_HIGH) ? 0 : (1UL<<3))
         | ((palReadPad(TEENSY_PIN21_IOPORT, TEENSY_PIN21)==PAL_HIGH) ? 0 : (1UL<<4))
         | ((palReadPad(TEENSY_PIN20_IOPORT, TEENSY_PIN20)==PAL_HIGH) ? 0 : (1UL<<5))
         | ((palReadPad(TEENSY_PIN19_IOPORT, TEENSY_PIN19)==PAL_HIGH) ? 0 : (1UL<<6))
         | ((palReadPad(TEENSY_PIN18_IOPORT, TEENSY_PIN18)==PAL_HIGH) ? 0 : (1UL<<7))
         | ((palReadPad(TEENSY_PIN17_IOPORT, TEENSY_PIN17)==PAL_HIGH) ? 0 : (1UL<<8))
         | ((palReadPad(TEENSY_PIN16_IOPORT, TEENSY_PIN16)==PAL_HIGH) ? 0 : (1UL<<9))
         | ((palReadPad(TEENSY_PIN15_IOPORT, TEENSY_PIN15)==PAL_HIGH) ? 0 : (1UL<<10))
         | ((palReadPad(TEENSY_PIN14_IOPORT, TEENSY_PIN14)==PAL_HIGH) ? 0 : (1UL<<11))
         | ((palReadPad(TEENSY_PIN12_IOPORT, TEENSY_PIN12)==PAL_HIGH) ? 0 : (1UL<<12))
         | ((palReadPad(TEENSY_PIN11_IOPORT, TEENSY_PIN11)==PAL_HIGH) ? 0 : (1UL<<13))
         | ((palReadPad(TEENSY_PIN10_IOPORT, TEENSY_PIN10)==PAL_HIGH) ? 0 : (1UL<<14))
         | ((palReadPad(TEENSY_PIN9_IOPORT,  TEENSY_PIN9) ==PAL_HIGH) ? 0 : (1UL<<15))
         | ((palReadPad(TEENSY_PIN8_IOPORT,  TEENSY_PIN8) ==PAL_HIGH) ? 0 : (1UL<<16));

        // un-strobe row
        switch (row) {
            case 0: palClearPad(TEENSY_PIN5_IOPORT, TEENSY_PIN5); break;
            case 1: palClearPad(TEENSY_PIN4_IOPORT, TEENSY_PIN4); break;
            case 2: palClearPad(TEENSY_PIN3_IOPORT, TEENSY_PIN3); break;
            case 3: palClearPad(TEENSY_PIN2_IOPORT, TEENSY_PIN2); break;
            case 4: palClearPad(TEENSY_PIN1_IOPORT, TEENSY_PIN1); break;
            case 5: palClearPad(TEENSY_PIN0_IOPORT, TEENSY_PIN0); break;
        }

        if (matrix_debouncing[row] != data) {
            matrix_debouncing[row] = data;
            debouncing = true;
            debouncing_time = timer_read();
        }
    }

    if (debouncing && timer_elapsed(debouncing_time) > DEBOUNCE) {
        for (int row = 0; row < MATRIX_ROWS; row++) {
            matrix[row] = matrix_debouncing[row];
        }
        debouncing = false;
    }
    return 1;
}

bool matrix_is_on(uint8_t row, uint8_t col)
{
    return (matrix[row] & (1<<col));
}

matrix_row_t matrix_get_row(uint8_t row)
{
    return matrix[row];
}

void matrix_print(void)
{
    xprintf("\nr/c 01234567\n");
    for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
        xprintf("%X0: ", row);
        matrix_row_t data = matrix_get_row(row);
        for (int col = 0; col < MATRIX_COLS; col++) {
            if (data & (1<<col))
                xprintf("1");
            else
                xprintf("0");
        }
        xprintf("\n");
    }
}

i suppose i only need to sort the pullup/pushpull and input/output for the rows/columns. this will add a layer of visualization to the keymaping but if it works it works.

since ill have 17 now rows, and 6 columns, the keymap only represents digits 0-8, do i use hex for it? (i assume K## is the row/column, what happens when theres more rows than single decimal/hex digit can display?

Offline flabbergast

  • Posts: 234
  • Location: UK
Re: Editing TMK for teensy
« Reply #15 on: Wed, 02 March 2016, 17:20:12 »
Pins 0-5 should be OUTPUT_PUSHPULL, the remaining ones should be INPUT_PULLUP. In the 'strobe' part for pins 0 - 5, should use 'palClearPad', for the 'unstrobe' part use 'palSetPad'.

In the keymap file, in the definition of the KEYMAP macro, you can use whatever names you like. It is like a function: you name the parameters in KEYMAP( ... ) part, and then use those names in the second part. The second part (in the curly brackets), you should have 6 rows, each row 17 entries.

Offline Un4tural

  • Thread Starter
  • Posts: 9
Re: Editing TMK for teensy
« Reply #16 on: Thu, 03 March 2016, 12:24:28 »
well i think i got most of it right, however i seem to get

More
$ make -f makefile
tmk_core/tool/chibios/chibios.mk:88: tmk_core/tool/chibios/chibios/os/common/ports/ARMCMx/compilers/GCC/mk/startup_kl2x.mk: No such file or directory
tmk_core/tool/chibios/chibios.mk:90: tmk_core/tool/chibios/chibios/os/hal/hal.mk: No such file or directory
tmk_core/tool/chibios/chibios.mk:91: tmk_core/tool/chibios/chibios/os/hal/ports/KINETIS/KL2x/platform.mk: No such file or directory
tmk_core/tool/chibios/chibios.mk:95: tmk_core/tool/chibios/chibios/os/hal/boards/PJRC_TEENSY_LC/board.mk: No such file or directory
tmk_core/tool/chibios/chibios.mk:97: tmk_core/tool/chibios/chibios/os/hal/osal/rt/osal.mk: No such file or directory
tmk_core/tool/chibios/chibios.mk:99: tmk_core/tool/chibios/chibios/os/rt/rt.mk: No such file or directory
tmk_core/tool/chibios/chibios.mk:100: tmk_core/tool/chibios/chibios/os/rt/ports/ARMCMx/compilers/GCC/mk/port_v6m.mk: No such file or directory
tmk_core/tool/chibios/chibios.mk:231: tmk_core/tool/chibios/chibios/os/common/ports/ARMCMx/compilers/GCC/rules.mk: No such file or directory
make: *** No rule to make target `tmk_core/tool/chibios/chibios/os/common/ports/ARMCMx/compilers/GCC/rules.mk'.  Stop.

when i try to make -f makefile. tried various compatibility modes with cygwin and just using windows cmd, same error win10. I'll install cygwin on my other pc on win7 and try again i guess... unless you can suggest some workaround or software to do this. the files aren't missing, they are there. downloaded chibios and everything, it's all in there... atleast no more error 1 or 2 i guess. I should just install linux and leave it at that, never had any luck with this kind of thing in windows...

going to get linux going, after trying to get backtrack fully loaded on a flash drive and failing no matter what i tried didn't need it... might as well now do it. (grub2 installing onto flash drive problems, after getting grub2 on it backtrack failing to install and vise versa... anyways)

this is what i got now, with your heavy guidance i think it's fine now. gonna cook it onto the teensy, eventually once i get this sorted and do the keymap then. quite happy it seems promising to get this thing working, curious why it wasn't used yet over teensy 2.0 and 3.0, as it seems tiny and easy to tuck away with quite a lot of functionality. i guess cause it's fairly recent? pi zero costs 5£ less too, would be cool to make a keyboard with a mini pc to hook up to tv for streaming, with a battery inside and the micro usb as a plug in keyboard. i can dream though, way beyond that me.
More
#include <stdint.h>
#include <stdbool.h>
#include <string.h>
#include "hal.h"
#include "timer.h"
#include "wait.h"
#include "print.h"
#include "debug.h"
#include "matrix.h"


/*
 * Matt3o's WhiteFox
 * Column pins are input with internal pull-down. Row pins are output and strobe with high.
 * Key is high or 1 when it turns on.
 *
 *     col: { PTD0, PTD1, PTD4, PTD5, PTD6, PTD7, PTC1, PTC2 }
 *     row: { PTB2, PTB3, PTB18, PTB19, PTC0, PTC8, PTC9, PTC10, PTC11 }
 */
/* matrix state(1:on, 0:off) */
static matrix_row_t matrix[MATRIX_ROWS];
static matrix_row_t matrix_debouncing[MATRIX_ROWS];
static bool debouncing = false;
static uint16_t debouncing_time = 0;


void matrix_init(void)
{
    debug_matrix = true;
    /* Column(strobe) */
    palSetPadMode(TEENSY_PIN0_IOPORT, TEENSY_PIN0,  PAL_MODE_OUTPUT_PUSHPULL);
    palSetPadMode(TEENSY_PIN1_IOPORT, TEENSY_PIN1,  PAL_MODE_OUTPUT_PUSHPULL);
    palSetPadMode(TEENSY_PIN2_IOPORT, TEENSY_PIN2,  PAL_MODE_OUTPUT_PUSHPULL);
    palSetPadMode(TEENSY_PIN3_IOPORT, TEENSY_PIN3,  PAL_MODE_OUTPUT_PUSHPULL);
    palSetPadMode(TEENSY_PIN4_IOPORT, TEENSY_PIN4,  PAL_MODE_OUTPUT_PUSHPULL);
    palSetPadMode(TEENSY_PIN5_IOPORT, TEENSY_PIN5,  PAL_MODE_OUTPUT_PUSHPULL);

    /* Row(sense) */
    palSetPadMode(TEENSY_PIN25_IOPORT, TEENSY_PIN25, PAL_MODE_INPUT_PULLUP);
    palSetPadMode(TEENSY_PIN24_IOPORT, TEENSY_PIN24, PAL_MODE_INPUT_PULLUP);
    palSetPadMode(TEENSY_PIN23_IOPORT, TEENSY_PIN23, PAL_MODE_INPUT_PULLUP);
    palSetPadMode(TEENSY_PIN22_IOPORT, TEENSY_PIN22, PAL_MODE_INPUT_PULLUP);
    palSetPadMode(TEENSY_PIN21_IOPORT, TEENSY_PIN21, PAL_MODE_INPUT_PULLUP);
    palSetPadMode(TEENSY_PIN20_IOPORT, TEENSY_PIN20, PAL_MODE_INPUT_PULLUP);
    palSetPadMode(TEENSY_PIN19_IOPORT, TEENSY_PIN19, PAL_MODE_INPUT_PULLUP);
    palSetPadMode(TEENSY_PIN18_IOPORT, TEENSY_PIN18, PAL_MODE_INPUT_PULLUP);
    palSetPadMode(TEENSY_PIN17_IOPORT, TEENSY_PIN17, PAL_MODE_INPUT_PULLUP);
   palSetPadMode(TEENSY_PIN16_IOPORT, TEENSY_PIN16, PAL_MODE_INPUT_PULLUP);
   palSetPadMode(TEENSY_PIN15_IOPORT, TEENSY_PIN15, PAL_MODE_INPUT_PULLUP);
   palSetPadMode(TEENSY_PIN14_IOPORT, TEENSY_PIN14, PAL_MODE_INPUT_PULLUP);
   palSetPadMode(TEENSY_PIN12_IOPORT, TEENSY_PIN12, PAL_MODE_INPUT_PULLUP);
   palSetPadMode(TEENSY_PIN11_IOPORT, TEENSY_PIN11, PAL_MODE_INPUT_PULLUP);
   palSetPadMode(TEENSY_PIN10_IOPORT, TEENSY_PIN10, PAL_MODE_INPUT_PULLUP);
   palSetPadMode(TEENSY_PIN9_IOPORT, TEENSY_PIN9, PAL_MODE_INPUT_PULLUP);
   palSetPadMode(TEENSY_PIN8_IOPORT, TEENSY_PIN8, PAL_MODE_INPUT_PULLUP);

    memset(matrix, 0, MATRIX_ROWS);
    memset(matrix_debouncing, 0, MATRIX_ROWS);
}

uint8_t matrix_scan(void)
{
    for (int row = 0; row < MATRIX_ROWS; row++) {
        matrix_row_t data = 0;

        // strobe row
        switch (row) {
            case 0: palClearPad(TEENSY_PIN5_IOPORT, TEENSY_PIN5);   break;
            case 1: palClearPad(TEENSY_PIN4_IOPORT, TEENSY_PIN4);   break;
            case 2: palClearPad(TEENSY_PIN3_IOPORT, TEENSY_PIN3);   break;
            case 3: palClearPad(TEENSY_PIN2_IOPORT, TEENSY_PIN2);   break;
            case 4: palClearPad(TEENSY_PIN1_IOPORT, TEENSY_PIN1);   break;
            case 5: palClearPad(TEENSY_PIN0_IOPORT, TEENSY_PIN0);   break;
        }

        wait_us(1); // need wait to settle pin state

        // read col data: { PTD0, PTD1, PTD4, PTD5, PTD6, PTD7, PTC1, PTC2 }
         data =
         ((palReadPad(TEENSY_PIN25_IOPORT, TEENSY_PIN25)==PAL_HIGH) ? 0 : (1UL<<0))
         | ((palReadPad(TEENSY_PIN24_IOPORT, TEENSY_PIN24)==PAL_HIGH) ? 0 : (1UL<<1))
         | ((palReadPad(TEENSY_PIN23_IOPORT, TEENSY_PIN23)==PAL_HIGH) ? 0 : (1UL<<2))
         | ((palReadPad(TEENSY_PIN22_IOPORT, TEENSY_PIN22)==PAL_HIGH) ? 0 : (1UL<<3))
         | ((palReadPad(TEENSY_PIN21_IOPORT, TEENSY_PIN21)==PAL_HIGH) ? 0 : (1UL<<4))
         | ((palReadPad(TEENSY_PIN20_IOPORT, TEENSY_PIN20)==PAL_HIGH) ? 0 : (1UL<<5))
         | ((palReadPad(TEENSY_PIN19_IOPORT, TEENSY_PIN19)==PAL_HIGH) ? 0 : (1UL<<6))
         | ((palReadPad(TEENSY_PIN18_IOPORT, TEENSY_PIN18)==PAL_HIGH) ? 0 : (1UL<<7))
         | ((palReadPad(TEENSY_PIN17_IOPORT, TEENSY_PIN17)==PAL_HIGH) ? 0 : (1UL<<8))
         | ((palReadPad(TEENSY_PIN16_IOPORT, TEENSY_PIN16)==PAL_HIGH) ? 0 : (1UL<<9))
         | ((palReadPad(TEENSY_PIN15_IOPORT, TEENSY_PIN15)==PAL_HIGH) ? 0 : (1UL<<10))
         | ((palReadPad(TEENSY_PIN14_IOPORT, TEENSY_PIN14)==PAL_HIGH) ? 0 : (1UL<<11))
         | ((palReadPad(TEENSY_PIN12_IOPORT, TEENSY_PIN12)==PAL_HIGH) ? 0 : (1UL<<12))
         | ((palReadPad(TEENSY_PIN11_IOPORT, TEENSY_PIN11)==PAL_HIGH) ? 0 : (1UL<<13))
         | ((palReadPad(TEENSY_PIN10_IOPORT, TEENSY_PIN10)==PAL_HIGH) ? 0 : (1UL<<14))
         | ((palReadPad(TEENSY_PIN9_IOPORT,  TEENSY_PIN9) ==PAL_HIGH) ? 0 : (1UL<<15))
         | ((palReadPad(TEENSY_PIN8_IOPORT,  TEENSY_PIN8) ==PAL_HIGH) ? 0 : (1UL<<16));

        // un-strobe row
        switch (row) {
            case 0: palSetPad(TEENSY_PIN5_IOPORT, TEENSY_PIN5); break;
            case 1: palSetPad(TEENSY_PIN4_IOPORT, TEENSY_PIN4); break;
            case 2: palSetPad(TEENSY_PIN3_IOPORT, TEENSY_PIN3); break;
            case 3: palSetPad(TEENSY_PIN2_IOPORT, TEENSY_PIN2); break;
            case 4: palSetPad(TEENSY_PIN1_IOPORT, TEENSY_PIN1); break;
            case 5: palSetPad(TEENSY_PIN0_IOPORT, TEENSY_PIN0); break;
        }

        if (matrix_debouncing[row] != data) {
            matrix_debouncing[row] = data;
            debouncing = true;
            debouncing_time = timer_read();
        }
    }

    if (debouncing && timer_elapsed(debouncing_time) > DEBOUNCE) {
        for (int row = 0; row < MATRIX_ROWS; row++) {
            matrix[row] = matrix_debouncing[row];
        }
        debouncing = false;
    }
    return 1;
}

bool matrix_is_on(uint8_t row, uint8_t col)
{
    return (matrix[row] & (1<<col));
}

matrix_row_t matrix_get_row(uint8_t row)
{
    return matrix[row];
}

void matrix_print(void)
{
    xprintf("\nr/c 01234567\n");
    for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
        xprintf("%X0: ", row);
        matrix_row_t data = matrix_get_row(row);
        for (int col = 0; col < MATRIX_COLS; col++) {
            if (data & (1<<col))
                xprintf("1");
            else
                xprintf("0");
        }
        xprintf("\n");
    }
}

Offline flabbergast

  • Posts: 234
  • Location: UK
Re: Editing TMK for teensy
« Reply #17 on: Thu, 03 March 2016, 12:52:48 »
Are you sure the files are really there?
For Teensy LC you need to get chibios fork from here (click on 'download ZIP'. Instead you can clone the repo with git, but then you need to remember to check out the 'kinetis' branch.)

Teensy 2.0 is used a lot; the ARM Teensies are relatively new and they required pretty much new code.

Offline Un4tural

  • Thread Starter
  • Posts: 9
Re: Editing TMK for teensy
« Reply #18 on: Thu, 03 March 2016, 15:32:22 »
https://gyazo.com/08a3b4660fdaa606efc07944e121ca55

tried both branch that came with the whitefox and the one you've linked, files are definitely there, ill pop install ubuntu and do it on that i suppose, will be less painful and wont get these random errors.

edit: messed around with windows some more, replaced one of the .dll files in winavr which fixed some of the issue, i don't even know which anymore, however no matter what i get make (e=2) The system cannot find the file specified.

This happens on compiling crt0_v6m.s , i think ill give up with windows doing anything more complex than internet and games at this point and go configure ubuntu for now...
« Last Edit: Fri, 04 March 2016, 14:03:47 by Un4tural »