diff --git a/keyboards/winkeyless/bface/README.md b/keyboards/winkeyless/bface/README.md
index f1789b04cf..da0eb8088b 100644
--- a/keyboards/winkeyless/bface/README.md
+++ b/keyboards/winkeyless/bface/README.md
@@ -14,6 +14,8 @@ Flashing
ps2avr(GB) boards use an atmega32a microcontroller and a different bootloader. It is not flashable using the regular QMK methods.
+**Reset Key:** Hold down the key located at K00, commonly programmed as left control while plugging in the keyboard.
+
Windows:
1. Download [HIDBootFlash](http://vusb.wikidot.com/project:hidbootflash).
2. Place your keyboard into reset.
@@ -33,7 +35,7 @@ macOS:
3. Install the following packages:
```
brew install python
- brew install pyusb
+ pip3 install pyusb
brew install --HEAD`https://raw.githubusercontent.com/robertgzr/homebrew-tap/master/bootloadhid.rb
```
diff --git a/keyboards/winkeyless/bface/backlight_ps2avrGB.c b/keyboards/winkeyless/bface/backlight_ps2avrGB.c
deleted file mode 100644
index c0f6428407..0000000000
--- a/keyboards/winkeyless/bface/backlight_ps2avrGB.c
+++ /dev/null
@@ -1,94 +0,0 @@
-/* Copyright 2017 Sebastian Kaim
- *
- * 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 .
- */
-
-#ifdef BACKLIGHT_ENABLE
-
-#include "backlight_ps2avrGB.h"
-#define sbi(reg,bit) reg |= (_BV(bit))
-#define cbi(reg,bit) reg &= (~_BV(bit))
-#define PWM10 WGM10
-#define PWM11 WGM11
-#define COM1x1 COM1B1
-#define OCR1x OCR1B
-
-void backlight_init_ports(void)
-{
-#if BACKLIGHT_ON_STATE == 0
- backlight_off();
-#else
- backlight_on();
-#endif
-
- // setup pwm
- // this bitmagic is sourced from the original firmware
- /*TCCR1B = ((TCCR1B & ~0x07) | 0x03);
- TCNT1H = 0;
- TCNT1L = 0;
- sbi(TIMSK, TOIE1);
- OCR1BH = 0;
- OCR1BL = 0;
- cbi(TCCR1A,PWM11);
- sbi(TCCR1A,PWM10);
- sbi(TCCR1A,COM1B1);
- cbi(TCCR1A,COM1B0);*/
- ICR1 = 0xFFFF;
-
- TCCR1A = _BV(COM1x1) | _BV(WGM11); // = 0b00001010;
- TCCR1B = _BV(WGM13) | _BV(WGM12) | _BV(CS10); // = 0b00011001;
-
- backlight_init();
-}
-
-void backlight_set(uint8_t level)
-{
- if( level == 0 ) {
- backlight_off();
- }
- else {
- backlight_on();
- /*uint8_t pwm = get_pwm_for_brightness(level);
- set_backlight_pwm(pwm);
- TCCR1A |= _BV(COM1x1);
- OCR1x = (level >= 2) ? 0xFFFF : 0x00FF;*/
- }
-}
-
-#define PWM_MAX 0xFF
-uint8_t get_pwm_for_brightness(uint8_t level)
-{
- // we need to cast up here to allow multiplication with 0xFF. We could also use floats, but this is probably a lot faster.
- uint16_t brightness = (uint16_t)level * (uint16_t)PWM_MAX / (uint16_t)BACKLIGHT_LEVELS;
- return (uint8_t)brightness;
-}
-
-void backlight_on(void)
-{
- //_SFR_IO8(0x12) |= _BV(0x4);
- LED_PIN |= BACKLIGHT_PORT_NUM;
-}
-
-void backlight_off(void)
-{
- //_SFR_IO8(0x12) &= ~_BV(0x4);
- LED_PIN &= ~BACKLIGHT_PORT_NUM;
-}
-
-void set_backlight_pwm(uint8_t level) {
- // this does not work (yet)
- //OCR1B = level;
-}
-
-#endif // BACKLIGHT_ENABLE
diff --git a/keyboards/winkeyless/bface/backlight_ps2avrGB.h b/keyboards/winkeyless/bface/backlight_ps2avrGB.h
deleted file mode 100644
index d5ca903993..0000000000
--- a/keyboards/winkeyless/bface/backlight_ps2avrGB.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/* Copyright 2017 Sebastian Kaim
- *
- * 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 .
- */
-
-
-#if defined(__AVR__)
-#include
-#include
-#include
-#endif
-#include
-#include
-#include "backlight.h"
-
-#ifndef PS2AVRGB_BACKLIGHT_H
-#define PS2AVRGB_BACKLIGHT_H
-
-uint8_t get_pwm_for_brightness(uint8_t level);
-void set_backlight_pwm(uint8_t level);
-void backlight_on(void);
-void backlight_off(void);
-
-#endif
diff --git a/keyboards/winkeyless/bface/bface.c b/keyboards/winkeyless/bface/bface.c
index 8422a4a40b..1c83be4b8d 100644
--- a/keyboards/winkeyless/bface/bface.c
+++ b/keyboards/winkeyless/bface/bface.c
@@ -1,30 +1,23 @@
-/*
-Copyright 2017 Luiz Ribeiro
-Copyright 2018 Sebastian Kaim
-
-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 "bface.h"
+/* Copyright 2019 MechMerlin
+ *
+ * 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 "rgblight.h"
-
-#include
-
-#include "action_layer.h"
-#include "i2c.h"
+#include "i2c_master.h"
#include "quantum.h"
+#ifdef RGBLIGHT_ENABLE
extern rgblight_config_t rgblight_config;
void rgblight_set(void) {
@@ -37,10 +30,59 @@ void rgblight_set(void) {
}
i2c_init();
- i2c_send(0xb0, (uint8_t*)led, 3 * RGBLED_NUM);
+ i2c_transmit(0xb0, (uint8_t*)led, 3 * RGBLED_NUM, 100);
+}
+#endif
+
+void matrix_init_kb(void) {
+#ifdef RGBLIGHT_ENABLE
+ if (rgblight_config.enable) {
+ i2c_init();
+ i2c_transmit(0xb0, (uint8_t*)led, 3 * RGBLED_NUM, 100);
+ }
+#endif
+ // call user level keymaps, if any
+ matrix_init_user();
+}
+
+void matrix_scan_kb(void) {
+#ifdef RGBLIGHT_ENABLE
+ rgblight_task();
+#endif
+ matrix_scan_user();
+ /* Nothing else for now. */
}
__attribute__ ((weak))
void matrix_scan_user(void) {
- rgblight_task();
+}
+
+void backlight_init_ports(void) {
+ // initialize pins D0, D1, D4 and D6 as output
+ setPinOutput(D0);
+ setPinOutput(D1);
+ setPinOutput(D4);
+ setPinOutput(D6);
+
+ // turn backlight LEDs on
+ writePinHigh(D0);
+ writePinHigh(D1);
+ writePinHigh(D4);
+ writePinHigh(D6);
+}
+
+void backlight_set(uint8_t level) {
+ if (level == 0) {
+ // turn backlight LEDs off
+ writePinLow(D0);
+ writePinLow(D1);
+ writePinLow(D4);
+ writePinLow(D6);
+ } else {
+ // turn backlight LEDs on
+ writePinHigh(D0);
+ writePinHigh(D1);
+ writePinHigh(D4);
+ writePinHigh(D6);
+ }
}
diff --git a/keyboards/winkeyless/bface/bface.h b/keyboards/winkeyless/bface/bface.h
index 62d62f6953..f7a3b9521f 100644
--- a/keyboards/winkeyless/bface/bface.h
+++ b/keyboards/winkeyless/bface/bface.h
@@ -16,8 +16,7 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see .
*/
-#ifndef KEYMAP_COMMON_H
-#define KEYMAP_COMMON_H
+#pragma once
#include "quantum_keycodes.h"
#include "keycode.h"
@@ -27,8 +26,8 @@ along with this program. If not, see .
K04, K14, K24, K34, K44, K54, K16, KB6, KB7, K17, KA4, KB4, KC4, KE4, \
K03, K13, K23, K33, K43, K53, K26, KC6, KC7, K27, KA3, KB3, KC3, KD3, \
K02, K12, K22, K32, K42, K52, K36, KD6, KD7, K37, KA2, KB2, KD2, \
- K01, K11, K21, K31, K41, K51, K46, KE6, KE7, K47, KA1, KB1, \
- K00, K10, K20, K56, K57, KA0, KB0, KC0 \
+ K01, K11, K21, K31, K41, K51, K46, KE6, KE7, K47, KA1, KB1, \
+ K00, K10, K20, K56, K57, KA0, KB0, KC0 \
){ \
{ K00, K10, K20, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KA0, KB0, KC0, KC_NO, KC_NO }, \
{ K01, K11, K21, K31, K41, K51, KC_NO, KC_NO, KC_NO, KC_NO, KA1, KB1, KC_NO, KC_NO, KC_NO }, \
@@ -37,8 +36,6 @@ along with this program. If not, see .
{ K04, K14, K24, K34, K44, K54, KC_NO, KC_NO, KC_NO, KC_NO, KA4, KB4, KC4, KC_NO, KE4 }, \
{ KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO }, \
{ KC_NO, K16, K26, K36, K46, K56, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KB6, KC6, KD6, KE6 }, \
- { KC_NO, K17, K27, K37, K47, K57, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KB7, KC7, KD7, KE7 } \
+ { KC_NO, K17, K27, K37, K47, K57, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KB7, KC7, KD7, KE7 } \
}
-
-#endif
diff --git a/keyboards/winkeyless/bface/config.h b/keyboards/winkeyless/bface/config.h
index 11ac373c02..7a1fe33354 100644
--- a/keyboards/winkeyless/bface/config.h
+++ b/keyboards/winkeyless/bface/config.h
@@ -16,8 +16,7 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see .
*/
-#ifndef CONFIG_H
-#define CONFIG_H
+#pragma once
#define VENDOR_ID 0x20A0
#define PRODUCT_ID 0x422D
@@ -30,6 +29,11 @@ along with this program. If not, see .
#define MATRIX_ROWS 8
#define MATRIX_COLS 15
+// 0 1 2 3 4 5 6 7 8 9 A B C D E
+#define MATRIX_ROW_PINS { B0, B1, B2, B3, B4, B5, B6, B7 }
+#define MATRIX_COL_PINS { A0, A1, A2, A3, A4, A5, A6, A7, C7, C6, C5, C4, C3, C2, D7}
+#define UNUSED_PINS
+
#define RGBLED_NUM 16
#define RGBLIGHT_ANIMATIONS
@@ -43,4 +47,3 @@ along with this program. If not, see .
#define BACKLIGHT_PORT_NUM (1 << 4)
#endif
-#endif
diff --git a/keyboards/winkeyless/bface/i2c.c b/keyboards/winkeyless/bface/i2c.c
deleted file mode 100644
index c27f3e3d17..0000000000
--- a/keyboards/winkeyless/bface/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/winkeyless/bface/matrix.c b/keyboards/winkeyless/bface/matrix.c
deleted file mode 100644
index b3761a63ca..0000000000
--- a/keyboards/winkeyless/bface/matrix.c
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
-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 .
-*/
-
-#include
-#include
-
-#include "matrix.h"
-
-#ifndef DEBOUNCE
-# define DEBOUNCE 5
-#endif
-
-static uint8_t debouncing = DEBOUNCE;
-
-static matrix_row_t matrix[MATRIX_ROWS];
-static matrix_row_t matrix_debouncing[MATRIX_ROWS];
-
-void matrix_init(void) {
- // all outputs for rows high
- DDRB = 0xFF;
- PORTB = 0xFF;
- // all inputs for columns
- DDRA = 0x00;
- DDRC &= ~(0x111111<<2);
- DDRD &= ~(1<> 1) & 0x55) | ((x << 1) & 0xaa);
- x = ((x >> 2) & 0x33) | ((x << 2) & 0xcc);
- x = ((x >> 4) & 0x0f) | ((x << 4) & 0xf0);
- return x;
-}
-
-uint8_t matrix_scan(void) {
- for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
- matrix_set_row_status(row);
- _delay_us(5);
-
- matrix_row_t cols = (
- // cols 0..7, PORTA 0 -> 7
- (~PINA) & 0xFF
- ) | (
- // cols 8..13, PORTC 7 -> 0
- bit_reverse((~PINC) & 0xFF) << 8
- ) | (
- // col 14, PORTD 7
- ((~PIND) & (1 << PIND7)) << 7
- );
-
- if (matrix_debouncing[row] != cols) {
- matrix_debouncing[row] = cols;
- debouncing = DEBOUNCE;
- }
- }
-
- if (debouncing) {
- if (--debouncing) {
- _delay_ms(1);
- } else {
- for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
- matrix[i] = matrix_debouncing[i];
- }
- }
- }
-
- matrix_scan_user();
-
- return 1;
-}
-
-inline matrix_row_t matrix_get_row(uint8_t row) {
- return matrix[row];
-}
-
-void matrix_print(void) {
-}
diff --git a/keyboards/winkeyless/bface/rules.mk b/keyboards/winkeyless/bface/rules.mk
index 369ccf2eda..b6d172f266 100644
--- a/keyboards/winkeyless/bface/rules.mk
+++ b/keyboards/winkeyless/bface/rules.mk
@@ -25,7 +25,7 @@ NO_SUSPEND_POWER_DOWN = yes
F_CPU = 12000000
# build options
-BOOTMAGIC_ENABLE = yes
+BOOTMAGIC_ENABLE = no
MOUSEKEY_ENABLE = yes
EXTRAKEY_ENABLE = yes
CONSOLE_ENABLE = no
@@ -40,8 +40,7 @@ OPT_DEFS = -DDEBUG_LEVEL=0
OPT_DEFS += -DBOOTLOADER_SIZE=2048
# custom matrix setup
-CUSTOM_MATRIX = yes
-SRC = matrix.c i2c.c backlight_ps2avrGB.c
+SRC = i2c_master.c
# programming options
PROGRAM_CMD = ./util/atmega32a_program.py $(TARGET).hex
diff --git a/keyboards/winkeyless/bface/usbconfig.h b/keyboards/winkeyless/bface/usbconfig.h
index f87922615b..192d80d916 100644
--- a/keyboards/winkeyless/bface/usbconfig.h
+++ b/keyboards/winkeyless/bface/usbconfig.h
@@ -8,8 +8,7 @@
* This Revision: $Id: usbconfig-prototype.h 785 2010-05-30 17:57:07Z cs $
*/
-#ifndef __usbconfig_h_included__
-#define __usbconfig_h_included__
+#pragma once
#include "config.h"
@@ -392,5 +391,3 @@ section at the end of this file).
/* #define USB_INTR_PENDING EIFR */
#define USB_INTR_PENDING_BIT INTF1
#define USB_INTR_VECTOR INT1_vect
-
-#endif /* __usbconfig_h_included__ */