Skip to content
This repository was archived by the owner on Jan 14, 2025. It is now read-only.

lily58: Update to use OLED driver #1

Merged
merged 1 commit into from
Jun 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions lily58/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define MASTER_RIGHT
// #define EE_HANDS

// OLED
#define SSD1306OLED

// Underglow
#undef RGBLED_NUM
#define RGBLIGHT_ANIMATIONS
Expand Down
68 changes: 22 additions & 46 deletions lily58/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
#include "lufa.h"
#include "split_util.h"
#endif
#ifdef SSD1306OLED
#include "ssd1306.h"
#endif

#include "keymap_alias.h"

Expand All @@ -16,8 +13,6 @@
extern rgblight_config_t rgblight_config;
#endif

extern uint8_t is_master;

enum keyboard_layers {
_QWERTY = 0, // default layer
_WIN, // windows layer
Expand Down Expand Up @@ -156,21 +151,19 @@ 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
#ifdef OLED_DRIVER_ENABLE

/* oled_rotation_t oled_init_user(oled_rotation_t rotation) { */
/* if (is_master) { */
/* return OLED_ROTATION_270; */
/* } */
/* return OLED_ROTATION_180; */
/* } */
oled_rotation_t oled_init_user(oled_rotation_t rotation) {
/* if (is_keyboard_master()) { */
/* return OLED_ROTATION_270; */
/* } */
/* return OLED_ROTATION_180; */
if (!is_keyboard_master())
return OLED_ROTATION_180;
return rotation;
}

#define L_QWERTY 0
#define L_WIN 2
Expand Down Expand Up @@ -228,10 +221,6 @@ const char *read_keylogs(void);
// void set_timelog(void);
// const char *read_timelog(void);

void matrix_scan_user(void) {
iota_gfx_task();
}

char rotary_message[24];
const char *read_rotary(void) {
switch(CURRENT_ROTARY_MODE) {
Expand All @@ -257,35 +246,22 @@ const char *read_rotary(void) {
return rotary_message;
}

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_custom_layer_state());
matrix_write_ln(matrix, read_keylog());
matrix_write_ln(matrix, read_rotary());
// 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_custom_layer_state(), false);
oled_write_ln(read_keylog(), false);
oled_write_ln(read_rotary(), 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

#ifdef ENCODER_ENABLE
void encoder_update_user(uint8_t index, bool clockwise) {
Expand Down Expand Up @@ -340,7 +316,7 @@ void encoder_update_user(uint8_t index, bool clockwise) {

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
4 changes: 2 additions & 2 deletions lily58/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ 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_DRIVER_ENABLE = yes # OLED display

# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE
SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend
ENCODER_ENABLE = yes

# 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 Down