From 61643864666659d7fd855ea2ec96af52edb18a68 Mon Sep 17 00:00:00 2001 From: Jesse Vincent Date: Fri, 11 Nov 2016 00:21:30 -0800 Subject: [PATCH] Break apart a method for easier reuse --- Model01.cpp | 16 ++++++++++++++-- Model01.h | 10 ++++++---- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/Model01.cpp b/Model01.cpp index 56a935d3..f8fda144 100644 --- a/Model01.cpp +++ b/Model01.cpp @@ -83,7 +83,10 @@ void debug_key_event(keydata_t state, keydata_t previousState, uint8_t keynum, u Serial.println(); } } -void Model01::scan_matrix() { + + +void Model01::read_matrix() { + //scan the Keyboard matrix looking for connections previousLeftHandState = leftHandState; previousRightHandState = rightHandState; @@ -94,7 +97,11 @@ void Model01::scan_matrix() { if (rightHand.readKeys()) { rightHandState = rightHand.getKeyData(); } +} + + +void Model01::act_on_matrix_scan() { for (byte row = 0; row < 4; row++) { for (byte col = 0; col < 8; col++) { @@ -111,5 +118,10 @@ void Model01::scan_matrix() { ); } } - //scan the Keyboard matrix looking for connections +} + + +void Model01::scan_matrix() { + read_matrix(); + act_on_matrix_scan(); } diff --git a/Model01.h b/Model01.h index ab3b3060..123304c7 100644 --- a/Model01.h +++ b/Model01.h @@ -24,18 +24,20 @@ class Model01 { cRGB get_key_color(byte row, byte col); void scan_matrix(void); + void read_matrix(void); + void act_on_matrix_scan(void); void setup(); void enable_high_power_leds(void); void enable_scanner_power(void); - - private: - static KeyboardioScanner leftHand; - static KeyboardioScanner rightHand; keydata_t leftHandState; keydata_t rightHandState; keydata_t previousLeftHandState; keydata_t previousRightHandState; + private: + static KeyboardioScanner leftHand; + static KeyboardioScanner rightHand; + static constexpr uint8_t key_led_map[4][16] = { {3,4,11,12,19,20,26,27, 36,37,43,44,51,52,59,60}, {2,5,10,13,18,21,31,28, 35,32,42,45,50,53,58,61},