diff options
Diffstat (limited to 'quantum/split_common/split_util.c')
| -rw-r--r-- | quantum/split_common/split_util.c | 51 |
1 files changed, 21 insertions, 30 deletions
diff --git a/quantum/split_common/split_util.c b/quantum/split_common/split_util.c index 13b09d5b8..e41b6f638 100644 --- a/quantum/split_common/split_util.c +++ b/quantum/split_common/split_util.c | |||
| @@ -1,31 +1,21 @@ | |||
| 1 | #include <avr/io.h> | ||
| 2 | #include <avr/wdt.h> | ||
| 3 | #include <avr/power.h> | ||
| 4 | #include <avr/interrupt.h> | ||
| 5 | #include <util/delay.h> | ||
| 6 | #include <avr/eeprom.h> | ||
| 7 | #include "split_util.h" | 1 | #include "split_util.h" |
| 8 | #include "matrix.h" | 2 | #include "matrix.h" |
| 9 | #include "keyboard.h" | 3 | #include "keyboard.h" |
| 10 | #include "config.h" | 4 | #include "config.h" |
| 11 | #include "timer.h" | 5 | #include "timer.h" |
| 12 | #include "split_flags.h" | 6 | #include "split_flags.h" |
| 7 | #include "quantum.h" | ||
| 13 | 8 | ||
| 14 | #ifdef RGBLIGHT_ENABLE | 9 | #ifdef EE_HANDS |
| 15 | # include "rgblight.h" | 10 | # include "tmk_core/common/eeprom.h" |
| 16 | #endif | 11 | #endif |
| 12 | |||
| 17 | #ifdef BACKLIGHT_ENABLE | 13 | #ifdef BACKLIGHT_ENABLE |
| 18 | # include "backlight.h" | 14 | # include "backlight.h" |
| 19 | #endif | 15 | #endif |
| 20 | 16 | ||
| 21 | #ifdef SPLIT_HAND_PIN | ||
| 22 | # include "pincontrol.h" | ||
| 23 | #endif | ||
| 24 | |||
| 25 | #if defined(USE_I2C) || defined(EH) | 17 | #if defined(USE_I2C) || defined(EH) |
| 26 | # include "i2c.h" | 18 | # include "i2c.h" |
| 27 | #else | ||
| 28 | # include "serial.h" | ||
| 29 | #endif | 19 | #endif |
| 30 | 20 | ||
| 31 | volatile bool isLeftHand = true; | 21 | volatile bool isLeftHand = true; |
| @@ -35,14 +25,13 @@ volatile uint8_t setTries = 0; | |||
| 35 | static void setup_handedness(void) { | 25 | static void setup_handedness(void) { |
| 36 | #ifdef SPLIT_HAND_PIN | 26 | #ifdef SPLIT_HAND_PIN |
| 37 | // Test pin SPLIT_HAND_PIN for High/Low, if low it's right hand | 27 | // Test pin SPLIT_HAND_PIN for High/Low, if low it's right hand |
| 38 | pinMode(SPLIT_HAND_PIN, PinDirectionInput); | 28 | setPinInput(SPLIT_HAND_PIN); |
| 39 | isLeftHand = digitalRead(SPLIT_HAND_PIN); | 29 | isLeftHand = readPin(SPLIT_HAND_PIN); |
| 40 | #else | 30 | #else |
| 41 | #ifdef EE_HANDS | 31 | #ifdef EE_HANDS |
| 42 | isLeftHand = eeprom_read_byte(EECONFIG_HANDEDNESS); | 32 | isLeftHand = eeprom_read_byte(EECONFIG_HANDEDNESS); |
| 43 | #else | 33 | #else |
| 44 | // I2C_MASTER_RIGHT is deprecated, use MASTER_RIGHT instead, since this works for both serial and i2c | 34 | #ifdef MASTER_RIGHT |
| 45 | #if defined(I2C_MASTER_RIGHT) || defined(MASTER_RIGHT) | ||
| 46 | isLeftHand = !has_usb(); | 35 | isLeftHand = !has_usb(); |
| 47 | #else | 36 | #else |
| 48 | isLeftHand = has_usb(); | 37 | isLeftHand = has_usb(); |
| @@ -94,7 +83,7 @@ void split_keyboard_setup(void) { | |||
| 94 | 83 | ||
| 95 | void keyboard_slave_loop(void) { | 84 | void keyboard_slave_loop(void) { |
| 96 | matrix_init(); | 85 | matrix_init(); |
| 97 | 86 | ||
| 98 | //Init RGB | 87 | //Init RGB |
| 99 | #ifdef RGBLIGHT_ENABLE | 88 | #ifdef RGBLIGHT_ENABLE |
| 100 | rgblight_init(); | 89 | rgblight_init(); |
| @@ -103,17 +92,17 @@ void keyboard_slave_loop(void) { | |||
| 103 | while (1) { | 92 | while (1) { |
| 104 | // Matrix Slave Scan | 93 | // Matrix Slave Scan |
| 105 | matrix_slave_scan(); | 94 | matrix_slave_scan(); |
| 106 | 95 | ||
| 107 | // Read Backlight Info | 96 | // Read Backlight Info |
| 108 | #ifdef BACKLIGHT_ENABLE | 97 | #ifdef BACKLIGHT_ENABLE |
| 109 | if (BACKLIT_DIRTY) { | 98 | #ifdef USE_I2C |
| 110 | #ifdef USE_I2C | 99 | if (BACKLIT_DIRTY) { |
| 111 | backlight_set(i2c_slave_buffer[I2C_BACKLIT_START]); | 100 | backlight_set(i2c_slave_buffer[I2C_BACKLIT_START]); |
| 112 | #else // USE_SERIAL | 101 | BACKLIT_DIRTY = false; |
| 113 | backlight_set(serial_master_buffer[SERIAL_BACKLIT_START]); | 102 | } |
| 114 | #endif | 103 | #else // USE_SERIAL |
| 115 | BACKLIT_DIRTY = false; | 104 | backlight_set(serial_m2s_buffer.backlight_level); |
| 116 | } | 105 | #endif |
| 117 | #endif | 106 | #endif |
| 118 | // Read RGB Info | 107 | // Read RGB Info |
| 119 | #ifdef RGBLIGHT_ENABLE | 108 | #ifdef RGBLIGHT_ENABLE |
| @@ -122,14 +111,14 @@ void keyboard_slave_loop(void) { | |||
| 122 | // Disable interupts (RGB data is big) | 111 | // Disable interupts (RGB data is big) |
| 123 | cli(); | 112 | cli(); |
| 124 | // Create new DWORD for RGB data | 113 | // Create new DWORD for RGB data |
| 125 | uint32_t dword; | 114 | uint32_t dword; |
| 126 | 115 | ||
| 127 | // Fill the new DWORD with the data that was sent over | 116 | // Fill the new DWORD with the data that was sent over |
| 128 | uint8_t *dword_dat = (uint8_t *)(&dword); | 117 | uint8_t *dword_dat = (uint8_t *)(&dword); |
| 129 | for (int i = 0; i < 4; i++) { | 118 | for (int i = 0; i < 4; i++) { |
| 130 | dword_dat[i] = i2c_slave_buffer[I2C_RGB_START+i]; | 119 | dword_dat[i] = i2c_slave_buffer[I2C_RGB_START+i]; |
| 131 | } | 120 | } |
| 132 | 121 | ||
| 133 | // Update the RGB now with the new data and set RGB_DIRTY to false | 122 | // Update the RGB now with the new data and set RGB_DIRTY to false |
| 134 | rgblight_update_dword(dword); | 123 | rgblight_update_dword(dword); |
| 135 | RGB_DIRTY = false; | 124 | RGB_DIRTY = false; |
| @@ -137,7 +126,9 @@ void keyboard_slave_loop(void) { | |||
| 137 | sei(); | 126 | sei(); |
| 138 | } | 127 | } |
| 139 | #else // USE_SERIAL | 128 | #else // USE_SERIAL |
| 129 | #ifdef RGBLIGHT_SPLIT | ||
| 140 | // Add serial implementation for RGB here | 130 | // Add serial implementation for RGB here |
| 131 | #endif | ||
| 141 | #endif | 132 | #endif |
| 142 | #endif | 133 | #endif |
| 143 | } | 134 | } |
