# HG changeset patch # User Jacob Alexander # Date 1317371434 25200 # Node ID c2ef3daf39e1267278472ec43e762ab1c7a06dce # Parent 2d65da455ef3f54cbe54e1d1e8d43f1ee4b25c80 Cleaning up main.c - main.c is now mostly complete - Required fixes to matrix.c (some are temporary) diff -r 2d65da455ef3 -r c2ef3daf39e1 Macro/basic/macro.c --- a/Macro/basic/macro.c Thu Sep 29 22:22:19 2011 -0700 +++ b/Macro/basic/macro.c Fri Sep 30 01:30:34 2011 -0700 @@ -24,9 +24,9 @@ // AVR Includes // Project Includes -#include +#include #include -#include +#include // Keymaps #include diff -r 2d65da455ef3 -r c2ef3daf39e1 Scan/matrix/matrix.c --- a/Scan/matrix/matrix.c Thu Sep 29 22:22:19 2011 -0700 +++ b/Scan/matrix/matrix.c Fri Sep 30 01:30:34 2011 -0700 @@ -21,6 +21,9 @@ // ----- Includes ----- +// AVR Includes +#include + // Local Includes #include "matrix.h" @@ -93,9 +96,10 @@ uint8_t ddrF = 0x00; // Loop through all the pin assignments, for the initial pin settings - int row, col; + //int row, col; // Rows + /* for ( row = 1; row < sizeof(matrix); row++ ) { switch ( matrix[row][col] ) { PIN_CASE(A): @@ -136,6 +140,7 @@ continue; } } + */ // Setting the pins DDRA = ddrA; @@ -158,6 +163,7 @@ { // Column Scan #if scanMode == scanCol + /* uint8_t col = 1; uint8_t row = 1; for ( ; col < sizeof(matrix[1]); col++ ) { @@ -176,6 +182,7 @@ PIN_TEST_COL(PINF); } } + */ #endif // Row Scan diff -r 2d65da455ef3 -r c2ef3daf39e1 Scan/matrix/setup.cmake --- a/Scan/matrix/setup.cmake Thu Sep 29 22:22:19 2011 -0700 +++ b/Scan/matrix/setup.cmake Fri Sep 30 01:30:34 2011 -0700 @@ -12,6 +12,7 @@ # set( SCAN_SRCS + matrix.c scan_loop.c ) diff -r 2d65da455ef3 -r c2ef3daf39e1 main.c --- a/main.c Thu Sep 29 22:22:19 2011 -0700 +++ b/main.c Fri Sep 30 01:30:34 2011 -0700 @@ -23,18 +23,15 @@ // AVR Includes #include -#include #include // Project Includes -//#include "usb_keys.h" -#include "scan_loop.h" -//#include "layouts.h" -//#include "usb_keyboard.h" +#include +#include +#include -#include "usb_keyboard_debug.h" -#include "print.h" -#include "led.h" +#include +#include @@ -90,6 +87,7 @@ // Configuring Pins pinSetup(); + init_errorLED(); // Setup USB Module usb_setup(); @@ -101,24 +99,36 @@ TIMSK0 = (1 << TOIE0); // Main Detection Loop - while ( 1 ) { - //scan_loop(); + uint8_t ledTimer = 15; // Enable LED for a short time + while ( 1 ) + { + while ( 1 ) + { + // Acquire Key Indices + scan_loop(); + + // Send keypresses over USB if the ISR has signalled that it's time + if ( !sendKeypresses ) + continue; + + // Run Macros over Key Indices and convert to USB Keys + process_macros(); + + // Send USB Data + usb_send(); + + // Clear sendKeypresses Flag + sendKeypresses = 0; + + // Indicate Error, if valid + errorLED( ledTimer ); + } // Loop should never get here (indicate error) - errorLED( 1 ); + ledTimer = 255; // HID Debug Error message erro_print("Detection loop error, this is very bad...bug report!"); - - // Send keypresses over USB if the ISR has signalled that it's time - if ( !sendKeypresses ) - continue; - - // Send USB Data - usb_send(); - - // Clear sendKeypresses Flag - sendKeypresses = 0; } }