aboutsummaryrefslogtreecommitdiffstats
path: root/quantum/split_common/split_util.c
diff options
context:
space:
mode:
authorGravatar Alex Ong <the.onga@gmail.com>2019-01-04 19:43:45 +1100
committerGravatar Alex Ong <the.onga@gmail.com>2019-01-04 19:43:45 +1100
commit2bb2977c133646c4e056960e72029270d77cc1eb (patch)
tree235d491f992121ac1716c5bf2fafb80983748576 /quantum/split_common/split_util.c
parenta55c838961c89097ab849ed6cb1f261791e6b9b4 (diff)
parent47c91fc7f75ae0a477e55b687aa0fc30da0a283c (diff)
downloadqmk_firmware-2bb2977c133646c4e056960e72029270d77cc1eb.tar.gz
Merge branch 'master' into debounce_refactor
# Conflicts: # tmk_core/common/keyboard.c
Diffstat (limited to 'quantum/split_common/split_util.c')
-rw-r--r--quantum/split_common/split_util.c51
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 @@
-#include <avr/io.h>
-#include <avr/wdt.h>
-#include <avr/power.h>
-#include <avr/interrupt.h>
-#include <util/delay.h>
-#include <avr/eeprom.h>
#include "split_util.h"
#include "matrix.h"
#include "keyboard.h"
#include "config.h"
#include "timer.h"
#include "split_flags.h"
+#include "quantum.h"
-#ifdef RGBLIGHT_ENABLE
-# include "rgblight.h"
+#ifdef EE_HANDS
+# include "tmk_core/common/eeprom.h"
#endif
+
#ifdef BACKLIGHT_ENABLE
# include "backlight.h"
#endif
-#ifdef SPLIT_HAND_PIN
-# include "pincontrol.h"
-#endif
-
#if defined(USE_I2C) || defined(EH)
# include "i2c.h"
-#else
-# include "serial.h"
#endif
volatile bool isLeftHand = true;
@@ -35,14 +25,13 @@ volatile uint8_t setTries = 0;
static void setup_handedness(void) {
#ifdef SPLIT_HAND_PIN
// Test pin SPLIT_HAND_PIN for High/Low, if low it's right hand
- pinMode(SPLIT_HAND_PIN, PinDirectionInput);
- isLeftHand = digitalRead(SPLIT_HAND_PIN);
+ setPinInput(SPLIT_HAND_PIN);
+ isLeftHand = readPin(SPLIT_HAND_PIN);
#else
#ifdef EE_HANDS
isLeftHand = eeprom_read_byte(EECONFIG_HANDEDNESS);
#else
- // I2C_MASTER_RIGHT is deprecated, use MASTER_RIGHT instead, since this works for both serial and i2c
- #if defined(I2C_MASTER_RIGHT) || defined(MASTER_RIGHT)
+ #ifdef MASTER_RIGHT
isLeftHand = !has_usb();
#else
isLeftHand = has_usb();
@@ -94,7 +83,7 @@ void split_keyboard_setup(void) {
void keyboard_slave_loop(void) {
matrix_init();
-
+
//Init RGB
#ifdef RGBLIGHT_ENABLE
rgblight_init();
@@ -103,17 +92,17 @@ void keyboard_slave_loop(void) {
while (1) {
// Matrix Slave Scan
matrix_slave_scan();
-
+
// Read Backlight Info
#ifdef BACKLIGHT_ENABLE
- if (BACKLIT_DIRTY) {
- #ifdef USE_I2C
+ #ifdef USE_I2C
+ if (BACKLIT_DIRTY) {
backlight_set(i2c_slave_buffer[I2C_BACKLIT_START]);
- #else // USE_SERIAL
- backlight_set(serial_master_buffer[SERIAL_BACKLIT_START]);
- #endif
- BACKLIT_DIRTY = false;
- }
+ BACKLIT_DIRTY = false;
+ }
+ #else // USE_SERIAL
+ backlight_set(serial_m2s_buffer.backlight_level);
+ #endif
#endif
// Read RGB Info
#ifdef RGBLIGHT_ENABLE
@@ -122,14 +111,14 @@ void keyboard_slave_loop(void) {
// Disable interupts (RGB data is big)
cli();
// Create new DWORD for RGB data
- uint32_t dword;
-
+ uint32_t dword;
+
// Fill the new DWORD with the data that was sent over
uint8_t *dword_dat = (uint8_t *)(&dword);
for (int i = 0; i < 4; i++) {
dword_dat[i] = i2c_slave_buffer[I2C_RGB_START+i];
}
-
+
// Update the RGB now with the new data and set RGB_DIRTY to false
rgblight_update_dword(dword);
RGB_DIRTY = false;
@@ -137,7 +126,9 @@ void keyboard_slave_loop(void) {
sei();
}
#else // USE_SERIAL
+ #ifdef RGBLIGHT_SPLIT
// Add serial implementation for RGB here
+ #endif
#endif
#endif
}