]> git.donarmstrong.com Git - qmk_firmware.git/commitdiff
Convert remaining PS2AVRGB boards to I2C WS2812 driver (#7245)
authorfauxpark <fauxpark@gmail.com>
Sun, 3 Nov 2019 22:43:13 +0000 (09:43 +1100)
committerDrashna Jaelre <drashna@live.com>
Sun, 3 Nov 2019 22:43:13 +0000 (14:43 -0800)
* Convert remaining PS2AVRGB boards to I2C WS2812 driver

* Add back functions to make the custom matrices happy

52 files changed:
keyboards/bfake/bfake.c
keyboards/bfake/i2c.c [deleted file]
keyboards/bfake/i2c.h [deleted file]
keyboards/bfake/rules.mk
keyboards/jc65/v32a/i2c.c [deleted file]
keyboards/jc65/v32a/i2c.h [deleted file]
keyboards/jc65/v32a/rules.mk
keyboards/jc65/v32a/v32a.c
keyboards/jj50/i2c.c [deleted file]
keyboards/jj50/i2c.h [deleted file]
keyboards/jj50/jj50.c
keyboards/jj50/rules.mk
keyboards/mechmini/v1/i2c.c [deleted file]
keyboards/mechmini/v1/i2c.h [deleted file]
keyboards/mechmini/v1/rules.mk
keyboards/mechmini/v1/v1.c
keyboards/mehkee96/i2c.c [deleted file]
keyboards/mehkee96/i2c.h [deleted file]
keyboards/mehkee96/mehkee96.c
keyboards/mehkee96/rules.mk
keyboards/mt40/i2c.c [deleted file]
keyboards/mt40/i2c.h [deleted file]
keyboards/mt40/mt40.c
keyboards/mt40/rules.mk
keyboards/percent/canoe/canoe.c
keyboards/percent/canoe/i2c.c [deleted file]
keyboards/percent/canoe/i2c.h [deleted file]
keyboards/percent/canoe/rules.mk
keyboards/percent/skog/i2c.c [deleted file]
keyboards/percent/skog/i2c.h [deleted file]
keyboards/percent/skog/rules.mk
keyboards/percent/skog/skog.c
keyboards/winkeyless/bmini/bmini.c
keyboards/winkeyless/bmini/i2c.c [deleted file]
keyboards/winkeyless/bmini/i2c.h [deleted file]
keyboards/winkeyless/bmini/rules.mk
keyboards/winkeyless/bminiex/bminiex.c
keyboards/winkeyless/bminiex/i2c.c [deleted file]
keyboards/winkeyless/bminiex/i2c.h [deleted file]
keyboards/winkeyless/bminiex/rules.mk
keyboards/ymd75/i2c.c [deleted file]
keyboards/ymd75/i2c.h [deleted file]
keyboards/ymd75/rules.mk
keyboards/ymd75/ymd75.c
keyboards/ymd96/i2c.c [deleted file]
keyboards/ymd96/i2c.h [deleted file]
keyboards/ymd96/rules.mk
keyboards/ymd96/ymd96.c
keyboards/ymdk_np21/i2c.c [deleted file]
keyboards/ymdk_np21/i2c.h [deleted file]
keyboards/ymdk_np21/rules.mk
keyboards/ymdk_np21/ymdk_np21.c

index 2160706fea56ee4946670412dea4d9f486625691..f7d006576c72d882a87415719e856299e7aef06a 100644 (file)
@@ -16,51 +16,34 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
 #include "bfake.h"
-#ifdef BACKLIGHT_ENABLE
-#include "backlight.h"
-#endif
-#ifdef RGBLIGHT_ENABLE
-#include "rgblight.h"
-#endif
-
-#include <avr/pgmspace.h>
-
-#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 (file)
index a4f9521..0000000
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
-Copyright 2016 Luiz Ribeiro <luizribeiro@gmail.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/>.
-*/
-
-// Please do not modify this file 
-
-#include <avr/io.h>
-#include <util/twi.h>
-
-#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<<TWINT) | (1<<TWSTA) | (1<<TWEN);
-    while (!(TWCR & (1<<TWINT)));
-
-    // check if the start condition was successfully transmitted
-    if ((TWSR & 0xF8) != TW_START) {
-        return 1;
-    }
-
-    // transmit address and wait
-    TWDR = address;
-    TWCR = (1<<TWINT) | (1<<TWEN);
-    while (!(TWCR & (1<<TWINT)));
-
-    // check if the device has acknowledged the READ / WRITE mode
-    uint8_t twst = TW_STATUS & 0xF8;
-    if ((twst != TW_MT_SLA_ACK) && (twst != TW_MR_SLA_ACK)) {
-        return 1;
-    }
-
-    return 0;
-}
-
-void i2c_stop(void) {
-    TWCR = (1<<TWINT) | (1<<TWEN) | (1<<TWSTO);
-}
-
-uint8_t i2c_write(uint8_t data) {
-    TWDR = data;
-
-    // transmit data and wait
-    TWCR = (1<<TWINT) | (1<<TWEN);
-    while (!(TWCR & (1<<TWINT)));
-
-    if ((TWSR & 0xF8) != TW_MT_DATA_ACK) {
-        return 1;
-    }
-
-    return 0;
-}
-
-uint8_t i2c_send(uint8_t address, uint8_t *data, uint16_t length) {
-    if (i2c_start(address)) {
-        return 1;
-    }
-
-    for (uint16_t i = 0; i < length; i++) {
-        if (i2c_write(data[i])) {
-            return 1;
-        }
-    }
-
-    i2c_stop();
-
-    return 0;
-}
diff --git a/keyboards/bfake/i2c.h b/keyboards/bfake/i2c.h
deleted file mode 100644 (file)
index 93a69c9..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
-Copyright 2016 Luiz Ribeiro <luizribeiro@gmail.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/>.
-*/
-
-// 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
index b5b3b852cb0531df54172b8878b7bc657949ea16..5963c9810a02daa145738a504f04ebf4216acdda 100644 (file)
@@ -1,18 +1,3 @@
-# Copyright 2017 Luiz Ribeiro <luizribeiro@gmail.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/>.
-
 # 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 (file)
index a4f9521..0000000
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
-Copyright 2016 Luiz Ribeiro <luizribeiro@gmail.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/>.
-*/
-
-// Please do not modify this file 
-
-#include <avr/io.h>
-#include <util/twi.h>
-
-#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<<TWINT) | (1<<TWSTA) | (1<<TWEN);
-    while (!(TWCR & (1<<TWINT)));
-
-    // check if the start condition was successfully transmitted
-    if ((TWSR & 0xF8) != TW_START) {
-        return 1;
-    }
-
-    // transmit address and wait
-    TWDR = address;
-    TWCR = (1<<TWINT) | (1<<TWEN);
-    while (!(TWCR & (1<<TWINT)));
-
-    // check if the device has acknowledged the READ / WRITE mode
-    uint8_t twst = TW_STATUS & 0xF8;
-    if ((twst != TW_MT_SLA_ACK) && (twst != TW_MR_SLA_ACK)) {
-        return 1;
-    }
-
-    return 0;
-}
-
-void i2c_stop(void) {
-    TWCR = (1<<TWINT) | (1<<TWEN) | (1<<TWSTO);
-}
-
-uint8_t i2c_write(uint8_t data) {
-    TWDR = data;
-
-    // transmit data and wait
-    TWCR = (1<<TWINT) | (1<<TWEN);
-    while (!(TWCR & (1<<TWINT)));
-
-    if ((TWSR & 0xF8) != TW_MT_DATA_ACK) {
-        return 1;
-    }
-
-    return 0;
-}
-
-uint8_t i2c_send(uint8_t address, uint8_t *data, uint16_t length) {
-    if (i2c_start(address)) {
-        return 1;
-    }
-
-    for (uint16_t i = 0; i < length; i++) {
-        if (i2c_write(data[i])) {
-            return 1;
-        }
-    }
-
-    i2c_stop();
-
-    return 0;
-}
diff --git a/keyboards/jc65/v32a/i2c.h b/keyboards/jc65/v32a/i2c.h
deleted file mode 100644 (file)
index 93a69c9..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
-Copyright 2016 Luiz Ribeiro <luizribeiro@gmail.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/>.
-*/
-
-// 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
index ee6efb3fa53ff10006b30ff1a5a41335483bfd88..18e7f1de9dc70b4eda269ed74b327c044cd5cd14 100644 (file)
@@ -1,18 +1,3 @@
-# Copyright 2017 Luiz Ribeiro <luizribeiro@gmail.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/>.
-
 # 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
index 8176ade0a1c599894af5b6aa0030e057d31771be..9b1e07274c514db4ed118fe56e34cce5ff71563c 100644 (file)
@@ -16,56 +16,36 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
 #include "v32a.h"
-#ifdef BACKLIGHT_ENABLE
-#include "backlight.h"
-#endif
-#ifdef RGBLIGHT_ENABLE
-#include "rgblight.h"
-#endif
-
-#include <avr/pgmspace.h>
-
-#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 (file)
index c27f3e3..0000000
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
-Copyright 2016 Luiz Ribeiro <luizribeiro@gmail.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 <avr/io.h>
-#include <util/twi.h>
-
-#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<<TWINT) | (1<<TWSTA) | (1<<TWEN);
-    while (!(TWCR & (1<<TWINT)));
-
-    // check if the start condition was successfully transmitted
-    if ((TWSR & 0xF8) != TW_START) {
-        return 1;
-    }
-
-    // transmit address and wait
-    TWDR = address;
-    TWCR = (1<<TWINT) | (1<<TWEN);
-    while (!(TWCR & (1<<TWINT)));
-
-    // check if the device has acknowledged the READ / WRITE mode
-    uint8_t twst = TW_STATUS & 0xF8;
-    if ((twst != TW_MT_SLA_ACK) && (twst != TW_MR_SLA_ACK)) {
-        return 1;
-    }
-
-    return 0;
-}
-
-void i2c_stop(void) {
-    TWCR = (1<<TWINT) | (1<<TWEN) | (1<<TWSTO);
-}
-
-uint8_t i2c_write(uint8_t data) {
-    TWDR = data;
-
-    // transmit data and wait
-    TWCR = (1<<TWINT) | (1<<TWEN);
-    while (!(TWCR & (1<<TWINT)));
-
-    if ((TWSR & 0xF8) != TW_MT_DATA_ACK) {
-        return 1;
-    }
-
-    return 0;
-}
-
-uint8_t i2c_send(uint8_t address, uint8_t *data, uint16_t length) {
-    if (i2c_start(address)) {
-        return 1;
-    }
-
-    for (uint16_t i = 0; i < length; i++) {
-        if (i2c_write(data[i])) {
-            return 1;
-        }
-    }
-
-    i2c_stop();
-
-    return 0;
-}
diff --git a/keyboards/jj50/i2c.h b/keyboards/jj50/i2c.h
deleted file mode 100644 (file)
index 27c9d3d..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
-Copyright 2016 Luiz Ribeiro <luizribeiro@gmail.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/>.
-*/
-
-#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
index d4a70f68d0dd3fd68d5021657222d6c58f3b41d1..7c3cee95d186c12ed9d44578612cc72b485201f8 100644 (file)
@@ -17,24 +17,20 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 #include "jj50.h"
 
-#include <avr/pgmspace.h>
-
-#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<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);
-}
-
-bool rgb_init = false;
-
-void matrix_scan_kb(void) {
-    // if LEDs were previously on before poweroff, turn them back on
-    if (rgb_init == false && rgblight_config.enable) {
-        i2c_init();
-        i2c_send(0xb0, (uint8_t*)led, 3 * RGBLED_NUM);
-        rgb_init = true;
-    }
-    
-    rgblight_task();
-#else
-    void matrix_scan_kb(void) {
-#endif
-        matrix_scan_user();
-        /* Nothing else for now. */
-    }
-    
-    __attribute__((weak)) // overridable
-    void matrix_init_user(void) {
-        
-    }
-    
-    __attribute__((weak)) // overridable
-    void matrix_scan_user(void) {
-        
-    }
index b23b4becd4023f8fa8a52d3a541ad1fd446b6986..40473e6ecc43bfebca4e5e8399ff2c79bdf09324 100644 (file)
@@ -1,19 +1,3 @@
-# Copyright 2017 Luiz Ribeiro <luizribeiro@gmail.com>
-# Modified 2018 Wayne Jones (WarmCatUK) <waynekjones@gmail.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/>.
-
 # 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 (file)
index c27f3e3..0000000
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
-Copyright 2016 Luiz Ribeiro <luizribeiro@gmail.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 <avr/io.h>
-#include <util/twi.h>
-
-#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<<TWINT) | (1<<TWSTA) | (1<<TWEN);
-    while (!(TWCR & (1<<TWINT)));
-
-    // check if the start condition was successfully transmitted
-    if ((TWSR & 0xF8) != TW_START) {
-        return 1;
-    }
-
-    // transmit address and wait
-    TWDR = address;
-    TWCR = (1<<TWINT) | (1<<TWEN);
-    while (!(TWCR & (1<<TWINT)));
-
-    // check if the device has acknowledged the READ / WRITE mode
-    uint8_t twst = TW_STATUS & 0xF8;
-    if ((twst != TW_MT_SLA_ACK) && (twst != TW_MR_SLA_ACK)) {
-        return 1;
-    }
-
-    return 0;
-}
-
-void i2c_stop(void) {
-    TWCR = (1<<TWINT) | (1<<TWEN) | (1<<TWSTO);
-}
-
-uint8_t i2c_write(uint8_t data) {
-    TWDR = data;
-
-    // transmit data and wait
-    TWCR = (1<<TWINT) | (1<<TWEN);
-    while (!(TWCR & (1<<TWINT)));
-
-    if ((TWSR & 0xF8) != TW_MT_DATA_ACK) {
-        return 1;
-    }
-
-    return 0;
-}
-
-uint8_t i2c_send(uint8_t address, uint8_t *data, uint16_t length) {
-    if (i2c_start(address)) {
-        return 1;
-    }
-
-    for (uint16_t i = 0; i < length; i++) {
-        if (i2c_write(data[i])) {
-            return 1;
-        }
-    }
-
-    i2c_stop();
-
-    return 0;
-}
diff --git a/keyboards/mechmini/v1/i2c.h b/keyboards/mechmini/v1/i2c.h
deleted file mode 100644 (file)
index 194a82c..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
-Copyright 2016 Luiz Ribeiro <luizribeiro@gmail.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/>.
-*/
-
-#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
index 3510ca6f3f1c0b78ea0a0798e08a86178d1d7957..ee023b43bae4e6d0711a380cd97d7153e3f34719 100644 (file)
@@ -1,18 +1,3 @@
-# Copyright 2017 Luiz Ribeiro <luizribeiro@gmail.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/>.
-
 # 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
index 508d60c784dbdf00b6e4e427007b6b35fb561577..2c910d9658ca03dfe9a3c96fed1321f5fc07082c 100644 (file)
@@ -16,61 +16,13 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
 #include "v1.h"
-#include <avr/pgmspace.h>
-#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<RGBLED_NUM; i++) {
-      led[i].r = 0;
-      led[i].g = 0;
-      led[i].b = 0;
-    }
-  }
+void matrix_scan_kb(void) { matrix_scan_user(); }
 
-  i2c_init();
-  i2c_send(0xb0, (uint8_t*)led, 3 * RGBLED_NUM);
-}
-
-bool rgb_init = false;
-
-void matrix_scan_kb(void) {
-  // if LEDs were previously on before poweroff, turn them back on
-  if (rgb_init == false && rgblight_config.enable) {
-    i2c_init();
-    i2c_send(0xb0, (uint8_t*)led, 3 * RGBLED_NUM);
-    rgb_init = true;
-  }
-
-  rgblight_task();
-#else
-void matrix_scan_kb(void) {
-#endif
-  matrix_scan_user();
-  /* Nothing else for now. */
-}
-
-__attribute__((weak)) // overridable
-void matrix_init_user(void) {
-
-}
-
-
-__attribute__((weak)) // overridable
-void matrix_scan_user(void) {
-
-}
+__attribute__ ((weak))
+void matrix_scan_user(void) {}
diff --git a/keyboards/mehkee96/i2c.c b/keyboards/mehkee96/i2c.c
deleted file mode 100644 (file)
index a4f9521..0000000
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
-Copyright 2016 Luiz Ribeiro <luizribeiro@gmail.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/>.
-*/
-
-// Please do not modify this file 
-
-#include <avr/io.h>
-#include <util/twi.h>
-
-#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<<TWINT) | (1<<TWSTA) | (1<<TWEN);
-    while (!(TWCR & (1<<TWINT)));
-
-    // check if the start condition was successfully transmitted
-    if ((TWSR & 0xF8) != TW_START) {
-        return 1;
-    }
-
-    // transmit address and wait
-    TWDR = address;
-    TWCR = (1<<TWINT) | (1<<TWEN);
-    while (!(TWCR & (1<<TWINT)));
-
-    // check if the device has acknowledged the READ / WRITE mode
-    uint8_t twst = TW_STATUS & 0xF8;
-    if ((twst != TW_MT_SLA_ACK) && (twst != TW_MR_SLA_ACK)) {
-        return 1;
-    }
-
-    return 0;
-}
-
-void i2c_stop(void) {
-    TWCR = (1<<TWINT) | (1<<TWEN) | (1<<TWSTO);
-}
-
-uint8_t i2c_write(uint8_t data) {
-    TWDR = data;
-
-    // transmit data and wait
-    TWCR = (1<<TWINT) | (1<<TWEN);
-    while (!(TWCR & (1<<TWINT)));
-
-    if ((TWSR & 0xF8) != TW_MT_DATA_ACK) {
-        return 1;
-    }
-
-    return 0;
-}
-
-uint8_t i2c_send(uint8_t address, uint8_t *data, uint16_t length) {
-    if (i2c_start(address)) {
-        return 1;
-    }
-
-    for (uint16_t i = 0; i < length; i++) {
-        if (i2c_write(data[i])) {
-            return 1;
-        }
-    }
-
-    i2c_stop();
-
-    return 0;
-}
diff --git a/keyboards/mehkee96/i2c.h b/keyboards/mehkee96/i2c.h
deleted file mode 100644 (file)
index 7ce50cd..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
-Copyright 2016 Luiz Ribeiro <luizribeiro@gmail.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/>.
-*/
-
-// 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
index 604fad8032c691d92ee0468fc113d12a5d2bcc32..46427ec93bfc023dbfa625531b59ca330084e2c2 100644 (file)
@@ -16,66 +16,13 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
 #include "mehkee96.h"
-#include "rgblight.h"
 
-#include <avr/pgmspace.h>
+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<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);
-}
-
-bool rgb_init = false;
-
-void matrix_scan_kb(void) {
-  // if LEDs were previously on before poweroff, turn them back on
-  if (rgb_init == false && rgblight_config.enable) {
-    i2c_init();
-    i2c_send(0xb0, (uint8_t*)led, 3 * RGBLED_NUM);
-    rgb_init = true;
-  }
-
-#ifdef RGBLIGHT_ANIMATION
-  rgblight_task();
-#endif
-
-#else
-void matrix_scan_kb(void) {
-#endif
-  matrix_scan_user();
-  /* Nothing else for now. */
-}
-
-__attribute__((weak)) // overridable
-void matrix_init_user(void) {
-
-}
-
-
-__attribute__((weak)) // overridable
-void matrix_scan_user(void) {
-
-}
+__attribute__ ((weak))
+void matrix_scan_user(void) {}
index 244dd2141e764e03f303c46263e56ec482ec0c68..1cbd02948f881d2bdb3fc8c0b3f588b32206b149 100644 (file)
@@ -21,10 +21,10 @@ CONSOLE_ENABLE = yes        # Console for debug(+400)
 COMMAND_ENABLE = yes    # Commands for debug and configuration
 BACKLIGHT_ENABLE = no  # Enable keyboard backlight functionality
 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/mt40/i2c.c b/keyboards/mt40/i2c.c
deleted file mode 100644 (file)
index c27f3e3..0000000
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
-Copyright 2016 Luiz Ribeiro <luizribeiro@gmail.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 <avr/io.h>
-#include <util/twi.h>
-
-#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<<TWINT) | (1<<TWSTA) | (1<<TWEN);
-    while (!(TWCR & (1<<TWINT)));
-
-    // check if the start condition was successfully transmitted
-    if ((TWSR & 0xF8) != TW_START) {
-        return 1;
-    }
-
-    // transmit address and wait
-    TWDR = address;
-    TWCR = (1<<TWINT) | (1<<TWEN);
-    while (!(TWCR & (1<<TWINT)));
-
-    // check if the device has acknowledged the READ / WRITE mode
-    uint8_t twst = TW_STATUS & 0xF8;
-    if ((twst != TW_MT_SLA_ACK) && (twst != TW_MR_SLA_ACK)) {
-        return 1;
-    }
-
-    return 0;
-}
-
-void i2c_stop(void) {
-    TWCR = (1<<TWINT) | (1<<TWEN) | (1<<TWSTO);
-}
-
-uint8_t i2c_write(uint8_t data) {
-    TWDR = data;
-
-    // transmit data and wait
-    TWCR = (1<<TWINT) | (1<<TWEN);
-    while (!(TWCR & (1<<TWINT)));
-
-    if ((TWSR & 0xF8) != TW_MT_DATA_ACK) {
-        return 1;
-    }
-
-    return 0;
-}
-
-uint8_t i2c_send(uint8_t address, uint8_t *data, uint16_t length) {
-    if (i2c_start(address)) {
-        return 1;
-    }
-
-    for (uint16_t i = 0; i < length; i++) {
-        if (i2c_write(data[i])) {
-            return 1;
-        }
-    }
-
-    i2c_stop();
-
-    return 0;
-}
diff --git a/keyboards/mt40/i2c.h b/keyboards/mt40/i2c.h
deleted file mode 100644 (file)
index 27c9d3d..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
-Copyright 2016 Luiz Ribeiro <luizribeiro@gmail.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/>.
-*/
-
-#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
index 555689f8729c7f1947be27226a89594957ea78d1..dd079e7d813eff1055c3ecee9c1aa2f3896fb5a7 100644 (file)
  * 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 "mt40.h"
-#include "rgblight.h"
-
-#include <avr/pgmspace.h>
-
-#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"
index 19410bc6e020cf06f7400918b3dcb5143c4c3a77..0cbf90c674b26b49b78783f4521bd2a06e76895e 100644 (file)
@@ -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
index a7427e15286c42aa867b486016ede10484a017fb..e59b0dd7bcc0e59f7b617e2d84bb035bda7e2359 100644 (file)
@@ -16,81 +16,43 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
 #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<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);
+       setPinOutput(D0);
+       setPinOutput(D1);
+       setPinOutput(D4);
+       setPinOutput(D6);
+
+       writePinLow(D0);
+       writePinLow(D1);
+       writePinLow(D4);
+       writePinLow(D6);
 }
-
-bool rgb_init = false;
-
-void matrix_scan_kb(void) {
-  // if LEDs were previously on before poweroff, turn them back on
-  if (rgb_init == false && rgblight_config.enable) {
-    i2c_init();
-    i2c_send(0xb0, (uint8_t*)led, 3 * RGBLED_NUM);
-    rgb_init = true;
-  }
-
-  rgblight_task();
-#else
-void matrix_scan_kb(void) {
 #endif
-  matrix_scan_user();
-  /* Nothing else for now. */
-}
-
-__attribute__((weak)) // overridable
-void matrix_init_user(void) {
-
-}
-
-
-__attribute__((weak)) // overridable
-void matrix_scan_user(void) {
-
-}
diff --git a/keyboards/percent/canoe/i2c.c b/keyboards/percent/canoe/i2c.c
deleted file mode 100644 (file)
index a4f9521..0000000
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
-Copyright 2016 Luiz Ribeiro <luizribeiro@gmail.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/>.
-*/
-
-// Please do not modify this file 
-
-#include <avr/io.h>
-#include <util/twi.h>
-
-#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<<TWINT) | (1<<TWSTA) | (1<<TWEN);
-    while (!(TWCR & (1<<TWINT)));
-
-    // check if the start condition was successfully transmitted
-    if ((TWSR & 0xF8) != TW_START) {
-        return 1;
-    }
-
-    // transmit address and wait
-    TWDR = address;
-    TWCR = (1<<TWINT) | (1<<TWEN);
-    while (!(TWCR & (1<<TWINT)));
-
-    // check if the device has acknowledged the READ / WRITE mode
-    uint8_t twst = TW_STATUS & 0xF8;
-    if ((twst != TW_MT_SLA_ACK) && (twst != TW_MR_SLA_ACK)) {
-        return 1;
-    }
-
-    return 0;
-}
-
-void i2c_stop(void) {
-    TWCR = (1<<TWINT) | (1<<TWEN) | (1<<TWSTO);
-}
-
-uint8_t i2c_write(uint8_t data) {
-    TWDR = data;
-
-    // transmit data and wait
-    TWCR = (1<<TWINT) | (1<<TWEN);
-    while (!(TWCR & (1<<TWINT)));
-
-    if ((TWSR & 0xF8) != TW_MT_DATA_ACK) {
-        return 1;
-    }
-
-    return 0;
-}
-
-uint8_t i2c_send(uint8_t address, uint8_t *data, uint16_t length) {
-    if (i2c_start(address)) {
-        return 1;
-    }
-
-    for (uint16_t i = 0; i < length; i++) {
-        if (i2c_write(data[i])) {
-            return 1;
-        }
-    }
-
-    i2c_stop();
-
-    return 0;
-}
diff --git a/keyboards/percent/canoe/i2c.h b/keyboards/percent/canoe/i2c.h
deleted file mode 100644 (file)
index 93a69c9..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
-Copyright 2016 Luiz Ribeiro <luizribeiro@gmail.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/>.
-*/
-
-// 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
index e3269b94db81d06f25a4fdb57a1363b61d4b4542..bb14269a2b28e3e5fd7ec1997d71a91fd09b1486 100644 (file)
@@ -1,18 +1,3 @@
-# Copyright 2017 Luiz Ribeiro <luizribeiro@gmail.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/>.
-
 # 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 (file)
index a4f9521..0000000
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
-Copyright 2016 Luiz Ribeiro <luizribeiro@gmail.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/>.
-*/
-
-// Please do not modify this file 
-
-#include <avr/io.h>
-#include <util/twi.h>
-
-#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<<TWINT) | (1<<TWSTA) | (1<<TWEN);
-    while (!(TWCR & (1<<TWINT)));
-
-    // check if the start condition was successfully transmitted
-    if ((TWSR & 0xF8) != TW_START) {
-        return 1;
-    }
-
-    // transmit address and wait
-    TWDR = address;
-    TWCR = (1<<TWINT) | (1<<TWEN);
-    while (!(TWCR & (1<<TWINT)));
-
-    // check if the device has acknowledged the READ / WRITE mode
-    uint8_t twst = TW_STATUS & 0xF8;
-    if ((twst != TW_MT_SLA_ACK) && (twst != TW_MR_SLA_ACK)) {
-        return 1;
-    }
-
-    return 0;
-}
-
-void i2c_stop(void) {
-    TWCR = (1<<TWINT) | (1<<TWEN) | (1<<TWSTO);
-}
-
-uint8_t i2c_write(uint8_t data) {
-    TWDR = data;
-
-    // transmit data and wait
-    TWCR = (1<<TWINT) | (1<<TWEN);
-    while (!(TWCR & (1<<TWINT)));
-
-    if ((TWSR & 0xF8) != TW_MT_DATA_ACK) {
-        return 1;
-    }
-
-    return 0;
-}
-
-uint8_t i2c_send(uint8_t address, uint8_t *data, uint16_t length) {
-    if (i2c_start(address)) {
-        return 1;
-    }
-
-    for (uint16_t i = 0; i < length; i++) {
-        if (i2c_write(data[i])) {
-            return 1;
-        }
-    }
-
-    i2c_stop();
-
-    return 0;
-}
diff --git a/keyboards/percent/skog/i2c.h b/keyboards/percent/skog/i2c.h
deleted file mode 100644 (file)
index ada8cc7..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
-Copyright 2016 Luiz Ribeiro <luizribeiro@gmail.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/>.
-*/
-
-// 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);
-
index b8439906b8b30447a1ab9aeb43afe64cf8ebd118..2b0c1154dd57185fa7291e5986687197056ee43c 100644 (file)
@@ -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 <http://www.gnu.org/licenses/>.
-
 # 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
index 3d1eb0e1a16ba53bc94eb05d529d2aa427518c95..8678d483a7e261ff2e17a563bec57f0d123768c5 100644 (file)
@@ -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 <avr/pgmspace.h>
+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<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);
-}
-
-bool rgb_init = false;
-
-void matrix_scan_kb(void) {
-  // if LEDs were previously on before poweroff, turn them back on
-  if (rgb_init == false && rgblight_config.enable) {
-    i2c_init();
-    i2c_send(0xb0, (uint8_t*)led, 3 * RGBLED_NUM);
-    rgb_init = true;
-  }
-
-  rgblight_task();
-#else
-void matrix_scan_kb(void) {
-#endif
-  matrix_scan_user();
-  /* Nothing else for now. */
-}
-
-__attribute__((weak)) // overridable
-void matrix_init_user(void) {
-
-}
-
-__attribute__((weak)) // overridable
-void matrix_scan_user(void) {
-
-}
index 35800358cf6e0c621249299c19c393ab0f40789b..87a31d05203c1441d53142b22df9a60542d70841 100644 (file)
@@ -16,30 +16,6 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
 #include "bmini.h"
-#include "rgblight.h"
-
-#include <avr/pgmspace.h>
-
-#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 (file)
index a4f9521..0000000
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
-Copyright 2016 Luiz Ribeiro <luizribeiro@gmail.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/>.
-*/
-
-// Please do not modify this file 
-
-#include <avr/io.h>
-#include <util/twi.h>
-
-#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<<TWINT) | (1<<TWSTA) | (1<<TWEN);
-    while (!(TWCR & (1<<TWINT)));
-
-    // check if the start condition was successfully transmitted
-    if ((TWSR & 0xF8) != TW_START) {
-        return 1;
-    }
-
-    // transmit address and wait
-    TWDR = address;
-    TWCR = (1<<TWINT) | (1<<TWEN);
-    while (!(TWCR & (1<<TWINT)));
-
-    // check if the device has acknowledged the READ / WRITE mode
-    uint8_t twst = TW_STATUS & 0xF8;
-    if ((twst != TW_MT_SLA_ACK) && (twst != TW_MR_SLA_ACK)) {
-        return 1;
-    }
-
-    return 0;
-}
-
-void i2c_stop(void) {
-    TWCR = (1<<TWINT) | (1<<TWEN) | (1<<TWSTO);
-}
-
-uint8_t i2c_write(uint8_t data) {
-    TWDR = data;
-
-    // transmit data and wait
-    TWCR = (1<<TWINT) | (1<<TWEN);
-    while (!(TWCR & (1<<TWINT)));
-
-    if ((TWSR & 0xF8) != TW_MT_DATA_ACK) {
-        return 1;
-    }
-
-    return 0;
-}
-
-uint8_t i2c_send(uint8_t address, uint8_t *data, uint16_t length) {
-    if (i2c_start(address)) {
-        return 1;
-    }
-
-    for (uint16_t i = 0; i < length; i++) {
-        if (i2c_write(data[i])) {
-            return 1;
-        }
-    }
-
-    i2c_stop();
-
-    return 0;
-}
diff --git a/keyboards/winkeyless/bmini/i2c.h b/keyboards/winkeyless/bmini/i2c.h
deleted file mode 100644 (file)
index 93a69c9..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
-Copyright 2016 Luiz Ribeiro <luizribeiro@gmail.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/>.
-*/
-
-// 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
index 8cfc810566d376bcf644f09f5e745ae6db20b41a..7822bd83010dbc5fcd3323280f1f48f2dbf49061 100644 (file)
@@ -1,18 +1,3 @@
-# Copyright 2017 Luiz Ribeiro <luizribeiro@gmail.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/>.
-
 # 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
index d9b05aba5145478a8e896942ec39a6fc12402086..11315b92107304eaa77287767fe2d98abe52760b 100644 (file)
@@ -16,24 +16,10 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
 #include "bminiex.h"
-#include "rgblight.h"
-
-#include <avr/pgmspace.h>
-
-#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<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);
-}
-
-bool rgb_init = false;
-
-void matrix_scan_kb(void) {
-  // if LEDs were previously on before poweroff, turn them back on
-  if (rgb_init == false && rgblight_config.enable) {
-    i2c_init();
-    i2c_send(0xb0, (uint8_t*)led, 3 * RGBLED_NUM);
-    rgb_init = true;
-  }
-
-  rgblight_task();
-#else
-void matrix_scan_kb(void) {
-#endif
-  matrix_scan_user();
-  /* Nothing else for now. */
-}
-
-__attribute__((weak)) // overridable
-void matrix_init_user(void) {
-
-}
-
-__attribute__((weak)) // overridable
-void matrix_scan_user(void) {
-
-}
-
-
diff --git a/keyboards/winkeyless/bminiex/i2c.c b/keyboards/winkeyless/bminiex/i2c.c
deleted file mode 100644 (file)
index a4f9521..0000000
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
-Copyright 2016 Luiz Ribeiro <luizribeiro@gmail.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/>.
-*/
-
-// Please do not modify this file 
-
-#include <avr/io.h>
-#include <util/twi.h>
-
-#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<<TWINT) | (1<<TWSTA) | (1<<TWEN);
-    while (!(TWCR & (1<<TWINT)));
-
-    // check if the start condition was successfully transmitted
-    if ((TWSR & 0xF8) != TW_START) {
-        return 1;
-    }
-
-    // transmit address and wait
-    TWDR = address;
-    TWCR = (1<<TWINT) | (1<<TWEN);
-    while (!(TWCR & (1<<TWINT)));
-
-    // check if the device has acknowledged the READ / WRITE mode
-    uint8_t twst = TW_STATUS & 0xF8;
-    if ((twst != TW_MT_SLA_ACK) && (twst != TW_MR_SLA_ACK)) {
-        return 1;
-    }
-
-    return 0;
-}
-
-void i2c_stop(void) {
-    TWCR = (1<<TWINT) | (1<<TWEN) | (1<<TWSTO);
-}
-
-uint8_t i2c_write(uint8_t data) {
-    TWDR = data;
-
-    // transmit data and wait
-    TWCR = (1<<TWINT) | (1<<TWEN);
-    while (!(TWCR & (1<<TWINT)));
-
-    if ((TWSR & 0xF8) != TW_MT_DATA_ACK) {
-        return 1;
-    }
-
-    return 0;
-}
-
-uint8_t i2c_send(uint8_t address, uint8_t *data, uint16_t length) {
-    if (i2c_start(address)) {
-        return 1;
-    }
-
-    for (uint16_t i = 0; i < length; i++) {
-        if (i2c_write(data[i])) {
-            return 1;
-        }
-    }
-
-    i2c_stop();
-
-    return 0;
-}
diff --git a/keyboards/winkeyless/bminiex/i2c.h b/keyboards/winkeyless/bminiex/i2c.h
deleted file mode 100644 (file)
index ada8cc7..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
-Copyright 2016 Luiz Ribeiro <luizribeiro@gmail.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/>.
-*/
-
-// 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);
-
index 24e4348795fe26ad912491f535ddbebf2fa3ea30..39a77bda1276cabf097f9e56132096068d1017e0 100644 (file)
@@ -1,18 +1,3 @@
-# Copyright 2017 Luiz Ribeiro <luizribeiro@gmail.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/>.
-
 # 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 (file)
index c27f3e3..0000000
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
-Copyright 2016 Luiz Ribeiro <luizribeiro@gmail.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 <avr/io.h>
-#include <util/twi.h>
-
-#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<<TWINT) | (1<<TWSTA) | (1<<TWEN);
-    while (!(TWCR & (1<<TWINT)));
-
-    // check if the start condition was successfully transmitted
-    if ((TWSR & 0xF8) != TW_START) {
-        return 1;
-    }
-
-    // transmit address and wait
-    TWDR = address;
-    TWCR = (1<<TWINT) | (1<<TWEN);
-    while (!(TWCR & (1<<TWINT)));
-
-    // check if the device has acknowledged the READ / WRITE mode
-    uint8_t twst = TW_STATUS & 0xF8;
-    if ((twst != TW_MT_SLA_ACK) && (twst != TW_MR_SLA_ACK)) {
-        return 1;
-    }
-
-    return 0;
-}
-
-void i2c_stop(void) {
-    TWCR = (1<<TWINT) | (1<<TWEN) | (1<<TWSTO);
-}
-
-uint8_t i2c_write(uint8_t data) {
-    TWDR = data;
-
-    // transmit data and wait
-    TWCR = (1<<TWINT) | (1<<TWEN);
-    while (!(TWCR & (1<<TWINT)));
-
-    if ((TWSR & 0xF8) != TW_MT_DATA_ACK) {
-        return 1;
-    }
-
-    return 0;
-}
-
-uint8_t i2c_send(uint8_t address, uint8_t *data, uint16_t length) {
-    if (i2c_start(address)) {
-        return 1;
-    }
-
-    for (uint16_t i = 0; i < length; i++) {
-        if (i2c_write(data[i])) {
-            return 1;
-        }
-    }
-
-    i2c_stop();
-
-    return 0;
-}
diff --git a/keyboards/ymd75/i2c.h b/keyboards/ymd75/i2c.h
deleted file mode 100644 (file)
index 27c9d3d..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
-Copyright 2016 Luiz Ribeiro <luizribeiro@gmail.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/>.
-*/
-
-#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
index 7bee201738ab0d746831644b218c843d3202c341..0c1c9110ca83b10b66639178bf8a04ba9e2ba7e5 100644 (file)
@@ -1,19 +1,3 @@
-# Copyright 2017 Luiz Ribeiro <luizribeiro@gmail.com>
-# Modified 2018 Wayne Jones (WarmCatUK) <waynekjones@gmail.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/>.
-
 # 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
index 2259dfa5f049fe9a1d4cacdd7fd4892ca514afaf..74f7c6a493d9195f08fcb5ff9274972e0797c14f 100644 (file)
@@ -16,23 +16,19 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
 #include "ymd75.h"
-//#include "rgblight.h"
-
-#include <avr/pgmspace.h>
-
-#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<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);
-}
-
-bool rgb_init = false;
-
-void matrix_scan_kb(void) {
-    // if LEDs were previously on before poweroff, turn them back on
-    if (rgb_init == false && rgblight_config.enable) {
-        i2c_init();
-        i2c_send(0xb0, (uint8_t*)led, 3 * RGBLED_NUM);
-        rgb_init = true;
-    }
-    
-    rgblight_task();
-#else
-    void matrix_scan_kb(void) {
-#endif
-        matrix_scan_user();
-        /* Nothing else for now. */
-    }
-    
-    __attribute__((weak)) // overridable
-    void matrix_init_user(void) {
-        
-    }
-    
-    __attribute__((weak)) // overridable
-    void matrix_scan_user(void) {
-        
-    }
diff --git a/keyboards/ymd96/i2c.c b/keyboards/ymd96/i2c.c
deleted file mode 100644 (file)
index c27f3e3..0000000
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
-Copyright 2016 Luiz Ribeiro <luizribeiro@gmail.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 <avr/io.h>
-#include <util/twi.h>
-
-#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<<TWINT) | (1<<TWSTA) | (1<<TWEN);
-    while (!(TWCR & (1<<TWINT)));
-
-    // check if the start condition was successfully transmitted
-    if ((TWSR & 0xF8) != TW_START) {
-        return 1;
-    }
-
-    // transmit address and wait
-    TWDR = address;
-    TWCR = (1<<TWINT) | (1<<TWEN);
-    while (!(TWCR & (1<<TWINT)));
-
-    // check if the device has acknowledged the READ / WRITE mode
-    uint8_t twst = TW_STATUS & 0xF8;
-    if ((twst != TW_MT_SLA_ACK) && (twst != TW_MR_SLA_ACK)) {
-        return 1;
-    }
-
-    return 0;
-}
-
-void i2c_stop(void) {
-    TWCR = (1<<TWINT) | (1<<TWEN) | (1<<TWSTO);
-}
-
-uint8_t i2c_write(uint8_t data) {
-    TWDR = data;
-
-    // transmit data and wait
-    TWCR = (1<<TWINT) | (1<<TWEN);
-    while (!(TWCR & (1<<TWINT)));
-
-    if ((TWSR & 0xF8) != TW_MT_DATA_ACK) {
-        return 1;
-    }
-
-    return 0;
-}
-
-uint8_t i2c_send(uint8_t address, uint8_t *data, uint16_t length) {
-    if (i2c_start(address)) {
-        return 1;
-    }
-
-    for (uint16_t i = 0; i < length; i++) {
-        if (i2c_write(data[i])) {
-            return 1;
-        }
-    }
-
-    i2c_stop();
-
-    return 0;
-}
diff --git a/keyboards/ymd96/i2c.h b/keyboards/ymd96/i2c.h
deleted file mode 100644 (file)
index 27c9d3d..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
-Copyright 2016 Luiz Ribeiro <luizribeiro@gmail.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/>.
-*/
-
-#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
index 96441e1b3f379b20b3ff982ffcad190461905ecd..19d9fd81abb3e679185ac00c4c792a19fe1cef87 100644 (file)
@@ -1,18 +1,3 @@
-# Copyright 2017 Luiz Ribeiro <luizribeiro@gmail.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/>.
-
 # 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
index b0bf6128faea5d7b1f67afbe05088d069300089a..546a4c6e3af232d737bb4eaeae4f47fe9b8485fd 100644 (file)
@@ -18,22 +18,18 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 #include "ymd96.h"
 
-#include <avr/pgmspace.h>
+#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<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);
-}
-
-bool rgb_init = false;
-
-void matrix_scan_kb(void) {
-  // if LEDs were previously on before poweroff, turn them back on
-  if (rgb_init == false && rgblight_config.enable) {
-    i2c_init();
-    i2c_send(0xb0, (uint8_t*)led, 3 * RGBLED_NUM);
-    rgb_init = true;
-  }
-
-  rgblight_task();
-#else
-void matrix_scan_kb(void) {
-#endif
-  matrix_scan_user();
-  /* Nothing else for now. */
-}
-
-__attribute__((weak)) // overridable
-void matrix_init_user(void) {
-
-}
-
-
-__attribute__((weak)) // overridable
-void matrix_scan_user(void) {
-
-}
diff --git a/keyboards/ymdk_np21/i2c.c b/keyboards/ymdk_np21/i2c.c
deleted file mode 100644 (file)
index c27f3e3..0000000
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
-Copyright 2016 Luiz Ribeiro <luizribeiro@gmail.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 <avr/io.h>
-#include <util/twi.h>
-
-#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<<TWINT) | (1<<TWSTA) | (1<<TWEN);
-    while (!(TWCR & (1<<TWINT)));
-
-    // check if the start condition was successfully transmitted
-    if ((TWSR & 0xF8) != TW_START) {
-        return 1;
-    }
-
-    // transmit address and wait
-    TWDR = address;
-    TWCR = (1<<TWINT) | (1<<TWEN);
-    while (!(TWCR & (1<<TWINT)));
-
-    // check if the device has acknowledged the READ / WRITE mode
-    uint8_t twst = TW_STATUS & 0xF8;
-    if ((twst != TW_MT_SLA_ACK) && (twst != TW_MR_SLA_ACK)) {
-        return 1;
-    }
-
-    return 0;
-}
-
-void i2c_stop(void) {
-    TWCR = (1<<TWINT) | (1<<TWEN) | (1<<TWSTO);
-}
-
-uint8_t i2c_write(uint8_t data) {
-    TWDR = data;
-
-    // transmit data and wait
-    TWCR = (1<<TWINT) | (1<<TWEN);
-    while (!(TWCR & (1<<TWINT)));
-
-    if ((TWSR & 0xF8) != TW_MT_DATA_ACK) {
-        return 1;
-    }
-
-    return 0;
-}
-
-uint8_t i2c_send(uint8_t address, uint8_t *data, uint16_t length) {
-    if (i2c_start(address)) {
-        return 1;
-    }
-
-    for (uint16_t i = 0; i < length; i++) {
-        if (i2c_write(data[i])) {
-            return 1;
-        }
-    }
-
-    i2c_stop();
-
-    return 0;
-}
diff --git a/keyboards/ymdk_np21/i2c.h b/keyboards/ymdk_np21/i2c.h
deleted file mode 100644 (file)
index 27c9d3d..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
-Copyright 2016 Luiz Ribeiro <luizribeiro@gmail.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/>.
-*/
-
-#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
index 634b9c69c4bd533e1ff2212234648afe01ca5d0e..2bab3043e87302de6e7527e9504b4e263dcb0094 100644 (file)
@@ -1,18 +1,3 @@
-# Copyright 2017 Luiz Ribeiro <luizribeiro@gmail.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/>.
-
 # 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
index c1b11b4046f2a2fc80fd902b12d74f3a7eb87053..f2b3d46dabd6460a46bb4ae2177b44bb610d547d 100644 (file)
@@ -18,25 +18,9 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 #include "ymdk_np21.h"
 
-#include <avr/pgmspace.h>
-
-#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<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);
-}
-
-bool rgb_init = false;
-void matrix_scan_kb(void) {
-  // if LEDs were previously on before poweroff, turn them back on
-  if (rgb_init == false && rgblight_config.enable) {
-    i2c_init();
-    i2c_send(0xb0, (uint8_t*)led, 3 * RGBLED_NUM);
-    rgb_init = true;
-  }
-
-  rgblight_task();
-  /* Nothing else for now. */
-
-  matrix_scan_user();
-}