Backlight and RGB now working for JJ50 (#2929)

* Added support for JJ50 from KPRepublic, no rgb or backlight control yet. Added as a layout of ymd96 at the moment (same microprocessor). Basic keymap with three layers to get started.

* Added support for JJ50

* Tidied up jj50 code, backlight and RGB is now working.

* Renaming "KEYMAP" to "LAYOUT" to adhere to the new QMK standards.
This commit is contained in:
WarmCat 2018-05-10 16:28:58 +01:00 committed by Drashna Jaelre
parent c5264d6d89
commit 933842067d
13 changed files with 525 additions and 46 deletions

View file

@ -13,6 +13,8 @@ USB report options are supported.
Hardware Supported: JJ50 with the ATmega32a chip.
Hardware Availability: The JJ50 PCB is available from kprepublic on AliExpress and suchlike.
This version by Wayne K Jones (github.com/WarmCatUK)
## Installing and Building
@ -70,8 +72,10 @@ And flash the compiled hex file with `HIDBootFlash`. Simply put the board in fla
1. Try plugging the board in while pressing `Backspace` (`Key below the top right 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.
3. If you get an error such as "Resource Unavailable" when attemting to flash on Linux, you may want to compile and run `tools/usb_detach.c`. See `tools/README.md` for more info.
4. I was occasionally finding that I wasn't flashing changes that I was making to my keymap. If that happens, simply force rebuild by making with:
4. I was occasionally finding that I wasn't flashing changes that I was making to my keymap. If that happens, remove the previous build and simply force rebuild by making with:
```
$ rm jj50_default.hex
$ make -B jj50:default
$ make -B jj50:default:program
```

212
keyboards/jj50/backlight.c Normal file
View file

@ -0,0 +1,212 @@
/**
* Backlighting code for PS2AVRGB boards (ATMEGA32A)
* Kenneth A. (github.com/krusli | krusli.me)
*/
#include "backlight.h"
#include "quantum.h"
#include <avr/pgmspace.h>
#include <avr/interrupt.h>
#include "backlight_custom.h"
#include "breathing_custom.h"
// DEBUG
#include <stdlib.h>
#include <stdio.h>
// Port D: digital pins of the AVR chipset
#define NUMLOCK_PORT (1 << 1) // 1st pin of Port D (digital)
#define CAPSLOCK_PORT (1 << 2) // 2nd pin
#define BACKLIGHT_PORT (1 << 4) // 4th pin
#define SCROLLLOCK_PORT (1 << 6) // 6th pin
#define TIMER_CLK_DIV64 0x03 ///< Timer clocked at F_CPU/64
#define TIMER1PRESCALE TIMER_CLK_DIV64 ///< timer 1 prescaler default
#define TIMER_PRESCALE_MASK 0x07 ///< Timer Prescaler Bit-Mask
#define PWM_MAX 0xFF
#define TIMER_TOP 255 // 8 bit PWM
extern backlight_config_t backlight_config;
/**
* References
* Port Registers: https://www.arduino.cc/en/Reference/PortManipulation
* TCCR1A: https://electronics.stackexchange.com/questions/92350/what-is-the-difference-between-tccr1a-and-tccr1b
* Timers: http://www.avrbeginners.net/architecture/timers/timers.html
* 16-bit timer setup: http://sculland.com/ATmega168/Interrupts-And-Timers/16-Bit-Timer-Setup/
* PS2AVRGB firmware: https://github.com/showjean/ps2avrU/tree/master/firmware
*/
// @Override
// turn LEDs on and off depending on USB caps/num/scroll lock states.
void led_set_user(uint8_t usb_led) {
if (usb_led & (1 << USB_LED_NUM_LOCK)) {
// turn on
DDRD |= NUMLOCK_PORT;
PORTD |= NUMLOCK_PORT;
} else {
// turn off
DDRD &= ~NUMLOCK_PORT;
PORTD &= ~NUMLOCK_PORT;
}
if (usb_led & (1 << USB_LED_CAPS_LOCK)) {
DDRD |= CAPSLOCK_PORT;
PORTD |= CAPSLOCK_PORT;
} else {
DDRD &= ~CAPSLOCK_PORT;
PORTD &= ~CAPSLOCK_PORT;
}
if (usb_led & (1 << USB_LED_SCROLL_LOCK)) {
DDRD |= SCROLLLOCK_PORT;
PORTD |= SCROLLLOCK_PORT;
} else {
DDRD &= ~SCROLLLOCK_PORT;
PORTD &= ~SCROLLLOCK_PORT;
}
}
#ifdef BACKLIGHT_ENABLE
// sets up Timer 1 for 8-bit PWM
void timer1PWMSetup(void) { // NOTE ONLY CALL THIS ONCE
// default 8 bit mode
TCCR1A &= ~(1 << 1); // cbi(TCCR1A,PWM11); <- set PWM11 bit to HIGH
TCCR1A |= (1 << 0); // sbi(TCCR1A,PWM10); <- set PWM10 bit to LOW
// clear output compare value A
// outb(OCR1AH, 0);
// outb(OCR1AL, 0);
// clear output comparator registers for B
OCR1BH = 0; // outb(OCR1BH, 0);
OCR1BL = 0; // outb(OCR1BL, 0);
}
bool is_init = false;
void timer1Init(void) {
// timer1SetPrescaler(TIMER1PRESCALE)
// set to DIV/64
(TCCR1B) = ((TCCR1B) & ~TIMER_PRESCALE_MASK) | TIMER1PRESCALE;
// reset TCNT1
TCNT1H = 0; // outb(TCNT1H, 0);
TCNT1L = 0; // outb(TCNT1L, 0);
// TOIE1: Timer Overflow Interrupt Enable (Timer 1);
TIMSK |= _BV(TOIE1); // sbi(TIMSK, TOIE1);
is_init = true;
}
void timer1UnInit(void) {
// set prescaler back to NONE
(TCCR1B) = ((TCCR1B) & ~TIMER_PRESCALE_MASK) | 0x00; // TIMERRTC_CLK_STOP
// disable timer overflow interrupt
TIMSK &= ~_BV(TOIE1); // overflow bit?
setPWM(0);
is_init = false;
}
// handle TCNT1 overflow
//! Interrupt handler for tcnt1 overflow interrupt
ISR(TIMER1_OVF_vect, ISR_NOBLOCK)
{
// sei();
// handle breathing here
#ifdef BACKLIGHT_BREATHING
if (is_breathing()) {
custom_breathing_handler();
}
#endif
// TODO call user defined function
}
// enable timer 1 PWM
// timer1PWMBOn()
void timer1PWMBEnable(void) {
// turn on channel B (OC1B) PWM output
// set OC1B as non-inverted PWM
TCCR1A |= _BV(COM1B1);
TCCR1A &= ~_BV(COM1B0);
}
// disable timer 1 PWM
// timer1PWMBOff()
void timer1PWMBDisable(void) {
TCCR1A &= ~_BV(COM1B1);
TCCR1A &= ~_BV(COM1B0);
}
void enableBacklight(void) {
DDRD |= BACKLIGHT_PORT; // set digital pin 4 as output
PORTD |= BACKLIGHT_PORT; // set digital pin 4 to high
}
void disableBacklight(void) {
// DDRD &= ~BACKLIGHT_PORT; // set digital pin 4 as input
PORTD &= ~BACKLIGHT_PORT; // set digital pin 4 to low
}
void startPWM(void) {
timer1Init();
timer1PWMBEnable();
enableBacklight();
}
void stopPWM(void) {
timer1UnInit();
disableBacklight();
timer1PWMBDisable();
}
void b_led_init_ports(void) {
/* turn backlight on/off depending on user preference */
#if BACKLIGHT_ON_STATE == 0
// DDRx register: sets the direction of Port D
// DDRD &= ~BACKLIGHT_PORT; // set digital pin 4 as input
PORTD &= ~BACKLIGHT_PORT; // set digital pin 4 to low
#else
DDRD |= BACKLIGHT_PORT; // set digital pin 4 as output
PORTD |= BACKLIGHT_PORT; // set digital pin 4 to high
#endif
timer1PWMSetup();
startPWM();
#ifdef BACKLIGHT_BREATHING
breathing_enable();
#endif
}
void b_led_set(uint8_t level) {
if (level > BACKLIGHT_LEVELS) {
level = BACKLIGHT_LEVELS;
}
setPWM((int)(TIMER_TOP * (float) level / BACKLIGHT_LEVELS));
}
// called every matrix scan
void b_led_task(void) {
// do nothing for now
}
void setPWM(uint16_t xValue) {
if (xValue > TIMER_TOP) {
xValue = TIMER_TOP;
}
OCR1B = xValue; // timer1PWMBSet(xValue);
}
#endif // BACKLIGHT_ENABLE

View file

@ -0,0 +1,15 @@
/**
* Backlighting code for PS2AVRGB boards (ATMEGA32A)
* Kenneth A. (github.com/krusli | krusli.me)
*/
#ifndef BACKLIGHT_CUSTOM_H
#define BACKLIGHT_CUSTOM_H
#include <avr/pgmspace.h>
void b_led_init_ports(void);
void b_led_set(uint8_t level);
void b_led_task(void);
void setPWM(uint16_t xValue);
#endif // BACKLIGHT_CUSTOM_H

View file

@ -0,0 +1,140 @@
/**
* Breathing effect code for PS2AVRGB boards (ATMEGA32A)
* Works in conjunction with `backlight.c`.
*
* Code adapted from `quantum.c` to register with the existing TIMER1 overflow
* handler in `backlight.c` instead of setting up its own timer.
* Kenneth A. (github.com/krusli | krusli.me)
*/
#ifdef BACKLIGHT_ENABLE
#ifdef BACKLIGHT_BREATHING
#include "backlight_custom.h"
#ifndef BREATHING_PERIOD
#define BREATHING_PERIOD 6
#endif
#define breathing_min() do {breathing_counter = 0;} while (0)
#define breathing_max() do {breathing_counter = breathing_period * 244 / 2;} while (0)
// TODO make this share code with quantum.c
#define BREATHING_NO_HALT 0
#define BREATHING_HALT_OFF 1
#define BREATHING_HALT_ON 2
#define BREATHING_STEPS 128
static uint8_t breathing_period = BREATHING_PERIOD;
static uint8_t breathing_halt = BREATHING_NO_HALT;
static uint16_t breathing_counter = 0;
static bool breathing = false;
bool is_breathing(void) {
return breathing;
}
// See http://jared.geek.nz/2013/feb/linear-led-pwm
static uint16_t cie_lightness(uint16_t v) {
if (v <= 5243) // if below 8% of max
return v / 9; // same as dividing by 900%
else {
uint32_t y = (((uint32_t) v + 10486) << 8) / (10486 + 0xFFFFUL); // add 16% of max and compare
// to get a useful result with integer division, we shift left in the expression above
// and revert what we've done again after squaring.
y = y * y * y >> 8;
if (y > 0xFFFFUL) // prevent overflow
return 0xFFFFU;
else
return (uint16_t) y;
}
}
void breathing_enable(void) {
breathing = true;
breathing_counter = 0;
breathing_halt = BREATHING_NO_HALT;
// interrupt already registered
}
void breathing_pulse(void) {
if (get_backlight_level() == 0)
breathing_min();
else
breathing_max();
breathing_halt = BREATHING_HALT_ON;
// breathing_interrupt_enable();
breathing = true;
}
void breathing_disable(void) {
breathing = false;
// backlight_set(get_backlight_level());
b_led_set(get_backlight_level()); // custom implementation of backlight_set()
}
void breathing_self_disable(void)
{
if (get_backlight_level() == 0)
breathing_halt = BREATHING_HALT_OFF;
else
breathing_halt = BREATHING_HALT_ON;
}
void breathing_toggle(void) {
if (is_breathing())
breathing_disable();
else
breathing_enable();
}
void breathing_period_set(uint8_t value)
{
if (!value)
value = 1;
breathing_period = value;
}
void breathing_period_default(void) {
breathing_period_set(BREATHING_PERIOD);
}
void breathing_period_inc(void)
{
breathing_period_set(breathing_period+1);
}
void breathing_period_dec(void)
{
breathing_period_set(breathing_period-1);
}
/* To generate breathing curve in python:
* from math import sin, pi; [int(sin(x/128.0*pi)**4*255) for x in range(128)]
*/
static const uint8_t breathing_table[BREATHING_STEPS] PROGMEM = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 2, 3, 4, 5, 6, 8, 10, 12, 15, 17, 20, 24, 28, 32, 36, 41, 46, 51, 57, 63, 70, 76, 83, 91, 98, 106, 113, 121, 129, 138, 146, 154, 162, 170, 178, 185, 193, 200, 207, 213, 220, 225, 231, 235, 240, 244, 247, 250, 252, 253, 254, 255, 254, 253, 252, 250, 247, 244, 240, 235, 231, 225, 220, 213, 207, 200, 193, 185, 178, 170, 162, 154, 146, 138, 129, 121, 113, 106, 98, 91, 83, 76, 70, 63, 57, 51, 46, 41, 36, 32, 28, 24, 20, 17, 15, 12, 10, 8, 6, 5, 4, 3, 2, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
// Use this before the cie_lightness function.
static inline uint16_t scale_backlight(uint16_t v) {
return v / BACKLIGHT_LEVELS * get_backlight_level();
}
void custom_breathing_handler(void) {
uint16_t interval = (uint16_t) breathing_period * 244 / BREATHING_STEPS;
// resetting after one period to prevent ugly reset at overflow.
breathing_counter = (breathing_counter + 1) % (breathing_period * 244);
uint8_t index = breathing_counter / interval % BREATHING_STEPS;
if (((breathing_halt == BREATHING_HALT_ON) && (index == BREATHING_STEPS / 2)) ||
((breathing_halt == BREATHING_HALT_OFF) && (index == BREATHING_STEPS - 1)))
{
// breathing_interrupt_disable();
}
setPWM(cie_lightness(scale_backlight((uint16_t) pgm_read_byte(&breathing_table[index]) * 0x0101U)));
}
#endif // BACKLIGHT_BREATHING
#endif // BACKLIGHT_ENABLE

View file

@ -35,11 +35,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define MATRIX_COLS 15
#define DIODE_DIRECTION ROW2COL
#define BACKLIGHT_PIN D4
#define BACKLIGHT_LEVELS 3
//#define BACKLIGHT_PIN D4
#define BACKLIGHT_LEVELS 12
//#define RGB_DI_PIN C0
#define RGBLED_NUM 5
#define RGB_DI_PIN E2
#define RGBLED_NUM 12
#define RGBLIGHT_ANIMATIONS
#define RGBLIGHT_HUE_STEP 12
#define RGBLIGHT_SAT_STEP 15

View file

@ -16,7 +16,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "jj50.h"
#include "rgblight.h"
#include <avr/pgmspace.h>
@ -24,22 +23,72 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#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) {
b_led_init_ports();
}
void backlight_task(void) {
b_led_task();
}
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++) {
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) {
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) {
}

View file

@ -20,11 +20,14 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef KEYMAP_COMMON_H
#define KEYMAP_COMMON_H
#include "quantum.h"
#include "quantum_keycodes.h"
#include "keycode.h"
#include "action.h"
#define KEYMAP( \
void matrix_init_user(void);
#define LAYOUT( \
K011, K010, K009, K008, K004, K005, K006, K007, K003, K002, K201, K000, \
K111, K110, K109, K108, K104, K105, K106, K107, K103, K102, K001, K100, \
K211, K210, K209, K208, K204, K205, K206, K207, K203, K202, K101, K200, \

View file

@ -17,7 +17,7 @@ You should have received a copy of the GNU General Public LicensezZZ
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "jj50.h"
#include QMK_KEYBOARD_H
#include "action_layer.h"
#include "rgblight.h"
@ -25,9 +25,30 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define _DEFLT 0
#define _RAISE 1
#define _LOWER 2
#define _FN 3
enum custom_keycodes {
P_MACRO = SAFE_RANGE
};
// GBP £ Macro (sends alt 156 - windows users only)
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
if (record->event.pressed) {
switch(keycode) {
case P_MACRO:
SEND_STRING(SS_DOWN(X_LALT));
SEND_STRING(SS_TAP(X_KP_1));
SEND_STRING(SS_TAP(X_KP_5));
SEND_STRING(SS_TAP(X_KP_6));
SEND_STRING(SS_UP(X_LALT));
return false; break;
}
}
return true;
};
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
/* Qwerty
* ,-----------------------------------------------------------------------------------.
* | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | - | = |
@ -36,20 +57,19 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
* |------+------+------+------+------+------+------+------+------+------+------+------|
* | Esc | A | S | D | F | G | H | J | K | L | ; | " |
* |------+------+------+------+------+------+------+------+------+------+------+------|
* | Shift| Z | X | C | V | B | N | M | , | . | / |Enter |
* | Shift| Z | X | C | V | B | N | M | , | . | / |Enter | (Hold for shift / tap for enter)
* |------+------+------+------+------+------+------+------+------+------+------+------|
* | | Ctrl | Alt | GUI |Lower | Space |Raise | Left | Down | Up |Right |
* | _FN | Ctrl | Alt | GUI |Lower | Space |Raise | Left | Down | Up |Right |
* `-----------------------------------------------------------------------------------'
*/
[_DEFLT] = KEYMAP( \
[_DEFLT] = LAYOUT( \
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_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSPC, \
KC_ESC, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, \
KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, SFT_T(KC_ENT),\
BL_TOGG, KC_LCTL, KC_LALT, KC_LGUI, MO(_LOWER), KC_SPC,KC_SPC, MO(_RAISE),KC_LEFT, KC_DOWN, KC_UP, KC_RGHT \
MO(_FN), KC_LCTL, KC_LALT, KC_LGUI, MO(_LOWER),KC_SPC,KC_SPC,MO(_RAISE),KC_LEFT, KC_DOWN, KC_UP, KC_RGHT \
),
/* Raise
* ,-----------------------------------------------------------------------------------.
* | F1 | F2 | F3 | F4 | F5 | F6 | F7 | F8 | F9 | F10 | F11 | F12 |
@ -63,15 +83,15 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
* | | | | | | | | Next | Vol- | Vol+ | Play |
* `-----------------------------------------------------------------------------------'
*/
[_RAISE] = KEYMAP( \
[_RAISE] = LAYOUT( \
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_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_DEL, \
RESET, BL_INC, RGB_SAI, _______, _______, _______, _______, _______, _______, KC_LBRC, KC_RBRC, KC_BSLS, \
_______, BL_DEC, _______, _______, _______, _______, _______, KC_NUHS, KC_NUBS, KC_PGUP, KC_PGDN, _______, \
RESET, BL_INC, RGB_SAI, _______, _______, _______, _______, _______, _______, KC_LBRC, KC_RBRC, KC_BSLS, \
_______, BL_DEC, _______, _______, _______, _______, _______, KC_NUHS, KC_NUBS, KC_PGUP, KC_PGDN, _______, \
RGB_TOG, _______, _______, _______, _______, _______, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY \
),
/* Lower
* ,-----------------------------------------------------------------------------------.
* | F1 | F2 | F3 | F4 | F5 | F6 | F7 | F8 | F9 | F10 | F11 | F12 |
@ -85,12 +105,33 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
* | | | | | | | | Next | Vol- | Vol+ | Play |
* `-----------------------------------------------------------------------------------'
*/
[_LOWER] = KEYMAP( \
[_LOWER] = LAYOUT( \
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_TILD, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, KC_DEL, \
RESET, _______, _______, _______, _______, _______, _______, _______, _______, KC_LCBR, KC_RCBR, KC_PIPE, \
RESET, _______, _______, _______, _______, _______, _______, _______, _______, KC_LCBR, KC_RCBR, KC_PIPE, \
_______, _______, _______, _______, _______, _______, _______,S(KC_NUHS),S(KC_NUBS),KC_HOME, KC_END, _______, \
_______, _______, _______, _______, _______, _______, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY \
)
BL_STEP, _______, _______, _______, _______, _______, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY \
),
/* Fn
* ,-----------------------------------------------------------------------------------.
* | | | £ | | | | | | | | | |
* |------+------+------+------+------+------+------+------+------+------+------+------|
* | | | | | | | | | | | | |
* |------+------+------+------+------+------+------+------+------+------+------+------|
* | | | | | | | | | | | | |
* |------+------+------+------+------+------+------+------+------+------+------+------|
* | | | | | | | | | | | | |
* |------+------+------+------+------+------+------+------+------+------+------+------|
* | | | | | | | | |BL_OFF|BL_DEC|BL_INC|BL_ON |
* `-----------------------------------------------------------------------------------'
*/
[_FN] = LAYOUT( \
_______, _______, P_MACRO, _______, _______, _______, _______, _______, _______, _______, _______, _______, \
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, \
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, \
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, \
_______, _______, _______, _______, _______, _______, _______, _______, BL_OFF, BL_DEC, BL_INC, BL_ON \
)
};

View file

@ -1,5 +1,6 @@
/*
Copyright 2017 Luiz Ribeiro <luizribeiro@gmail.com>
Modified 2018 by Wayne K Jones <github.com/WarmCatUK>
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
@ -36,17 +37,20 @@ void matrix_init(void) {
// all inputs for columns
DDRA = 0x00;
DDRC &= ~(0x111111<<2);
DDRD &= ~(1<<PIND7);
//----> DDRD &= ~(1<<PIND7);
// Port D not used on this keyboard
// all columns are pulled-up
PORTA = 0xFF;
PORTC |= (0b111111<<2);
//PORTD |= (1<<PIND7);
// Port D not used on this keyboard
// initialize matrix state: all keys off
for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
matrix[row] = 0x00;
matrix_debouncing[row] = 0x00;
}
matrix_init_quantum(); // missing from original port by Luiz
}
void matrix_set_row_status(uint8_t row) {
@ -72,9 +76,6 @@ uint8_t matrix_scan(void) {
) | (
// cols 8..13, PORTC 7 -> 0
bit_reverse((~PINC) & 0xFF) << 8
) | (
// col 14, PORTD 7
((~PIND) & (1 << PIND7)) << 7
);
if (matrix_debouncing[row] != cols) {
@ -92,8 +93,8 @@ uint8_t matrix_scan(void) {
}
}
}
matrix_scan_user();
matrix_scan_quantum(); // also missing in original PS2AVRGB implementation
//matrix_scan_user();
return 1;
}

View file

@ -36,16 +36,30 @@ BOOTMAGIC_ENABLE = yes
MOUSEKEY_ENABLE = no
EXTRAKEY_ENABLE = yes
CONSOLE_ENABLE = no
COMMAND_ENABLE = no
COMMAND_ENABLE = yes
BACKLIGHT_ENABLE = yes
RGBLIGHT_ENABLE = yes
RGBLIGHT_CUSTOM_DRIVER = yes
NKRO_ENABLE = no
# Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work
OPT_DEFS = -DDEBUG_LEVEL=0
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
SRC = matrix.c i2c.c backlight.c
ifndef QUANTUM_DIR
include ../../../../Makefile
endif
# programming options
PROGRAM_CMD = ./keyboards/ps2avrGB/program $(TARGET).hex

View file

@ -241,8 +241,8 @@ section at the end of this file).
#define USB_CFG_DEVICE_VERSION 0x00, 0x02
/* Version number of the device: Minor number first, then major number.
*/
#define USB_CFG_VENDOR_NAME 'w', 'i', 'n', 'k', 'e', 'y', 'l', 'e', 's', 's', '.', 'k', 'r'
#define USB_CFG_VENDOR_NAME_LEN 13
#define USB_CFG_VENDOR_NAME 'K', 'P', 'R', 'e', 'p', 'u', 'b', 'l', 'i', 'c'
#define USB_CFG_VENDOR_NAME_LEN 10
/* These two values define the vendor name returned by the USB device. The name
* must be given as a list of characters under single quotes. The characters
* are interpreted as Unicode (UTF-16) entities.
@ -251,8 +251,8 @@ section at the end of this file).
* obdev's free shared VID/PID pair. See the file USB-IDs-for-free.txt for
* details.
*/
#define USB_CFG_DEVICE_NAME 'p', 's', '2', 'a', 'v', 'r', 'G', 'B'
#define USB_CFG_DEVICE_NAME_LEN 8
#define USB_CFG_DEVICE_NAME 'J','J','5','0',' ','K','e','y','b','o','a','r','d'
#define USB_CFG_DEVICE_NAME_LEN 13
/* Same as above for the device name. If you don't want a device name, undefine
* the macros. See the file USB-IDs-for-free.txt before you assign a name if
* you use a shared VID/PID.

View file

@ -41,7 +41,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
* | | Ctrl | Alt | GUI |Lower | Space |Raise | Left | Down | Up |Right |
* `-----------------------------------------------------------------------------------'
*/
[_DEFLT] = KEYMAP_JJ50( \
[_DEFLT] = LAYOUT_jj50( \
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_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSPC, \
KC_ESC, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, \
@ -63,7 +63,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
* | | | | | | | | Next | Vol- | Vol+ | Play |
* `-----------------------------------------------------------------------------------'
*/
[_RAISE] = KEYMAP_JJ50( \
[_RAISE] = LAYOUT_jj50( \
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_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_DEL, \
_______, _______, _______, _______, _______, _______, _______, _______, _______, KC_LBRC, KC_RBRC, KC_BSLS, \
@ -85,7 +85,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
* | | | | | | | | Next | Vol- | Vol+ | Play |
* `-----------------------------------------------------------------------------------'
*/
[_LOWER] = KEYMAP_JJ50( \
[_LOWER] = LAYOUT_jj50( \
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_TILD, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, KC_DEL, \
_______, _______, _______, _______, _______, _______, _______, _______, _______, KC_LCBR, KC_RCBR, KC_PIPE, \

View file

@ -41,7 +41,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
{ K700, K701, K702, K703, K704, K705, K706, KC_NO, K708, K709, K710, K711, K712, K713, K714 } \
}
#define KEYMAP_JJ50( \
#define LAYOUT_jj50( \
K011, K010, K009, K008, K004, K005, K006, K007, K003, K002, K201, K000, \
K111, K110, K109, K108, K104, K105, K106, K107, K103, K102, K001, K100, \
K211, K210, K209, K208, K204, K205, K206, K207, K203, K202, K101, K200, \