]> git.donarmstrong.com Git - kiibohd-controller.git/commitdiff
Cleaning up main.c
authorJacob Alexander <haata@users.sf.net>
Fri, 30 Sep 2011 08:30:34 +0000 (01:30 -0700)
committerJacob Alexander <haata@users.sf.net>
Fri, 30 Sep 2011 08:30:34 +0000 (01:30 -0700)
- main.c is now mostly complete
- Required fixes to matrix.c (some are temporary)

Macro/basic/macro.c
Scan/matrix/matrix.c
Scan/matrix/setup.cmake
main.c

index f96209138fc290fe69d7f2b60b1fe6ac0981f1b4..a74cf309eefe768d273300e842503726732d2ea7 100644 (file)
@@ -24,9 +24,9 @@
 // AVR Includes
 
 // Project Includes
-#include <usb_com.h>
-#include <scan_loop.h>
 #include <print.h>
+#include <scan_loop.h>
+#include <usb_com.h>
 
 // Keymaps
 #include <keymap.h>
index aa4af23367f03140e70c4a220680fea4447e379b..644cf457c05d396ac02dd4a609122c37cf70c771 100644 (file)
@@ -21,6 +21,9 @@
 
 // ----- Includes -----
 
+// AVR Includes
+#include <avr/io.h>
+
 // Local Includes
 #include "matrix.h"
 
@@ -93,9 +96,10 @@ void matrix_pinSetup( uint8_t *matrix )
        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 @@ void matrix_pinSetup( uint8_t *matrix )
                        continue;
                }
        }
+       */
 
        // Setting the pins
        DDRA = ddrA;
@@ -158,6 +163,7 @@ void matrix_scan( uint8_t *matrix, uint8_t *detectArray )
 {
        // Column Scan
 #if scanMode == scanCol
+       /*
        uint8_t col = 1;
        uint8_t row = 1;
        for ( ; col < sizeof(matrix[1]); col++ ) {
@@ -176,6 +182,7 @@ void matrix_scan( uint8_t *matrix, uint8_t *detectArray )
                        PIN_TEST_COL(PINF);
                }
        }
+       */
 #endif
 
        // Row Scan
index 8fb34b6b4dcdae722b65f84f2e1b887b43e580f9..b529a5178879342bcb1128e4cff37340f8878892 100644 (file)
@@ -12,6 +12,7 @@
 #
 
 set( SCAN_SRCS
+       matrix.c
        scan_loop.c
 )
 
diff --git a/main.c b/main.c
index 58679644e2c5d90e8ca773532b0ad8cbf9263f22..537e0adf4d6e459db4256a0f49c502cbb3f8ab01 100644 (file)
--- a/main.c
+++ b/main.c
 
 // AVR Includes
 #include <avr/io.h>
-#include <avr/pgmspace.h>
 #include <avr/interrupt.h>
 
 // Project Includes
-//#include "usb_keys.h"
-#include "scan_loop.h"
-//#include "layouts.h"
-//#include "usb_keyboard.h"
+#include <macro.h>
+#include <scan_loop.h>
+#include <usb_com.h>
 
-#include "usb_keyboard_debug.h"
-#include "print.h"
-#include "led.h"
+#include <led.h>
+#include <print.h>
 
 
 
@@ -90,6 +87,7 @@ int main(void)
 
        // Configuring Pins
        pinSetup();
+       init_errorLED();
 
        // Setup USB Module
        usb_setup();
@@ -101,24 +99,36 @@ int main(void)
        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();
 
-               // Loop should never get here (indicate error)
-               errorLED( 1 );
+                       // Send keypresses over USB if the ISR has signalled that it's time
+                       if ( !sendKeypresses )
+                               continue;
 
-               // HID Debug Error message
-               erro_print("Detection loop error, this is very bad...bug report!");
+                       // Run Macros over Key Indices and convert to USB Keys
+                       process_macros();
+
+                       // Send USB Data
+                       usb_send();
 
-               // Send keypresses over USB if the ISR has signalled that it's time
-               if ( !sendKeypresses )
-                       continue;
+                       // Clear sendKeypresses Flag
+                       sendKeypresses = 0;
 
-               // Send USB Data
-               usb_send();
+                       // Indicate Error, if valid
+                       errorLED( ledTimer );
+               }
 
-               // Clear sendKeypresses Flag
-               sendKeypresses = 0;
+               // Loop should never get here (indicate error)
+               ledTimer = 255;
+
+               // HID Debug Error message
+               erro_print("Detection loop error, this is very bad...bug report!");
        }
 }