move "scan_matrix" into the implementation specific class, since it looks like it'll be very different between beta and production

pull/18/head
Jesse Vincent 9 years ago
parent 3a67f2d25f
commit 9bb0e64f4a

@ -32,7 +32,6 @@ extern uint8_t primary_keymap;
extern uint8_t temporary_keymap; extern uint8_t temporary_keymap;
void scan_matrix();
#ifndef VERSION #ifndef VERSION
#define VERSION "locally-built" #define VERSION "locally-built"

@ -13,38 +13,20 @@ uint8_t primary_keymap = 0;
uint8_t temporary_keymap = 0; uint8_t temporary_keymap = 0;
void scan_matrix() {
//scan the Keyboard matrix looking for connections
for (byte row = 0; row < LEFT_ROWS; row++) {
KeyboardHardware.scan_row(row);
for (byte col = 0; col < LEFT_COLS; col++) {
KeyboardHardware.scan_left_col(row,col,&matrixState[row][col]);
handle_key_event(row, col);
if (KeyboardHardware.right_hand_connected()) {
KeyboardHardware.scan_right_col(row,col,&matrixState[row][(COLS - 1) - col]);
handle_key_event(row, (COLS - 1) - col);
}
}
KeyboardHardware.finish_scanning_row(row);
}
}
void setup() { void setup() {
wdt_disable(); wdt_disable();
Keyboard.begin(); Keyboard.begin();
Mouse.begin(); Mouse.begin();
KeyboardHardware.leds_setup(); KeyboardHardware.leds_setup();
LEDControl.boot_animation();
KeyboardHardware.pins_setup(); KeyboardHardware.pins_setup();
LEDControl.boot_animation();
temporary_keymap = primary_keymap = Storage.load_primary_keymap(KEYMAPS); temporary_keymap = primary_keymap = Storage.load_primary_keymap(KEYMAPS);
} }
void loop() { void loop() {
scan_matrix(); KeyboardHardware.scan_matrix();
Keyboard.sendReport(); Keyboard.sendReport();
Keyboard.releaseAll(); Keyboard.releaseAll();
LEDControl.update(temporary_keymap); LEDControl.update(temporary_keymap);

@ -34,6 +34,33 @@ void Model01Beta_::led_sync() {
LED.sync(); LED.sync();
} }
void Model01Beta_::scan_matrix() {
//scan the Keyboard matrix looking for connections
for (byte row = 0; row < LEFT_ROWS; row++) {
KeyboardHardware.scan_row(row);
for (byte col = 0; col < LEFT_COLS; col++) {
KeyboardHardware.scan_left_col(row,col,&matrixState[row][col]);
handle_key_event(row, col);
if (KeyboardHardware.right_hand_connected()) {
KeyboardHardware.scan_right_col(row,col,&matrixState[row][(COLS - 1) - col]);
handle_key_event(row, (COLS - 1) - col);
}
}
KeyboardHardware.finish_scanning_row(row);
}
}
void Model01Beta_::scan_row(byte row) { void Model01Beta_::scan_row(byte row) {
if (left_initted) { if (left_initted) {
leftsx1509.updatePinState(left_rowpins[row], LOW); leftsx1509.updatePinState(left_rowpins[row], LOW);

@ -1,8 +1,10 @@
#pragma once #pragma once
#include "../keymaps.h"
#include "../generated/keymaps.h" #include "../generated/keymaps.h"
#include "WS2812.h" #include "WS2812.h"
#include "KeyboardioSX1509.h" #include "KeyboardioSX1509.h"
#include "../key_events.h"
#define USE_HSV_CURVE 1 #define USE_HSV_CURVE 1
@ -25,11 +27,6 @@ static uint8_t right_rowpins[]= {8,9,10,11};
#define COLS 16
#define ROWS 4
#define KEYMAPS 3
#define NUMPAD_KEYMAP 2
#define KEYMAP_LIST KEYMAP_QWERTY KEYMAP_GENERIC_FN2 KEYMAP_NUMPAD
class Model01Beta_ { class Model01Beta_ {
@ -40,13 +37,9 @@ class Model01Beta_ {
void led_set_crgb_at(uint8_t i, cRGB crgb); void led_set_crgb_at(uint8_t i, cRGB crgb);
cRGB get_key_color(byte row, byte col); cRGB get_key_color(byte row, byte col);
void scan_matrix(void);
void scan_row(byte row);
void finish_scanning_row(byte row);
void scan_right_col(byte row, byte col, uint8_t *state);
void scan_left_col(byte row, byte col, uint8_t *state);
void pins_setup(); void pins_setup();
boolean right_hand_connected(void);
void leds_setup(); void leds_setup();
@ -57,6 +50,11 @@ class Model01Beta_ {
int right_initted = 0; int right_initted = 0;
int left_initted = 0; int left_initted = 0;
boolean right_hand_connected(void);
void scan_row(byte row);
void finish_scanning_row(byte row);
void scan_right_col(byte row, byte col, uint8_t *state);
void scan_left_col(byte row, byte col, uint8_t *state);
void make_input(sx1509Class sx1509, uint8_t pin) ; void make_input(sx1509Class sx1509, uint8_t pin) ;
void make_output(sx1509Class sx1509, uint8_t pin) ; void make_output(sx1509Class sx1509, uint8_t pin) ;
int setup_sx1509 (sx1509Class sx1509, uint8_t colpins[], uint8_t rowpins[]); int setup_sx1509 (sx1509Class sx1509, uint8_t colpins[], uint8_t rowpins[]);

Loading…
Cancel
Save