]> git.donarmstrong.com Git - qmk_firmware.git/commitdiff
[Keymap] Display logo for caps lock indication on crkbd using old OLED driver (#7535)
authorManna Harbour <51143715+manna-harbour@users.noreply.github.com>
Sun, 8 Dec 2019 07:08:12 +0000 (18:08 +1100)
committerDrashna Jaelre <drashna@live.com>
Sun, 8 Dec 2019 07:08:12 +0000 (23:08 -0800)
* Display logo for caps lock indication on crkbd using old OLED driver

* Add emacs read-only mode file variable to generated files

* use LTO_ENABLE instead of EXTRAFLAGS

This enables the same option, and disables action_macros, and action_functions, both of which seem to break when LTO is enabled. And this is a lot simpler to use.

Co-Authored-By: Drashna Jaelre <drashna@live.com>
keyboards/crkbd/keymaps/manna-harbour_miryoku/config.h
keyboards/crkbd/keymaps/manna-harbour_miryoku/keymap.c
keyboards/crkbd/keymaps/manna-harbour_miryoku/rules.mk
layouts/community/ergodox/manna-harbour_miryoku/keymap.c
layouts/community/ortho_4x12/manna-harbour_miryoku/keymap.c
users/manna-harbour_miryoku/config.h
users/manna-harbour_miryoku/manna-harbour_miryoku.c
users/manna-harbour_miryoku/miryoku.org
users/manna-harbour_miryoku/rules.mk

index 4b8f78a650c29b918128f99dbbf357c20aed829b..e2fe1824da34a85ca8308c8235664cfd8b2a9dc2 100644 (file)
@@ -1,5 +1,4 @@
-
-// generated from users/manna-harbour_miryoku/miryoku.org
+// generated from users/manna-harbour_miryoku/miryoku.org  -*- buffer-read-only: t -*-
 
 #pragma once
 
@@ -15,3 +14,5 @@
 #define RGB_MATRIX_VAL_STEP 8
 #define RGB_MATRIX_SPD_STEP 10
 #endif
+
+#define SSD1306OLED // old oled driver
index 56d4de25ac9a6b61c4c2ca0b9b8b5ba258c9a77b..f5be6844f8c4ef3a5003478eefaf7a3881059369 100644 (file)
@@ -1,5 +1,4 @@
-
-// generated from users/manna-harbour_miryoku/miryoku.org
+// generated from users/manna-harbour_miryoku/miryoku.org  -*- buffer-read-only: t -*-
 
 #define LAYOUT_miryoku( \
        K00,   K01,   K02,   K03,   K04,   K05,   K06,   K07,   K08,   K09, \
@@ -15,3 +14,41 @@ KC_NO, K20,   K21,   K22,   K23,   K24,   K25,   K26,   K27,   K28,   K29,   KC_
 )
 
 #include "manna-harbour_miryoku.c"
+
+
+#ifdef SSD1306OLED
+
+#include "ssd1306.h"
+
+void matrix_init_user(void) {
+  iota_gfx_init(!has_usb());   // turns on the display
+}
+
+// When add source files to SRC in rules.mk, you can use functions.
+const char *read_logo(void);
+
+void matrix_scan_user(void) {
+   iota_gfx_task();
+}
+
+void matrix_render_user(struct CharacterMatrix *matrix) {
+  if (host_keyboard_leds() & (1<<USB_LED_CAPS_LOCK)) {
+    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
index f62c86e93261026128929aea29e7c9890274ea1b..c4fb15f34263aae8a7b6f88ba60aefde326fd0c9 100644 (file)
@@ -1,4 +1,7 @@
-
-# generated from users/manna-harbour_miryoku/miryoku.org
+# generated from users/manna-harbour_miryoku/miryoku.org  -*- buffer-read-only: t -*-
 
 RGB_MATRIX_ENABLE = WS2812
+
+# old oled driver
+SRC += ./lib/glcdfont.c \
+       ./lib/logo_reader.c
index 86547df98eaf6f37b226e84855b03fb37c440185..1c715a68f7aea51261e8006f000f856b7f6336d6 100644 (file)
@@ -1,5 +1,4 @@
-
-// generated from users/manna-harbour_miryoku/miryoku.org
+// generated from users/manna-harbour_miryoku/miryoku.org  -*- buffer-read-only: t -*-
 
 #define LAYOUT_miryoku(\
 K00,   K01,   K02,   K03,   K04,   K05,   K06,   K07,   K08,   K09,\
index b1341d41f9a1b869cdd277d0e9b7e9fc29a2841c..07bc15c2af410ba13af6602e40f581c31cb9e6a5 100644 (file)
@@ -1,5 +1,4 @@
-
-// generated from users/manna-harbour_miryoku/miryoku.org
+// generated from users/manna-harbour_miryoku/miryoku.org  -*- buffer-read-only: t -*-
 
 #define LAYOUT_miryoku(\
 K00,   K01,   K02,   K03,   K04,   K05,   K06,   K07,   K08,   K09,\
index c3c513d063c457f5220bc58f8cdcccc6de610051..5ac3208c90cb151b803ec5ddcff5611c0706b6b9 100644 (file)
@@ -1,5 +1,4 @@
-
-// generated from users/manna-harbour_miryoku/miryoku.org
+// generated from users/manna-harbour_miryoku/miryoku.org  -*- buffer-read-only: t -*-
 
 #pragma once
 
index 740e3830f9c83b9af4c936a59d5f27b5b929c2e7..8ae38c25c8f804a62ec41f530fa8f70ce7b02849 100644 (file)
@@ -1,5 +1,4 @@
-
-// generated from users/manna-harbour_miryoku/miryoku.org
+// generated from users/manna-harbour_miryoku/miryoku.org  -*- buffer-read-only: t -*-
 
 #include QMK_KEYBOARD_H
 
index 2733cbceaf6b19cfdf9c36c6ee76b2aa55d63fb5..692321d01ebc9ccf35d0d22381bcab20036e2e4f 100644 (file)
@@ -384,7 +384,7 @@ Header for tangled src files.
 
 #+NAME: header
 #+BEGIN_SRC C :tangle no
-generated from users/manna-harbour_miryoku/miryoku.org
+generated from users/manna-harbour_miryoku/miryoku.org  -*- buffer-read-only: t -*-
 #+END_SRC
 
 
@@ -405,8 +405,7 @@ bottom row unused and the rest of the bottom row are the thumb keys.
 Contains the keymap.  Included from keymap.c
 
 [[./manna-harbour_miryoku.c][users/manna-harbour_miryoku/manna-harbour_miryoku.c]]
-#+BEGIN_SRC C :noweb yes :tangle manna-harbour_miryoku.c
-
+#+BEGIN_SRC C :noweb yes :padline no :tangle manna-harbour_miryoku.c
 // <<header>>
 
 #include QMK_KEYBOARD_H
@@ -442,8 +441,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
 Config options.  Automatically included.
 
 [[./config.h][users/manna-harbour_miryoku/config.h]]
-#+BEGIN_SRC C :noweb yes :tangle config.h
-
+#+BEGIN_SRC C :noweb yes :padline no :tangle config.h
 // <<header>>
 
 #pragma once
@@ -465,13 +463,12 @@ Config options.  Automatically included.
 Build options.  Automatically included.
 
 [[./rules.mk][users/manna-harbour_miryoku/rules.mk]]
-#+BEGIN_SRC makefile :noweb yes :tangle rules.mk
-
+#+BEGIN_SRC makefile :noweb yes :padline no :tangle rules.mk
 # <<header>>
 
 MOUSEKEY_ENABLE = yes        # Mouse keys(+4700)
 EXTRAKEY_ENABLE = yes        # Audio control and System control(+450)
-
+EXTRAFLAGS += -flto         # Link Time Optimization to reduce code size, 31358->28034/28672
 
 #+END_SRC
 
@@ -490,8 +487,7 @@ thumb key is the innermost key of the partial bottom row.  The remaining keys
 are unused.
 
 [[../../layouts/community/ergodox/manna-harbour_miryoku/keymap.c][layouts/community/ergodox/manna-harbour_miryoku/keymap.c]]
-#+BEGIN_SRC C :noweb yes :tangle ../../layouts/community/ergodox/manna-harbour_miryoku/keymap.c
-
+#+BEGIN_SRC C :noweb yes :padline no :tangle ../../layouts/community/ergodox/manna-harbour_miryoku/keymap.c
 // <<header>>
 
 #define LAYOUT_miryoku(\
@@ -533,8 +529,7 @@ provide some column stagger on ortho keyboards.  The bottom row left 3 columns
 are the thumb keys.  The remaining keys are unused.
 
 [[../../layouts/community/ortho_4x12/manna-harbour_miryoku/keymap.c][layouts/community/ortho_4x12/manna-harbour_miryoku/keymap.c]]
-#+BEGIN_SRC C :noweb yes :tangle ../../layouts/community/ortho_4x12/manna-harbour_miryoku/keymap.c
-
+#+BEGIN_SRC C :noweb yes :padline no :tangle ../../layouts/community/ortho_4x12/manna-harbour_miryoku/keymap.c
 // <<header>>
 
 #define LAYOUT_miryoku(\
@@ -577,8 +572,7 @@ The outer columns are unused.
 **** keymap.c
 
 [[../../keyboards/crkbd/keymaps/manna-harbour_miryoku/keymap.c][keyboards/crkbd/keymaps/manna-harbour_miryoku/keymap.c]]
-#+BEGIN_SRC C :noweb yes :tangle ../../keyboards/crkbd/keymaps/manna-harbour_miryoku/keymap.c
-
+#+BEGIN_SRC C :noweb yes :padline no :tangle ../../keyboards/crkbd/keymaps/manna-harbour_miryoku/keymap.c
 // <<header>>
 
 #define LAYOUT_miryoku( \
@@ -596,14 +590,51 @@ KC_NO, K20,   K21,   K22,   K23,   K24,   K25,   K26,   K27,   K28,   K29,   KC_
 
 #include "manna-harbour_miryoku.c"
 
+
+#ifdef SSD1306OLED
+
+#include "ssd1306.h"
+
+void matrix_init_user(void) {
+  iota_gfx_init(!has_usb());   // turns on the display
+}
+
+// When add source files to SRC in rules.mk, you can use functions.
+const char *read_logo(void);
+
+void matrix_scan_user(void) {
+   iota_gfx_task();
+}
+
+void matrix_render_user(struct CharacterMatrix *matrix) {
+  if (host_keyboard_leds() & (1<<USB_LED_CAPS_LOCK)) {
+    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
+
 #+END_SRC
 
 
 **** config.h
 
 [[../../keyboards/crkbd/keymaps/manna-harbour_miryoku/config.h][keyboards/crkbd/keymaps/manna-harbour_miryoku/config.h]]
-#+BEGIN_SRC C :noweb yes :tangle ../../keyboards/crkbd/keymaps/manna-harbour_miryoku/config.h
-
+#+BEGIN_SRC C :noweb yes :padline no :tangle ../../keyboards/crkbd/keymaps/manna-harbour_miryoku/config.h
 // <<header>>
 
 #pragma once
@@ -621,18 +652,23 @@ KC_NO, K20,   K21,   K22,   K23,   K24,   K25,   K26,   K27,   K28,   K29,   KC_
 #define RGB_MATRIX_SPD_STEP 10
 #endif
 
+#define SSD1306OLED // old oled driver
+
 #+END_SRC
 
 
 **** rules.mk
 
 [[../../keyboards/crkbd/keymaps/manna-harbour_miryoku/rules.mk][keyboards/crkbd/keymaps/manna-harbour_miryoku/rules.mk]]
-#+BEGIN_SRC C :noweb yes :tangle ../../keyboards/crkbd/keymaps/manna-harbour_miryoku/rules.mk
-
+#+BEGIN_SRC C :noweb yes :padline no :tangle ../../keyboards/crkbd/keymaps/manna-harbour_miryoku/rules.mk
 # <<header>>
 
 RGB_MATRIX_ENABLE = WS2812
 
+# old oled driver
+SRC += ./lib/glcdfont.c \
+       ./lib/logo_reader.c
+
 #+END_SRC
 
 
index baff1431f0d3f2fde245aeb34b257785f58df176..a54616b47aaaaf39c5424a9f9bef00e6f8da4f02 100644 (file)
@@ -1,5 +1,5 @@
-
-# generated from users/manna-harbour_miryoku/miryoku.org
+# generated from users/manna-harbour_miryoku/miryoku.org  -*- buffer-read-only: t -*-
 
 MOUSEKEY_ENABLE = yes        # Mouse keys(+4700)
 EXTRAKEY_ENABLE = yes        # Audio control and System control(+450)
+LTO_ENABLE = yes