-
-
Notifications
You must be signed in to change notification settings - Fork 40.5k
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
Adds Gray Studio HB85 Initial Support #5311
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
60b892b
Gray Studio HB85 Initial Support
fcoury 55281b9
Fixed README image
fcoury dde7761
Updated README
fcoury 4fce251
Disabled Bootmagic and Console for HB85
fcoury e3988bd
Fixed Numpad 4 matrix place
fcoury 2f7dc00
Fixes board crashing with RGB enabled
fcoury 5532c6d
Moved HB85 files to gray_studio folder
fcoury 1b07a98
Uses old i2c library since this version makes RGB underglow work
fcoury 0b375f8
Improved default keymap with underglow control layer
fcoury 37f0d58
Removes obsolete program and uses generic script instead
fcoury 7864215
Uses GPIO Functions to initialise and set RGB underglow PINS
fcoury File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
Copyright 2017 Luiz Ribeiro <[email protected]> | ||
|
||
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/>. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#define VENDOR_ID 0x20A0 | ||
#define PRODUCT_ID 0x422F | ||
// TODO: share these strings with usbconfig.h | ||
// Edit usbconfig.h to change these. | ||
#define MANUFACTURER Gray Studio | ||
#define PRODUCT HB85 | ||
|
||
/* matrix size */ | ||
#define MATRIX_ROWS 8 | ||
#define MATRIX_COLS 15 | ||
|
||
#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 DIODE_DIRECTION COL2ROW | ||
|
||
#define RGBLED_NUM 5 | ||
#define RGBLIGHT_ANIMATIONS | ||
|
||
#define NO_UART 1 | ||
#define BOOTLOADHID_BOOTLOADER 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
/* | ||
Copyright 2017 Luiz Ribeiro <[email protected]> | ||
|
||
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 <string.h> | ||
|
||
#include "rgblight.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 backlight_init_ports(void) { | ||
// initialize pins D0, D1, D4 and D6 as output | ||
setPinOutput(D0); | ||
setPinOutput(D1); | ||
setPinOutput(D4); | ||
setPinOutput(D6); | ||
|
||
// turn RGB LEDs on | ||
writePinHigh(D0); | ||
writePinHigh(D1); | ||
writePinHigh(D4); | ||
writePinHigh(D6); | ||
} | ||
|
||
void backlight_set(uint8_t level) { | ||
if (level == 0) { | ||
// turn RGB LEDs off | ||
writePinLow(D0); | ||
writePinLow(D1); | ||
writePinLow(D4); | ||
writePinLow(D6); | ||
} else { | ||
// turn RGB LEDs on | ||
writePinHigh(D0); | ||
writePinHigh(D1); | ||
writePinHigh(D4); | ||
writePinHigh(D6); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
Copyright 2017 Luiz Ribeiro <[email protected]> | ||
|
||
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/>. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include "quantum.h" | ||
|
||
#define LAYOUT( \ | ||
K12, K11, K10, K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K13, \ | ||
K28, K27, K26, K25, K24, K14, K15, K16, K17, K18, K19, K20, K21, K22, K23, K77, K76, K75, \ | ||
K43, K42, K41, K40, K39, K29, K30, K31, K32, K33, K34, K35, K36, K37, K38, K74, K73, \ | ||
K57, K56, K55, K54, K53, K44, K45, K46, K47, K48, K49, K50, K51, K52, K88, K87, \ | ||
K72, K71, K70, K69, K68, K58, K59, K60, K61, K62, K63, K66, K64, K65, K67, K90, K89, \ | ||
K86, K85, K78, K79, K80, K81, K82, K83, K84, K91 \ | ||
) \ | ||
{ \ | ||
{ K00 , K01 , K02 , K03 , K04 , K05 , K06 , K07 , K08 , K09 , K10 , K11 , K12 , KC_NO, 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 , KC_NO, K52 , K53 , K54 , K55 , K56 , K57 }, \ | ||
{ K58 , K59 , K60 , K61 , K62 , K63 , K64 , K65 , K66 , K67 , K68 , K69 , K70 , K71 , K72 }, \ | ||
{ KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, K73 , K74 , K75 , K76 , K77 , KC_NO, KC_NO, KC_NO, KC_NO, KC_NO }, \ | ||
{ KC_NO, K78 , KC_NO, KC_NO, K79 , K80 , K81 , K82 , K83 , K84 , KC_NO, KC_NO, K85 , K86 , KC_NO }, \ | ||
{ KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, K87 , K88 , K89 , K90 , K91 , KC_NO, KC_NO, KC_NO, KC_NO, KC_NO } \ | ||
} | ||
|
||
// F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F2 F1 ESC FN | ||
// 5 6 7 8 9 0 - = BS BS 4 3 2 1 ~ | ||
// T Y U I O P [ ] | PAD7 R E W Q Tab | ||
// G H J K L ; ' ENTR PAD4 F D S A CAPS | ||
// V B N M , . RSFT UP / PAD1 C X Z EUR2 LSFT | ||
// PAD9 PAD8 PAD- PAD* PAD/ | ||
// SPC RALT RCTL LEFT DOWN RGHT PAD0 LALT LGUI | ||
// PAD6 PAD5 PAD3 PAD2 PAD. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
/* | ||
Copyright 2016 Luiz Ribeiro <[email protected]> | ||
|
||
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
Copyright 2016 Luiz Ribeiro <[email protected]> | ||
|
||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
Copyright 2017 Luiz Ribeiro <[email protected]> | ||
|
||
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 | ||
|
||
// Layer shorthand | ||
enum layers { | ||
_BASE = 0, // Base | ||
_CTRL // Multimedia and RGB | ||
}; | ||
|
||
#define KC_TGCT MO(_CTRL) // Toggles CTRL layer | ||
|
||
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | ||
[_BASE] = LAYOUT( | ||
KC_ESC , 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_TGCT, \ | ||
KC_GRV , 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_BSPC, KC_PSLS, KC_PAST, KC_PMNS, \ | ||
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_P7 , KC_P8 , KC_P9 , \ | ||
KC_CAPS, 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_P4 , KC_P5 , KC_P6 , \ | ||
KC_LSFT, KC_NO , KC_Z , KC_Z , KC_X , KC_V , KC_B , KC_N , KC_M , KC_COMM, KC_DOT , KC_SLSH, KC_RSFT, KC_UP , KC_P1 , KC_P2 , KC_P3 , \ | ||
KC_LCTL, KC_LALT, KC_SPC , KC_RALT, KC_RGUI, KC_LEFT, KC_DOWN, KC_RGHT, KC_P0 , KC_PDOT \ | ||
), | ||
|
||
[_CTRL] = LAYOUT( | ||
RESET , _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, \ | ||
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, \ | ||
_______, RGB_TOG, RGB_MOD, RGB_HUI, RGB_HUD, RGB_SAI, RGB_SAD, RGB_VAI, RGB_VAD, _______, _______, _______, _______, _______, _______, _______, _______, \ | ||
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, \ | ||
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, \ | ||
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______ \ | ||
), | ||
}; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cries in i2c