From d6e12772644a3b18cb4c495dc99dc669eb0c272b Mon Sep 17 00:00:00 2001 From: jiaxin96 <572673807@qq.com> Date: Tue, 20 Apr 2021 00:55:51 +0800 Subject: [PATCH] add keyboards add keyboards and utils for 'y&r studio' --- keyboards/yandrstudio/cool87/config.h | 58 ++ keyboards/yandrstudio/cool87/cool87.c | 1 + keyboards/yandrstudio/cool87/cool87.h | 23 + .../cool87/keymaps/default/keymap.c | 215 +++++ keyboards/yandrstudio/cool87/rules.mk | 57 ++ keyboards/yandrstudio/nlhhkb/config.h | 74 ++ keyboards/yandrstudio/nlhhkb/info-via.json | 117 +++ .../nlhhkb/keymaps/default/keymap.c | 39 + keyboards/yandrstudio/nlhhkb/kle.json | 110 +++ keyboards/yandrstudio/nlhhkb/nlhhkb.c | 1 + keyboards/yandrstudio/nlhhkb/nlhhkb.h | 23 + keyboards/yandrstudio/nlhhkb/readme.md | 14 + keyboards/yandrstudio/nlhhkb/rules.mk | 34 + keyboards/yandrstudio/rainbow65/config.h | 93 +++ keyboards/yandrstudio/rainbow65/info-via.json | 157 ++++ keyboards/yandrstudio/rainbow65/jason_fount.c | 137 ++++ .../rainbow65/keymaps/default/config.h | 24 + .../keymaps/default/dev_oled/glcdfont.c | 16 + .../keymaps/default/dev_oled/licenses.txt | 45 + .../keymaps/default/dev_oled/oled_driver.c | 767 ++++++++++++++++++ .../keymaps/default/dev_oled/oled_driver.h | 313 +++++++ .../default/graph_lib/kb_press_graph.c | 37 + .../default/graph_lib/kb_press_graph.h | 18 + .../keymaps/default/graph_lib/my_pic_lib.h | 136 ++++ .../keymaps/default/graph_lib/wpm_graph.c | 183 +++++ .../keymaps/default/graph_lib/wpm_graph.h | 151 ++++ .../rainbow65/keymaps/default/keymap.c | 392 +++++++++ .../keymaps/default/rgb_matrix_user.inc | 98 +++ .../rainbow65/keymaps/default/rules.mk | 11 + .../rainbow65/keymaps/test_oled/config.h | 24 + .../keymaps/test_oled/dev_oled/glcdfont.c | 16 + .../keymaps/test_oled/dev_oled/licenses.txt | 45 + .../keymaps/test_oled/dev_oled/oled_driver.c | 767 ++++++++++++++++++ .../keymaps/test_oled/dev_oled/oled_driver.h | 313 +++++++ .../test_oled/graph_lib/kb_press_graph.c | 37 + .../test_oled/graph_lib/kb_press_graph.h | 18 + .../keymaps/test_oled/graph_lib/my_pic_lib.h | 136 ++++ .../keymaps/test_oled/graph_lib/wpm_graph.c | 183 +++++ .../keymaps/test_oled/graph_lib/wpm_graph.h | 151 ++++ .../rainbow65/keymaps/test_oled/keymap.c | 392 +++++++++ .../keymaps/test_oled/rgb_matrix_user.inc | 98 +++ .../rainbow65/keymaps/test_oled/rules.mk | 11 + .../rainbow65/keymaps/test_rgb/config.h | 18 + .../rainbow65/keymaps/test_rgb/keymap copy.c | 223 +++++ .../rainbow65/keymaps/test_rgb/keymap.c | 196 +++++ .../keymaps/test_rgb/rgb_matrix_user.inc | 98 +++ .../rainbow65/keymaps/test_rgb/rules.mk | 5 + .../rainbow65/keymaps/test_via/config.h | 18 + .../rainbow65/keymaps/test_via/keymap.c | 114 +++ .../rainbow65/keymaps/test_via/rules.mk | 4 + keyboards/yandrstudio/rainbow65/mcuconf.h | 14 + keyboards/yandrstudio/rainbow65/r65.json | 157 ++++ keyboards/yandrstudio/rainbow65/rainbow65.c | 76 ++ keyboards/yandrstudio/rainbow65/rainbow65.h | 20 + keyboards/yandrstudio/rainbow65/rules.mk | 24 + keyboards/yandrstudio/sb65p/config.h | 55 ++ .../sb65p/keymaps/default/keymap.c | 45 + keyboards/yandrstudio/sb65p/matrix.c | 192 +++++ keyboards/yandrstudio/sb65p/rules.mk | 39 + keyboards/yandrstudio/sb65p/sb65p.c | 18 + keyboards/yandrstudio/sb65p/sb65p.h | 30 + .../utils/BiuMisicDance/audio_lib.py | 235 ++++++ .../utils/BiuMisicDance/yandr_hid_tool.py | 87 ++ .../BiuMisicDance/yandr_hid_tool_test.py | 30 + keyboards/yandrstudio/utils/Font/font_user.py | 11 + .../utils/Font/rotate_font_tool.py | 38 + .../utils/RGB/getRgbMtrixPosition.js | 27 + 67 files changed, 7309 insertions(+) create mode 100755 keyboards/yandrstudio/cool87/config.h create mode 100755 keyboards/yandrstudio/cool87/cool87.c create mode 100755 keyboards/yandrstudio/cool87/cool87.h create mode 100755 keyboards/yandrstudio/cool87/keymaps/default/keymap.c create mode 100755 keyboards/yandrstudio/cool87/rules.mk create mode 100644 keyboards/yandrstudio/nlhhkb/config.h create mode 100644 keyboards/yandrstudio/nlhhkb/info-via.json create mode 100644 keyboards/yandrstudio/nlhhkb/keymaps/default/keymap.c create mode 100644 keyboards/yandrstudio/nlhhkb/kle.json create mode 100644 keyboards/yandrstudio/nlhhkb/nlhhkb.c create mode 100644 keyboards/yandrstudio/nlhhkb/nlhhkb.h create mode 100644 keyboards/yandrstudio/nlhhkb/readme.md create mode 100644 keyboards/yandrstudio/nlhhkb/rules.mk create mode 100755 keyboards/yandrstudio/rainbow65/config.h create mode 100755 keyboards/yandrstudio/rainbow65/info-via.json create mode 100755 keyboards/yandrstudio/rainbow65/jason_fount.c create mode 100755 keyboards/yandrstudio/rainbow65/keymaps/default/config.h create mode 100755 keyboards/yandrstudio/rainbow65/keymaps/default/dev_oled/glcdfont.c create mode 100755 keyboards/yandrstudio/rainbow65/keymaps/default/dev_oled/licenses.txt create mode 100755 keyboards/yandrstudio/rainbow65/keymaps/default/dev_oled/oled_driver.c create mode 100755 keyboards/yandrstudio/rainbow65/keymaps/default/dev_oled/oled_driver.h create mode 100755 keyboards/yandrstudio/rainbow65/keymaps/default/graph_lib/kb_press_graph.c create mode 100755 keyboards/yandrstudio/rainbow65/keymaps/default/graph_lib/kb_press_graph.h create mode 100755 keyboards/yandrstudio/rainbow65/keymaps/default/graph_lib/my_pic_lib.h create mode 100755 keyboards/yandrstudio/rainbow65/keymaps/default/graph_lib/wpm_graph.c create mode 100755 keyboards/yandrstudio/rainbow65/keymaps/default/graph_lib/wpm_graph.h create mode 100755 keyboards/yandrstudio/rainbow65/keymaps/default/keymap.c create mode 100755 keyboards/yandrstudio/rainbow65/keymaps/default/rgb_matrix_user.inc create mode 100755 keyboards/yandrstudio/rainbow65/keymaps/default/rules.mk create mode 100755 keyboards/yandrstudio/rainbow65/keymaps/test_oled/config.h create mode 100755 keyboards/yandrstudio/rainbow65/keymaps/test_oled/dev_oled/glcdfont.c create mode 100755 keyboards/yandrstudio/rainbow65/keymaps/test_oled/dev_oled/licenses.txt create mode 100755 keyboards/yandrstudio/rainbow65/keymaps/test_oled/dev_oled/oled_driver.c create mode 100755 keyboards/yandrstudio/rainbow65/keymaps/test_oled/dev_oled/oled_driver.h create mode 100755 keyboards/yandrstudio/rainbow65/keymaps/test_oled/graph_lib/kb_press_graph.c create mode 100755 keyboards/yandrstudio/rainbow65/keymaps/test_oled/graph_lib/kb_press_graph.h create mode 100755 keyboards/yandrstudio/rainbow65/keymaps/test_oled/graph_lib/my_pic_lib.h create mode 100755 keyboards/yandrstudio/rainbow65/keymaps/test_oled/graph_lib/wpm_graph.c create mode 100755 keyboards/yandrstudio/rainbow65/keymaps/test_oled/graph_lib/wpm_graph.h create mode 100755 keyboards/yandrstudio/rainbow65/keymaps/test_oled/keymap.c create mode 100755 keyboards/yandrstudio/rainbow65/keymaps/test_oled/rgb_matrix_user.inc create mode 100755 keyboards/yandrstudio/rainbow65/keymaps/test_oled/rules.mk create mode 100644 keyboards/yandrstudio/rainbow65/keymaps/test_rgb/config.h create mode 100755 keyboards/yandrstudio/rainbow65/keymaps/test_rgb/keymap copy.c create mode 100755 keyboards/yandrstudio/rainbow65/keymaps/test_rgb/keymap.c create mode 100755 keyboards/yandrstudio/rainbow65/keymaps/test_rgb/rgb_matrix_user.inc create mode 100755 keyboards/yandrstudio/rainbow65/keymaps/test_rgb/rules.mk create mode 100644 keyboards/yandrstudio/rainbow65/keymaps/test_via/config.h create mode 100755 keyboards/yandrstudio/rainbow65/keymaps/test_via/keymap.c create mode 100755 keyboards/yandrstudio/rainbow65/keymaps/test_via/rules.mk create mode 100755 keyboards/yandrstudio/rainbow65/mcuconf.h create mode 100755 keyboards/yandrstudio/rainbow65/r65.json create mode 100755 keyboards/yandrstudio/rainbow65/rainbow65.c create mode 100755 keyboards/yandrstudio/rainbow65/rainbow65.h create mode 100755 keyboards/yandrstudio/rainbow65/rules.mk create mode 100644 keyboards/yandrstudio/sb65p/config.h create mode 100644 keyboards/yandrstudio/sb65p/keymaps/default/keymap.c create mode 100644 keyboards/yandrstudio/sb65p/matrix.c create mode 100644 keyboards/yandrstudio/sb65p/rules.mk create mode 100644 keyboards/yandrstudio/sb65p/sb65p.c create mode 100644 keyboards/yandrstudio/sb65p/sb65p.h create mode 100755 keyboards/yandrstudio/utils/BiuMisicDance/audio_lib.py create mode 100755 keyboards/yandrstudio/utils/BiuMisicDance/yandr_hid_tool.py create mode 100755 keyboards/yandrstudio/utils/BiuMisicDance/yandr_hid_tool_test.py create mode 100755 keyboards/yandrstudio/utils/Font/font_user.py create mode 100755 keyboards/yandrstudio/utils/Font/rotate_font_tool.py create mode 100755 keyboards/yandrstudio/utils/RGB/getRgbMtrixPosition.js diff --git a/keyboards/yandrstudio/cool87/config.h b/keyboards/yandrstudio/cool87/config.h new file mode 100755 index 000000000000..1d5cd319cb19 --- /dev/null +++ b/keyboards/yandrstudio/cool87/config.h @@ -0,0 +1,58 @@ +#ifndef CONFIG_H +#define CONFIG_H + +#include "config_common.h" + +/* USB Device descriptor parameter */ +#define VENDOR_ID 0xAA96 +#define PRODUCT_ID 0xAA01 +#define DEVICE_VER 0x0001 +#define MANUFACTURER YandR studio +#define PRODUCT Y&R-Cool87 +#define DESCRIPTION YandR studio Cool87 + +/* key matrix size */ +#define MATRIX_ROWS 6 +#define MATRIX_COLS 17 + +/* key matrix pins */ +#define MATRIX_ROW_PINS { B1, B2, B3, B0, D3, D0 } +#define MATRIX_COL_PINS { E6, F0, F1, F4, F5, F6, F7, C7, C6, B6, B5, B4, D7, D6, B7, D2, D1 } +#define UNUSED_PINS + +/* COL2ROW or ROW2COL */ +#define DIODE_DIRECTION COL2ROW + +/* number of backlight levels */ + +#ifdef BACKLIGHT_PIN +#define BACKLIGHT_LEVELS 3 +#endif + +/* Set 0 if debouncing isn't needed */ +#define DEBOUNCING_DELAY 5 + +/* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */ +#define LOCKING_SUPPORT_ENABLE + +/* Locking resynchronize hack */ +#define LOCKING_RESYNC_ENABLE + +/* key combination for command */ +#define IS_COMMAND() ( \ + keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \ +) + +/* prevent stuck modifiers */ +#define PREVENT_STUCK_MODIFIERS + +#define RGB_DI_PIN D5 +#ifdef RGB_DI_PIN +#define RGBLIGHT_ANIMATIONS +#define RGBLED_NUM 1 +#define RGBLIGHT_HUE_STEP 8 +#define RGBLIGHT_SAT_STEP 8 +#define RGBLIGHT_VAL_STEP 8 +#endif + +#endif diff --git a/keyboards/yandrstudio/cool87/cool87.c b/keyboards/yandrstudio/cool87/cool87.c new file mode 100755 index 000000000000..0efcdb30a48f --- /dev/null +++ b/keyboards/yandrstudio/cool87/cool87.c @@ -0,0 +1 @@ +#include "cool87.h" diff --git a/keyboards/yandrstudio/cool87/cool87.h b/keyboards/yandrstudio/cool87/cool87.h new file mode 100755 index 000000000000..0968372f97ed --- /dev/null +++ b/keyboards/yandrstudio/cool87/cool87.h @@ -0,0 +1,23 @@ +#ifndef KB_H +#define KB_H + +#include "quantum.h" + +#define KEYMAP( \ + K000, K001, K002, K003, K004, K006, K007, K008, K009, K010, K011, K012, K013, K014, K015, K016, \ + K100, K101, K102, K103, K104, K105, K106, K107, K108, K109, K110, K111, K112, K113, K114, K115, K116, \ + K200, K201, K202, K203, K204, K205, K206, K207, K208, K209, K210, K211, K212, K213, K214, K215, K216, \ + K300, K301, K302, K303, K304, K305, K306, K307, K308, K309, K310, K311, K313, \ + K400, K401, K402, K403, K404, K405, K406, K407, K408, K409, K410, K413, K415, \ + K500, K501, K502, K506, K510, K511, K513, K514, K515, K516 \ + )\ + { \ + { K000, K001, K002, K003, K004, KC_NO, K006, K007, K008, K009, K010, K011, K012, K013, K014, K015, K016 }, \ + { K100, K101, K102, K103, K104, K105, K106, K107, K108, K109, K110, K111, K112, K113, K114, K115, K116 }, \ + { K200, K201, K202, K203, K204, K205, K206, K207, K208, K209, K210, K211, K212, K213, K214, K215, K216 }, \ + { K300, K301, K302, K303, K304, K305, K306, K307, K308, K309, K310, K311, KC_NO, K313, KC_NO, KC_NO, KC_NO }, \ + { K400, K401, K402, K403, K404, K405, K406, K407, K408, K409, K410, KC_NO, KC_NO, K413, KC_NO, K415, KC_NO }, \ + { K500, K501, K502, KC_NO, KC_NO, KC_NO, K506, KC_NO, KC_NO, KC_NO, K510, K511, KC_NO, K513, K514, K515, K516 } \ +} + +#endif diff --git a/keyboards/yandrstudio/cool87/keymaps/default/keymap.c b/keyboards/yandrstudio/cool87/keymaps/default/keymap.c new file mode 100755 index 000000000000..63305fa7e7c6 --- /dev/null +++ b/keyboards/yandrstudio/cool87/keymaps/default/keymap.c @@ -0,0 +1,215 @@ +#include "cool87.h" + +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + + KEYMAP( + KC_ESC, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_MUTE, KC_VOLU, KC_VOLD, + KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC, KC_INS, KC_HOME, KC_PGUP, + KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSLS, KC_DEL, KC_END, KC_PGDN, + KC_CAPS, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT, + KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, KC_UP, + KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, KC_RALT, MO(1), KC_RCTL, KC_LEFT, KC_DOWN, KC_RIGHT), + + KEYMAP( + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, RESET, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS), + + KEYMAP( + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS), + + KEYMAP( + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS), + + KEYMAP( + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS), + + KEYMAP( + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS), + + KEYMAP( + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS), + + KEYMAP( + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS), + + KEYMAP( + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS), + + KEYMAP( + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS), + + KEYMAP( + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS), + + KEYMAP( + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS), + + KEYMAP( + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS), + + KEYMAP( + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS), + + KEYMAP( + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS), + + KEYMAP( + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS) + +}; + +const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) { + // keyevent_t event = record->event; + + switch (id) { + + } + return MACRO_NONE; +} + +void matrix_init_user(void) { +} + +void matrix_scan_user(void) { +} + +#define CPP_MAIN_TMP "#include \nusing namespace std;\n\nint main() {\n\n return 0;\n}\n" +bool process_record_user(uint16_t keycode, keyrecord_t *record) { + switch (keycode) { + case KC_1: + if (biton32(layer_state) == 1 && record->event.pressed) { + SEND_STRING("572673807"); + return false; + } + break; + case KC_3: + if (biton32(layer_state) == 1 && record->event.pressed) { + SEND_STRING("572673807@qq.com"); + return false; + } + break; + case KC_0: + if (biton32(layer_state) == 1 && record->event.pressed) { + SEND_STRING("13719175883"); + return false; + } + break; + case KC_C: + if (biton32(layer_state) == 1 && record->event.pressed) { + SEND_STRING(CPP_MAIN_TMP); + return false; + } + break; + default: + break; + } + return true; +} + +void led_set_user(uint8_t usb_led) { + + if (usb_led & (1 << USB_LED_NUM_LOCK)) { + + } else { + + } + + if (usb_led & (1 << USB_LED_CAPS_LOCK)) { + + } else { + + } + + if (usb_led & (1 << USB_LED_SCROLL_LOCK)) { + + } else { + + } + + if (usb_led & (1 << USB_LED_COMPOSE)) { + + } else { + + } + + if (usb_led & (1 << USB_LED_KANA)) { + + } else { + + } + +} diff --git a/keyboards/yandrstudio/cool87/rules.mk b/keyboards/yandrstudio/cool87/rules.mk new file mode 100755 index 000000000000..5c44d2276121 --- /dev/null +++ b/keyboards/yandrstudio/cool87/rules.mk @@ -0,0 +1,57 @@ +# MCU name +MCU = atmega32u4 + +# Processor frequency. +# This will define a symbol, F_CPU, in all source code files equal to the +# processor frequency in Hz. You can then use this symbol in your source code to +# calculate timings. Do NOT tack on a 'UL' at the end, this will be done +# automatically to create a 32-bit value in your source code. +# +# This will be an integer division of F_USB below, as it is sourced by +# F_USB after it has run through any CPU prescalers. Note that this value +# does not *change* the processor frequency - it should merely be updated to +# reflect the processor speed set externally so that the code can use accurate +# software delays. +F_CPU = 16000000 + +# +# LUFA specific +# +# Target architecture (see library "Board Types" documentation). +ARCH = AVR8 + +# Input clock frequency. +# This will define a symbol, F_USB, in all source code files equal to the +# input clock frequency (before any prescaling is performed) in Hz. This value may +# differ from F_CPU if prescaling is used on the latter, and is required as the +# raw input clock is fed directly to the PLL sections of the AVR for high speed +# clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL' +# at the end, this will be done automatically to create a 32-bit value in your +# source code. +# +# If no clock division is performed on the input clock inside the AVR (via the +# CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU. +F_USB = $(F_CPU) + +# Interrupt driven control endpoint task(+60) +OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT + + +# Boot Section Size in *bytes* +OPT_DEFS += -DBOOTLOADER_SIZE=4096 + + +# Build Options +# comment out to disable the options. +# +BOOTMAGIC_ENABLE ?= yes # Virtual DIP switch configuration(+1000) +MOUSEKEY_ENABLE ?= no # Mouse keys(+4700) +EXTRAKEY_ENABLE ?= yes # Audio control and System control(+450) +CONSOLE_ENABLE ?= no # Console for debug(+400) +COMMAND_ENABLE ?= no # Commands for debug and configuration +SLEEP_LED_ENABLE ?= no # Breathing sleep LED during USB suspend +NKRO_ENABLE ?= yes # USB Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work +BACKLIGHT_ENABLE ?= no # Enable keyboard backlight functionality +AUDIO_ENABLE ?= no +# RGBLIGHT_ENABLE ?= yes +# VIA_ENABLE = yes diff --git a/keyboards/yandrstudio/nlhhkb/config.h b/keyboards/yandrstudio/nlhhkb/config.h new file mode 100644 index 000000000000..d8f7d9be441e --- /dev/null +++ b/keyboards/yandrstudio/nlhhkb/config.h @@ -0,0 +1,74 @@ +/* +Copyright 2012 Jun Wako + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +#ifndef CONFIG_H +#define CONFIG_H + +#include "config_common.h" + +/* USB Device descriptor parameter */ +#define VENDOR_ID 0xAA96 +#define PRODUCT_ID 0xAAA0 +#define DEVICE_VER 0x0001 +#define MANUFACTURER Biu (Jason Ren) +#define PRODUCT NLHHKB + +/* key matrix size */ +#define MATRIX_ROWS 5 +#define MATRIX_COLS 15 + +// ROWS: Top to bottom, COLS: Left to right + +#define MATRIX_ROW_PINS { D6, D7, B4, B5, E6} +#define MATRIX_COL_PINS { D4, B6, F0, F1, F4, F5, F6, F7, C7, C6, D5, D3, D2, D1, D0} +#define UNUSED_PINS + +/* COL2ROW or ROW2COL */ +#define DIODE_DIRECTION COL2ROW + + +// enable the nkro when using the VIA. +#define FORCE_NKRO + +// fix VIA RGB_light +#define VIA_HAS_BROKEN_KEYCODES + +/* define if matrix has ghost */ +//#define MATRIX_HAS_GHOST + +/* Set 0 if debouncing isn't needed */ +#define DEBOUNCE 5 + +/* + * Feature disable options + * These options are also useful to firmware size reduction. + */ + +/* disable debug print */ +//#define NO_DEBUG + +/* disable print */ +//#define NO_PRINT + +/* disable action features */ +//#define NO_ACTION_LAYER +//#define NO_ACTION_TAPPING +//#define NO_ACTION_ONESHOT +//#define NO_ACTION_MACRO +//#define NO_ACTION_FUNCTION + +#endif diff --git a/keyboards/yandrstudio/nlhhkb/info-via.json b/keyboards/yandrstudio/nlhhkb/info-via.json new file mode 100644 index 000000000000..565eba1fff18 --- /dev/null +++ b/keyboards/yandrstudio/nlhhkb/info-via.json @@ -0,0 +1,117 @@ +{ + "name": "HHKB (Biu)", + "vendorId": "0xFEED", + "productId": "0x6066", + "lighting": { + "extends": "none", + "keycodes": "qmk" + }, + "matrix": { "rows": 5, "cols": 15 }, + "layouts": { + "keymap": [ + { + "name": "via" + }, + [ + "0,0", + "0,1", + "0,2", + "0,3", + "0,4", + "0,5", + "0,6", + "0,7", + "0,8", + "0,9", + "0,10", + "0,11", + "0,12", + "0,13", + "0,14" + ], + [ + { + "w": 1.5 + }, + "1,0", + "1,1", + "1,2", + "1,3", + "1,4", + "1,5", + "1,6", + "1,7", + "1,8", + "1,9", + "1,10", + "1,11", + "1,12", + { + "w": 1.5 + }, + "1,14" + ], + [ + { + "w": 1.75 + }, + "2,0", + "2,1", + "2,2", + "2,3", + "2,4", + "2,5", + "2,6", + "2,7", + "2,8", + "2,9", + "2,10", + "2,11", + { + "w": 2.25 + }, + "2,13" + ], + [ + { + "w": 2.25 + }, + "3,0", + "3,1", + "3,2", + "3,3", + "3,4", + "3,5", + "3,6", + "3,7", + "3,8", + "3,9", + "3,10", + { + "w": 1.75 + }, + "3,12", + "3,14" + ], + [ + { + "x": 1.25 + }, + "4,0", + { + "w": 1.5 + }, + "4,1", + { + "w": 6.25 + }, + "4,6", + { + "w": 1.5 + }, + "4,10", + "4,12" + ] +] + } +} diff --git a/keyboards/yandrstudio/nlhhkb/keymaps/default/keymap.c b/keyboards/yandrstudio/nlhhkb/keymaps/default/keymap.c new file mode 100644 index 000000000000..83169589dc55 --- /dev/null +++ b/keyboards/yandrstudio/nlhhkb/keymaps/default/keymap.c @@ -0,0 +1,39 @@ + +#include QMK_KEYBOARD_H + +// 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. +// Layer names don't all need to be of the same length, obviously, and you can also skip them +// entirely and just use numbers. + + +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + KEYMAP( + KC_ESC, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSLS, KC_BSPC, + KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_DEL, + KC_CAPS, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT, + KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_LSFT, MO(1), + KC_LCTL, KC_LALT, KC_SPC, KC_LALT, KC_RCTL), + + KEYMAP( + KC_GRV, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_TRNS, KC_DEL, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS), + + KEYMAP( + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS), + + KEYMAP( + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS), + +}; diff --git a/keyboards/yandrstudio/nlhhkb/kle.json b/keyboards/yandrstudio/nlhhkb/kle.json new file mode 100644 index 000000000000..e1ddf1551853 --- /dev/null +++ b/keyboards/yandrstudio/nlhhkb/kle.json @@ -0,0 +1,110 @@ +[ + { + "name": "via" + }, + [ + "0,0", + "0,1", + "0,2", + "0,3", + "0,4", + "0,5", + "0,6", + "0,7", + "0,8", + "0,9", + "0,10", + "0,11", + "0,12", + "0,13", + "0,14" + ], + [ + { + "w": 1.5 + }, + "1,0", + "1,1", + "1,2", + "1,3", + "1,4", + "1,5", + "1,6", + "1,7", + "1,8", + "1,9", + "1,10", + "1,11", + "1,12", + { + "w": 1.5 + }, + "1,14" + ], + [ + { + "w": 1.75 + }, + "2,0", + "2,1", + "2,2", + "2,3", + "2,4", + "2,5", + "2,6", + "2,7", + "2,8", + "2,9", + "2,10", + "2,11", + { + "w": 2.25 + }, + "2,13" + ], + [ + { + "w": 2.25 + }, + "3,0", + "3,1", + "3,2", + "3,3", + "3,4", + "3,5", + "3,6", + "3,7", + "3,8", + "3,9", + "3,10", + { + "w": 1.75 + }, + "3,12", + "3,14" + ], + [ + { + "x": 1.25, + "w": 1.25 + }, + "4,0", + { + "w": 1.25 + }, + "4,1", + { + "w": 6.25 + }, + "4,6", + { + "w2": 1.25 + }, + "4,10", + { + "x": 0.25, + "w2": 1.25 + }, + "4,12" + ] +] \ No newline at end of file diff --git a/keyboards/yandrstudio/nlhhkb/nlhhkb.c b/keyboards/yandrstudio/nlhhkb/nlhhkb.c new file mode 100644 index 000000000000..e29c55c6aafa --- /dev/null +++ b/keyboards/yandrstudio/nlhhkb/nlhhkb.c @@ -0,0 +1 @@ +#include "nlhhkb.h" diff --git a/keyboards/yandrstudio/nlhhkb/nlhhkb.h b/keyboards/yandrstudio/nlhhkb/nlhhkb.h new file mode 100644 index 000000000000..54b324d09145 --- /dev/null +++ b/keyboards/yandrstudio/nlhhkb/nlhhkb.h @@ -0,0 +1,23 @@ +#ifndef NLHHKB_H +#define NLHHKB_H + +#include "quantum.h" + +// readability +#define XXX KC_NO + +#define KEYMAP( \ + K000, K001, K002, K003, K004, K005, K006, K007, K008, K009, K010, K011, K012, K013, K014, \ + K100, K101, K102, K103, K104, K105, K106, K107, K108, K109, K110, K111, K112, K114, \ + K200, K201, K202, K203, K204, K205, K206, K207, K208, K209, K210, K211, K213, \ + K300, K301, K302, K303, K304, K305, K306, K307, K308, K309, K310, K312, K314, \ + K400, K401, K406, K410, K412 \ +) { \ + { K000, K001, K002, K003, K004, K005, K006, K007, K008, K009, K010, K011, K012, K013, K014 }, \ + { K100, K101, K102, K103, K104, K105, K106, K107, K108, K109, K110, K111, K112, KC_NO, K114 }, \ + { K200, K201, K202, K203, K204, K205, K206, K207, K208, K209, K210, K211, KC_NO, K213, KC_NO }, \ + { K300, K301, K302, K303, K304, K305, K306, K307, K308, K309, K310, KC_NO, K312, KC_NO, K314 }, \ + { K400, K401, KC_NO, KC_NO, KC_NO, KC_NO, K406, KC_NO, KC_NO, KC_NO, K410, KC_NO, K412, KC_NO, KC_NO } \ +} + +#endif diff --git a/keyboards/yandrstudio/nlhhkb/readme.md b/keyboards/yandrstudio/nlhhkb/readme.md new file mode 100644 index 000000000000..394f86456224 --- /dev/null +++ b/keyboards/yandrstudio/nlhhkb/readme.md @@ -0,0 +1,14 @@ +AMJ60 +=== + +A 60% keyboard. + +Keyboard Maintainer: QMK Community +Hardware Supported: AMJ60 +Hardware Availability: https://geekhack.org/index.php?topic=77636.0 + +Make example for this keyboard (after setting up your build environment): + + make amj60:maximized + +See [build environment setup](https://docs.qmk.fm/#/getting_started_build_tools) then the [make instructions](https://docs.qmk.fm/#/getting_started_make_guide) for more information. diff --git a/keyboards/yandrstudio/nlhhkb/rules.mk b/keyboards/yandrstudio/nlhhkb/rules.mk new file mode 100644 index 000000000000..a06a78591f12 --- /dev/null +++ b/keyboards/yandrstudio/nlhhkb/rules.mk @@ -0,0 +1,34 @@ +# MCU name +MCU = atmega32u4 +# Processor frequency +F_CPU = 8000000 +# Bootloader selection +# Teensy halfkay +# Pro Micro caterina +# Atmel DFU atmel-dfu +# LUFA DFU lufa-dfu +# QMK DFU qmk-dfu +# ATmega32A bootloadHID +# ATmega328P USBasp +BOOTLOADER = atmel-dfu + +# Build Options +# comment out to disable the options. +# +BOOTMAGIC_ENABLE = lite # Virtual DIP switch configuration +MOUSEKEY_ENABLE = yes # Mouse keys +EXTRAKEY_ENABLE = yes # Audio control and System control +CONSOLE_ENABLE = no # Console for debug +COMMAND_ENABLE = yes # Commands for debug and configuration +NKRO_ENABLE = yes # USB Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work +RGBLIGHT_ENABLE = no # Enable keyboard underlight functionality +BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality +MIDI_ENABLE = no # MIDI controls +AUDIO_ENABLE = no +UNICODE_ENABLE = no # Unicode +BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID +LTO_ENABLE = yes # Reduce firmware size +# LAYOUTS = 60_ansi + + +VIA_ENABLE = yes # VIA support should be enabled here due to the main() loop will be compiled first. diff --git a/keyboards/yandrstudio/rainbow65/config.h b/keyboards/yandrstudio/rainbow65/config.h new file mode 100755 index 000000000000..c7219acf8591 --- /dev/null +++ b/keyboards/yandrstudio/rainbow65/config.h @@ -0,0 +1,93 @@ +#ifndef CONFIG_H +#define CONFIG_H + +#include "config_common.h" + +/* USB Device descriptor parameter */ +#define VENDOR_ID 0xAA96 +#define PRODUCT_ID 0xAA00 +#define DEVICE_VER 0x0001 +#define RAW_USAGE_PAGE 0xFF60 +#define MANUFACTURER yrstudio Jason Ren and magic mvp +#define PRODUCT rainbow65 +#define DESCRIPTION STM32 based 65 keyboard with full rgb, oled and encoder. + +/* key matrix set */ +#define MATRIX_ROWS 5 +#define MATRIX_COLS 15 + +#define MATRIX_ROW_PINS { B5, B4, A3, A2, B9 } +#define MATRIX_COL_PINS { A10, A9, A8, B14, B13, B12, B11, B10, B1, B0, A7, A6, A5, A4, B8 } + + +#define DIODE_DIRECTION COL2ROW +#define DEBOUNCE 5 + + + +// enable the nkro when using the VIA. +#define FORCE_NKRO + +// fix VIA RGB_light +#define VIA_HAS_BROKEN_KEYCODES + + + + +#ifdef RGBLIGHT_ENABLE +# define RGB_DI_PIN B15 +# define RGBLED_NUM 68 +# define RGBLIGHT_ANIMATIONS +#endif // RGBLIGHT_ENABLE + + + + +/* RGN Matrix */ +#ifdef RGB_MATRIX_ENABLE + +# define RGB_DI_PIN B15 +# define RGBLED_NUM 68 +# define DRIVER_LED_TOTAL RGBLED_NUM +#define WS2812_SPI SPID2 // default: SPID1 +#define WS2812_SPI_MOSI_PAL_MODE 5 + +# define RGB_MATRIX_MAXIMUM_BRIGHTNESS 180 +# define RGBLIGHT_VAL_STEP 18 +# define RGB_DISABLE_WHEN_USB_SUSPENDED true +# define RGB_MATRIX_CENTER { 32, 96 } +# define RGB_MATRIX_KEYPRESSES +# define RGB_MATRIX_FRAMEBUFFER_EFFECTS + +#endif + +/* Encoder */ +#ifdef ENCODER_ENABLE +# define ENCODERS_PAD_A { A15 } +# define ENCODERS_PAD_B { B3 } +# define ENCODER_RESOLUTION 4 +//# define ENCODER_DIRECTION_FLIP +#endif + +/* MOUSEKEY */ +#ifdef MOUSEKEY_ENABLE +# define MOUSEKEY_DELAY 0 +# define MOUSEKEY_INTERVAL 17 +# define MK_3_SPEED +# define MK_MOMENTARY_ACCEL +# define MK_C_OFFSET_UNMOD 64 +# define MK_C_INTERVAL_UNMOD 17 +#endif + + + +/* Others */ +#define TAP_HOLD_CAPS_DELAY 20 + +#ifdef CONSOLE_ENABLE +# define DEBUG_MATRIX_SCAN_RATE +#endif + +#endif + + diff --git a/keyboards/yandrstudio/rainbow65/info-via.json b/keyboards/yandrstudio/rainbow65/info-via.json new file mode 100755 index 000000000000..7995fb29978e --- /dev/null +++ b/keyboards/yandrstudio/rainbow65/info-via.json @@ -0,0 +1,157 @@ +{ + "name": "Rainbow65_Y&R", + "vendorId": "0xAA96", + "productId": "0xAA00", + "lighting": { + "extends": "none", + "keycodes": "qmk" + }, + "matrix": { "rows": 5, "cols": 15 }, + "layouts": { + "keymap": [ + { + "name": "via" + }, + [ + "0,0", + "0,1", + "0,2", + "0,3", + "0,4", + "0,5", + "0,6", + "0,7", + "0,8", + "0,9", + "0,10", + "0,11", + "0,12", + { + "w": 2 + }, + "0,13", + { + "x": 1 + }, + "0,14" + ], + [ + { + "y": -0.75, + "x": 15.25, + "w": 0.75, + "h": 0.75 + }, + "4,3", + { + "x": 1, + "w": 0.75, + "h": 0.75 + }, + "4,4" + ], + [ + { + "y": -0.25, + "w": 1.5 + }, + "1,0", + "1,1", + "1,2", + "1,3", + "1,4", + "1,5", + "1,6", + "1,7", + "1,8", + "1,9", + "1,10", + "1,11", + "1,12", + { + "w": 1.5 + }, + "1,13" + ], + [ + { + "w": 1.75 + }, + "2,0", + "2,1", + "2,2", + "2,3", + "2,4", + "2,5", + "2,6", + "2,7", + "2,8", + "2,9", + "2,10", + "2,11", + { + "w": 2.25 + }, + "2,12" + ], + [ + { + "w": 2.25 + }, + "3,0", + "3,1", + "3,2", + "3,3", + "3,4", + "3,5", + "3,6", + "3,7", + "3,8", + "3,9", + "3,10", + { + "w": 1.75 + }, + "3,11" + ], + [ + { + "y": -0.75, + "x": 14.25 + }, + "3,12" + ], + [ + { + "y": -0.25, + "w": 1.25 + }, + "4,0", + { + "w": 1.25 + }, + "4,1", + { + "w": 1.25 + }, + "4,2", + { + "w": 6.25 + }, + "4,5", + "4,8", + "4,9", + "4,10" + ], + [ + { + "y": -0.75, + "x": 13.25 + }, + "4,11", + "4,12", + "4,13" + ] + ] + } +} diff --git a/keyboards/yandrstudio/rainbow65/jason_fount.c b/keyboards/yandrstudio/rainbow65/jason_fount.c new file mode 100755 index 000000000000..2c37f38e61c1 --- /dev/null +++ b/keyboards/yandrstudio/rainbow65/jason_fount.c @@ -0,0 +1,137 @@ +#include "progmem.h" + +// Helidox 8x6 font with QMK Firmware Logo +// Online editor: http://teripom.x0.com/ + + +static const unsigned char font[] PROGMEM = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x3E, 0x5B, 0x4F, 0x5B, 0x3E, 0x00, + 0x3E, 0x6B, 0x4F, 0x6B, 0x3E, 0x00, + 0x1C, 0x3E, 0x7C, 0x3E, 0x1C, 0x00, + 0x18, 0x3C, 0x7E, 0x3C, 0x18, 0x00, + 0x1C, 0x57, 0x7D, 0x57, 0x1C, 0x00, + 0x1C, 0x5E, 0x7F, 0x5E, 0x1C, 0x00, + 0x00, 0x18, 0x3C, 0x18, 0x00, 0x00, + 0xFF, 0xE7, 0xC3, 0xE7, 0xFF, 0x00, + 0x00, 0x18, 0x24, 0x18, 0x00, 0x00, + 0xFF, 0xE7, 0xDB, 0xE7, 0xFF, 0x00, + 0x30, 0x48, 0x3A, 0x06, 0x0E, 0x00, + 0x26, 0x29, 0x79, 0x29, 0x26, 0x00, + 0x40, 0x7F, 0x05, 0x05, 0x07, 0x00, + 0x40, 0x7F, 0x05, 0x25, 0x3F, 0x00, + 0x5A, 0x3C, 0xE7, 0x3C, 0x5A, 0x00, + 0x7F, 0x3E, 0x1C, 0x1C, 0x08, 0x00, + 0x08, 0x1C, 0x1C, 0x3E, 0x7F, 0x00, + 0x14, 0x22, 0x7F, 0x22, 0x14, 0x00, + 0x5F, 0x5F, 0x00, 0x5F, 0x5F, 0x00, + 0x06, 0x09, 0x7F, 0x01, 0x7F, 0x00, + 0x00, 0x66, 0x89, 0x95, 0x6A, 0x00, + 0x60, 0x60, 0x60, 0x60, 0x60, 0x00, + 0x94, 0xA2, 0xFF, 0xA2, 0x94, 0x00, + 0x08, 0x04, 0x7E, 0x04, 0x08, 0x00, + 0x10, 0x20, 0x7E, 0x20, 0x10, 0x00, + 0x08, 0x08, 0x2A, 0x1C, 0x08, 0x00, + 0x08, 0x1C, 0x2A, 0x08, 0x08, 0x00, + 0x1E, 0x10, 0x10, 0x10, 0x10, 0x00, + 0x0C, 0x1E, 0x0C, 0x1E, 0x0C, 0x00, + 0x30, 0x38, 0x3E, 0x38, 0x30, 0x00, + 0x06, 0x0E, 0x3E, 0x0E, 0x06, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x5F, 0x00, 0x00, 0x00, + 0x00, 0x07, 0x00, 0x07, 0x00, 0x00, + 0x14, 0x7F, 0x14, 0x7F, 0x14, 0x00, + 0x24, 0x2A, 0x7F, 0x2A, 0x12, 0x00, + 0x23, 0x13, 0x08, 0x64, 0x62, 0x00, + 0x36, 0x49, 0x56, 0x20, 0x50, 0x00, + 0x00, 0x08, 0x07, 0x03, 0x00, 0x00, + 0x00, 0x1C, 0x22, 0x41, 0x00, 0x00, + 0x00, 0x41, 0x22, 0x1C, 0x00, 0x00, + 0x2A, 0x1C, 0x7F, 0x1C, 0x2A, 0x00, + 0x08, 0x08, 0x3E, 0x08, 0x08, 0x00, + 0x00, 0x80, 0x70, 0x30, 0x00, 0x00, + 0x08, 0x08, 0x08, 0x08, 0x08, 0x00, + 0x00, 0x00, 0x60, 0x60, 0x00, 0x00, + 0x20, 0x10, 0x08, 0x04, 0x02, 0x00, + 0x7C, 0xA2, 0x92, 0x8A, 0x7C, 0x00, + 0x00, 0x84, 0xFE, 0x80, 0x00, 0x00, + 0xE4, 0x92, 0x92, 0x92, 0x8C, 0x00, + 0x42, 0x82, 0x92, 0x9A, 0x66, 0x00, + 0x30, 0x28, 0x24, 0xFE, 0x20, 0x00, + 0x4E, 0x8A, 0x8A, 0x8A, 0x72, 0x00, + 0x78, 0x94, 0x92, 0x92, 0x62, 0x00, + 0x82, 0x42, 0x22, 0x12, 0x0E, 0x00, + 0x6C, 0x92, 0x92, 0x92, 0x6C, 0x00, + 0x8C, 0x92, 0x92, 0x52, 0x3C, 0x00, + 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, + 0x00, 0x40, 0x34, 0x00, 0x00, 0x00, + 0x00, 0x08, 0x14, 0x22, 0x41, 0x00, + 0x14, 0x14, 0x14, 0x14, 0x14, 0x00, + 0x00, 0x41, 0x22, 0x14, 0x08, 0x00, + 0x02, 0x01, 0x59, 0x09, 0x06, 0x00, + 0x3E, 0x41, 0x5D, 0x59, 0x4E, 0x00, + 0x7C, 0x12, 0x11, 0x12, 0x7C, 0x00, + 0x7F, 0x49, 0x49, 0x49, 0x36, 0x00, + 0x3E, 0x41, 0x41, 0x41, 0x22, 0x00, + 0x7F, 0x41, 0x41, 0x41, 0x3E, 0x00, + 0x7F, 0x49, 0x49, 0x49, 0x41, 0x00, + 0x7F, 0x09, 0x09, 0x09, 0x01, 0x00, + 0x3E, 0x41, 0x41, 0x51, 0x73, 0x00, + 0x7F, 0x08, 0x08, 0x08, 0x7F, 0x00, + 0x00, 0x41, 0x7F, 0x41, 0x00, 0x00, + 0x20, 0x40, 0x41, 0x3F, 0x01, 0x00, + 0x7F, 0x08, 0x14, 0x22, 0x41, 0x00, + 0x7F, 0x40, 0x40, 0x40, 0x40, 0x00, + 0x7F, 0x02, 0x1C, 0x02, 0x7F, 0x00, + 0x7F, 0x04, 0x08, 0x10, 0x7F, 0x00, + 0x3E, 0x41, 0x41, 0x41, 0x3E, 0x00, + 0x7F, 0x09, 0x09, 0x09, 0x06, 0x00, + 0x3E, 0x41, 0x51, 0x21, 0x5E, 0x00, + 0x7F, 0x09, 0x19, 0x29, 0x46, 0x00, + 0x26, 0x49, 0x49, 0x49, 0x32, 0x00, + 0x03, 0x01, 0x7F, 0x01, 0x03, 0x00, + 0x3F, 0x40, 0x40, 0x40, 0x3F, 0x00, + 0x1F, 0x20, 0x40, 0x20, 0x1F, 0x00, + 0x3F, 0x40, 0x38, 0x40, 0x3F, 0x00, + 0x63, 0x14, 0x08, 0x14, 0x63, 0x00, + 0x03, 0x04, 0x78, 0x04, 0x03, 0x00, + 0x61, 0x59, 0x49, 0x4D, 0x43, 0x00, + 0x00, 0x7F, 0x41, 0x41, 0x41, 0x00, + 0x02, 0x04, 0x08, 0x10, 0x20, 0x00, + 0x00, 0x41, 0x41, 0x41, 0x7F, 0x00, + 0x04, 0x02, 0x01, 0x02, 0x04, 0x00, + 0x40, 0x40, 0x40, 0x40, 0x40, 0x00, + 0x00, 0x03, 0x07, 0x08, 0x00, 0x00, + 0x20, 0x54, 0x54, 0x78, 0x40, 0x00, + 0x7F, 0x28, 0x44, 0x44, 0x38, 0x00, + 0x38, 0x44, 0x44, 0x44, 0x28, 0x00, + 0x38, 0x44, 0x44, 0x28, 0x7F, 0x00, + 0x38, 0x54, 0x54, 0x54, 0x18, 0x00, + 0x00, 0x08, 0x7E, 0x09, 0x02, 0x00, + 0x18, 0xA4, 0xA4, 0x9C, 0x78, 0x00, + 0x7F, 0x08, 0x04, 0x04, 0x78, 0x00, + 0x00, 0x44, 0x7D, 0x40, 0x00, 0x00, + 0x20, 0x40, 0x40, 0x3D, 0x00, 0x00, + 0x7F, 0x10, 0x28, 0x44, 0x00, 0x00, + 0x00, 0x41, 0x7F, 0x40, 0x00, 0x00, + 0x7C, 0x04, 0x78, 0x04, 0x78, 0x00, + 0x7C, 0x08, 0x04, 0x04, 0x78, 0x00, + 0x38, 0x44, 0x44, 0x44, 0x38, 0x00, + 0xFC, 0x18, 0x24, 0x24, 0x18, 0x00, + 0x18, 0x24, 0x24, 0x18, 0xFC, 0x00, + 0x7C, 0x08, 0x04, 0x04, 0x08, 0x00, + 0x48, 0x54, 0x54, 0x54, 0x24, 0x00, + 0x04, 0x04, 0x3F, 0x44, 0x24, 0x00, + 0x3C, 0x40, 0x40, 0x20, 0x7C, 0x00, + 0x1C, 0x20, 0x40, 0x20, 0x1C, 0x00, + 0x3C, 0x40, 0x30, 0x40, 0x3C, 0x00, + 0x44, 0x28, 0x10, 0x28, 0x44, 0x00, + 0x4C, 0x90, 0x90, 0x90, 0x7C, 0x00, + 0x44, 0x64, 0x54, 0x4C, 0x44, 0x00, + 0x00, 0x08, 0x36, 0x41, 0x00, 0x00, + 0x00, 0x00, 0x77, 0x00, 0x00, 0x00, + 0x00, 0x41, 0x36, 0x08, 0x00, 0x00, + 0x02, 0x01, 0x02, 0x04, 0x02, 0x00, + 0x3C, 0x26, 0x23, 0x26, 0x3C, 0x00, +}; + diff --git a/keyboards/yandrstudio/rainbow65/keymaps/default/config.h b/keyboards/yandrstudio/rainbow65/keymaps/default/config.h new file mode 100755 index 000000000000..2cc86c1fd1f4 --- /dev/null +++ b/keyboards/yandrstudio/rainbow65/keymaps/default/config.h @@ -0,0 +1,24 @@ +/* OLED */ +#ifdef OLED_DRIVER_ENABLE +// # define OLED_DISPLAY_128X64 +# define I2C_DRIVER I2CD1 +# define I2C1_TIMINGR_PRESC 0U +# define I2C1_TIMINGR_SCLDEL 7U +# define I2C1_TIMINGR_SDADEL 0U +# define I2C1_TIMINGR_SCLH 38U +# define I2C1_TIMINGR_SCLL 129U +# define OLED_BRIGHTNESS 50 +# define OLED_TIMEOUT 300000 +// # define OLED_TIMEOUT 0 +# define OLED_FONT_HEIGHT 8 +# define OLED_FONT_WIDTH 6 +# define OLED_FONT_H "../../jason_fount.c" +# define OLED_FONT_END 127 +# define OLED_FONT_START 0 +#endif + + +#ifdef TAP_DANCE_ENABLE +#define TAPPING_TERM 200 + +#endif diff --git a/keyboards/yandrstudio/rainbow65/keymaps/default/dev_oled/glcdfont.c b/keyboards/yandrstudio/rainbow65/keymaps/default/dev_oled/glcdfont.c new file mode 100755 index 000000000000..de5896018986 --- /dev/null +++ b/keyboards/yandrstudio/rainbow65/keymaps/default/dev_oled/glcdfont.c @@ -0,0 +1,16 @@ +#include "progmem.h" + +// Helidox 8x6 font with QMK Firmware Logo +// Online editor: http://teripom.x0.com/ + +static const unsigned char font[] PROGMEM = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3E, 0x5B, 0x4F, 0x5B, 0x3E, 0x00, 0x3E, 0x6B, 0x4F, 0x6B, 0x3E, 0x00, 0x1C, 0x3E, 0x7C, 0x3E, 0x1C, 0x00, 0x18, 0x3C, 0x7E, 0x3C, 0x18, 0x00, 0x1C, 0x57, 0x7D, 0x57, 0x1C, 0x00, 0x1C, 0x5E, 0x7F, 0x5E, 0x1C, 0x00, 0x00, 0x18, 0x3C, 0x18, 0x00, 0x00, 0xFF, 0xE7, 0xC3, 0xE7, 0xFF, 0x00, 0x00, 0x18, 0x24, 0x18, 0x00, 0x00, 0xFF, 0xE7, 0xDB, 0xE7, 0xFF, 0x00, 0x30, 0x48, 0x3A, 0x06, 0x0E, 0x00, 0x26, 0x29, 0x79, 0x29, 0x26, 0x00, 0x40, 0x7F, 0x05, 0x05, 0x07, 0x00, 0x40, 0x7F, 0x05, 0x25, 0x3F, 0x00, 0x5A, 0x3C, 0xE7, 0x3C, 0x5A, 0x00, 0x7F, 0x3E, 0x1C, 0x1C, 0x08, 0x00, 0x08, 0x1C, 0x1C, 0x3E, 0x7F, 0x00, 0x14, 0x22, 0x7F, 0x22, 0x14, 0x00, 0x5F, 0x5F, 0x00, 0x5F, 0x5F, 0x00, 0x06, 0x09, 0x7F, 0x01, 0x7F, 0x00, 0x00, 0x66, 0x89, 0x95, 0x6A, 0x00, 0x60, 0x60, 0x60, 0x60, 0x60, 0x00, 0x94, 0xA2, 0xFF, 0xA2, 0x94, 0x00, 0x08, 0x04, 0x7E, 0x04, 0x08, 0x00, + 0x10, 0x20, 0x7E, 0x20, 0x10, 0x00, 0x08, 0x08, 0x2A, 0x1C, 0x08, 0x00, 0x08, 0x1C, 0x2A, 0x08, 0x08, 0x00, 0x1E, 0x10, 0x10, 0x10, 0x10, 0x00, 0x0C, 0x1E, 0x0C, 0x1E, 0x0C, 0x00, 0x30, 0x38, 0x3E, 0x38, 0x30, 0x00, 0x06, 0x0E, 0x3E, 0x0E, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5F, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x07, 0x00, 0x00, 0x14, 0x7F, 0x14, 0x7F, 0x14, 0x00, 0x24, 0x2A, 0x7F, 0x2A, 0x12, 0x00, 0x23, 0x13, 0x08, 0x64, 0x62, 0x00, 0x36, 0x49, 0x56, 0x20, 0x50, 0x00, 0x00, 0x08, 0x07, 0x03, 0x00, 0x00, 0x00, 0x1C, 0x22, 0x41, 0x00, 0x00, 0x00, 0x41, 0x22, 0x1C, 0x00, 0x00, 0x2A, 0x1C, 0x7F, 0x1C, 0x2A, 0x00, 0x08, 0x08, 0x3E, 0x08, 0x08, 0x00, 0x00, 0x80, 0x70, 0x30, 0x00, 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x00, 0x00, 0x00, 0x60, 0x60, 0x00, 0x00, 0x20, 0x10, 0x08, 0x04, 0x02, 0x00, 0x3E, 0x51, 0x49, 0x45, 0x3E, 0x00, 0x00, 0x42, 0x7F, 0x40, 0x00, 0x00, + 0x72, 0x49, 0x49, 0x49, 0x46, 0x00, 0x21, 0x41, 0x49, 0x4D, 0x33, 0x00, 0x18, 0x14, 0x12, 0x7F, 0x10, 0x00, 0x27, 0x45, 0x45, 0x45, 0x39, 0x00, 0x3C, 0x4A, 0x49, 0x49, 0x31, 0x00, 0x41, 0x21, 0x11, 0x09, 0x07, 0x00, 0x36, 0x49, 0x49, 0x49, 0x36, 0x00, 0x46, 0x49, 0x49, 0x29, 0x1E, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x40, 0x34, 0x00, 0x00, 0x00, 0x00, 0x08, 0x14, 0x22, 0x41, 0x00, 0x14, 0x14, 0x14, 0x14, 0x14, 0x00, 0x00, 0x41, 0x22, 0x14, 0x08, 0x00, 0x02, 0x01, 0x59, 0x09, 0x06, 0x00, 0x3E, 0x41, 0x5D, 0x59, 0x4E, 0x00, 0x7C, 0x12, 0x11, 0x12, 0x7C, 0x00, 0x7F, 0x49, 0x49, 0x49, 0x36, 0x00, 0x3E, 0x41, 0x41, 0x41, 0x22, 0x00, 0x7F, 0x41, 0x41, 0x41, 0x3E, 0x00, 0x7F, 0x49, 0x49, 0x49, 0x41, 0x00, 0x7F, 0x09, 0x09, 0x09, 0x01, 0x00, 0x3E, 0x41, 0x41, 0x51, 0x73, 0x00, 0x7F, 0x08, 0x08, 0x08, 0x7F, 0x00, 0x00, 0x41, 0x7F, 0x41, 0x00, 0x00, 0x20, 0x40, 0x41, 0x3F, 0x01, 0x00, + 0x7F, 0x08, 0x14, 0x22, 0x41, 0x00, 0x7F, 0x40, 0x40, 0x40, 0x40, 0x00, 0x7F, 0x02, 0x1C, 0x02, 0x7F, 0x00, 0x7F, 0x04, 0x08, 0x10, 0x7F, 0x00, 0x3E, 0x41, 0x41, 0x41, 0x3E, 0x00, 0x7F, 0x09, 0x09, 0x09, 0x06, 0x00, 0x3E, 0x41, 0x51, 0x21, 0x5E, 0x00, 0x7F, 0x09, 0x19, 0x29, 0x46, 0x00, 0x26, 0x49, 0x49, 0x49, 0x32, 0x00, 0x03, 0x01, 0x7F, 0x01, 0x03, 0x00, 0x3F, 0x40, 0x40, 0x40, 0x3F, 0x00, 0x1F, 0x20, 0x40, 0x20, 0x1F, 0x00, 0x3F, 0x40, 0x38, 0x40, 0x3F, 0x00, 0x63, 0x14, 0x08, 0x14, 0x63, 0x00, 0x03, 0x04, 0x78, 0x04, 0x03, 0x00, 0x61, 0x59, 0x49, 0x4D, 0x43, 0x00, 0x00, 0x7F, 0x41, 0x41, 0x41, 0x00, 0x02, 0x04, 0x08, 0x10, 0x20, 0x00, 0x00, 0x41, 0x41, 0x41, 0x7F, 0x00, 0x04, 0x02, 0x01, 0x02, 0x04, 0x00, 0x40, 0x40, 0x40, 0x40, 0x40, 0x00, 0x00, 0x03, 0x07, 0x08, 0x00, 0x00, 0x20, 0x54, 0x54, 0x78, 0x40, 0x00, 0x7F, 0x28, 0x44, 0x44, 0x38, 0x00, 0x38, 0x44, 0x44, 0x44, 0x28, 0x00, + 0x38, 0x44, 0x44, 0x28, 0x7F, 0x00, 0x38, 0x54, 0x54, 0x54, 0x18, 0x00, 0x00, 0x08, 0x7E, 0x09, 0x02, 0x00, 0x18, 0xA4, 0xA4, 0x9C, 0x78, 0x00, 0x7F, 0x08, 0x04, 0x04, 0x78, 0x00, 0x00, 0x44, 0x7D, 0x40, 0x00, 0x00, 0x20, 0x40, 0x40, 0x3D, 0x00, 0x00, 0x7F, 0x10, 0x28, 0x44, 0x00, 0x00, 0x00, 0x41, 0x7F, 0x40, 0x00, 0x00, 0x7C, 0x04, 0x78, 0x04, 0x78, 0x00, 0x7C, 0x08, 0x04, 0x04, 0x78, 0x00, 0x38, 0x44, 0x44, 0x44, 0x38, 0x00, 0xFC, 0x18, 0x24, 0x24, 0x18, 0x00, 0x18, 0x24, 0x24, 0x18, 0xFC, 0x00, 0x7C, 0x08, 0x04, 0x04, 0x08, 0x00, 0x48, 0x54, 0x54, 0x54, 0x24, 0x00, 0x04, 0x04, 0x3F, 0x44, 0x24, 0x00, 0x3C, 0x40, 0x40, 0x20, 0x7C, 0x00, 0x1C, 0x20, 0x40, 0x20, 0x1C, 0x00, 0x3C, 0x40, 0x30, 0x40, 0x3C, 0x00, 0x44, 0x28, 0x10, 0x28, 0x44, 0x00, 0x4C, 0x90, 0x90, 0x90, 0x7C, 0x00, 0x44, 0x64, 0x54, 0x4C, 0x44, 0x00, 0x00, 0x08, 0x36, 0x41, 0x00, 0x00, 0x00, 0x00, 0x77, 0x00, 0x00, 0x00, + 0x00, 0x41, 0x36, 0x08, 0x00, 0x00, 0x02, 0x01, 0x02, 0x04, 0x02, 0x00, 0x3C, 0x26, 0x23, 0x26, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x40, 0x40, 0xF0, 0xF8, 0xF8, 0xFF, 0x38, 0xFF, 0xF8, 0xF8, 0x3F, 0xF8, 0xF8, 0xFF, 0x38, 0xFF, 0xF8, 0xF8, 0xF0, 0x40, 0x40, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xC0, 0xC0, 0xC0, 0x80, 0x00, 0x00, 0xC0, 0xC0, 0x80, 0x00, 0x00, 0x00, 0x80, 0xC0, 0xC0, 0x00, 0xC0, 0xC0, 0x00, 0x00, 0x80, 0xC0, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0x00, 0xC0, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xF0, 0xF8, 0xFC, 0x3E, + 0x1E, 0x06, 0x01, 0x00, 0x00, 0x00, 0x7F, 0x41, 0x41, 0x41, 0x7F, 0x00, 0x7F, 0x41, 0x41, 0x41, 0x7F, 0x00, 0x00, 0x80, 0xC0, 0xE0, 0x7E, 0x5B, 0x4F, 0x5B, 0xFE, 0xC0, 0x00, 0x00, 0xC0, 0x00, 0xDC, 0xD7, 0xDE, 0xDE, 0xDE, 0xD7, 0xDC, 0x00, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x49, 0x49, 0x49, 0xFF, 0xFF, 0xFF, 0xFF, 0xE0, 0xDF, 0xBF, 0xBF, 0x00, 0xBF, 0xBF, 0xDF, 0xE0, 0xFF, 0xFF, 0xFF, 0xFF, 0x49, 0x49, 0x49, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x3F, 0x60, 0x60, 0xE0, 0xBF, 0x1F, 0x00, 0x7F, 0x7F, 0x07, 0x1E, 0x38, 0x1E, 0x07, 0x7F, 0x7F, 0x00, 0x7F, 0x7F, 0x0E, 0x1F, 0x3B, 0x71, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0x7F, 0x0C, 0x0C, 0x0C, 0x00, 0x7E, 0x7E, 0x00, 0x7F, 0x7E, 0x03, 0x03, 0x00, 0x7F, 0x7E, 0x03, 0x03, 0x7E, 0x7E, 0x03, 0x03, 0x7F, 0x7E, 0x00, 0x0F, + 0x3E, 0x70, 0x3C, 0x06, 0x3C, 0x70, 0x3E, 0x0F, 0x00, 0x32, 0x7B, 0x49, 0x49, 0x3F, 0x7E, 0x00, 0x7F, 0x7E, 0x03, 0x03, 0x00, 0x1E, 0x3F, 0x69, 0x69, 0x6F, 0x26, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x0F, 0x1F, 0x3F, 0x3C, 0x78, 0x70, 0x60, 0x00, 0x00, 0x00, 0x7F, 0x41, 0x41, 0x41, 0x7F, 0x00, 0x7F, 0x41, 0x41, 0x41, 0x7F, 0x00, 0x30, 0x7B, 0x7F, 0x78, 0x30, 0x20, 0x20, 0x30, 0x78, 0x7F, 0x3B, 0x00, 0x03, 0x00, 0x0F, 0x7F, 0x0F, 0x0F, 0x0F, 0x7F, 0x0F, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x07, 0x0F, 0x0F, 0x7F, 0x0F, 0x7F, 0x0F, 0x0F, 0x7E, 0x0F, 0x0F, 0x7F, 0x0F, 0x7F, 0x0F, 0x0F, 0x07, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +}; diff --git a/keyboards/yandrstudio/rainbow65/keymaps/default/dev_oled/licenses.txt b/keyboards/yandrstudio/rainbow65/keymaps/default/dev_oled/licenses.txt new file mode 100755 index 000000000000..111603ebf3c7 --- /dev/null +++ b/keyboards/yandrstudio/rainbow65/keymaps/default/dev_oled/licenses.txt @@ -0,0 +1,45 @@ +The Android robot is reproduced or modified from work created and shared by Google and used according to terms described in the Creative Commons 3.0 Attribution License. + + +This is the Linux-penguin again... + +Originally drewn by Larry Ewing (http://www.isc.tamu.edu/~lewing/) +(with the GIMP) the Linux Logo has been vectorized by me (Simon Budig, +http://www.home.unix-ag.org/simon/). + +This happened quite some time ago with Corel Draw 4. But luckily +meanwhile there are tools available to handle vector graphics with +Linux. Bernhard Herzog (bernhard@users.sourceforge.net) deserves kudos +for creating Sketch (http://sketch.sourceforge.net), a powerful free +tool for creating vector graphics. He converted the Corel Draw file to +the Sketch native format. Since I am unable to maintain the Corel Draw +file any longer, the Sketch version now is the "official" one. + +Anja Gerwinski (anja@gerwinski.de) has created an alternate version of +the penguin (penguin-variant.sk) with a thinner mouth line and slightly +altered gradients. It also features a nifty drop shadow. + +The third bird (penguin-flat.sk) is a version reduced to three colors +(black/white/yellow) for e.g. silk screen printing. I made this version +for a mug, available at the friendly folks at +http://www.kernelconcepts.de/ - they do good stuff, mail Petra +(pinguin@kernelconcepts.de) if you need something special or don't +understand the german :-) + +These drawings are copyrighted by Larry Ewing and Simon Budig +(penguin-variant.sk also by Anja Gerwinski), redistribution is free but +has to include this README/Copyright notice. + +The use of these drawings is free. However I am happy about a sample of +your mug/t-shirt/whatever with this penguin on it... + +Have fun + Simon Budig + + +Simon.Budig@unix-ag.org +http://www.home.unix-ag.org/simon/ + +Simon Budig +Am Hardtkoeppel 2 +D-61279 Graevenwiesbach diff --git a/keyboards/yandrstudio/rainbow65/keymaps/default/dev_oled/oled_driver.c b/keyboards/yandrstudio/rainbow65/keymaps/default/dev_oled/oled_driver.c new file mode 100755 index 000000000000..23b81e5ad9f3 --- /dev/null +++ b/keyboards/yandrstudio/rainbow65/keymaps/default/dev_oled/oled_driver.c @@ -0,0 +1,767 @@ +/* +Copyright 2019 Ryan Caltabiano + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ +#include "i2c_master.h" +#include "oled_driver.h" +#include OLED_FONT_H +#include "timer.h" +#include "print.h" + +#include + +#include "progmem.h" + +// Used commands from spec sheet: https://cdn-shop.adafruit.com/datasheets/SSD1306.pdf +// for SH1106: https://www.velleman.eu/downloads/29/infosheets/sh1106_datasheet.pdf + +// Fundamental Commands +#define CONTRAST 0x81 +#define DISPLAY_ALL_ON 0xA5 +#define DISPLAY_ALL_ON_RESUME 0xA4 +#define NORMAL_DISPLAY 0xA6 +#define DISPLAY_ON 0xAF +#define DISPLAY_OFF 0xAE +#define NOP 0xE3 + +// Scrolling Commands +#define ACTIVATE_SCROLL 0x2F +#define DEACTIVATE_SCROLL 0x2E +#define SCROLL_RIGHT 0x26 +#define SCROLL_LEFT 0x27 +#define SCROLL_RIGHT_UP 0x29 +#define SCROLL_LEFT_UP 0x2A + +// Addressing Setting Commands +#define MEMORY_MODE 0x20 +#define COLUMN_ADDR 0x21 +#define PAGE_ADDR 0x22 +#define PAM_SETCOLUMN_LSB 0x00 +#define PAM_SETCOLUMN_MSB 0x10 +#define PAM_PAGE_ADDR 0xB0 // 0xb0 -- 0xb7 + +// Hardware Configuration Commands +#define DISPLAY_START_LINE 0x40 +#define SEGMENT_REMAP 0xA0 +#define SEGMENT_REMAP_INV 0xA1 +#define MULTIPLEX_RATIO 0xA8 +#define COM_SCAN_INC 0xC0 +#define COM_SCAN_DEC 0xC8 +#define DISPLAY_OFFSET 0xD3 +#define COM_PINS 0xDA +#define COM_PINS_SEQ 0x02 +#define COM_PINS_ALT 0x12 +#define COM_PINS_SEQ_LR 0x22 +#define COM_PINS_ALT_LR 0x32 + +// Timing & Driving Commands +#define DISPLAY_CLOCK 0xD5 +#define PRE_CHARGE_PERIOD 0xD9 +#define VCOM_DETECT 0xDB + +// Charge Pump Commands +#define CHARGE_PUMP 0x8D + +// Misc defines +#ifndef OLED_BLOCK_COUNT +# define OLED_BLOCK_COUNT (sizeof(OLED_BLOCK_TYPE) * 8) +#endif +#ifndef OLED_BLOCK_SIZE +# define OLED_BLOCK_SIZE (OLED_MATRIX_SIZE / OLED_BLOCK_COUNT) +#endif + +#define OLED_ALL_BLOCKS_MASK (((((OLED_BLOCK_TYPE)1 << (OLED_BLOCK_COUNT - 1)) - 1) << 1) | 1) + +// i2c defines +#define I2C_CMD 0x00 +#define I2C_DATA 0x40 +#if defined(__AVR__) +# define I2C_TRANSMIT_P(data) i2c_transmit_P((OLED_DISPLAY_ADDRESS << 1), &data[0], sizeof(data), OLED_I2C_TIMEOUT) +#else // defined(__AVR__) +# define I2C_TRANSMIT_P(data) i2c_transmit((OLED_DISPLAY_ADDRESS << 1), &data[0], sizeof(data), OLED_I2C_TIMEOUT) +#endif // defined(__AVR__) +#define I2C_TRANSMIT(data) i2c_transmit((OLED_DISPLAY_ADDRESS << 1), &data[0], sizeof(data), OLED_I2C_TIMEOUT) +#define I2C_WRITE_REG(mode, data, size) i2c_writeReg((OLED_DISPLAY_ADDRESS << 1), mode, data, size, OLED_I2C_TIMEOUT) + +#define HAS_FLAGS(bits, flags) ((bits & flags) == flags) + +// Display buffer's is the same as the OLED memory layout +// this is so we don't end up with rounding errors with +// parts of the display unusable or don't get cleared correctly +// and also allows for drawing & inverting +uint8_t oled_buffer[OLED_MATRIX_SIZE]; +uint8_t * oled_cursor; +OLED_BLOCK_TYPE oled_dirty = 0; +bool oled_initialized = false; +bool oled_active = false; +bool oled_scrolling = false; +uint8_t oled_brightness = OLED_BRIGHTNESS; +uint8_t oled_rotation = 0; +uint8_t oled_rotation_width = 0; +uint8_t oled_scroll_speed = 0; // this holds the speed after being remapped to ssd1306 internal values +uint8_t oled_scroll_start = 0; +uint8_t oled_scroll_end = 7; +#if OLED_TIMEOUT > 0 +uint32_t oled_timeout; +#endif +#if OLED_SCROLL_TIMEOUT > 0 +uint32_t oled_scroll_timeout; +#endif +#if OLED_UPDATE_INTERVAL > 0 +uint16_t oled_update_timeout; +#endif + +// Internal variables to reduce math instructions + +#if defined(__AVR__) +// identical to i2c_transmit, but for PROGMEM since all initialization is in PROGMEM arrays currently +// probably should move this into i2c_master... +static i2c_status_t i2c_transmit_P(uint8_t address, const uint8_t *data, uint16_t length, uint16_t timeout) { + i2c_status_t status = i2c_start(address | I2C_WRITE, timeout); + + for (uint16_t i = 0; i < length && status >= 0; i++) { + status = i2c_write(pgm_read_byte((const char *)data++), timeout); + if (status) break; + } + + i2c_stop(); + + return status; +} +#endif + +// Flips the rendering bits for a character at the current cursor position +static void InvertCharacter(uint8_t *cursor) { + const uint8_t *end = cursor + OLED_FONT_WIDTH; + while (cursor < end) { + *cursor = ~(*cursor); + cursor++; + } +} + +bool oled_init(uint8_t rotation) { + oled_rotation = oled_init_user(rotation); + if (!HAS_FLAGS(oled_rotation, OLED_ROTATION_90)) { + oled_rotation_width = OLED_DISPLAY_WIDTH; + } else { + oled_rotation_width = OLED_DISPLAY_HEIGHT; + } + i2c_init(); + + static const uint8_t PROGMEM display_setup1[] = { + I2C_CMD, + DISPLAY_OFF, + DISPLAY_CLOCK, + 0x80, + MULTIPLEX_RATIO, + OLED_DISPLAY_HEIGHT - 1, + DISPLAY_OFFSET, + 0x00, + DISPLAY_START_LINE | 0x00, + CHARGE_PUMP, + 0x14, +#if (OLED_IC != OLED_IC_SH1106) + // MEMORY_MODE is unsupported on SH1106 (Page Addressing only) + MEMORY_MODE, + 0x00, // Horizontal addressing mode +#endif + }; + if (I2C_TRANSMIT_P(display_setup1) != I2C_STATUS_SUCCESS) { + print("oled_init cmd set 1 failed\n"); + return false; + } + + if (!HAS_FLAGS(oled_rotation, OLED_ROTATION_180)) { + static const uint8_t PROGMEM display_normal[] = {I2C_CMD, SEGMENT_REMAP_INV, COM_SCAN_DEC}; + if (I2C_TRANSMIT_P(display_normal) != I2C_STATUS_SUCCESS) { + print("oled_init cmd normal rotation failed\n"); + return false; + } + } else { + static const uint8_t PROGMEM display_flipped[] = {I2C_CMD, SEGMENT_REMAP, COM_SCAN_INC}; + if (I2C_TRANSMIT_P(display_flipped) != I2C_STATUS_SUCCESS) { + print("display_flipped failed\n"); + return false; + } + } + + static const uint8_t PROGMEM display_setup2[] = {I2C_CMD, COM_PINS, OLED_COM_PINS, CONTRAST, OLED_BRIGHTNESS, PRE_CHARGE_PERIOD, 0xF1, VCOM_DETECT, 0x20, DISPLAY_ALL_ON_RESUME, NORMAL_DISPLAY, DEACTIVATE_SCROLL, DISPLAY_ON}; + if (I2C_TRANSMIT_P(display_setup2) != I2C_STATUS_SUCCESS) { + print("display_setup2 failed\n"); + return false; + } + +#if OLED_TIMEOUT > 0 + oled_timeout = timer_read32() + OLED_TIMEOUT; +#endif +#if OLED_SCROLL_TIMEOUT > 0 + oled_scroll_timeout = timer_read32() + OLED_SCROLL_TIMEOUT; +#endif + + oled_clear(); + oled_initialized = true; + oled_active = true; + oled_scrolling = false; + return true; +} + +__attribute__((weak)) oled_rotation_t oled_init_user(oled_rotation_t rotation) { return rotation; } + +void oled_clear(void) { + memset(oled_buffer, 0, sizeof(oled_buffer)); + oled_cursor = &oled_buffer[0]; + oled_dirty = OLED_ALL_BLOCKS_MASK; +} + +static void calc_bounds(uint8_t update_start, uint8_t *cmd_array) { + // Calculate commands to set memory addressing bounds. + uint8_t start_page = OLED_BLOCK_SIZE * update_start / OLED_DISPLAY_WIDTH; + uint8_t start_column = OLED_BLOCK_SIZE * update_start % OLED_DISPLAY_WIDTH; +#if (OLED_IC == OLED_IC_SH1106) + // Commands for Page Addressing Mode. Sets starting page and column; has no end bound. + // Column value must be split into high and low nybble and sent as two commands. + cmd_array[0] = PAM_PAGE_ADDR | start_page; + cmd_array[1] = PAM_SETCOLUMN_LSB | ((OLED_COLUMN_OFFSET + start_column) & 0x0f); + cmd_array[2] = PAM_SETCOLUMN_MSB | ((OLED_COLUMN_OFFSET + start_column) >> 4 & 0x0f); + cmd_array[3] = NOP; + cmd_array[4] = NOP; + cmd_array[5] = NOP; +#else + // Commands for use in Horizontal Addressing mode. + cmd_array[1] = start_column; + cmd_array[4] = start_page; + cmd_array[2] = (OLED_BLOCK_SIZE + OLED_DISPLAY_WIDTH - 1) % OLED_DISPLAY_WIDTH + cmd_array[1]; + cmd_array[5] = (OLED_BLOCK_SIZE + OLED_DISPLAY_WIDTH - 1) / OLED_DISPLAY_WIDTH - 1; +#endif +} + +static void calc_bounds_90(uint8_t update_start, uint8_t *cmd_array) { + cmd_array[1] = OLED_BLOCK_SIZE * update_start / OLED_DISPLAY_HEIGHT * 8; + cmd_array[4] = OLED_BLOCK_SIZE * update_start % OLED_DISPLAY_HEIGHT; + cmd_array[2] = (OLED_BLOCK_SIZE + OLED_DISPLAY_HEIGHT - 1) / OLED_DISPLAY_HEIGHT * 8 - 1 + cmd_array[1]; + ; + cmd_array[5] = (OLED_BLOCK_SIZE + OLED_DISPLAY_HEIGHT - 1) % OLED_DISPLAY_HEIGHT / 8; +} + +uint8_t crot(uint8_t a, int8_t n) { + const uint8_t mask = 0x7; + n &= mask; + return a << n | a >> (-n & mask); +} + +static void rotate_90(const uint8_t *src, uint8_t *dest) { + for (uint8_t i = 0, shift = 7; i < 8; ++i, --shift) { + uint8_t selector = (1 << i); + for (uint8_t j = 0; j < 8; ++j) { + dest[i] |= crot(src[j] & selector, shift - (int8_t)j); + } + } +} + +void oled_render(void) { + if (!oled_initialized) { + return; + } + + // Do we have work to do? + oled_dirty &= OLED_ALL_BLOCKS_MASK; + if (!oled_dirty || oled_scrolling) { + return; + } + + // Find first dirty block + uint8_t update_start = 0; + while (!(oled_dirty & ((OLED_BLOCK_TYPE)1 << update_start))) { + ++update_start; + } + + // Set column & page position + static uint8_t display_start[] = {I2C_CMD, COLUMN_ADDR, 0, OLED_DISPLAY_WIDTH - 1, PAGE_ADDR, 0, OLED_DISPLAY_HEIGHT / 8 - 1}; + if (!HAS_FLAGS(oled_rotation, OLED_ROTATION_90)) { + calc_bounds(update_start, &display_start[1]); // Offset from I2C_CMD byte at the start + } else { + calc_bounds_90(update_start, &display_start[1]); // Offset from I2C_CMD byte at the start + } + + // Send column & page position + if (I2C_TRANSMIT(display_start) != I2C_STATUS_SUCCESS) { + print("oled_render offset command failed\n"); + return; + } + + if (!HAS_FLAGS(oled_rotation, OLED_ROTATION_90)) { + // Send render data chunk as is + if (I2C_WRITE_REG(I2C_DATA, &oled_buffer[OLED_BLOCK_SIZE * update_start], OLED_BLOCK_SIZE) != I2C_STATUS_SUCCESS) { + print("oled_render data failed\n"); + return; + } + } else { + // Rotate the render chunks + const static uint8_t source_map[] = OLED_SOURCE_MAP; + const static uint8_t target_map[] = OLED_TARGET_MAP; + + static uint8_t temp_buffer[OLED_BLOCK_SIZE]; + memset(temp_buffer, 0, sizeof(temp_buffer)); + for (uint8_t i = 0; i < sizeof(source_map); ++i) { + rotate_90(&oled_buffer[OLED_BLOCK_SIZE * update_start + source_map[i]], &temp_buffer[target_map[i]]); + } + + // Send render data chunk after rotating + if (I2C_WRITE_REG(I2C_DATA, &temp_buffer[0], OLED_BLOCK_SIZE) != I2C_STATUS_SUCCESS) { + print("oled_render90 data failed\n"); + return; + } + } + + // Turn on display if it is off + oled_on(); + + // Clear dirty flag + oled_dirty &= ~((OLED_BLOCK_TYPE)1 << update_start); +} + +void oled_set_cursor(uint8_t col, uint8_t line) { + uint16_t index = line * oled_rotation_width + col * OLED_FONT_WIDTH; + + // Out of bounds? + if (index >= OLED_MATRIX_SIZE) { + index = 0; + } + + oled_cursor = &oled_buffer[index]; +} +void oled_set_precise_cursor(uint16_t index) { + // Out of bounds? + if (index >= OLED_MATRIX_SIZE) { + index = 0; + } + oled_cursor = &oled_buffer[index]; +} +void oled_advance_page(bool clearPageRemainder) { + uint16_t index = oled_cursor - &oled_buffer[0]; + uint8_t remaining = (oled_rotation_width - (index % oled_rotation_width))%oled_rotation_width; + + if (clearPageRemainder) { + // Remaining Char count + remaining = remaining / OLED_FONT_WIDTH; + + // Write empty character until next line + while (remaining--) oled_write_char(' ', false); + } else { + // Next page index out of bounds? + if (index + remaining >= OLED_MATRIX_SIZE) { + index = 0; + remaining = 0; + } + + oled_cursor = &oled_buffer[index + remaining]; + } +} + +void oled_advance_char(void) { + uint16_t nextIndex = oled_cursor - &oled_buffer[0] + OLED_FONT_WIDTH; + uint8_t remainingSpace = oled_rotation_width - (nextIndex % oled_rotation_width); + + // Do we have enough space on the current line for the next character + if (remainingSpace < OLED_FONT_WIDTH) { + nextIndex += remainingSpace; + } + + // Did we go out of bounds + if (nextIndex >= OLED_MATRIX_SIZE) { + nextIndex = 0; + } + + // Update cursor position + oled_cursor = &oled_buffer[nextIndex]; +} + +// Main handler that writes character data to the display buffer +void oled_write_char(const char data, bool invert) { + // Advance to the next line if newline + if (data == '\n') { + // Old source wrote ' ' until end of line... + oled_advance_page(true); + return; + } + + if (data == '\r') { + oled_advance_page(false); + return; + } + + // copy the current render buffer to check for dirty after + static uint8_t oled_temp_buffer[OLED_FONT_WIDTH]; + memcpy(&oled_temp_buffer, oled_cursor, OLED_FONT_WIDTH); + + _Static_assert(sizeof(font) >= ((OLED_FONT_END + 1 - OLED_FONT_START) * OLED_FONT_WIDTH), "OLED_FONT_END references outside array"); + + // set the reder buffer data + uint8_t cast_data = (uint8_t)data; // font based on unsigned type for index + if (cast_data < OLED_FONT_START || cast_data > OLED_FONT_END) { + memset(oled_cursor, 0x00, OLED_FONT_WIDTH); + } else { + const uint8_t *glyph = &font[(cast_data - OLED_FONT_START) * OLED_FONT_WIDTH]; + memcpy_P(oled_cursor, glyph, OLED_FONT_WIDTH); + } + + // Invert if needed + if (invert) { + InvertCharacter(oled_cursor); + } + + // Dirty check + if (memcmp(&oled_temp_buffer, oled_cursor, OLED_FONT_WIDTH)) { + uint16_t index = oled_cursor - &oled_buffer[0]; + oled_dirty |= ((OLED_BLOCK_TYPE)1 << (index / OLED_BLOCK_SIZE)); + // Edgecase check if the written data spans the 2 chunks + oled_dirty |= ((OLED_BLOCK_TYPE)1 << ((index + OLED_FONT_WIDTH - 1) / OLED_BLOCK_SIZE)); + } + + // Finally move to the next char + oled_advance_char(); +} + +void oled_write(const char *data, bool invert) { + const char *end = data + strlen(data); + while (data < end) { + oled_write_char(*data, invert); + data++; + } +} + +void oled_write_ln(const char *data, bool invert) { + oled_write(data, invert); + oled_advance_page(true); +} + +void oled_pan(bool left) { + uint16_t i = 0; + for (uint16_t y = 0; y < OLED_DISPLAY_HEIGHT / 8; y++) { + if (left) { + for (uint16_t x = 0; x < OLED_DISPLAY_WIDTH - 1; x++) { + i = y * OLED_DISPLAY_WIDTH + x; + oled_buffer[i] = oled_buffer[i + 1]; + } + } else { + for (uint16_t x = OLED_DISPLAY_WIDTH - 1; x > 0; x--) { + i = y * OLED_DISPLAY_WIDTH + x; + oled_buffer[i] = oled_buffer[i - 1]; + } + } + } + oled_dirty = OLED_ALL_BLOCKS_MASK; +} + +void oled_precise_pan(bool left, uint16_t index) { + if (index>OLED_MATRIX_SIZE-1) { + return; + } + if (left) { + for (uint16_t x = 0; x < index; x++) { + oled_buffer[x] = oled_buffer[x + 1]; + } + } else { + for (uint16_t x = OLED_MATRIX_SIZE - 1; x > index; x--) { + oled_buffer[x] = oled_buffer[x - 1]; + } + } + oled_dirty = OLED_ALL_BLOCKS_MASK; +} +void oled_precise_pan_h(bool left, uint16_t start_line) { + uint16_t i = 0; + uint16_t oled_rotation_height = 8 * OLED_MATRIX_SIZE / oled_rotation_width; + for (uint16_t y = start_line; y < oled_rotation_height / 8; y++) { + if (left) { + for (uint16_t x = 0; x < oled_rotation_width - 1; x++) { + i = y * oled_rotation_width + x; + oled_buffer[i] = oled_buffer[i + 1]; + } + } else { + for (uint16_t x = oled_rotation_width - 1; x > 0; x--) { + i = y * oled_rotation_width + x; + oled_buffer[i] = oled_buffer[i - 1]; + } + } + } + oled_dirty = OLED_ALL_BLOCKS_MASK; +} + + +oled_buffer_reader_t oled_read_raw(uint16_t start_index) { + if (start_index > OLED_MATRIX_SIZE) start_index = OLED_MATRIX_SIZE; + oled_buffer_reader_t ret_reader; + ret_reader.current_element = &oled_buffer[start_index]; + ret_reader.remaining_element_count = OLED_MATRIX_SIZE - start_index; + return ret_reader; +} + +void oled_write_raw_byte(const char data, uint16_t index) { + if (index > OLED_MATRIX_SIZE) index = OLED_MATRIX_SIZE; + if (oled_buffer[index] == data) return; + oled_buffer[index] = data; + oled_dirty |= ((OLED_BLOCK_TYPE)1 << (index / OLED_BLOCK_SIZE)); +} + +void oled_write_raw(const char *data, uint16_t size) { + uint16_t cursor_start_index = oled_cursor - &oled_buffer[0]; + if ((size + cursor_start_index) > OLED_MATRIX_SIZE) size = OLED_MATRIX_SIZE - cursor_start_index; + + for (uint16_t j = 0, i = cursor_start_index; i < cursor_start_index + size; i++, j++) { + if (oled_buffer[i] == data[j]) continue; + oled_buffer[i] = data[j]; + oled_dirty |= ((OLED_BLOCK_TYPE)1 << (i / OLED_BLOCK_SIZE)); + } +} + +void oled_write_pixel(uint8_t x, uint8_t y, bool on) { + if (x >= oled_rotation_width) { + return; + } + uint16_t index = x + (y / 8) * oled_rotation_width; + if (index >= OLED_MATRIX_SIZE) { + return; + } + uint8_t data = oled_buffer[index]; + if (on) { + data |= (1 << (y % 8)); + } else { + data &= ~(1 << (y % 8)); + } + if (oled_buffer[index] != data) { + oled_buffer[index] = data; + oled_dirty |= ((OLED_BLOCK_TYPE)1 << (index / OLED_BLOCK_SIZE)); + } +} + +#if defined(__AVR__) +void oled_write_P(const char *data, bool invert) { + uint8_t c = pgm_read_byte(data); + while (c != 0) { + oled_write_char(c, invert); + c = pgm_read_byte(++data); + } +} + +void oled_write_ln_P(const char *data, bool invert) { + oled_write_P(data, invert); + oled_advance_page(true); +} + +void oled_write_raw_P(const char *data, uint16_t size) { + uint16_t cursor_start_index = oled_cursor - &oled_buffer[0]; + if ((size + cursor_start_index) > OLED_MATRIX_SIZE) size = OLED_MATRIX_SIZE - cursor_start_index; + for (uint16_t i = cursor_start_index; i < cursor_start_index + size; i++) { + uint8_t c = pgm_read_byte(data++); + if (oled_buffer[i] == c) continue; + oled_buffer[i] = c; + oled_dirty |= ((OLED_BLOCK_TYPE)1 << (i / OLED_BLOCK_SIZE)); + } +} +#endif // defined(__AVR__) + +bool oled_on(void) { + if (!oled_initialized) { + return oled_active; + } + +#if OLED_TIMEOUT > 0 + oled_timeout = timer_read32() + OLED_TIMEOUT; +#endif + + static const uint8_t PROGMEM display_on[] = {I2C_CMD, DISPLAY_ON}; + if (!oled_active) { + if (I2C_TRANSMIT_P(display_on) != I2C_STATUS_SUCCESS) { + print("oled_on cmd failed\n"); + return oled_active; + } + oled_active = true; + } + return oled_active; +} + +bool oled_off(void) { + if (!oled_initialized) { + return !oled_active; + } + + static const uint8_t PROGMEM display_off[] = {I2C_CMD, DISPLAY_OFF}; + if (oled_active) { + if (I2C_TRANSMIT_P(display_off) != I2C_STATUS_SUCCESS) { + print("oled_off cmd failed\n"); + return oled_active; + } + oled_active = false; + } + return !oled_active; +} + +bool is_oled_on(void) { return oled_active; } + +uint8_t oled_set_brightness(uint8_t level) { + if (!oled_initialized) { + return oled_brightness; + } + + uint8_t set_contrast[] = {I2C_CMD, CONTRAST, level}; + if (oled_brightness != level) { + if (I2C_TRANSMIT(set_contrast) != I2C_STATUS_SUCCESS) { + print("set_brightness cmd failed\n"); + return oled_brightness; + } + oled_brightness = level; + } + return oled_brightness; +} + +uint8_t oled_get_brightness(void) { return oled_brightness; } + +// Set the specific 8 lines rows of the screen to scroll. +// 0 is the default for start, and 7 for end, which is the entire +// height of the screen. For 128x32 screens, rows 4-7 are not used. +void oled_scroll_set_area(uint8_t start_line, uint8_t end_line) { + oled_scroll_start = start_line; + oled_scroll_end = end_line; +} + +void oled_scroll_set_speed(uint8_t speed) { + // Sets the speed for scrolling... does not take effect + // until scrolling is either started or restarted + // the ssd1306 supports 8 speeds + // FrameRate2 speed = 7 + // FrameRate3 speed = 4 + // FrameRate4 speed = 5 + // FrameRate5 speed = 0 + // FrameRate25 speed = 6 + // FrameRate64 speed = 1 + // FrameRate128 speed = 2 + // FrameRate256 speed = 3 + // for ease of use these are remaped here to be in order + static const uint8_t scroll_remap[8] = {7, 4, 5, 0, 6, 1, 2, 3}; + oled_scroll_speed = scroll_remap[speed]; +} + +bool oled_scroll_right(void) { + if (!oled_initialized) { + return oled_scrolling; + } + + // Dont enable scrolling if we need to update the display + // This prevents scrolling of bad data from starting the scroll too early after init + if (!oled_dirty && !oled_scrolling) { + uint8_t display_scroll_right[] = {I2C_CMD, SCROLL_RIGHT, 0x00, oled_scroll_start, oled_scroll_speed, oled_scroll_end, 0x00, 0xFF, ACTIVATE_SCROLL}; + if (I2C_TRANSMIT(display_scroll_right) != I2C_STATUS_SUCCESS) { + print("oled_scroll_right cmd failed\n"); + return oled_scrolling; + } + oled_scrolling = true; + } + return oled_scrolling; +} + +bool oled_scroll_left(void) { + if (!oled_initialized) { + return oled_scrolling; + } + + // Dont enable scrolling if we need to update the display + // This prevents scrolling of bad data from starting the scroll too early after init + if (!oled_dirty && !oled_scrolling) { + uint8_t display_scroll_left[] = {I2C_CMD, SCROLL_LEFT, 0x00, oled_scroll_start, oled_scroll_speed, oled_scroll_end, 0x00, 0xFF, ACTIVATE_SCROLL}; + if (I2C_TRANSMIT(display_scroll_left) != I2C_STATUS_SUCCESS) { + print("oled_scroll_left cmd failed\n"); + return oled_scrolling; + } + oled_scrolling = true; + } + return oled_scrolling; +} + +bool oled_scroll_off(void) { + if (!oled_initialized) { + return !oled_scrolling; + } + + if (oled_scrolling) { + static const uint8_t PROGMEM display_scroll_off[] = {I2C_CMD, DEACTIVATE_SCROLL}; + if (I2C_TRANSMIT_P(display_scroll_off) != I2C_STATUS_SUCCESS) { + print("oled_scroll_off cmd failed\n"); + return oled_scrolling; + } + oled_scrolling = false; + oled_dirty = OLED_ALL_BLOCKS_MASK; + } + return !oled_scrolling; +} + +uint8_t oled_max_chars(void) { + if (!HAS_FLAGS(oled_rotation, OLED_ROTATION_90)) { + return OLED_DISPLAY_WIDTH / OLED_FONT_WIDTH; + } + return OLED_DISPLAY_HEIGHT / OLED_FONT_WIDTH; +} + +uint8_t oled_max_lines(void) { + if (!HAS_FLAGS(oled_rotation, OLED_ROTATION_90)) { + return OLED_DISPLAY_HEIGHT / OLED_FONT_HEIGHT; + } + return OLED_DISPLAY_WIDTH / OLED_FONT_HEIGHT; +} + +void oled_task(void) { + if (!oled_initialized) { + return; + } + +#if OLED_UPDATE_INTERVAL > 0 + if (timer_elapsed(oled_update_timeout) >= OLED_UPDATE_INTERVAL) { + oled_update_timeout = timer_read(); + oled_set_cursor(0, 0); + oled_task_user(); + } +#else + oled_set_cursor(0, 0); + oled_task_user(); +#endif + +#if OLED_SCROLL_TIMEOUT > 0 + if (oled_dirty && oled_scrolling) { + oled_scroll_timeout = timer_read32() + OLED_SCROLL_TIMEOUT; + oled_scroll_off(); + } +#endif + + // Smart render system, no need to check for dirty + oled_render(); + + // Display timeout check +#if OLED_TIMEOUT > 0 + if (oled_active && timer_expired32(timer_read32(), oled_timeout)) { + oled_off(); + } +#endif + +#if OLED_SCROLL_TIMEOUT > 0 + if (!oled_scrolling && timer_expired32(timer_read32(), oled_scroll_timeout)) { +# ifdef OLED_SCROLL_TIMEOUT_RIGHT + oled_scroll_right(); +# else + oled_scroll_left(); +# endif + } +#endif +} + +__attribute__((weak)) void oled_task_user(void) {} diff --git a/keyboards/yandrstudio/rainbow65/keymaps/default/dev_oled/oled_driver.h b/keyboards/yandrstudio/rainbow65/keymaps/default/dev_oled/oled_driver.h new file mode 100755 index 000000000000..ba721e88d7d4 --- /dev/null +++ b/keyboards/yandrstudio/rainbow65/keymaps/default/dev_oled/oled_driver.h @@ -0,0 +1,313 @@ +/* +Copyright 2019 Ryan Caltabiano + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ +#pragma once + +#include +#include + +// an enumeration of the chips this driver supports +#define OLED_IC_SSD1306 0 +#define OLED_IC_SH1106 1 + +#if defined(OLED_DISPLAY_CUSTOM) +// Expected user to implement the necessary defines +#elif defined(OLED_DISPLAY_128X64) +// Double height 128x64 +# ifndef OLED_DISPLAY_WIDTH +# define OLED_DISPLAY_WIDTH 128 +# endif +# ifndef OLED_DISPLAY_HEIGHT +# define OLED_DISPLAY_HEIGHT 64 +# endif +# ifndef OLED_MATRIX_SIZE +# define OLED_MATRIX_SIZE (OLED_DISPLAY_HEIGHT / 8 * OLED_DISPLAY_WIDTH) // 1024 (compile time mathed) +# endif +# ifndef OLED_BLOCK_TYPE +# define OLED_BLOCK_TYPE uint16_t +# endif +# ifndef OLED_BLOCK_COUNT +# define OLED_BLOCK_COUNT (sizeof(OLED_BLOCK_TYPE) * 8) // 32 (compile time mathed) +# endif +# ifndef OLED_BLOCK_SIZE +# define OLED_BLOCK_SIZE (OLED_MATRIX_SIZE / OLED_BLOCK_COUNT) // 32 (compile time mathed) +# endif +# ifndef OLED_COM_PINS +# define OLED_COM_PINS COM_PINS_ALT +# endif + +// For 90 degree rotation, we map our internal matrix to oled matrix using fixed arrays +// The OLED writes to it's memory horizontally, starting top left, but our memory starts bottom left in this mode +# ifndef OLED_SOURCE_MAP +# define OLED_SOURCE_MAP \ + { 0, 8, 16, 24, 32, 40, 48, 56 } +# endif +# ifndef OLED_TARGET_MAP +# define OLED_TARGET_MAP \ + { 56, 48, 40, 32, 24, 16, 8, 0 } +# endif +// If OLED_BLOCK_TYPE is uint32_t, these tables would look like: +// #define OLED_SOURCE_MAP { 32, 40, 48, 56 } +// #define OLED_TARGET_MAP { 24, 16, 8, 0 } +// If OLED_BLOCK_TYPE is uint16_t, these tables would look like: +// #define OLED_SOURCE_MAP { 0, 8, 16, 24, 32, 40, 48, 56 } +// #define OLED_TARGET_MAP { 56, 48, 40, 32, 24, 16, 8, 0 } +// If OLED_BLOCK_TYPE is uint8_t, these tables would look like: +// #define OLED_SOURCE_MAP { 0, 8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104, 112, 120 } +// #define OLED_TARGET_MAP { 56, 120, 48, 112, 40, 104, 32, 96, 24, 88, 16, 80, 8, 72, 0, 64 } +#else // defined(OLED_DISPLAY_128X64) +// Default 128x32 +# ifndef OLED_DISPLAY_WIDTH +# define OLED_DISPLAY_WIDTH 128 +# endif +# ifndef OLED_DISPLAY_HEIGHT +# define OLED_DISPLAY_HEIGHT 32 +# endif +# ifndef OLED_MATRIX_SIZE +# define OLED_MATRIX_SIZE (OLED_DISPLAY_HEIGHT / 8 * OLED_DISPLAY_WIDTH) // 512 (compile time mathed) +# endif +# ifndef OLED_BLOCK_TYPE +# define OLED_BLOCK_TYPE uint16_t // Type to use for segmenting the oled display for smart rendering, use unsigned types only +# endif +# ifndef OLED_BLOCK_COUNT +# define OLED_BLOCK_COUNT (sizeof(OLED_BLOCK_TYPE) * 8) // 16 (compile time mathed) +# endif +# ifndef OLED_BLOCK_SIZE +# define OLED_BLOCK_SIZE (OLED_MATRIX_SIZE / OLED_BLOCK_COUNT) // 32 (compile time mathed) +# endif +# ifndef OLED_COM_PINS +# define OLED_COM_PINS COM_PINS_SEQ +# endif + +// For 90 degree rotation, we map our internal matrix to oled matrix using fixed arrays +// The OLED writes to it's memory horizontally, starting top left, but our memory starts bottom left in this mode +# ifndef OLED_SOURCE_MAP +# define OLED_SOURCE_MAP \ + { 0, 8, 16, 24 } +# endif +# ifndef OLED_TARGET_MAP +# define OLED_TARGET_MAP \ + { 24, 16, 8, 0 } +# endif +// If OLED_BLOCK_TYPE is uint8_t, these tables would look like: +// #define OLED_SOURCE_MAP { 0, 8, 16, 24, 32, 40, 48, 56 } +// #define OLED_TARGET_MAP { 48, 32, 16, 0, 56, 40, 24, 8 } +#endif // defined(OLED_DISPLAY_CUSTOM) + +#if !defined(OLED_IC) +# define OLED_IC OLED_IC_SSD1306 +#endif + +// the column address corresponding to the first column in the display hardware +#if !defined(OLED_COLUMN_OFFSET) +# define OLED_COLUMN_OFFSET 0 +#endif + +// Address to use for the i2c oled communication +#if !defined(OLED_DISPLAY_ADDRESS) +# define OLED_DISPLAY_ADDRESS 0x3C +#endif + +// Custom font file to use +#if !defined(OLED_FONT_H) +# define OLED_FONT_H "glcdfont.c" +#endif +// unsigned char value of the first character in the font file +#if !defined(OLED_FONT_START) +# define OLED_FONT_START 0 +#endif +// unsigned char value of the last character in the font file +#if !defined(OLED_FONT_END) +# define OLED_FONT_END 223 +#endif +// Font render width +#if !defined(OLED_FONT_WIDTH) +# define OLED_FONT_WIDTH 6 +#endif +// Font render height +#if !defined(OLED_FONT_HEIGHT) +# define OLED_FONT_HEIGHT 8 +#endif +// Default brightness level +#if !defined(OLED_BRIGHTNESS) +# define OLED_BRIGHTNESS 255 +#endif + +#if !defined(OLED_TIMEOUT) +# if defined(OLED_DISABLE_TIMEOUT) +# define OLED_TIMEOUT 0 +# else +# define OLED_TIMEOUT 60000 +# endif +#endif + +#if !defined(OLED_I2C_TIMEOUT) +# define OLED_I2C_TIMEOUT 100 +#endif + +typedef struct __attribute__((__packed__)) { + uint8_t *current_element; + uint16_t remaining_element_count; +} oled_buffer_reader_t; + +// OLED Rotation enum values are flags +typedef enum { + OLED_ROTATION_0 = 0, + OLED_ROTATION_90 = 1, + OLED_ROTATION_180 = 2, + OLED_ROTATION_270 = 3, // OLED_ROTATION_90 | OLED_ROTATION_180 +} oled_rotation_t; + +// Initialize the oled display, rotating the rendered output based on the define passed in. +// Returns true if the OLED was initialized successfully +bool oled_init(oled_rotation_t rotation); + +// Called at the start of oled_init, weak function overridable by the user +// rotation - the value passed into oled_init +// Return new oled_rotation_t if you want to override default rotation +oled_rotation_t oled_init_user(oled_rotation_t rotation); + +// Clears the display buffer, resets cursor position to 0, and sets the buffer to dirty for rendering +void oled_clear(void); + +// Renders the dirty chunks of the buffer to oled display +void oled_render(void); + +// Moves cursor to character position indicated by column and line, wraps if out of bounds +// Max column denoted by 'oled_max_chars()' and max lines by 'oled_max_lines()' functions +void oled_set_cursor(uint8_t col, uint8_t line); +void oled_set_precise_cursor(uint16_t index); + +// Advances the cursor to the next page, writing ' ' if true +// Wraps to the begining when out of bounds +void oled_advance_page(bool clearPageRemainder); + +// Moves the cursor forward 1 character length +// Advance page if there is not enough room for the next character +// Wraps to the begining when out of bounds +void oled_advance_char(void); + +// Writes a single character to the buffer at current cursor position +// Advances the cursor while writing, inverts the pixels if true +// Main handler that writes character data to the display buffer +void oled_write_char(const char data, bool invert); + +// Writes a string to the buffer at current cursor position +// Advances the cursor while writing, inverts the pixels if true +void oled_write(const char *data, bool invert); + +// Writes a string to the buffer at current cursor position +// Advances the cursor while writing, inverts the pixels if true +// Advances the cursor to the next page, wiring ' ' to the remainder of the current page +void oled_write_ln(const char *data, bool invert); + +// Pans the buffer to the right (or left by passing true) by moving contents of the buffer +void oled_pan(bool left); +void oled_precise_pan(bool left, uint16_t start_index); +void oled_precise_pan_h(bool left, uint16_t start_line); + +// Returns a pointer to the requested start index in the buffer plus remaining +// buffer length as struct +oled_buffer_reader_t oled_read_raw(uint16_t start_index); + +void oled_write_raw(const char *data, uint16_t size); +void oled_write_raw_byte(const char data, uint16_t index); + +// Sets a specific pixel on or off +// Coordinates start at top-left and go right and down for positive x and y +void oled_write_pixel(uint8_t x, uint8_t y, bool on); + +#if defined(__AVR__) +// Writes a PROGMEM string to the buffer at current cursor position +// Advances the cursor while writing, inverts the pixels if true +// Remapped to call 'void oled_write(const char *data, bool invert);' on ARM +void oled_write_P(const char *data, bool invert); + +// Writes a PROGMEM string to the buffer at current cursor position +// Advances the cursor while writing, inverts the pixels if true +// Advances the cursor to the next page, wiring ' ' to the remainder of the current page +// Remapped to call 'void oled_write_ln(const char *data, bool invert);' on ARM +void oled_write_ln_P(const char *data, bool invert); + +void oled_write_raw_P(const char *data, uint16_t size); +#else +// Writes a string to the buffer at current cursor position +// Advances the cursor while writing, inverts the pixels if true +# define oled_write_P(data, invert) oled_write(data, invert) + +// Writes a string to the buffer at current cursor position +// Advances the cursor while writing, inverts the pixels if true +// Advances the cursor to the next page, wiring ' ' to the remainder of the current page +# define oled_write_ln_P(data, invert) oled_write_ln(data, invert) + +# define oled_write_raw_P(data, size) oled_write_raw(data, size) +#endif // defined(__AVR__) + +// Can be used to manually turn on the screen if it is off +// Returns true if the screen was on or turns on +bool oled_on(void); + +// Can be used to manually turn off the screen if it is on +// Returns true if the screen was off or turns off +bool oled_off(void); + +// Returns true if the oled is currently on, false if it is +// not +bool is_oled_on(void); + +// Sets the brightness of the display +uint8_t oled_set_brightness(uint8_t level); + +// Gets the current brightness of the display +uint8_t oled_get_brightness(void); + +// Basically it's oled_render, but with timeout management and oled_task_user calling! +void oled_task(void); + +// Called at the start of oled_task, weak function overridable by the user +void oled_task_user(void); + +// Set the specific 8 lines rows of the screen to scroll. +// 0 is the default for start, and 7 for end, which is the entire +// height of the screen. For 128x32 screens, rows 4-7 are not used. +void oled_scroll_set_area(uint8_t start_line, uint8_t end_line); + +// Sets scroll speed, 0-7, fastest to slowest. Default is three. +// Does not take effect until scrolling is either started or restarted +// the ssd1306 supports 8 speeds with the delay +// listed below betwen each frame of the scrolling effect +// 0=2, 1=3, 2=4, 3=5, 4=25, 5=64, 6=128, 7=256 +void oled_scroll_set_speed(uint8_t speed); + +// Scrolls the entire display right +// Returns true if the screen was scrolling or starts scrolling +// NOTE: display contents cannot be changed while scrolling +bool oled_scroll_right(void); + +// Scrolls the entire display left +// Returns true if the screen was scrolling or starts scrolling +// NOTE: display contents cannot be changed while scrolling +bool oled_scroll_left(void); + +// Turns off display scrolling +// Returns true if the screen was not scrolling or stops scrolling +bool oled_scroll_off(void); + +// Returns the maximum number of characters that will fit on a line +uint8_t oled_max_chars(void); + +// Returns the maximum number of lines that will fit on the oled +uint8_t oled_max_lines(void); diff --git a/keyboards/yandrstudio/rainbow65/keymaps/default/graph_lib/kb_press_graph.c b/keyboards/yandrstudio/rainbow65/keymaps/default/graph_lib/kb_press_graph.c new file mode 100755 index 000000000000..65057611df97 --- /dev/null +++ b/keyboards/yandrstudio/rainbow65/keymaps/default/graph_lib/kb_press_graph.c @@ -0,0 +1,37 @@ +#include "kb_press_graph.h" + + +const uint8_t kb_graph_start_line = 8; +// 0 1 2 3 4 +const uint8_t kb_press_row_map[5] = {65, 68, 71, 74, 77}; +// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 +const uint8_t kb_press_col_map[15] = {3, 6, 6, 9, 9, 12, 12, 15, 18, 18, 21, 21, 24, 27, 27}; + +void render_r65_kb(uint8_t col, uint8_t row, uint16_t keycode, bool on, uint16_t key_press_count) { + if (key_press_count == 0) { + oled_set_cursor(0, kb_graph_start_line); + oled_write_raw(my_font_lib_etc_r65kb, 32); + oled_set_cursor(0, kb_graph_start_line+1); + oled_write_raw(my_font_lib_etc_r65kb+32, 32); + oled_set_cursor(0,0); + return; + } + if (col == 255 && row == 255) return; + // skip the encoder map key + if (col == 3 && row == 4) return; + if (col == 4 && row == 4) return; + // space keypress + if (col == 5 && row == 4) { + for (uint8_t i = kb_press_col_map[5-2];i<=kb_press_col_map[5+2]+1; ++i) { + oled_write_pixel(i, kb_press_row_map[4], on); + oled_write_pixel(i, kb_press_row_map[4]+1, on); + } + return; + } + uint8_t y_oled = kb_press_row_map[row]; + uint8_t x_oled = kb_press_col_map[col]; + oled_write_pixel(x_oled, y_oled, on); + oled_write_pixel(x_oled, y_oled+1, on); + oled_write_pixel(x_oled+1, y_oled, on); + oled_write_pixel(x_oled+1, y_oled+1, on); +} diff --git a/keyboards/yandrstudio/rainbow65/keymaps/default/graph_lib/kb_press_graph.h b/keyboards/yandrstudio/rainbow65/keymaps/default/graph_lib/kb_press_graph.h new file mode 100755 index 000000000000..f90083093680 --- /dev/null +++ b/keyboards/yandrstudio/rainbow65/keymaps/default/graph_lib/kb_press_graph.h @@ -0,0 +1,18 @@ +#pragma once +#include "progmem.h" +#include "../dev_oled/oled_driver.h" +#include "time.h" + +void render_r65_kb(uint8_t col, uint8_t row, uint16_t keycode, bool on, uint16_t key_press_count); + +static const char my_font_lib_etc_r65kb[] PROGMEM = { + 0x07, 0xFF, 0xFF, 0x49, 0x49, 0xFF, 0x49, 0x49, + 0xFF, 0x49, 0x49, 0xFF, 0x49, 0x49, 0xFF, 0x49, + 0x49, 0xFF, 0x49, 0x49, 0xFF, 0x49, 0x49, 0xFF, + 0x49, 0x49, 0xFF, 0x49, 0x49, 0xFF, 0xFF, 0x07, + + 0xE0, 0xFF, 0xFF, 0x92, 0x92, 0xFF, 0x92, 0x92, + 0xFF, 0x92, 0x92, 0x9F, 0x92, 0x92, 0x9F, 0x92, + 0x92, 0xFF, 0x92, 0x92, 0xFF, 0x92, 0x92, 0xFF, + 0x92, 0x92, 0xFF, 0x92, 0x92, 0xFF, 0xFF, 0xE0, +}; diff --git a/keyboards/yandrstudio/rainbow65/keymaps/default/graph_lib/my_pic_lib.h b/keyboards/yandrstudio/rainbow65/keymaps/default/graph_lib/my_pic_lib.h new file mode 100755 index 000000000000..fe8ac056614d --- /dev/null +++ b/keyboards/yandrstudio/rainbow65/keymaps/default/graph_lib/my_pic_lib.h @@ -0,0 +1,136 @@ +#pragma once +#include "progmem.h" + +static const char my_font_lib_layer[] PROGMEM = { + 0x02, 0xF2, 0x02, 0x02, 0x02, 0x02, 0x22, 0x22, + 0xE2, 0x02, 0x22, 0x42, 0x82, 0x42, 0x22, 0x02, + 0xE2, 0xA2, 0xE2, 0x02, 0xE2, 0x42, 0x22, 0x02, + 0xF2, 0x3A, 0x1A, 0xCA, 0xCA, 0x1A, 0x3A, 0xF2, + 0xF2, 0xFA, 0x9A, 0x0A, 0x0A, 0xFA, 0xFA, 0xF2, + 0xF2, 0xFA, 0xCA, 0xEA, 0x6A, 0x0A, 0xFA, 0xF2, + 0xF2, 0xDA, 0xEA, 0x6A, 0x6A, 0x1A, 0xFA, 0xF2, + 0xF2, 0xDA, 0xBA, 0x7A, 0x7A, 0xBA, 0xDA, 0xF2, + + 0x40, 0x4F, 0x48, 0x48, 0x48, 0x40, 0x47, 0x45, + 0x47, 0x40, 0x40, 0x40, 0x47, 0x40, 0x40, 0x40, + 0x47, 0x44, 0x44, 0x40, 0x47, 0x40, 0x40, 0x40, + 0x4F, 0x5C, 0x58, 0x53, 0x53, 0x58, 0x5C, 0x4F, + 0x4F, 0x5F, 0x57, 0x50, 0x50, 0x57, 0x5F, 0x4F, + 0x4F, 0x5F, 0x50, 0x56, 0x57, 0x53, 0x5F, 0x4F, + 0x4F, 0x5B, 0x57, 0x56, 0x56, 0x58, 0x5F, 0x4F, + 0x4F, 0x5B, 0x5D, 0x5E, 0x5E, 0x5D, 0x5B, 0x4F, +}; +static const char my_font_lib_caps_off[] PROGMEM = { + 0xFC, 0x06, 0xE2, 0x12, 0x1A, 0x12, 0x22, 0x02, + 0xC2, 0x72, 0x1A, 0x72, 0xC2, 0x02, 0xFA, 0x9A, + 0x0A, 0x9A, 0xF2, 0x06, 0xFC, 0x00, 0x00, 0x00, + 0x3F, 0x60, 0x47, 0x48, 0x58, 0x48, 0x44, 0x40, + 0x5F, 0x42, 0x42, 0x42, 0x5F, 0x40, 0x5F, 0x41, + 0x41, 0x41, 0x40, 0x60, 0x3F, 0x00, 0x00, 0x00, +}; +static const char my_font_lib_caps_on[] PROGMEM = { + 0xFC, 0xFE, 0x1E, 0xEE, 0xE6, 0xEE, 0xDE, 0xFE, + 0x3E, 0x8E, 0xF6, 0x8E, 0x3E, 0xFE, 0x06, 0x66, + 0xF6, 0x66, 0x0E, 0xFE, 0xFC, 0x00, 0x00, 0x00, + 0x3F, 0x7F, 0x78, 0x77, 0x67, 0x77, 0x7B, 0x7F, + 0x60, 0x7D, 0x7D, 0x7D, 0x60, 0x7F, 0x60, 0x7E, + 0x7E, 0x7E, 0x7F, 0x7F, 0x3F, 0x00, 0x00, 0x00, +}; + +static const char my_font_lib_shift_off[] PROGMEM = { + 0xFC, 0x06, 0x72, 0x8A, 0x0A, 0x32, 0x06, 0xFC, + 0x3F, 0x60, 0x4C, 0x50, 0x51, 0x4E, 0x60, 0x3F, +}; +static const char my_font_lib_shift_on[] PROGMEM = { + 0xFC, 0xFE, 0x8E, 0x76, 0xF6, 0xCE, 0xFE, 0xFC, + 0x3F, 0x7F, 0x73, 0x6F, 0x6E, 0x71, 0x7F, 0x3F, +}; + +static const char my_font_lib_ctrl_off[] PROGMEM = { + 0x00, 0xFC, 0x06, 0xE2, 0x12, 0x1A, 0x12, 0x22, 0x06, 0xFC, + 0x00, 0x3F, 0x60, 0x47, 0x48, 0x58, 0x48, 0x44, 0x60, 0x3F, +}; +static const char my_font_lib_ctrl_on[] PROGMEM = { + 0x00, 0xFC, 0xFE, 0x1E, 0xEE, 0xE6, 0xEE, 0xDE, 0xFE, 0xFC, + 0x00, 0x3F, 0x7F, 0x78, 0x77, 0x67, 0x77, 0x7B, 0x7F, 0x3F, +}; + +static const char my_font_lib_gui_off[] PROGMEM = { + 0x00, 0xFC, 0x06, 0xE2, 0x12, 0x1A, 0x12, 0x22, 0x06, 0xFC, + 0x00, 0x3F, 0x60, 0x47, 0x48, 0x59, 0x49, 0x47, 0x60, 0x3F, +}; +static const char my_font_lib_gui_on[] PROGMEM = { + 0x00, 0xFC, 0xFE, 0x1E, 0xEE, 0xE6, 0xEE, 0xDE, 0xFE, 0xFC, + 0x00, 0x3F, 0x7F, 0x78, 0x77, 0x66, 0x76, 0x78, 0x7F, 0x3F, +}; + +static const char my_font_lib_alt_off[] PROGMEM = { + 0x00, 0xFC, 0x06, 0xC2, 0x72, 0x0A, 0x72, 0xC2, 0x06, 0xFC, + 0x00, 0x3F, 0x60, 0x4F, 0x41, 0x41, 0x41, 0x4F, 0x60, 0x3F, +}; +static const char my_font_lib_alt_on[] PROGMEM = { + 0x00, 0xFC, 0xFE, 0x3E, 0x8E, 0xF6, 0x8E, 0x3E, 0xFE, 0xFC, + 0x00, 0x3F, 0x7F, 0x70, 0x7E, 0x7E, 0x7E, 0x70, 0x7F, 0x3F, +}; + +static const char my_font_lib_rgb_off[] PROGMEM = { + 0x00, 0xFC, 0x06, 0xFA, 0x8A, 0x8A, 0x72, 0x02, + 0xF2, 0x1A, 0x1A, 0x72, 0x02, 0xFA, 0x8A, 0x8A, + 0xFA, 0x72, 0x06, 0xFC, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x3F, 0x60, 0x5F, 0x41, 0x43, 0x5E, 0x40, + 0x4F, 0x58, 0x5A, 0x4E, 0x40, 0x5F, 0x51, 0x51, + 0x5F, 0x4E, 0x60, 0x3F, 0x00, 0x00, 0x00, 0x00, +}; +static const char my_font_lib_rgb_on[] PROGMEM = { + 0x00, 0xFC, 0xFE, 0x06, 0x76, 0x76, 0x8E, 0xFE, + 0x0E, 0xE6, 0xE6, 0x8E, 0xFE, 0x06, 0x76, 0x76, + 0x06, 0x8E, 0xFE, 0xFC, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x3F, 0x7F, 0x60, 0x7E, 0x7C, 0x61, 0x7F, + 0x70, 0x67, 0x65, 0x71, 0x7F, 0x60, 0x6E, 0x6E, + 0x60, 0x71, 0x7F, 0x3F, 0x00, 0x00, 0x00, 0x00, +}; + + + + + + + + + + + +/* 1*32 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +*/ diff --git a/keyboards/yandrstudio/rainbow65/keymaps/default/graph_lib/wpm_graph.c b/keyboards/yandrstudio/rainbow65/keymaps/default/graph_lib/wpm_graph.c new file mode 100755 index 000000000000..0c84679b3ea8 --- /dev/null +++ b/keyboards/yandrstudio/rainbow65/keymaps/default/graph_lib/wpm_graph.c @@ -0,0 +1,183 @@ +#include "wpm_graph.h" +// #include "print.h" + + +const uint8_t single_bit_masks[] = {0, 128, 192, 224, 240, 248, 252, 254, 255}; +const uint8_t max_wpm = 120; +const uint8_t max_wpm_byte_bar_height = 5; // 5*8 = 40 bit +const uint8_t wpm_graph_start_line = 11; +const uint16_t show_count_time = 60000; +uint16_t wpm_graph_timer_update = 0; +uint16_t wpm_graph_timer_countdown = 0; +bool countdown_over = false; +bool first_startup = true; + +void draw_y_grad(uint8_t x, uint8_t y, bool inside) { + uint16_t start_index = (y * OLED_DISPLAY_WIDTH) + (x*8); + oled_buffer_reader_t reader; + if (inside) { + start_index += 2; + for (uint8_t i=0; i < 4; i++) + oled_write_raw_byte(60, start_index + i); + } else { + reader = oled_read_raw(start_index); + for (uint8_t i=0; i < 8; i++) { + if (i > 1 && i < 6) + oled_write_raw_byte((*reader.current_element)++ | 129, start_index + i); // 129 = 0b1000 0001 + else + oled_write_raw_byte(255, start_index + i); + } + } +} + +void render_wpm_graph(uint16_t wpm) { + // init + if (first_startup) { + render_r65_logo(); + } + if (wpm_graph_timer_countdown == 0) { + wpm_graph_timer_countdown = timer_read(); + } + if (wpm_graph_timer_update == 0) { + wpm_graph_timer_update = timer_read(); + return; + } + + // 2 frame + if (timer_elapsed(wpm_graph_timer_update) < 500) return; + wpm_graph_timer_update = timer_read(); + + // global var for this function + static uint8_t zero_bar_count = 0; + static uint8_t bar_count = 0; + + uint8_t bar_height = 0; + uint8_t bar_segment = 0; + + + bar_height = wpm; + if(bar_height > max_wpm) { + bar_height = max_wpm; + } + + if(bar_height == 0) { + // keep track of how many zero bars we have drawn. If + // there is a whole screen worth, turn the display off and + // wait until there is something to do + // uprintf("zero %u\n", zero_bar_count); + if (first_startup) return; + + if (zero_bar_count > 32) { + // do some thing when not typing + if (timer_elapsed(wpm_graph_timer_countdown) <= show_count_time+1 && !countdown_over) { + render_countdown(); + } else { + countdown_over = true; + render_yandr_logo(); + // oled_off(); + } + return; + } + zero_bar_count++; + wpm_graph_timer_countdown = timer_read(); + countdown_over = false; + } else { + first_startup = false; + zero_bar_count=0; + } + bar_count++; + + // scale the ture wpm to fit the bar height + uint8_t scale_rate = max_wpm/(max_wpm_byte_bar_height*8); + bar_height = bar_height / scale_rate; + + // wpm history bar move one step to right + // oled_precise_pan(false, wpm_graph_start_line*32); + if (!first_startup) { + oled_precise_pan_h(false, (uint16_t)wpm_graph_start_line); + } else { + return; + } + // oled_pan(false); + + + for (uint8_t i = max_wpm_byte_bar_height; i >0; i--) { + if (bar_height > 8) { + bar_segment = 255; + bar_height -= 8; + } else { + bar_segment = single_bit_masks[bar_height]; + bar_height = 0; + } + // uprintf("max%u",max_wpm_byte_bar_height); + oled_write_raw_byte(bar_segment, (uint16_t)((i - 1 + wpm_graph_start_line) * 32)); + } +} + + + +void render_countdown(void) { + uint16_t pass_time_mm = timer_elapsed(wpm_graph_timer_countdown); + // second + uint16_t pass_time_s = show_count_time/1000 - pass_time_mm / 1000; + + oled_set_cursor(0, wpm_graph_start_line+1); + if (pass_time_s < 10) { + // 0 + oled_set_cursor(0, wpm_graph_start_line+1); + oled_write_raw(my_font_lib_etc_countdown[0], 16); + oled_set_cursor(0, wpm_graph_start_line+2); + oled_write_raw(my_font_lib_etc_countdown[0]+16, 16); + oled_set_cursor(0, wpm_graph_start_line+3); + oled_write_raw(my_font_lib_etc_countdown[0]+32, 16); + + // pass_time_s + oled_set_precise_cursor((wpm_graph_start_line+1)*32 + 16); + oled_write_raw(my_font_lib_etc_countdown[pass_time_s], 16); + oled_set_precise_cursor((wpm_graph_start_line+2)*32 + 16); + oled_write_raw(my_font_lib_etc_countdown[pass_time_s]+16, 16); + oled_set_precise_cursor((wpm_graph_start_line+3)*32 + 16); + oled_write_raw(my_font_lib_etc_countdown[pass_time_s]+32, 16); + } else { + uint16_t pass_time_s_h = pass_time_s / 10; + uint16_t pass_time_s_l = pass_time_s % 10; + // heigh bit + oled_set_cursor(0, wpm_graph_start_line+1); + oled_write_raw(my_font_lib_etc_countdown[pass_time_s_h], 16); + oled_set_cursor(0, wpm_graph_start_line+2); + oled_write_raw(my_font_lib_etc_countdown[pass_time_s_h]+16, 16); + oled_set_cursor(0, wpm_graph_start_line+3); + oled_write_raw(my_font_lib_etc_countdown[pass_time_s_h]+32, 16); + + // low bit + oled_set_precise_cursor((wpm_graph_start_line+1)*32 + 16); + oled_write_raw(my_font_lib_etc_countdown[pass_time_s_l], 16); + oled_set_precise_cursor((wpm_graph_start_line+2)*32 + 16); + oled_write_raw(my_font_lib_etc_countdown[pass_time_s_l]+16, 16); + oled_set_precise_cursor((wpm_graph_start_line+3)*32 + 16); + oled_write_raw(my_font_lib_etc_countdown[pass_time_s_l]+32, 16); + } + oled_set_cursor(0, wpm_graph_start_line+4); +} + + + +void render_yandr_logo() { + oled_set_cursor(0, wpm_graph_start_line+1); + oled_write_raw(my_font_lib_etc_logo, 32); + oled_set_cursor(0, wpm_graph_start_line+2); + oled_write_raw(my_font_lib_etc_logo+32, 32); + oled_set_cursor(0, wpm_graph_start_line+3); + oled_write_raw(my_font_lib_etc_logo+64, 32); + oled_set_cursor(0,0); +} + +void render_r65_logo() { + oled_set_cursor(0, wpm_graph_start_line+1); + oled_write_raw(my_font_lib_etc_r65_logo, 32); + oled_set_cursor(0, wpm_graph_start_line+2); + oled_write_raw(my_font_lib_etc_r65_logo+32, 32); + oled_set_cursor(0, wpm_graph_start_line+3); + oled_write_raw(my_font_lib_etc_r65_logo+64, 32); + oled_set_cursor(0,0); +} diff --git a/keyboards/yandrstudio/rainbow65/keymaps/default/graph_lib/wpm_graph.h b/keyboards/yandrstudio/rainbow65/keymaps/default/graph_lib/wpm_graph.h new file mode 100755 index 000000000000..0a7fcaa91dd9 --- /dev/null +++ b/keyboards/yandrstudio/rainbow65/keymaps/default/graph_lib/wpm_graph.h @@ -0,0 +1,151 @@ +#pragma once + +#include "../dev_oled/oled_driver.h" +#include "time.h" +#include "wpm.h" + + + +void draw_y_grad(uint8_t x, uint8_t y, bool inside); +void render_countdown(void); +void render_wpm_graph(uint16_t); +void render_yandr_logo(void); +void render_r65_logo(void); + + +static const char my_font_lib_etc_countdown[10][48] PROGMEM = { + {// 0 + 0x00, 0x00, 0x00, 0xF8, 0x08, 0x08, 0x08, 0x08, + 0x08, 0x08, 0x08, 0x08, 0xF8, 0x00, 0x00, 0x00, + + 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, + + 0x00, 0x00, 0x00, 0x1F, 0x10, 0x10, 0x10, 0x10, + 0x10, 0x10, 0x10, 0x10, 0x1F, 0x00, 0x00, 0x00, + }, + { // 1 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xF8, 0x00, 0x00, 0x00, + + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, + + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x1F, 0x00, 0x00, 0x00, + }, + { // 2 + 0x00, 0x00, 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, + 0x08, 0x08, 0x08, 0x08, 0xF8, 0x00, 0x00, 0x00, + + 0x00, 0x00, 0x00, 0xF0, 0x10, 0x10, 0x10, 0x10, + 0x08, 0x08, 0x08, 0x08, 0x0F, 0x00, 0x00, 0x00, + + 0x00, 0x00, 0x00, 0x1F, 0x10, 0x10, 0x10, 0x10, + 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, + }, + { // 3 + 0x00, 0x00, 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, + 0x08, 0x08, 0x08, 0x08, 0xF8, 0x00, 0x00, 0x00, + + 0x00, 0x00, 0x00, 0x10, 0x10, 0x10, 0x10, 0x10, + 0x08, 0x08, 0x08, 0x08, 0xFF, 0x00, 0x00, 0x00, + + 0x00, 0x00, 0x00, 0x10, 0x10, 0x10, 0x10, 0x10, + 0x10, 0x10, 0x10, 0x10, 0x1F, 0x00, 0x00, 0x00, + }, + { // 4 + 0x00, 0x00, 0x00, 0xF8, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xF8, 0x00, 0x00, 0x00, + + 0x00, 0x00, 0x00, 0x1F, 0x10, 0x10, 0x10, 0x10, + 0x08, 0x08, 0x08, 0x08, 0xFF, 0x00, 0x00, 0x00, + + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x1F, 0x00, 0x00, 0x00, + }, + { // 5 + 0x00, 0x00, 0x00, 0xF8, 0x08, 0x08, 0x08, 0x08, + 0x08, 0x08, 0x08, 0x08, 0x08, 0x00, 0x00, 0x00, + + 0x00, 0x00, 0x00, 0x1F, 0x10, 0x10, 0x10, 0x10, + 0x08, 0x08, 0x08, 0x08, 0xF8, 0x00, 0x00, 0x00, + + 0x00, 0x00, 0x00, 0x10, 0x10, 0x10, 0x10, 0x10, + 0x10, 0x10, 0x10, 0x10, 0x1F, 0x00, 0x00, 0x00, + }, + { // 6 + 0x00, 0x00, 0x00, 0xF8, 0x08, 0x08, 0x08, 0x08, + 0x08, 0x08, 0x08, 0x08, 0x08, 0x00, 0x00, 0x00, + + 0x00, 0x00, 0x00, 0xFF, 0x10, 0x10, 0x10, 0x10, + 0x08, 0x08, 0x08, 0x08, 0xF8, 0x00, 0x00, 0x00, + + 0x00, 0x00, 0x00, 0x1F, 0x10, 0x10, 0x10, 0x10, + 0x10, 0x10, 0x10, 0x10, 0x1F, 0x00, 0x00, 0x00, + }, + { // 7 + 0x00, 0x00, 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, + 0x08, 0x08, 0x08, 0x08, 0xF8, 0x00, 0x00, 0x00, + + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, + + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x1F, 0x00, 0x00, 0x00, + }, + { // 8 + 0x00, 0x00, 0x00, 0xF8, 0x08, 0x08, 0x08, 0x08, + 0x08, 0x08, 0x08, 0x08, 0xF8, 0x00, 0x00, 0x00, + + 0x00, 0x00, 0x00, 0xFF, 0x10, 0x10, 0x10, 0x10, + 0x08, 0x08, 0x08, 0x08, 0xFF, 0x00, 0x00, 0x00, + + 0x00, 0x00, 0x00, 0x1F, 0x10, 0x10, 0x10, 0x10, + 0x10, 0x10, 0x10, 0x10, 0x1F, 0x00, 0x00, 0x00, + }, + { // 9 + 0x00, 0x00, 0x00, 0xF8, 0x08, 0x08, 0x08, 0x08, + 0x08, 0x08, 0x08, 0x08, 0xF8, 0x00, 0x00, 0x00, + + 0x00, 0x00, 0x00, 0x1F, 0x10, 0x10, 0x10, 0x10, + 0x08, 0x08, 0x08, 0x08, 0xFF, 0x00, 0x00, 0x00, + + 0x00, 0x00, 0x00, 0x10, 0x10, 0x10, 0x10, 0x10, + 0x10, 0x10, 0x10, 0x10, 0x1F, 0x00, 0x00, 0x00, + } +}; + +static const char my_font_lib_etc_logo[] PROGMEM = { + 0x00, 0x00, 0x18, 0x30, 0x60, 0xC0, 0x80, 0x00, + 0x00, 0x80, 0xC0, 0x60, 0x30, 0x18, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0xF8, + 0x18, 0x18, 0x18, 0x30, 0x60, 0xC0, 0x00, 0x00, + + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xFF, + 0xFF, 0x01, 0x00, 0x00, 0x00, 0xDC, 0x22, 0x22, + 0xDC, 0x80, 0x40, 0x00, 0x00, 0x00, 0xFF, 0xFF, + 0x7C, 0xCC, 0x8C, 0x06, 0x03, 0x01, 0x00, 0x00, + + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, + 0x1F, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, + 0x01, 0x01, 0x02, 0x00, 0x00, 0x00, 0x1F, 0x1F, + 0x00, 0x00, 0x01, 0x03, 0x06, 0x0C, 0x18, 0x00, +}; + +static const char my_font_lib_etc_r65_logo[] PROGMEM = { + 0x00, 0x00, 0xF8, 0xF8, 0x18, 0x18, 0x18, 0x18, + 0x18, 0x30, 0x60, 0xC0, 0x00, 0xF8, 0xF8, 0x18, + 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, 0xF8, 0xF8, + 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, 0x00, + + 0x00, 0x00, 0xFF, 0xFF, 0x3C, 0x6C, 0xCC, 0x8C, + 0x0C, 0x06, 0x03, 0x01, 0x00, 0xFF, 0xFF, 0x18, + 0x18, 0x18, 0x18, 0xF8, 0xF8, 0x00, 0x1F, 0x1F, + 0x18, 0x18, 0x18, 0x18, 0xF8, 0xF8, 0x00, 0x00, + + 0x00, 0x00, 0x1F, 0x1F, 0x00, 0x00, 0x00, 0x01, + 0x03, 0x06, 0x0C, 0x18, 0x00, 0x1F, 0x1F, 0x18, + 0x18, 0x18, 0x18, 0x1F, 0x1F, 0x00, 0x18, 0x18, + 0x18, 0x18, 0x18, 0x18, 0x1F, 0x1F, 0x00, 0x00, +}; diff --git a/keyboards/yandrstudio/rainbow65/keymaps/default/keymap.c b/keyboards/yandrstudio/rainbow65/keymaps/default/keymap.c new file mode 100755 index 000000000000..34c92c9c08b2 --- /dev/null +++ b/keyboards/yandrstudio/rainbow65/keymaps/default/keymap.c @@ -0,0 +1,392 @@ +#include "rainbow65.h" +#include "dynamic_keymap.h" +#include "raw_hid.h" +#include "print.h" +#include +#include "graph_lib/my_pic_lib.h" +#include "graph_lib/wpm_graph.h" +#include "graph_lib/kb_press_graph.h" +#include "dev_oled/oled_driver.h" +#include +enum layer_names { _BASE, _FN, _SYS, _USER }; + + +// Tap Dance declarations +enum { + TD_FN_LAYER_TOG, +}; + +void dance_layer_to_layer_count_pre(qk_tap_dance_state_t *state, void *user_data) { + if (state->count <= 4) { + layer_on(state->count); + // reset_tap_dance(state); + } + uprintf("press Fn %u times\n", state->count); +} + +void dance_layer_to_layer_count_finsh(qk_tap_dance_state_t *state, void *user_data) { + if (state->count <= 4) { + layer_off(state->count); + // reset_tap_dance(state); + } + uprintf("press Fn %u times\n", state->count); +} + +// Tap Dance definitions +qk_tap_dance_action_t tap_dance_actions[] = { + [TD_FN_LAYER_TOG] = ACTION_TAP_DANCE_FN_ADVANCED(NULL,dance_layer_to_layer_count_pre,dance_layer_to_layer_count_finsh) +}; + + +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + [_BASE] = KEYMAP( + KC_ESC, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC, KC_MUTE, + KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSLS, + KC_CAPS, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT, + KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, KC_UP, + KC_LCTL, KC_LGUI, KC_LALT, KC_VOLD, KC_VOLU, KC_SPC, KC_RALT, TD(TD_FN_LAYER_TOG), KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT), + + [_FN] = KEYMAP( + KC_GRV, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_DEL, TO(_BASE), + KC_TRNS, KC_TRNS, KC_UP, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_LEFT, KC_DOWN, KC_RGHT, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_CAPS, + KC_TRNS, RGB_TOG, RGB_MOD, RGB_MODE_REVERSE, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS), + + [_SYS] = KEYMAP( + TO(_BASE), KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, TO(_BASE), + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, RGB_MODE_PLAIN, RGB_MODE_BREATHE, RGB_MODE_RAINBOW, RGB_MODE_SWIRL, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, RGB_TOG, RGB_MOD, RGB_MODE_REVERSE, RGB_VAI, RGB_VAD, RGB_SPI, RGB_SPD, RGB_HUI, RGB_HUD, RGB_SAI, RGB_SAD, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS), + [_USER] = KEYMAP( + TO(_BASE), KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, TO(_BASE), + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS) +}; + + + +#ifdef ENCODER_ENABLE +void encoder_update_user(uint8_t index, bool clockwise) { + uprintf("%ud raw g_rgb_time\n", g_rgb_timer); + uprintf("%ud rgb speed\n", rgb_matrix_config.speed); + + // uprintf("%ud g_rgb_time scale8\n", scale16by8(g_rgb_timer, rgb_matrix_config.speed / 4)); + if (clockwise) { + uint16_t keycode = dynamic_keymap_get_keycode(biton32(layer_state), 4, 3); + if (keycode >= MACRO00 && keycode <= MACRO15) { + dynamic_keymap_macro_send(keycode - MACRO00); + } else { + register_code16(keycode); + wait_ms(10); + unregister_code16(keycode); + } + } else { + uint16_t keycode = dynamic_keymap_get_keycode(biton32(layer_state), 4, 4); + if (keycode >= MACRO00 && keycode <= MACRO15) { + dynamic_keymap_macro_send(keycode - MACRO00); + } else { + register_code16(keycode); + wait_ms(10); + unregister_code16(keycode); + } + } +} +#endif + +#ifdef OLED_DRIVER_ENABLE +char wpm_str[10]; // limit WPM string length. +char rgbStatus[26] = {0}; +uint16_t oled_start_timer = 0; +uint16_t key_press_count = 0; + +#define col_module_ +oled_rotation_t oled_init_user(oled_rotation_t rotation) { + // oled_scroll_set_area(0,2); + // oled_scroll_set_speed(4); + // oled_scroll_right(); + oled_start_timer = timer_read(); + return OLED_ROTATION_90; +} + + + +void oled_write_ln_clo(const char *data, bool invert, uint8_t col, uint8_t line) { + uint8_t l = strlen(data); + const char *end = data + l; + uint8_t i = 0; + while (data < end) { + oled_set_cursor(col, line+i); + oled_write_char(*data, invert); + data++; + i++; + } + uint8_t rm = 16-(line+l); + uint8_t j = 0; + for(; j < rm; ++j) { + oled_set_cursor(col, line+j+l); + oled_write_char(' ', invert); + } +} + +void oled_write_clo(const char *data, bool invert, uint8_t col, uint8_t line) { + uint8_t l = strlen(data); + const char *end = data + l; + uint8_t i = 0; + while (data < end) { + oled_set_cursor(col, line+i); + oled_write_char(*data, invert); + data++; + i++; + } +} + + +static bool has_clear = false; +void oled_task_user(void) { + if (!has_clear) { + oled_clear(); + has_clear = true; + } + // if (timer_elapsed(oled_start_timer) < 1000) { + // render_logo_yandr(); + // } + // Layer + const char *st_my = my_font_lib_layer; + oled_set_cursor(0,0); + oled_write_raw_P(st_my, 24); + oled_set_cursor(0,1); + oled_write_raw_P(st_my+8*8, 24); + switch (biton32(layer_state)) { + case 0: + oled_set_cursor(4,0); + oled_write_raw_P(st_my+3*8, 8); + oled_set_cursor(4,1); + oled_write_raw_P(st_my+11*8, 8); + oled_set_cursor(0,2); + break; + case 1: + oled_set_cursor(4,0); + oled_write_raw_P(st_my+4*8, 8); + oled_set_cursor(4,1); + oled_write_raw_P(st_my+12*8, 8); + oled_set_cursor(0,2); + break; + case 2: + oled_set_cursor(4,0); + oled_write_raw_P(st_my+5*8, 8); + oled_set_cursor(4,1); + oled_write_raw_P(st_my+13*8, 8); + oled_set_cursor(0,2); + break; + case 3: + oled_set_cursor(4,0); + oled_write_raw_P(st_my+6*8, 8); + oled_set_cursor(4,1); + oled_write_raw_P(st_my+14*8, 8); + oled_set_cursor(0,2); + break; + default: + oled_set_cursor(4,0); + oled_write_raw_P(st_my+7*8, 8); + oled_set_cursor(4,1); + oled_write_raw_P(st_my+15*8, 8); + oled_set_cursor(0,2); + } + oled_set_cursor(0,2); + if (host_keyboard_led_state().caps_lock) { + oled_write_raw_P(my_font_lib_caps_on, 24); + oled_set_cursor(0,3); + oled_write_raw_P(my_font_lib_caps_on+3*8, 24); + } else { + oled_write_raw_P(my_font_lib_caps_off, 24); + oled_set_cursor(0,3); + oled_write_raw_P(my_font_lib_caps_off+3*8, 24); + } + oled_set_cursor(4,2); + if ((get_mods() & MOD_MASK_SHIFT)) { + oled_write_raw_P(my_font_lib_shift_on, 8); + oled_set_cursor(4,3); + oled_write_raw_P(my_font_lib_shift_on+1*8, 8); + } else { + oled_write_raw_P(my_font_lib_shift_off, 8); + oled_set_cursor(4,3); + oled_write_raw_P(my_font_lib_shift_off+1*8, 8); + } + oled_set_precise_cursor(4*32+1); + if ((get_mods() & MOD_MASK_CTRL)) { + oled_write_raw_P(my_font_lib_ctrl_on, 10); + oled_set_precise_cursor(5*32+1); + oled_write_raw_P(my_font_lib_ctrl_on+1*10, 10); + } else { + oled_write_raw_P(my_font_lib_ctrl_off, 10); + oled_set_precise_cursor(5*32+1); + oled_write_raw_P(my_font_lib_ctrl_off+1*10, 10); + } + oled_set_precise_cursor(4*32+11); + if ((get_mods() & MOD_MASK_GUI)) { + oled_write_raw_P(my_font_lib_gui_on, 10); + oled_set_precise_cursor(5*32+11); + oled_write_raw_P(my_font_lib_gui_on+1*10, 10); + } else { + oled_write_raw_P(my_font_lib_gui_off, 10); + oled_set_precise_cursor(5*32+11); + oled_write_raw_P(my_font_lib_gui_off+1*10, 10); + } + oled_set_precise_cursor(4*32+21); + if ((get_mods() & MOD_MASK_ALT)) { + oled_write_raw_P(my_font_lib_alt_on, 10); + oled_set_precise_cursor(5*32+21); + oled_write_raw_P(my_font_lib_alt_on+1*10, 10); + } else { + oled_write_raw_P(my_font_lib_alt_off, 10); + oled_set_precise_cursor(5*32+21); + oled_write_raw_P(my_font_lib_alt_off+1*10, 10); + } + // oled_write_ln_P((get_mods() & MOD_MASK_ALT) ? "\x9c" : "\x9b", false); + oled_set_cursor(0,6); + if (rgb_matrix_is_enabled()) { + oled_write_raw_P(my_font_lib_rgb_on, 20); + oled_set_precise_cursor(6*32+20); + snprintf(rgbStatus, sizeof(rgbStatus), "%2d", rgb_matrix_get_mode()); + oled_write(rgbStatus, false); + oled_set_cursor(0,7); + oled_write_raw_P(my_font_lib_rgb_on+1*24, 20); + oled_set_precise_cursor(7*32+20); + snprintf(rgbStatus, sizeof(rgbStatus), "%2d", RGB_MATRIX_EFFECT_MAX); + oled_write(rgbStatus, false); + } else { + oled_write_raw_P(my_font_lib_rgb_off, 20); + oled_set_precise_cursor(6*32+20); + oled_write("xx", false); + oled_set_cursor(0,7); + oled_write_raw_P(my_font_lib_rgb_off+1*24, 20); + oled_set_precise_cursor(7*32+20); + oled_write("xx", false); + } + + // show which area is pressed + if (key_press_count==0) { + render_r65_kb(255, 255, 0, false, key_press_count); + } + + oled_set_cursor(0,10); + uint16_t cur_wpm = get_current_wpm(); + snprintf(wpm_str, sizeof(wpm_str), " %03d ", cur_wpm); + oled_write_ln_P(wpm_str, false); + oled_set_cursor(0,11); + + // show the wpm wave + render_wpm_graph(cur_wpm); +} + +bool process_record_user(uint16_t keycode, keyrecord_t *record) { + // switch(keycode) { + // case MACRO_1: + // if (record->event.pressed) { + // SEND_STRING("This is macro #1."); + // } + // return false; + // } +#ifdef OLED_DRIVER_ENABLE + uint8_t map_col = record->event.key.col; + uint8_t map_row = record->event.key.row; + if (record->event.pressed) { + key_press_count++; + print("key_press\n"); + uprintf("col %d ", map_col); + uprintf("row %d\n", map_row); + render_r65_kb(map_col, map_row, keycode, true, key_press_count); + } else { + if (key_press_count>0) { + key_press_count--; + } + render_r65_kb(map_col, map_row, keycode, false, key_press_count); + } +#endif + return true; +}; + + +#endif + +#define RAW_HID_CUM_ + + +#ifdef RAW_HID_CUM +extern uint8_t global_r_power_state[MATRIX_ROWS]; +extern uint8_t global_c_power_state[MATRIX_COLS]; +uint8_t pre_rgb_mode = 0xff; +void raw_hid_receive_kb(uint8_t *data, uint8_t length) { + // Your code goes here. data is the packet received from host. + switch (data[0]) { + case 60: + switch (data[1]) { + case 1: + rgb_matrix_toggle_noeeprom(); + break; + case 2: + rgb_matrix_enable_noeeprom(); + break; + case 3: + rgb_matrix_disable_noeeprom(); + break; + case 4: + if (rgb_matrix_get_mode() != RGB_MATRIX_CUSTOM_AUDIO_VISUALIZATION_COL) { + pre_rgb_mode = rgb_matrix_get_mode(); + rgb_matrix_mode(RGB_MATRIX_CUSTOM_AUDIO_VISUALIZATION_COL); + } else { + rgb_matrix_mode(pre_rgb_mode); + } + break; + case 5: + if (rgb_matrix_get_mode() != RGB_MATRIX_CUSTOM_AUDIO_VISUALIZATION_ROW) { + pre_rgb_mode = rgb_matrix_get_mode(); + rgb_matrix_mode(RGB_MATRIX_CUSTOM_AUDIO_VISUALIZATION_ROW); + } else { + rgb_matrix_mode(pre_rgb_mode); + } + case 6: + if (rgb_matrix_get_mode() == RGB_MATRIX_CUSTOM_AUDIO_VISUALIZATION_ROW) { + for (uint8_t i = 0; i < length; ++i) { + global_r_power_state[i] = data[2+i]; + } + } else if (rgb_matrix_get_mode() == RGB_MATRIX_CUSTOM_AUDIO_VISUALIZATION_COL) { + for (uint8_t i = 0; i < length; ++i) { + global_c_power_state[i] = data[2+i]; + } + } else { + dprint("BAD: not in the audio visual mod."); + } + break; + case 7: + rgb_matrix_mode(data[2]); + default: + break; + } + break; + case 66: + dprint("GOOD: 6666"); + break; + default: + break; + } + raw_hid_send(data, 32); +} +#endif + + + +#ifdef CONSOLE_ENABLE +void keyboard_post_init_user(void) { + // eeconfig_init(); + // Customise these values to desired behaviour + debug_enable=true; + debug_matrix=false; + // debug_keyboard=true; + //debug_mouse=true; +} +#endif diff --git a/keyboards/yandrstudio/rainbow65/keymaps/default/rgb_matrix_user.inc b/keyboards/yandrstudio/rainbow65/keymaps/default/rgb_matrix_user.inc new file mode 100755 index 000000000000..03aa3b20015b --- /dev/null +++ b/keyboards/yandrstudio/rainbow65/keymaps/default/rgb_matrix_user.inc @@ -0,0 +1,98 @@ +/* +Copyright 2020 Evy Dekkers + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +RGB_MATRIX_EFFECT(AUDIO_VISUALIZATION_COL) +RGB_MATRIX_EFFECT(AUDIO_VISUALIZATION_ROW) + + +#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS +uint8_t global_r_power_state[MATRIX_ROWS]; +uint8_t global_c_power_state[MATRIX_COLS]; + +// bool AUDIO_VISUALIZATION_COL(effect_params_t* params) { +// // HSV hsv = rgb_matrix_config.hsv; +// // RGB rgb = hsv_to_rgb(hsv); +// RGB_MATRIX_USE_LIMITS(led_min, led_max); +// for (uint8_t i = led_min ; i < led_max; i++) { +// rgb_matrix_set_color(i, global_r_state[i], global_g_state[i], global_b_state[i]); +// } +// return led_max < DRIVER_LED_TOTAL; +// } + + + + +static HSV AUDIO_VISUALIZATION_COL_math(HSV hsv, uint8_t i, uint8_t time) { + // uint8_t cur_row = (uint8_t)((MATRIX_ROWS-1)*g_led_config.point[i].y/64); + uint8_t cur_col = (uint8_t)((MATRIX_COLS-1)*g_led_config.point[i].x/224); + uint8_t cur_row2height_index = MATRIX_ROWS - (uint8_t)((MATRIX_ROWS-1)*g_led_config.point[i].y/64) - 1; + uint8_t max_height_cur_col = (uint8_t)(global_c_power_state[cur_col]*MATRIX_ROWS/10); + + if (max_height_cur_col >= 1 && (max_height_cur_col - 1) >= cur_row2height_index) { + hsv.h += abs8(g_led_config.point[i].y - k_rgb_matrix_center.y) + (g_led_config.point[i].x - time); + } else { + hsv.h = 0; + hsv.v = 0; + } + return hsv; +} + +static HSV AUDIO_VISUALIZATION_ROW_math(HSV hsv, uint8_t i, uint8_t time) { + uint8_t cur_row = (uint8_t)((MATRIX_ROWS-1)*g_led_config.point[i].y/64); + // uint8_t cur_col2height_index = MATRIX_COLS - (uint8_t)((MATRIX_COLS-1)*g_led_config.point[i].x/224) - 1; + uint8_t cur_col2height_index = (uint8_t)((MATRIX_COLS-1)*g_led_config.point[i].x/224); + + uint8_t max_height_cur_row = (uint8_t)(global_r_power_state[cur_row]*MATRIX_COLS/10); + + + if (max_height_cur_row >= 1 && (max_height_cur_row - 1) >= cur_col2height_index) { + hsv.h += abs8(g_led_config.point[i].y - k_rgb_matrix_center.y) + (g_led_config.point[i].x - time); + } else { + hsv.h = 0; + hsv.v = 0; + } + return hsv; +} +bool AUDIO_VISUALIZATION_COL(effect_params_t* params) { + // HSV hsv = rgb_matrix_config.hsv; + // RGB rgb = hsv_to_rgb(hsv); + return effect_runner_i(params, &AUDIO_VISUALIZATION_COL_math); +} + +bool AUDIO_VISUALIZATION_ROW(effect_params_t* params) { + return effect_runner_i(params, &AUDIO_VISUALIZATION_ROW_math); +} +// static HSV RAINBOW_MOVING_CHEVRON_math(HSV hsv, uint8_t i, uint8_t time) { +// hsv.h += abs8(g_led_config.point[i].y - k_rgb_matrix_center.y) + (g_led_config.point[i].x - time); +// return hsv; +// } +// static HSV RAINBOW_BEACON_math(HSV hsv, int8_t sin, int8_t cos, uint8_t i, uint8_t time) { +// hsv.h += ((g_led_config.point[i].y - k_rgb_matrix_center.y) * 2 * cos + (g_led_config.point[i].x - k_rgb_matrix_center.x) * 2 * sin) / 128; +// return hsv; +// } +// static HSV RAINBOW_PINWHEELS_math(HSV hsv, int8_t sin, int8_t cos, uint8_t i, uint8_t time) { +// hsv.h += ((g_led_config.point[i].y - k_rgb_matrix_center.y) * 3 * cos + (56 - abs8(g_led_config.point[i].x - k_rgb_matrix_center.x)) * 3 * sin) / 128; +// return hsv; +// } + +// bool RAINBOW_PINWHEELS(effect_params_t* params) { return effect_runner_sin_cos_i(params, &RAINBOW_PINWHEELS_math); } +// bool RAINBOW_BEACON(effect_params_t* params) { return effect_runner_sin_cos_i(params, &RAINBOW_BEACON_math); } +// bool RAINBOW_MOVING_CHEVRON(effect_params_t* params) { return effect_runner_i(params, &RAINBOW_MOVING_CHEVRON_math); } + + + +#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS diff --git a/keyboards/yandrstudio/rainbow65/keymaps/default/rules.mk b/keyboards/yandrstudio/rainbow65/keymaps/default/rules.mk new file mode 100755 index 000000000000..99ea2668c767 --- /dev/null +++ b/keyboards/yandrstudio/rainbow65/keymaps/default/rules.mk @@ -0,0 +1,11 @@ +# OLED_DRIVER_ENABLE = yes +VIA_ENABLE = yes +WPM_ENABLE = yes +RGB_MATRIX_CUSTOM_USER = no +CONSOLE_ENABLE = no +TAP_DANCE_ENABLE = yes + +SRC += graph_lib/wpm_graph.c graph_lib/kb_press_graph.c dev_oled/oled_driver.c +QUANTUM_LIB_SRC += i2c_master.c +OPT_DEFS += -DOLED_DRIVER_ENABLE +COMMON_VPATH += keyboards/yandrstudio/rainbow65/keymaps/test_oled/dev_oled diff --git a/keyboards/yandrstudio/rainbow65/keymaps/test_oled/config.h b/keyboards/yandrstudio/rainbow65/keymaps/test_oled/config.h new file mode 100755 index 000000000000..5657b8d1b817 --- /dev/null +++ b/keyboards/yandrstudio/rainbow65/keymaps/test_oled/config.h @@ -0,0 +1,24 @@ +/* OLED */ +#ifdef OLED_DRIVER_ENABLE +// # define OLED_DISPLAY_128X64 +# define I2C_DRIVER I2CD1 +# define I2C1_TIMINGR_PRESC 0U +# define I2C1_TIMINGR_SCLDEL 7U +# define I2C1_TIMINGR_SDADEL 0U +# define I2C1_TIMINGR_SCLH 38U +# define I2C1_TIMINGR_SCLL 129U +# define OLED_BRIGHTNESS 50 +# define OLED_TIMEOUT 300000 +// # define OLED_TIMEOUT 0 +# define OLED_FONT_HEIGHT 8 +# define OLED_FONT_WIDTH 6 +# define OLED_FONT_H "../../jason_fount.c" +# define OLED_FONT_END 127 +# define OLED_FONT_START 0 +#endif + + +#ifdef TAP_DANCE_ENABLE +#define TAPPING_TERM 300 + +#endif diff --git a/keyboards/yandrstudio/rainbow65/keymaps/test_oled/dev_oled/glcdfont.c b/keyboards/yandrstudio/rainbow65/keymaps/test_oled/dev_oled/glcdfont.c new file mode 100755 index 000000000000..de5896018986 --- /dev/null +++ b/keyboards/yandrstudio/rainbow65/keymaps/test_oled/dev_oled/glcdfont.c @@ -0,0 +1,16 @@ +#include "progmem.h" + +// Helidox 8x6 font with QMK Firmware Logo +// Online editor: http://teripom.x0.com/ + +static const unsigned char font[] PROGMEM = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3E, 0x5B, 0x4F, 0x5B, 0x3E, 0x00, 0x3E, 0x6B, 0x4F, 0x6B, 0x3E, 0x00, 0x1C, 0x3E, 0x7C, 0x3E, 0x1C, 0x00, 0x18, 0x3C, 0x7E, 0x3C, 0x18, 0x00, 0x1C, 0x57, 0x7D, 0x57, 0x1C, 0x00, 0x1C, 0x5E, 0x7F, 0x5E, 0x1C, 0x00, 0x00, 0x18, 0x3C, 0x18, 0x00, 0x00, 0xFF, 0xE7, 0xC3, 0xE7, 0xFF, 0x00, 0x00, 0x18, 0x24, 0x18, 0x00, 0x00, 0xFF, 0xE7, 0xDB, 0xE7, 0xFF, 0x00, 0x30, 0x48, 0x3A, 0x06, 0x0E, 0x00, 0x26, 0x29, 0x79, 0x29, 0x26, 0x00, 0x40, 0x7F, 0x05, 0x05, 0x07, 0x00, 0x40, 0x7F, 0x05, 0x25, 0x3F, 0x00, 0x5A, 0x3C, 0xE7, 0x3C, 0x5A, 0x00, 0x7F, 0x3E, 0x1C, 0x1C, 0x08, 0x00, 0x08, 0x1C, 0x1C, 0x3E, 0x7F, 0x00, 0x14, 0x22, 0x7F, 0x22, 0x14, 0x00, 0x5F, 0x5F, 0x00, 0x5F, 0x5F, 0x00, 0x06, 0x09, 0x7F, 0x01, 0x7F, 0x00, 0x00, 0x66, 0x89, 0x95, 0x6A, 0x00, 0x60, 0x60, 0x60, 0x60, 0x60, 0x00, 0x94, 0xA2, 0xFF, 0xA2, 0x94, 0x00, 0x08, 0x04, 0x7E, 0x04, 0x08, 0x00, + 0x10, 0x20, 0x7E, 0x20, 0x10, 0x00, 0x08, 0x08, 0x2A, 0x1C, 0x08, 0x00, 0x08, 0x1C, 0x2A, 0x08, 0x08, 0x00, 0x1E, 0x10, 0x10, 0x10, 0x10, 0x00, 0x0C, 0x1E, 0x0C, 0x1E, 0x0C, 0x00, 0x30, 0x38, 0x3E, 0x38, 0x30, 0x00, 0x06, 0x0E, 0x3E, 0x0E, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5F, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x07, 0x00, 0x00, 0x14, 0x7F, 0x14, 0x7F, 0x14, 0x00, 0x24, 0x2A, 0x7F, 0x2A, 0x12, 0x00, 0x23, 0x13, 0x08, 0x64, 0x62, 0x00, 0x36, 0x49, 0x56, 0x20, 0x50, 0x00, 0x00, 0x08, 0x07, 0x03, 0x00, 0x00, 0x00, 0x1C, 0x22, 0x41, 0x00, 0x00, 0x00, 0x41, 0x22, 0x1C, 0x00, 0x00, 0x2A, 0x1C, 0x7F, 0x1C, 0x2A, 0x00, 0x08, 0x08, 0x3E, 0x08, 0x08, 0x00, 0x00, 0x80, 0x70, 0x30, 0x00, 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x00, 0x00, 0x00, 0x60, 0x60, 0x00, 0x00, 0x20, 0x10, 0x08, 0x04, 0x02, 0x00, 0x3E, 0x51, 0x49, 0x45, 0x3E, 0x00, 0x00, 0x42, 0x7F, 0x40, 0x00, 0x00, + 0x72, 0x49, 0x49, 0x49, 0x46, 0x00, 0x21, 0x41, 0x49, 0x4D, 0x33, 0x00, 0x18, 0x14, 0x12, 0x7F, 0x10, 0x00, 0x27, 0x45, 0x45, 0x45, 0x39, 0x00, 0x3C, 0x4A, 0x49, 0x49, 0x31, 0x00, 0x41, 0x21, 0x11, 0x09, 0x07, 0x00, 0x36, 0x49, 0x49, 0x49, 0x36, 0x00, 0x46, 0x49, 0x49, 0x29, 0x1E, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x40, 0x34, 0x00, 0x00, 0x00, 0x00, 0x08, 0x14, 0x22, 0x41, 0x00, 0x14, 0x14, 0x14, 0x14, 0x14, 0x00, 0x00, 0x41, 0x22, 0x14, 0x08, 0x00, 0x02, 0x01, 0x59, 0x09, 0x06, 0x00, 0x3E, 0x41, 0x5D, 0x59, 0x4E, 0x00, 0x7C, 0x12, 0x11, 0x12, 0x7C, 0x00, 0x7F, 0x49, 0x49, 0x49, 0x36, 0x00, 0x3E, 0x41, 0x41, 0x41, 0x22, 0x00, 0x7F, 0x41, 0x41, 0x41, 0x3E, 0x00, 0x7F, 0x49, 0x49, 0x49, 0x41, 0x00, 0x7F, 0x09, 0x09, 0x09, 0x01, 0x00, 0x3E, 0x41, 0x41, 0x51, 0x73, 0x00, 0x7F, 0x08, 0x08, 0x08, 0x7F, 0x00, 0x00, 0x41, 0x7F, 0x41, 0x00, 0x00, 0x20, 0x40, 0x41, 0x3F, 0x01, 0x00, + 0x7F, 0x08, 0x14, 0x22, 0x41, 0x00, 0x7F, 0x40, 0x40, 0x40, 0x40, 0x00, 0x7F, 0x02, 0x1C, 0x02, 0x7F, 0x00, 0x7F, 0x04, 0x08, 0x10, 0x7F, 0x00, 0x3E, 0x41, 0x41, 0x41, 0x3E, 0x00, 0x7F, 0x09, 0x09, 0x09, 0x06, 0x00, 0x3E, 0x41, 0x51, 0x21, 0x5E, 0x00, 0x7F, 0x09, 0x19, 0x29, 0x46, 0x00, 0x26, 0x49, 0x49, 0x49, 0x32, 0x00, 0x03, 0x01, 0x7F, 0x01, 0x03, 0x00, 0x3F, 0x40, 0x40, 0x40, 0x3F, 0x00, 0x1F, 0x20, 0x40, 0x20, 0x1F, 0x00, 0x3F, 0x40, 0x38, 0x40, 0x3F, 0x00, 0x63, 0x14, 0x08, 0x14, 0x63, 0x00, 0x03, 0x04, 0x78, 0x04, 0x03, 0x00, 0x61, 0x59, 0x49, 0x4D, 0x43, 0x00, 0x00, 0x7F, 0x41, 0x41, 0x41, 0x00, 0x02, 0x04, 0x08, 0x10, 0x20, 0x00, 0x00, 0x41, 0x41, 0x41, 0x7F, 0x00, 0x04, 0x02, 0x01, 0x02, 0x04, 0x00, 0x40, 0x40, 0x40, 0x40, 0x40, 0x00, 0x00, 0x03, 0x07, 0x08, 0x00, 0x00, 0x20, 0x54, 0x54, 0x78, 0x40, 0x00, 0x7F, 0x28, 0x44, 0x44, 0x38, 0x00, 0x38, 0x44, 0x44, 0x44, 0x28, 0x00, + 0x38, 0x44, 0x44, 0x28, 0x7F, 0x00, 0x38, 0x54, 0x54, 0x54, 0x18, 0x00, 0x00, 0x08, 0x7E, 0x09, 0x02, 0x00, 0x18, 0xA4, 0xA4, 0x9C, 0x78, 0x00, 0x7F, 0x08, 0x04, 0x04, 0x78, 0x00, 0x00, 0x44, 0x7D, 0x40, 0x00, 0x00, 0x20, 0x40, 0x40, 0x3D, 0x00, 0x00, 0x7F, 0x10, 0x28, 0x44, 0x00, 0x00, 0x00, 0x41, 0x7F, 0x40, 0x00, 0x00, 0x7C, 0x04, 0x78, 0x04, 0x78, 0x00, 0x7C, 0x08, 0x04, 0x04, 0x78, 0x00, 0x38, 0x44, 0x44, 0x44, 0x38, 0x00, 0xFC, 0x18, 0x24, 0x24, 0x18, 0x00, 0x18, 0x24, 0x24, 0x18, 0xFC, 0x00, 0x7C, 0x08, 0x04, 0x04, 0x08, 0x00, 0x48, 0x54, 0x54, 0x54, 0x24, 0x00, 0x04, 0x04, 0x3F, 0x44, 0x24, 0x00, 0x3C, 0x40, 0x40, 0x20, 0x7C, 0x00, 0x1C, 0x20, 0x40, 0x20, 0x1C, 0x00, 0x3C, 0x40, 0x30, 0x40, 0x3C, 0x00, 0x44, 0x28, 0x10, 0x28, 0x44, 0x00, 0x4C, 0x90, 0x90, 0x90, 0x7C, 0x00, 0x44, 0x64, 0x54, 0x4C, 0x44, 0x00, 0x00, 0x08, 0x36, 0x41, 0x00, 0x00, 0x00, 0x00, 0x77, 0x00, 0x00, 0x00, + 0x00, 0x41, 0x36, 0x08, 0x00, 0x00, 0x02, 0x01, 0x02, 0x04, 0x02, 0x00, 0x3C, 0x26, 0x23, 0x26, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x40, 0x40, 0xF0, 0xF8, 0xF8, 0xFF, 0x38, 0xFF, 0xF8, 0xF8, 0x3F, 0xF8, 0xF8, 0xFF, 0x38, 0xFF, 0xF8, 0xF8, 0xF0, 0x40, 0x40, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xC0, 0xC0, 0xC0, 0x80, 0x00, 0x00, 0xC0, 0xC0, 0x80, 0x00, 0x00, 0x00, 0x80, 0xC0, 0xC0, 0x00, 0xC0, 0xC0, 0x00, 0x00, 0x80, 0xC0, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0x00, 0xC0, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xF0, 0xF8, 0xFC, 0x3E, + 0x1E, 0x06, 0x01, 0x00, 0x00, 0x00, 0x7F, 0x41, 0x41, 0x41, 0x7F, 0x00, 0x7F, 0x41, 0x41, 0x41, 0x7F, 0x00, 0x00, 0x80, 0xC0, 0xE0, 0x7E, 0x5B, 0x4F, 0x5B, 0xFE, 0xC0, 0x00, 0x00, 0xC0, 0x00, 0xDC, 0xD7, 0xDE, 0xDE, 0xDE, 0xD7, 0xDC, 0x00, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x49, 0x49, 0x49, 0xFF, 0xFF, 0xFF, 0xFF, 0xE0, 0xDF, 0xBF, 0xBF, 0x00, 0xBF, 0xBF, 0xDF, 0xE0, 0xFF, 0xFF, 0xFF, 0xFF, 0x49, 0x49, 0x49, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x3F, 0x60, 0x60, 0xE0, 0xBF, 0x1F, 0x00, 0x7F, 0x7F, 0x07, 0x1E, 0x38, 0x1E, 0x07, 0x7F, 0x7F, 0x00, 0x7F, 0x7F, 0x0E, 0x1F, 0x3B, 0x71, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0x7F, 0x0C, 0x0C, 0x0C, 0x00, 0x7E, 0x7E, 0x00, 0x7F, 0x7E, 0x03, 0x03, 0x00, 0x7F, 0x7E, 0x03, 0x03, 0x7E, 0x7E, 0x03, 0x03, 0x7F, 0x7E, 0x00, 0x0F, + 0x3E, 0x70, 0x3C, 0x06, 0x3C, 0x70, 0x3E, 0x0F, 0x00, 0x32, 0x7B, 0x49, 0x49, 0x3F, 0x7E, 0x00, 0x7F, 0x7E, 0x03, 0x03, 0x00, 0x1E, 0x3F, 0x69, 0x69, 0x6F, 0x26, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x0F, 0x1F, 0x3F, 0x3C, 0x78, 0x70, 0x60, 0x00, 0x00, 0x00, 0x7F, 0x41, 0x41, 0x41, 0x7F, 0x00, 0x7F, 0x41, 0x41, 0x41, 0x7F, 0x00, 0x30, 0x7B, 0x7F, 0x78, 0x30, 0x20, 0x20, 0x30, 0x78, 0x7F, 0x3B, 0x00, 0x03, 0x00, 0x0F, 0x7F, 0x0F, 0x0F, 0x0F, 0x7F, 0x0F, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x07, 0x0F, 0x0F, 0x7F, 0x0F, 0x7F, 0x0F, 0x0F, 0x7E, 0x0F, 0x0F, 0x7F, 0x0F, 0x7F, 0x0F, 0x0F, 0x07, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +}; diff --git a/keyboards/yandrstudio/rainbow65/keymaps/test_oled/dev_oled/licenses.txt b/keyboards/yandrstudio/rainbow65/keymaps/test_oled/dev_oled/licenses.txt new file mode 100755 index 000000000000..111603ebf3c7 --- /dev/null +++ b/keyboards/yandrstudio/rainbow65/keymaps/test_oled/dev_oled/licenses.txt @@ -0,0 +1,45 @@ +The Android robot is reproduced or modified from work created and shared by Google and used according to terms described in the Creative Commons 3.0 Attribution License. + + +This is the Linux-penguin again... + +Originally drewn by Larry Ewing (http://www.isc.tamu.edu/~lewing/) +(with the GIMP) the Linux Logo has been vectorized by me (Simon Budig, +http://www.home.unix-ag.org/simon/). + +This happened quite some time ago with Corel Draw 4. But luckily +meanwhile there are tools available to handle vector graphics with +Linux. Bernhard Herzog (bernhard@users.sourceforge.net) deserves kudos +for creating Sketch (http://sketch.sourceforge.net), a powerful free +tool for creating vector graphics. He converted the Corel Draw file to +the Sketch native format. Since I am unable to maintain the Corel Draw +file any longer, the Sketch version now is the "official" one. + +Anja Gerwinski (anja@gerwinski.de) has created an alternate version of +the penguin (penguin-variant.sk) with a thinner mouth line and slightly +altered gradients. It also features a nifty drop shadow. + +The third bird (penguin-flat.sk) is a version reduced to three colors +(black/white/yellow) for e.g. silk screen printing. I made this version +for a mug, available at the friendly folks at +http://www.kernelconcepts.de/ - they do good stuff, mail Petra +(pinguin@kernelconcepts.de) if you need something special or don't +understand the german :-) + +These drawings are copyrighted by Larry Ewing and Simon Budig +(penguin-variant.sk also by Anja Gerwinski), redistribution is free but +has to include this README/Copyright notice. + +The use of these drawings is free. However I am happy about a sample of +your mug/t-shirt/whatever with this penguin on it... + +Have fun + Simon Budig + + +Simon.Budig@unix-ag.org +http://www.home.unix-ag.org/simon/ + +Simon Budig +Am Hardtkoeppel 2 +D-61279 Graevenwiesbach diff --git a/keyboards/yandrstudio/rainbow65/keymaps/test_oled/dev_oled/oled_driver.c b/keyboards/yandrstudio/rainbow65/keymaps/test_oled/dev_oled/oled_driver.c new file mode 100755 index 000000000000..23b81e5ad9f3 --- /dev/null +++ b/keyboards/yandrstudio/rainbow65/keymaps/test_oled/dev_oled/oled_driver.c @@ -0,0 +1,767 @@ +/* +Copyright 2019 Ryan Caltabiano + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ +#include "i2c_master.h" +#include "oled_driver.h" +#include OLED_FONT_H +#include "timer.h" +#include "print.h" + +#include + +#include "progmem.h" + +// Used commands from spec sheet: https://cdn-shop.adafruit.com/datasheets/SSD1306.pdf +// for SH1106: https://www.velleman.eu/downloads/29/infosheets/sh1106_datasheet.pdf + +// Fundamental Commands +#define CONTRAST 0x81 +#define DISPLAY_ALL_ON 0xA5 +#define DISPLAY_ALL_ON_RESUME 0xA4 +#define NORMAL_DISPLAY 0xA6 +#define DISPLAY_ON 0xAF +#define DISPLAY_OFF 0xAE +#define NOP 0xE3 + +// Scrolling Commands +#define ACTIVATE_SCROLL 0x2F +#define DEACTIVATE_SCROLL 0x2E +#define SCROLL_RIGHT 0x26 +#define SCROLL_LEFT 0x27 +#define SCROLL_RIGHT_UP 0x29 +#define SCROLL_LEFT_UP 0x2A + +// Addressing Setting Commands +#define MEMORY_MODE 0x20 +#define COLUMN_ADDR 0x21 +#define PAGE_ADDR 0x22 +#define PAM_SETCOLUMN_LSB 0x00 +#define PAM_SETCOLUMN_MSB 0x10 +#define PAM_PAGE_ADDR 0xB0 // 0xb0 -- 0xb7 + +// Hardware Configuration Commands +#define DISPLAY_START_LINE 0x40 +#define SEGMENT_REMAP 0xA0 +#define SEGMENT_REMAP_INV 0xA1 +#define MULTIPLEX_RATIO 0xA8 +#define COM_SCAN_INC 0xC0 +#define COM_SCAN_DEC 0xC8 +#define DISPLAY_OFFSET 0xD3 +#define COM_PINS 0xDA +#define COM_PINS_SEQ 0x02 +#define COM_PINS_ALT 0x12 +#define COM_PINS_SEQ_LR 0x22 +#define COM_PINS_ALT_LR 0x32 + +// Timing & Driving Commands +#define DISPLAY_CLOCK 0xD5 +#define PRE_CHARGE_PERIOD 0xD9 +#define VCOM_DETECT 0xDB + +// Charge Pump Commands +#define CHARGE_PUMP 0x8D + +// Misc defines +#ifndef OLED_BLOCK_COUNT +# define OLED_BLOCK_COUNT (sizeof(OLED_BLOCK_TYPE) * 8) +#endif +#ifndef OLED_BLOCK_SIZE +# define OLED_BLOCK_SIZE (OLED_MATRIX_SIZE / OLED_BLOCK_COUNT) +#endif + +#define OLED_ALL_BLOCKS_MASK (((((OLED_BLOCK_TYPE)1 << (OLED_BLOCK_COUNT - 1)) - 1) << 1) | 1) + +// i2c defines +#define I2C_CMD 0x00 +#define I2C_DATA 0x40 +#if defined(__AVR__) +# define I2C_TRANSMIT_P(data) i2c_transmit_P((OLED_DISPLAY_ADDRESS << 1), &data[0], sizeof(data), OLED_I2C_TIMEOUT) +#else // defined(__AVR__) +# define I2C_TRANSMIT_P(data) i2c_transmit((OLED_DISPLAY_ADDRESS << 1), &data[0], sizeof(data), OLED_I2C_TIMEOUT) +#endif // defined(__AVR__) +#define I2C_TRANSMIT(data) i2c_transmit((OLED_DISPLAY_ADDRESS << 1), &data[0], sizeof(data), OLED_I2C_TIMEOUT) +#define I2C_WRITE_REG(mode, data, size) i2c_writeReg((OLED_DISPLAY_ADDRESS << 1), mode, data, size, OLED_I2C_TIMEOUT) + +#define HAS_FLAGS(bits, flags) ((bits & flags) == flags) + +// Display buffer's is the same as the OLED memory layout +// this is so we don't end up with rounding errors with +// parts of the display unusable or don't get cleared correctly +// and also allows for drawing & inverting +uint8_t oled_buffer[OLED_MATRIX_SIZE]; +uint8_t * oled_cursor; +OLED_BLOCK_TYPE oled_dirty = 0; +bool oled_initialized = false; +bool oled_active = false; +bool oled_scrolling = false; +uint8_t oled_brightness = OLED_BRIGHTNESS; +uint8_t oled_rotation = 0; +uint8_t oled_rotation_width = 0; +uint8_t oled_scroll_speed = 0; // this holds the speed after being remapped to ssd1306 internal values +uint8_t oled_scroll_start = 0; +uint8_t oled_scroll_end = 7; +#if OLED_TIMEOUT > 0 +uint32_t oled_timeout; +#endif +#if OLED_SCROLL_TIMEOUT > 0 +uint32_t oled_scroll_timeout; +#endif +#if OLED_UPDATE_INTERVAL > 0 +uint16_t oled_update_timeout; +#endif + +// Internal variables to reduce math instructions + +#if defined(__AVR__) +// identical to i2c_transmit, but for PROGMEM since all initialization is in PROGMEM arrays currently +// probably should move this into i2c_master... +static i2c_status_t i2c_transmit_P(uint8_t address, const uint8_t *data, uint16_t length, uint16_t timeout) { + i2c_status_t status = i2c_start(address | I2C_WRITE, timeout); + + for (uint16_t i = 0; i < length && status >= 0; i++) { + status = i2c_write(pgm_read_byte((const char *)data++), timeout); + if (status) break; + } + + i2c_stop(); + + return status; +} +#endif + +// Flips the rendering bits for a character at the current cursor position +static void InvertCharacter(uint8_t *cursor) { + const uint8_t *end = cursor + OLED_FONT_WIDTH; + while (cursor < end) { + *cursor = ~(*cursor); + cursor++; + } +} + +bool oled_init(uint8_t rotation) { + oled_rotation = oled_init_user(rotation); + if (!HAS_FLAGS(oled_rotation, OLED_ROTATION_90)) { + oled_rotation_width = OLED_DISPLAY_WIDTH; + } else { + oled_rotation_width = OLED_DISPLAY_HEIGHT; + } + i2c_init(); + + static const uint8_t PROGMEM display_setup1[] = { + I2C_CMD, + DISPLAY_OFF, + DISPLAY_CLOCK, + 0x80, + MULTIPLEX_RATIO, + OLED_DISPLAY_HEIGHT - 1, + DISPLAY_OFFSET, + 0x00, + DISPLAY_START_LINE | 0x00, + CHARGE_PUMP, + 0x14, +#if (OLED_IC != OLED_IC_SH1106) + // MEMORY_MODE is unsupported on SH1106 (Page Addressing only) + MEMORY_MODE, + 0x00, // Horizontal addressing mode +#endif + }; + if (I2C_TRANSMIT_P(display_setup1) != I2C_STATUS_SUCCESS) { + print("oled_init cmd set 1 failed\n"); + return false; + } + + if (!HAS_FLAGS(oled_rotation, OLED_ROTATION_180)) { + static const uint8_t PROGMEM display_normal[] = {I2C_CMD, SEGMENT_REMAP_INV, COM_SCAN_DEC}; + if (I2C_TRANSMIT_P(display_normal) != I2C_STATUS_SUCCESS) { + print("oled_init cmd normal rotation failed\n"); + return false; + } + } else { + static const uint8_t PROGMEM display_flipped[] = {I2C_CMD, SEGMENT_REMAP, COM_SCAN_INC}; + if (I2C_TRANSMIT_P(display_flipped) != I2C_STATUS_SUCCESS) { + print("display_flipped failed\n"); + return false; + } + } + + static const uint8_t PROGMEM display_setup2[] = {I2C_CMD, COM_PINS, OLED_COM_PINS, CONTRAST, OLED_BRIGHTNESS, PRE_CHARGE_PERIOD, 0xF1, VCOM_DETECT, 0x20, DISPLAY_ALL_ON_RESUME, NORMAL_DISPLAY, DEACTIVATE_SCROLL, DISPLAY_ON}; + if (I2C_TRANSMIT_P(display_setup2) != I2C_STATUS_SUCCESS) { + print("display_setup2 failed\n"); + return false; + } + +#if OLED_TIMEOUT > 0 + oled_timeout = timer_read32() + OLED_TIMEOUT; +#endif +#if OLED_SCROLL_TIMEOUT > 0 + oled_scroll_timeout = timer_read32() + OLED_SCROLL_TIMEOUT; +#endif + + oled_clear(); + oled_initialized = true; + oled_active = true; + oled_scrolling = false; + return true; +} + +__attribute__((weak)) oled_rotation_t oled_init_user(oled_rotation_t rotation) { return rotation; } + +void oled_clear(void) { + memset(oled_buffer, 0, sizeof(oled_buffer)); + oled_cursor = &oled_buffer[0]; + oled_dirty = OLED_ALL_BLOCKS_MASK; +} + +static void calc_bounds(uint8_t update_start, uint8_t *cmd_array) { + // Calculate commands to set memory addressing bounds. + uint8_t start_page = OLED_BLOCK_SIZE * update_start / OLED_DISPLAY_WIDTH; + uint8_t start_column = OLED_BLOCK_SIZE * update_start % OLED_DISPLAY_WIDTH; +#if (OLED_IC == OLED_IC_SH1106) + // Commands for Page Addressing Mode. Sets starting page and column; has no end bound. + // Column value must be split into high and low nybble and sent as two commands. + cmd_array[0] = PAM_PAGE_ADDR | start_page; + cmd_array[1] = PAM_SETCOLUMN_LSB | ((OLED_COLUMN_OFFSET + start_column) & 0x0f); + cmd_array[2] = PAM_SETCOLUMN_MSB | ((OLED_COLUMN_OFFSET + start_column) >> 4 & 0x0f); + cmd_array[3] = NOP; + cmd_array[4] = NOP; + cmd_array[5] = NOP; +#else + // Commands for use in Horizontal Addressing mode. + cmd_array[1] = start_column; + cmd_array[4] = start_page; + cmd_array[2] = (OLED_BLOCK_SIZE + OLED_DISPLAY_WIDTH - 1) % OLED_DISPLAY_WIDTH + cmd_array[1]; + cmd_array[5] = (OLED_BLOCK_SIZE + OLED_DISPLAY_WIDTH - 1) / OLED_DISPLAY_WIDTH - 1; +#endif +} + +static void calc_bounds_90(uint8_t update_start, uint8_t *cmd_array) { + cmd_array[1] = OLED_BLOCK_SIZE * update_start / OLED_DISPLAY_HEIGHT * 8; + cmd_array[4] = OLED_BLOCK_SIZE * update_start % OLED_DISPLAY_HEIGHT; + cmd_array[2] = (OLED_BLOCK_SIZE + OLED_DISPLAY_HEIGHT - 1) / OLED_DISPLAY_HEIGHT * 8 - 1 + cmd_array[1]; + ; + cmd_array[5] = (OLED_BLOCK_SIZE + OLED_DISPLAY_HEIGHT - 1) % OLED_DISPLAY_HEIGHT / 8; +} + +uint8_t crot(uint8_t a, int8_t n) { + const uint8_t mask = 0x7; + n &= mask; + return a << n | a >> (-n & mask); +} + +static void rotate_90(const uint8_t *src, uint8_t *dest) { + for (uint8_t i = 0, shift = 7; i < 8; ++i, --shift) { + uint8_t selector = (1 << i); + for (uint8_t j = 0; j < 8; ++j) { + dest[i] |= crot(src[j] & selector, shift - (int8_t)j); + } + } +} + +void oled_render(void) { + if (!oled_initialized) { + return; + } + + // Do we have work to do? + oled_dirty &= OLED_ALL_BLOCKS_MASK; + if (!oled_dirty || oled_scrolling) { + return; + } + + // Find first dirty block + uint8_t update_start = 0; + while (!(oled_dirty & ((OLED_BLOCK_TYPE)1 << update_start))) { + ++update_start; + } + + // Set column & page position + static uint8_t display_start[] = {I2C_CMD, COLUMN_ADDR, 0, OLED_DISPLAY_WIDTH - 1, PAGE_ADDR, 0, OLED_DISPLAY_HEIGHT / 8 - 1}; + if (!HAS_FLAGS(oled_rotation, OLED_ROTATION_90)) { + calc_bounds(update_start, &display_start[1]); // Offset from I2C_CMD byte at the start + } else { + calc_bounds_90(update_start, &display_start[1]); // Offset from I2C_CMD byte at the start + } + + // Send column & page position + if (I2C_TRANSMIT(display_start) != I2C_STATUS_SUCCESS) { + print("oled_render offset command failed\n"); + return; + } + + if (!HAS_FLAGS(oled_rotation, OLED_ROTATION_90)) { + // Send render data chunk as is + if (I2C_WRITE_REG(I2C_DATA, &oled_buffer[OLED_BLOCK_SIZE * update_start], OLED_BLOCK_SIZE) != I2C_STATUS_SUCCESS) { + print("oled_render data failed\n"); + return; + } + } else { + // Rotate the render chunks + const static uint8_t source_map[] = OLED_SOURCE_MAP; + const static uint8_t target_map[] = OLED_TARGET_MAP; + + static uint8_t temp_buffer[OLED_BLOCK_SIZE]; + memset(temp_buffer, 0, sizeof(temp_buffer)); + for (uint8_t i = 0; i < sizeof(source_map); ++i) { + rotate_90(&oled_buffer[OLED_BLOCK_SIZE * update_start + source_map[i]], &temp_buffer[target_map[i]]); + } + + // Send render data chunk after rotating + if (I2C_WRITE_REG(I2C_DATA, &temp_buffer[0], OLED_BLOCK_SIZE) != I2C_STATUS_SUCCESS) { + print("oled_render90 data failed\n"); + return; + } + } + + // Turn on display if it is off + oled_on(); + + // Clear dirty flag + oled_dirty &= ~((OLED_BLOCK_TYPE)1 << update_start); +} + +void oled_set_cursor(uint8_t col, uint8_t line) { + uint16_t index = line * oled_rotation_width + col * OLED_FONT_WIDTH; + + // Out of bounds? + if (index >= OLED_MATRIX_SIZE) { + index = 0; + } + + oled_cursor = &oled_buffer[index]; +} +void oled_set_precise_cursor(uint16_t index) { + // Out of bounds? + if (index >= OLED_MATRIX_SIZE) { + index = 0; + } + oled_cursor = &oled_buffer[index]; +} +void oled_advance_page(bool clearPageRemainder) { + uint16_t index = oled_cursor - &oled_buffer[0]; + uint8_t remaining = (oled_rotation_width - (index % oled_rotation_width))%oled_rotation_width; + + if (clearPageRemainder) { + // Remaining Char count + remaining = remaining / OLED_FONT_WIDTH; + + // Write empty character until next line + while (remaining--) oled_write_char(' ', false); + } else { + // Next page index out of bounds? + if (index + remaining >= OLED_MATRIX_SIZE) { + index = 0; + remaining = 0; + } + + oled_cursor = &oled_buffer[index + remaining]; + } +} + +void oled_advance_char(void) { + uint16_t nextIndex = oled_cursor - &oled_buffer[0] + OLED_FONT_WIDTH; + uint8_t remainingSpace = oled_rotation_width - (nextIndex % oled_rotation_width); + + // Do we have enough space on the current line for the next character + if (remainingSpace < OLED_FONT_WIDTH) { + nextIndex += remainingSpace; + } + + // Did we go out of bounds + if (nextIndex >= OLED_MATRIX_SIZE) { + nextIndex = 0; + } + + // Update cursor position + oled_cursor = &oled_buffer[nextIndex]; +} + +// Main handler that writes character data to the display buffer +void oled_write_char(const char data, bool invert) { + // Advance to the next line if newline + if (data == '\n') { + // Old source wrote ' ' until end of line... + oled_advance_page(true); + return; + } + + if (data == '\r') { + oled_advance_page(false); + return; + } + + // copy the current render buffer to check for dirty after + static uint8_t oled_temp_buffer[OLED_FONT_WIDTH]; + memcpy(&oled_temp_buffer, oled_cursor, OLED_FONT_WIDTH); + + _Static_assert(sizeof(font) >= ((OLED_FONT_END + 1 - OLED_FONT_START) * OLED_FONT_WIDTH), "OLED_FONT_END references outside array"); + + // set the reder buffer data + uint8_t cast_data = (uint8_t)data; // font based on unsigned type for index + if (cast_data < OLED_FONT_START || cast_data > OLED_FONT_END) { + memset(oled_cursor, 0x00, OLED_FONT_WIDTH); + } else { + const uint8_t *glyph = &font[(cast_data - OLED_FONT_START) * OLED_FONT_WIDTH]; + memcpy_P(oled_cursor, glyph, OLED_FONT_WIDTH); + } + + // Invert if needed + if (invert) { + InvertCharacter(oled_cursor); + } + + // Dirty check + if (memcmp(&oled_temp_buffer, oled_cursor, OLED_FONT_WIDTH)) { + uint16_t index = oled_cursor - &oled_buffer[0]; + oled_dirty |= ((OLED_BLOCK_TYPE)1 << (index / OLED_BLOCK_SIZE)); + // Edgecase check if the written data spans the 2 chunks + oled_dirty |= ((OLED_BLOCK_TYPE)1 << ((index + OLED_FONT_WIDTH - 1) / OLED_BLOCK_SIZE)); + } + + // Finally move to the next char + oled_advance_char(); +} + +void oled_write(const char *data, bool invert) { + const char *end = data + strlen(data); + while (data < end) { + oled_write_char(*data, invert); + data++; + } +} + +void oled_write_ln(const char *data, bool invert) { + oled_write(data, invert); + oled_advance_page(true); +} + +void oled_pan(bool left) { + uint16_t i = 0; + for (uint16_t y = 0; y < OLED_DISPLAY_HEIGHT / 8; y++) { + if (left) { + for (uint16_t x = 0; x < OLED_DISPLAY_WIDTH - 1; x++) { + i = y * OLED_DISPLAY_WIDTH + x; + oled_buffer[i] = oled_buffer[i + 1]; + } + } else { + for (uint16_t x = OLED_DISPLAY_WIDTH - 1; x > 0; x--) { + i = y * OLED_DISPLAY_WIDTH + x; + oled_buffer[i] = oled_buffer[i - 1]; + } + } + } + oled_dirty = OLED_ALL_BLOCKS_MASK; +} + +void oled_precise_pan(bool left, uint16_t index) { + if (index>OLED_MATRIX_SIZE-1) { + return; + } + if (left) { + for (uint16_t x = 0; x < index; x++) { + oled_buffer[x] = oled_buffer[x + 1]; + } + } else { + for (uint16_t x = OLED_MATRIX_SIZE - 1; x > index; x--) { + oled_buffer[x] = oled_buffer[x - 1]; + } + } + oled_dirty = OLED_ALL_BLOCKS_MASK; +} +void oled_precise_pan_h(bool left, uint16_t start_line) { + uint16_t i = 0; + uint16_t oled_rotation_height = 8 * OLED_MATRIX_SIZE / oled_rotation_width; + for (uint16_t y = start_line; y < oled_rotation_height / 8; y++) { + if (left) { + for (uint16_t x = 0; x < oled_rotation_width - 1; x++) { + i = y * oled_rotation_width + x; + oled_buffer[i] = oled_buffer[i + 1]; + } + } else { + for (uint16_t x = oled_rotation_width - 1; x > 0; x--) { + i = y * oled_rotation_width + x; + oled_buffer[i] = oled_buffer[i - 1]; + } + } + } + oled_dirty = OLED_ALL_BLOCKS_MASK; +} + + +oled_buffer_reader_t oled_read_raw(uint16_t start_index) { + if (start_index > OLED_MATRIX_SIZE) start_index = OLED_MATRIX_SIZE; + oled_buffer_reader_t ret_reader; + ret_reader.current_element = &oled_buffer[start_index]; + ret_reader.remaining_element_count = OLED_MATRIX_SIZE - start_index; + return ret_reader; +} + +void oled_write_raw_byte(const char data, uint16_t index) { + if (index > OLED_MATRIX_SIZE) index = OLED_MATRIX_SIZE; + if (oled_buffer[index] == data) return; + oled_buffer[index] = data; + oled_dirty |= ((OLED_BLOCK_TYPE)1 << (index / OLED_BLOCK_SIZE)); +} + +void oled_write_raw(const char *data, uint16_t size) { + uint16_t cursor_start_index = oled_cursor - &oled_buffer[0]; + if ((size + cursor_start_index) > OLED_MATRIX_SIZE) size = OLED_MATRIX_SIZE - cursor_start_index; + + for (uint16_t j = 0, i = cursor_start_index; i < cursor_start_index + size; i++, j++) { + if (oled_buffer[i] == data[j]) continue; + oled_buffer[i] = data[j]; + oled_dirty |= ((OLED_BLOCK_TYPE)1 << (i / OLED_BLOCK_SIZE)); + } +} + +void oled_write_pixel(uint8_t x, uint8_t y, bool on) { + if (x >= oled_rotation_width) { + return; + } + uint16_t index = x + (y / 8) * oled_rotation_width; + if (index >= OLED_MATRIX_SIZE) { + return; + } + uint8_t data = oled_buffer[index]; + if (on) { + data |= (1 << (y % 8)); + } else { + data &= ~(1 << (y % 8)); + } + if (oled_buffer[index] != data) { + oled_buffer[index] = data; + oled_dirty |= ((OLED_BLOCK_TYPE)1 << (index / OLED_BLOCK_SIZE)); + } +} + +#if defined(__AVR__) +void oled_write_P(const char *data, bool invert) { + uint8_t c = pgm_read_byte(data); + while (c != 0) { + oled_write_char(c, invert); + c = pgm_read_byte(++data); + } +} + +void oled_write_ln_P(const char *data, bool invert) { + oled_write_P(data, invert); + oled_advance_page(true); +} + +void oled_write_raw_P(const char *data, uint16_t size) { + uint16_t cursor_start_index = oled_cursor - &oled_buffer[0]; + if ((size + cursor_start_index) > OLED_MATRIX_SIZE) size = OLED_MATRIX_SIZE - cursor_start_index; + for (uint16_t i = cursor_start_index; i < cursor_start_index + size; i++) { + uint8_t c = pgm_read_byte(data++); + if (oled_buffer[i] == c) continue; + oled_buffer[i] = c; + oled_dirty |= ((OLED_BLOCK_TYPE)1 << (i / OLED_BLOCK_SIZE)); + } +} +#endif // defined(__AVR__) + +bool oled_on(void) { + if (!oled_initialized) { + return oled_active; + } + +#if OLED_TIMEOUT > 0 + oled_timeout = timer_read32() + OLED_TIMEOUT; +#endif + + static const uint8_t PROGMEM display_on[] = {I2C_CMD, DISPLAY_ON}; + if (!oled_active) { + if (I2C_TRANSMIT_P(display_on) != I2C_STATUS_SUCCESS) { + print("oled_on cmd failed\n"); + return oled_active; + } + oled_active = true; + } + return oled_active; +} + +bool oled_off(void) { + if (!oled_initialized) { + return !oled_active; + } + + static const uint8_t PROGMEM display_off[] = {I2C_CMD, DISPLAY_OFF}; + if (oled_active) { + if (I2C_TRANSMIT_P(display_off) != I2C_STATUS_SUCCESS) { + print("oled_off cmd failed\n"); + return oled_active; + } + oled_active = false; + } + return !oled_active; +} + +bool is_oled_on(void) { return oled_active; } + +uint8_t oled_set_brightness(uint8_t level) { + if (!oled_initialized) { + return oled_brightness; + } + + uint8_t set_contrast[] = {I2C_CMD, CONTRAST, level}; + if (oled_brightness != level) { + if (I2C_TRANSMIT(set_contrast) != I2C_STATUS_SUCCESS) { + print("set_brightness cmd failed\n"); + return oled_brightness; + } + oled_brightness = level; + } + return oled_brightness; +} + +uint8_t oled_get_brightness(void) { return oled_brightness; } + +// Set the specific 8 lines rows of the screen to scroll. +// 0 is the default for start, and 7 for end, which is the entire +// height of the screen. For 128x32 screens, rows 4-7 are not used. +void oled_scroll_set_area(uint8_t start_line, uint8_t end_line) { + oled_scroll_start = start_line; + oled_scroll_end = end_line; +} + +void oled_scroll_set_speed(uint8_t speed) { + // Sets the speed for scrolling... does not take effect + // until scrolling is either started or restarted + // the ssd1306 supports 8 speeds + // FrameRate2 speed = 7 + // FrameRate3 speed = 4 + // FrameRate4 speed = 5 + // FrameRate5 speed = 0 + // FrameRate25 speed = 6 + // FrameRate64 speed = 1 + // FrameRate128 speed = 2 + // FrameRate256 speed = 3 + // for ease of use these are remaped here to be in order + static const uint8_t scroll_remap[8] = {7, 4, 5, 0, 6, 1, 2, 3}; + oled_scroll_speed = scroll_remap[speed]; +} + +bool oled_scroll_right(void) { + if (!oled_initialized) { + return oled_scrolling; + } + + // Dont enable scrolling if we need to update the display + // This prevents scrolling of bad data from starting the scroll too early after init + if (!oled_dirty && !oled_scrolling) { + uint8_t display_scroll_right[] = {I2C_CMD, SCROLL_RIGHT, 0x00, oled_scroll_start, oled_scroll_speed, oled_scroll_end, 0x00, 0xFF, ACTIVATE_SCROLL}; + if (I2C_TRANSMIT(display_scroll_right) != I2C_STATUS_SUCCESS) { + print("oled_scroll_right cmd failed\n"); + return oled_scrolling; + } + oled_scrolling = true; + } + return oled_scrolling; +} + +bool oled_scroll_left(void) { + if (!oled_initialized) { + return oled_scrolling; + } + + // Dont enable scrolling if we need to update the display + // This prevents scrolling of bad data from starting the scroll too early after init + if (!oled_dirty && !oled_scrolling) { + uint8_t display_scroll_left[] = {I2C_CMD, SCROLL_LEFT, 0x00, oled_scroll_start, oled_scroll_speed, oled_scroll_end, 0x00, 0xFF, ACTIVATE_SCROLL}; + if (I2C_TRANSMIT(display_scroll_left) != I2C_STATUS_SUCCESS) { + print("oled_scroll_left cmd failed\n"); + return oled_scrolling; + } + oled_scrolling = true; + } + return oled_scrolling; +} + +bool oled_scroll_off(void) { + if (!oled_initialized) { + return !oled_scrolling; + } + + if (oled_scrolling) { + static const uint8_t PROGMEM display_scroll_off[] = {I2C_CMD, DEACTIVATE_SCROLL}; + if (I2C_TRANSMIT_P(display_scroll_off) != I2C_STATUS_SUCCESS) { + print("oled_scroll_off cmd failed\n"); + return oled_scrolling; + } + oled_scrolling = false; + oled_dirty = OLED_ALL_BLOCKS_MASK; + } + return !oled_scrolling; +} + +uint8_t oled_max_chars(void) { + if (!HAS_FLAGS(oled_rotation, OLED_ROTATION_90)) { + return OLED_DISPLAY_WIDTH / OLED_FONT_WIDTH; + } + return OLED_DISPLAY_HEIGHT / OLED_FONT_WIDTH; +} + +uint8_t oled_max_lines(void) { + if (!HAS_FLAGS(oled_rotation, OLED_ROTATION_90)) { + return OLED_DISPLAY_HEIGHT / OLED_FONT_HEIGHT; + } + return OLED_DISPLAY_WIDTH / OLED_FONT_HEIGHT; +} + +void oled_task(void) { + if (!oled_initialized) { + return; + } + +#if OLED_UPDATE_INTERVAL > 0 + if (timer_elapsed(oled_update_timeout) >= OLED_UPDATE_INTERVAL) { + oled_update_timeout = timer_read(); + oled_set_cursor(0, 0); + oled_task_user(); + } +#else + oled_set_cursor(0, 0); + oled_task_user(); +#endif + +#if OLED_SCROLL_TIMEOUT > 0 + if (oled_dirty && oled_scrolling) { + oled_scroll_timeout = timer_read32() + OLED_SCROLL_TIMEOUT; + oled_scroll_off(); + } +#endif + + // Smart render system, no need to check for dirty + oled_render(); + + // Display timeout check +#if OLED_TIMEOUT > 0 + if (oled_active && timer_expired32(timer_read32(), oled_timeout)) { + oled_off(); + } +#endif + +#if OLED_SCROLL_TIMEOUT > 0 + if (!oled_scrolling && timer_expired32(timer_read32(), oled_scroll_timeout)) { +# ifdef OLED_SCROLL_TIMEOUT_RIGHT + oled_scroll_right(); +# else + oled_scroll_left(); +# endif + } +#endif +} + +__attribute__((weak)) void oled_task_user(void) {} diff --git a/keyboards/yandrstudio/rainbow65/keymaps/test_oled/dev_oled/oled_driver.h b/keyboards/yandrstudio/rainbow65/keymaps/test_oled/dev_oled/oled_driver.h new file mode 100755 index 000000000000..ba721e88d7d4 --- /dev/null +++ b/keyboards/yandrstudio/rainbow65/keymaps/test_oled/dev_oled/oled_driver.h @@ -0,0 +1,313 @@ +/* +Copyright 2019 Ryan Caltabiano + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ +#pragma once + +#include +#include + +// an enumeration of the chips this driver supports +#define OLED_IC_SSD1306 0 +#define OLED_IC_SH1106 1 + +#if defined(OLED_DISPLAY_CUSTOM) +// Expected user to implement the necessary defines +#elif defined(OLED_DISPLAY_128X64) +// Double height 128x64 +# ifndef OLED_DISPLAY_WIDTH +# define OLED_DISPLAY_WIDTH 128 +# endif +# ifndef OLED_DISPLAY_HEIGHT +# define OLED_DISPLAY_HEIGHT 64 +# endif +# ifndef OLED_MATRIX_SIZE +# define OLED_MATRIX_SIZE (OLED_DISPLAY_HEIGHT / 8 * OLED_DISPLAY_WIDTH) // 1024 (compile time mathed) +# endif +# ifndef OLED_BLOCK_TYPE +# define OLED_BLOCK_TYPE uint16_t +# endif +# ifndef OLED_BLOCK_COUNT +# define OLED_BLOCK_COUNT (sizeof(OLED_BLOCK_TYPE) * 8) // 32 (compile time mathed) +# endif +# ifndef OLED_BLOCK_SIZE +# define OLED_BLOCK_SIZE (OLED_MATRIX_SIZE / OLED_BLOCK_COUNT) // 32 (compile time mathed) +# endif +# ifndef OLED_COM_PINS +# define OLED_COM_PINS COM_PINS_ALT +# endif + +// For 90 degree rotation, we map our internal matrix to oled matrix using fixed arrays +// The OLED writes to it's memory horizontally, starting top left, but our memory starts bottom left in this mode +# ifndef OLED_SOURCE_MAP +# define OLED_SOURCE_MAP \ + { 0, 8, 16, 24, 32, 40, 48, 56 } +# endif +# ifndef OLED_TARGET_MAP +# define OLED_TARGET_MAP \ + { 56, 48, 40, 32, 24, 16, 8, 0 } +# endif +// If OLED_BLOCK_TYPE is uint32_t, these tables would look like: +// #define OLED_SOURCE_MAP { 32, 40, 48, 56 } +// #define OLED_TARGET_MAP { 24, 16, 8, 0 } +// If OLED_BLOCK_TYPE is uint16_t, these tables would look like: +// #define OLED_SOURCE_MAP { 0, 8, 16, 24, 32, 40, 48, 56 } +// #define OLED_TARGET_MAP { 56, 48, 40, 32, 24, 16, 8, 0 } +// If OLED_BLOCK_TYPE is uint8_t, these tables would look like: +// #define OLED_SOURCE_MAP { 0, 8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104, 112, 120 } +// #define OLED_TARGET_MAP { 56, 120, 48, 112, 40, 104, 32, 96, 24, 88, 16, 80, 8, 72, 0, 64 } +#else // defined(OLED_DISPLAY_128X64) +// Default 128x32 +# ifndef OLED_DISPLAY_WIDTH +# define OLED_DISPLAY_WIDTH 128 +# endif +# ifndef OLED_DISPLAY_HEIGHT +# define OLED_DISPLAY_HEIGHT 32 +# endif +# ifndef OLED_MATRIX_SIZE +# define OLED_MATRIX_SIZE (OLED_DISPLAY_HEIGHT / 8 * OLED_DISPLAY_WIDTH) // 512 (compile time mathed) +# endif +# ifndef OLED_BLOCK_TYPE +# define OLED_BLOCK_TYPE uint16_t // Type to use for segmenting the oled display for smart rendering, use unsigned types only +# endif +# ifndef OLED_BLOCK_COUNT +# define OLED_BLOCK_COUNT (sizeof(OLED_BLOCK_TYPE) * 8) // 16 (compile time mathed) +# endif +# ifndef OLED_BLOCK_SIZE +# define OLED_BLOCK_SIZE (OLED_MATRIX_SIZE / OLED_BLOCK_COUNT) // 32 (compile time mathed) +# endif +# ifndef OLED_COM_PINS +# define OLED_COM_PINS COM_PINS_SEQ +# endif + +// For 90 degree rotation, we map our internal matrix to oled matrix using fixed arrays +// The OLED writes to it's memory horizontally, starting top left, but our memory starts bottom left in this mode +# ifndef OLED_SOURCE_MAP +# define OLED_SOURCE_MAP \ + { 0, 8, 16, 24 } +# endif +# ifndef OLED_TARGET_MAP +# define OLED_TARGET_MAP \ + { 24, 16, 8, 0 } +# endif +// If OLED_BLOCK_TYPE is uint8_t, these tables would look like: +// #define OLED_SOURCE_MAP { 0, 8, 16, 24, 32, 40, 48, 56 } +// #define OLED_TARGET_MAP { 48, 32, 16, 0, 56, 40, 24, 8 } +#endif // defined(OLED_DISPLAY_CUSTOM) + +#if !defined(OLED_IC) +# define OLED_IC OLED_IC_SSD1306 +#endif + +// the column address corresponding to the first column in the display hardware +#if !defined(OLED_COLUMN_OFFSET) +# define OLED_COLUMN_OFFSET 0 +#endif + +// Address to use for the i2c oled communication +#if !defined(OLED_DISPLAY_ADDRESS) +# define OLED_DISPLAY_ADDRESS 0x3C +#endif + +// Custom font file to use +#if !defined(OLED_FONT_H) +# define OLED_FONT_H "glcdfont.c" +#endif +// unsigned char value of the first character in the font file +#if !defined(OLED_FONT_START) +# define OLED_FONT_START 0 +#endif +// unsigned char value of the last character in the font file +#if !defined(OLED_FONT_END) +# define OLED_FONT_END 223 +#endif +// Font render width +#if !defined(OLED_FONT_WIDTH) +# define OLED_FONT_WIDTH 6 +#endif +// Font render height +#if !defined(OLED_FONT_HEIGHT) +# define OLED_FONT_HEIGHT 8 +#endif +// Default brightness level +#if !defined(OLED_BRIGHTNESS) +# define OLED_BRIGHTNESS 255 +#endif + +#if !defined(OLED_TIMEOUT) +# if defined(OLED_DISABLE_TIMEOUT) +# define OLED_TIMEOUT 0 +# else +# define OLED_TIMEOUT 60000 +# endif +#endif + +#if !defined(OLED_I2C_TIMEOUT) +# define OLED_I2C_TIMEOUT 100 +#endif + +typedef struct __attribute__((__packed__)) { + uint8_t *current_element; + uint16_t remaining_element_count; +} oled_buffer_reader_t; + +// OLED Rotation enum values are flags +typedef enum { + OLED_ROTATION_0 = 0, + OLED_ROTATION_90 = 1, + OLED_ROTATION_180 = 2, + OLED_ROTATION_270 = 3, // OLED_ROTATION_90 | OLED_ROTATION_180 +} oled_rotation_t; + +// Initialize the oled display, rotating the rendered output based on the define passed in. +// Returns true if the OLED was initialized successfully +bool oled_init(oled_rotation_t rotation); + +// Called at the start of oled_init, weak function overridable by the user +// rotation - the value passed into oled_init +// Return new oled_rotation_t if you want to override default rotation +oled_rotation_t oled_init_user(oled_rotation_t rotation); + +// Clears the display buffer, resets cursor position to 0, and sets the buffer to dirty for rendering +void oled_clear(void); + +// Renders the dirty chunks of the buffer to oled display +void oled_render(void); + +// Moves cursor to character position indicated by column and line, wraps if out of bounds +// Max column denoted by 'oled_max_chars()' and max lines by 'oled_max_lines()' functions +void oled_set_cursor(uint8_t col, uint8_t line); +void oled_set_precise_cursor(uint16_t index); + +// Advances the cursor to the next page, writing ' ' if true +// Wraps to the begining when out of bounds +void oled_advance_page(bool clearPageRemainder); + +// Moves the cursor forward 1 character length +// Advance page if there is not enough room for the next character +// Wraps to the begining when out of bounds +void oled_advance_char(void); + +// Writes a single character to the buffer at current cursor position +// Advances the cursor while writing, inverts the pixels if true +// Main handler that writes character data to the display buffer +void oled_write_char(const char data, bool invert); + +// Writes a string to the buffer at current cursor position +// Advances the cursor while writing, inverts the pixels if true +void oled_write(const char *data, bool invert); + +// Writes a string to the buffer at current cursor position +// Advances the cursor while writing, inverts the pixels if true +// Advances the cursor to the next page, wiring ' ' to the remainder of the current page +void oled_write_ln(const char *data, bool invert); + +// Pans the buffer to the right (or left by passing true) by moving contents of the buffer +void oled_pan(bool left); +void oled_precise_pan(bool left, uint16_t start_index); +void oled_precise_pan_h(bool left, uint16_t start_line); + +// Returns a pointer to the requested start index in the buffer plus remaining +// buffer length as struct +oled_buffer_reader_t oled_read_raw(uint16_t start_index); + +void oled_write_raw(const char *data, uint16_t size); +void oled_write_raw_byte(const char data, uint16_t index); + +// Sets a specific pixel on or off +// Coordinates start at top-left and go right and down for positive x and y +void oled_write_pixel(uint8_t x, uint8_t y, bool on); + +#if defined(__AVR__) +// Writes a PROGMEM string to the buffer at current cursor position +// Advances the cursor while writing, inverts the pixels if true +// Remapped to call 'void oled_write(const char *data, bool invert);' on ARM +void oled_write_P(const char *data, bool invert); + +// Writes a PROGMEM string to the buffer at current cursor position +// Advances the cursor while writing, inverts the pixels if true +// Advances the cursor to the next page, wiring ' ' to the remainder of the current page +// Remapped to call 'void oled_write_ln(const char *data, bool invert);' on ARM +void oled_write_ln_P(const char *data, bool invert); + +void oled_write_raw_P(const char *data, uint16_t size); +#else +// Writes a string to the buffer at current cursor position +// Advances the cursor while writing, inverts the pixels if true +# define oled_write_P(data, invert) oled_write(data, invert) + +// Writes a string to the buffer at current cursor position +// Advances the cursor while writing, inverts the pixels if true +// Advances the cursor to the next page, wiring ' ' to the remainder of the current page +# define oled_write_ln_P(data, invert) oled_write_ln(data, invert) + +# define oled_write_raw_P(data, size) oled_write_raw(data, size) +#endif // defined(__AVR__) + +// Can be used to manually turn on the screen if it is off +// Returns true if the screen was on or turns on +bool oled_on(void); + +// Can be used to manually turn off the screen if it is on +// Returns true if the screen was off or turns off +bool oled_off(void); + +// Returns true if the oled is currently on, false if it is +// not +bool is_oled_on(void); + +// Sets the brightness of the display +uint8_t oled_set_brightness(uint8_t level); + +// Gets the current brightness of the display +uint8_t oled_get_brightness(void); + +// Basically it's oled_render, but with timeout management and oled_task_user calling! +void oled_task(void); + +// Called at the start of oled_task, weak function overridable by the user +void oled_task_user(void); + +// Set the specific 8 lines rows of the screen to scroll. +// 0 is the default for start, and 7 for end, which is the entire +// height of the screen. For 128x32 screens, rows 4-7 are not used. +void oled_scroll_set_area(uint8_t start_line, uint8_t end_line); + +// Sets scroll speed, 0-7, fastest to slowest. Default is three. +// Does not take effect until scrolling is either started or restarted +// the ssd1306 supports 8 speeds with the delay +// listed below betwen each frame of the scrolling effect +// 0=2, 1=3, 2=4, 3=5, 4=25, 5=64, 6=128, 7=256 +void oled_scroll_set_speed(uint8_t speed); + +// Scrolls the entire display right +// Returns true if the screen was scrolling or starts scrolling +// NOTE: display contents cannot be changed while scrolling +bool oled_scroll_right(void); + +// Scrolls the entire display left +// Returns true if the screen was scrolling or starts scrolling +// NOTE: display contents cannot be changed while scrolling +bool oled_scroll_left(void); + +// Turns off display scrolling +// Returns true if the screen was not scrolling or stops scrolling +bool oled_scroll_off(void); + +// Returns the maximum number of characters that will fit on a line +uint8_t oled_max_chars(void); + +// Returns the maximum number of lines that will fit on the oled +uint8_t oled_max_lines(void); diff --git a/keyboards/yandrstudio/rainbow65/keymaps/test_oled/graph_lib/kb_press_graph.c b/keyboards/yandrstudio/rainbow65/keymaps/test_oled/graph_lib/kb_press_graph.c new file mode 100755 index 000000000000..65057611df97 --- /dev/null +++ b/keyboards/yandrstudio/rainbow65/keymaps/test_oled/graph_lib/kb_press_graph.c @@ -0,0 +1,37 @@ +#include "kb_press_graph.h" + + +const uint8_t kb_graph_start_line = 8; +// 0 1 2 3 4 +const uint8_t kb_press_row_map[5] = {65, 68, 71, 74, 77}; +// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 +const uint8_t kb_press_col_map[15] = {3, 6, 6, 9, 9, 12, 12, 15, 18, 18, 21, 21, 24, 27, 27}; + +void render_r65_kb(uint8_t col, uint8_t row, uint16_t keycode, bool on, uint16_t key_press_count) { + if (key_press_count == 0) { + oled_set_cursor(0, kb_graph_start_line); + oled_write_raw(my_font_lib_etc_r65kb, 32); + oled_set_cursor(0, kb_graph_start_line+1); + oled_write_raw(my_font_lib_etc_r65kb+32, 32); + oled_set_cursor(0,0); + return; + } + if (col == 255 && row == 255) return; + // skip the encoder map key + if (col == 3 && row == 4) return; + if (col == 4 && row == 4) return; + // space keypress + if (col == 5 && row == 4) { + for (uint8_t i = kb_press_col_map[5-2];i<=kb_press_col_map[5+2]+1; ++i) { + oled_write_pixel(i, kb_press_row_map[4], on); + oled_write_pixel(i, kb_press_row_map[4]+1, on); + } + return; + } + uint8_t y_oled = kb_press_row_map[row]; + uint8_t x_oled = kb_press_col_map[col]; + oled_write_pixel(x_oled, y_oled, on); + oled_write_pixel(x_oled, y_oled+1, on); + oled_write_pixel(x_oled+1, y_oled, on); + oled_write_pixel(x_oled+1, y_oled+1, on); +} diff --git a/keyboards/yandrstudio/rainbow65/keymaps/test_oled/graph_lib/kb_press_graph.h b/keyboards/yandrstudio/rainbow65/keymaps/test_oled/graph_lib/kb_press_graph.h new file mode 100755 index 000000000000..f90083093680 --- /dev/null +++ b/keyboards/yandrstudio/rainbow65/keymaps/test_oled/graph_lib/kb_press_graph.h @@ -0,0 +1,18 @@ +#pragma once +#include "progmem.h" +#include "../dev_oled/oled_driver.h" +#include "time.h" + +void render_r65_kb(uint8_t col, uint8_t row, uint16_t keycode, bool on, uint16_t key_press_count); + +static const char my_font_lib_etc_r65kb[] PROGMEM = { + 0x07, 0xFF, 0xFF, 0x49, 0x49, 0xFF, 0x49, 0x49, + 0xFF, 0x49, 0x49, 0xFF, 0x49, 0x49, 0xFF, 0x49, + 0x49, 0xFF, 0x49, 0x49, 0xFF, 0x49, 0x49, 0xFF, + 0x49, 0x49, 0xFF, 0x49, 0x49, 0xFF, 0xFF, 0x07, + + 0xE0, 0xFF, 0xFF, 0x92, 0x92, 0xFF, 0x92, 0x92, + 0xFF, 0x92, 0x92, 0x9F, 0x92, 0x92, 0x9F, 0x92, + 0x92, 0xFF, 0x92, 0x92, 0xFF, 0x92, 0x92, 0xFF, + 0x92, 0x92, 0xFF, 0x92, 0x92, 0xFF, 0xFF, 0xE0, +}; diff --git a/keyboards/yandrstudio/rainbow65/keymaps/test_oled/graph_lib/my_pic_lib.h b/keyboards/yandrstudio/rainbow65/keymaps/test_oled/graph_lib/my_pic_lib.h new file mode 100755 index 000000000000..fe8ac056614d --- /dev/null +++ b/keyboards/yandrstudio/rainbow65/keymaps/test_oled/graph_lib/my_pic_lib.h @@ -0,0 +1,136 @@ +#pragma once +#include "progmem.h" + +static const char my_font_lib_layer[] PROGMEM = { + 0x02, 0xF2, 0x02, 0x02, 0x02, 0x02, 0x22, 0x22, + 0xE2, 0x02, 0x22, 0x42, 0x82, 0x42, 0x22, 0x02, + 0xE2, 0xA2, 0xE2, 0x02, 0xE2, 0x42, 0x22, 0x02, + 0xF2, 0x3A, 0x1A, 0xCA, 0xCA, 0x1A, 0x3A, 0xF2, + 0xF2, 0xFA, 0x9A, 0x0A, 0x0A, 0xFA, 0xFA, 0xF2, + 0xF2, 0xFA, 0xCA, 0xEA, 0x6A, 0x0A, 0xFA, 0xF2, + 0xF2, 0xDA, 0xEA, 0x6A, 0x6A, 0x1A, 0xFA, 0xF2, + 0xF2, 0xDA, 0xBA, 0x7A, 0x7A, 0xBA, 0xDA, 0xF2, + + 0x40, 0x4F, 0x48, 0x48, 0x48, 0x40, 0x47, 0x45, + 0x47, 0x40, 0x40, 0x40, 0x47, 0x40, 0x40, 0x40, + 0x47, 0x44, 0x44, 0x40, 0x47, 0x40, 0x40, 0x40, + 0x4F, 0x5C, 0x58, 0x53, 0x53, 0x58, 0x5C, 0x4F, + 0x4F, 0x5F, 0x57, 0x50, 0x50, 0x57, 0x5F, 0x4F, + 0x4F, 0x5F, 0x50, 0x56, 0x57, 0x53, 0x5F, 0x4F, + 0x4F, 0x5B, 0x57, 0x56, 0x56, 0x58, 0x5F, 0x4F, + 0x4F, 0x5B, 0x5D, 0x5E, 0x5E, 0x5D, 0x5B, 0x4F, +}; +static const char my_font_lib_caps_off[] PROGMEM = { + 0xFC, 0x06, 0xE2, 0x12, 0x1A, 0x12, 0x22, 0x02, + 0xC2, 0x72, 0x1A, 0x72, 0xC2, 0x02, 0xFA, 0x9A, + 0x0A, 0x9A, 0xF2, 0x06, 0xFC, 0x00, 0x00, 0x00, + 0x3F, 0x60, 0x47, 0x48, 0x58, 0x48, 0x44, 0x40, + 0x5F, 0x42, 0x42, 0x42, 0x5F, 0x40, 0x5F, 0x41, + 0x41, 0x41, 0x40, 0x60, 0x3F, 0x00, 0x00, 0x00, +}; +static const char my_font_lib_caps_on[] PROGMEM = { + 0xFC, 0xFE, 0x1E, 0xEE, 0xE6, 0xEE, 0xDE, 0xFE, + 0x3E, 0x8E, 0xF6, 0x8E, 0x3E, 0xFE, 0x06, 0x66, + 0xF6, 0x66, 0x0E, 0xFE, 0xFC, 0x00, 0x00, 0x00, + 0x3F, 0x7F, 0x78, 0x77, 0x67, 0x77, 0x7B, 0x7F, + 0x60, 0x7D, 0x7D, 0x7D, 0x60, 0x7F, 0x60, 0x7E, + 0x7E, 0x7E, 0x7F, 0x7F, 0x3F, 0x00, 0x00, 0x00, +}; + +static const char my_font_lib_shift_off[] PROGMEM = { + 0xFC, 0x06, 0x72, 0x8A, 0x0A, 0x32, 0x06, 0xFC, + 0x3F, 0x60, 0x4C, 0x50, 0x51, 0x4E, 0x60, 0x3F, +}; +static const char my_font_lib_shift_on[] PROGMEM = { + 0xFC, 0xFE, 0x8E, 0x76, 0xF6, 0xCE, 0xFE, 0xFC, + 0x3F, 0x7F, 0x73, 0x6F, 0x6E, 0x71, 0x7F, 0x3F, +}; + +static const char my_font_lib_ctrl_off[] PROGMEM = { + 0x00, 0xFC, 0x06, 0xE2, 0x12, 0x1A, 0x12, 0x22, 0x06, 0xFC, + 0x00, 0x3F, 0x60, 0x47, 0x48, 0x58, 0x48, 0x44, 0x60, 0x3F, +}; +static const char my_font_lib_ctrl_on[] PROGMEM = { + 0x00, 0xFC, 0xFE, 0x1E, 0xEE, 0xE6, 0xEE, 0xDE, 0xFE, 0xFC, + 0x00, 0x3F, 0x7F, 0x78, 0x77, 0x67, 0x77, 0x7B, 0x7F, 0x3F, +}; + +static const char my_font_lib_gui_off[] PROGMEM = { + 0x00, 0xFC, 0x06, 0xE2, 0x12, 0x1A, 0x12, 0x22, 0x06, 0xFC, + 0x00, 0x3F, 0x60, 0x47, 0x48, 0x59, 0x49, 0x47, 0x60, 0x3F, +}; +static const char my_font_lib_gui_on[] PROGMEM = { + 0x00, 0xFC, 0xFE, 0x1E, 0xEE, 0xE6, 0xEE, 0xDE, 0xFE, 0xFC, + 0x00, 0x3F, 0x7F, 0x78, 0x77, 0x66, 0x76, 0x78, 0x7F, 0x3F, +}; + +static const char my_font_lib_alt_off[] PROGMEM = { + 0x00, 0xFC, 0x06, 0xC2, 0x72, 0x0A, 0x72, 0xC2, 0x06, 0xFC, + 0x00, 0x3F, 0x60, 0x4F, 0x41, 0x41, 0x41, 0x4F, 0x60, 0x3F, +}; +static const char my_font_lib_alt_on[] PROGMEM = { + 0x00, 0xFC, 0xFE, 0x3E, 0x8E, 0xF6, 0x8E, 0x3E, 0xFE, 0xFC, + 0x00, 0x3F, 0x7F, 0x70, 0x7E, 0x7E, 0x7E, 0x70, 0x7F, 0x3F, +}; + +static const char my_font_lib_rgb_off[] PROGMEM = { + 0x00, 0xFC, 0x06, 0xFA, 0x8A, 0x8A, 0x72, 0x02, + 0xF2, 0x1A, 0x1A, 0x72, 0x02, 0xFA, 0x8A, 0x8A, + 0xFA, 0x72, 0x06, 0xFC, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x3F, 0x60, 0x5F, 0x41, 0x43, 0x5E, 0x40, + 0x4F, 0x58, 0x5A, 0x4E, 0x40, 0x5F, 0x51, 0x51, + 0x5F, 0x4E, 0x60, 0x3F, 0x00, 0x00, 0x00, 0x00, +}; +static const char my_font_lib_rgb_on[] PROGMEM = { + 0x00, 0xFC, 0xFE, 0x06, 0x76, 0x76, 0x8E, 0xFE, + 0x0E, 0xE6, 0xE6, 0x8E, 0xFE, 0x06, 0x76, 0x76, + 0x06, 0x8E, 0xFE, 0xFC, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x3F, 0x7F, 0x60, 0x7E, 0x7C, 0x61, 0x7F, + 0x70, 0x67, 0x65, 0x71, 0x7F, 0x60, 0x6E, 0x6E, + 0x60, 0x71, 0x7F, 0x3F, 0x00, 0x00, 0x00, 0x00, +}; + + + + + + + + + + + +/* 1*32 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +*/ diff --git a/keyboards/yandrstudio/rainbow65/keymaps/test_oled/graph_lib/wpm_graph.c b/keyboards/yandrstudio/rainbow65/keymaps/test_oled/graph_lib/wpm_graph.c new file mode 100755 index 000000000000..cf92759651b0 --- /dev/null +++ b/keyboards/yandrstudio/rainbow65/keymaps/test_oled/graph_lib/wpm_graph.c @@ -0,0 +1,183 @@ +#include "wpm_graph.h" +// #include "print.h" + + +const uint8_t single_bit_masks[] = {0, 128, 192, 224, 240, 248, 252, 254, 255}; +const uint8_t max_wpm = 160; +const uint8_t max_wpm_byte_bar_height = 5; // 5*8 = 40 bit +const uint8_t wpm_graph_start_line = 11; +const uint16_t show_count_time = 60000; +uint16_t wpm_graph_timer_update = 0; +uint16_t wpm_graph_timer_countdown = 0; +bool countdown_over = false; +bool first_startup = true; + +void draw_y_grad(uint8_t x, uint8_t y, bool inside) { + uint16_t start_index = (y * OLED_DISPLAY_WIDTH) + (x*8); + oled_buffer_reader_t reader; + if (inside) { + start_index += 2; + for (uint8_t i=0; i < 4; i++) + oled_write_raw_byte(60, start_index + i); + } else { + reader = oled_read_raw(start_index); + for (uint8_t i=0; i < 8; i++) { + if (i > 1 && i < 6) + oled_write_raw_byte((*reader.current_element)++ | 129, start_index + i); // 129 = 0b1000 0001 + else + oled_write_raw_byte(255, start_index + i); + } + } +} + +void render_wpm_graph(uint16_t wpm) { + // init + if (first_startup) { + render_r65_logo(); + } + if (wpm_graph_timer_countdown == 0) { + wpm_graph_timer_countdown = timer_read(); + } + if (wpm_graph_timer_update == 0) { + wpm_graph_timer_update = timer_read(); + return; + } + + // 2 frame + if (timer_elapsed(wpm_graph_timer_update) < 500) return; + wpm_graph_timer_update = timer_read(); + + // global var for this function + static uint8_t zero_bar_count = 0; + static uint8_t bar_count = 0; + + uint8_t bar_height = 0; + uint8_t bar_segment = 0; + + + bar_height = wpm; + if(bar_height > max_wpm) { + bar_height = max_wpm; + } + + if(bar_height == 0) { + // keep track of how many zero bars we have drawn. If + // there is a whole screen worth, turn the display off and + // wait until there is something to do + // uprintf("zero %u\n", zero_bar_count); + if (first_startup) return; + + if (zero_bar_count > 32) { + // do some thing when not typing + if (timer_elapsed(wpm_graph_timer_countdown) <= show_count_time+1 && !countdown_over) { + render_countdown(); + } else { + countdown_over = true; + render_yandr_logo(); + // oled_off(); + } + return; + } + zero_bar_count++; + wpm_graph_timer_countdown = timer_read(); + countdown_over = false; + } else { + first_startup = false; + zero_bar_count=0; + } + bar_count++; + + // scale the ture wpm to fit the bar height + uint8_t scale_rate = max_wpm/(max_wpm_byte_bar_height*8); + bar_height = bar_height / scale_rate; + + // wpm history bar move one step to right + // oled_precise_pan(false, wpm_graph_start_line*32); + if (!first_startup) { + oled_precise_pan_h(false, (uint16_t)wpm_graph_start_line); + } else { + return; + } + // oled_pan(false); + + + for (uint8_t i = max_wpm_byte_bar_height; i >0; i--) { + if (bar_height > 8) { + bar_segment = 255; + bar_height -= 8; + } else { + bar_segment = single_bit_masks[bar_height]; + bar_height = 0; + } + // uprintf("max%u",max_wpm_byte_bar_height); + oled_write_raw_byte(bar_segment, (uint16_t)((i - 1 + wpm_graph_start_line) * 32)); + } +} + + + +void render_countdown(void) { + uint16_t pass_time_mm = timer_elapsed(wpm_graph_timer_countdown); + // second + uint16_t pass_time_s = show_count_time/1000 - pass_time_mm / 1000; + + oled_set_cursor(0, wpm_graph_start_line+1); + if (pass_time_s < 10) { + // 0 + oled_set_cursor(0, wpm_graph_start_line+1); + oled_write_raw(my_font_lib_etc_countdown[0], 16); + oled_set_cursor(0, wpm_graph_start_line+2); + oled_write_raw(my_font_lib_etc_countdown[0]+16, 16); + oled_set_cursor(0, wpm_graph_start_line+3); + oled_write_raw(my_font_lib_etc_countdown[0]+32, 16); + + // pass_time_s + oled_set_precise_cursor((wpm_graph_start_line+1)*32 + 16); + oled_write_raw(my_font_lib_etc_countdown[pass_time_s], 16); + oled_set_precise_cursor((wpm_graph_start_line+2)*32 + 16); + oled_write_raw(my_font_lib_etc_countdown[pass_time_s]+16, 16); + oled_set_precise_cursor((wpm_graph_start_line+3)*32 + 16); + oled_write_raw(my_font_lib_etc_countdown[pass_time_s]+32, 16); + } else { + uint16_t pass_time_s_h = pass_time_s / 10; + uint16_t pass_time_s_l = pass_time_s % 10; + // heigh bit + oled_set_cursor(0, wpm_graph_start_line+1); + oled_write_raw(my_font_lib_etc_countdown[pass_time_s_h], 16); + oled_set_cursor(0, wpm_graph_start_line+2); + oled_write_raw(my_font_lib_etc_countdown[pass_time_s_h]+16, 16); + oled_set_cursor(0, wpm_graph_start_line+3); + oled_write_raw(my_font_lib_etc_countdown[pass_time_s_h]+32, 16); + + // low bit + oled_set_precise_cursor((wpm_graph_start_line+1)*32 + 16); + oled_write_raw(my_font_lib_etc_countdown[pass_time_s_l], 16); + oled_set_precise_cursor((wpm_graph_start_line+2)*32 + 16); + oled_write_raw(my_font_lib_etc_countdown[pass_time_s_l]+16, 16); + oled_set_precise_cursor((wpm_graph_start_line+3)*32 + 16); + oled_write_raw(my_font_lib_etc_countdown[pass_time_s_l]+32, 16); + } + oled_set_cursor(0, wpm_graph_start_line+4); +} + + + +void render_yandr_logo() { + oled_set_cursor(0, wpm_graph_start_line+1); + oled_write_raw(my_font_lib_etc_logo, 32); + oled_set_cursor(0, wpm_graph_start_line+2); + oled_write_raw(my_font_lib_etc_logo+32, 32); + oled_set_cursor(0, wpm_graph_start_line+3); + oled_write_raw(my_font_lib_etc_logo+64, 32); + oled_set_cursor(0,0); +} + +void render_r65_logo() { + oled_set_cursor(0, wpm_graph_start_line+1); + oled_write_raw(my_font_lib_etc_r65_logo, 32); + oled_set_cursor(0, wpm_graph_start_line+2); + oled_write_raw(my_font_lib_etc_r65_logo+32, 32); + oled_set_cursor(0, wpm_graph_start_line+3); + oled_write_raw(my_font_lib_etc_r65_logo+64, 32); + oled_set_cursor(0,0); +} diff --git a/keyboards/yandrstudio/rainbow65/keymaps/test_oled/graph_lib/wpm_graph.h b/keyboards/yandrstudio/rainbow65/keymaps/test_oled/graph_lib/wpm_graph.h new file mode 100755 index 000000000000..0a7fcaa91dd9 --- /dev/null +++ b/keyboards/yandrstudio/rainbow65/keymaps/test_oled/graph_lib/wpm_graph.h @@ -0,0 +1,151 @@ +#pragma once + +#include "../dev_oled/oled_driver.h" +#include "time.h" +#include "wpm.h" + + + +void draw_y_grad(uint8_t x, uint8_t y, bool inside); +void render_countdown(void); +void render_wpm_graph(uint16_t); +void render_yandr_logo(void); +void render_r65_logo(void); + + +static const char my_font_lib_etc_countdown[10][48] PROGMEM = { + {// 0 + 0x00, 0x00, 0x00, 0xF8, 0x08, 0x08, 0x08, 0x08, + 0x08, 0x08, 0x08, 0x08, 0xF8, 0x00, 0x00, 0x00, + + 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, + + 0x00, 0x00, 0x00, 0x1F, 0x10, 0x10, 0x10, 0x10, + 0x10, 0x10, 0x10, 0x10, 0x1F, 0x00, 0x00, 0x00, + }, + { // 1 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xF8, 0x00, 0x00, 0x00, + + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, + + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x1F, 0x00, 0x00, 0x00, + }, + { // 2 + 0x00, 0x00, 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, + 0x08, 0x08, 0x08, 0x08, 0xF8, 0x00, 0x00, 0x00, + + 0x00, 0x00, 0x00, 0xF0, 0x10, 0x10, 0x10, 0x10, + 0x08, 0x08, 0x08, 0x08, 0x0F, 0x00, 0x00, 0x00, + + 0x00, 0x00, 0x00, 0x1F, 0x10, 0x10, 0x10, 0x10, + 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, + }, + { // 3 + 0x00, 0x00, 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, + 0x08, 0x08, 0x08, 0x08, 0xF8, 0x00, 0x00, 0x00, + + 0x00, 0x00, 0x00, 0x10, 0x10, 0x10, 0x10, 0x10, + 0x08, 0x08, 0x08, 0x08, 0xFF, 0x00, 0x00, 0x00, + + 0x00, 0x00, 0x00, 0x10, 0x10, 0x10, 0x10, 0x10, + 0x10, 0x10, 0x10, 0x10, 0x1F, 0x00, 0x00, 0x00, + }, + { // 4 + 0x00, 0x00, 0x00, 0xF8, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xF8, 0x00, 0x00, 0x00, + + 0x00, 0x00, 0x00, 0x1F, 0x10, 0x10, 0x10, 0x10, + 0x08, 0x08, 0x08, 0x08, 0xFF, 0x00, 0x00, 0x00, + + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x1F, 0x00, 0x00, 0x00, + }, + { // 5 + 0x00, 0x00, 0x00, 0xF8, 0x08, 0x08, 0x08, 0x08, + 0x08, 0x08, 0x08, 0x08, 0x08, 0x00, 0x00, 0x00, + + 0x00, 0x00, 0x00, 0x1F, 0x10, 0x10, 0x10, 0x10, + 0x08, 0x08, 0x08, 0x08, 0xF8, 0x00, 0x00, 0x00, + + 0x00, 0x00, 0x00, 0x10, 0x10, 0x10, 0x10, 0x10, + 0x10, 0x10, 0x10, 0x10, 0x1F, 0x00, 0x00, 0x00, + }, + { // 6 + 0x00, 0x00, 0x00, 0xF8, 0x08, 0x08, 0x08, 0x08, + 0x08, 0x08, 0x08, 0x08, 0x08, 0x00, 0x00, 0x00, + + 0x00, 0x00, 0x00, 0xFF, 0x10, 0x10, 0x10, 0x10, + 0x08, 0x08, 0x08, 0x08, 0xF8, 0x00, 0x00, 0x00, + + 0x00, 0x00, 0x00, 0x1F, 0x10, 0x10, 0x10, 0x10, + 0x10, 0x10, 0x10, 0x10, 0x1F, 0x00, 0x00, 0x00, + }, + { // 7 + 0x00, 0x00, 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, + 0x08, 0x08, 0x08, 0x08, 0xF8, 0x00, 0x00, 0x00, + + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, + + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x1F, 0x00, 0x00, 0x00, + }, + { // 8 + 0x00, 0x00, 0x00, 0xF8, 0x08, 0x08, 0x08, 0x08, + 0x08, 0x08, 0x08, 0x08, 0xF8, 0x00, 0x00, 0x00, + + 0x00, 0x00, 0x00, 0xFF, 0x10, 0x10, 0x10, 0x10, + 0x08, 0x08, 0x08, 0x08, 0xFF, 0x00, 0x00, 0x00, + + 0x00, 0x00, 0x00, 0x1F, 0x10, 0x10, 0x10, 0x10, + 0x10, 0x10, 0x10, 0x10, 0x1F, 0x00, 0x00, 0x00, + }, + { // 9 + 0x00, 0x00, 0x00, 0xF8, 0x08, 0x08, 0x08, 0x08, + 0x08, 0x08, 0x08, 0x08, 0xF8, 0x00, 0x00, 0x00, + + 0x00, 0x00, 0x00, 0x1F, 0x10, 0x10, 0x10, 0x10, + 0x08, 0x08, 0x08, 0x08, 0xFF, 0x00, 0x00, 0x00, + + 0x00, 0x00, 0x00, 0x10, 0x10, 0x10, 0x10, 0x10, + 0x10, 0x10, 0x10, 0x10, 0x1F, 0x00, 0x00, 0x00, + } +}; + +static const char my_font_lib_etc_logo[] PROGMEM = { + 0x00, 0x00, 0x18, 0x30, 0x60, 0xC0, 0x80, 0x00, + 0x00, 0x80, 0xC0, 0x60, 0x30, 0x18, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0xF8, + 0x18, 0x18, 0x18, 0x30, 0x60, 0xC0, 0x00, 0x00, + + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xFF, + 0xFF, 0x01, 0x00, 0x00, 0x00, 0xDC, 0x22, 0x22, + 0xDC, 0x80, 0x40, 0x00, 0x00, 0x00, 0xFF, 0xFF, + 0x7C, 0xCC, 0x8C, 0x06, 0x03, 0x01, 0x00, 0x00, + + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, + 0x1F, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, + 0x01, 0x01, 0x02, 0x00, 0x00, 0x00, 0x1F, 0x1F, + 0x00, 0x00, 0x01, 0x03, 0x06, 0x0C, 0x18, 0x00, +}; + +static const char my_font_lib_etc_r65_logo[] PROGMEM = { + 0x00, 0x00, 0xF8, 0xF8, 0x18, 0x18, 0x18, 0x18, + 0x18, 0x30, 0x60, 0xC0, 0x00, 0xF8, 0xF8, 0x18, + 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, 0xF8, 0xF8, + 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, 0x00, + + 0x00, 0x00, 0xFF, 0xFF, 0x3C, 0x6C, 0xCC, 0x8C, + 0x0C, 0x06, 0x03, 0x01, 0x00, 0xFF, 0xFF, 0x18, + 0x18, 0x18, 0x18, 0xF8, 0xF8, 0x00, 0x1F, 0x1F, + 0x18, 0x18, 0x18, 0x18, 0xF8, 0xF8, 0x00, 0x00, + + 0x00, 0x00, 0x1F, 0x1F, 0x00, 0x00, 0x00, 0x01, + 0x03, 0x06, 0x0C, 0x18, 0x00, 0x1F, 0x1F, 0x18, + 0x18, 0x18, 0x18, 0x1F, 0x1F, 0x00, 0x18, 0x18, + 0x18, 0x18, 0x18, 0x18, 0x1F, 0x1F, 0x00, 0x00, +}; diff --git a/keyboards/yandrstudio/rainbow65/keymaps/test_oled/keymap.c b/keyboards/yandrstudio/rainbow65/keymaps/test_oled/keymap.c new file mode 100755 index 000000000000..d2a42d59b3bf --- /dev/null +++ b/keyboards/yandrstudio/rainbow65/keymaps/test_oled/keymap.c @@ -0,0 +1,392 @@ +#include "rainbow65.h" +#include "dynamic_keymap.h" +#include "raw_hid.h" +#include "print.h" +#include +#include "graph_lib/my_pic_lib.h" +#include "graph_lib/wpm_graph.h" +#include "graph_lib/kb_press_graph.h" +#include "dev_oled/oled_driver.h" + +enum layer_names { _BASE, _FN, _SYS, _USER }; + + +// Tap Dance declarations +enum { + TD_FN_LAYER_TOG, +}; + +void dance_layer_to_layer_count_pre(qk_tap_dance_state_t *state, void *user_data) { + if (state->count <= 4) { + layer_on(state->count); + // reset_tap_dance(state); + } + uprintf("press Fn %u times\n", state->count); +} + +void dance_layer_to_layer_count_finsh(qk_tap_dance_state_t *state, void *user_data) { + if (state->count <= 4) { + layer_off(state->count); + // reset_tap_dance(state); + } + uprintf("press Fn %u times\n", state->count); +} + +// Tap Dance definitions +qk_tap_dance_action_t tap_dance_actions[] = { + [TD_FN_LAYER_TOG] = ACTION_TAP_DANCE_FN_ADVANCED(NULL,dance_layer_to_layer_count_pre,dance_layer_to_layer_count_finsh) +}; + + +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + [_BASE] = KEYMAP( + KC_ESC, RESET, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC, KC_MUTE, + KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSLS, + KC_CAPS, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT, + KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, KC_UP, + KC_LCTL, KC_LGUI, KC_LALT, KC_VOLD, KC_VOLU, KC_SPC, KC_RALT, TD(TD_FN_LAYER_TOG), KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT), + + [_FN] = KEYMAP( + KC_GRV, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_DEL, TO(_BASE), + KC_TRNS, KC_TRNS, KC_UP, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_LEFT, KC_DOWN, KC_RGHT, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_CAPS, + KC_TRNS, RGB_TOG, RGB_MOD, RGB_MODE_REVERSE, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS), + + [_SYS] = KEYMAP( + TO(_BASE), KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, TO(_BASE), + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, RGB_MODE_PLAIN, RGB_MODE_BREATHE, RGB_MODE_RAINBOW, RGB_MODE_SWIRL, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, RGB_TOG, RGB_MOD, RGB_MODE_REVERSE, RGB_VAI, RGB_VAD, RGB_SPI, RGB_SPD, RGB_HUI, RGB_HUD, RGB_SAI, RGB_SAD, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS), + [_USER] = KEYMAP( + TO(_BASE), KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, TO(_BASE), + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS) +}; + + + +#ifdef ENCODER_ENABLE +void encoder_update_user(uint8_t index, bool clockwise) { + uprintf("%ud raw g_rgb_time\n", g_rgb_timer); + uprintf("%ud rgb speed\n", rgb_matrix_config.speed); + + // uprintf("%ud g_rgb_time scale8\n", scale16by8(g_rgb_timer, rgb_matrix_config.speed / 4)); + if (clockwise) { + uint16_t keycode = dynamic_keymap_get_keycode(biton32(layer_state), 4, 3); + if (keycode >= MACRO00 && keycode <= MACRO15) { + dynamic_keymap_macro_send(keycode - MACRO00); + } else { + register_code16(keycode); + wait_ms(10); + unregister_code16(keycode); + } + } else { + uint16_t keycode = dynamic_keymap_get_keycode(biton32(layer_state), 4, 4); + if (keycode >= MACRO00 && keycode <= MACRO15) { + dynamic_keymap_macro_send(keycode - MACRO00); + } else { + register_code16(keycode); + wait_ms(10); + unregister_code16(keycode); + } + } +} +#endif + +#ifdef OLED_DRIVER_ENABLE +char wpm_str[10]; // limit WPM string length. +char rgbStatus[26] = {0}; +uint16_t oled_start_timer = 0; +uint16_t key_press_count = 0; + +#define col_module_ +oled_rotation_t oled_init_user(oled_rotation_t rotation) { + // oled_scroll_set_area(0,2); + // oled_scroll_set_speed(4); + // oled_scroll_right(); + oled_start_timer = timer_read(); + return OLED_ROTATION_90; +} + + + +void oled_write_ln_clo(const char *data, bool invert, uint8_t col, uint8_t line) { + uint8_t l = strlen(data); + const char *end = data + l; + uint8_t i = 0; + while (data < end) { + oled_set_cursor(col, line+i); + oled_write_char(*data, invert); + data++; + i++; + } + uint8_t rm = 16-(line+l); + uint8_t j = 0; + for(; j < rm; ++j) { + oled_set_cursor(col, line+j+l); + oled_write_char(' ', invert); + } +} + +void oled_write_clo(const char *data, bool invert, uint8_t col, uint8_t line) { + uint8_t l = strlen(data); + const char *end = data + l; + uint8_t i = 0; + while (data < end) { + oled_set_cursor(col, line+i); + oled_write_char(*data, invert); + data++; + i++; + } +} + + +static bool has_clear = false; +void oled_task_user(void) { + if (!has_clear) { + oled_clear(); + has_clear = true; + } + // if (timer_elapsed(oled_start_timer) < 1000) { + // render_logo_yandr(); + // } + // Layer + const char *st_my = my_font_lib_layer; + oled_set_cursor(0,0); + oled_write_raw_P(st_my, 24); + oled_set_cursor(0,1); + oled_write_raw_P(st_my+8*8, 24); + switch (biton32(layer_state)) { + case 0: + oled_set_cursor(4,0); + oled_write_raw_P(st_my+3*8, 8); + oled_set_cursor(4,1); + oled_write_raw_P(st_my+11*8, 8); + oled_set_cursor(0,2); + break; + case 1: + oled_set_cursor(4,0); + oled_write_raw_P(st_my+4*8, 8); + oled_set_cursor(4,1); + oled_write_raw_P(st_my+12*8, 8); + oled_set_cursor(0,2); + break; + case 2: + oled_set_cursor(4,0); + oled_write_raw_P(st_my+5*8, 8); + oled_set_cursor(4,1); + oled_write_raw_P(st_my+13*8, 8); + oled_set_cursor(0,2); + break; + case 3: + oled_set_cursor(4,0); + oled_write_raw_P(st_my+6*8, 8); + oled_set_cursor(4,1); + oled_write_raw_P(st_my+14*8, 8); + oled_set_cursor(0,2); + break; + default: + oled_set_cursor(4,0); + oled_write_raw_P(st_my+7*8, 8); + oled_set_cursor(4,1); + oled_write_raw_P(st_my+15*8, 8); + oled_set_cursor(0,2); + } + oled_set_cursor(0,2); + if (host_keyboard_led_state().caps_lock) { + oled_write_raw_P(my_font_lib_caps_on, 24); + oled_set_cursor(0,3); + oled_write_raw_P(my_font_lib_caps_on+3*8, 24); + } else { + oled_write_raw_P(my_font_lib_caps_off, 24); + oled_set_cursor(0,3); + oled_write_raw_P(my_font_lib_caps_off+3*8, 24); + } + oled_set_cursor(4,2); + if ((get_mods() & MOD_MASK_SHIFT)) { + oled_write_raw_P(my_font_lib_shift_on, 8); + oled_set_cursor(4,3); + oled_write_raw_P(my_font_lib_shift_on+1*8, 8); + } else { + oled_write_raw_P(my_font_lib_shift_off, 8); + oled_set_cursor(4,3); + oled_write_raw_P(my_font_lib_shift_off+1*8, 8); + } + oled_set_precise_cursor(4*32+1); + if ((get_mods() & MOD_MASK_CTRL)) { + oled_write_raw_P(my_font_lib_ctrl_on, 10); + oled_set_precise_cursor(5*32+1); + oled_write_raw_P(my_font_lib_ctrl_on+1*10, 10); + } else { + oled_write_raw_P(my_font_lib_ctrl_off, 10); + oled_set_precise_cursor(5*32+1); + oled_write_raw_P(my_font_lib_ctrl_off+1*10, 10); + } + oled_set_precise_cursor(4*32+11); + if ((get_mods() & MOD_MASK_GUI)) { + oled_write_raw_P(my_font_lib_gui_on, 10); + oled_set_precise_cursor(5*32+11); + oled_write_raw_P(my_font_lib_gui_on+1*10, 10); + } else { + oled_write_raw_P(my_font_lib_gui_off, 10); + oled_set_precise_cursor(5*32+11); + oled_write_raw_P(my_font_lib_gui_off+1*10, 10); + } + oled_set_precise_cursor(4*32+21); + if ((get_mods() & MOD_MASK_ALT)) { + oled_write_raw_P(my_font_lib_alt_on, 10); + oled_set_precise_cursor(5*32+21); + oled_write_raw_P(my_font_lib_alt_on+1*10, 10); + } else { + oled_write_raw_P(my_font_lib_alt_off, 10); + oled_set_precise_cursor(5*32+21); + oled_write_raw_P(my_font_lib_alt_off+1*10, 10); + } + // oled_write_ln_P((get_mods() & MOD_MASK_ALT) ? "\x9c" : "\x9b", false); + oled_set_cursor(0,6); + if (rgb_matrix_is_enabled()) { + oled_write_raw_P(my_font_lib_rgb_on, 20); + oled_set_precise_cursor(6*32+20); + snprintf(rgbStatus, sizeof(rgbStatus), "%2d", rgb_matrix_get_mode()); + oled_write(rgbStatus, false); + oled_set_cursor(0,7); + oled_write_raw_P(my_font_lib_rgb_on+1*24, 20); + oled_set_precise_cursor(7*32+20); + snprintf(rgbStatus, sizeof(rgbStatus), "%2d", RGB_MATRIX_EFFECT_MAX); + oled_write(rgbStatus, false); + } else { + oled_write_raw_P(my_font_lib_rgb_off, 20); + oled_set_precise_cursor(6*32+20); + oled_write("xx", false); + oled_set_cursor(0,7); + oled_write_raw_P(my_font_lib_rgb_off+1*24, 20); + oled_set_precise_cursor(7*32+20); + oled_write("xx", false); + } + + // show which area is pressed + if (key_press_count==0) { + render_r65_kb(255, 255, 0, false, key_press_count); + } + + oled_set_cursor(0,10); + uint16_t cur_wpm = get_current_wpm(); + snprintf(wpm_str, sizeof(wpm_str), " %03d ", cur_wpm); + oled_write_ln_P(wpm_str, false); + oled_set_cursor(0,11); + + // show the wpm wave + render_wpm_graph(cur_wpm); +} + +bool process_record_user(uint16_t keycode, keyrecord_t *record) { + // switch(keycode) { + // case MACRO_1: + // if (record->event.pressed) { + // SEND_STRING("This is macro #1."); + // } + // return false; + // } +#ifdef OLED_DRIVER_ENABLE + uint8_t map_col = record->event.key.col; + uint8_t map_row = record->event.key.row; + if (record->event.pressed) { + key_press_count++; + print("key_press\n"); + uprintf("col %d ", map_col); + uprintf("row %d\n", map_row); + render_r65_kb(map_col, map_row, keycode, true, key_press_count); + } else { + if (key_press_count>0) { + key_press_count--; + } + render_r65_kb(map_col, map_row, keycode, false, key_press_count); + } +#endif + return true; +}; + + +#endif + +#define RAW_HID_CUM_ + + +#ifdef RAW_HID_CUM +extern uint8_t global_r_power_state[MATRIX_ROWS]; +extern uint8_t global_c_power_state[MATRIX_COLS]; +uint8_t pre_rgb_mode = 0xff; +void raw_hid_receive_kb(uint8_t *data, uint8_t length) { + // Your code goes here. data is the packet received from host. + switch (data[0]) { + case 60: + switch (data[1]) { + case 1: + rgb_matrix_toggle_noeeprom(); + break; + case 2: + rgb_matrix_enable_noeeprom(); + break; + case 3: + rgb_matrix_disable_noeeprom(); + break; + case 4: + if (rgb_matrix_get_mode() != RGB_MATRIX_CUSTOM_AUDIO_VISUALIZATION_COL) { + pre_rgb_mode = rgb_matrix_get_mode(); + rgb_matrix_mode(RGB_MATRIX_CUSTOM_AUDIO_VISUALIZATION_COL); + } else { + rgb_matrix_mode(pre_rgb_mode); + } + break; + case 5: + if (rgb_matrix_get_mode() != RGB_MATRIX_CUSTOM_AUDIO_VISUALIZATION_ROW) { + pre_rgb_mode = rgb_matrix_get_mode(); + rgb_matrix_mode(RGB_MATRIX_CUSTOM_AUDIO_VISUALIZATION_ROW); + } else { + rgb_matrix_mode(pre_rgb_mode); + } + case 6: + if (rgb_matrix_get_mode() == RGB_MATRIX_CUSTOM_AUDIO_VISUALIZATION_ROW) { + for (uint8_t i = 0; i < length; ++i) { + global_r_power_state[i] = data[2+i]; + } + } else if (rgb_matrix_get_mode() == RGB_MATRIX_CUSTOM_AUDIO_VISUALIZATION_COL) { + for (uint8_t i = 0; i < length; ++i) { + global_c_power_state[i] = data[2+i]; + } + } else { + dprint("BAD: not in the audio visual mod."); + } + break; + case 7: + rgb_matrix_mode(data[2]); + default: + break; + } + break; + case 66: + dprint("GOOD: 6666"); + break; + default: + break; + } + raw_hid_send(data, 32); +} +#endif + + + +#ifdef CONSOLE_ENABLE +void keyboard_post_init_user(void) { + // eeconfig_init(); + // Customise these values to desired behaviour + debug_enable=true; + debug_matrix=false; + // debug_keyboard=true; + //debug_mouse=true; +} +#endif diff --git a/keyboards/yandrstudio/rainbow65/keymaps/test_oled/rgb_matrix_user.inc b/keyboards/yandrstudio/rainbow65/keymaps/test_oled/rgb_matrix_user.inc new file mode 100755 index 000000000000..03aa3b20015b --- /dev/null +++ b/keyboards/yandrstudio/rainbow65/keymaps/test_oled/rgb_matrix_user.inc @@ -0,0 +1,98 @@ +/* +Copyright 2020 Evy Dekkers + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +RGB_MATRIX_EFFECT(AUDIO_VISUALIZATION_COL) +RGB_MATRIX_EFFECT(AUDIO_VISUALIZATION_ROW) + + +#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS +uint8_t global_r_power_state[MATRIX_ROWS]; +uint8_t global_c_power_state[MATRIX_COLS]; + +// bool AUDIO_VISUALIZATION_COL(effect_params_t* params) { +// // HSV hsv = rgb_matrix_config.hsv; +// // RGB rgb = hsv_to_rgb(hsv); +// RGB_MATRIX_USE_LIMITS(led_min, led_max); +// for (uint8_t i = led_min ; i < led_max; i++) { +// rgb_matrix_set_color(i, global_r_state[i], global_g_state[i], global_b_state[i]); +// } +// return led_max < DRIVER_LED_TOTAL; +// } + + + + +static HSV AUDIO_VISUALIZATION_COL_math(HSV hsv, uint8_t i, uint8_t time) { + // uint8_t cur_row = (uint8_t)((MATRIX_ROWS-1)*g_led_config.point[i].y/64); + uint8_t cur_col = (uint8_t)((MATRIX_COLS-1)*g_led_config.point[i].x/224); + uint8_t cur_row2height_index = MATRIX_ROWS - (uint8_t)((MATRIX_ROWS-1)*g_led_config.point[i].y/64) - 1; + uint8_t max_height_cur_col = (uint8_t)(global_c_power_state[cur_col]*MATRIX_ROWS/10); + + if (max_height_cur_col >= 1 && (max_height_cur_col - 1) >= cur_row2height_index) { + hsv.h += abs8(g_led_config.point[i].y - k_rgb_matrix_center.y) + (g_led_config.point[i].x - time); + } else { + hsv.h = 0; + hsv.v = 0; + } + return hsv; +} + +static HSV AUDIO_VISUALIZATION_ROW_math(HSV hsv, uint8_t i, uint8_t time) { + uint8_t cur_row = (uint8_t)((MATRIX_ROWS-1)*g_led_config.point[i].y/64); + // uint8_t cur_col2height_index = MATRIX_COLS - (uint8_t)((MATRIX_COLS-1)*g_led_config.point[i].x/224) - 1; + uint8_t cur_col2height_index = (uint8_t)((MATRIX_COLS-1)*g_led_config.point[i].x/224); + + uint8_t max_height_cur_row = (uint8_t)(global_r_power_state[cur_row]*MATRIX_COLS/10); + + + if (max_height_cur_row >= 1 && (max_height_cur_row - 1) >= cur_col2height_index) { + hsv.h += abs8(g_led_config.point[i].y - k_rgb_matrix_center.y) + (g_led_config.point[i].x - time); + } else { + hsv.h = 0; + hsv.v = 0; + } + return hsv; +} +bool AUDIO_VISUALIZATION_COL(effect_params_t* params) { + // HSV hsv = rgb_matrix_config.hsv; + // RGB rgb = hsv_to_rgb(hsv); + return effect_runner_i(params, &AUDIO_VISUALIZATION_COL_math); +} + +bool AUDIO_VISUALIZATION_ROW(effect_params_t* params) { + return effect_runner_i(params, &AUDIO_VISUALIZATION_ROW_math); +} +// static HSV RAINBOW_MOVING_CHEVRON_math(HSV hsv, uint8_t i, uint8_t time) { +// hsv.h += abs8(g_led_config.point[i].y - k_rgb_matrix_center.y) + (g_led_config.point[i].x - time); +// return hsv; +// } +// static HSV RAINBOW_BEACON_math(HSV hsv, int8_t sin, int8_t cos, uint8_t i, uint8_t time) { +// hsv.h += ((g_led_config.point[i].y - k_rgb_matrix_center.y) * 2 * cos + (g_led_config.point[i].x - k_rgb_matrix_center.x) * 2 * sin) / 128; +// return hsv; +// } +// static HSV RAINBOW_PINWHEELS_math(HSV hsv, int8_t sin, int8_t cos, uint8_t i, uint8_t time) { +// hsv.h += ((g_led_config.point[i].y - k_rgb_matrix_center.y) * 3 * cos + (56 - abs8(g_led_config.point[i].x - k_rgb_matrix_center.x)) * 3 * sin) / 128; +// return hsv; +// } + +// bool RAINBOW_PINWHEELS(effect_params_t* params) { return effect_runner_sin_cos_i(params, &RAINBOW_PINWHEELS_math); } +// bool RAINBOW_BEACON(effect_params_t* params) { return effect_runner_sin_cos_i(params, &RAINBOW_BEACON_math); } +// bool RAINBOW_MOVING_CHEVRON(effect_params_t* params) { return effect_runner_i(params, &RAINBOW_MOVING_CHEVRON_math); } + + + +#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS diff --git a/keyboards/yandrstudio/rainbow65/keymaps/test_oled/rules.mk b/keyboards/yandrstudio/rainbow65/keymaps/test_oled/rules.mk new file mode 100755 index 000000000000..5a45f7f1a779 --- /dev/null +++ b/keyboards/yandrstudio/rainbow65/keymaps/test_oled/rules.mk @@ -0,0 +1,11 @@ +# OLED_DRIVER_ENABLE = yes +VIA_ENABLE = yes +WPM_ENABLE = yes +RGB_MATRIX_CUSTOM_USER = no +CONSOLE_ENABLE = yes +TAP_DANCE_ENABLE = yes + +SRC += graph_lib/wpm_graph.c graph_lib/kb_press_graph.c dev_oled/oled_driver.c +QUANTUM_LIB_SRC += i2c_master.c +OPT_DEFS += -DOLED_DRIVER_ENABLE +COMMON_VPATH += keyboards/yandrstudio/rainbow65/keymaps/test_oled/dev_oled diff --git a/keyboards/yandrstudio/rainbow65/keymaps/test_rgb/config.h b/keyboards/yandrstudio/rainbow65/keymaps/test_rgb/config.h new file mode 100644 index 000000000000..ca4e95960601 --- /dev/null +++ b/keyboards/yandrstudio/rainbow65/keymaps/test_rgb/config.h @@ -0,0 +1,18 @@ +/* OLED */ +#ifdef OLED_DRIVER_ENABLE +// # define OLED_DISPLAY_128X64 +# define I2C_DRIVER I2CD1 +# define I2C1_TIMINGR_PRESC 0U +# define I2C1_TIMINGR_SCLDEL 7U +# define I2C1_TIMINGR_SDADEL 0U +# define I2C1_TIMINGR_SCLH 38U +# define I2C1_TIMINGR_SCLL 129U +# define OLED_BRIGHTNESS 50 +# define OLED_TIMEOUT 300000 +// # define OLED_TIMEOUT 0 +# define OLED_FONT_HEIGHT 8 +# define OLED_FONT_WIDTH 6 +# define OLED_FONT_H "../../jason_fount.c" +# define OLED_FONT_END 127 +# define OLED_FONT_START 0 +#endif diff --git a/keyboards/yandrstudio/rainbow65/keymaps/test_rgb/keymap copy.c b/keyboards/yandrstudio/rainbow65/keymaps/test_rgb/keymap copy.c new file mode 100755 index 000000000000..2486ea0848a1 --- /dev/null +++ b/keyboards/yandrstudio/rainbow65/keymaps/test_rgb/keymap copy.c @@ -0,0 +1,223 @@ +#include "rainbow65.h" +#include "dynamic_keymap.h" +#include "raw_hid.h" +#include "print.h" +#include +// #include "scale8.h" +enum layer_names { _BASE, _FN, _SYS, _USER }; +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + [_BASE] = KEYMAP( + KC_ESC, RESET, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC, KC_MUTE, + KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSLS, + KC_CAPS, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT, + KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, KC_UP, + KC_LCTL, KC_LGUI, KC_LALT, KC_VOLD, KC_VOLU, KC_SPC, KC_RALT, MO(1), KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT), + + [_FN] = KEYMAP( + KC_GRV, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_DEL, TO(_BASE), + KC_TRNS, KC_TRNS, KC_UP, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_LEFT, KC_DOWN, KC_RGHT, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_CAPS, + KC_TRNS, RGB_TOG, RGB_MOD, RGB_MODE_REVERSE, RGB_VAI, RGB_VAD, RGB_SPI, RGB_SPD, RGB_MODE_PLAIN, RGB_MODE_BREATHE, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS), + + [_SYS] = KEYMAP( + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS), + + [_USER] = KEYMAP( + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS) +}; + + + +#ifdef ENCODER_ENABLE +void encoder_update_user(uint8_t index, bool clockwise) { + uprintf("%ud raw g_rgb_time\n", g_rgb_timer); + uprintf("%ud rgb speed\n", rgb_matrix_config.speed); + + // uprintf("%ud g_rgb_time scale8\n", scale16by8(g_rgb_timer, rgb_matrix_config.speed / 4)); + if (clockwise) { + uint16_t keycode = dynamic_keymap_get_keycode(biton32(layer_state), 4, 3); + if (keycode >= MACRO00 && keycode <= MACRO15) { + dynamic_keymap_macro_send(keycode - MACRO00); + } else { + register_code16(keycode); + wait_ms(10); + unregister_code16(keycode); + } + } else { + uint16_t keycode = dynamic_keymap_get_keycode(biton32(layer_state), 4, 4); + if (keycode >= MACRO00 && keycode <= MACRO15) { + dynamic_keymap_macro_send(keycode - MACRO00); + } else { + register_code16(keycode); + wait_ms(10); + unregister_code16(keycode); + } + } +} +#endif + +#ifdef OLED_DRIVER_ENABLE +void oled_task_user(void) { + // Host Keyboard Layer Status + oled_write_P(PSTR("Layer: "), false); + + switch (get_highest_layer(layer_state)) { + case _QWERTY: + oled_write_P(PSTR("Default\n"), false); + break; + case _FN: + oled_write_P(PSTR("FN\n"), false); + break; + case _ADJ: + oled_write_P(PSTR("ADJ\n"), false); + break; + default: + // Or use the write_ln shortcut over adding '\n' to the end of your string + oled_write_ln_P(PSTR("Undefined"), false); + } + + // Host Keyboard LED Status + led_t led_state = host_keyboard_led_state(); + oled_write_P(led_state.num_lock ? PSTR("NUM ") : PSTR(" "), false); + oled_write_P(led_state.caps_lock ? PSTR("CAP ") : PSTR(" "), false); + oled_write_P(led_state.scroll_lock ? PSTR("SCR ") : PSTR(" "), false); +} +#endif + + +/* +#ifdef OLED_DRIVER_ENABLE +char wpm_str[10]; // limit WPM string length. +char rgbStatus[26] = {0}; + +oled_rotation_t oled_init_user(oled_rotation_t rotation) { + // oled_scroll_set_area(0,2); + // oled_scroll_set_speed(4); + // oled_scroll_right(); + return OLED_ROTATION_0; +} + + + + +void oled_task_user(void) { + switch (biton32(layer_state)) { + case 0: + oled_write_ln("Layer: Base", false); + break; + case 1: + oled_write_ln("Layer: Function", false); + break; + case 2: + oled_write_ln("Layer: System", false); + break; + case 3: + oled_write_ln("Layer: User", false); + break; + default: + oled_write_ln("Layer: Undefine", false); + } + oled_write_P((get_mods() & MOD_MASK_SHIFT) ? "SF>* " : "SF>x ", false); + oled_write_P((get_mods() & MOD_MASK_CTRL) ? "CT>* " : "CT>x ", false); + oled_write_P((get_mods() & MOD_MASK_ALT) ? "AL>* " : "AL>x ", false); + oled_write_ln((get_mods() & MOD_MASK_GUI) ? "GU>*" : "GU>x", false); + + + if (rgb_matrix_is_enabled()) { + snprintf(rgbStatus, sizeof(rgbStatus), "RGB:o M:%d", rgb_matrix_get_mode()); + oled_write_ln(rgbStatus, false); + } else { + snprintf(rgbStatus, sizeof(rgbStatus), "RGB:x M:x", rgb_matrix_get_mode()); + oled_write_ln(rgbStatus, false); + } + snprintf(wpm_str, sizeof(wpm_str), "APM:%03d", get_current_wpm()); + oled_write_ln(wpm_str, false); +} +#endif +*/ +#define RAW_HID_CUM + + +#ifdef RAW_HID_CUM +extern uint8_t global_r_power_state[MATRIX_ROWS]; +extern uint8_t global_c_power_state[MATRIX_COLS]; +uint8_t pre_rgb_mode = 0xff; +void raw_hid_receive_kb(uint8_t *data, uint8_t length) { + // Your code goes here. data is the packet received from host. + switch (data[0]) { + case 60: + switch (data[1]) { + case 1: + rgb_matrix_toggle_noeeprom(); + break; + case 2: + rgb_matrix_enable_noeeprom(); + break; + case 3: + rgb_matrix_disable_noeeprom(); + break; + case 4: + if (rgb_matrix_get_mode() != RGB_MATRIX_CUSTOM_AUDIO_VISUALIZATION_COL) { + pre_rgb_mode = rgb_matrix_get_mode(); + rgb_matrix_mode(RGB_MATRIX_CUSTOM_AUDIO_VISUALIZATION_COL); + } else { + rgb_matrix_mode(pre_rgb_mode); + } + break; + case 5: + if (rgb_matrix_get_mode() != RGB_MATRIX_CUSTOM_AUDIO_VISUALIZATION_ROW) { + pre_rgb_mode = rgb_matrix_get_mode(); + rgb_matrix_mode(RGB_MATRIX_CUSTOM_AUDIO_VISUALIZATION_ROW); + } else { + rgb_matrix_mode(pre_rgb_mode); + } + case 6: + if (rgb_matrix_get_mode() == RGB_MATRIX_CUSTOM_AUDIO_VISUALIZATION_ROW) { + for (uint8_t i = 0; i < length; ++i) { + global_r_power_state[i] = data[2+i]; + } + } else if (rgb_matrix_get_mode() == RGB_MATRIX_CUSTOM_AUDIO_VISUALIZATION_COL) { + for (uint8_t i = 0; i < length; ++i) { + global_c_power_state[i] = data[2+i]; + } + } else { + dprint("BAD: not in the audio visual mod."); + } + break; + case 7: + rgb_matrix_mode(data[2]); + default: + break; + } + break; + case 66: + dprint("GOOD: 6666"); + break; + default: + break; + } + raw_hid_send(data, 32); +} +#endif + + + +#ifdef CONSOLE_ENABLE +void keyboard_post_init_user(void) { + // eeconfig_init(); + // Customise these values to desired behaviour + debug_enable=true; + // debug_matrix=true; + // debug_keyboard=true; + //debug_mouse=true; +} +#endif diff --git a/keyboards/yandrstudio/rainbow65/keymaps/test_rgb/keymap.c b/keyboards/yandrstudio/rainbow65/keymaps/test_rgb/keymap.c new file mode 100755 index 000000000000..6a24252422f0 --- /dev/null +++ b/keyboards/yandrstudio/rainbow65/keymaps/test_rgb/keymap.c @@ -0,0 +1,196 @@ +#include "rainbow65.h" +#include "dynamic_keymap.h" +#include "raw_hid.h" +#include "print.h" +#include +// #include "scale8.h" +enum layer_names { _BASE, _FN, _SYS, _USER }; +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + [_BASE] = KEYMAP( + KC_ESC, RESET, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC, KC_MUTE, + KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSLS, + KC_CAPS, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT, + KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, KC_UP, + KC_LCTL, KC_LGUI, KC_LALT, KC_VOLD, KC_VOLU, KC_SPC, KC_RALT, MO(1), KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT), + + [_FN] = KEYMAP( + KC_GRV, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_DEL, TO(_BASE), + KC_TRNS, KC_TRNS, KC_UP, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_LEFT, KC_DOWN, KC_RGHT, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_CAPS, + KC_TRNS, RGB_TOG, RGB_MOD, RGB_MODE_REVERSE, RGB_VAI, RGB_VAD, RGB_SPI, RGB_SPD, RGB_MODE_PLAIN, RGB_MODE_BREATHE, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS), + + [_SYS] = KEYMAP( + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS), + + [_USER] = KEYMAP( + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS) +}; + + + +#ifdef ENCODER_ENABLE +void encoder_update_user(uint8_t index, bool clockwise) { + uprintf("%ud raw g_rgb_time\n", g_rgb_timer); + uprintf("%ud rgb speed\n", rgb_matrix_config.speed); + + // uprintf("%ud g_rgb_time scale8\n", scale16by8(g_rgb_timer, rgb_matrix_config.speed / 4)); + if (clockwise) { + uint16_t keycode = dynamic_keymap_get_keycode(biton32(layer_state), 4, 3); + if (keycode >= MACRO00 && keycode <= MACRO15) { + dynamic_keymap_macro_send(keycode - MACRO00); + } else { + register_code16(keycode); + wait_ms(10); + unregister_code16(keycode); + } + } else { + uint16_t keycode = dynamic_keymap_get_keycode(biton32(layer_state), 4, 4); + if (keycode >= MACRO00 && keycode <= MACRO15) { + dynamic_keymap_macro_send(keycode - MACRO00); + } else { + register_code16(keycode); + wait_ms(10); + unregister_code16(keycode); + } + } +} +#endif + +#ifdef OLED_DRIVER_ENABLE +char wpm_str[10]; // limit WPM string length. +char rgbStatus[26] = {0}; + +oled_rotation_t oled_init_user(oled_rotation_t rotation) { + // oled_scroll_set_area(0,2); + // oled_scroll_set_speed(4); + // oled_scroll_right(); + return OLED_ROTATION_0; +} + + + + +void oled_task_user(void) { + + switch (biton32(layer_state)) { + case 0: + const char a[] = {0x00, 0x63, 0x1E, 0x14, 0x33, 0x20}; + oled_write_raw(a, 0*32+7); + oled_write_ln("Layer: Base", false); + break; + case 1: + oled_write_ln("Layer: Function", false); + break; + case 2: + oled_write_ln("Layer: System", false); + break; + case 3: + oled_write_ln("Layer: User", false); + break; + default: + oled_write_ln("Layer: Undefine", false); + } + oled_write_P((get_mods() & MOD_MASK_SHIFT) ? "SF>* " : "SF>x ", false); + oled_write_P((get_mods() & MOD_MASK_CTRL) ? "CT>* " : "CT>x ", false); + oled_write_P((get_mods() & MOD_MASK_ALT) ? "AL>* " : "AL>x ", false); + oled_write_ln((get_mods() & MOD_MASK_GUI) ? "GU>*" : "GU>x", false); + + + if (rgb_matrix_is_enabled()) { + snprintf(rgbStatus, sizeof(rgbStatus), "RGB:o M:%d", rgb_matrix_get_mode()); + oled_write_ln(rgbStatus, false); + } else { + snprintf(rgbStatus, sizeof(rgbStatus), "RGB:x M:x", rgb_matrix_get_mode()); + oled_write_ln(rgbStatus, false); + } + snprintf(wpm_str, sizeof(wpm_str), "APM:%03d", get_current_wpm()); + oled_write_ln(wpm_str, false); +} +#endif + +#define RAW_HID_CUM + + +#ifdef RAW_HID_CUM +extern uint8_t global_r_power_state[MATRIX_ROWS]; +extern uint8_t global_c_power_state[MATRIX_COLS]; +uint8_t pre_rgb_mode = 0xff; +void raw_hid_receive_kb(uint8_t *data, uint8_t length) { + // Your code goes here. data is the packet received from host. + switch (data[0]) { + case 60: + switch (data[1]) { + case 1: + rgb_matrix_toggle_noeeprom(); + break; + case 2: + rgb_matrix_enable_noeeprom(); + break; + case 3: + rgb_matrix_disable_noeeprom(); + break; + case 4: + if (rgb_matrix_get_mode() != RGB_MATRIX_CUSTOM_AUDIO_VISUALIZATION_COL) { + pre_rgb_mode = rgb_matrix_get_mode(); + rgb_matrix_mode(RGB_MATRIX_CUSTOM_AUDIO_VISUALIZATION_COL); + } else { + rgb_matrix_mode(pre_rgb_mode); + } + break; + case 5: + if (rgb_matrix_get_mode() != RGB_MATRIX_CUSTOM_AUDIO_VISUALIZATION_ROW) { + pre_rgb_mode = rgb_matrix_get_mode(); + rgb_matrix_mode(RGB_MATRIX_CUSTOM_AUDIO_VISUALIZATION_ROW); + } else { + rgb_matrix_mode(pre_rgb_mode); + } + case 6: + if (rgb_matrix_get_mode() == RGB_MATRIX_CUSTOM_AUDIO_VISUALIZATION_ROW) { + for (uint8_t i = 0; i < length; ++i) { + global_r_power_state[i] = data[2+i]; + } + } else if (rgb_matrix_get_mode() == RGB_MATRIX_CUSTOM_AUDIO_VISUALIZATION_COL) { + for (uint8_t i = 0; i < length; ++i) { + global_c_power_state[i] = data[2+i]; + } + } else { + dprint("BAD: not in the audio visual mod."); + } + break; + case 7: + rgb_matrix_mode(data[2]); + default: + break; + } + break; + case 66: + dprint("GOOD: 6666"); + break; + default: + break; + } + raw_hid_send(data, 32); +} +#endif + + + +#ifdef CONSOLE_ENABLE +void keyboard_post_init_user(void) { + // eeconfig_init(); + // Customise these values to desired behaviour + debug_enable=true; + // debug_matrix=true; + // debug_keyboard=true; + //debug_mouse=true; +} +#endif diff --git a/keyboards/yandrstudio/rainbow65/keymaps/test_rgb/rgb_matrix_user.inc b/keyboards/yandrstudio/rainbow65/keymaps/test_rgb/rgb_matrix_user.inc new file mode 100755 index 000000000000..03aa3b20015b --- /dev/null +++ b/keyboards/yandrstudio/rainbow65/keymaps/test_rgb/rgb_matrix_user.inc @@ -0,0 +1,98 @@ +/* +Copyright 2020 Evy Dekkers + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +RGB_MATRIX_EFFECT(AUDIO_VISUALIZATION_COL) +RGB_MATRIX_EFFECT(AUDIO_VISUALIZATION_ROW) + + +#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS +uint8_t global_r_power_state[MATRIX_ROWS]; +uint8_t global_c_power_state[MATRIX_COLS]; + +// bool AUDIO_VISUALIZATION_COL(effect_params_t* params) { +// // HSV hsv = rgb_matrix_config.hsv; +// // RGB rgb = hsv_to_rgb(hsv); +// RGB_MATRIX_USE_LIMITS(led_min, led_max); +// for (uint8_t i = led_min ; i < led_max; i++) { +// rgb_matrix_set_color(i, global_r_state[i], global_g_state[i], global_b_state[i]); +// } +// return led_max < DRIVER_LED_TOTAL; +// } + + + + +static HSV AUDIO_VISUALIZATION_COL_math(HSV hsv, uint8_t i, uint8_t time) { + // uint8_t cur_row = (uint8_t)((MATRIX_ROWS-1)*g_led_config.point[i].y/64); + uint8_t cur_col = (uint8_t)((MATRIX_COLS-1)*g_led_config.point[i].x/224); + uint8_t cur_row2height_index = MATRIX_ROWS - (uint8_t)((MATRIX_ROWS-1)*g_led_config.point[i].y/64) - 1; + uint8_t max_height_cur_col = (uint8_t)(global_c_power_state[cur_col]*MATRIX_ROWS/10); + + if (max_height_cur_col >= 1 && (max_height_cur_col - 1) >= cur_row2height_index) { + hsv.h += abs8(g_led_config.point[i].y - k_rgb_matrix_center.y) + (g_led_config.point[i].x - time); + } else { + hsv.h = 0; + hsv.v = 0; + } + return hsv; +} + +static HSV AUDIO_VISUALIZATION_ROW_math(HSV hsv, uint8_t i, uint8_t time) { + uint8_t cur_row = (uint8_t)((MATRIX_ROWS-1)*g_led_config.point[i].y/64); + // uint8_t cur_col2height_index = MATRIX_COLS - (uint8_t)((MATRIX_COLS-1)*g_led_config.point[i].x/224) - 1; + uint8_t cur_col2height_index = (uint8_t)((MATRIX_COLS-1)*g_led_config.point[i].x/224); + + uint8_t max_height_cur_row = (uint8_t)(global_r_power_state[cur_row]*MATRIX_COLS/10); + + + if (max_height_cur_row >= 1 && (max_height_cur_row - 1) >= cur_col2height_index) { + hsv.h += abs8(g_led_config.point[i].y - k_rgb_matrix_center.y) + (g_led_config.point[i].x - time); + } else { + hsv.h = 0; + hsv.v = 0; + } + return hsv; +} +bool AUDIO_VISUALIZATION_COL(effect_params_t* params) { + // HSV hsv = rgb_matrix_config.hsv; + // RGB rgb = hsv_to_rgb(hsv); + return effect_runner_i(params, &AUDIO_VISUALIZATION_COL_math); +} + +bool AUDIO_VISUALIZATION_ROW(effect_params_t* params) { + return effect_runner_i(params, &AUDIO_VISUALIZATION_ROW_math); +} +// static HSV RAINBOW_MOVING_CHEVRON_math(HSV hsv, uint8_t i, uint8_t time) { +// hsv.h += abs8(g_led_config.point[i].y - k_rgb_matrix_center.y) + (g_led_config.point[i].x - time); +// return hsv; +// } +// static HSV RAINBOW_BEACON_math(HSV hsv, int8_t sin, int8_t cos, uint8_t i, uint8_t time) { +// hsv.h += ((g_led_config.point[i].y - k_rgb_matrix_center.y) * 2 * cos + (g_led_config.point[i].x - k_rgb_matrix_center.x) * 2 * sin) / 128; +// return hsv; +// } +// static HSV RAINBOW_PINWHEELS_math(HSV hsv, int8_t sin, int8_t cos, uint8_t i, uint8_t time) { +// hsv.h += ((g_led_config.point[i].y - k_rgb_matrix_center.y) * 3 * cos + (56 - abs8(g_led_config.point[i].x - k_rgb_matrix_center.x)) * 3 * sin) / 128; +// return hsv; +// } + +// bool RAINBOW_PINWHEELS(effect_params_t* params) { return effect_runner_sin_cos_i(params, &RAINBOW_PINWHEELS_math); } +// bool RAINBOW_BEACON(effect_params_t* params) { return effect_runner_sin_cos_i(params, &RAINBOW_BEACON_math); } +// bool RAINBOW_MOVING_CHEVRON(effect_params_t* params) { return effect_runner_i(params, &RAINBOW_MOVING_CHEVRON_math); } + + + +#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS diff --git a/keyboards/yandrstudio/rainbow65/keymaps/test_rgb/rules.mk b/keyboards/yandrstudio/rainbow65/keymaps/test_rgb/rules.mk new file mode 100755 index 000000000000..ffdf2ad688ec --- /dev/null +++ b/keyboards/yandrstudio/rainbow65/keymaps/test_rgb/rules.mk @@ -0,0 +1,5 @@ +VIA_ENABLE = yes +WPM_ENABLE = yes +RGB_MATRIX_CUSTOM_USER = yes +CONSOLE_ENABLE = yes +OLED_DRIVER_ENABLE = yes diff --git a/keyboards/yandrstudio/rainbow65/keymaps/test_via/config.h b/keyboards/yandrstudio/rainbow65/keymaps/test_via/config.h new file mode 100644 index 000000000000..ca4e95960601 --- /dev/null +++ b/keyboards/yandrstudio/rainbow65/keymaps/test_via/config.h @@ -0,0 +1,18 @@ +/* OLED */ +#ifdef OLED_DRIVER_ENABLE +// # define OLED_DISPLAY_128X64 +# define I2C_DRIVER I2CD1 +# define I2C1_TIMINGR_PRESC 0U +# define I2C1_TIMINGR_SCLDEL 7U +# define I2C1_TIMINGR_SDADEL 0U +# define I2C1_TIMINGR_SCLH 38U +# define I2C1_TIMINGR_SCLL 129U +# define OLED_BRIGHTNESS 50 +# define OLED_TIMEOUT 300000 +// # define OLED_TIMEOUT 0 +# define OLED_FONT_HEIGHT 8 +# define OLED_FONT_WIDTH 6 +# define OLED_FONT_H "../../jason_fount.c" +# define OLED_FONT_END 127 +# define OLED_FONT_START 0 +#endif diff --git a/keyboards/yandrstudio/rainbow65/keymaps/test_via/keymap.c b/keyboards/yandrstudio/rainbow65/keymaps/test_via/keymap.c new file mode 100755 index 000000000000..2137f7d18a1a --- /dev/null +++ b/keyboards/yandrstudio/rainbow65/keymaps/test_via/keymap.c @@ -0,0 +1,114 @@ +#include "rainbow65.h" +#include +#include "dynamic_keymap.h" + +enum layer_names { _BASE, _FN, _SYS, _USER }; +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + [_BASE] = KEYMAP( + KC_ESC, RESET, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC, KC_MUTE, + KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSLS, + KC_CAPS, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT, + KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, KC_UP, + KC_LCTL, KC_LGUI, KC_LALT, KC_VOLD, KC_VOLU, KC_SPC, KC_RALT, MO(1), KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT), + + [_FN] = KEYMAP( + KC_GRV, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_DEL, TO(_BASE), + KC_TRNS, KC_TRNS, KC_UP, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_LEFT, KC_DOWN, KC_RGHT, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_CAPS, + KC_TRNS, RGB_TOG, RGB_MOD, RGB_MODE_REVERSE, RGB_VAI, RGB_VAD, RGB_SPI, RGB_SPD, RGB_MODE_PLAIN, RGB_MODE_BREATHE, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS), + + [_SYS] = KEYMAP( + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS), + + [_USER] = KEYMAP( + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS) +}; + + + +#ifdef ENCODER_ENABLE +void encoder_update_user(uint8_t index, bool clockwise) { + if (clockwise) { + uint16_t keycode = dynamic_keymap_get_keycode(biton32(layer_state), 4, 3); + if (keycode >= MACRO00 && keycode <= MACRO15) { + dynamic_keymap_macro_send(keycode - MACRO00); + } else { + register_code16(keycode); + wait_ms(10); + unregister_code16(keycode); + } + } else { + uint16_t keycode = dynamic_keymap_get_keycode(biton32(layer_state), 4, 4); + if (keycode >= MACRO00 && keycode <= MACRO15) { + dynamic_keymap_macro_send(keycode - MACRO00); + } else { + register_code16(keycode); + wait_ms(10); + unregister_code16(keycode); + } + } +} +#endif + +#ifdef OLED_DRIVER_ENABLE +char wpm_str[10]; // limit WPM string length. +char rgbStatus[26] = {0}; + +void oled_write_ln_col(const char *data, bool invert) { + +} + +oled_rotation_t oled_init_user(oled_rotation_t rotation) { + // oled_scroll_set_area(0,2); + // oled_scroll_set_speed(4); + // oled_scroll_right(); + return OLED_ROTATION_0; +} +void oled_task_user(void) { + switch (biton32(layer_state)) { + case 0: + oled_write_ln("Layer: Base", false); + break; + case 1: + oled_write_ln("Layer: Function", false); + break; + case 2: + oled_write_ln("Layer: System", false); + break; + case 3: + oled_write_ln("Layer: User", false); + break; + default: + oled_write_ln("Layer: Undefine", false); + } + oled_write_P((get_mods() & MOD_MASK_SHIFT) ? "SF>* " : "SF>x ", false); + oled_write_P((get_mods() & MOD_MASK_CTRL) ? "CT>* " : "CT>x ", false); + oled_write_P((get_mods() & MOD_MASK_ALT) ? "AL>* " : "AL>x ", false); + oled_write_ln((get_mods() & MOD_MASK_GUI) ? "GU>*" : "GU>x", false); + + if (rgb_matrix_is_enabled()) { + snprintf(rgbStatus, sizeof(rgbStatus), "RGB: M:[%d]", rgb_matrix_get_mode()); + oled_write_ln(rgbStatus, false); + } else { + snprintf(rgbStatus, sizeof(rgbStatus), "RGB: M:[x]"); + oled_write_ln(rgbStatus, false); + } + snprintf(wpm_str, sizeof(wpm_str), "APM:%03d", get_current_wpm()); + oled_write_ln(wpm_str, false); +} +#endif + + + +// void keyboard_post_init_user(void) { +// eeconfig_init(); +// } diff --git a/keyboards/yandrstudio/rainbow65/keymaps/test_via/rules.mk b/keyboards/yandrstudio/rainbow65/keymaps/test_via/rules.mk new file mode 100755 index 000000000000..70767b0f26e9 --- /dev/null +++ b/keyboards/yandrstudio/rainbow65/keymaps/test_via/rules.mk @@ -0,0 +1,4 @@ +VIA_ENABLE = yes +OPT_ENABLE = yes +WPM_ENABLE = yes +OLED_DRIVER_ENABLE = yes diff --git a/keyboards/yandrstudio/rainbow65/mcuconf.h b/keyboards/yandrstudio/rainbow65/mcuconf.h new file mode 100755 index 000000000000..c0d3c1a16bf5 --- /dev/null +++ b/keyboards/yandrstudio/rainbow65/mcuconf.h @@ -0,0 +1,14 @@ +#pragma once + +#include_next + +#undef STM32_SPI_USE_SPI1 +#define STM32_SPI_USE_SPI1 FALSE + +#undef STM32_SPI_USE_SPI2 +#define STM32_SPI_USE_SPI2 TRUE + + + +#define STM32_I2C_USE_I2C1 TRUE +#define STM32_I2C_USE_I2C2 FALSE diff --git a/keyboards/yandrstudio/rainbow65/r65.json b/keyboards/yandrstudio/rainbow65/r65.json new file mode 100755 index 000000000000..f3b05c45aaf7 --- /dev/null +++ b/keyboards/yandrstudio/rainbow65/r65.json @@ -0,0 +1,157 @@ +{ + "name": "R65_test", + "vendorId": "0xFEED", + "productId": "0x6060", + "lighting": "qmk_rgblight", + "matrix": { "rows": 5, "cols": 15 }, + "layouts": { + "keymap": + [ + [ + { + "name": "via" + }, + [ + "0,0", + "0,1", + "0,2", + "0,3", + "0,4", + "0,5", + "0,6", + "0,7", + "0,8", + "0,9", + "0,10", + "0,11", + "0,12", + { + "w": 2 + }, + "0,13", + { + "x": 1 + }, + "0,14" + ], + [ + { + "y": -0.75, + "x": 15.25, + "w": 0.75, + "h": 0.75 + }, + "4,3", + { + "x": 1, + "w": 0.75, + "h": 0.75 + }, + "4,4" + ], + [ + { + "y": -0.25, + "w": 1.5 + }, + "1,0", + "1,1", + "1,2", + "1,3", + "1,4", + "1,5", + "1,6", + "1,7", + "1,8", + "1,9", + "1,10", + "1,11", + "1,12", + { + "w": 1.5 + }, + "1,13" + ], + [ + { + "w": 1.75 + }, + "2,0", + "2,1", + "2,2", + "2,3", + "2,4", + "2,5", + "2,6", + "2,7", + "2,8", + "2,9", + "2,10", + "2,11", + { + "w": 2.25 + }, + "2,12" + ], + [ + { + "w": 2.25 + }, + "3,0", + "3,1", + "3,2", + "3,3", + "3,4", + "3,5", + "3,6", + "3,7", + "3,8", + "3,9", + "3,10", + { + "w": 1.75 + }, + "3,11" + ], + [ + { + "y": -0.75, + "x": 14.25 + }, + "3,12" + ], + [ + { + "y": -0.25, + "w": 1.25 + }, + "4,0", + { + "w": 1.25 + }, + "4,1", + { + "w": 1.25 + }, + "4,2", + { + "w": 6.25 + }, + "4,5", + "4,8", + "4,9", + "4,10" + ], + [ + { + "y": -0.75, + "x": 13.25 + }, + "4,11", + "4,12", + "4,13" + ] + ] + ] + } +} diff --git a/keyboards/yandrstudio/rainbow65/rainbow65.c b/keyboards/yandrstudio/rainbow65/rainbow65.c new file mode 100755 index 000000000000..6a58312059dd --- /dev/null +++ b/keyboards/yandrstudio/rainbow65/rainbow65.c @@ -0,0 +1,76 @@ +#include "rainbow65.h" + + +#ifdef RGB_MATRIX_ENABLE +led_config_t g_led_config = { + { + // Key Matrix to LED Index + //clo + // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 // r0 + { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, NO_LED}, + {14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, NO_LED}, + {28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, NO_LED, NO_LED}, + {41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, NO_LED, NO_LED}, + {54, 55, 56, NO_LED, NO_LED, 59, NO_LED, NO_LED, 62, 63, 64, 65, 66, 67, NO_LED}, + }, + { + // LED Index to Physical Position + {0, 0}, {16, 0}, {32, 0}, {48, 0}, {64, 0}, {80, 0}, {96, 0}, {112, 0}, {128, 0}, {144, 0}, {160, 0}, {176, 0}, {192, 0}, {208, 0}, + {0, 16}, {16, 16}, {32, 16}, {48, 16}, {64, 16}, {80, 16}, {96, 16}, {112, 16}, {128, 16}, {144, 16}, {160, 16}, {176, 16}, {192, 16}, {208, 16}, + {0, 32}, {16, 32}, {32, 32}, {48, 32}, {64, 32}, {80, 32}, {96, 32}, {112, 32}, {128, 32}, {144, 32}, {160, 32}, {176, 32}, {192, 32}, + {0, 48}, {16, 48}, {32, 48}, {48, 48}, {64, 48}, {80, 48}, {96, 48}, {112, 48}, {128, 48}, {144, 48}, {160, 48}, {176, 48}, {192, 48}, + {0, 64}, {16, 64}, {32, 64}, {48, 64}, {64, 64}, {80, 64}, {96, 64}, {112, 64}, {128, 64}, {144, 64}, {160, 64}, {176, 64}, {192, 64}, {208, 64}, + + }, + { + // LED Index to Flag + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 255, 255, 4, 255, 255, 4, 4, 4, 4, 4, 4, + } +}; + +// void rgb_matrix_indicators_kb(void) { +// if (rgb_matrix_is_enabled()) { +// if (biton32(layer_state) == 1) { // UPPER_LAYER = BLUE +// rgb_matrix_set_color(57, 100, 0, 0); +// rgb_matrix_set_color(58, 0, 100, 0); +// rgb_matrix_set_color(60, 100, 0, 0); +// rgb_matrix_set_color(61, 100, 0, 0); +// } else if (biton32(layer_state) == 2) +// { +// rgb_matrix_set_color(57, 100, 0, 0); +// rgb_matrix_set_color(58, 100, 0, 0); +// rgb_matrix_set_color(60, 0, 100, 0); +// rgb_matrix_set_color(61, 100, 0, 0); +// } else if (biton32(layer_state) == 3) +// { +// rgb_matrix_set_color(57, 100, 0, 0); +// rgb_matrix_set_color(58, 100, 0, 0); +// rgb_matrix_set_color(60, 100, 0, 0); +// rgb_matrix_set_color(61, 0, 100, 0); +// } else if (biton32(layer_state) != 0) +// { +// rgb_matrix_set_color(57, 150, 0, 0); +// rgb_matrix_set_color(58, 150, 0, 0); +// rgb_matrix_set_color(60, 150, 0, 0); +// rgb_matrix_set_color(61, 150, 0, 0); +// } +// } +// } + +#endif + +#ifdef RGB_DISABLE_WHEN_USB_SUSPENDED +void suspend_power_down_kb(void) { + rgb_matrix_set_suspend_state(true); + suspend_power_down_user(); +} + +void suspend_wakeup_init_kb(void) { + rgb_matrix_set_suspend_state(false); + suspend_wakeup_init_user(); +} +#endif diff --git a/keyboards/yandrstudio/rainbow65/rainbow65.h b/keyboards/yandrstudio/rainbow65/rainbow65.h new file mode 100755 index 000000000000..9d282f269e22 --- /dev/null +++ b/keyboards/yandrstudio/rainbow65/rainbow65.h @@ -0,0 +1,20 @@ +#ifndef RAINBOW65_H +#define RAINBOW65_H + +#include "quantum.h" + +#define KEYMAP( \ + K000, K001, K002, K003, K004, K005, K006, K007, K008, K009, K010, K011, K012, K013, K014, \ + K100, K101, K102, K103, K104, K105, K106, K107, K108, K109, K110, K111, K112, K113, \ + K200, K201, K202, K203, K204, K205, K206, K207, K208, K209, K210, K211, K212, \ + K300, K301, K302, K303, K304, K305, K306, K307, K308, K309, K310, K311, K312, \ + K400, K401, K402, K403, K404, K405, K408, K409, K410, K411, K412, K413 \ +) { \ + { K000, K001, K002, K003, K004, K005, K006, K007, K008, K009, K010, K011, K012, K013, K014 }, \ + { K100, K101, K102, K103, K104, K105, K106, K107, K108, K109, K110, K111, K112, K113, KC_NO}, \ + { K200, K201, K202, K203, K204, K205, K206, K207, K208, K209, K210, K211, K212, KC_NO, KC_NO}, \ + { K300, K301, K302, K303, K304, K305, K306, K307, K308, K309, K310, K311, K312, KC_NO, KC_NO}, \ + { K400, K401, K402, K403, K404, K405, KC_NO, KC_NO, K408, K409, K410, K411, K412, K413, KC_NO} \ +} + +#endif diff --git a/keyboards/yandrstudio/rainbow65/rules.mk b/keyboards/yandrstudio/rainbow65/rules.mk new file mode 100755 index 000000000000..624c6c556c60 --- /dev/null +++ b/keyboards/yandrstudio/rainbow65/rules.mk @@ -0,0 +1,24 @@ +# MCU name +MCU = STM32F303 +BOARD = QMK_PROTON_C +# Build Options +# change yes to no to disable +# +BOOTMAGIC_ENABLE = lite # Virtual DIP switch configuration +MOUSEKEY_ENABLE = yes # Mouse keys +EXTRAKEY_ENABLE = yes # Audio control and System control +COMMAND_ENABLE = yes # Commands for debug and configuration +# if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work +NKRO_ENABLE = yes # USB Nkey Rollover +#RGBLIGHT_ENABLE = yes +RGB_MATRIX_ENABLE = yes +RGB_MATRIX_DRIVER = WS2812 +WS2812_DRIVER = spi +# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE +SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend +WPM_ENABLE = yes # Show APM. +ENCODER_ENABLE = yes +AUTO_SHIFT_ENABLE = no +VELOCIKEY_ENABLE = yes +# TAP_DANCE_ENABLE = yes +DFU_ARGS = -d 0483:df11 -a 0 -s 0x08000000:leave diff --git a/keyboards/yandrstudio/sb65p/config.h b/keyboards/yandrstudio/sb65p/config.h new file mode 100644 index 000000000000..cfd1fbffc2ea --- /dev/null +++ b/keyboards/yandrstudio/sb65p/config.h @@ -0,0 +1,55 @@ +#pragma once +#include "config_common.h" + +/* USB Device descriptor parameter */ +#define VENDOR_ID 0xAA96 +#define PRODUCT_ID 0xAA02 +#define DEVICE_VER 0x0001 +#define MANUFACTURER Jason Ren and Student WTF +#define PRODUCT SB-65P +#define DESCRIPTION Split Biu 65 Plus KB + +/* key matrix size */ +#define MATRIX_ROWS 10 +#define MATRIX_COLS 9 + +/* key matrix pins */ +#define MATRIX_ROW_PINS { B0, B1, B2, B3, B4, B5, B6, B7, C0, C1 } +#define MATRIX_COL_PINS { C2, C3, C4, C5, C6, C7, D0, D1, D2 } +#define UNUSED_PINS + +/* COL2ROW or ROW2COL */ +#define DIODE_DIRECTION COL2ROW + +/* number of backlight levels */ + + +/* Set 0 if debouncing isn't needed */ +#define DEBOUNCING_DELAY 5 + +#define ONESHOT_TIMEOUT 500 + +/* key combination for command */ +#define IS_COMMAND() ( \ + keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \ +) + + +//UART settings for communication with the RF microcontroller +#define SERIAL_UART_BAUD 1000000 +#define SERIAL_UART_DATA UDR1 +#define SERIAL_UART_UBRR (F_CPU / (16UL * SERIAL_UART_BAUD) - 1) +#define SERIAL_UART_TXD_READY (UCSR1A & _BV(UDRE1)) +#define SERIAL_UART_RXD_PRESENT (UCSR1A & _BV(RXC1)) +#define SERIAL_UART_INIT() do { \ + /* baud rate */ \ + UBRR1L = SERIAL_UART_UBRR; \ + /* baud rate */ \ + UBRR1H = SERIAL_UART_UBRR >> 8; \ + /* enable TX and RX */ \ + UCSR1B = _BV(TXEN1) | _BV(RXEN1); \ + /* 8-bit data */ \ + UCSR1C = _BV(UCSZ11) | _BV(UCSZ10); \ + } while(0) + + diff --git a/keyboards/yandrstudio/sb65p/keymaps/default/keymap.c b/keyboards/yandrstudio/sb65p/keymaps/default/keymap.c new file mode 100644 index 000000000000..0ac518e8b751 --- /dev/null +++ b/keyboards/yandrstudio/sb65p/keymaps/default/keymap.c @@ -0,0 +1,45 @@ +#include QMK_KEYBOARD_H + +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + + KEYMAP( + KC_F2, KC_ESC, KC_1, KC_2, KC_3, KC_4, KC_5, + KC_F5, KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, + M(0), KC_CAPS, KC_A, KC_S, KC_D, KC_F, KC_G, + M(1), KC_LSFT, KC_Z, KC_X, KC_C, KC_V, + KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, // left + KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC, KC_MUTE, + KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSLS, KC_VOLU, + KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT, KC_VOLD, + KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_LSFT, KC_UP, + KC_SPC, KC_LALT, MO(1), KC_LCTL, KC_LEFT, KC_DOWN, KC_RIGHT), // right + + KEYMAP( + KC_TRNS, KC_GRAVE, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS) +}; + +const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) { + // keyevent_t event = record->event; + switch (id) { + case 0: + if (record->event.pressed) { + return MACRO( D(LCTL), T(C), U(LCTL), END ); + } + break; + case 1: + if (record->event.pressed) { + return MACRO( D(LCTL), T(V), U(LCTL), END ); + } + break; + } + return MACRO_NONE; +} diff --git a/keyboards/yandrstudio/sb65p/matrix.c b/keyboards/yandrstudio/sb65p/matrix.c new file mode 100644 index 000000000000..3658a28caf68 --- /dev/null +++ b/keyboards/yandrstudio/sb65p/matrix.c @@ -0,0 +1,192 @@ +/* Copyright 2017 Mattia Dal Ben + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +#include +#include +#if defined(__AVR__) +#include +#endif +#include "wait.h" +#include "print.h" +#include "debug.h" +#include "util.h" +#include "matrix.h" +#include "timer.h" + +#if (MATRIX_COLS <= 8) +# define print_matrix_header() print("\nr/c 01234567\n") +# define print_matrix_row(row) print_bin_reverse8(matrix_get_row(row)) +# define matrix_bitpop(i) bitpop(matrix[i]) +# define ROW_SHIFTER ((uint8_t)1) +#elif (MATRIX_COLS <= 16) +# define print_matrix_header() print("\nr/c 0123456789ABCDEF\n") +# define print_matrix_row(row) print_bin_reverse16(matrix_get_row(row)) +# define matrix_bitpop(i) bitpop16(matrix[i]) +# define ROW_SHIFTER ((uint16_t)1) +#elif (MATRIX_COLS <= 32) +# define print_matrix_header() print("\nr/c 0123456789ABCDEF0123456789ABCDEF\n") +# define print_matrix_row(row) print_bin_reverse32(matrix_get_row(row)) +# define matrix_bitpop(i) bitpop32(matrix[i]) +# define ROW_SHIFTER ((uint32_t)1) +#endif + +/* matrix state(1:on, 0:off) */ +static matrix_row_t matrix[MATRIX_ROWS]; + +__attribute__ ((weak)) +void matrix_init_quantum(void) { + matrix_init_kb(); +} + +__attribute__ ((weak)) +void matrix_scan_quantum(void) { + matrix_scan_kb(); +} + +__attribute__ ((weak)) +void matrix_init_kb(void) { + matrix_init_user(); +} + +__attribute__ ((weak)) +void matrix_scan_kb(void) { + matrix_scan_user(); +} + +__attribute__ ((weak)) +void matrix_init_user(void) { +} + +__attribute__ ((weak)) +void matrix_scan_user(void) { +} + +inline +uint8_t matrix_rows(void) { + return MATRIX_ROWS; +} + +inline +uint8_t matrix_cols(void) { + return MATRIX_COLS; +} + +void matrix_init(void) { + + matrix_init_quantum(); +} + +uint8_t matrix_scan(void) +{ + SERIAL_UART_INIT(); + + uint32_t timeout = 0; + + //the s character requests the RF slave to send the matrix + SERIAL_UART_DATA = 's'; + + //trust the external keystates entirely, erase the last data + // 2倍列+1个终止位 + // #define MATRIX_COLS 9 + uint8_t uart_data[19] = {0}; + + //there are 9 bytes corresponding to 9 columns, and an end byte + // 一列一列的接受数据 分左右 还有停止位 + for (uint8_t i = 0; i < 19; i++) { + //wait for the serial data, timeout if it's been too long + //this only happened in testing with a loose wire, but does no + //harm to leave it in here + while(!SERIAL_UART_RXD_PRESENT){ + timeout++; + if (timeout > 10000){ + break; + } + } + // 一次接受的数据只能试8位 + uart_data[i] = SERIAL_UART_DATA; + } + + //check for the end packet, the key state bytes use the LSBs, so 0xE0 + //will only show up here if the correct bytes were recieved + // 判断最后一个位置是否合法 + if (uart_data[18] == 0xE0) + { + //shifting and transferring the keystates to the QMK matrix variable + // 直接把每一行数据复制给matrix,叠加行方法的方便之处便体现出来了 + // 先处理左边的数据,一行一行的处理 + // 由于发过来的是一列一列的数据所以先处理左边 + for (uint8_t i = 0; i < MATRIX_ROWS/2; i++) { + matrix[i] = (matrix_row_t)((uart_data[0] & 1<-2.5e-4)&(data<2.5e-4)] = 0 + # print('data mean after:', data.mean()) + data = np.abs(fft(data, shift))[:int(shift/2)] + # line.set_ydata(data/(math.sqrt(shift/2))) + power_list_show = 0.1*data[fft_samp_indexs[0]] + 0.2*data[fft_samp_indexs[1]] + 0.4*data[fft_samp_indexs[2]] + 0.2*data[fft_samp_indexs[3]] + 0.1*data[fft_samp_indexs[4]] + # print('to max: ', power_list_show/(1e-8+power_list_show.max())*10) + # print('log sum:', np.log1p(power_list_show.sum())) + # print('log:', np.log1p(power_list_show)) + power_list_kb = [] + for i in power_list_show: + for k in power_dict.keys(): + if (i < power_dict[k]): + power_list_kb.append(k) + break + power_list_kb = np.roll(np.array(power_list_kb), int(len(fft_samp_indexs)/4)) + print('power dict:', power_list_kb) + print(q.qsize()) + return power_list_kb + + +## run data init +q = queue.Queue() +def audio_callback(indata, frames, time, status): + """This is called (from a separate thread) for each audio block.""" + if status: + print(status, file=sys.stderr) + # Fancy indexing with mapping creates a (necessary!) copy: + # print('audio input shape:', indata.shape) + q.put(indata.reshape(-1)) + + +def update_plot(frame, rgb_power_list, fft_samp_indexs, line): + """This is called by matplotlib for each plot update. + + Typically, audio callbacks happen more frequently than plot updates, + therefore the queue tends to contain multiple blocks of audio data. + + """ + # while True: + try: + data = q.get() + except queue.Empty: + return + shift = len(data) + # plotdata = np.roll(plotdata, -shift, axis=0) + data = np.array(data) + data = data.reshape(shift) + # print('data shape:', data.shape) + print('data mean:', data.mean()) + data[(data>-2.5e-4)&(data<2.5e-4)] = 0 + print('data mean after:', data.mean()) + data = np.abs(fft(data, shift))[:int(shift/2)] + line.set_ydata(data/(math.sqrt(shift/2))) + genPower2(data, rgb_power_list, fft_samp_indexs) + return [line] + + + + + +def start_audio_dance(row=5, col=10, is_col_visual=True, dev_idx=None): + + ## some pre init cfg + audio_cfg = audioCfg() + kb_rgb_cfg = kbRgbCfg(row, col, is_col_visual) + plt_cfg = pltCfg() + + ## post init + if (kb_rgb_cfg.is_col_visual): + rgb_frq_num = kb_rgb_cfg.rgb_matrix_col + rgb_power_list = np.zeros(kb_rgb_cfg.rgb_matrix_col) + else: + rgb_frq_num = kb_rgb_cfg.rgb_matrix_row + rgb_power_list = np.zeros(kb_rgb_cfg.rgb_matrix_row) + + + try: + if audio_cfg.samplerate is None: + device_info = sd.query_devices(1, 'input') + audio_cfg.samplerate = device_info['default_samplerate'] + + fftlx = np.linspace(0, audio_cfg.samplerate, audio_cfg.length)[:int(audio_cfg.length/2)] + fft_samp_indexs = get_frq_sp_point(rgb_frq_num, samplerate=audio_cfg.samplerate, length=audio_cfg.length, startFrq=25, endFrq=19000) + # plotdata = np.zeros((length, len(args.channels)))[:int(length/2)] + print("window:", audio_cfg.window) + print("samplerate:", audio_cfg.samplerate) + print("downsample", audio_cfg.downsample) + print("channels:", audio_cfg.channels) + print("length:", audio_cfg.length) + # print("plotdataShape:", plotdata.shape) + print('fft_x shape:', fftlx.shape) + + # fig, ax = plt.subplots() + # line = ax.semilogx(fftlx, np.zeros(len(fftlx)))[0] + # if len(audio_cfg.channels) > 1: + # ax.legend(['channel {}'.format(c) for c in audio_cfg.channels], + # loc='lower left', ncol=len(audio_cfg.channels)) + # ax.axis((1e0, audio_cfg.samplerate, 0, 1)) + # ax.set_yticks([0]) + # ax.yaxis.grid(True) + # ax.tick_params(bottom=False, top=False, labelbottom=False, + # right=False, left=False, labelleft=False) + # fig.tight_layout(pad=0) + if (dev_idx is not None): + stream = sd.InputStream(device=dev_idx, + channels=max(audio_cfg.channels),blocksize=audio_cfg.length, + samplerate=audio_cfg.samplerate, callback=audio_callback) + else: + stream = sd.InputStream( + channels=max(audio_cfg.channels),blocksize=audio_cfg.length, + samplerate=audio_cfg.samplerate, callback=audio_callback) + # ani = FuncAnimation(fig, update_plot, interval=plt_cfg.interval, blit=True, fargs=(rgb_power_list, fft_samp_indexs, line)) + # with stream: + # plt.show() + except Exception as e: + print(type(e).__name__ + ': ' + str(e)) + + return stream, rgb_power_list, fft_samp_indexs + +start_audio_dance() \ No newline at end of file diff --git a/keyboards/yandrstudio/utils/BiuMisicDance/yandr_hid_tool.py b/keyboards/yandrstudio/utils/BiuMisicDance/yandr_hid_tool.py new file mode 100755 index 000000000000..63675638e17e --- /dev/null +++ b/keyboards/yandrstudio/utils/BiuMisicDance/yandr_hid_tool.py @@ -0,0 +1,87 @@ +import hid +import platform +import seaborn as sns +import time +import numpy as np +import colorsys +import sys + +from audio_lib import * + + +vid = 0xFEED +pid = 0x6060 +dev = hid.device() + +for dev_info in hid.enumerate(): + if (dev_info['vendor_id'] == vid and dev_info['product_id'] == pid and dev_info['interface_number'] == 1): + dev.open_path(dev_info['path']) + break + +# NOTE: Change the 64 here if your board uses 32-byte RAW_EPSIZE +RAW_EPSIZE = 32 +def pad_message(payload): + return payload + b'\x00' * (RAW_EPSIZE - len(payload)) + +def tobyte(data): + if type(data) is bytes: + return data + else: + return (data).to_bytes(1, 'big') + +def tobytes(data): + data = [0] + data + if (len(data) > RAW_EPSIZE): + raise IndexError + out = b'' + for num in data: + out += tobyte(num) + return out + +# protocol define +''' +[00] + [commond1, commond2, data1, data2, ..., data30] + + +todo: +pack per 10 LED into one report +''' + +# pre-config +LED_KEY_NUM = 5 +LED_INDEX = [i for i in range(LED_KEY_NUM)] +DECAY_WEIGHT = 0.8 +MAX_POW = 150 +MATRIX_ROWS = 5 +MATRIX_COLS = 15 + +# step 1: set the kb rgb effect to be audio_visualization. 4ForCol 5ForRow +audio_mod = 4 +dev.write(tobytes([60, audio_mod])) + +if (audio_mod==4): + is_col_visual = True +else: + is_col_visual = False + +try: + # open stream + stream, rgb_power_list, fft_samp_indexs = start_audio_dance(MATRIX_ROWS, MATRIX_COLS, is_col_visual) + # some algorithm for audio visualization + with stream: + while True: + if (audio_mod == 4): + # rgb_power = (np.random.rand(MATRIX_COLS)*10).astype(np.int).tolist() + rgb_power = get_power(MATRIX_COLS, rgb_power_list, fft_samp_indexs).tolist() + else: + # rgb_power = (np.random.rand(MATRIX_ROWS)*10).astype(np.int).tolist() + rgb_power = get_power(MATRIX_ROWS, rgb_power_list, fft_samp_indexs).tolist() + # print(rgb_power) + dev.write(tobytes([60, 6]+rgb_power)) + time.sleep(0.01) + +except KeyboardInterrupt: + # recover pre mold + dev.write(tobytes([60, audio_mod])) + print("exit") + sys.exit() diff --git a/keyboards/yandrstudio/utils/BiuMisicDance/yandr_hid_tool_test.py b/keyboards/yandrstudio/utils/BiuMisicDance/yandr_hid_tool_test.py new file mode 100755 index 000000000000..320c6eab7ab8 --- /dev/null +++ b/keyboards/yandrstudio/utils/BiuMisicDance/yandr_hid_tool_test.py @@ -0,0 +1,30 @@ +import hid +vid = 0xFEED +pid = 0x6060 +h = hid.device() +h.open(vid,pid) +print(f'Device manufacturer: {h.get_manufacturer_string()}') +print(f'Product: {h.get_product_string()}') +h.set_nonblocking(1) +h.write(bytes([3,5])) + +# NOTE: Change the 64 here if your board uses 32-byte RAW_EPSIZE +def pad_message(payload): + return payload + b'\x00' * (32 - len(payload)) + +def tobyte(data): + if type(data) is bytes: + return data + else: + return (data).to_bytes(1, 'big') + +def tobytes(data): + out = b'' + for num in data: + out += tobyte(num) + return out + + +# print(f'Serial Number: {h.serial}') +# # 0x03,!0x02...... +# #h.send_feature_report(b'\0x03\0x44') diff --git a/keyboards/yandrstudio/utils/Font/font_user.py b/keyboards/yandrstudio/utils/Font/font_user.py new file mode 100755 index 000000000000..eedbf8e899c1 --- /dev/null +++ b/keyboards/yandrstudio/utils/Font/font_user.py @@ -0,0 +1,11 @@ +font = [ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3E, 0x5B, 0x4F, 0x5B, 0x3E, 0x00, 0x3E, 0x6B, 0x4F, 0x6B, 0x3E, 0x00, 0x1C, 0x3E, 0x7C, 0x3E, 0x1C, 0x00, 0x18, 0x3C, 0x7E, 0x3C, 0x18, 0x00, 0x1C, 0x57, 0x7D, 0x57, 0x1C, 0x00, 0x1C, 0x5E, 0x7F, 0x5E, 0x1C, 0x00, 0x00, 0x18, 0x3C, 0x18, 0x00, 0x00, 0xFF, 0xE7, 0xC3, 0xE7, 0xFF, 0x00, 0x00, 0x18, 0x24, 0x18, 0x00, 0x00, 0xFF, 0xE7, 0xDB, 0xE7, 0xFF, 0x00, 0x30, 0x48, 0x3A, 0x06, 0x0E, 0x00, 0x26, 0x29, 0x79, 0x29, 0x26, 0x00, 0x40, 0x7F, 0x05, 0x05, 0x07, 0x00, 0x40, 0x7F, 0x05, 0x25, 0x3F, 0x00, 0x5A, 0x3C, 0xE7, 0x3C, 0x5A, 0x00, 0x7F, 0x3E, 0x1C, 0x1C, 0x08, 0x00, 0x08, 0x1C, 0x1C, 0x3E, 0x7F, 0x00, 0x14, 0x22, 0x7F, 0x22, 0x14, 0x00, 0x5F, 0x5F, 0x00, 0x5F, 0x5F, 0x00, 0x06, 0x09, 0x7F, 0x01, 0x7F, 0x00, 0x00, 0x66, 0x89, 0x95, 0x6A, 0x00, 0x60, 0x60, 0x60, 0x60, 0x60, 0x00, 0x94, 0xA2, 0xFF, 0xA2, 0x94, 0x00, 0x08, 0x04, 0x7E, 0x04, 0x08, 0x00, + 0x10, 0x20, 0x7E, 0x20, 0x10, 0x00, 0x08, 0x08, 0x2A, 0x1C, 0x08, 0x00, 0x08, 0x1C, 0x2A, 0x08, 0x08, 0x00, 0x1E, 0x10, 0x10, 0x10, 0x10, 0x00, 0x0C, 0x1E, 0x0C, 0x1E, 0x0C, 0x00, 0x30, 0x38, 0x3E, 0x38, 0x30, 0x00, 0x06, 0x0E, 0x3E, 0x0E, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5F, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x07, 0x00, 0x00, 0x14, 0x7F, 0x14, 0x7F, 0x14, 0x00, 0x24, 0x2A, 0x7F, 0x2A, 0x12, 0x00, 0x23, 0x13, 0x08, 0x64, 0x62, 0x00, 0x36, 0x49, 0x56, 0x20, 0x50, 0x00, 0x00, 0x08, 0x07, 0x03, 0x00, 0x00, 0x00, 0x1C, 0x22, 0x41, 0x00, 0x00, 0x00, 0x41, 0x22, 0x1C, 0x00, 0x00, 0x2A, 0x1C, 0x7F, 0x1C, 0x2A, 0x00, 0x08, 0x08, 0x3E, 0x08, 0x08, 0x00, 0x00, 0x80, 0x70, 0x30, 0x00, 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x00, 0x00, 0x00, 0x60, 0x60, 0x00, 0x00, 0x20, 0x10, 0x08, 0x04, 0x02, 0x00, 0x3E, 0x51, 0x49, 0x45, 0x3E, 0x00, 0x00, 0x42, 0x7F, 0x40, 0x00, 0x00, + 0x72, 0x49, 0x49, 0x49, 0x46, 0x00, 0x21, 0x41, 0x49, 0x4D, 0x33, 0x00, 0x18, 0x14, 0x12, 0x7F, 0x10, 0x00, 0x27, 0x45, 0x45, 0x45, 0x39, 0x00, 0x3C, 0x4A, 0x49, 0x49, 0x31, 0x00, 0x41, 0x21, 0x11, 0x09, 0x07, 0x00, 0x36, 0x49, 0x49, 0x49, 0x36, 0x00, 0x46, 0x49, 0x49, 0x29, 0x1E, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x40, 0x34, 0x00, 0x00, 0x00, 0x00, 0x08, 0x14, 0x22, 0x41, 0x00, 0x14, 0x14, 0x14, 0x14, 0x14, 0x00, 0x00, 0x41, 0x22, 0x14, 0x08, 0x00, 0x02, 0x01, 0x59, 0x09, 0x06, 0x00, 0x3E, 0x41, 0x5D, 0x59, 0x4E, 0x00, 0x7C, 0x12, 0x11, 0x12, 0x7C, 0x00, 0x7F, 0x49, 0x49, 0x49, 0x36, 0x00, 0x3E, 0x41, 0x41, 0x41, 0x22, 0x00, 0x7F, 0x41, 0x41, 0x41, 0x3E, 0x00, 0x7F, 0x49, 0x49, 0x49, 0x41, 0x00, 0x7F, 0x09, 0x09, 0x09, 0x01, 0x00, 0x3E, 0x41, 0x41, 0x51, 0x73, 0x00, 0x7F, 0x08, 0x08, 0x08, 0x7F, 0x00, 0x00, 0x41, 0x7F, 0x41, 0x00, 0x00, 0x20, 0x40, 0x41, 0x3F, 0x01, 0x00, + 0x7F, 0x08, 0x14, 0x22, 0x41, 0x00, 0x7F, 0x40, 0x40, 0x40, 0x40, 0x00, 0x7F, 0x02, 0x1C, 0x02, 0x7F, 0x00, 0x7F, 0x04, 0x08, 0x10, 0x7F, 0x00, 0x3E, 0x41, 0x41, 0x41, 0x3E, 0x00, 0x7F, 0x09, 0x09, 0x09, 0x06, 0x00, 0x3E, 0x41, 0x51, 0x21, 0x5E, 0x00, 0x7F, 0x09, 0x19, 0x29, 0x46, 0x00, 0x26, 0x49, 0x49, 0x49, 0x32, 0x00, 0x03, 0x01, 0x7F, 0x01, 0x03, 0x00, 0x3F, 0x40, 0x40, 0x40, 0x3F, 0x00, 0x1F, 0x20, 0x40, 0x20, 0x1F, 0x00, 0x3F, 0x40, 0x38, 0x40, 0x3F, 0x00, 0x63, 0x14, 0x08, 0x14, 0x63, 0x00, 0x03, 0x04, 0x78, 0x04, 0x03, 0x00, 0x61, 0x59, 0x49, 0x4D, 0x43, 0x00, 0x00, 0x7F, 0x41, 0x41, 0x41, 0x00, 0x02, 0x04, 0x08, 0x10, 0x20, 0x00, 0x00, 0x41, 0x41, 0x41, 0x7F, 0x00, 0x04, 0x02, 0x01, 0x02, 0x04, 0x00, 0x40, 0x40, 0x40, 0x40, 0x40, 0x00, 0x00, 0x03, 0x07, 0x08, 0x00, 0x00, 0x20, 0x54, 0x54, 0x78, 0x40, 0x00, 0x7F, 0x28, 0x44, 0x44, 0x38, 0x00, 0x38, 0x44, 0x44, 0x44, 0x28, 0x00, + 0x38, 0x44, 0x44, 0x28, 0x7F, 0x00, 0x38, 0x54, 0x54, 0x54, 0x18, 0x00, 0x00, 0x08, 0x7E, 0x09, 0x02, 0x00, 0x18, 0xA4, 0xA4, 0x9C, 0x78, 0x00, 0x7F, 0x08, 0x04, 0x04, 0x78, 0x00, 0x00, 0x44, 0x7D, 0x40, 0x00, 0x00, 0x20, 0x40, 0x40, 0x3D, 0x00, 0x00, 0x7F, 0x10, 0x28, 0x44, 0x00, 0x00, 0x00, 0x41, 0x7F, 0x40, 0x00, 0x00, 0x7C, 0x04, 0x78, 0x04, 0x78, 0x00, 0x7C, 0x08, 0x04, 0x04, 0x78, 0x00, 0x38, 0x44, 0x44, 0x44, 0x38, 0x00, 0xFC, 0x18, 0x24, 0x24, 0x18, 0x00, 0x18, 0x24, 0x24, 0x18, 0xFC, 0x00, 0x7C, 0x08, 0x04, 0x04, 0x08, 0x00, 0x48, 0x54, 0x54, 0x54, 0x24, 0x00, 0x04, 0x04, 0x3F, 0x44, 0x24, 0x00, 0x3C, 0x40, 0x40, 0x20, 0x7C, 0x00, 0x1C, 0x20, 0x40, 0x20, 0x1C, 0x00, 0x3C, 0x40, 0x30, 0x40, 0x3C, 0x00, 0x44, 0x28, 0x10, 0x28, 0x44, 0x00, 0x4C, 0x90, 0x90, 0x90, 0x7C, 0x00, 0x44, 0x64, 0x54, 0x4C, 0x44, 0x00, 0x00, 0x08, 0x36, 0x41, 0x00, 0x00, 0x00, 0x00, 0x77, 0x00, 0x00, 0x00, + 0x00, 0x41, 0x36, 0x08, 0x00, 0x00, 0x02, 0x01, 0x02, 0x04, 0x02, 0x00, 0x3C, 0x26, 0x23, 0x26, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x40, 0x40, 0xF0, 0xF8, 0xF8, 0xFF, 0x38, 0xFF, 0xF8, 0xF8, 0x3F, 0xF8, 0xF8, 0xFF, 0x38, 0xFF, 0xF8, 0xF8, 0xF0, 0x40, 0x40, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xC0, 0xC0, 0xC0, 0x80, 0x00, 0x00, 0xC0, 0xC0, 0x80, 0x00, 0x00, 0x00, 0x80, 0xC0, 0xC0, 0x00, 0xC0, 0xC0, 0x00, 0x00, 0x80, 0xC0, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0x00, 0xC0, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xF0, 0xF8, 0xFC, 0x3E, + 0x1E, 0x06, 0x01, 0x00, 0x00, 0x00, 0x7F, 0x41, 0x41, 0x41, 0x7F, 0x00, 0x7F, 0x41, 0x41, 0x41, 0x7F, 0x00, 0x00, 0x80, 0xC0, 0xE0, 0x7E, 0x5B, 0x4F, 0x5B, 0xFE, 0xC0, 0x00, 0x00, 0xC0, 0x00, 0xDC, 0xD7, 0xDE, 0xDE, 0xDE, 0xD7, 0xDC, 0x00, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x49, 0x49, 0x49, 0xFF, 0xFF, 0xFF, 0xFF, 0xE0, 0xDF, 0xBF, 0xBF, 0x00, 0xBF, 0xBF, 0xDF, 0xE0, 0xFF, 0xFF, 0xFF, 0xFF, 0x49, 0x49, 0x49, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x3F, 0x60, 0x60, 0xE0, 0xBF, 0x1F, 0x00, 0x7F, 0x7F, 0x07, 0x1E, 0x38, 0x1E, 0x07, 0x7F, 0x7F, 0x00, 0x7F, 0x7F, 0x0E, 0x1F, 0x3B, 0x71, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0x7F, 0x0C, 0x0C, 0x0C, 0x00, 0x7E, 0x7E, 0x00, 0x7F, 0x7E, 0x03, 0x03, 0x00, 0x7F, 0x7E, 0x03, 0x03, 0x7E, 0x7E, 0x03, 0x03, 0x7F, 0x7E, 0x00, 0x0F, + 0x3E, 0x70, 0x3C, 0x06, 0x3C, 0x70, 0x3E, 0x0F, 0x00, 0x32, 0x7B, 0x49, 0x49, 0x3F, 0x7E, 0x00, 0x7F, 0x7E, 0x03, 0x03, 0x00, 0x1E, 0x3F, 0x69, 0x69, 0x6F, 0x26, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x0F, 0x1F, 0x3F, 0x3C, 0x78, 0x70, 0x60, 0x00, 0x00, 0x00, 0x7F, 0x41, 0x41, 0x41, 0x7F, 0x00, 0x7F, 0x41, 0x41, 0x41, 0x7F, 0x00, 0x30, 0x7B, 0x7F, 0x78, 0x30, 0x20, 0x20, 0x30, 0x78, 0x7F, 0x3B, 0x00, 0x03, 0x00, 0x0F, 0x7F, 0x0F, 0x0F, 0x0F, 0x7F, 0x0F, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x07, 0x0F, 0x0F, 0x7F, 0x0F, 0x7F, 0x0F, 0x0F, 0x7E, 0x0F, 0x0F, 0x7F, 0x0F, 0x7F, 0x0F, 0x0F, 0x07, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 +] diff --git a/keyboards/yandrstudio/utils/Font/rotate_font_tool.py b/keyboards/yandrstudio/utils/Font/rotate_font_tool.py new file mode 100755 index 000000000000..6efd6817a518 --- /dev/null +++ b/keyboards/yandrstudio/utils/Font/rotate_font_tool.py @@ -0,0 +1,38 @@ +import font_user +# print(font_user.font) +# one_f = [0x3E, 0x5B, 0x4F, 0x5B, 0x3E, 0x00] + +cur_H = 8 +cur_W = 6 + +aim_H = 6 +aim_W = 8 + +def cvo(one_f): + new_one_f = [] + cols_old_t = [] + for f_c in one_f: + c = bin(f_c)[2:].ljust(8, '0')[::-1] + cols_old_t.append(c) + for i in range(aim_W): + cur_str='' + for j in range(cur_W): + cur_str += cols_old_t[j][i] + cur_str += '00' + new_one_f.append(hex(int(cur_str,2))) + return new_one_f +# print(','.join(new_one_f)) +# new_one_f.append(int(c,2)) + +f_num = len(font_user.font)//cur_W + +new_font=[] +for i in range(f_num): + one_f = [] + for j in range(cur_W): + one_f.append(i*cur_W+j) + st = cvo(one_f) + st = ','.join(st)+',' + new_font.append(st) +for i in new_font: + print(i) diff --git a/keyboards/yandrstudio/utils/RGB/getRgbMtrixPosition.js b/keyboards/yandrstudio/utils/RGB/getRgbMtrixPosition.js new file mode 100755 index 000000000000..9254d2af3cca --- /dev/null +++ b/keyboards/yandrstudio/utils/RGB/getRgbMtrixPosition.js @@ -0,0 +1,27 @@ +cal = function gen_rgb_matrix_2(rownum, colnum) { + function get_x(col, colnum){ + var x = 224 / (colnum - 1) * col; + return Math.round(x); + } + function get_y(row, rownum) { + var y = 64 / (rownum - 1) * row; + return Math.round(y); + } + var gen_rgb_matrix_text = new String(); + for (var i = 0; i < colnum; i++) { + var row_rgb_text = new String(); + var xx = get_x(i, colnum).toString(); + for (var j = 0; j < rownum; j++) { + var yy = get_y(j, rownum).toString(); + row_rgb_text += '{' + xx + ',' + yy + '}' + if (i != colnum -1 | j != rownum - 1) { + row_rgb_text += ', '; + } + } + if (i != colnum - 1) { + row_rgb_text += '\n'; + } + gen_rgb_matrix_text += row_rgb_text + } + return gen_rgb_matrix_text + } \ No newline at end of file