From 4307e98cee1d2b5f1e0d86ea6ab73084a338f1b1 Mon Sep 17 00:00:00 2001 From: jesse Date: Wed, 20 Nov 2013 17:39:47 +0800 Subject: [PATCH] 20 bytes of memory savings! --- ArduinoKeyboard.ino | 52 ++++++++++++++++++++++----------------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/ArduinoKeyboard.ino b/ArduinoKeyboard.ino index d68ae68c..10cd0bda 100644 --- a/ArduinoKeyboard.ino +++ b/ArduinoKeyboard.ino @@ -31,8 +31,8 @@ #define LAYERS 6 -static const int colPins[COLS] = { 16, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 }; -static const int rowPins[ROWS] = { A2, A3, A4, A5, 15 }; +static const byte colPins[COLS] = { 16, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 }; +static const byte rowPins[ROWS] = { A2, A3, A4, A5, 15 }; byte matrixState[ROWS][COLS]; @@ -47,7 +47,7 @@ byte charsReportedLastTime[KEYS_HELD_BUFFER]; // A bit vector for the 256 keys w long reporting_counter = 0; -int current_layer = 0; +byte current_layer = 0; double mouseActiveForCycles = 0; float carriedOverX =0; float carriedOverY =0; @@ -61,7 +61,7 @@ void release_keys_not_being_pressed() // we use charsReportedLastTime to figure out what we might not be holding anymore and can now release. this is destructive to charsReportedLastTime - for (int i=0; iJ, if (digitalRead(colPins[col])) { @@ -288,8 +288,8 @@ void report_matrix() { #ifdef DEBUG_SERIAL if (reporting_counter++ %100 == 0 ) { - for (int row = 0; row < ROWS; row++) { - for (int col = 0; col < COLS; col++) { + for (byte row = 0; row < ROWS; row++) { + for (byte col = 0; col < COLS; col++) { Serial.print(matrixState[row][col],HEX); Serial.print(", "); @@ -301,7 +301,7 @@ void report_matrix() #endif } -void report(int row, int col, boolean value) +void report(byte row, byte col, boolean value) { #ifdef DEBUG_SERIAL Serial.print("Detected a change on ");