Skip to content

Commit

Permalink
Keychron C1 RGB: Mac and Windows Indicator lights
Browse files Browse the repository at this point in the history
  • Loading branch information
NetUserGet committed Jun 29, 2024
1 parent d29e8e0 commit 1630ab1
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 1 deletion.
62 changes: 62 additions & 0 deletions keyboards/keychron/c1/c1.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/* Copyright 2023 @ NetUserGet
*
* 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"

bool mode_leds_show = true;
bool mode_leds_windows;

static void mode_leds_update(void){
if (mode_leds_show && mode_leds_windows) {
gpio_write_pin_high(LED_WIN_PIN);
} else if (mode_leds_show && !mode_leds_windows) {
gpio_write_pin_high(LED_MAC_PIN);
}
}

#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));
}

mode_leds_windows = !active;
mode_leds_update();
return true;
}

#endif // DIP_SWITCH_ENABLE

void keyboard_pre_init_user(void) {
// Setup Win & Mac LED Pins as output
gpio_set_pin_output(LED_WIN_PIN);
gpio_set_pin_output(LED_MAC_PIN);
}

void suspend_power_down_user(void) {
// Turn leds off
mode_leds_show = false;
mode_leds_update();
}

void suspend_wakeup_init_user(void) {
mode_leds_show = true;
mode_leds_update();
}
6 changes: 6 additions & 0 deletions keyboards/keychron/c1/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#define SN32_RGB_MATRIX_ROW_PINS { C0, C1, C3, C4, C5, C6, C7, C8, C9, C10, C11, C12, C13, C14, B13, D3, B15, B14 }
#define SN32_RGB_MATRIX_COL_PINS { A8, A9, A10, A11, A12, A13, A14, A15, B0, B1, B2, B3, B4, B5, B6, B7, B8 }

#define BACKLIGHT_LEVELS 8

#define LED_MAC_PIN B11 //labeled Mac on KB since no Scroll Lock
#define LED_WIN_PIN B12 //labeled Windows on KB since no Numpad

4 changes: 3 additions & 1 deletion keyboards/keychron/c1/keyboard.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
"extrakey": true,
"mousekey": true,
"nkro": true,
"rgb_matrix": true
"rgb_matrix": true,
"dip_switch": true
},
"lto": true,
"indicators": {
Expand Down Expand Up @@ -133,6 +134,7 @@
},
"rgb_matrix": {
"driver": "sn32f24xb",
"speed": 96,
"animations": {
"breathing": true,
"band_spiral_val": true,
Expand Down

0 comments on commit 1630ab1

Please sign in to comment.