pull/18/head
Jesse Vincent 9 years ago
parent 04ec58cced
commit fbb5e1e163

@ -11,7 +11,8 @@
#define ROWS 5 #define ROWS 5
#define COLS 14 #define COLS 14
static const byte colPins[COLS] = { static const byte colPins[COLS] = {
A0, 3,13, 5, 10, 9, 8, 6, 12, 4, 11, 1, 0, 2 }; A0, 3,13, 5, 10, 9, 8, 6, 12, 4, 11, 1, 0, 2
};
static const byte rowPins[ROWS] = { A5,A4,A3,A2,A1}; static const byte rowPins[ROWS] = { A5,A4,A3,A2,A1};
#define LED_DATA_PIN 7 #define LED_DATA_PIN 7
@ -28,11 +29,11 @@ int RIGHT_ROWS=4;
int LEFT_COLS=8; int LEFT_COLS=8;
int LEFT_ROWS=4; int LEFT_ROWS=4;
int left_colpins[]={7,6,5,4,3,2,1,0}; int left_colpins[]= {7,6,5,4,3,2,1,0};
int left_rowpins[]={8,9,10,11}; int left_rowpins[]= {8,9,10,11};
int right_colpins[]={0,1,2,3,4,5,6,7}; int right_colpins[]= {0,1,2,3,4,5,6,7};
int right_rowpins[]={8,9,10,11}; int right_rowpins[]= {8,9,10,11};

@ -33,8 +33,7 @@ int left_initted = 0;
#define TS(X) //Serial.print(micros() );Serial.print("\t");Serial.println(X); #define TS(X) //Serial.print(micros() );Serial.print("\t");Serial.println(X);
void setup_matrix() void setup_matrix() {
{
reset_key_report(); reset_key_report();
//blank out the matrix. //blank out the matrix.
for (byte col = 0; col < COLS; col++) { for (byte col = 0; col < COLS; col++) {
@ -80,8 +79,7 @@ void set_keymap(Key keymapEntry, byte matrixStateEntry) {
} }
} }
void scan_matrix() void scan_matrix() {
{
x = 0; x = 0;
y = 0; y = 0;
//scan the Keyboard matrix looking for connections //scan the Keyboard matrix looking for connections
@ -263,16 +261,15 @@ void process_command_buffer() {
} }
void setup() void setup() {
{
wdt_disable(); wdt_disable();
Serial.begin(115200); Serial.begin(115200);
//usbMaxPower = 100; //usbMaxPower = 100;
Keyboard.begin(); Keyboard.begin();
Mouse.begin(); Mouse.begin();
setup_leds(); setup_leds();
led_bootup(); led_bootup();
setup_command_mode(); setup_command_mode();
setup_matrix(); setup_matrix();
setup_pins(); setup_pins();
rightsx1509.fetchPinStates(); rightsx1509.fetchPinStates();
@ -282,8 +279,7 @@ setup_command_mode();
String myApp; String myApp;
void loop() void loop() {
{
// if(Serial.available()) { // if(Serial.available()) {
// myApp = Serial.readString(); // myApp = Serial.readString();
// myApp.trim(); // myApp.trim();
@ -299,18 +295,16 @@ void loop()
void save_primary_keymap(byte keymap) void save_primary_keymap(byte keymap) {
{
EEPROM.write(EEPROM_KEYMAP_LOCATION, keymap); EEPROM.write(EEPROM_KEYMAP_LOCATION, keymap);
} }
byte load_primary_keymap() byte load_primary_keymap() {
{
byte keymap = EEPROM.read(EEPROM_KEYMAP_LOCATION); byte keymap = EEPROM.read(EEPROM_KEYMAP_LOCATION);
if (keymap >= KEYMAPS ) { if (keymap >= KEYMAPS ) {
return 0; // undefined positions get saved as 255 return 0; // undefined positions get saved as 255
} }
return 0; // return keymap; return 0; // return keymap;
} }
@ -319,8 +313,7 @@ return 0; // return keymap;
// Debugging Reporting // Debugging Reporting
// //
void report_matrix() void report_matrix() {
{
#ifdef DEBUG_SERIAL #ifdef DEBUG_SERIAL
if (reporting_counter++ % 100 == 0 ) { if (reporting_counter++ % 100 == 0 ) {
for (byte row = 0; row < ROWS; row++) { for (byte row = 0; row < ROWS; row++) {
@ -336,8 +329,7 @@ void report_matrix()
#endif #endif
} }
void report(byte row, byte col, boolean value) void report(byte row, byte col, boolean value) {
{
#ifdef DEBUG_SERIAL #ifdef DEBUG_SERIAL
Serial.print("Detected a change on "); Serial.print("Detected a change on ");
Serial.print(col); Serial.print(col);
@ -353,8 +345,7 @@ void report(byte row, byte col, boolean value)
// Key Reports // Key Reports
// //
void release_keys_not_being_pressed() void release_keys_not_being_pressed() {
{
// we use charsReportedLastTime to figure out what we might // we use charsReportedLastTime to figure out what we might
// not be holding anymore and can now release. this is // not be holding anymore and can now release. this is
// destructive to charsReportedLastTime // destructive to charsReportedLastTime
@ -380,8 +371,7 @@ void release_keys_not_being_pressed()
} }
} }
void record_key_being_pressed(byte character) void record_key_being_pressed(byte character) {
{
for (byte i = 0; i < KEYS_HELD_BUFFER; i++) { for (byte i = 0; i < KEYS_HELD_BUFFER; i++) {
// todo - deal with overflowing the 12 key buffer here // todo - deal with overflowing the 12 key buffer here
if (charsBeingReported[i] == 0x00) { if (charsBeingReported[i] == 0x00) {
@ -391,8 +381,7 @@ void record_key_being_pressed(byte character)
} }
} }
void reset_key_report() void reset_key_report() {
{
memcpy( charsReportedLastTime, charsBeingReported, KEYS_HELD_BUFFER); memcpy( charsReportedLastTime, charsBeingReported, KEYS_HELD_BUFFER);
memset(charsBeingReported, 0, KEYS_HELD_BUFFER); memset(charsBeingReported, 0, KEYS_HELD_BUFFER);
@ -414,13 +403,11 @@ void handle_synthetic_key_press(byte switchState, Key mappedKey) {
next_led_mode(); next_led_mode();
} }
} }
} } else if (mappedKey.flags & IS_SYSCTL) {
else if (mappedKey.flags & IS_SYSCTL) {
if (key_toggled_on (switchState)) { if (key_toggled_on (switchState)) {
SystemControl.press(mappedKey.rawKey); SystemControl.press(mappedKey.rawKey);
} }
} } else if (mappedKey.flags & IS_MACRO) {
else if (mappedKey.flags & IS_MACRO) {
if (key_toggled_on (switchState)) { if (key_toggled_on (switchState)) {
if (mappedKey.rawKey == 1) { if (mappedKey.rawKey == 1) {
Serial.print("Keyboard.IO keyboard driver v0.00"); Serial.print("Keyboard.IO keyboard driver v0.00");
@ -439,8 +426,7 @@ void handle_synthetic_key_press(byte switchState, Key mappedKey) {
} }
} }
void send_key_event(byte row, byte col) void send_key_event(byte row, byte col) {
{
//for every newly pressed button, figure out what logical key it is and send a key down event //for every newly pressed button, figure out what logical key it is and send a key down event
// for every newly released button, figure out what logical key it is and send a key up event // for every newly released button, figure out what logical key it is and send a key up event
@ -465,8 +451,7 @@ void send_key_event(byte row, byte col)
} else if (mappedKey.flags & SYNTHETIC_KEY) { } else if (mappedKey.flags & SYNTHETIC_KEY) {
handle_synthetic_key_press(switchState, mappedKey); handle_synthetic_key_press(switchState, mappedKey);
} } else {
else {
if (key_is_pressed(switchState)) { if (key_is_pressed(switchState)) {
record_key_being_pressed(mappedKey.rawKey); record_key_being_pressed(mappedKey.rawKey);
if (key_toggled_on (switchState)) { if (key_toggled_on (switchState)) {

@ -4,8 +4,7 @@
// switch debouncing and status // switch debouncing and status
boolean key_was_pressed (byte keyState) boolean key_was_pressed (byte keyState) {
{
return (! key_was_not_pressed(keyState)); return (! key_was_not_pressed(keyState));
@ -13,8 +12,7 @@ boolean key_was_pressed (byte keyState)
} }
boolean key_was_not_pressed (byte keyState) boolean key_was_not_pressed (byte keyState) {
{
if ( keyState & B00001000 || keyState & B00000100) { if ( keyState & B00001000 || keyState & B00000100) {
return false; return false;
} else { } else {
@ -28,23 +26,20 @@ boolean key_was_not_pressed (byte keyState)
} }
boolean key_is_pressed (byte keyState) boolean key_is_pressed (byte keyState) {
{
if ( keyState & B00000001 && keyState & B00000010 ){ if ( keyState & B00000001 && keyState & B00000010 ) {
return true; return true;
} else { } else {
return false; return false;
} }
} }
boolean key_is_not_pressed (byte keyState) boolean key_is_not_pressed (byte keyState) {
{ return !key_is_pressed(keyState);
return !key_is_pressed(keyState);
} }
boolean key_toggled_on(byte keyState) boolean key_toggled_on(byte keyState) {
{
if (key_is_pressed(keyState) && key_was_not_pressed(keyState)) { if (key_is_pressed(keyState) && key_was_not_pressed(keyState)) {
return true; return true;
} else { } else {
@ -53,8 +48,7 @@ boolean key_toggled_on(byte keyState)
} }
boolean key_toggled_off(byte keyState) boolean key_toggled_off(byte keyState) {
{
if (key_was_pressed(keyState) && key_is_not_pressed(keyState)) { if (key_was_pressed(keyState) && key_is_not_pressed(keyState)) {
return true; return true;
} else { } else {

@ -170,9 +170,9 @@ void led_effect_numlock_update() {
LED.set_crgb_at(60, led_breathe); // make numlock breathe LED.set_crgb_at(60, led_breathe); // make numlock breathe
LED.sync(); LED.sync();
} }
void led_effect_steady_update() { void led_effect_steady_update() {
LED.sync(); LED.sync();
} }
void led_compute_breath() { void led_compute_breath() {
// algorithm from http://sean.voisen.org/blog/2011/10/breathing-led-with-arduino/ // algorithm from http://sean.voisen.org/blog/2011/10/breathing-led-with-arduino/
@ -225,7 +225,9 @@ void led_effect_rainbow_update() {
if (rainbow_current_ticks++ < rainbow_ticks) { if (rainbow_current_ticks++ < rainbow_ticks) {
return; return;
} else { rainbow_current_ticks = 0; } } else {
rainbow_current_ticks = 0;
}
rainbow.SetHSV(rainbow_hue, rainbow_saturation, rainbow_value); rainbow.SetHSV(rainbow_hue, rainbow_saturation, rainbow_value);
@ -246,7 +248,9 @@ void led_effect_rainbow_wave_update() {
if (rainbow_current_ticks++ < rainbow_wave_ticks) { if (rainbow_current_ticks++ < rainbow_wave_ticks) {
return; return;
} else { rainbow_current_ticks = 0; } } else {
rainbow_current_ticks = 0;
}
for (int i = 0; i < LED_COUNT; i++) { for (int i = 0; i < LED_COUNT; i++) {

@ -16,8 +16,7 @@
#define LED_COUNT 64 #define LED_COUNT 64
static const int key_led_map[4][16] = static const int key_led_map[4][16] = {
{
{3,4,11,12,19,20,26,27, 36,37,43,44,51,52,59,60}, {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}, {2,5,10,13,18,21,31,28, 35,32,42,45,50,53,58,61},
{1,6,9,14, 17,22,25,29, 34,38,41,46,49,54,57,62}, {1,6,9,14, 17,22,25,29, 34,38,41,46,49,54,57,62},

@ -67,7 +67,7 @@ void warp_mouse(Key ninth) {
if (ninth.rawKey & MOUSE_UP) { if (ninth.rawKey & MOUSE_UP) {
// Serial.print(" - up "); // Serial.print(" - up ");
} else if (ninth.rawKey & MOUSE_DN) { } else if (ninth.rawKey & MOUSE_DN) {
// Serial.print(" - down "); // Serial.print(" - down ");
section_top = section_top + next_height; section_top = section_top + next_height;
} }
@ -96,8 +96,7 @@ void warp_mouse(Key ninth) {
#define ACCELERATION_CLIMB_SPEED 0.05 #define ACCELERATION_CLIMB_SPEED 0.05
double mouse_accel (double cycles) double mouse_accel (double cycles) {
{
double accel = (atan((cycles * ACCELERATION_CLIMB_SPEED)-ACCELERATION_RUNWAY) + ATAN_LIMIT) * ACCELERATION_MULTIPLIER; double accel = (atan((cycles * ACCELERATION_CLIMB_SPEED)-ACCELERATION_RUNWAY) + ATAN_LIMIT) * ACCELERATION_MULTIPLIER;
if (accel < ACCELERATION_FLOOR) { if (accel < ACCELERATION_FLOOR) {
accel = ACCELERATION_FLOOR; accel = ACCELERATION_FLOOR;
@ -105,8 +104,7 @@ double mouse_accel (double cycles)
return accel; return accel;
} }
void handle_mouse_movement( char x, char y) void handle_mouse_movement( char x, char y) {
{
if (x != 0 || y != 0) { if (x != 0 || y != 0) {
mouseActiveForCycles++; mouseActiveForCycles++;

Loading…
Cancel
Save