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

Remove LAYOUT_kc macros from edvorakjp keymaps #12217

Merged
merged 12 commits into from
Apr 10, 2021
Merged
Prev Previous commit
Next Next commit
Run `clang-format -style=file -i keyboards/crkbd/keymaps/edvorakjp/*.…
…{c,h}`
  • Loading branch information
epaew committed Mar 26, 2021
commit 7492a34d99c300abe7d9b99a69bdb5beabeb202d
5 changes: 1 addition & 4 deletions keyboards/crkbd/keymaps/edvorakjp/config.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#ifndef CONFIG_USER_H
#define CONFIG_USER_H
#pragma once

/* Select hand configuration */

Expand All @@ -21,5 +20,3 @@
#define RGBLIGHT_HUE_STEP 10
#define RGBLIGHT_SAT_STEP 17
#define RGBLIGHT_VAL_STEP 17

#endif // CONFIG_USER_H
52 changes: 27 additions & 25 deletions keyboards/crkbd/keymaps/edvorakjp/keymap.c
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#include QMK_KEYBOARD_H
#ifdef PROTOCOL_LUFA
#include "split_util.h"
# include "split_util.h"
#endif
#ifdef SSD1306OLED
#include "oled.h"
# include "oled.h"
#endif

#include "edvorakjp.h"
Expand All @@ -18,12 +18,13 @@

#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_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)

// clang-format off
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {

[_EDVORAK] = LAYOUT_kc(
Expand Down Expand Up @@ -62,37 +63,38 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
// `-----+----+----' `----+----+----'
)
};
// clang-format on

#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
// 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
iota_gfx_task(); // this is what updates the display continuously
}
#endif

#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 _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;
}
#endif
99 changes: 49 additions & 50 deletions keyboards/crkbd/keymaps/edvorakjp/oled.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,74 +3,73 @@

// 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];
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]);
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]);
strcat(mode_icon, "\n");
strcat(mode_icon, logo[mode_number][1]);

return mode_icon;
return mode_icon;
}

const char *read_layer_state(void) {
static char layer_state_str[24];
char layer_name[17];
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);
}
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);
}

strcpy(layer_state_str, "Layer: ");
strcpy(layer_state_str, "Layer: ");

strcat(layer_state_str, layer_name);
strcat(layer_state_str, "\n");
return layer_state_str;
strcat(layer_state_str, layer_name);
strcat(layer_state_str, "\n");
return layer_state_str;
}

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

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 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;
struct CharacterMatrix matrix;

matrix_clear(&matrix);
matrix_clear(&matrix);
#ifdef MASTER_RIGHT
if (!is_master) {
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);
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);
}
16 changes: 6 additions & 10 deletions keyboards/crkbd/keymaps/edvorakjp/oled.h
Original file line number Diff line number Diff line change
@@ -1,24 +1,20 @@
#ifndef OLED_USER_H
#define OLED_USER_H
#pragma once

//SSD1306 OLED update loop, make sure to add #define SSD1306OLED in config.h
// 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
// assign the right code to your layers for OLED display
#define L_BASE 0

extern uint8_t is_master;
extern bool japanese_mode;
extern bool japanese_mode;

// method prototypes defined in crkbd/lib
extern const char *read_logo(void);

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 matrix_update(struct CharacterMatrix *dest, const struct CharacterMatrix *source);
void iota_gfx_task_user(void);