summaryrefslogtreecommitdiff
path: root/keyboards/lily58/keymaps/default/keymap.c
diff options
context:
space:
mode:
authorNaoki Katahira <kata0510.com@gmail.com>2019-01-06 02:30:48 +0900
committerDrashna Jaelre <drashna@live.com>2019-01-05 09:30:48 -0800
commitea47be936b41a31e2644ad3403d91010916683ce (patch)
treec8db4d32373542cd1236a4d537fa45a00ed7b6fb /keyboards/lily58/keymaps/default/keymap.c
parent5b5f452bf9feae121ec5c2f3e9d5d993fcb73f92 (diff)
Keyboard: Lily58 update serial.c and add OLED (#4715)
* update serial.c and add OLED * update readme * keymap fix * keymap fix2
Diffstat (limited to 'keyboards/lily58/keymaps/default/keymap.c')
-rw-r--r--keyboards/lily58/keymaps/default/keymap.c123
1 files changed, 107 insertions, 16 deletions
diff --git a/keyboards/lily58/keymaps/default/keymap.c b/keyboards/lily58/keymaps/default/keymap.c
index 8d77058129..5ff5dc3182 100644
--- a/keyboards/lily58/keymaps/default/keymap.c
+++ b/keyboards/lily58/keymaps/default/keymap.c
@@ -1,7 +1,23 @@
#include QMK_KEYBOARD_H
+#ifdef PROTOCOL_LUFA
+ #include "lufa.h"
+ #include "split_util.h"
+#endif
+#ifdef SSD1306OLED
+ #include "ssd1306.h"
+#endif
+
+
extern keymap_config_t keymap_config;
+#ifdef RGBLIGHT_ENABLE
+//Following line allows macro to read current RGB settings
+extern rgblight_config_t rgblight_config;
+#endif
+
+extern uint8_t is_master;
+
#define _QWERTY 0
#define _LOWER 1
#define _RAISE 2
@@ -88,9 +104,9 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
* |------+------+------+------+------+------| |------+------+------+------+------+------|
* | | | | | | | | | | | | | |
* |------+------+------+------+------+------| |------+------+------+------+------+------|
- * | | | | | | |-------. ,-------| | | | | | |
+ * | | | | | | |-------. ,-------| | |RGB ON| HUE+ | SAT+ | VAL+ |
* |------+------+------+------+------+------| | | |------+------+------+------+------+------|
- * | | | | | | |-------| |-------| | | | | | |
+ * | | | | | | |-------| |-------| | | MODE | HUE- | SAT- | VAL- |
* `-----------------------------------------/ / \ \-----------------------------------------'
* | LAlt | LGUI |LOWER | /Space / \Enter \ |RAISE |BackSP| RGUI |
* | | | |/ / \ \ | | | |
@@ -99,17 +115,92 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
[_ADJUST] = LAYOUT( \
XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, \
XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, \
- XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, \
- XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,\
+ XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, RGB_TOG, RGB_HUI, RGB_SAI, RGB_VAI, \
+ XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, RGB_MOD, RGB_HUD, RGB_SAD, RGB_VAD,\
_______, _______, _______, _______, _______, _______, _______, _______ \
)
};
+int RGB_current_mode;
+
+// Setting ADJUST layer RGB back to default
+void update_tri_layer_RGB(uint8_t layer1, uint8_t layer2, uint8_t layer3) {
+ if (IS_LAYER_ON(layer1) && IS_LAYER_ON(layer2)) {
+ layer_on(layer3);
+ } else {
+ layer_off(layer3);
+ }
+}
+
+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
+
+// When add source files to SRC in rules.mk, you can use functions.
+const char *read_layer_state(void);
+const char *read_logo(void);
+void set_keylog(uint16_t keycode, keyrecord_t *record);
+const char *read_keylog(void);
+const char *read_keylogs(void);
+
+// const char *read_mode_icon(bool swap);
+// const char *read_host_led_state(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) {
+ // 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());
+ }
+}
+
+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
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
+ if (record->event.pressed) {
+#ifdef SSD1306OLED
+ set_keylog(keycode, record);
+#endif
+ // set_timelog();
+ }
+
switch (keycode) {
case QWERTY:
- if (record->event.pressed) {
+ if (record->event.pressed) {
set_single_persistent_default_layer(_QWERTY);
}
return false;
@@ -117,31 +208,31 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
case LOWER:
if (record->event.pressed) {
layer_on(_LOWER);
- update_tri_layer(_LOWER, _RAISE, _ADJUST);
+ update_tri_layer_RGB(_LOWER, _RAISE, _ADJUST);
} else {
layer_off(_LOWER);
- update_tri_layer(_LOWER, _RAISE, _ADJUST);
+ update_tri_layer_RGB(_LOWER, _RAISE, _ADJUST);
}
return false;
break;
case RAISE:
if (record->event.pressed) {
layer_on(_RAISE);
- update_tri_layer(_LOWER, _RAISE, _ADJUST);
+ update_tri_layer_RGB(_LOWER, _RAISE, _ADJUST);
} else {
layer_off(_RAISE);
- update_tri_layer(_LOWER, _RAISE, _ADJUST);
+ update_tri_layer_RGB(_LOWER, _RAISE, _ADJUST);
}
return false;
break;
case ADJUST:
- if (record->event.pressed) {
- layer_on(_ADJUST);
- } else {
- layer_off(_ADJUST);
- }
- return false;
- break;
+ if (record->event.pressed) {
+ layer_on(_ADJUST);
+ } else {
+ layer_off(_ADJUST);
+ }
+ return false;
+ break;
}
return true;
} \ No newline at end of file