From 3a215195ed3a12464df7169e7b68bfe0763e95b1 Mon Sep 17 00:00:00 2001 From: fauxpark Date: Mon, 4 Nov 2019 09:43:13 +1100 Subject: [PATCH] Convert remaining PS2AVRGB boards to I2C WS2812 driver (#7245) * Convert remaining PS2AVRGB boards to I2C WS2812 driver * Add back functions to make the custom matrices happy --- keyboards/bfake/bfake.c | 53 +++++-------- keyboards/bfake/i2c.c | 106 ------------------------- keyboards/bfake/i2c.h | 27 ------- keyboards/bfake/rules.mk | 19 +---- keyboards/jc65/v32a/i2c.c | 106 ------------------------- keyboards/jc65/v32a/i2c.h | 27 ------- keyboards/jc65/v32a/rules.mk | 19 +---- keyboards/jc65/v32a/v32a.c | 56 +++++-------- keyboards/jj50/i2c.c | 104 ------------------------ keyboards/jj50/i2c.h | 25 ------ keyboards/jj50/jj50.c | 67 +++------------- keyboards/jj50/rules.mk | 24 +----- keyboards/mechmini/v1/i2c.c | 104 ------------------------ keyboards/mechmini/v1/i2c.h | 22 ----- keyboards/mechmini/v1/rules.mk | 19 +---- keyboards/mechmini/v1/v1.c | 60 ++------------ keyboards/mehkee96/i2c.c | 106 ------------------------- keyboards/mehkee96/i2c.h | 27 ------- keyboards/mehkee96/mehkee96.c | 65 ++------------- keyboards/mehkee96/rules.mk | 4 +- keyboards/mt40/i2c.c | 104 ------------------------ keyboards/mt40/i2c.h | 25 ------ keyboards/mt40/mt40.c | 29 +------ keyboards/mt40/rules.mk | 4 +- keyboards/percent/canoe/canoe.c | 92 +++++++-------------- keyboards/percent/canoe/i2c.c | 106 ------------------------- keyboards/percent/canoe/i2c.h | 27 ------- keyboards/percent/canoe/rules.mk | 21 +---- keyboards/percent/skog/i2c.c | 106 ------------------------- keyboards/percent/skog/i2c.h | 25 ------ keyboards/percent/skog/rules.mk | 19 +---- keyboards/percent/skog/skog.c | 66 ++------------- keyboards/winkeyless/bmini/bmini.c | 26 +----- keyboards/winkeyless/bmini/i2c.c | 106 ------------------------- keyboards/winkeyless/bmini/i2c.h | 27 ------- keyboards/winkeyless/bmini/rules.mk | 19 +---- keyboards/winkeyless/bminiex/bminiex.c | 61 -------------- keyboards/winkeyless/bminiex/i2c.c | 106 ------------------------- keyboards/winkeyless/bminiex/i2c.h | 25 ------ keyboards/winkeyless/bminiex/rules.mk | 19 +---- keyboards/ymd75/i2c.c | 104 ------------------------ keyboards/ymd75/i2c.h | 25 ------ keyboards/ymd75/rules.mk | 20 +---- keyboards/ymd75/ymd75.c | 67 +++------------- keyboards/ymd96/i2c.c | 104 ------------------------ keyboards/ymd96/i2c.h | 25 ------ keyboards/ymd96/rules.mk | 19 +---- keyboards/ymd96/ymd96.c | 66 ++------------- keyboards/ymdk_np21/i2c.c | 104 ------------------------ keyboards/ymdk_np21/i2c.h | 25 ------ keyboards/ymdk_np21/rules.mk | 20 +---- keyboards/ymdk_np21/ymdk_np21.c | 45 ----------- 52 files changed, 138 insertions(+), 2539 deletions(-) delete mode 100644 keyboards/bfake/i2c.c delete mode 100644 keyboards/bfake/i2c.h delete mode 100644 keyboards/jc65/v32a/i2c.c delete mode 100644 keyboards/jc65/v32a/i2c.h delete mode 100644 keyboards/jj50/i2c.c delete mode 100644 keyboards/jj50/i2c.h delete mode 100644 keyboards/mechmini/v1/i2c.c delete mode 100644 keyboards/mechmini/v1/i2c.h delete mode 100644 keyboards/mehkee96/i2c.c delete mode 100644 keyboards/mehkee96/i2c.h delete mode 100644 keyboards/mt40/i2c.c delete mode 100644 keyboards/mt40/i2c.h delete mode 100644 keyboards/percent/canoe/i2c.c delete mode 100644 keyboards/percent/canoe/i2c.h delete mode 100644 keyboards/percent/skog/i2c.c delete mode 100644 keyboards/percent/skog/i2c.h delete mode 100644 keyboards/winkeyless/bmini/i2c.c delete mode 100644 keyboards/winkeyless/bmini/i2c.h delete mode 100644 keyboards/winkeyless/bminiex/i2c.c delete mode 100644 keyboards/winkeyless/bminiex/i2c.h delete mode 100644 keyboards/ymd75/i2c.c delete mode 100644 keyboards/ymd75/i2c.h delete mode 100644 keyboards/ymd96/i2c.c delete mode 100644 keyboards/ymd96/i2c.h delete mode 100644 keyboards/ymdk_np21/i2c.c delete mode 100644 keyboards/ymdk_np21/i2c.h diff --git a/keyboards/bfake/bfake.c b/keyboards/bfake/bfake.c index 2160706fea5..f7d006576c7 100644 --- a/keyboards/bfake/bfake.c +++ b/keyboards/bfake/bfake.c @@ -16,51 +16,34 @@ along with this program. If not, see . */ #include "bfake.h" -#ifdef BACKLIGHT_ENABLE -#include "backlight.h" -#endif -#ifdef RGBLIGHT_ENABLE -#include "rgblight.h" -#endif - -#include - -#include "action_layer.h" -#include "i2c.h" -#include "quantum.h" - -#ifdef RGBLIGHT_ENABLE -extern rgblight_config_t rgblight_config; - -void rgblight_set(void) { - if (!rgblight_config.enable) { - for (uint8_t i = 0; i < RGBLED_NUM; i++) { - led[i].r = 0; - led[i].g = 0; - led[i].b = 0; - } - } - - i2c_init(); - i2c_send(0xb0, (uint8_t*)led, 3 * RGBLED_NUM); -} -#endif __attribute__ ((weak)) -void matrix_scan_user(void) { -} +void matrix_scan_user(void) {} void backlight_init_ports(void) { - DDRD |= (1<<0 | 1<<1 | 1<<4 | 1<<6); - PORTD &= ~(1<<0 | 1<<1 | 1<<4 | 1<<6); + setPinOutput(D0); + setPinOutput(D1); + setPinOutput(D4); + setPinOutput(D6); + + writePinLow(D0); + writePinLow(D1); + writePinLow(D4); + writePinLow(D6); } void backlight_set(uint8_t level) { if (level == 0) { // Turn out the lights - PORTD &= ~(1<<0 | 1<<1 | 1<<4 | 1<<6); + writePinLow(D0); + writePinLow(D1); + writePinLow(D4); + writePinLow(D6); } else { // Turn on the lights - PORTD |= (1<<0 | 1<<1 | 1<<4 | 1<<6); + writePinHigh(D0); + writePinHigh(D1); + writePinHigh(D4); + writePinHigh(D6); } } diff --git a/keyboards/bfake/i2c.c b/keyboards/bfake/i2c.c deleted file mode 100644 index a4f95213524..00000000000 --- a/keyboards/bfake/i2c.c +++ /dev/null @@ -1,106 +0,0 @@ -/* -Copyright 2016 Luiz Ribeiro - -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 . -*/ - -// Please do not modify this file - -#include -#include - -#include "i2c.h" - -void i2c_set_bitrate(uint16_t bitrate_khz) { - uint8_t bitrate_div = ((F_CPU / 1000l) / bitrate_khz); - if (bitrate_div >= 16) { - bitrate_div = (bitrate_div - 16) / 2; - } - TWBR = bitrate_div; -} - -void i2c_init(void) { - // set pull-up resistors on I2C bus pins - PORTC |= 0b11; - - i2c_set_bitrate(400); - - // enable TWI (two-wire interface) - TWCR |= (1 << TWEN); - - // enable TWI interrupt and slave address ACK - TWCR |= (1 << TWIE); - TWCR |= (1 << TWEA); -} - -uint8_t i2c_start(uint8_t address) { - // reset TWI control register - TWCR = 0; - - // begin transmission and wait for it to end - TWCR = (1< - -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 . -*/ - -// Please do not modify this file - -#ifndef __I2C_H__ -#define __I2C_H__ - -void i2c_init(void); -void i2c_set_bitrate(uint16_t bitrate_khz); -uint8_t i2c_send(uint8_t address, uint8_t *data, uint16_t length); - -#endif diff --git a/keyboards/bfake/rules.mk b/keyboards/bfake/rules.mk index b5b3b852cb0..5963c9810a0 100644 --- a/keyboards/bfake/rules.mk +++ b/keyboards/bfake/rules.mk @@ -1,18 +1,3 @@ -# Copyright 2017 Luiz Ribeiro -# -# 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 . - # MCU name MCU = atmega32a @@ -34,10 +19,10 @@ CONSOLE_ENABLE = yes COMMAND_ENABLE = yes BACKLIGHT_ENABLE = no RGBLIGHT_ENABLE = no -RGBLIGHT_CUSTOM_DRIVER = yes +WS2812_DRIVER = i2c OPT_DEFS = -DDEBUG_LEVEL=0 # custom matrix setup CUSTOM_MATRIX = yes -SRC = matrix.c i2c.c +SRC = matrix.c diff --git a/keyboards/jc65/v32a/i2c.c b/keyboards/jc65/v32a/i2c.c deleted file mode 100644 index a4f95213524..00000000000 --- a/keyboards/jc65/v32a/i2c.c +++ /dev/null @@ -1,106 +0,0 @@ -/* -Copyright 2016 Luiz Ribeiro - -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 . -*/ - -// Please do not modify this file - -#include -#include - -#include "i2c.h" - -void i2c_set_bitrate(uint16_t bitrate_khz) { - uint8_t bitrate_div = ((F_CPU / 1000l) / bitrate_khz); - if (bitrate_div >= 16) { - bitrate_div = (bitrate_div - 16) / 2; - } - TWBR = bitrate_div; -} - -void i2c_init(void) { - // set pull-up resistors on I2C bus pins - PORTC |= 0b11; - - i2c_set_bitrate(400); - - // enable TWI (two-wire interface) - TWCR |= (1 << TWEN); - - // enable TWI interrupt and slave address ACK - TWCR |= (1 << TWIE); - TWCR |= (1 << TWEA); -} - -uint8_t i2c_start(uint8_t address) { - // reset TWI control register - TWCR = 0; - - // begin transmission and wait for it to end - TWCR = (1< - -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 . -*/ - -// Please do not modify this file - -#ifndef __I2C_H__ -#define __I2C_H__ - -void i2c_init(void); -void i2c_set_bitrate(uint16_t bitrate_khz); -uint8_t i2c_send(uint8_t address, uint8_t *data, uint16_t length); - -#endif diff --git a/keyboards/jc65/v32a/rules.mk b/keyboards/jc65/v32a/rules.mk index ee6efb3fa53..18e7f1de9dc 100644 --- a/keyboards/jc65/v32a/rules.mk +++ b/keyboards/jc65/v32a/rules.mk @@ -1,18 +1,3 @@ -# Copyright 2017 Luiz Ribeiro -# -# 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 . - # MCU name MCU = atmega32a @@ -34,10 +19,10 @@ CONSOLE_ENABLE = yes COMMAND_ENABLE = yes BACKLIGHT_ENABLE = yes RGBLIGHT_ENABLE = yes -RGBLIGHT_CUSTOM_DRIVER = yes +WS2812_DRIVER = i2c OPT_DEFS = -DDEBUG_LEVEL=0 # custom matrix setup CUSTOM_MATRIX = yes -SRC = matrix.c i2c.c +SRC = matrix.c diff --git a/keyboards/jc65/v32a/v32a.c b/keyboards/jc65/v32a/v32a.c index 8176ade0a1c..9b1e07274c5 100644 --- a/keyboards/jc65/v32a/v32a.c +++ b/keyboards/jc65/v32a/v32a.c @@ -16,56 +16,36 @@ along with this program. If not, see . */ #include "v32a.h" -#ifdef BACKLIGHT_ENABLE -#include "backlight.h" -#endif -#ifdef RGBLIGHT_ENABLE -#include "rgblight.h" -#endif - -#include - -#include "action_layer.h" -#include "i2c.h" -#include "quantum.h" - -#ifdef RGBLIGHT_ENABLE -extern rgblight_config_t rgblight_config; - -void rgblight_set(void) { - if (!rgblight_config.enable) { - for (uint8_t i = 0; i < RGBLED_NUM; i++) { - led[i].r = 0; - led[i].g = 0; - led[i].b = 0; - } - } - - i2c_init(); - i2c_send(0xb0, (uint8_t*)led, 3 * RGBLED_NUM); -} -#endif __attribute__ ((weak)) -void matrix_scan_user(void) { -#ifdef RGBLIGHT_ENABLE - rgblight_task(); -#endif -} +void matrix_scan_user(void) {} #ifdef BACKLIGHT_ENABLE void backlight_init_ports(void) { - DDRD |= (1<<0 | 1<<1 | 1<<4 | 1<<6); - PORTD &= ~(1<<0 | 1<<1 | 1<<4 | 1<<6); + setPinOutput(D0); + setPinOutput(D1); + setPinOutput(D4); + setPinOutput(D6); + + writePinLow(D0); + writePinLow(D1); + writePinLow(D4); + writePinLow(D6); } void backlight_set(uint8_t level) { if (level == 0) { // Turn out the lights - PORTD &= ~(1<<0 | 1<<1 | 1<<4 | 1<<6); + writePinLow(D0); + writePinLow(D1); + writePinLow(D4); + writePinLow(D6); } else { // Turn on the lights - PORTD |= (1<<0 | 1<<1 | 1<<4 | 1<<6); + writePinHigh(D0); + writePinHigh(D1); + writePinHigh(D4); + writePinHigh(D6); } } #endif diff --git a/keyboards/jj50/i2c.c b/keyboards/jj50/i2c.c deleted file mode 100644 index c27f3e3d17e..00000000000 --- a/keyboards/jj50/i2c.c +++ /dev/null @@ -1,104 +0,0 @@ -/* -Copyright 2016 Luiz Ribeiro - -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 . -*/ - -#include -#include - -#include "i2c.h" - -void i2c_set_bitrate(uint16_t bitrate_khz) { - uint8_t bitrate_div = ((F_CPU / 1000l) / bitrate_khz); - if (bitrate_div >= 16) { - bitrate_div = (bitrate_div - 16) / 2; - } - TWBR = bitrate_div; -} - -void i2c_init(void) { - // set pull-up resistors on I2C bus pins - PORTC |= 0b11; - - i2c_set_bitrate(400); - - // enable TWI (two-wire interface) - TWCR |= (1 << TWEN); - - // enable TWI interrupt and slave address ACK - TWCR |= (1 << TWIE); - TWCR |= (1 << TWEA); -} - -uint8_t i2c_start(uint8_t address) { - // reset TWI control register - TWCR = 0; - - // begin transmission and wait for it to end - TWCR = (1< - -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 . -*/ - -#ifndef __I2C_H__ -#define __I2C_H__ - -void i2c_init(void); -void i2c_set_bitrate(uint16_t bitrate_khz); -uint8_t i2c_send(uint8_t address, uint8_t *data, uint16_t length); - -#endif diff --git a/keyboards/jj50/jj50.c b/keyboards/jj50/jj50.c index d4a70f68d0d..7c3cee95d18 100644 --- a/keyboards/jj50/jj50.c +++ b/keyboards/jj50/jj50.c @@ -17,24 +17,20 @@ along with this program. If not, see . #include "jj50.h" -#include - -#include "action_layer.h" -#include "i2c.h" -#include "quantum.h" - #include "backlight.h" #include "backlight_custom.h" -// for keyboard subdirectory level init functions -// @Override -void matrix_init_kb(void) { - // call user level keymaps, if any - matrix_init_user(); -} +void matrix_init_kb(void) { matrix_init_user(); } + +__attribute__ ((weak)) +void matrix_init_user(void) {} + +void matrix_scan_kb(void) { matrix_scan_user(); } + +__attribute__ ((weak)) +void matrix_scan_user(void) {} #ifdef BACKLIGHT_ENABLE -/// Overrides functions in `quantum.c` void backlight_init_ports(void) { b_led_init_ports(); } @@ -47,48 +43,3 @@ void backlight_set(uint8_t level) { b_led_set(level); } #endif - -#ifdef RGBLIGHT_ENABLE -extern rgblight_config_t rgblight_config; - -// custom RGB driver -void rgblight_set(void) { - if (!rgblight_config.enable) { - for (uint8_t i=0; i -# Modified 2018 Wayne Jones (WarmCatUK) - -# 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 . - # MCU name MCU = atmega32a @@ -35,22 +19,18 @@ CONSOLE_ENABLE = no COMMAND_ENABLE = yes BACKLIGHT_ENABLE = yes RGBLIGHT_ENABLE = yes -RGBLIGHT_CUSTOM_DRIVER = yes +WS2812_DRIVER = i2c NKRO_ENABLE = no # Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work - -DISABLE_WS2812 = no - KEY_LOCK_ENABLE = yes # Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend - #OPT_DEFS = -DDEBUG_LEVEL=0 # custom matrix setup CUSTOM_MATRIX = yes -SRC = matrix.c i2c.c backlight.c +SRC = matrix.c backlight.c LAYOUTS = ortho_5x12 diff --git a/keyboards/mechmini/v1/i2c.c b/keyboards/mechmini/v1/i2c.c deleted file mode 100644 index c27f3e3d17e..00000000000 --- a/keyboards/mechmini/v1/i2c.c +++ /dev/null @@ -1,104 +0,0 @@ -/* -Copyright 2016 Luiz Ribeiro - -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 . -*/ - -#include -#include - -#include "i2c.h" - -void i2c_set_bitrate(uint16_t bitrate_khz) { - uint8_t bitrate_div = ((F_CPU / 1000l) / bitrate_khz); - if (bitrate_div >= 16) { - bitrate_div = (bitrate_div - 16) / 2; - } - TWBR = bitrate_div; -} - -void i2c_init(void) { - // set pull-up resistors on I2C bus pins - PORTC |= 0b11; - - i2c_set_bitrate(400); - - // enable TWI (two-wire interface) - TWCR |= (1 << TWEN); - - // enable TWI interrupt and slave address ACK - TWCR |= (1 << TWIE); - TWCR |= (1 << TWEA); -} - -uint8_t i2c_start(uint8_t address) { - // reset TWI control register - TWCR = 0; - - // begin transmission and wait for it to end - TWCR = (1< -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 . -*/ - -#ifndef __I2C_H__ -#define __I2C_H__ - -void i2c_init(void); -void i2c_set_bitrate(uint16_t bitrate_khz); -uint8_t i2c_send(uint8_t address, uint8_t *data, uint16_t length); - -#endif diff --git a/keyboards/mechmini/v1/rules.mk b/keyboards/mechmini/v1/rules.mk index 3510ca6f3f1..ee023b43bae 100644 --- a/keyboards/mechmini/v1/rules.mk +++ b/keyboards/mechmini/v1/rules.mk @@ -1,18 +1,3 @@ -# Copyright 2017 Luiz Ribeiro -# -# 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 . - # MCU name MCU = atmega32a @@ -34,10 +19,10 @@ CONSOLE_ENABLE = yes COMMAND_ENABLE = yes BACKLIGHT_ENABLE = no RGBLIGHT_ENABLE = yes -RGBLIGHT_CUSTOM_DRIVER = yes +WS2812_DRIVER = i2c OPT_DEFS = -DDEBUG_LEVEL=0 # custom matrix setup CUSTOM_MATRIX = yes -SRC = matrix.c i2c.c +SRC = matrix.c diff --git a/keyboards/mechmini/v1/v1.c b/keyboards/mechmini/v1/v1.c index 508d60c784d..2c910d9658c 100644 --- a/keyboards/mechmini/v1/v1.c +++ b/keyboards/mechmini/v1/v1.c @@ -16,61 +16,13 @@ along with this program. If not, see . */ #include "v1.h" -#include -#include "action_layer.h" -#include "i2c.h" -#include "quantum.h" -#include "rgblight.h" -// for keyboard subdirectory level init functions -// @Override -void matrix_init_kb(void) { - // call user level keymaps, if any - matrix_init_user(); -} +void matrix_init_kb(void) { matrix_init_user(); } -#ifdef RGBLIGHT_ENABLE -extern rgblight_config_t rgblight_config; +__attribute__ ((weak)) +void matrix_init_user(void) {} -// custom RGB driver -void rgblight_set(void) { - if (!rgblight_config.enable) { - for (uint8_t i=0; i - -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 . -*/ - -// Please do not modify this file - -#include -#include - -#include "i2c.h" - -void i2c_set_bitrate(uint16_t bitrate_khz) { - uint8_t bitrate_div = ((F_CPU / 1000l) / bitrate_khz); - if (bitrate_div >= 16) { - bitrate_div = (bitrate_div - 16) / 2; - } - TWBR = bitrate_div; -} - -void i2c_init(void) { - // set pull-up resistors on I2C bus pins - PORTC |= 0b11; - - i2c_set_bitrate(400); - - // enable TWI (two-wire interface) - TWCR |= (1 << TWEN); - - // enable TWI interrupt and slave address ACK - TWCR |= (1 << TWIE); - TWCR |= (1 << TWEA); -} - -uint8_t i2c_start(uint8_t address) { - // reset TWI control register - TWCR = 0; - - // begin transmission and wait for it to end - TWCR = (1< - -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 . -*/ - -// Please do not modify this file - -#ifndef __I2C_H__ -#define __I2C_H__ - -void i2c_init(void); -void i2c_set_bitrate(uint16_t bitrate_khz); -uint8_t i2c_send(uint8_t address, uint8_t *data, uint16_t length); - -#endif diff --git a/keyboards/mehkee96/mehkee96.c b/keyboards/mehkee96/mehkee96.c index 604fad8032c..46427ec93bf 100644 --- a/keyboards/mehkee96/mehkee96.c +++ b/keyboards/mehkee96/mehkee96.c @@ -16,66 +16,13 @@ along with this program. If not, see . */ #include "mehkee96.h" -#include "rgblight.h" -#include +void matrix_init_kb(void) { matrix_init_user(); } -#include "action_layer.h" -#include "i2c.h" -#include "quantum.h" +__attribute__ ((weak)) +void matrix_init_user(void) {} -// for keyboard subdirectory level init functions -// @Override -void matrix_init_kb(void) { - // call user level keymaps, if any - matrix_init_user(); -} +void matrix_scan_kb(void) { matrix_scan_user(); } -#ifdef RGBLIGHT_ENABLE -extern rgblight_config_t rgblight_config; - -// custom RGB driver -void rgblight_set(void) { - if (!rgblight_config.enable) { - for (uint8_t i=0; i - -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 . -*/ - -#include -#include - -#include "i2c.h" - -void i2c_set_bitrate(uint16_t bitrate_khz) { - uint8_t bitrate_div = ((F_CPU / 1000l) / bitrate_khz); - if (bitrate_div >= 16) { - bitrate_div = (bitrate_div - 16) / 2; - } - TWBR = bitrate_div; -} - -void i2c_init(void) { - // set pull-up resistors on I2C bus pins - PORTC |= 0b11; - - i2c_set_bitrate(400); - - // enable TWI (two-wire interface) - TWCR |= (1 << TWEN); - - // enable TWI interrupt and slave address ACK - TWCR |= (1 << TWIE); - TWCR |= (1 << TWEA); -} - -uint8_t i2c_start(uint8_t address) { - // reset TWI control register - TWCR = 0; - - // begin transmission and wait for it to end - TWCR = (1< - -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 . -*/ - -#ifndef __I2C_H__ -#define __I2C_H__ - -void i2c_init(void); -void i2c_set_bitrate(uint16_t bitrate_khz); -uint8_t i2c_send(uint8_t address, uint8_t *data, uint16_t length); - -#endif diff --git a/keyboards/mt40/mt40.c b/keyboards/mt40/mt40.c index 555689f8729..dd079e7d813 100644 --- a/keyboards/mt40/mt40.c +++ b/keyboards/mt40/mt40.c @@ -13,32 +13,5 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -#include "mt40.h" -#include "rgblight.h" - -#include - -#include "action_layer.h" -#include "i2c.h" -#include "quantum.h" - -extern rgblight_config_t rgblight_config; -void rgblight_set(void) { - if (!rgblight_config.enable) { - for (uint8_t i = 0; i < RGBLED_NUM; i++) { - led[i].r = 0; - led[i].g = 0; - led[i].b = 0; - } - } - - i2c_init(); - i2c_send(0xb0, (uint8_t*)led, 3 * RGBLED_NUM); -} - -__attribute__ ((weak)) -void matrix_scan_kb(void) { - rgblight_task(); - matrix_init_user(); -} +#include "mt40.h" diff --git a/keyboards/mt40/rules.mk b/keyboards/mt40/rules.mk index 19410bc6e02..0cbf90c674b 100644 --- a/keyboards/mt40/rules.mk +++ b/keyboards/mt40/rules.mk @@ -24,14 +24,14 @@ AUDIO_ENABLE ?= no # Audio output on port C6 UNICODE_ENABLE ?= no # Unicode BLUETOOTH_ENABLE ?= no # Enable Bluetooth with the Adafruit EZ-Key HID RGBLIGHT_ENABLE ?= yes # Enable WS2812 RGB underlight. -RGBLIGHT_CUSTOM_DRIVER = yes +WS2812_DRIVER = i2c TAP_DANCE_ENABLE = no OPT_DEFS = -DDEBUG_LEVEL=0 # custom matrix setup CUSTOM_MATRIX = yes -SRC = matrix.c i2c.c +SRC = matrix.c LAYOUTS = planck_mit LAYOUTS_HAS_RGB = no diff --git a/keyboards/percent/canoe/canoe.c b/keyboards/percent/canoe/canoe.c index a7427e15286..e59b0dd7bcc 100644 --- a/keyboards/percent/canoe/canoe.c +++ b/keyboards/percent/canoe/canoe.c @@ -16,81 +16,43 @@ along with this program. If not, see . */ #include "canoe.h" -#ifdef BACKLIGHT_ENABLE -#include "backlight.h" -#endif -#ifdef RGBLIGHT_ENABLE -#include "i2c.h" -#include "rgblight.h" -#endif + +void matrix_init_kb(void) { matrix_init_user(); } + +__attribute__ ((weak)) +void matrix_init_user(void) {} + +void matrix_scan_kb(void) { matrix_scan_user(); } + +__attribute__ ((weak)) +void matrix_scan_user(void) {} #ifdef BACKLIGHT_ENABLE void backlight_set(uint8_t level) { if (level == 0) { // Turn out the lights - PORTD &= ~(1<<0 | 1<<1 | 1<<4 | 1<<6); + writePinLow(D0); + writePinLow(D1); + writePinLow(D4); + writePinLow(D6); } else { // Turn on the lights - PORTD |= (1<<0 | 1<<1 | 1<<4 | 1<<6); + writePinHigh(D0); + writePinHigh(D1); + writePinHigh(D4); + writePinHigh(D6); } } void backlight_init_ports(void) { - DDRD |= (1<<0 | 1<<1 | 1<<4 | 1<<6); - PORTD &= ~(1<<0 | 1<<1 | 1<<4 | 1<<6); -} - -#endif - -// for keyboard subdirectory level init functions -// @Override -void matrix_init_kb(void) { - // call user level keymaps, if any - matrix_init_user(); -} - -#ifdef RGBLIGHT_ENABLE -extern rgblight_config_t rgblight_config; - -// custom RGB driver -void rgblight_set(void) { - if (!rgblight_config.enable) { - for (uint8_t i=0; i - -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 . -*/ - -// Please do not modify this file - -#include -#include - -#include "i2c.h" - -void i2c_set_bitrate(uint16_t bitrate_khz) { - uint8_t bitrate_div = ((F_CPU / 1000l) / bitrate_khz); - if (bitrate_div >= 16) { - bitrate_div = (bitrate_div - 16) / 2; - } - TWBR = bitrate_div; -} - -void i2c_init(void) { - // set pull-up resistors on I2C bus pins - PORTC |= 0b11; - - i2c_set_bitrate(400); - - // enable TWI (two-wire interface) - TWCR |= (1 << TWEN); - - // enable TWI interrupt and slave address ACK - TWCR |= (1 << TWIE); - TWCR |= (1 << TWEA); -} - -uint8_t i2c_start(uint8_t address) { - // reset TWI control register - TWCR = 0; - - // begin transmission and wait for it to end - TWCR = (1< - -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 . -*/ - -// Please do not modify this file - -#ifndef __I2C_H__ -#define __I2C_H__ - -void i2c_init(void); -void i2c_set_bitrate(uint16_t bitrate_khz); -uint8_t i2c_send(uint8_t address, uint8_t *data, uint16_t length); - -#endif diff --git a/keyboards/percent/canoe/rules.mk b/keyboards/percent/canoe/rules.mk index e3269b94db8..bb14269a2b2 100644 --- a/keyboards/percent/canoe/rules.mk +++ b/keyboards/percent/canoe/rules.mk @@ -1,18 +1,3 @@ -# Copyright 2017 Luiz Ribeiro -# -# 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 . - # MCU name MCU = atmega32a @@ -34,12 +19,12 @@ CONSOLE_ENABLE = yes COMMAND_ENABLE = yes BACKLIGHT_ENABLE = no RGBLIGHT_ENABLE = yes -RGBLIGHT_CUSTOM_DRIVER = yes +WS2812_DRIVER = i2c OPT_DEFS = -DDEBUG_LEVEL=0 # custom matrix setup CUSTOM_MATRIX = yes -SRC = matrix.c i2c.c +SRC = matrix.c -LAYOUTS = 65_ansi_blocker \ No newline at end of file +LAYOUTS = 65_ansi_blocker diff --git a/keyboards/percent/skog/i2c.c b/keyboards/percent/skog/i2c.c deleted file mode 100644 index a4f95213524..00000000000 --- a/keyboards/percent/skog/i2c.c +++ /dev/null @@ -1,106 +0,0 @@ -/* -Copyright 2016 Luiz Ribeiro - -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 . -*/ - -// Please do not modify this file - -#include -#include - -#include "i2c.h" - -void i2c_set_bitrate(uint16_t bitrate_khz) { - uint8_t bitrate_div = ((F_CPU / 1000l) / bitrate_khz); - if (bitrate_div >= 16) { - bitrate_div = (bitrate_div - 16) / 2; - } - TWBR = bitrate_div; -} - -void i2c_init(void) { - // set pull-up resistors on I2C bus pins - PORTC |= 0b11; - - i2c_set_bitrate(400); - - // enable TWI (two-wire interface) - TWCR |= (1 << TWEN); - - // enable TWI interrupt and slave address ACK - TWCR |= (1 << TWIE); - TWCR |= (1 << TWEA); -} - -uint8_t i2c_start(uint8_t address) { - // reset TWI control register - TWCR = 0; - - // begin transmission and wait for it to end - TWCR = (1< - -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 . -*/ - -// Please do not modify this file - -#pragma once - -void i2c_init(void); -void i2c_set_bitrate(uint16_t bitrate_khz); -uint8_t i2c_send(uint8_t address, uint8_t *data, uint16_t length); - diff --git a/keyboards/percent/skog/rules.mk b/keyboards/percent/skog/rules.mk index b8439906b8b..2b0c1154dd5 100644 --- a/keyboards/percent/skog/rules.mk +++ b/keyboards/percent/skog/rules.mk @@ -1,18 +1,3 @@ -# Copyright 2018 Jumail Mundekkat / MxBlue -# -# 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 . - # MCU name MCU = atmega32a @@ -34,9 +19,9 @@ CONSOLE_ENABLE = yes COMMAND_ENABLE = yes BACKLIGHT_ENABLE = yes RGBLIGHT_ENABLE = yes +WS2812_DRIVER = i2c BACKLIGHT_CUSTOM_DRIVER = yes -RGBLIGHT_CUSTOM_DRIVER = yes OPT_DEFS = -DDEBUG_LEVEL=0 @@ -45,4 +30,4 @@ SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend # custom matrix setup CUSTOM_MATRIX = yes -SRC = matrix.c i2c.c backlight.c +SRC = matrix.c backlight.c diff --git a/keyboards/percent/skog/skog.c b/keyboards/percent/skog/skog.c index 3d1eb0e1a16..8678d483a7e 100644 --- a/keyboards/percent/skog/skog.c +++ b/keyboards/percent/skog/skog.c @@ -19,23 +19,18 @@ ps2avrGB support code by Kenneth A. (bminiex/.[ch]) #include "skog.h" -#include "rgblight.h" +#include "backlight.h" +#include "backlight_custom.h" -#include +void matrix_init_kb(void) { matrix_init_user(); } -#include "action_layer.h" -#include "i2c.h" -#include "quantum.h" +__attribute__ ((weak)) +void matrix_init_user(void) {} -#include "backlight.h" -#include "backlight_custom.h" +void matrix_scan_kb(void) { matrix_scan_user(); } -// for keyboard subdirectory level init functions -// @Override -void matrix_init_kb(void) { - // call user level keymaps, if any - matrix_init_user(); -} +__attribute__ ((weak)) +void matrix_scan_user(void) {} #ifdef BACKLIGHT_ENABLE /// Overrides functions in `quantum.c` @@ -51,48 +46,3 @@ void backlight_set(uint8_t level) { b_led_set(level); } #endif - -#ifdef RGBLIGHT_ENABLE -extern rgblight_config_t rgblight_config; - -// custom RGB driver -void rgblight_set(void) { - if (!rgblight_config.enable) { - for (uint8_t i=0; i. */ #include "bmini.h" -#include "rgblight.h" - -#include - -#include "action_layer.h" -#include "i2c.h" -#include "quantum.h" - -extern rgblight_config_t rgblight_config; - -void rgblight_set(void) { - if (!rgblight_config.enable) { - for (uint8_t i = 0; i < RGBLED_NUM; i++) { - led[i].r = 0; - led[i].g = 0; - led[i].b = 0; - } - } - - i2c_init(); - i2c_send(0xb0, (uint8_t*)led, 3 * RGBLED_NUM); -} __attribute__ ((weak)) -void matrix_scan_user(void) { - rgblight_task(); -} +void matrix_scan_user(void) {} diff --git a/keyboards/winkeyless/bmini/i2c.c b/keyboards/winkeyless/bmini/i2c.c deleted file mode 100644 index a4f95213524..00000000000 --- a/keyboards/winkeyless/bmini/i2c.c +++ /dev/null @@ -1,106 +0,0 @@ -/* -Copyright 2016 Luiz Ribeiro - -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 . -*/ - -// Please do not modify this file - -#include -#include - -#include "i2c.h" - -void i2c_set_bitrate(uint16_t bitrate_khz) { - uint8_t bitrate_div = ((F_CPU / 1000l) / bitrate_khz); - if (bitrate_div >= 16) { - bitrate_div = (bitrate_div - 16) / 2; - } - TWBR = bitrate_div; -} - -void i2c_init(void) { - // set pull-up resistors on I2C bus pins - PORTC |= 0b11; - - i2c_set_bitrate(400); - - // enable TWI (two-wire interface) - TWCR |= (1 << TWEN); - - // enable TWI interrupt and slave address ACK - TWCR |= (1 << TWIE); - TWCR |= (1 << TWEA); -} - -uint8_t i2c_start(uint8_t address) { - // reset TWI control register - TWCR = 0; - - // begin transmission and wait for it to end - TWCR = (1< - -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 . -*/ - -// Please do not modify this file - -#ifndef __I2C_H__ -#define __I2C_H__ - -void i2c_init(void); -void i2c_set_bitrate(uint16_t bitrate_khz); -uint8_t i2c_send(uint8_t address, uint8_t *data, uint16_t length); - -#endif diff --git a/keyboards/winkeyless/bmini/rules.mk b/keyboards/winkeyless/bmini/rules.mk index 8cfc810566d..7822bd83010 100644 --- a/keyboards/winkeyless/bmini/rules.mk +++ b/keyboards/winkeyless/bmini/rules.mk @@ -1,18 +1,3 @@ -# Copyright 2017 Luiz Ribeiro -# -# 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 . - # MCU name MCU = atmega32a @@ -34,10 +19,10 @@ CONSOLE_ENABLE = yes COMMAND_ENABLE = yes BACKLIGHT_ENABLE = no RGBLIGHT_ENABLE = yes -RGBLIGHT_CUSTOM_DRIVER = yes +WS2812_DRIVER = i2c OPT_DEFS = -DDEBUG_LEVEL=0 # custom matrix setup CUSTOM_MATRIX = yes -SRC = matrix.c i2c.c +SRC = matrix.c diff --git a/keyboards/winkeyless/bminiex/bminiex.c b/keyboards/winkeyless/bminiex/bminiex.c index d9b05aba514..11315b92107 100644 --- a/keyboards/winkeyless/bminiex/bminiex.c +++ b/keyboards/winkeyless/bminiex/bminiex.c @@ -16,24 +16,10 @@ along with this program. If not, see . */ #include "bminiex.h" -#include "rgblight.h" - -#include - -#include "action_layer.h" -#include "i2c.h" -#include "quantum.h" #include "backlight.h" #include "backlight_custom.h" -// for keyboard subdirectory level init functions -// @Override -void matrix_init_kb(void) { - // call user level keymaps, if any - matrix_init_user(); -} - #ifdef BACKLIGHT_ENABLE /// Overrides functions in `quantum.c` void backlight_init_ports(void) { @@ -48,50 +34,3 @@ void backlight_set(uint8_t level) { b_led_set(level); } #endif - -#ifdef RGBLIGHT_ENABLE -extern rgblight_config_t rgblight_config; - -// custom RGB driver -void rgblight_set(void) { - if (!rgblight_config.enable) { - for (uint8_t i=0; i - -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 . -*/ - -// Please do not modify this file - -#include -#include - -#include "i2c.h" - -void i2c_set_bitrate(uint16_t bitrate_khz) { - uint8_t bitrate_div = ((F_CPU / 1000l) / bitrate_khz); - if (bitrate_div >= 16) { - bitrate_div = (bitrate_div - 16) / 2; - } - TWBR = bitrate_div; -} - -void i2c_init(void) { - // set pull-up resistors on I2C bus pins - PORTC |= 0b11; - - i2c_set_bitrate(400); - - // enable TWI (two-wire interface) - TWCR |= (1 << TWEN); - - // enable TWI interrupt and slave address ACK - TWCR |= (1 << TWIE); - TWCR |= (1 << TWEA); -} - -uint8_t i2c_start(uint8_t address) { - // reset TWI control register - TWCR = 0; - - // begin transmission and wait for it to end - TWCR = (1< - -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 . -*/ - -// Please do not modify this file - -#pragma once - -void i2c_init(void); -void i2c_set_bitrate(uint16_t bitrate_khz); -uint8_t i2c_send(uint8_t address, uint8_t *data, uint16_t length); - diff --git a/keyboards/winkeyless/bminiex/rules.mk b/keyboards/winkeyless/bminiex/rules.mk index 24e4348795f..39a77bda127 100644 --- a/keyboards/winkeyless/bminiex/rules.mk +++ b/keyboards/winkeyless/bminiex/rules.mk @@ -1,18 +1,3 @@ -# Copyright 2017 Luiz Ribeiro -# -# 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 . - # MCU name MCU = atmega32a @@ -36,7 +21,7 @@ COMMAND_ENABLE = no BACKLIGHT_ENABLE = yes BACKLIGHT_CUSTOM_DRIVER = yes RGBLIGHT_ENABLE = yes -RGBLIGHT_CUSTOM_DRIVER = yes +WS2812_DRIVER = i2c TAP_DANCE_ENABLE = no # Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE @@ -46,4 +31,4 @@ OPT_DEFS = -DDEBUG_LEVEL=0 # custom matrix setup CUSTOM_MATRIX = yes -SRC = matrix.c i2c.c backlight.c +SRC = matrix.c backlight.c diff --git a/keyboards/ymd75/i2c.c b/keyboards/ymd75/i2c.c deleted file mode 100644 index c27f3e3d17e..00000000000 --- a/keyboards/ymd75/i2c.c +++ /dev/null @@ -1,104 +0,0 @@ -/* -Copyright 2016 Luiz Ribeiro - -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 . -*/ - -#include -#include - -#include "i2c.h" - -void i2c_set_bitrate(uint16_t bitrate_khz) { - uint8_t bitrate_div = ((F_CPU / 1000l) / bitrate_khz); - if (bitrate_div >= 16) { - bitrate_div = (bitrate_div - 16) / 2; - } - TWBR = bitrate_div; -} - -void i2c_init(void) { - // set pull-up resistors on I2C bus pins - PORTC |= 0b11; - - i2c_set_bitrate(400); - - // enable TWI (two-wire interface) - TWCR |= (1 << TWEN); - - // enable TWI interrupt and slave address ACK - TWCR |= (1 << TWIE); - TWCR |= (1 << TWEA); -} - -uint8_t i2c_start(uint8_t address) { - // reset TWI control register - TWCR = 0; - - // begin transmission and wait for it to end - TWCR = (1< - -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 . -*/ - -#ifndef __I2C_H__ -#define __I2C_H__ - -void i2c_init(void); -void i2c_set_bitrate(uint16_t bitrate_khz); -uint8_t i2c_send(uint8_t address, uint8_t *data, uint16_t length); - -#endif diff --git a/keyboards/ymd75/rules.mk b/keyboards/ymd75/rules.mk index 7bee201738a..0c1c9110ca8 100644 --- a/keyboards/ymd75/rules.mk +++ b/keyboards/ymd75/rules.mk @@ -1,19 +1,3 @@ -# Copyright 2017 Luiz Ribeiro -# Modified 2018 Wayne Jones (WarmCatUK) - -# 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 . - # MCU name MCU = atmega32a @@ -35,7 +19,7 @@ CONSOLE_ENABLE = no COMMAND_ENABLE = yes BACKLIGHT_ENABLE = yes RGBLIGHT_ENABLE = yes -RGBLIGHT_CUSTOM_DRIVER = yes +WS2812_DRIVER = i2c NKRO_ENABLE = no # Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work @@ -51,4 +35,4 @@ SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend # custom matrix setup CUSTOM_MATRIX = yes -SRC = matrix.c i2c.c backlight.c +SRC = matrix.c backlight.c diff --git a/keyboards/ymd75/ymd75.c b/keyboards/ymd75/ymd75.c index 2259dfa5f04..74f7c6a493d 100644 --- a/keyboards/ymd75/ymd75.c +++ b/keyboards/ymd75/ymd75.c @@ -16,23 +16,19 @@ along with this program. If not, see . */ #include "ymd75.h" -//#include "rgblight.h" - -#include - -#include "action_layer.h" -#include "i2c.h" -#include "quantum.h" #include "backlight.h" #include "backlight_custom.h" -// for keyboard subdirectory level init functions -// @Override -void matrix_init_kb(void) { - // call user level keymaps, if any - matrix_init_user(); -} +void matrix_init_kb(void) { matrix_init_user(); } + +__attribute__ ((weak)) +void matrix_init_user(void) {} + +void matrix_scan_kb(void) { matrix_scan_user(); } + +__attribute__ ((weak)) +void matrix_scan_user(void) {} #ifdef BACKLIGHT_ENABLE /// Overrides functions in `quantum.c` @@ -48,48 +44,3 @@ void backlight_set(uint8_t level) { b_led_set(level); } #endif - -#ifdef RGBLIGHT_ENABLE -extern rgblight_config_t rgblight_config; - -// custom RGB driver -void rgblight_set(void) { - if (!rgblight_config.enable) { - for (uint8_t i=0; i - -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 . -*/ - -#include -#include - -#include "i2c.h" - -void i2c_set_bitrate(uint16_t bitrate_khz) { - uint8_t bitrate_div = ((F_CPU / 1000l) / bitrate_khz); - if (bitrate_div >= 16) { - bitrate_div = (bitrate_div - 16) / 2; - } - TWBR = bitrate_div; -} - -void i2c_init(void) { - // set pull-up resistors on I2C bus pins - PORTC |= 0b11; - - i2c_set_bitrate(400); - - // enable TWI (two-wire interface) - TWCR |= (1 << TWEN); - - // enable TWI interrupt and slave address ACK - TWCR |= (1 << TWIE); - TWCR |= (1 << TWEA); -} - -uint8_t i2c_start(uint8_t address) { - // reset TWI control register - TWCR = 0; - - // begin transmission and wait for it to end - TWCR = (1< - -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 . -*/ - -#ifndef __I2C_H__ -#define __I2C_H__ - -void i2c_init(void); -void i2c_set_bitrate(uint16_t bitrate_khz); -uint8_t i2c_send(uint8_t address, uint8_t *data, uint16_t length); - -#endif diff --git a/keyboards/ymd96/rules.mk b/keyboards/ymd96/rules.mk index 96441e1b3f3..19d9fd81abb 100644 --- a/keyboards/ymd96/rules.mk +++ b/keyboards/ymd96/rules.mk @@ -1,18 +1,3 @@ -# Copyright 2017 Luiz Ribeiro -# -# 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 . - # MCU name MCU = atmega32a @@ -37,7 +22,7 @@ BACKLIGHT_ENABLE = yes BACKLIGHT_CUSTOM_DRIVER = yes RGBLIGHT_ENABLE = yes -RGBLIGHT_CUSTOM_DRIVER = yes +WS2812_DRIVER = i2c KEY_LOCK_ENABLE = yes @@ -48,4 +33,4 @@ OPT_DEFS = -DDEBUG_LEVEL=0 # custom matrix setup CUSTOM_MATRIX = yes -SRC = matrix.c i2c.c backlight.c +SRC = matrix.c backlight.c diff --git a/keyboards/ymd96/ymd96.c b/keyboards/ymd96/ymd96.c index b0bf6128fae..546a4c6e3af 100644 --- a/keyboards/ymd96/ymd96.c +++ b/keyboards/ymd96/ymd96.c @@ -18,22 +18,18 @@ along with this program. If not, see . #include "ymd96.h" -#include +#include "backlight.h" +#include "backlight_custom.h" -#include "action_layer.h" -#include "quantum.h" +void matrix_init_kb(void) { matrix_init_user(); } -#include "i2c.h" +__attribute__ ((weak)) +void matrix_init_user(void) {} -#include "backlight.h" -#include "backlight_custom.h" +void matrix_scan_kb(void) { matrix_scan_user(); } -// for keyboard subdirectory level init functions -// @Override -void matrix_init_kb(void) { - // call user level keymaps, if any - matrix_init_user(); -} +__attribute__ ((weak)) +void matrix_scan_user(void) {} #ifdef BACKLIGHT_ENABLE /// Overrides functions in `quantum.c` @@ -49,49 +45,3 @@ void backlight_set(uint8_t level) { b_led_set(level); } #endif - -#ifdef RGBLIGHT_ENABLE -extern rgblight_config_t rgblight_config; - -// custom RGB driver -void rgblight_set(void) { - if (!rgblight_config.enable) { - for (uint8_t i=0; i - -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 . -*/ - -#include -#include - -#include "i2c.h" - -void i2c_set_bitrate(uint16_t bitrate_khz) { - uint8_t bitrate_div = ((F_CPU / 1000l) / bitrate_khz); - if (bitrate_div >= 16) { - bitrate_div = (bitrate_div - 16) / 2; - } - TWBR = bitrate_div; -} - -void i2c_init(void) { - // set pull-up resistors on I2C bus pins - PORTC |= 0b11; - - i2c_set_bitrate(400); - - // enable TWI (two-wire interface) - TWCR |= (1 << TWEN); - - // enable TWI interrupt and slave address ACK - TWCR |= (1 << TWIE); - TWCR |= (1 << TWEA); -} - -uint8_t i2c_start(uint8_t address) { - // reset TWI control register - TWCR = 0; - - // begin transmission and wait for it to end - TWCR = (1< - -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 . -*/ - -#ifndef __I2C_H__ -#define __I2C_H__ - -void i2c_init(void); -void i2c_set_bitrate(uint16_t bitrate_khz); -uint8_t i2c_send(uint8_t address, uint8_t *data, uint16_t length); - -#endif diff --git a/keyboards/ymdk_np21/rules.mk b/keyboards/ymdk_np21/rules.mk index 634b9c69c4b..2bab3043e87 100644 --- a/keyboards/ymdk_np21/rules.mk +++ b/keyboards/ymdk_np21/rules.mk @@ -1,18 +1,3 @@ -# Copyright 2017 Luiz Ribeiro -# -# 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 . - # MCU name MCU = atmega32a @@ -37,8 +22,7 @@ BACKLIGHT_ENABLE = yes BACKLIGHT_CUSTOM_DRIVER = yes RGBLIGHT_ENABLE = yes -RGBLIGHT_CUSTOM_DRIVER = yes -# DISABLE_WS2812 = no +WS2812_DRIVER = i2c KEY_LOCK_ENABLE = yes @@ -49,4 +33,4 @@ OPT_DEFS = -DDEBUG_LEVEL=0 # custom matrix setup CUSTOM_MATRIX = yes -SRC = matrix.c i2c.c backlight.c +SRC = matrix.c backlight.c diff --git a/keyboards/ymdk_np21/ymdk_np21.c b/keyboards/ymdk_np21/ymdk_np21.c index c1b11b4046f..f2b3d46dabd 100644 --- a/keyboards/ymdk_np21/ymdk_np21.c +++ b/keyboards/ymdk_np21/ymdk_np21.c @@ -18,25 +18,9 @@ along with this program. If not, see . #include "ymdk_np21.h" -#include - -#include "action_layer.h" -#include "quantum.h" - -#include "i2c.h" - #include "backlight.h" #include "backlight_custom.h" -extern rgblight_config_t rgblight_config; - -// for keyboard subdirectory level init functions -// @Override -void matrix_init_kb(void) { - // call user level keymaps, if any - matrix_init_user(); -} - #ifdef BACKLIGHT_ENABLE /// Overrides functions in `quantum.c` void backlight_init_ports(void) { @@ -51,32 +35,3 @@ void backlight_set(uint8_t level) { b_led_set(level); } #endif - -// custom RGB driver -void rgblight_set(void) { - if (!rgblight_config.enable) { - for (uint8_t i=0; i