From a8422cca0324ce61247dd0d8320a3d11a433cecf Mon Sep 17 00:00:00 2001
From: Drashna Jaelre <drashna@live.com>
Date: Fri, 15 Oct 2021 22:09:40 -0700
Subject: [PATCH] [Keyboard] Tractyl Manuform Updates (#14841)

---
 .../tractyl_manuform/5x6_right/5x6_right.h    |  4 ++
 .../tractyl_manuform/5x6_right/config.h       |  2 +
 .../5x6_right/elite_c/config.h                | 52 +++++++++++++++++++
 .../5x6_right/elite_c/elite_c.h               | 19 +++++++
 .../5x6_right/elite_c/rules.mk                | 11 ++++
 .../tractyl_manuform/5x6_right/f411/config.h  |  3 +-
 .../tractyl_manuform/5x6_right/f411/readme.md |  3 +-
 .../5x6_right/keymaps/drashna/config.h        |  5 --
 .../5x6_right/keymaps/drashna/keymap.c        |  9 +++-
 .../5x6_right/teensy2pp/config.h              |  1 +
 10 files changed, 101 insertions(+), 8 deletions(-)
 create mode 100644 keyboards/handwired/tractyl_manuform/5x6_right/elite_c/config.h
 create mode 100644 keyboards/handwired/tractyl_manuform/5x6_right/elite_c/elite_c.h
 create mode 100644 keyboards/handwired/tractyl_manuform/5x6_right/elite_c/rules.mk

diff --git a/keyboards/handwired/tractyl_manuform/5x6_right/5x6_right.h b/keyboards/handwired/tractyl_manuform/5x6_right/5x6_right.h
index e481e7841d..f171d41181 100644
--- a/keyboards/handwired/tractyl_manuform/5x6_right/5x6_right.h
+++ b/keyboards/handwired/tractyl_manuform/5x6_right/5x6_right.h
@@ -17,13 +17,17 @@
 #pragma once
 
 #include "tractyl_manuform.h"
+
 #if defined(KEYBOARD_handwired_tractyl_manuform_5x6_right_f411)
 #    include "f411.h"
 #elif defined(KEYBOARD_handwired_tractyl_manuform_5x6_right_f303)
 #    include "f303.h"
 #elif defined(KEYBOARD_handwired_tractyl_manuform_5x6_right_teensy2pp)
 #    include "teensy2pp.h"
+#elif defined(KEYBOARD_handwired_tractyl_manuform_5x6_right_elite_c)
+#    include "elite_c.h"
 #endif
+
 #include "quantum.h"
 
 #define ___ KC_NO
diff --git a/keyboards/handwired/tractyl_manuform/5x6_right/config.h b/keyboards/handwired/tractyl_manuform/5x6_right/config.h
index d1860c3378..cd42364b4f 100644
--- a/keyboards/handwired/tractyl_manuform/5x6_right/config.h
+++ b/keyboards/handwired/tractyl_manuform/5x6_right/config.h
@@ -50,3 +50,5 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 //#define NO_ACTION_ONESHOT
 #define NO_ACTION_MACRO
 #define NO_ACTION_FUNCTION
+
+#define OLED_DISPLAY_128X64
diff --git a/keyboards/handwired/tractyl_manuform/5x6_right/elite_c/config.h b/keyboards/handwired/tractyl_manuform/5x6_right/elite_c/config.h
new file mode 100644
index 0000000000..9daec0cd8f
--- /dev/null
+++ b/keyboards/handwired/tractyl_manuform/5x6_right/elite_c/config.h
@@ -0,0 +1,52 @@
+/*
+Copyright 2012 Jun Wako <wakojun@gmail.com>
+Copyright 2015 Jack Humbert
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#pragma once
+
+#define PRODUCT Tractyl Manuform(5x6) Elite C
+
+// wiring of each half
+#define MATRIX_COL_PINS \
+    { D4, D7, E6, B4, B5, B7 }
+#define MATRIX_ROW_PINS \
+    { F7, F6, F5, F4, F1, F0 }
+
+#define DIODE_DIRECTION COL2ROW
+
+// WS2812 RGB LED strip input and number of LEDs
+#define RGB_DI_PIN      D3
+#define RGBLED_NUM      20
+#define RGBLIGHT_SPLIT
+#define RGBLED_SPLIT \
+    { 10, 10 }
+#define RGBLIGHT_LIMIT_VAL 80
+#define OLED_BRIGHTNESS    50
+
+#define AUDIO_PIN       C6
+
+/* serial.c configuration for split keyboard */
+#define SOFT_SERIAL_PIN D2
+#define EE_HANDS
+
+#define ENCODERS_PAD_A \
+    { D5 }
+#define ENCODERS_PAD_B \
+    { C7 }
+
+/* PMW3360 Settings */
+#define PMW3360_CS_PIN B6
diff --git a/keyboards/handwired/tractyl_manuform/5x6_right/elite_c/elite_c.h b/keyboards/handwired/tractyl_manuform/5x6_right/elite_c/elite_c.h
new file mode 100644
index 0000000000..525b0378b4
--- /dev/null
+++ b/keyboards/handwired/tractyl_manuform/5x6_right/elite_c/elite_c.h
@@ -0,0 +1,19 @@
+/* Copyright 2020 Christopher Courtney, aka Drashna Jael're  (@drashna) <drashna@live.com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#pragma once
+
+#include "5x6_right.h"
diff --git a/keyboards/handwired/tractyl_manuform/5x6_right/elite_c/rules.mk b/keyboards/handwired/tractyl_manuform/5x6_right/elite_c/rules.mk
new file mode 100644
index 0000000000..e594097f8b
--- /dev/null
+++ b/keyboards/handwired/tractyl_manuform/5x6_right/elite_c/rules.mk
@@ -0,0 +1,11 @@
+# MCU name
+MCU = atmega32u4
+
+# Bootloader selection
+BOOTLOADER = atmel-dfu
+
+LTO_ENABLE := yes
+RGBLIGHT_ENABLE = no
+OLED_ENABLE = no
+AUDIO_ENABLE = no
+ENCODER_ENABLE = no
diff --git a/keyboards/handwired/tractyl_manuform/5x6_right/f411/config.h b/keyboards/handwired/tractyl_manuform/5x6_right/f411/config.h
index b2a240f9ff..172ccf7bc2 100644
--- a/keyboards/handwired/tractyl_manuform/5x6_right/f411/config.h
+++ b/keyboards/handwired/tractyl_manuform/5x6_right/f411/config.h
@@ -39,6 +39,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #define WS2812_PWM_DRIVER   PWMD2  // default: PWMD2
 #define WS2812_PWM_CHANNEL  2      // default: 2
 #define WS2812_PWM_PAL_MODE 1      // Pin "alternate function", see the respective datasheet for the appropriate values for your MCU. default: 2
+#define WS2812_EXTERNAL_PULLUP
 //#define WS2812_PWM_COMPLEMENTARY_OUTPUT // Define for a complementary timer output (TIMx_CHyN); omit for a normal timer output (TIMx_CHy).
 #define WS2812_DMA_STREAM   STM32_DMA1_STREAM7  // DMA Stream for TIMx_UP, see the respective reference manual for the appropriate values for your MCU.
 #define WS2812_DMA_CHANNEL  3                   // DMA Channel for TIMx_UP, see the respective reference manual for the appropriate values for your MCU.
@@ -47,7 +48,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #define RGBLIGHT_SPLIT
 #define RGBLED_SPLIT \
     { 10, 10 }
-#define RGBLIGHT_LIMIT_VAL 80
+#define RGBLIGHT_LMIT_VAL 80
 
 #define DEBUG_LED_PIN      C13
 
diff --git a/keyboards/handwired/tractyl_manuform/5x6_right/f411/readme.md b/keyboards/handwired/tractyl_manuform/5x6_right/f411/readme.md
index 6377613814..5fb2c0fc72 100644
--- a/keyboards/handwired/tractyl_manuform/5x6_right/f411/readme.md
+++ b/keyboards/handwired/tractyl_manuform/5x6_right/f411/readme.md
@@ -9,7 +9,8 @@
 * 8KB SPI EEPROM chip sharing PA5-PA7 on SPI1 with PA4 as CS pin
 * Encoder using PA13 and PA14
 * SSD1306 OLED display (128x64) using PB8-PB9 on I2C1
-* Pull-up resistor (22k) on A10 to fix reset issue.
+* Pull-up resistor (22k) on PA10 to fix reset issue.
+* Pull-up resistor (5.1k) on PA1 for WS2812 LED support, and wire it's VCC to the 5V pin.
 
 * Keyboard Maintainer: [Drashna Jael're](https://github.com/drashna)
 * Hardware Supported: [Design files](https://gitlab.com/keyboards1/dm_r_track/-/tree/master/boolean), [WeAct BlackPill (F411)](https://github.com/WeActTC/MiniSTM32F4x1), [PMW3360 Optical Sensor](https://www.tindie.com/products/jkicklighter/pmw3360-motion-sensor/)
diff --git a/keyboards/handwired/tractyl_manuform/5x6_right/keymaps/drashna/config.h b/keyboards/handwired/tractyl_manuform/5x6_right/keymaps/drashna/config.h
index 21bc8e616a..df3e877f98 100644
--- a/keyboards/handwired/tractyl_manuform/5x6_right/keymaps/drashna/config.h
+++ b/keyboards/handwired/tractyl_manuform/5x6_right/keymaps/drashna/config.h
@@ -24,13 +24,8 @@
 
 #define TRACKBALL_DPI_OPTIONS { 1200, 1800, 2600, 3400 }
 
-#define RGBLIGHT_MAX_BRIGHTNESS 60
-
 #undef DEBOUNCE
 #define DEBOUNCE 10
 
 #define SOLENOID_PIN F1
 #define SOLENOID_DEFAULT_DWELL 8
-
-#define OLED_DISPLAY_128X64
-#define OLED_BRIGHTNESS 50
diff --git a/keyboards/handwired/tractyl_manuform/5x6_right/keymaps/drashna/keymap.c b/keyboards/handwired/tractyl_manuform/5x6_right/keymaps/drashna/keymap.c
index f209206337..be2938ebf6 100644
--- a/keyboards/handwired/tractyl_manuform/5x6_right/keymaps/drashna/keymap.c
+++ b/keyboards/handwired/tractyl_manuform/5x6_right/keymaps/drashna/keymap.c
@@ -348,9 +348,16 @@ void render_kitty(void) {
                                                                 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x06, 0x04, 0x04, 0x04, 0x04, 0x05, 0x04, 0x04, 0x04, 0x07, 0x07, 0x07, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}};
 
     // assumes 1 frame prep stage
+#ifdef SWAP_HANDS_ENABLE
     extern bool swap_hands;
+#endif
     void        animation_phase(void) {
-        if (tap_toggling) {
+#    ifdef SWAP_HANDS_ENABLE
+        if (swap_hands)
+#else
+        if (tap_toggling)
+#endif
+        {
             anim_frame_duration = 300;
             current_rtogi_frame = (current_rtogi_frame + 1) % RTOGI_FRAMES;
             oled_write_raw_P(rtogi[abs((RTOGI_FRAMES - 1) - current_rtogi_frame)], ANIM_SIZE);
diff --git a/keyboards/handwired/tractyl_manuform/5x6_right/teensy2pp/config.h b/keyboards/handwired/tractyl_manuform/5x6_right/teensy2pp/config.h
index 2391020598..442d474920 100644
--- a/keyboards/handwired/tractyl_manuform/5x6_right/teensy2pp/config.h
+++ b/keyboards/handwired/tractyl_manuform/5x6_right/teensy2pp/config.h
@@ -35,6 +35,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #define RGBLED_SPLIT \
     { 10, 10 }
 #define RGBLIGHT_LIMIT_VAL 80
+#define OLED_BRIGHTNESS    50
 
 #define DEBUG_LED_PIN   D6