Skip to content

Commit

Permalink
Add elephant42 keyboard (#14336)
Browse files Browse the repository at this point in the history
  • Loading branch information
diastremskii authored Jul 2, 2022
1 parent fd44341 commit f2f88bc
Show file tree
Hide file tree
Showing 12 changed files with 783 additions and 0 deletions.
93 changes: 93 additions & 0 deletions keyboards/elephant42/config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
/*
Copyright 2021 illness072
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 "config_common.h"

/* USB Device descriptor parameter */
#define VENDOR_ID 0x4649
#define PRODUCT_ID 0x0721
#define DEVICE_VER 0x0001
#define MANUFACTURER illness072
#define PRODUCT elephant42

/* key matrix size */
#define MATRIX_ROWS 8
#define MATRIX_COLS 6

/*
* Keyboard Matrix Assignments
*
* Change this to how you wired your keyboard
* COLS: AVR pins used for columns, left to right
* ROWS: AVR pins used for rows, top to bottom
* DIODE_DIRECTION: COL2ROW = COL = Anode (+), ROW = Cathode (-, marked on diode)
* ROW2COL = ROW = Anode (+), COL = Cathode (-, marked on diode)
*
*/
#define MATRIX_ROW_PINS \
{ D4, C6, D7, E6 }
#define MATRIX_COL_PINS \
{ F4, F5, F6, F7, B1, B3 }
#define UNUSED_PINS

/* COL2ROW, ROW2COL */
#define DIODE_DIRECTION COL2ROW

#define SOFT_SERIAL_PIN D2

#define RGB_DI_PIN D3
#ifdef RGB_DI_PIN
# define RGBLED_SPLIT { 27, 27 }
# define RGBLED_NUM 54 // backlight x42 + underglow x12
# define RGBLIGHT_HUE_STEP 8
# define RGBLIGHT_SAT_STEP 8
# define RGBLIGHT_VAL_STEP 8
# define RGBLIGHT_LIMIT_VAL 170 /* The maximum brightness level */
# define RGBLIGHT_EFFECT_BREATHING
# define RGBLIGHT_EFFECT_RAINBOW_MOOD
# define RGBLIGHT_EFFECT_RAINBOW_SWIRL
# define RGBLIGHT_EFFECT_SNAKE
# define RGBLIGHT_EFFECT_KNIGHT
# define RGBLIGHT_EFFECT_CHRISTMAS
# define RGBLIGHT_EFFECT_STATIC_GRADIENT
# define RGBLIGHT_EFFECT_RGB_TEST
# define RGBLIGHT_EFFECT_ALTERNATING
# define RGBLIGHT_EFFECT_TWINKLE
#endif

#ifdef RGB_MATRIX_ENABLE
# define SPLIT_TRANSPORT_MIRROR
# define DRIVER_LED_TOTAL RGBLED_NUM
# define RGB_MATRIX_SPLIT RGBLED_SPLIT
# define RGB_MATRIX_MAXIMUM_BRIGHTNESS RGBLIGHT_LIMIT_VAL
# define RGB_MATRIX_HUE_STEP RGBLIGHT_HUE_STEP
# define RGB_MATRIX_SAT_STEP RGBLIGHT_SAT_STEP
# define RGB_MATRIX_VAL_STEP RGBLIGHT_VAL_STEP
# define RGB_MATRIX_SPD_STEP 8
#endif

/* Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not needed */
#define DEBOUNCE 5

/* define if matrix has ghost (lacks anti-ghosting diodes) */
//#define MATRIX_HAS_GHOST

#ifndef OLED_FONT_H
# define OLED_FONT_H "keyboards/elephant42/lib/glcdfont.c"
#endif
66 changes: 66 additions & 0 deletions keyboards/elephant42/elephant42.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/* Copyright 2021 illness072
*
* 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 "elephant42.h"

#if defined(RGB_MATRIX_ENABLE)
led_config_t g_led_config = {
{ // keymap to LED number
// left
{ 19, 18, 13, 12, 7, 6}, // R3
{ 20, 17, 14, 11, 8, 5}, // R2
{NO_LED, 16, 15, 10, 9, 4}, // R1
{NO_LED, NO_LED, 0, 1, 2, 3}, // R0
// right
{ 46, 45, 40, 39, 34, 33}, // R3
{ 47, 44, 41, 38, 35, 32}, // R2
{NO_LED, 43, 42, 37, 36, 31}, // R1
{NO_LED, NO_LED, 27, 28, 29, 30}, // R0
},
{// phisical LED position, {x, y} : x = 0..224, y = 0..64
// left-bg [LED_01-21]
{56, 65}, {77, 68}, {95, 79}, {109, 91},
{87, 46}, {87, 29}, {87, 12}, { 69, 43}, { 69, 26}, { 69, 8},
{52, 35}, {52, 17}, {52, 0}, { 35, 4}, { 35, 21}, { 35, 38},
{17, 54}, {17, 36}, {17, 19}, { 0, 26}, { 0, 43},
// left-ug [LED_22-27]
{25, 49}, {26, 19}, {60, 14}, {106, 33}, {107, 72}, { 70, 66},
// right-bg [LED_28-48]
{199, 65}, {179, 68}, {160, 79}, {146, 91},
{168, 46}, {168, 29}, {168, 12}, {186, 43}, {186, 26}, {186, 8},
{203, 35}, {203, 17}, {203, 0}, {220, 4}, {220, 21}, {220, 38},
{238, 54}, {238, 36}, {238, 19}, {255, 26}, {255, 43},
// right-ug [LED_49-54]
{230, 49}, {230, 19}, {195, 14}, {149, 33}, {148, 72}, {185, 66},
},
{// LED Index to Flag
// Left-bg [LED_01-21]
LED_FLAG_KEYLIGHT, LED_FLAG_KEYLIGHT, LED_FLAG_KEYLIGHT, LED_FLAG_KEYLIGHT, LED_FLAG_KEYLIGHT, LED_FLAG_KEYLIGHT,
LED_FLAG_KEYLIGHT, LED_FLAG_KEYLIGHT, LED_FLAG_KEYLIGHT, LED_FLAG_KEYLIGHT, LED_FLAG_KEYLIGHT, LED_FLAG_KEYLIGHT,
LED_FLAG_KEYLIGHT, LED_FLAG_KEYLIGHT, LED_FLAG_KEYLIGHT, LED_FLAG_KEYLIGHT, LED_FLAG_KEYLIGHT, LED_FLAG_KEYLIGHT,
LED_FLAG_KEYLIGHT, LED_FLAG_KEYLIGHT, LED_FLAG_KEYLIGHT,
// left-ug [LED_22-27]
LED_FLAG_UNDERGLOW, LED_FLAG_UNDERGLOW, LED_FLAG_UNDERGLOW, LED_FLAG_UNDERGLOW, LED_FLAG_UNDERGLOW, LED_FLAG_UNDERGLOW,
// right-bg [LED_28-48]
LED_FLAG_KEYLIGHT, LED_FLAG_KEYLIGHT, LED_FLAG_KEYLIGHT, LED_FLAG_KEYLIGHT, LED_FLAG_KEYLIGHT, LED_FLAG_KEYLIGHT,
LED_FLAG_KEYLIGHT, LED_FLAG_KEYLIGHT, LED_FLAG_KEYLIGHT, LED_FLAG_KEYLIGHT, LED_FLAG_KEYLIGHT, LED_FLAG_KEYLIGHT,
LED_FLAG_KEYLIGHT, LED_FLAG_KEYLIGHT, LED_FLAG_KEYLIGHT, LED_FLAG_KEYLIGHT, LED_FLAG_KEYLIGHT, LED_FLAG_KEYLIGHT,
LED_FLAG_KEYLIGHT, LED_FLAG_KEYLIGHT, LED_FLAG_KEYLIGHT,
// right-ug [LED_49-54]
LED_FLAG_UNDERGLOW, LED_FLAG_UNDERGLOW, LED_FLAG_UNDERGLOW, LED_FLAG_UNDERGLOW, LED_FLAG_UNDERGLOW, LED_FLAG_UNDERGLOW
}
};
#endif
35 changes: 35 additions & 0 deletions keyboards/elephant42/elephant42.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/* Copyright 2021 illness072
*
* 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( \
L00, L01, L02, L03, L04, L05, R00, R01, R02, R03, R04, R05, \
L10, L11, L12, L13, L14, L15, R10, R11, R12, R13, R14, R15, \
L21, L22, L23, L24, L25, R20, R21, R22, R23, R24, \
L30, L31, L32, L33, R30, R31, R32, R33 \
) { \
{ L00, L01, L02, L03, L04, L05 }, \
{ L10, L11, L12, L13, L14, L15 }, \
{ KC_NO, L21, L22, L23, L24, L25 }, \
{ KC_NO, KC_NO, L30, L31, L32, L33 }, \
{ R05, R04, R03, R02, R01, R00 }, \
{ R15, R14, R13, R12, R11, R10 }, \
{ KC_NO, R24, R23, R22, R21, R20 }, \
{ KC_NO, KC_NO, R33, R32, R31, R30 } \
}
60 changes: 60 additions & 0 deletions keyboards/elephant42/info.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
{
"keyboard_name": "elephant42",
"url": "https://github.com/qmk/qmk_firmware/tree/master/keyboards/elephant42",
"maintainer": "illness072",
"layouts": {
"LAYOUT": {
"layout": [
{"label":"Tab", "x":0, "y":1.6},
{"label":"Q", "x":1, "y":1.1},
{"label":"W", "x":2, "y":0.3},
{"label":"E", "x":3, "y":0},
{"label":"R", "x":4, "y":0.6},
{"label":"T", "x":5, "y":0.8},

{"label":"Y", "x":10.5, "y":0.8},
{"label":"U", "x":11.5, "y":0.6},
{"label":"I", "x":12.5, "y":0},
{"label":"O", "x":13.5, "y":0.3},
{"label":"P", "x":14.5, "y":1.1},
{"label":"\\", "x":15.5, "y":1.6},

{"label":"Ctrl", "x":0, "y":2.6},
{"label":"A", "x":1, "y":2.1},
{"label":"S", "x":2, "y":1.3},
{"label":"D", "x":3, "y":1},
{"label":"F", "x":4, "y":1.6},
{"label":"G", "x":5, "y":1.8},

{"label":"H", "x":10.5, "y":1.8},
{"label":"J", "x":11.5, "y":1.6},
{"label":"K", "x":12.5, "y":1},
{"label":"L", "x":13.5, "y":1.3},
{"label":":", "x":14.5, "y":2.1},
{"label":"\"", "x":15.5, "y":2.6},

{"label":"Z", "x":1, "y":3.1},
{"label":"X", "x":2, "y":2.3},
{"label":"C", "x":3, "y":2},
{"label":"V", "x":4, "y":2.6},
{"label":"B", "x":5, "y":2.8},

{"label":"N", "x":10.5, "y":2.8},
{"label":"M", "x":11.5, "y":2.6},
{"label":"<", "x":12.5, "y":2},
{"label":">", "x":13.5, "y":2.3},
{"label":"?", "x":14.5, "y":3.1},

{"label":"Alt", "x":3.5, "y":4.0},
{"label":"Cmd", "x":4.5, "y":4.0},
{"label":"Lower", "x":5.5, "y":4.0},
{"label":"Shift", "x":6.5, "y":4.0},

{"label":"Del", "x":9.25, "y":4.0},
{"label":"Raise", "x":10.25, "y":4.0},
{"label":"Enter", "x":11.25, "y":4.0},
{"label":"Backspace", "x":12.25, "y":4.0}
]
}
}
}
114 changes: 114 additions & 0 deletions keyboards/elephant42/keymaps/default/keymap.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
/* Copyright 2021 illness072
*
* 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

#define KC_VU KC_AUDIO_VOL_UP
#define KC_VD KC_AUDIO_VOL_DOWN
#define KC_MU KC_AUDIO_MUTE
#define KC_LSPC LT(_LOWER, KC_SPC)
#define KC_RSPC LT(_RAISE, KC_SPC)

enum layer_names {
_QWERTY,
_LOWER,
_RAISE,

NUMBER_OF_LAYERS
};

const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
[_QWERTY] = LAYOUT( \
//,-------+-------+-------+-------+-------+-------. ,-------+-------+-------+-------+-------+-------.
KC_TAB , KC_Q , KC_W , KC_E , KC_R , KC_T , KC_Y , KC_U , KC_I , KC_O , KC_P ,KC_BSLS,
//|-------+-------+-------+-------+-------+-------| |-------+-------+-------+-------+-------+-------|
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_Z , KC_X , KC_C , KC_V , KC_B , KC_N , KC_M ,KC_COMM,KC_DOT ,KC_SLSH,
// `-------+-------+-------+-------+-------+-------+-------. ,-------+-------+-------+-------+-------+-------+-------'
KC_LALT,KC_LCMD,KC_LSPC,KC_LSFT, KC_DEL ,KC_RSPC,KC_ENT ,KC_BSPC
// `-------+-------+-------+-------' `-------+-------+-------+-------'
),

[_LOWER] = LAYOUT(
//,-------+-------+-------+-------+-------+-------. ,-------+-------+-------+-------+-------+-------.
KC_ESC , KC_1 , KC_2 , KC_3 , KC_4 , KC_5 , KC_6 , KC_7 , KC_8 , KC_9 , KC_0 ,KC_TILD,
//|-------+-------+-------+-------+-------+-------| |-------+-------+-------+-------+-------+-------|
KC_LCTL,KC_EXLM,KC_AT ,KC_HASH,KC_DLR ,KC_PERC, KC_CIRC,KC_AMPR,KC_ASTR,KC_MINS,KC_PLUS,KC_GRV,
//`-------+-------+-------+-------+-------+-------| |-------+-------+-------+-------+-------+-------|
XXXXXXX,XXXXXXX,KC_LCBR,KC_LBRC,KC_LPRN, KC_RPRN,KC_RBRC,KC_RCBR,KC_UNDS,KC_EQL ,
// `-------+-------+-------+-------+-------+-------+-------. ,-------+-------+-------+-------+-------+-------+-------'
KC_LALT,KC_LCMD,KC_LSPC,KC_LSFT, KC_DEL ,KC_RSPC,KC_ENT ,KC_BSPC
// `-------+-------+-------+-------' `-------+-------+-------+-------'
),

[_RAISE] = 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_LCTL, KC_VD , KC_VU , KC_MU ,RGB_HUI,RGB_VAI, KC_LEFT,KC_DOWN, KC_UP ,KC_RGHT,XXXXXXX,KC_F12 ,
//`-------+-------+-------+-------+-------+-------| |-------+-------+-------+-------+-------+-------'
KC_BRMD,KC_BRMU,RGB_TOG,RGB_MOD,RGB_VAD, KC_HOME,KC_PGDN,KC_PGUP,KC_END ,XXXXXXX,
// `-------+-------+-------+-------+-------+-------+-------. ,-------+-------+-------+-------+-------+-------+-------'
KC_LALT,KC_LCMD,KC_LSPC,KC_LSFT, KC_DEL ,KC_RSPC,KC_ENT ,KC_BSPC
// `-------+-------+-------+-------' `-------+-------+-------+-------'
)
};


#ifdef OLED_ENABLE
# define STEPS 32

uint8_t keypresses = 0;

bool process_record_user(uint16_t keycode, keyrecord_t *record) {
if (record->event.pressed) {
keypresses = (keypresses + 1) % STEPS;
}
return true;
}

bool oled_task_user(void) {
if (is_keyboard_master()) {
static char layer_names[NUMBER_OF_LAYERS][10] = {"Default", "Lower", "Raise"};
static char l1[] = " \x94\x95\x96\x97";
static char l2[] = " \xB4\xB5\xB6\xB7";
static char r1[] = " \x98\x99\x9A\x9B";
static char r2[] = " \xB8\xB9\xBA\xBB";
int iconShift = keypresses % STEPS;
if (iconShift > STEPS / 2) {
iconShift = STEPS - iconShift;
}
bool goingLeft = keypresses < STEPS / 2;

oled_write_P(PSTR("Layer: "), false);
oled_write_ln(layer_names[get_highest_layer(layer_state)], false);
oled_advance_page(true);
oled_write_ln((goingLeft ? l1 : r1) + iconShift, false);
oled_write_ln((goingLeft ? l2 : r2) + iconShift, false);
} else {
oled_advance_page(true);
static const char PROGMEM logo[] = {
0x8f,0x90,0x91,0x92,0x93,0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8a,0x8b,0x8c,0x8d,0x8e,0x0a,
0xaf,0xb0,0xb1,0xb2,0xb3,0xa0,0xa1,0xa2,0xa3,0xa4,0xa5,0xa6,0xa7,0xa8,0xa9,0xaa,0xab,0xac,0xad,0xae,0x0a,
0xcf,0xd0,0xd1,0xd2,0xd3,0xc0,0xc1,0xc2,0xc3,0xc4,0xc5,0xc6,0xc7,0xc8,0xc9,0xca,0xcb,0xcc,0xcd,0xce,0
};

oled_write_ln_P(logo, false);
}

return false;
}
#endif
1 change: 1 addition & 0 deletions keyboards/elephant42/keymaps/default/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# The default keymap for elephant42
Loading

0 comments on commit f2f88bc

Please sign in to comment.