summaryrefslogtreecommitdiff
path: root/keyboards/crkbd
diff options
context:
space:
mode:
authorQMK Bot <hello@qmk.fm>2021-04-10 00:38:17 +0000
committerQMK Bot <hello@qmk.fm>2021-04-10 00:38:17 +0000
commit29d537ce7b9b9770d99b0244793b6bc159d8a435 (patch)
tree6286d9e012bd89a4e267a23f41f1c31cf0b63d24 /keyboards/crkbd
parent688fb1999b339d20ba8cd173d6dc7c53754d4ba0 (diff)
parent3dbb7f261dab573a3b55390394444ac3ceb3d257 (diff)
Merge remote-tracking branch 'origin/master' into develop
Diffstat (limited to 'keyboards/crkbd')
-rw-r--r--keyboards/crkbd/keymaps/edvorakjp/config.h26
-rw-r--r--keyboards/crkbd/keymaps/edvorakjp/keymap.c121
-rw-r--r--keyboards/crkbd/keymaps/edvorakjp/oled.c107
-rw-r--r--keyboards/crkbd/keymaps/edvorakjp/oled.h25
-rw-r--r--keyboards/crkbd/keymaps/edvorakjp/rules.mk12
5 files changed, 117 insertions, 174 deletions
diff --git a/keyboards/crkbd/keymaps/edvorakjp/config.h b/keyboards/crkbd/keymaps/edvorakjp/config.h
index b8662aca09..8787ba88d3 100644
--- a/keyboards/crkbd/keymaps/edvorakjp/config.h
+++ b/keyboards/crkbd/keymaps/edvorakjp/config.h
@@ -1,25 +1,25 @@
-#ifndef CONFIG_USER_H
-#define CONFIG_USER_H
+#pragma once
/* Select hand configuration */
-// #define MASTER_LEFT
-#define MASTER_RIGHT
+#define MASTER_LEFT
+// #define MASTER_RIGHT
// #define EE_HANDS
-#define SSD1306OLED
#define SWAP_SCLN
// #define TAPPING_FORCE_HOLD
#define TAPPING_TERM 300
#define IGNORE_MOD_TAP_INTERRUPT
-#undef RGBLED_NUM
-#define RGBLIGHT_EFFECT_STATIC_GRADIENT
-#define RGBLED_NUM 27
-#define RGBLIGHT_LIMIT_VAL 100
-#define RGBLIGHT_HUE_STEP 10
-#define RGBLIGHT_SAT_STEP 17
-#define RGBLIGHT_VAL_STEP 17
+#ifdef RGBLIGHT_ENABLE
+# undef RGBLED_NUM
+# define RGBLIGHT_EFFECT_STATIC_GRADIENT
+# define RGBLED_NUM 27
+# define RGBLIGHT_LIMIT_VAL 100
+# define RGBLIGHT_HUE_STEP 10
+# define RGBLIGHT_SAT_STEP 17
+# define RGBLIGHT_VAL_STEP 17
+#endif // RGBLIGHT_ENABLE
-#endif // CONFIG_USER_H
+#define OLED_FONT_H "keyboards/crkbd/lib/glcdfont.c"
diff --git a/keyboards/crkbd/keymaps/edvorakjp/keymap.c b/keyboards/crkbd/keymaps/edvorakjp/keymap.c
index 32001f22da..5e56da61a9 100644
--- a/keyboards/crkbd/keymaps/edvorakjp/keymap.c
+++ b/keyboards/crkbd/keymaps/edvorakjp/keymap.c
@@ -1,9 +1,6 @@
#include QMK_KEYBOARD_H
#ifdef PROTOCOL_LUFA
- #include "split_util.h"
-#endif
-#ifdef SSD1306OLED
- #include "oled.h"
+# include "split_util.h"
#endif
#include "edvorakjp.h"
@@ -14,85 +11,63 @@
* };
*/
-#define KC_ KC_TRNS
-
-#define KC_TMB1 KC_LA(TAB)
-#define KC_TMB2 KC_LS(SPC)
-#define KC_TMB3 TD(TD_LOWER) // act as LOWER when hold, as KC_LANG2(=English) when tapped
-#define KC_TMB4 TD(TD_RAISE) // act as RAISE when hold, as KC_LANG1(=Japanese) when tapped
-#define KC_TMB5 KC_RC(BSPC)
-#define KC_TMB6 KC_RG(ENT)
-#define KC_TMB7 KC_RC(DEL)
+#define LAYOUT_wrapper(...) LAYOUT_split_3x6_3(__VA_ARGS__)
+// clang-format off
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
-
- [_EDVORAK] = LAYOUT_kc(
- //|----+----+-----+-----+-----+----| |----+-----+-----+-----+----+----|
- GRV ,QUOT,COMM , DOT , Y , Q , F , G , R , W , P ,BSLS,
- //|----+----+-----+-----+-----+----| |----+-----+-----+-----+----+----|
- EQL , A ,LA(O),LG(E),LC(I), U , D ,RS(T),RG(N),RA(S), M ,MINS,
- //|----+----+-----+-----+-----+----| |----+-----+-----+-----+----+----|
- ESC ,SCLN, X , C , V , Z , H , J , K , L , B ,SLSH,
- //`----+----+-----+-----+-----+----+----| |----+----+-----+-----+-----+----+----'
- TMB1 ,TMB2,TMB3, TMB4,TMB5,TMB6
- // `-----+----+----' `----+----+-----'
+ [L_EDVORAKJP_BASE] = LAYOUT_wrapper(
+ //,-----------------------------------------------------. ,-----------------------------------------------------.
+ KC_GRV, __EDVORAKJP_BASE_L1__ , __EDVORAKJP_BASE_R1__ , KC_BSLS,
+ //|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------|
+ KC_EQL, __EDVORAKJP_BASE_L2__ , __EDVORAKJP_BASE_R2__ , KC_MINS,
+ //|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------|
+ KC_ESC, __EDVORAKJP_BASE_L3__ , __EDVORAKJP_BASE_R3__ , KC_SLSH,
+ //|--------+--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------+--------|
+ LA_TAB, LS_SPC,LOWER_TD, RAISE_TD, RC_BSPC, RG_ENT
+ //`--------------------------' `--------------------------'
),
- [_LOWER] = LAYOUT_kc(
- //|----+----+------+------+------+----| |----+------+------+-------+----+----|
- , , LCBR , LBRC , LPRN , , , RPRN , RBRC , RCBR , , ,
- //|----+----+------+------+------+----| |----+------+------+-------+----+----|
- F1 , F2 ,LA(F3),LG(F4),LC(F5), F6 , F7 ,RS(F8),RG(F9),RA(F10),F11 ,F12 ,
- //|----+----+------+------+------+----| |----+------+------+-------+----+----|
- PSCR, , HOME , PGDN , PGUP ,END , LEFT, DOWN , UP , RGHT , , ,
- //`----+----+------+------+------+----+----| |----+----+------+------+-------+----+----'
- , , NO , MAC ,TMB7,
- // `-----+----+----' `----+----+-----'
+ [L_EDVORAKJP_LOWER] = LAYOUT_wrapper(
+ //,-----------------------------------------------------. ,-----------------------------------------------------.
+ XXXXXXX, XXXXXXX, __EDVORAKJP_BRACKET_L__ , XXXXXXX, XXXXXXX, __EDVORAKJP_BRACKET_R__ , XXXXXXX, XXXXXXX,
+ //|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------|
+ __EDVORAKJP_FUNCTION_L__ , __EDVORAKJP_FUNCTION_R__ ,
+ //|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------|
+ KC_PSCR, XXXXXXX, __EDVORAKJP_PAGE__ , __EDVORAKJP_CURSOR__ , XXXXXXX, XXXXXXX,
+ //|--------+--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------+--------|
+ KC_TRNS, KC_TRNS, XXXXXXX, KC_MAC, RC_DEL, KC_TRNS
+ //`--------------------------' `--------------------------'
),
- [_RAISE] = LAYOUT_kc(
- //|----+----+-----+-----+-----+----| |----+-----+-----+-----+----+----|
- , ,EXLM , AT ,HASH ,DLR , PERC,CIRC ,AMPR ,ASTR , , ,
- //|----+----+-----+-----+-----+----| |----+-----+-----+-----+----+----|
- , 1 ,LA(2),LG(3),LC(4), 5 , 6 ,RS(7),RG(8),RA(9), 0 , ,
- //|----+----+-----+-----+-----+----| |----+-----+-----+-----+----+----|
- PSCR, ,HOME ,PGDN ,PGUP ,END , LEFT,DOWN , UP ,RGHT , , ,
- //`----+----+-----+-----+-----+----+----| |----+----+-----+-----+-----+----+----'
- , ,WIN , NO , ,
- // `-----+----+----' `----+----+----'
+ [L_EDVORAKJP_RAISE] = LAYOUT_wrapper(
+ //,-----------------------------------------------------. ,-----------------------------------------------------.
+ XXXXXXX, XXXXXXX, __EDVORAKJP_SYMBOL_L__ , __EDVORAKJP_SYMBOL_R__ , XXXXXXX, XXXXXXX,
+ //|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------|
+ XXXXXXX, __EDVORAKJP_NUMBER_L__ , __EDVORAKJP_NUMBER_R__ , XXXXXXX,
+ //|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------|
+ KC_PSCR, XXXXXXX, __EDVORAKJP_PAGE__ , __EDVORAKJP_CURSOR__ , XXXXXXX, XXXXXXX,
+ //|--------+--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------+--------|
+ KC_TRNS, KC_TRNS, KC_WIN, XXXXXXX, KC_TRNS, KC_TRNS
+ //`--------------------------' `--------------------------'
)
};
-
-#ifdef SSD1306OLED
-void matrix_init_keymap(void) {
- //SSD1306 OLED init, make sure to add #define SSD1306OLED in config.h
-#ifdef MASTER_RIGHT
- iota_gfx_init(has_usb()); // turns on the display
-#else
- iota_gfx_init(!has_usb());
-#endif // MASTER_RIGHT
-}
-
-void matrix_scan_user(void) {
- iota_gfx_task(); // this is what updates the display continuously
-}
-#endif
+// clang-format on
#ifdef RGBLIGHT_EFFECT_STATIC_GRADIENT
uint32_t layer_state_set_keymap(uint32_t state) {
- rgblight_mode_noeeprom(RGBLIGHT_MODE_STATIC_LIGHT);
- switch (biton32(state)) {
- case _LOWER:
- rgblight_sethsv_noeeprom_red();
- break;
- case _RAISE:
- rgblight_sethsv_noeeprom_green();
- break;
- default: // for any other layers, or the default layer
- rgblight_mode(RGBLIGHT_MODE_STATIC_GRADIENT + 3);
- rgblight_sethsv_red();
- break;
- }
- return state;
+ rgblight_mode_noeeprom(RGBLIGHT_MODE_STATIC_LIGHT);
+ switch (biton32(state)) {
+ case L_EDVORAKJP_LOWER:
+ rgblight_sethsv_noeeprom_red();
+ break;
+ case L_EDVORAKJP_RAISE:
+ rgblight_sethsv_noeeprom_green();
+ break;
+ default: // for any other layers, or the default layer
+ rgblight_mode(RGBLIGHT_MODE_STATIC_GRADIENT + 3);
+ rgblight_sethsv_red();
+ break;
+ }
+ return state;
}
#endif
diff --git a/keyboards/crkbd/keymaps/edvorakjp/oled.c b/keyboards/crkbd/keymaps/edvorakjp/oled.c
index cbb43d0615..2e0fed47ee 100644
--- a/keyboards/crkbd/keymaps/edvorakjp/oled.c
+++ b/keyboards/crkbd/keymaps/edvorakjp/oled.c
@@ -1,76 +1,55 @@
+#include <stdio.h>
#include <string.h>
#include "oled.h"
-// NOTE: Redefined to avoid to use snprintf(); It makes size of firmware big.
-const char *read_mode_icon(bool windows_mode) {
- static const char logo[][2][3] = {{{0x95, 0x96, 0}, {0xb5, 0xb6, 0}}, {{0x97, 0x98, 0}, {0xb7, 0xb8, 0}}};
- static char mode_icon[10];
-
- int mode_number = windows_mode ? 1 : 0;
- strcpy(mode_icon, logo[mode_number][0]);
-
- strcat(mode_icon, "\n");
- strcat(mode_icon, logo[mode_number][1]);
-
- return mode_icon;
+#ifdef OLED_DRIVER_ENABLE
+void render_host_led_state(void) { oled_write(read_host_led_state(), false); }
+
+void render_layer_state(void) {
+ char layer_name[17];
+ oled_write_P(PSTR("Layer: "), false);
+
+ switch (biton32(layer_state)) {
+ case L_EDVORAKJP_BASE:
+ oled_write_ln_P(PSTR("Default"), false);
+ break;
+ case L_EDVORAKJP_LOWER:
+ oled_write_ln_P(PSTR("Lower"), false);
+ break;
+ case L_EDVORAKJP_RAISE:
+ oled_write_ln_P(PSTR("Raise"), false);
+ break;
+ default:
+ snprintf(layer_name, sizeof(layer_name), "Undef-%ld", layer_state);
+ oled_write_ln(layer_name, false);
+ }
}
-const char *read_layer_state(void) {
- static char layer_state_str[24];
- char layer_name[17];
-
- switch (biton32(layer_state)) {
- case L_BASE:
- strcpy(layer_name, "Default");
- break;
- case _RAISE:
- strcpy(layer_name, "Raise");
- break;
- case _LOWER:
- strcpy(layer_name, "Lower");
- break;
- default:
- snprintf(layer_name, sizeof(layer_name), "Undef-%ld", layer_state);
- }
+void render_logo(void) { oled_write(read_logo(), false); }
- strcpy(layer_state_str, "Layer: ");
+void render_mode_icon(bool is_windows) {
+ static const char logo[][2][3] = {
+ {{0x95, 0x96, 0}, {0xb5, 0xb6, 0}},
+ {{0x97, 0x98, 0}, {0xb7, 0xb8, 0}},
+ };
+ static char mode_icon[10];
- strcat(layer_state_str, layer_name);
- strcat(layer_state_str, "\n");
- return layer_state_str;
+ snprintf(mode_icon, sizeof(mode_icon), "%s\n%s ", logo[is_windows][0], logo[is_windows][1]);
+ oled_write(mode_icon, false);
}
-const char *read_host_led_state(void) {
- static char led_str[24];
- strcpy(led_str, (host_keyboard_leds() & (1<<USB_LED_NUM_LOCK)) ? "NMLK" : " ");
- strcat(led_str, (host_keyboard_leds() & (1<<USB_LED_CAPS_LOCK)) ? " CAPS" : " ");
- strcat(led_str, (host_keyboard_leds() & (1<<USB_LED_SCROLL_LOCK)) ? " SCLK" : " ");
- return led_str;
+oled_rotation_t oled_init_user(oled_rotation_t rotation) {
+ // flips the display 180 degrees if offhand
+ return is_keyboard_left() ? rotation : rotation ^ OLED_ROTATION_180;
}
-void matrix_update(struct CharacterMatrix *dest,
- const struct CharacterMatrix *source) {
- if (memcmp(dest->display, source->display, sizeof(dest->display))) {
- memcpy(dest->display, source->display, sizeof(dest->display));
- dest->dirty = true;
- }
-}
-
-void iota_gfx_task_user(void) {
- struct CharacterMatrix matrix;
-
- matrix_clear(&matrix);
-#ifdef MASTER_RIGHT
- if (!is_master) {
-#else
- if (is_master) {
-#endif // MASTER_RIGHT
- matrix_write(&matrix, read_mode_icon(!get_enable_kc_lang()));
- matrix_write(&matrix, " ");
- matrix_write(&matrix, read_layer_state());
- matrix_write(&matrix, read_host_led_state());
- } else {
- matrix_write(&matrix, read_logo());
- }
- matrix_update(&display, &matrix);
+void oled_task_user(void) {
+ if (is_keyboard_left()) {
+ render_mode_icon(!get_enable_kc_lang());
+ render_layer_state();
+ render_host_led_state();
+ } else {
+ render_logo();
+ }
}
+#endif // OLED_DRIVER_ENABLE
diff --git a/keyboards/crkbd/keymaps/edvorakjp/oled.h b/keyboards/crkbd/keymaps/edvorakjp/oled.h
index 896347aea9..d9939c83a0 100644
--- a/keyboards/crkbd/keymaps/edvorakjp/oled.h
+++ b/keyboards/crkbd/keymaps/edvorakjp/oled.h
@@ -1,24 +1,17 @@
-#ifndef OLED_USER_H
-#define OLED_USER_H
+#pragma once
-//SSD1306 OLED update loop, make sure to add #define SSD1306OLED in config.h
-#include "ssd1306.h"
#include "edvorakjp.h"
-//assign the right code to your layers for OLED display
-#define L_BASE 0
-
-extern uint8_t is_master;
extern bool japanese_mode;
// method prototypes defined in crkbd/lib
+extern const char *read_host_led_state(void);
extern const char *read_logo(void);
+extern const char *read_mode_icon(bool swap);
-const char *read_mode_icon(bool swap);
-const char *read_layer_state(void);
-const char *read_host_led_state(void);
-void matrix_update(struct CharacterMatrix *dest,
- const struct CharacterMatrix *source);
-void iota_gfx_task_user(void);
-
-#endif // OLED_CONFIG_USER_H
+void render_host_led_state(void);
+void render_layer_state(void);
+void render_logo(void);
+void render_mode_icon(bool is_windows);
+oled_rotation_t oled_init_user(oled_rotation_t rotation);
+void oled_task_user(void);
diff --git a/keyboards/crkbd/keymaps/edvorakjp/rules.mk b/keyboards/crkbd/keymaps/edvorakjp/rules.mk
index b4f6d2f1f1..111f6de27d 100644
--- a/keyboards/crkbd/keymaps/edvorakjp/rules.mk
+++ b/keyboards/crkbd/keymaps/edvorakjp/rules.mk
@@ -16,17 +16,13 @@ BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID
RGBLIGHT_ENABLE = yes # Enable WS2812 RGB underlight.
SWAP_HANDS_ENABLE = no # Enable one-hand typing
TAP_DANCE_ENABLE = yes
+OLED_DRIVER_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
# If you want to change the display of OLED, you need to change here
-SRC += ./lib/glcdfont.c \
+SRC += ./lib/host_led_state_reader.c \
./lib/logo_reader.c \
- oled.c \
- # ./lib/rgb_state_reader.c \
- # ./lib/layer_state_reader.c \
- # ./lib/keylogger.c \
- # ./lib/mode_icon_reader.c \
- # ./lib/host_led_state_reader.c \
- # ./lib/timelogger.c \
+ ./lib/mode_icon_reader.c \
+ oled.c