Skip to content

Commit

Permalink
Migrate crkbd keymaps to oled driver (qmk#17863)
Browse files Browse the repository at this point in the history
  • Loading branch information
zvecr authored and nolanseaton committed Jan 23, 2023
1 parent 5b5aa20 commit ff2bb7d
Show file tree
Hide file tree
Showing 40 changed files with 97 additions and 524 deletions.
2 changes: 0 additions & 2 deletions keyboards/crkbd/keymaps/davidrambo/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.

#define RGBLIGHT_SPLIT

//#define SSD1306OLED

#define TAPPING_TERM 200
#define PERMISSIVE_HOLD

Expand Down
3 changes: 0 additions & 3 deletions keyboards/crkbd/keymaps/davidrambo/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@

#include QMK_KEYBOARD_H

//extern uint8_t is_master;


enum custom_layers {
_COLEMAK,
_SYMBOL,
Expand Down
25 changes: 5 additions & 20 deletions keyboards/crkbd/keymaps/devdev/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -263,9 +263,6 @@ bool led_update_user(led_t led_state) {
}
*/



//SSD1306 OLED update loop, make sure to add #define SSD1306OLED in config.h
#ifdef OLED_ENABLE
oled_rotation_t oled_init_user(oled_rotation_t rotation) {
if (!is_keyboard_master()) {
Expand Down Expand Up @@ -319,27 +316,15 @@ void oled_render_layer_state(void) {
oled_write_ln_P(PSTR("Layer: Layer Switch"),false);
break;
default:
#if defined (LAYER_STATE_32BIT)
snprintf(string, sizeof(string), "%ld",layer_state);
#else
snprintf(string, sizeof(string), "%d",layer_state);
#endif
oled_write_P(PSTR("Layer: Undef-"),false);
oled_write_ln(string, false);
}
}

/*
void matrix_render_user(struct CharacterMatrix *matrix) {
if (has_usb()) {
// If you want to change the display of OLED, you need to change here
matrix_write_ln(matrix, read_layer_state());
matrix_write_ln(matrix, read_keylog());
//matrix_write_ln(matrix, read_keylogs());
//matrix_write_ln(matrix, read_mode_icon(keymap_config.swap_lalt_lgui));
//matrix_write_ln(matrix, read_host_led_state());
//matrix_write_ln(matrix, read_timelog());
} else {
matrix_write(matrix, read_logo());
}
}
*/

char keylog_str[24] = {};
const char code_to_name[60] = {
Expand Down Expand Up @@ -393,7 +378,7 @@ void oled_render_logo(void) {
}

bool oled_task_user(void) {
if (is_master) {
if (is_keyboard_master()) {
oled_render_layer_state();
oled_render_keylog();
} else {
Expand Down
3 changes: 0 additions & 3 deletions keyboards/crkbd/keymaps/gotham/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
#define EE_HANDS
#define SPLIT_USB_DETECT

#undef USE_I2C
#undef SSD1306OLED

#define USE_SERIAL_PD2

#define IGNORE_MOD_TAP_INTERRUPT
Expand Down
2 changes: 0 additions & 2 deletions keyboards/crkbd/keymaps/gotham/oled.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#pragma once

extern uint8_t is_master;

#if defined(RGBLIGHT_ENABLE) || defined(RGB_MATRIX_ENABLE)
# include "rgb.c"
#endif
Expand Down
4 changes: 0 additions & 4 deletions keyboards/crkbd/keymaps/hvp/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
// #define MASTER_RIGHT
// #define EE_HANDS

#define SSD1306OLED
#define USE_SSD_I2C


#define USE_SERIAL_PD2

//#define TAPPING_FORCE_HOLD
Expand Down
45 changes: 12 additions & 33 deletions keyboards/crkbd/keymaps/hvp/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,9 @@ void matrix_init_user(void) {
#ifdef RGBLIGHT_ENABLE
RGB_current_mode = rgblight_config.mode;
#endif
//SSD1306 OLED init, make sure to add #define SSD1306OLED in config.h
#ifdef SSD1306OLED
iota_gfx_init(); // turns on the display
#endif
}

//SSD1306 OLED update loop, make sure to add #define SSD1306OLED in config.h
#ifdef SSD1306OLED
#ifdef OLED_ENABLE

// When add source files to SRC in rules.mk, you can use functions.
const char *read_layer_state(void);
Expand All @@ -112,42 +107,26 @@ const char *read_keylogs(void);
// void set_timelog(void);
// const char *read_timelog(void);

void matrix_scan_user(void) {
iota_gfx_task();
}

void matrix_render_user(struct CharacterMatrix *matrix) {
bool oled_task_user(void) {
if (is_keyboard_master()) {
// If you want to change the display of OLED, you need to change here
matrix_write(matrix, read_layer_state());
matrix_write(matrix, read_keylog());
//matrix_write_ln(matrix, read_keylogs());
//matrix_write_ln(matrix, read_mode_icon(keymap_config.swap_lalt_lgui));
//matrix_write_ln(matrix, read_host_led_state());
//matrix_write_ln(matrix, read_timelog());
oled_write(read_layer_state(), false);
oled_write(read_keylog(), false);
//oled_write_ln(read_keylogs(), false);
//oled_write_ln(read_mode_icon(keymap_config.swap_lalt_lgui), false);
//oled_write_ln(read_host_led_state()), false;
//oled_write_ln(read_timelog(), false);
} else {
matrix_write(matrix, read_logo());
}
}

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;
oled_write(read_logo(), false);
}
return false;
}

void iota_gfx_task_user(void) {
struct CharacterMatrix matrix;
matrix_clear(&matrix);
matrix_render_user(&matrix);
matrix_update(&display, &matrix);
}
#endif//SSD1306OLED
#endif

bool process_record_user(uint16_t keycode, keyrecord_t *record) {
if (record->event.pressed) {
#ifdef SSD1306OLED
#ifdef OLED_ENABLE
set_keylog(keycode, record);
#endif
// set_timelog();
Expand Down
9 changes: 3 additions & 6 deletions keyboards/crkbd/keymaps/hvp/rules.mk
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@

VPATH += keyboards/crkbd/lib
LIB_SRC += ssd1306.c i2c.c

# If you want to change the display of OLED, you need to change here
SRC += ./lib/glcdfont.c \
./lib/rgb_state_reader.c \
SRC += ./lib/rgb_state_reader.c \
./lib/layer_state_reader.c \
./lib/logo_reader.c \
./lib/keylogger.c \
Expand All @@ -14,4 +9,6 @@ SRC += ./lib/glcdfont.c \
TAP_DANCE_ENABLE = yes
EXTRAKEY_ENABLE = yes # Audio control and System control
OLED_ENABLE = yes
OLED_DRIVER = SSD1306
# LOCAL_GLCDFONT = yes
3 changes: 0 additions & 3 deletions keyboards/crkbd/keymaps/jarred/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
// #define MASTER_RIGHT
// #define EE_HANDS

#define SSD1306OLED
#define USE_SSD_I2C

#define USE_SERIAL_PD2

//#define TAPPING_FORCE_HOLD
Expand Down
47 changes: 8 additions & 39 deletions keyboards/crkbd/keymaps/jarred/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@
#include "lufa.h"
#include "split_util.h"
#endif
#ifdef SSD1306OLED
#include "ssd1306.h"
#endif


#ifdef RGBLIGHT_ENABLE
//Following line allows macro to read current RGB settings
Expand Down Expand Up @@ -65,15 +61,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
)
};

void matrix_init_user(void) {
//SSD1306 OLED init, make sure to add #define SSD1306OLED in config.h
#ifdef SSD1306OLED
iota_gfx_init(); // turns on the display
#endif
}

//SSD1306 OLED update loop, make sure to add #define SSD1306OLED in config.h
#ifdef SSD1306OLED
#ifdef OLED_ENABLE

// When add source files to SRC in rules.mk, you can use functions.
const char *read_logo(void);
Expand Down Expand Up @@ -142,37 +130,18 @@ const char *read_usb_state(void) {
return matrix_line_str;
}

void matrix_scan_user(void) {
iota_gfx_task();
}

void matrix_render_user(struct CharacterMatrix *matrix) {
bool oled_task_user(void) {
if (is_keyboard_master()) {
matrix_write(matrix, read_layer_state());
matrix_write(matrix, "\n");
matrix_write(matrix, read_usb_state());
matrix_write(matrix, "\n");
matrix_write(matrix, read_keylogs());
matrix_write(matrix, "\n");
oled_write_ln(read_layer_state(), false);
oled_write_ln(read_usb_state(), false);
oled_write_ln(read_keylogs(), false);
} else {
matrix_write(matrix, read_logo());
oled_write(read_logo(), false);
}
return false;
}

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);
matrix_render_user(&matrix);
matrix_update(&display, &matrix);
}
#endif//SSD1306OLED
#endif

bool process_record_keymap(uint16_t keycode, keyrecord_t *record) {
if (record->event.pressed) {
Expand Down
8 changes: 3 additions & 5 deletions keyboards/crkbd/keymaps/jarred/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,17 @@ UNICODE_ENABLE = no # Unicode
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
OLED_ENABLE = yes
OLED_DRIVER = SSD1306

# 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 \
./lib/rgb_state_reader.c \
SRC += ./lib/rgb_state_reader.c \
./lib/logo_reader.c \
./lib/keylogger.c \
#./lib/layer_state_reader.c \
# ./lib/mode_icon_reader.c \
# ./lib/host_led_state_reader.c \
# ./lib/timelogger.c \
VPATH += keyboards/crkbd/lib
LIB_SRC += ssd1306.c i2c.c
3 changes: 0 additions & 3 deletions keyboards/crkbd/keymaps/kidbrazil/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
// #define MASTER_RIGHT
// #define EE_HANDS

#define SSD1306OLED
#define USE_SSD_I2C

#define USE_SERIAL_PD2

#define TAPPING_FORCE_HOLD
Expand Down
4 changes: 2 additions & 2 deletions keyboards/crkbd/keymaps/kidbrazil/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -182,13 +182,13 @@ bool oled_task_user(void) {
master_oled_cleared = true;
}
render_logo();
return;
return false;
}
// Drashna style timeout for LED and OLED Roughly 8mins
else if (timer_elapsed32(oled_timer) > 480000) {
oled_off();
rgb_matrix_disable_noeeprom();
return;
return false;
}
else {
oled_on();
Expand Down
3 changes: 0 additions & 3 deletions keyboards/crkbd/keymaps/kidbrazil/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,3 @@ OLED_DRIVER = SSD1306
# If you want to change the display of OLED, you need to change here
SRC += logo_reader.c \
layer.c

VPATH += keyboards/crkbd/lib
LIB_SRC += ssd1306.c i2c.c
3 changes: 0 additions & 3 deletions keyboards/crkbd/keymaps/madhatter/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
// #define MASTER_RIGHT
// #define EE_HANDS

#define SSD1306OLED
#define USE_SSD_I2C

#define USE_SERIAL_PD2

#define TAPPING_FORCE_HOLD
Expand Down
Loading

0 comments on commit ff2bb7d

Please sign in to comment.