summaryrefslogtreecommitdiffstats
path: root/keyboards
diff options
context:
space:
mode:
authorSebastian Kaim <Sebb767@users.noreply.github.com>2018-08-20 04:32:35 +0200
committerDrashna Jaelre <drashna@live.com>2018-08-19 19:32:35 -0700
commit4a3eb3bdd457af85fda4b25d9e6379ee245d468b (patch)
tree79d1ce2dc5c7df85f5fd794034aa02d03bdca79f /keyboards
parent10c636a1eeaff65292edabe7f01c781110ba871f (diff)
[WIP] Added support for the b.face keyboard (#2493)
* Added support for the b.face keyboard This commit adds support for the 60% keyboard from winkeyless, the b.face. The basic keyboard layout as well as the RGB backlighting works as expected; the per-key LEDs can be turned on or off but not yet dimmed. A default 60% US-layout is included. * Added link to the bface in the ps2avrGB README
Diffstat (limited to 'keyboards')
-rw-r--r--keyboards/bface/README.md61
-rw-r--r--keyboards/bface/backlight_ps2avrGB.c94
-rw-r--r--keyboards/bface/backlight_ps2avrGB.h35
-rw-r--r--keyboards/bface/bface.c46
-rw-r--r--keyboards/bface/bface.h44
-rw-r--r--keyboards/bface/config.h49
-rw-r--r--keyboards/bface/i2c.c104
-rw-r--r--keyboards/bface/i2c.h25
-rw-r--r--keyboards/bface/keymaps/default/keymap.c49
-rw-r--r--keyboards/bface/matrix.c113
-rwxr-xr-xkeyboards/bface/program105
-rw-r--r--keyboards/bface/rules.mk47
-rw-r--r--keyboards/bface/usbconfig.h396
-rw-r--r--keyboards/ps2avrGB/README.md1
14 files changed, 1169 insertions, 0 deletions
diff --git a/keyboards/bface/README.md b/keyboards/bface/README.md
new file mode 100644
index 0000000000..f8360aec0c
--- /dev/null
+++ b/keyboards/bface/README.md
@@ -0,0 +1,61 @@
+ps2avrGB keyboard firmware
+==========================
+
+This is a port of the QMK firmware for boards that are based on the
+ps2avrGB firmware, like the [ps2avrGB
+keyboard](https://www.keyclack.com/product/gb-ps2avrgb/) or the ones sold
+by [Winkeyless](http://winkeyless.kr/product/ps2avrgb-parts/).
+
+Note that this is a complete replacement for the firmware, so you won't be
+using Bootmapper Client to change any keyboard settings, since not all the
+USB report options are supported.
+
+## Supported Boards
+
+Only the [B.mini X2](http://winkeyless.kr/product/b-mini-x2-pcb/) has been
+tested so far (since it's the only one I own). But other boards that use
+the ps2avrGB firmware should work as well.
+
+## Installing
+
+First, install the requirements. These commands are for OSX, but all you
+need is the AVR toolchain and `bootloadHID` for flashing:
+
+```
+$ brew cask install crosspack-avr
+$ brew install --HEAD https://raw.githubusercontent.com/robertgzr/homebrew-tap/master/bootloadhid.rb
+```
+
+In order to use the `./program` script, which can reboot the board into
+the bootloader, you'll need Python 2 with PyUSB installed:
+
+```
+$ pip install pyusb
+```
+
+Then, with the keyboard plugged in, simply run this command from the
+`qmk_firmware` directory:
+
+```
+$ make ps2avrGB-program
+```
+
+If you prefer, you can just build it and flash the firmware directly with
+`bootloadHID` if you boot the board while holding down `L_Ctrl` to keep it
+in the bootloader:
+
+```
+$ make ps2avrGB
+$ bootloadHID -r ps2avrGB_default.hex
+```
+
+## Troubleshooting
+
+From my experience, it's really hard to brick these boards. But these
+tricks have been useful when it got stuck in a weird scenario.
+
+1. Try plugging the board in while pressing `L_Ctrl`. This will force it
+ to boot only the bootloader without loading the firmware. Once this is
+ done, just reflash the board with the original firmware.
+2. Sometimes USB hubs can act weird, so try connecting the board directly
+ to your computer or plugging/unplugging the USB hub.
diff --git a/keyboards/bface/backlight_ps2avrGB.c b/keyboards/bface/backlight_ps2avrGB.c
new file mode 100644
index 0000000000..c0f6428407
--- /dev/null
+++ b/keyboards/bface/backlight_ps2avrGB.c
@@ -0,0 +1,94 @@
+/* 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 <http://www.gnu.org/licenses/>.
+ */
+
+#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/bface/backlight_ps2avrGB.h b/keyboards/bface/backlight_ps2avrGB.h
new file mode 100644
index 0000000000..d5ca903993
--- /dev/null
+++ b/keyboards/bface/backlight_ps2avrGB.h
@@ -0,0 +1,35 @@
+/* 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 <http://www.gnu.org/licenses/>.
+ */
+
+
+#if defined(__AVR__)
+#include <avr/pgmspace.h>
+#include <avr/io.h>
+#include <avr/interrupt.h>
+#endif
+#include <stddef.h>
+#include <stdlib.h>
+#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/bface/bface.c b/keyboards/bface/bface.c
new file mode 100644
index 0000000000..8422a4a40b
--- /dev/null
+++ b/keyboards/bface/bface.c
@@ -0,0 +1,46 @@
+/*
+Copyright 2017 Luiz Ribeiro <luizribeiro@gmail.com>
+Copyright 2018 Sebastian Kaim <sebb@sebb767.de>
+
+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 "bface.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();
+}
diff --git a/keyboards/bface/bface.h b/keyboards/bface/bface.h
new file mode 100644
index 0000000000..1f1f3393ff
--- /dev/null
+++ b/keyboards/bface/bface.h
@@ -0,0 +1,44 @@
+/*
+Copyright 2017 Luiz Ribeiro <luizribeiro@gmail.com>
+Copyright 2017 Sebastian Kaim <sebb@sebb767.de>
+
+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 KEYMAP_COMMON_H
+#define KEYMAP_COMMON_H
+
+#include "quantum_keycodes.h"
+#include "keycode.h"
+#include "action.h"
+
+#define KEYMAP( \
+ 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 \
+){ \
+ { 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 }, \
+ { K02, K12, K22, K32, K42, K52, KC_NO, KC_NO, KC_NO, KC_NO, KA2, KB2, KC_NO, KD2, KC_NO }, \
+ { K03, K13, K23, K33, K43, K53, KC_NO, KC_NO, KC_NO, KC_NO, KA3, KB3, KC3, KD3, KC_NO }, \
+ { 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 } \
+}
+
+
+#endif
diff --git a/keyboards/bface/config.h b/keyboards/bface/config.h
new file mode 100644
index 0000000000..3d74af4f14
--- /dev/null
+++ b/keyboards/bface/config.h
@@ -0,0 +1,49 @@
+/*
+Copyright 2017 Luiz Ribeiro <luizribeiro@gmail.com>
+Copyright 2017 Sebastian Kaim <sebastian.kaim@sebb767.de>
+
+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 CONFIG_H
+#define CONFIG_H
+
+#define VENDOR_ID 0x20A0
+#define PRODUCT_ID 0x422D
+// You can edit those at usbconfig.h about line 250. These values will
+// unforunatly be ignored so far
+#define MANUFACTURER winkeyless.kr
+#define PRODUCT b.face
+
+/* matrix size */
+#define MATRIX_ROWS 8
+#define MATRIX_COLS 15
+
+#define RGBLED_NUM 16
+#define RGBLIGHT_ANIMATIONS
+
+#define NO_UART 1
+#define BOOTLOADHID_BOOTLOADER 1
+
+/* key combination for command */
+#define IS_COMMAND() (keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)))
+
+#ifdef BACKLIGHT_ENABLE
+ // the backlight PWM does not work (yet). Therefore, we only have two backlight levels (on/off)
+ #define BACKLIGHT_LEVELS 1
+ #define LED_PIN PORTD
+ #define BACKLIGHT_PORT_NUM (1 << 4)
+#endif
+
+#endif
diff --git a/keyboards/bface/i2c.c b/keyboards/bface/i2c.c
new file mode 100644
index 0000000000..c27f3e3d17
--- /dev/null
+++ b/keyboards/bface/i2c.c
@@ -0,0 +1,104 @@
+/*
+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/bface/i2c.h b/keyboards/bface/i2c.h
new file mode 100644
index 0000000000..27c9d3d050
--- /dev/null
+++ b/keyboards/bface/i2c.h
@@ -0,0 +1,25 @@
+/*
+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
diff --git a/keyboards/bface/keymaps/default/keymap.c b/keyboards/bface/keymaps/default/keymap.c
new file mode 100644
index 0000000000..785ab2e9de
--- /dev/null
+++ b/keyboards/bface/keymaps/default/keymap.c
@@ -0,0 +1,49 @@
+/*
+Copyright 2017 Sebastian Kaim <sebastian.kaim@sebb767.de>
+
+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 "bface.h"
+#include "action_layer.h"
+#include "rgblight.h"
+
+const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
+ [0] = KEYMAP(
+ KC_ESC, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS,KC_EQL, KC_BSPC,
+ KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC,KC_RBRC,KC_BSLS,
+ KC_F1, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN,KC_QUOT,KC_ENT,
+ KC_LSFT,KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM,KC_DOT, KC_SLSH, KC_RSFT,
+ KC_LCTL,KC_LALT,KC_LGUI, KC_SPC, KC_RALT,KC_RGUI,KC_FN0, KC_RCTL
+ ),
+ [1] = KEYMAP(
+ KC_TRNS,KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_TRNS,
+ KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS,
+ KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS,BL_INC, BL_DEC, KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS,
+ KC_TRNS,KC_TRNS,RGB_SMOD,KC_TRNS,BL_ON, BL_OFF, KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS, KC_TRNS,
+ KC_TRNS,KC_TRNS,KC_TRNS, KC_TRNS, KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS
+ ),
+ /* You can copy this layer as base for a new fn layer * /
+ [n] = KEYMAP(
+ KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS,
+ KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS,
+ KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS,
+ KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS, KC_TRNS,
+ KC_TRNS,KC_TRNS,KC_TRNS, KC_TRNS, KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS
+ ), // */
+};
+
+const uint16_t PROGMEM fn_actions[] = {
+ [0] = ACTION_LAYER_MOMENTARY(1),
+};
diff --git a/keyboards/bface/matrix.c b/keyboards/bface/matrix.c
new file mode 100644
index 0000000000..b3761a63ca
--- /dev/null
+++ b/keyboards/bface/matrix.c
@@ -0,0 +1,113 @@
+/*
+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/>.
+*/
+
+#include <avr/io.h>
+#include <util/delay.h>
+
+#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<<PIND7);
+ // all columns are pulled-up
+ PORTA = 0xFF;
+ PORTC |= (0b111111<<2);
+ PORTD |= (1<<PIND7);
+
+ // initialize matrix state: all keys off
+ for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
+ matrix[row] = 0x00;
+ matrix_debouncing[row] = 0x00;
+ }
+
+ // activate backlight
+ //PORTD |= (1 << 4);
+ //_SFR_IO8(0x09) |= (1 << 4); //_BV(0x94 & 0xF);
+ //
+ // this is the code that *should* be executed in quantum.c
+ _SFR_IO8(0x12) |= _BV(0x4);
+}
+
+void matrix_set_row_status(uint8_t row) {
+ DDRB = (1 << row);
+ PORTB = ~(1 << row);
+}
+
+uint8_t bit_reverse(uint8_t x) {
+ x = ((x >> 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/bface/program b/keyboards/bface/program
new file mode 100755
index 0000000000..298e645477
--- /dev/null
+++ b/keyboards/bface/program
@@ -0,0 +1,105 @@
+#!/usr/bin/env python
+# Copyright 2017 Luiz Ribeiro <luizribeiro@gmail.com>, Sebastian Kaim <sebb@sebb767.de>
+#
+# 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/>.
+
+from __future__ import print_function
+
+import os
+import sys
+import time
+import usb
+
+
+def checkForKeyboardInNormalMode():
+ """Returns a device if a ps2avrGB device in normal made (that is in keyboard mode) or None if it is not found."""
+ return usb.core.find(idVendor=0x20A0, idProduct=0x422D)
+
+def checkForKeyboardInBootloaderMode():
+ """Returns True if a ps2avrGB device in bootloader (flashable) mode is found and False otherwise."""
+ return (usb.core.find(idVendor=0x16c0, idProduct=0x05df) is not None)
+
+def flashKeyboard(firmware_file):
+ """Calls bootloadHID to flash the given file to the device."""
+ print('Flashing firmware to device ...')
+ if os.system('bootloadHID -r "%s"' % firmware_file) == 0:
+ print('\nDone!')
+ else:
+ print('\nbootloadHID returned an error.')
+
+def printDeviceInfo(dev):
+ """Prints all infos for a given USB device"""
+ print('Device Information:')
+ print(' idVendor: %d (0x%04x)' % (dev.idVendor, dev.idVendor))
+ print(' idProduct: %d (0x%04x)' % (dev.idProduct, dev.idProduct))
+ print('Manufacturer: %s' % (dev.iManufacturer))
+ print('Serial: %s' % (dev.iSerialNumber))
+ print('Product: %s' % (dev.iProduct), end='\n\n')
+
+def sendDeviceToBootloaderMode(dev):
+ """Tries to send a given ps2avrGB keyboard to bootloader mode to allow flashing."""
+ try:
+ dev.set_configuration()
+
+ request_type = usb.util.build_request_type(
+ usb.util.CTRL_OUT,
+ usb.util.CTRL_TYPE_CLASS,
+ usb.util.CTRL_RECIPIENT_DEVICE)
+
+ USBRQ_HID_SET_REPORT = 0x09
+ HID_REPORT_OPTION = 0x0301
+
+ dev.ctrl_transfer(request_type, USBRQ_HID_SET_REPORT, HID_REPORT_OPTION, 0, [0, 0, 0xFF] + [0] * 5)
+ except usb.core.USBError:
+ # for some reason I keep getting USBError, but it works!
+ pass
+
+
+if len(sys.argv) < 2:
+ print('Usage: %s <firmware.hex>' % sys.argv[0])
+ sys.exit(1)
+
+kb = checkForKeyboardInNormalMode()
+
+if kb is not None:
+ print('Found a keyboad in normal mode. Attempting to send it to bootloader mode ...', end='')
+ sendDeviceToBootloaderMode(kb)
+ print(' done.')
+ print("Hint: If your keyboard can't be set to bootloader mode automatically, plug it in while pressing the bootloader key to do so manually.")
+ print(" You can find more infos about this here: https://github.com/qmk/qmk_firmware/tree/master/keyboards/ps2avrGB#setting-the-board-to-bootloader-mode")
+
+attempts = 12 # 60 seconds
+found = False
+for attempt in range(1, attempts + 1):
+ print("Searching for keyboard in bootloader mode (%i/%i) ... " % (attempt, attempts), end='')
+
+ if checkForKeyboardInBootloaderMode():
+ print('Found', end='\n\n')
+ flashKeyboard(sys.argv[1])
+ found = True
+ break
+ else:
+ print('Nothing.', end='')
+
+ if attempt != attempts: # no need to wait on the last attempt
+ print(' Sleeping 5 seconds.', end='')
+ time.sleep(5)
+
+ # print a newline
+ print()
+
+if not found:
+ print("Couldn't find a flashable keyboard. Aborting.")
+ sys.exit(2)
+
diff --git a/keyboards/bface/rules.mk b/keyboards/bface/rules.mk
new file mode 100644
index 0000000000..6fb32ae57b
--- /dev/null
+++ b/keyboards/bface/rules.mk
@@ -0,0 +1,47 @@
+# 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
+PROTOCOL = VUSB
+
+# unsupported features for now
+NO_UART = yes
+NO_SUSPEND_POWER_DOWN = yes
+
+# processor frequency
+F_CPU = 12000000
+
+# build options
+BOOTMAGIC_ENABLE = yes
+MOUSEKEY_ENABLE = yes
+EXTRAKEY_ENABLE = yes
+CONSOLE_ENABLE = no
+COMMAND_ENABLE = yes
+BACKLIGHT_ENABLE = yes
+BACKLIGHT_CUSTOM_DRIVER = yes
+BACKLIGHT_BREATHING = no
+RGBLIGHT_ENABLE = yes
+RGBLIGHT_CUSTOM_DRIVER = yes
+
+OPT_DEFS = -DDEBUG_LEVEL=0
+OPT_DEFS += -DBOOTLOADER_SIZE=2048
+
+# custom matrix setup
+CUSTOM_MATRIX = yes
+SRC = matrix.c i2c.c backlight_ps2avrGB.c
+
+# programming options
+PROGRAM_CMD = ./keyboards/bface/program .build/$(TARGET).hex
diff --git a/keyboards/bface/usbconfig.h b/keyboards/bface/usbconfig.h
new file mode 100644
index 0000000000..f87922615b
--- /dev/null
+++ b/keyboards/bface/usbconfig.h
@@ -0,0 +1,396 @@
+/* Name: usbconfig.h
+ * Project: V-USB, virtual USB port for Atmel's(r) AVR(r) microcontrollers
+ * Author: Christian Starkjohann
+ * Creation Date: 2005-04-01
+ * Tabsize: 4
+ * Copyright: (c) 2005 by OBJECTIVE DEVELOPMENT Software GmbH
+ * License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt)
+ * This Revision: $Id: usbconfig-prototype.h 785 2010-05-30 17:57:07Z cs $
+ */
+
+#ifndef __usbconfig_h_included__
+#define __usbconfig_h_included__
+
+#include "config.h"
+
+/*
+General Description:
+This file is an example configuration (with inline documentation) for the USB
+driver. It configures V-USB for USB D+ connected to Port D bit 2 (which is
+also hardware interrupt 0 on many devices) and USB D- to Port D bit 4. You may
+wire the lines to any other port, as long as D+ is also wired to INT0 (or any
+other hardware interrupt, as long as it is the highest level interrupt, see
+section at the end of this file).
+*/
+
+/* ---------------------------- Hardware Config ---------------------------- */
+
+#define USB_CFG_IOPORTNAME D
+/* This is the port where the USB bus is connected. When you configure it to
+ * "B", the registers PORTB, PINB and DDRB will be used.
+ */
+#define USB_CFG_DMINUS_BIT 3
+/* This is the bit number in USB_CFG_IOPORT where the USB D- line is connected.
+ * This may be any bit in the port.
+ */
+#define USB_CFG_DPLUS_BIT 2
+/* This is the bit number in USB_CFG_IOPORT where the USB D+ line is connected.
+ * This may be any bit in the port. Please note that D+ must also be connected
+ * to interrupt pin INT0! [You can also use other interrupts, see section
+ * "Optional MCU Description" below, or you can connect D- to the interrupt, as
+ * it is required if you use the USB_COUNT_SOF feature. If you use D- for the
+ * interrupt, the USB interrupt will also be triggered at Start-Of-Frame
+ * markers every millisecond.]
+ */
+#define USB_CFG_CLOCK_KHZ (F_CPU/1000)
+/* Clock rate of the AVR in kHz. Legal values are 12000, 12800, 15000, 16000,
+ * 16500, 18000 and 20000. The 12.8 MHz and 16.5 MHz versions of the code
+ * require no crystal, they tolerate +/- 1% deviation from the nominal
+ * frequency. All other rates require a precision of 2000 ppm and thus a
+ * crystal!
+ * Since F_CPU should be defined to your actual clock rate anyway, you should
+ * not need to modify this setting.
+ */
+#define USB_CFG_CHECK_CRC 0
+/* Define this to 1 if you want that the driver checks integrity of incoming
+ * data packets (CRC checks). CRC checks cost quite a bit of code size and are
+ * currently only available for 18 MHz crystal clock. You must choose
+ * USB_CFG_CLOCK_KHZ = 18000 if you enable this option.
+ */
+
+/* ----------------------- Optional Hardware Config ------------------------ */
+
+/* #define USB_CFG_PULLUP_IOPORTNAME D */
+/* If you connect the 1.5k pullup resistor from D- to a port pin instead of
+ * V+, you can connect and disconnect the device from firmware by calling
+ * the macros usbDeviceConnect() and usbDeviceDisconnect() (see usbdrv.h).
+ * This constant defines the port on which the pullup resistor is connected.
+ */
+/* #define USB_CFG_PULLUP_BIT 4 */
+/* This constant defines the bit number in USB_CFG_PULLUP_IOPORT (defined
+ * above) where the 1.5k pullup resistor is connected. See description
+ * above for details.
+ */
+
+/* --------------------------- Functional Range ---------------------------- */
+
+#define USB_CFG_HAVE_INTRIN_ENDPOINT 1
+/* Define this to 1 if you want to compile a version with two endpoints: The
+ * default control endpoint 0 and an interrupt-in endpoint (any other endpoint
+ * number).
+ */
+#define USB_CFG_HAVE_INTRIN_ENDPOINT3 1
+/* Define this to 1 if you want to compile a version with three endpoints: The
+ * default control endpoint 0, an interrupt-in endpoint 3 (or the number
+ * configured below) and a catch-all default interrupt-in endpoint as above.
+ * You must also define USB_CFG_HAVE_INTRIN_ENDPOINT to 1 for this feature.
+ */
+#define USB_CFG_EP3_NUMBER 3
+/* If the so-called endpoint 3 is used, it can now be configured to any other
+ * endpoint number (except 0) with this macro. Default if undefined is 3.
+ */
+/* #define USB_INITIAL_DATATOKEN USBPID_DATA1 */
+/* The above macro defines the startup condition for data toggling on the
+ * interrupt/bulk endpoints 1 and 3