Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added TGR Alice keyboard support #4896

Merged
merged 3 commits into from
Jan 21, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions keyboards/alice/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# TGR Alice
drashna marked this conversation as resolved.
Show resolved Hide resolved

![TGR Alice](https://i.imgur.com/cJohEqS.jpg)

An ergonomic 60% keyboard.

Keyboard Maintainer: [Felipe Coury](https://github.com/fcoury)
Hardware Supported: TGR Alice
Hardware Availability: Group buy finished

Make example for this keyboard (after setting up your build environment):

make alice:default

See [build environment setup](https://docs.qmk.fm/#/getting_started_build_tools) then the [make instructions](https://docs.qmk.fm/#/getting_started_make_guide) for more information.


ps2avrGB keyboard firmware
==========================

This keyboard uses the port of the QMK firmware for boards that are based on the
ps2avrGB firmware.

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.

## 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
$ pip install pyusb
```

Then, with the keyboard plugged in, simply run this command from the
`qmk_firmware` directory:

```
$ make alice
$ bootloadHID -r alice_default.hex
```

## Setting the board to bootloader mode

Hold the ESC key (the one before the 1! key, in case you remaped it).

## 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 holding the bootloader key. 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.
78 changes: 78 additions & 0 deletions keyboards/alice/alice.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
/*
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 "alice.h"
#include "rgblight.h"

#include <avr/pgmspace.h>

#include "action_layer.h"
#include "i2c.h"
#include "quantum.h"

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

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) {

}
40 changes: 40 additions & 0 deletions keyboards/alice/alice.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
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/>.
*/

#ifndef ALICE_H
#define ALICE_H

#include "quantum.h"

#define LAYOUT( \
K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K10, K11, K12, K13, K14, \
K15, K16, K17, K18, K19, K20, K21, K22, K23, K24, K25, K26, K27, K28, \
K29, K30, K31, K32, K33, K34, K35, K36, K37, K38, K39, K40, K41, \
K42, K43, K44, K45, K46, K47, K48, K49, K50, K51, K52, K53, K54, K55, \
K56, K57, K58, K59, K60, K61, K62, \
K63, K64, K65 \
) \
{ \
{ K00 , K01 , K02 , K03 , K04 , K05 , K06 , K07 , K08 , K09 , K10 , K11 , K12 , K13 , K14 }, \
{ K15 , K16 , K17 , K18 , K19 , K20 , K21 , K22 , K23 , K24 , K25 , K26 , K27 , K28 , KC_NO }, \
{ K29 , K30 , K31 , K32 , K33 , K34 , K35 , K36 , K37 , K38 , K39 , K40 , K41 , KC_NO, KC_NO }, \
{ K42 , K43 , K44 , K45 , K46 , K47 , K48 , K49 , K50 , K51 , K52 , K53 , K54 , K55 , KC_NO }, \
{ K56 , K57 , K58 , K59 , KC_NO, KC_NO, K60 , K61 , K62 , KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO }, \
{ K63 , K64 , K65 , KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO } \
}

#endif
41 changes: 41 additions & 0 deletions keyboards/alice/config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
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/>.
*/

#ifndef CONFIG_H
drashna marked this conversation as resolved.
Show resolved Hide resolved
#define CONFIG_H
drashna marked this conversation as resolved.
Show resolved Hide resolved

#define VENDOR_ID 0x20A0
#define PRODUCT_ID 0x422E
// TODO: share these strings with usbconfig.h
// Edit usbconfig.h to change these.
#define MANUFACTURER TGR
#define PRODUCT TGR Alice

/* matrix size */
#define MATRIX_ROWS 6
#define MATRIX_COLS 15

#define RGBLED_NUM 20
#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)))

#endif
drashna marked this conversation as resolved.
Show resolved Hide resolved
106 changes: 106 additions & 0 deletions keyboards/alice/i2c.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
/*
drashna marked this conversation as resolved.
Show resolved Hide resolved
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;
}
27 changes: 27 additions & 0 deletions keyboards/alice/i2c.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
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
37 changes: 37 additions & 0 deletions keyboards/alice/keymaps/default/keymap.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
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 QMK_KEYBOARD_H

const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
[0] = LAYOUT(
KC_GESC, 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_GRV, KC_BSLS, \
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_BSPC, \
KC_LCTL, 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_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, MO(1), \
KC_LGUI, KC_LALT, KC_SPC, KC_LGUI, KC_SPC, KC_RALT, KC_RCTL, \
KC_ESC, KC_PGUP, KC_PGDN \
),
[1] = LAYOUT(
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, \
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_UP , _______, _______, \
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_LEFT, KC_RGHT, _______, \
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_DOWN, _______, _______, \
_______, _______, _______, _______, _______, _______, _______, \
_______, _______, _______ \
),
};
Loading