]> git.donarmstrong.com Git - kiibohd-controller.git/commitdiff
Pre Tandy1000 overhaul
authorJacob Alexander <triplehaata@gmail.com>
Tue, 29 Nov 2011 06:20:04 +0000 (22:20 -0800)
committerJacob Alexander <triplehaata@gmail.com>
Tue, 29 Nov 2011 06:20:04 +0000 (22:20 -0800)
17 files changed:
CMakeLists.txt
Debug/full/setup.cmake
Debug/led/setup.cmake
Debug/print/setup.cmake
Keymap/tandy1000.h
Scan/HeathZenith/matrix.h
Scan/MicroSwitch8304/scan_loop.c
Scan/MicroSwitch8304/scan_loop.h
Scan/Tandy1000/scan_loop.c
Scan/Tandy1000/scan_loop.h
Scan/Tandy1000/setup.cmake
Scan/matrix/matrix_scan.c
Scan/matrix/matrix_scan.h
Scan/matrix/scan_loop.c
Scan/matrix/scan_loop.h
USB/pjrc/usb_keyboard_debug.c
setup.cmake

index 7cc93c25290def46b479124705ebd66b7ea4a309..6719d935977c4028fda1801a5ea90ac146232fda 100644 (file)
@@ -64,7 +64,7 @@ set( SRCS
 #| "atmega32u4"       # Teensy   2.0
 #| "at90usb646"       # Teensy++ 1.0
 #| "at90usb1286"      # Teensy++ 2.0
-set( MCU "atmega32u4" )
+set( MCU "at90usb1286" )
 
 
 #| Compiler flag to set the C Standard level.
index e8f8205e95c30ba428e31efa0060f05e2fa770af..023405964eeb177112e07bae9e9e7fd53ec4f51a 100644 (file)
@@ -18,6 +18,13 @@ set( DEBUG_SRCS
 )
 
 
+###
+# Setup File Dependencies
+#
+add_file_dependencies( ../led/led.c ../led/led.h )
+add_file_dependencies( ../led/print.c ../led/print.h )
+
+
 ###
 # Module Specific Options
 #
index 58c375dbf6f183f2d9ba179dcd599e97d89ac7ba..bb55e5bc97b2c41259fd46ae00c68a3ab8a90472 100644 (file)
@@ -16,6 +16,12 @@ set( DEBUG_SRCS
 )
 
 
+###
+# Setup File Dependencies
+#
+add_file_dependencies( ../led/led.c ../led/led.h )
+
+
 ###
 # Module Specific Options
 #
index 45faff33360e45c4d1422a5cb84315aa6191849f..abd4b8d75865b7154aacadd2998afcfc1343f9de 100644 (file)
@@ -16,6 +16,12 @@ set( DEBUG_SRCS
 )
 
 
+###
+# Setup File Dependencies
+#
+add_file_dependencies( ../led/print.c ../led/print.h )
+
+
 ###
 # Module Specific Options
 #
index 8aba2a635bfa70c44703add702bf724db0712816..379d8509535d43320b1bee692e823c3195d2d651 100644 (file)
@@ -27,9 +27,9 @@
 
 // ----- Variables -----
 
-static uint8_t tandy1000_modifierMask[] = { 0x1D, 0x2A, 0x36, 0x38, 0x46 };
+static uint8_t tandy1000_ModifierMask[] = { 0x1D, 0x2A, 0x36, 0x38, 0x46 };
 
-static uint8_t tandy1000_map[] = { 0,
+static uint8_t tandy1000_DefaultMap[] = { 0,
                                KEY_ESC,
                                KEY_1,
                                KEY_2,
@@ -122,7 +122,7 @@ static uint8_t tandy1000_map[] = { 0,
                                KEY_F12, // 0x5A
 };
 
-static uint8_t tandy1000_colemak[] = { 0,
+static uint8_t tandy1000_ColemakMap[] = { 0,
                                KEY_ESC,
                                KEY_1,
                                KEY_2,
index 5792661436924a3b556dc5dff3f44cdc87997da5..b8c029e44c5c05d3f8d3978eaddd963db9c824c8 100644 (file)
 static const uint8_t matrix_pinout[][MAX_ROW_SIZE + 1] = {
 
 
-// TODO Pinout
+// Bread-board debug pinout
 // Note: Pins 49 and 60 are connected together, by row AND column, why? dunno...(shift)
-  { scanMode, pinF0, pinF4, pinB7, pinD3, pinF5, pinF1, pinD1, pinD2, pinE0, pinE1, pinE2, pinE3 },
-  { pinF6,    1,     2,     3,     4,     5,     6,     7,     8,     0,     0,     0,     0     },
-  { pinF7,    16,    15,    14,    13,    12,    11,    10,    9,     0,     0,     0,     0     },
-  { pinB2,    17,    18,    19,    20,    21,    22,    23,    24,    0,     0,     0,     0     },
-  { pinD0,    32,    31,    30,    29,    28,    27,    26,    25,    0,     0,     0,     0     },
-  { pinB6,    35,    36,    37,    38,    39,    40,    41,    42,    0,     0,     0,     0     },
-  { pinB3,    47,    61,    46,    45,    44,    43,    58,    0,     0,     0,     0,     0     },
-  { pinA0,    50,    51,    52,    53,    54,    55,    56,    57,    0,     0,     0,     0     },
-  { pinB0,    62,    63,    0,     0,     59,    0,     0,     0,     0,     0,     0,     0     },
-  { pinB0,    0,     0,     0,     0,     0,     0,     0,     0,     33,    34,    48,    49    },
+  { scanMode, pinC6, pinC5, pinC4, pinC3, pinC2, pinE1, pinC0, pinC1, pinD7, pinE0, pinD6, pinC7 },
+  { pinF3,    1,     2,     3,     4,     5,     6,     7,     8,     0,     0,     0,     0     },
+  { pinE7,    16,    15,    14,    13,    12,    11,    10,    9,     0,     0,     0,     0     },
+  { pinB4,    17,    18,    19,    20,    21,    22,    23,    24,    0,     0,     0,     0     },
+  { pinB0,    32,    31,    30,    29,    28,    27,    26,    25,    0,     0,     0,     0     },
+  { pinB2,    35,    36,    37,    38,    39,    40,    41,    42,    0,     0,     0,     0     },
+  { pinB1,    47,    61,    46,    45,    44,    43,    58,    0,     0,     0,     0,     0     },
+  { pinB5,    50,    51,    52,    53,    54,    55,    56,    57,    0,     0,     0,     0     },
+  { pinE6,    62,    63,    0,     0,     59,    0,     0,     0,     0,     0,     0,     0     },
+  { pinB6,    0,     0,     0,     0,     0,     0,     0,     0,     33,    34,    48,    49    },
 
 
 
index 478a3348ea5d6e6db47ff34416bec1d79e2e95de..a378424d652b96fa0443617743f2f666b177c8b8 100644 (file)
@@ -94,6 +94,10 @@ inline void scan_setup()
 
        // Initially buffer doesn't need to be cleared (it's empty...)
        BufferReadyToClear = 0;
+
+       // Reset the keyboard before scanning, we might be in a wierd state
+       // Note: This should be run asap, but we need the USART setup to run this command on the 8304
+       scan_resetKeyboard();
 }
 
 
@@ -223,3 +227,10 @@ void scan_unlockKeyboard( void )
        SET_RESET();
 }
 
+// Reset Keyboard
+void scan_resetKeyboard( void )
+{
+       // Reset command for the 8304
+       scan_sendData( 0x92 );
+}
+
index bca52836999113d6bc8e4eeb881b52939c4d3efc..08b6883b4b6e927b4c9c87353c643d272c46c235 100644 (file)
@@ -33,7 +33,7 @@
 
 // ----- Defines -----
 
-#define KEYBOARD_SIZE 0x62 // 76 - Size of the array space for the keyboard(max index)
+#define KEYBOARD_SIZE 0x62 // 98 - Size of the array space for the keyboard(max index)
 #define KEYBOARD_BUFFER 24 // Max number of key signals to buffer
 
 
@@ -58,6 +58,7 @@ uint8_t scan_sendData( uint8_t dataPayload );
 void scan_finishedWithBuffer( void );
 void scan_lockKeyboard( void );
 void scan_unlockKeyboard( void );
+void scan_resetKeyboard( void );
 
 
 #endif // __SCAN_LOOP_H
index 519dd92905f8c37f9c3f6f2f45e01f99f6e00c26..a44e789389c4ee36d941e72108d4e9fc6d8cfa51 100644 (file)
@@ -23,6 +23,8 @@
 
 // AVR Includes
 #include <avr/interrupt.h>
+#include <avr/io.h>
+#include <util/delay.h>
 
 // Project Includes
 #include <led.h>
 
 
 // ----- Macros -----
+
 #define READ_CLK       CLK_READ &   (1 <<  CLK_PIN) ? 1 : 0
 #define READ_DATA     DATA_READ &   (1 << DATA_PIN) ? 0 : 1
 
 #define UNSET_INTR()  INTR_DDR &= ~(1 << INTR_PIN)
 #define   SET_INTR()  INTR_DDR |=  (1 << INTR_PIN)
 
+#define bufferAdd(byte) \
+               if ( KeyIndex_BufferUsed < KEYBOARD_BUFFER ) \
+                       KeyIndex_Buffer[KeyIndex_BufferUsed++] = byte
 
 
 // ----- Variables -----
 
-uint8_t KeyIndex_Array[KEYBOARD_SIZE + 1];
+// Buffer used to inform the macro processing module which keys have been detected as pressed
+volatile uint8_t KeyIndex_Buffer[KEYBOARD_BUFFER];
+volatile uint8_t KeyIndex_BufferUsed;
+
 
 // Scan Code Retrieval Variables
 uint8_t inputData    = 0xFF;
@@ -76,6 +85,12 @@ uint8_t packet_index = 0;
 // Setup
 inline void scan_setup()
 {
+       // Initially reset the keyboard (just in case we are in a wierd state)
+       scan_resetKeyboard();
+
+       // Setup SPI for data input using the clock and data inputs
+       // TODO
+       /*
        // Setup inputs
        CLK_DDR  &= ~(1 << CLK_PIN);
        DATA_DDR &= ~(1 << DATA_PIN);
@@ -83,22 +98,14 @@ inline void scan_setup()
        // Setup Pull-up's
        CLK_PORT  &= ~(1 << CLK_PIN);  // (CLK)
        DATA_PORT &= ~(1 << DATA_PIN); // (/DATA)
+       */
 
        // Setup Keyboard Interrupt
        INTR_DDR  &= ~(1 << INTR_PIN);
        INTR_PORT &= ~(1 << INTR_PIN);
 
-       /* Interrupt Style (Not working fully)
-       cli();
-       // Setup interrupt on the CLK pin TODO Better defines
-       EICRA |= 0x03; // Rising Edge Interrupt
-       EIMSK |= (1 << INT0);
-
-       // Setup interrupt on the DATA pin TODO Better defines
-       EICRA |= 0x08; // Falling Edge Interrupt
-       EIMSK |= (1 << INT1);
-       sei();
-       */
+       // Setup Keyboard Reset Line
+       // TODO
 }
 
 
@@ -212,28 +219,35 @@ inline uint8_t scan_loop()
        return packet_index;
 }
 
-// Detection interrupt, signalled by a clock pulse from CLK_PIN
-ISR(INT0_vect)
+// Send data
+// XXX Not used with the Tandy1000
+uint8_t scan_sendData( uint8_t dataPayload )
 {
-       //cli(); // Disable Interrupts
-
-       // Append 1 bit of data
-       //inputData &= ~(READ_DATA << packet_index);
-       packet_index++;
-
-       //sei(); // Re-enable Interrupts
+       return 0;
 }
 
-// Data Detected
-ISR(INT1_vect)
+// Signal KeyIndex_Buffer that it has been properly read
+// TODO
+void scan_finishedWithBuffer( void )
 {
-       // Append 1 bit of data
-       inputData &= ~(1 << packet_index);
-       packet_index++;
+}
 
-       // Disable Clk Signal (Not needed if there's a data signal)
-       EIFR |= (1 << INTF0);
+// Reset/Hold keyboard
+// Warning! This will cause the keyboard to not send any data, so you can't disable with a keypress
+// The Tandy 1000 keyboard has a dedicated hold/processor interrupt line
+void scan_lockKeyboard( void )
+{
+       UNSET_INTR();
 }
 
+void scan_unlockKeyboard( void )
+{
+       SET_INTR();
+}
 
+// Reset Keyboard
+void scan_resetKeyboard( void )
+{
+       // TODO Tandy1000 has a dedicated reset line
+}
 
index 10b6fbce76d76644a0ae523be2a5f6ff67d02cea..fc32ca77733734d88e49539d28b209ad5ced7547 100644 (file)
 // ----- Defines -----
 
 #define KEYBOARD_SIZE 0x5A // 90 - Size of the array space for the keyboardr(max index)
+#define KEYBOARD_BUFFER 24 // Max number of key signals to buffer
 
 
 
 // ----- Variables -----
 
-// NOTE: Highest Bit: Valid keypress (0x80 is valid keypress)
-//        Other Bits: Pressed state sample counter
-extern              uint8_t KeyIndex_Array [KEYBOARD_SIZE + 1];
-       static const uint8_t KeyIndex_Size = KEYBOARD_SIZE;
+extern volatile     uint8_t KeyIndex_Buffer[KEYBOARD_BUFFER];
+extern volatile     uint8_t KeyIndex_BufferUsed;
 
 
 
 // ----- Functions -----
 
+// Functions used by main.c
 void scan_setup( void );
 uint8_t scan_loop( void );
 
+
+// Functions available to macro.c
+uint8_t scan_sendData( uint8_t dataPayload );
+
+void scan_finishedWithBuffer( void );
+void scan_lockKeyboard( void );
+void scan_unlockKeyboard( void );
+void scan_resetKeyboard( void );
+
+
 #endif // __SCAN_LOOP_H
 
index cb3bf6ad3e1631298f125d0a69b3ac0df793798c..95f05e62cd831c744425b84af27d7e8929f99a56 100644 (file)
@@ -23,7 +23,8 @@ add_definitions( -I${HEAD_DIR}/Keymap )
 
 #| Keymap Settings
 add_definitions(
-       -DMODIFIER_MASK=tandy1000_modifierMask
-       -DKEYINDEX_MASK=tandy1000_colemak
+       -DMODIFIER_MASK=tandy1000_ModifierMask
+       -DKEYINDEX_MASK=tandy1000_ColemakMap
+       #-DKEYINDEX_MASK=tandy1000_DefaultMap
 )
 
index 54f3b6d2d0660da7a28dfe44fb7a41a5a5b72dc8..5071cceb55ad7ce65a0dc9eeb4dd6ba233c77d88 100644 (file)
@@ -23,6 +23,7 @@
 
 // AVR Includes
 #include <avr/io.h>
+#include <util/delay.h>
 
 // Project Includes
 #include <print.h>
 // -- pinSetup Macros --
 #define REG_SET(reg)   reg |= (1 << ( matrix[row*(MAX_ROW_SIZE+1)+col] % 10 ) )
                        
-#define PIN_SET_COL(pin) \
-                       switch ( scanMode ) { \
+#define PIN_SET_COL(pin,scan) \
+                       switch ( scan ) { \
                        case scanCol: \
-                       case scanCol_powrRow: \
+                       case scanRow_powrCol: \
                        case scanDual: \
                                REG_SET(port##pin); break; \
-                       case scanRow_powrCol: REG_SET(ddr##pin); REG_SET(port##pin); break; \
+                       case scanCol_powrRow: REG_SET(ddr##pin); REG_SET(port##pin); break; \
                        } \
                        break
 
-#define PIN_SET_ROW(pin) \
-                       switch ( scanMode ) { \
+#define PIN_SET_ROW(pin,scan) \
+                       switch ( scan ) { \
                        case scanRow: \
-                       case scanRow_powrCol: \
+                       case scanCol_powrRow: \
                        case scanDual: \
                                REG_SET(port##pin); break; \
-                       case scanCol_powrRow: REG_SET(ddr##pin); REG_SET(port##pin); break; \
+                       case scanRow_powrCol: REG_SET(ddr##pin); REG_SET(port##pin); break; \
                        } \
                        break
 
 #define PIN_TEST_COL(pin) \
                        scanCode = matrix[row*(MAX_ROW_SIZE+1)+col]; \
                        if ( scanCode && !( pin & ( 1 << ( matrix[0*(MAX_ROW_SIZE+1)+col] % 10 ) ) ) ) \
+                       { \
+                               warn_print("YAY!"); \
                                detectArray[scanCode]++; \
+                       } \
                        break
 
 // -- Row Scan Macros --
 // ----- Functions -----
 
 // Goes through the defined matrix and matrix mode, and sets the initial state of all of the available pins
-inline void matrix_pinSetup( uint8_t *matrix )
+void matrix_pinSetup( uint8_t *matrix, uint8_t scanType )
 {
        // Setup the variables
        uint8_t portA = 0x00;
@@ -136,17 +140,17 @@ inline void matrix_pinSetup( uint8_t *matrix )
                switch ( matrix[row*(MAX_ROW_SIZE+1)+col] )
                {
                PIN_CASE(A):
-                       PIN_SET_ROW(A);
+                       PIN_SET_ROW(A, scanType);
                PIN_CASE(B):
-                       PIN_SET_ROW(B);
+                       PIN_SET_ROW(B, scanType);
                PIN_CASE(C):
-                       PIN_SET_ROW(C);
+                       PIN_SET_ROW(C, scanType);
                PIN_CASE(D):
-                       PIN_SET_ROW(D);
+                       PIN_SET_ROW(D, scanType);
                PIN_CASE(E):
-                       PIN_SET_ROW(E);
+                       PIN_SET_ROW(E, scanType);
                PIN_CASE(F):
-                       PIN_SET_ROW(F);
+                       PIN_SET_ROW(F, scanType);
 
                default:
                        continue;
@@ -160,17 +164,17 @@ inline void matrix_pinSetup( uint8_t *matrix )
                switch ( matrix[row*(MAX_ROW_SIZE+1)+col] )
                {
                PIN_CASE(A):
-                       PIN_SET_COL(A);
+                       PIN_SET_COL(A, scanType);
                PIN_CASE(B):
-                       PIN_SET_COL(B);
+                       PIN_SET_COL(B, scanType);
                PIN_CASE(C):
-                       PIN_SET_COL(C);
+                       PIN_SET_COL(C, scanType);
                PIN_CASE(D):
-                       PIN_SET_COL(D);
+                       PIN_SET_COL(D, scanType);
                PIN_CASE(E):
-                       PIN_SET_COL(E);
+                       PIN_SET_COL(E, scanType);
                PIN_CASE(F):
-                       PIN_SET_COL(F);
+                       PIN_SET_COL(F, scanType);
 
                default:
                        continue;
@@ -178,26 +182,30 @@ inline void matrix_pinSetup( uint8_t *matrix )
        }
 
        // Pin Status
-       char tmpStr[6];
-       info_print("Initial Matrix Pin Setup");
-       info_print(" ddrA  ddrB  ddrC  ddrD  ddrE  ddrF");
-       print("      ");
-       hexToStr_op( ddrA, tmpStr, 2 ); dPrintStrs( "  0x", tmpStr );
-       hexToStr_op( ddrB, tmpStr, 2 ); dPrintStrs( "  0x", tmpStr );
-       hexToStr_op( ddrC, tmpStr, 2 ); dPrintStrs( "  0x", tmpStr );
-       hexToStr_op( ddrD, tmpStr, 2 ); dPrintStrs( "  0x", tmpStr );
-       hexToStr_op( ddrE, tmpStr, 2 ); dPrintStrs( "  0x", tmpStr );
-       hexToStr_op( ddrF, tmpStr, 2 ); dPrintStrs( "  0x", tmpStr );
-       print("\n");
-       info_print("portA portB portC portD portE portF");
-       print("      ");
-       hexToStr_op( portA, tmpStr, 2 ); dPrintStrs( "  0x", tmpStr );
-       hexToStr_op( portB, tmpStr, 2 ); dPrintStrs( "  0x", tmpStr );
-       hexToStr_op( portC, tmpStr, 2 ); dPrintStrs( "  0x", tmpStr );
-       hexToStr_op( portD, tmpStr, 2 ); dPrintStrs( "  0x", tmpStr );
-       hexToStr_op( portE, tmpStr, 2 ); dPrintStrs( "  0x", tmpStr );
-       hexToStr_op( portF, tmpStr, 2 ); dPrintStrs( "  0x", tmpStr );
-       print("\n");
+       if ( scanType == scanMode )
+       {
+               char tmpStr[6];
+               info_print("Initial Matrix Pin Setup");
+               info_print(" ddrA  ddrB  ddrC  ddrD  ddrE  ddrF");
+               print("      ");
+               hexToStr_op( ddrA, tmpStr, 2 ); dPrintStrs( "  0x", tmpStr );
+               hexToStr_op( ddrB, tmpStr, 2 ); dPrintStrs( "  0x", tmpStr );
+               hexToStr_op( ddrC, tmpStr, 2 ); dPrintStrs( "  0x", tmpStr );
+               hexToStr_op( ddrD, tmpStr, 2 ); dPrintStrs( "  0x", tmpStr );
+               hexToStr_op( ddrE, tmpStr, 2 ); dPrintStrs( "  0x", tmpStr );
+               hexToStr_op( ddrF, tmpStr, 2 ); dPrintStrs( "  0x", tmpStr );
+               print("\n");
+               info_print("portA portB portC portD portE portF");
+               print("      ");
+               hexToStr_op( portA, tmpStr, 2 ); dPrintStrs( "  0x", tmpStr );
+               hexToStr_op( portB, tmpStr, 2 ); dPrintStrs( "  0x", tmpStr );
+               hexToStr_op( portC, tmpStr, 2 ); dPrintStrs( "  0x", tmpStr );
+               hexToStr_op( portD, tmpStr, 2 ); dPrintStrs( "  0x", tmpStr );
+               hexToStr_op( portE, tmpStr, 2 ); dPrintStrs( "  0x", tmpStr );
+               hexToStr_op( portF, tmpStr, 2 ); dPrintStrs( "  0x", tmpStr );
+               print("\n");
+               int8ToStr( scanType, tmpStr );
+       }
 
        // Setting the pins
 #if defined(__AVR_AT90USB1286__)
@@ -235,6 +243,7 @@ inline void matrix_scan( uint8_t *matrix, uint8_t *detectArray )
                // Scan over the pins for each of the columns, and using the pin alias to determine which pin to set
                // (e.g. / 10 is for the pin name (A,B,C,etc.) and % 10 is for the position of the pin (A1,A2,etc.))
                switch ( matrix[0*(MAX_ROW_SIZE+1)+col] / 10 )
+                               REG_SET(port##pin); break; \
                {
 #if defined(__AVR_AT90USB1286__)
                case 0: // PINA
@@ -285,6 +294,8 @@ inline void matrix_scan( uint8_t *matrix, uint8_t *detectArray )
        // Dual Scan
 #if scanMode == scanDual
        // First do a scan of all of the columns, marking each one
+       matrix_pinSetup( matrix, scanCol_powrRow );
+       _delay_us( 1 );
        for ( ; row < (MAX_COL_SIZE+1); row++ ) for ( ; col < (MAX_ROW_SIZE+1); col++ )
        {
                // Scan over the pins for each of the columns, and using the pin alias to determine which pin to set
@@ -310,6 +321,8 @@ inline void matrix_scan( uint8_t *matrix, uint8_t *detectArray )
 
        // Next, do a scan of all of the rows, clearing any "vague" keys (only detected on row, but not column, or vice-versa)
        // And marking any keys that are detected on the row and column
+       matrix_pinSetup( matrix, scanRow_powrCol );
+       _delay_us( 1 );
        col = 1;
        row = 1;
        for ( ; col < (MAX_ROW_SIZE+1); col++ ) for ( ; row < (MAX_COL_SIZE+1); row++ ) 
index 9492425a25080e6946da16111da1da933d307394..0fdaeae9e3efa352dd5d42be70bd3fbca5efd7de 100644 (file)
 
 // ----- Functions -----
 
-void matrix_pinSetup( uint8_t *matrix );
+void matrix_pinSetup( uint8_t *matrix, uint8_t scanType );
 void matrix_scan( uint8_t *matrix, uint8_t *detectArray );
 
 #endif // __MATRIX_SCAN_H
index 731754e963389399aeec00f77d9d4a2b7ca76c5b..a7389a6699baf8e4374552945a0ddcb59d2a2e45 100644 (file)
 
 // ----- Macros -----
 
-// Loop over all of the sampled keys of the given array
-// If the number of samples is higher than the sample threshold, flag the high bit, clear otherwise
-// This should be resetting VERY quickly, cutting off a potentially valid keypress is not an issue
-#define DEBOUNCE_ASSESS(table,size) \
-                       for ( uint8_t key = 1; key < size + 1; key++ ) \
-                               table[key] = ( table[key] & ~(1 << 7) ) > SAMPLE_THRESHOLD ? (1 << 7) : 0x00
+// Make sure we haven't overflowed the buffer
+#define bufferAdd(byte) \
+               if ( KeyIndex_BufferUsed < KEYBOARD_BUFFER ) \
+                       KeyIndex_Buffer[KeyIndex_BufferUsed++] = byte
 
 
 
 // ----- Variables -----
 
+// Buffer used to inform the macro processing module which keys have been detected as pressed
+volatile uint8_t KeyIndex_Buffer[KEYBOARD_BUFFER];
+volatile uint8_t KeyIndex_BufferUsed;
+
+
 // Keeps track of the number of scans, so we only do a debounce assess when it would be valid (as it throws away data)
 uint8_t scan_count = 0;
 
@@ -69,7 +72,7 @@ uint8_t KeyIndex_Array[KEYBOARD_SIZE + 1];
 // Setup
 inline void scan_setup()
 {
-       matrix_pinSetup( (uint8_t*)matrix_pinout );
+       matrix_pinSetup( (uint8_t*)matrix_pinout, scanMode );
 }
 
 // Main Detection Loop
@@ -95,7 +98,18 @@ inline uint8_t scan_loop()
        scan_count = 0;
 
        // Assess debouncing sample table
-       DEBOUNCE_ASSESS( KeyIndex_Array, KeyIndex_Size );
+       // Loop over all of the sampled keys of the given array
+       // If the number of samples is higher than the sample threshold, flag the high bit, clear otherwise
+       // This should be resetting VERY quickly, cutting off a potentially valid keypress is not an issue
+       for ( uint8_t key = 1; key < KeyIndex_Size + 1; key++ ) if ( ( KeyIndex_Array[key] & ~(1 << 7) ) > SAMPLE_THRESHOLD )
+       {
+               bufferAdd( key );
+               KeyIndex_Array[key] = (1 << 7);
+       }
+       else
+       {
+               KeyIndex_Array[key] = 0x00;
+       }
 
        // Ready to allow for USB send
        return 1;
index a451d664ccb38eca572f8d6d16e3dff3ed32eb9b..3897c9cab935cf267bf61e2697aa91f4a5008148 100644 (file)
 
 // ----- Defines -----
 
+#define KEYBOARD_BUFFER 24 // Max number of key signals to buffer
+
 
 
 // ----- Variables -----
 
 // NOTE: Highest Bit: Valid keypress (0x80 is valid keypress)
 //        Other Bits: Pressed state sample counter
-extern              uint8_t KeyIndex_Array [KEYBOARD_SIZE + 1];
-       static const uint8_t KeyIndex_Size = KEYBOARD_SIZE;
+extern                       uint8_t KeyIndex_Array [KEYBOARD_SIZE + 1];
+                static const uint8_t KeyIndex_Size = KEYBOARD_SIZE;
+
+extern volatile              uint8_t KeyIndex_Buffer[KEYBOARD_BUFFER];
+extern volatile              uint8_t KeyIndex_BufferUsed;
 
 
 
index 6aec93f98ea3197aac0d5857148bc3c9f436320b..1043e6ac1ebcb7369e0347d9d5215b4a3b670f10 100644 (file)
@@ -135,8 +135,8 @@ static const uint8_t PROGMEM keyboard_hid_report_desc[] = {
 };
 
 static const uint8_t PROGMEM debug_hid_report_desc[] = {
-       0x06, 0x30, 0xFF,                       // Usage Page 0xFF31 (vendor defined)
-       //0x06, 0x31, 0xFF,                     // Usage Page 0xFF31 (vendor defined)
+       //0x06, 0x30, 0xFF,                     // Usage Page 0xFF31 (vendor defined)
+       0x06, 0x31, 0xFF,                       // Usage Page 0xFF31 (vendor defined)
        0x09, 0x74,                             // Usage 0x74
        0xA1, 0x53,                             // Collection 0x53
        0x75, 0x08,                             // report size = 8 bits
index 2bd7cd15020cba82e5d8949bd12bccf1e6fecaa9..39a50bfff0c3d79f0cbeba3f6effa1cd43f2b7e5 100644 (file)
@@ -20,7 +20,7 @@
 #| Please the {Scan,Macro,USB,Debug}/module.txt for information on the modules and how to create new ones
 
 ##| Deals with acquiring the keypress information and turning it into a key index
-set(  ScanModule  "MicroSwitch8304" )
+set(  ScanModule  "SonyNEWS" )
 
 ##| Uses the key index and potentially applies special conditions to it, mapping it to a usb key code
 set( MacroModule  "buffer"  )