Skip to content

Commit

Permalink
try refactor to use split_common and use OLED driver
Browse files Browse the repository at this point in the history
  • Loading branch information
nrtkbb committed Oct 1, 2019
1 parent 917edde commit 5a9afce
Show file tree
Hide file tree
Showing 17 changed files with 33 additions and 1,941 deletions.
10 changes: 6 additions & 4 deletions keyboards/uzu42/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#pragma once

#include "config_common.h"
#include <serial_config.h>

#define USE_I2C
#define USE_SERIAL
#ifndef SOFT_SERIAL_PIN
#define SOFT_SERIAL_PIN D2
#define SERIAL_USE_MULTI_TRANSACTION
#endif

#define NO_ACTION_MACRO
#define NO_ACTION_FUNCTION

#define DISABLE_LEADER
// Use the lily version to get the uzu42 logo instead of the qmk logo
#define OLED_FONT_H "lib/glcdfont_uzu42.c"
162 changes: 0 additions & 162 deletions keyboards/uzu42/i2c.c

This file was deleted.

46 changes: 0 additions & 46 deletions keyboards/uzu42/i2c.h

This file was deleted.

56 changes: 20 additions & 36 deletions keyboards/uzu42/keymaps/default/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ extern keymap_config_t keymap_config;
extern rgblight_config_t rgblight_config;
#endif

extern uint8_t is_master;
extern volatile bool isLeftHand;

// Each layer gets a name for readability, which is then used in the keymap matrix below.
// The underscores don't mean anything - you can have a layer called STUFF or any other name.
Expand Down Expand Up @@ -117,14 +117,16 @@ 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(!has_usb()); // turns on the display
#endif
}

//SSD1306 OLED update loop, make sure to add #define SSD1306OLED in config.h
#ifdef SSD1306OLED
//SSD1306 OLED update loop, make sure to enable OLED_DRIVER_ENABLE=yes in rules.mk
#ifdef OLED_DRIVER_ENABLE

oled_rotation_t oled_init_user(oled_rotation_t rotation) {
if (!is_keyboard_master())
return OLED_ROTATION_180; // flips the display 180 degrees if offhand
return rotation;
}

// When add source files to SRC in rules.mk, you can use functions.
const char *read_layer_state(void);
Expand All @@ -138,42 +140,24 @@ 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) {
if (is_master) {
void oled_task_user(void) {
if (is_keyboard_master()) {
// 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());
oled_write_ln(read_layer_state(), false);
oled_write_ln(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());
oled_write(read_logo(), 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 // OLED_DRIVER_ENABLE

bool process_record_user(uint16_t keycode, keyrecord_t *record) {
if (record->event.pressed) {
#ifdef SSD1306OLED
#ifdef OLED_DRIVER_ENABLE
set_keylog(keycode, record);
#endif
// set_timelog();
Expand Down
File renamed without changes.
Loading

0 comments on commit 5a9afce

Please sign in to comment.