Skip to content

Commit

Permalink
Add back deleted ansi_v1 and ansi_v2/rgb files
Browse files Browse the repository at this point in the history
Signed-off-by: Mahid Sheikh <[email protected]>
  • Loading branch information
StandingPadAnimations committed Jun 9, 2024
1 parent 458fabc commit 4eb181d
Show file tree
Hide file tree
Showing 33 changed files with 2,081 additions and 0 deletions.
154 changes: 154 additions & 0 deletions keyboards/keychron/c2_pro/ansi_v1/ansi_v1.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
/* Copyright 2022 @ Keychron (https://www.keychron.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/>.
*/

#include "quantum.h"

// clang-format off
const matrix_row_t matrix_mask[] = {
0b11111111111111111111,
0b11111111111111111111,
0b11111111111111111111,
0b11111111111111111111,
0b11111111111111111111,
0b11111111111111101111,
};

// clang-format on

#ifdef DIP_SWITCH_ENABLE

bool dip_switch_update_kb(uint8_t index, bool active) {
if (!dip_switch_update_user(index, active)) {
return false;
}
if (index == 0) {
default_layer_set(1UL << (active ? 2 : 0));
}
return true;
}

#endif // DIP_SWITCH_ENABLE

#if (defined(RGB_MATRIX_ENABLE) || defined(LED_MATRIX_ENABLE))

# ifdef RGB_MATRIX_ENABLE
# define LED_MATRIX_INDICATORS_KB rgb_matrix_indicators_kb
# define LED_MATRIX_INDICATORS_USER rgb_matrix_indicators_user
# define LED_MATRIX_SET_COLOR rgb_matrix_set_color
# define LED_MATRIX_UPDATE_PWN_BUFFERS rgb_matrix_update_pwm_buffers
# define LED_MATRIX_INDICATORS_NONE_KB rgb_matrix_indicators_none_kb
# define LED_MATRIX_IS_ENABLED rgb_matrix_is_enabled
# define COLOR_WHITE 255, 255, 255
# define COLOR_BLACK 0, 0, 0
# endif

# ifdef LED_MATRIX_ENABLE
# define LED_MATRIX_INDICATORS_KB led_matrix_indicators_kb
# define LED_MATRIX_INDICATORS_USER led_matrix_indicators_user
# define LED_MATRIX_SET_COLOR led_matrix_set_value
# define LED_MATRIX_UPDATE_PWN_BUFFERS led_matrix_update_pwm_buffers
# define LED_MATRIX_INDICATORS_NONE_KB led_matrix_indicators_none_kb
# define LED_MATRIX_IS_ENABLED led_matrix_is_enabled
# define COLOR_WHITE 255
# define COLOR_BLACK 0
# endif

extern void LED_MATRIX_UPDATE_PWN_BUFFERS(void);

bool LED_MATRIX_INDICATORS_KB(void) {
if (!LED_MATRIX_INDICATORS_USER()) {
return false;
}
if (host_keyboard_led_state().caps_lock) {
LED_MATRIX_SET_COLOR(CAPS_LOCK_LED_INDEX, COLOR_WHITE);
} else {
LED_MATRIX_SET_COLOR(CAPS_LOCK_LED_INDEX, COLOR_BLACK);
}
if (host_keyboard_led_state().num_lock) {
LED_MATRIX_SET_COLOR(NUM_LOCK_LED_INDEX, COLOR_WHITE);
} else {
LED_MATRIX_SET_COLOR(NUM_LOCK_LED_INDEX, COLOR_BLACK);
}
if (default_layer_state == (1 << 0)) {
LED_MATRIX_SET_COLOR(MAC_OS_LED_INDEX, COLOR_WHITE);
} else {
LED_MATRIX_SET_COLOR(MAC_OS_LED_INDEX, COLOR_BLACK);
}
if (default_layer_state == (1 << 2)) {
LED_MATRIX_SET_COLOR(WIN_OS_LED_INDEX, COLOR_WHITE);
} else {
LED_MATRIX_SET_COLOR(WIN_OS_LED_INDEX, COLOR_BLACK);
}
return true;
}

void LED_MATRIX_INDICATORS_NONE_KB(void) {
LED_MATRIX_INDICATORS_KB();
LED_MATRIX_UPDATE_PWN_BUFFERS();
}

bool led_update_kb(led_t led_state) {
bool res = led_update_user(led_state);

if (LED_MATRIX_IS_ENABLED()
# if defined(RGB_MATRIX_ENABLE)
# if defined(ENABLE_RGB_MATRIX_RAINDROPS)
&& (rgb_matrix_get_mode() != RGB_MATRIX_RAINDROPS)
# endif
# if defined(ENABLE_RGB_MATRIX_JELLYBEAN_RAINDROPS)
&& (rgb_matrix_get_mode() != RGB_MATRIX_JELLYBEAN_RAINDROPS)
# endif
# if defined(ENABLE_RGB_MATRIX_PIXEL_RAIN)
&& (rgb_matrix_get_mode() != RGB_MATRIX_PIXEL_RAIN)
# endif
# endif
) {
return res;
}

if (res) {
if (led_state.num_lock) {
LED_MATRIX_SET_COLOR(NUM_LOCK_LED_INDEX, COLOR_WHITE);
} else {
LED_MATRIX_SET_COLOR(NUM_LOCK_LED_INDEX, COLOR_BLACK);
}
if (led_state.caps_lock) {
LED_MATRIX_SET_COLOR(CAPS_LOCK_LED_INDEX, COLOR_WHITE);
} else {
LED_MATRIX_SET_COLOR(CAPS_LOCK_LED_INDEX, COLOR_BLACK);
}
LED_MATRIX_UPDATE_PWN_BUFFERS();
}
return res;
}

void housekeeping_task_kb(void) {
if (!LED_MATRIX_IS_ENABLED()) {
if (default_layer_state == (1 << 0)) {
LED_MATRIX_SET_COLOR(MAC_OS_LED_INDEX, COLOR_WHITE);
} else {
LED_MATRIX_SET_COLOR(MAC_OS_LED_INDEX, COLOR_BLACK);
}
if (default_layer_state == (1 << 2)) {
LED_MATRIX_SET_COLOR(WIN_OS_LED_INDEX, COLOR_WHITE);
} else {
LED_MATRIX_SET_COLOR(WIN_OS_LED_INDEX, COLOR_BLACK);
}
LED_MATRIX_UPDATE_PWN_BUFFERS();
}
}

#endif
43 changes: 43 additions & 0 deletions keyboards/keychron/c2_pro/ansi_v1/config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/* Copyright 2022 @ Keychron(https://www.keychron.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

/* DIP switch */
#define DIP_SWITCH_MATRIX_GRID { {5, 4}, }

/* Disable DIP switch in matrix data */
#define MATRIX_MASKED

/* Increase I2C speed to 1000 KHz */
#define I2C1_TIMINGR_PRESC 0U
#define I2C1_TIMINGR_SCLDEL 3U
#define I2C1_TIMINGR_SDADEL 0U
#define I2C1_TIMINGR_SCLH 15U
#define I2C1_TIMINGR_SCLL 51U

/* Enable indicator LED*/
#define NUM_LOCK_LED_INDEX 16
#define CAPS_LOCK_LED_INDEX 17
#define MAC_OS_LED_INDEX 18
#define WIN_OS_LED_INDEX 19

/* HC595 driver definition */
#define HC595_STCP A0
#define HC595_SHCP A1
#define HC595_DS C15
#define HC595_START_INDEX 11
#define HC595_END_INDEX 19
21 changes: 21 additions & 0 deletions keyboards/keychron/c2_pro/ansi_v1/halconf.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/* Copyright 2020 QMK
*
* 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 HAL_USE_I2C TRUE

#include_next <halconf.h>
11 changes: 11 additions & 0 deletions keyboards/keychron/c2_pro/ansi_v1/info.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"processor": "STM32L432",
"bootloader": "stm32-dfu",
"matrix_pins": {
"cols": ["A10", "A9", "A8", "B1", "B0", "A7", "A6", "A5", "A4", "A3", "A2", null, null, null, null, null, null, null, null, "C14"],
"rows": ["B5", "B4", "B3", "A15", "A14", "A13"],
"custom": true,
"custom_lite": true
},
"diode_direction": "ROW2COL"
}
22 changes: 22 additions & 0 deletions keyboards/keychron/c2_pro/ansi_v1/mcuconf.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/* Copyright 2020 QMK
*
* 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_next <mcuconf.h>

#undef STM32_I2C_USE_I2C1
#define STM32_I2C_USE_I2C1 TRUE
40 changes: 40 additions & 0 deletions keyboards/keychron/c2_pro/ansi_v1/rgb/config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/* Copyright 2022 @ Keychron (https://www.keychron.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

#ifdef RGB_MATRIX_ENABLE
/* RGB Matrix Driver Configuration */
# define DRIVER_COUNT 2
# define DRIVER_ADDR_1 0b1110111
# define DRIVER_ADDR_2 0b1110100

/* RGB Matrix Configuration */
# define RGB_MATRIX_LED_COUNT 108

/* turn off effects when suspended */
# define RGB_DISABLE_WHEN_USB_SUSPENDED

/* Set LED driver current */
# define CKLED2001_CURRENT_TUNE \
{ 0xAA, 0xAA, 0x56, 0xAA, 0xAA, 0x56, 0xAA, 0xAA, 0x56, 0xAA, 0xAA, 0x56 }

// RGB Matrix Animation modes. Explicitly enabled
// For full list of effects, see:
// https://docs.qmk.fm/#/feature_rgb_matrix?id=rgb-matrix-effects
# define RGB_MATRIX_FRAMEBUFFER_EFFECTS
# define RGB_MATRIX_KEYPRESSES
#endif
Loading

0 comments on commit 4eb181d

Please sign in to comment.