summaryrefslogtreecommitdiff
path: root/keyboards/bm60rgb_iso/keymaps/iso_nordic_sleepmode
diff options
context:
space:
mode:
authorJakob Stendahl <14180120+JakobST1n@users.noreply.github.com>2020-10-17 06:29:15 +0200
committerGitHub <noreply@github.com>2020-10-16 21:29:15 -0700
commit44f9017cb8ca8bd646b5561c0b587bab476e3054 (patch)
tree5ce4515642aa59d8f36e8f5018b67f390f69f703 /keyboards/bm60rgb_iso/keymaps/iso_nordic_sleepmode
parent3c4fa6800066797fd99872d1fc0909822b20bb96 (diff)
Bm60rgb iso nordic keymap with sleepmode functional (#10510)
* Add nordic keymap Changes from default: - Change button right of `LSHIFT` to `KC_NUBS` - Add some more keys to the second layer. * Add sleepmode functionality Added a sleepmode, this turns of the rgb_matrix if no key was pressed for x minutes. Not default on, so you have to enable it by defining `SLEEPMODE_ENABLED`. * Move all sleepmode config to config.h, rename keymap - Move all configurations for sleepmode to keymap config.h - rename keymap to include reference to it having sleepmode (suggestion from guy the discord-server) - add copyright in config.h * Update keyboards/bm60rgb_iso/keymaps/iso_nordic_sleepmode/config.h * Update keyboards/bm60rgb_iso/keymaps/iso_nordic_sleepmode/keymap.c * Update keyboards/bm60rgb_iso/keymaps/iso_nordic_sleepmode/keymap.c * Update keyboards/bm60rgb_iso/keymaps/iso_nordic_sleepmode/keymap.c * Update keyboards/bm60rgb_iso/keymaps/iso_nordic_sleepmode/keymap.c * Update keyboards/bm60rgb_iso/keymaps/iso_nordic_sleepmode/keymap.c
Diffstat (limited to 'keyboards/bm60rgb_iso/keymaps/iso_nordic_sleepmode')
-rw-r--r--keyboards/bm60rgb_iso/keymaps/iso_nordic_sleepmode/config.h34
-rw-r--r--keyboards/bm60rgb_iso/keymaps/iso_nordic_sleepmode/keymap.c116
-rw-r--r--keyboards/bm60rgb_iso/keymaps/iso_nordic_sleepmode/readme.md17
3 files changed, 167 insertions, 0 deletions
diff --git a/keyboards/bm60rgb_iso/keymaps/iso_nordic_sleepmode/config.h b/keyboards/bm60rgb_iso/keymaps/iso_nordic_sleepmode/config.h
new file mode 100644
index 0000000000..a1bb75eb4a
--- /dev/null
+++ b/keyboards/bm60rgb_iso/keymaps/iso_nordic_sleepmode/config.h
@@ -0,0 +1,34 @@
+/* Copyright 2020 jakobst1n
+ *
+ * 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 <http://www.gnu.org/licenses/>.
+ */
+
+#pragma once
+
+/*****************************
+ * SLEEPMODE CONFIG
+ *****************************/
+#define SLEEPMODE_ENABLE // see keymap readme for info about this function.
+
+/* How long the backlight should stay on
+ without any interaction before turning off. */
+#define SLEEPMODE_TIMEOUT 10 // in minutes
+/* Which mode we should enter after the timeout,
+ RGB_MATRIX_NONE to turn off.
+ I thinks RGB_MATRIX_DIGITAL RAIN is pretty :) */
+#define SLEEPMODE_RGB_MODE RGB_MATRIX_NONE
+/* The desired animation speed when in "sleep mode" */
+#define SLEEPMODE_RGB_ANIMATION_SPEED 10
+/* The desired brightness when in "sleep mode" */
+#define SLEEPMODE_RGB_VAL 10
diff --git a/keyboards/bm60rgb_iso/keymaps/iso_nordic_sleepmode/keymap.c b/keyboards/bm60rgb_iso/keymaps/iso_nordic_sleepmode/keymap.c
new file mode 100644
index 0000000000..4e874b26df
--- /dev/null
+++ b/keyboards/bm60rgb_iso/keymaps/iso_nordic_sleepmode/keymap.c
@@ -0,0 +1,116 @@
+/* Copyright 2020 jakobst1n
+ *
+ * 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 <http://www.gnu.org/licenses/>.
+ */
+#include QMK_KEYBOARD_H
+
+#ifdef RGB_MATRIX_ENABLE
+#ifdef SLEEPMODE_ENABLE
+ /* A bunch of vars to keep track of the rgb states
+ before sleepmode is turned on */
+ static bool sleepmode_on = false;
+ static uint8_t sleepmode_before_mode = -1;
+ static uint8_t sleepmode_before_brightness = -1;
+ static uint8_t sleepmode_before_anim_speed = -1;
+ static uint8_t halfmin_counter = 0;
+ static uint16_t idle_timer = 0;
+#endif
+#endif
+
+const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
+ /* ,-----------------------------------------------------------.
+ * |ESC| 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | + | ´ | BACK |
+ * |-----------------------------------------------------------|
+ * | TAB | Q | W | E | R | T | Y | U | I | O | P | Å | ¨ | RET |
+ * |------------------------------------------------------\ |
+ * | CAPS | A | S | D | F | G | H | J | K | L | Ø | Æ | @ | |
+ * |-----------------------------------------------------------|
+ * | ^ | < | Z | X | C | V | B | N | M | , | . | ^/- | U | - |
+ * |-----------------------------------------------------------|
+ * |ctrl| win| alt| |alt| fn| L | D | R |
+ * `-----------------------------------------------------------' */
+ [0] = LAYOUT(
+ 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_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_CAPS, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_BSLS, KC_ENT,
+ KC_LSFT, KC_NUBS, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, MT(MOD_RSFT, KC_SLSH), KC_UP, KC_SLSH,
+ KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, KC_RALT, OSL(1), KC_LEFT, KC_DOWN, KC_RGHT
+ ),
+ /* ,-----------------------------------------------------------.
+ * |GRA| f1| f2| f3| f4| f5| f6| f7| f8| f9|f10|f11|f12| DEL |
+ * |-----------------------------------------------------------|
+ * | | R | R | R | R | R | R | R | R | | | | | |
+ * |------------------------------------------------------\ |
+ * | | | | | | | H |PGD|PGU| E | | | | |
+ * |-----------------------------------------------------------|
+ * | | | | | | | | | | | | |V_D|V_U|
+ * |-----------------------------------------------------------|
+ * | | | | | |PRE|PLA|NEX|
+ * `-----------------------------------------------------------' */
+ [1] = LAYOUT(
+ 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,
+ _______, RGB_TOG, RGB_MOD, RGB_HUI, RGB_HUD, RGB_SAI, RGB_SAD, RGB_VAI, RGB_VAD, _______, _______, _______, _______,
+ _______, _______, _______, _______, _______, _______, KC_HOME, KC_PGDN, KC_PGUP, KC_END, _______, _______, _______, _______,
+ _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_VOLD, KC_VOLU,
+ _______, _______, _______, _______, _______, _______, KC_MPRV, KC_MPLY, KC_MNXT
+ ),
+};
+
+
+bool process_record_user(uint16_t keycode, keyrecord_t *record) {
+#if defined(RGB_MATRIX_ENABLE) && defined(SLEEPMODE_ENABLE)
+ if (record->event.pressed) {
+ if (sleepmode_before_mode == -1) { sleepmode_before_mode = rgb_matrix_get_mode(); }
+ if (sleepmode_before_brightness == -1) { sleepmode_before_brightness = rgb_matrix_get_val(); }
+ if (sleepmode_before_anim_speed == -1) { sleepmode_before_anim_speed = rgb_matrix_get_speed(); }
+
+ if (sleepmode_on == true) {
+ // rgb_matrix_enable_noeeprom();
+ rgb_matrix_mode_noeeprom(sleepmode_before_mode);
+ rgb_matrix_set_speed_noeeprom(sleepmode_before_anim_speed);
+ rgb_matrix_sethsv_noeeprom(rgb_matrix_get_hue(), rgb_matrix_get_sat(), sleepmode_before_brightness);
+ sleepmode_on = false;
+ }
+ idle_timer = timer_read();
+ halfmin_counter = 0;
+ }
+#endif
+ return true;
+ }
+
+ void matrix_scan_user(void) {
+#if defined(RGB_MATRIX_ENABLE) && defined(SLEEPMODE_ENABLE)
+ /* idle_timer needs to be set one time */
+ if (idle_timer == 0) idle_timer = timer_read();
+
+ if ( !sleepmode_on && timer_elapsed(idle_timer) > 30000) {
+ halfmin_counter++;
+ idle_timer = timer_read();
+ }
+
+ if ( !sleepmode_on && halfmin_counter >= SLEEPMODE_TIMEOUT * 2) {// * 2) {
+ layer_clear();
+ sleepmode_before_anim_speed = rgb_matrix_get_speed();
+ sleepmode_before_brightness = rgb_matrix_get_val();
+ sleepmode_before_mode = rgb_matrix_get_mode();
+ //rgb_matrix_disable_noeeprom();
+
+ rgb_matrix_mode_noeeprom(SLEEPMODE_RGB_MODE);
+ rgb_matrix_set_speed_noeeprom(SLEEPMODE_RGB_ANIMATION_SPEED);
+ rgb_matrix_sethsv_noeeprom(rgb_matrix_get_hue(), rgb_matrix_get_sat(), SLEEPMODE_RGB_VAL);
+ sleepmode_on = true;
+ halfmin_counter = 0;
+ }
+#endif
+}
diff --git a/keyboards/bm60rgb_iso/keymaps/iso_nordic_sleepmode/readme.md b/keyboards/bm60rgb_iso/keymaps/iso_nordic_sleepmode/readme.md
new file mode 100644
index 0000000000..af5b29da19
--- /dev/null
+++ b/keyboards/bm60rgb_iso/keymaps/iso_nordic_sleepmode/readme.md
@@ -0,0 +1,17 @@
+# Nordic keymap for BM60rgb_iso
+Very few changes from default keyboard, apart from the button right of leftshift,
+and adding some more buttons on the second layer (function keys, home/end, pg up/down and media keys).
+
+On the default layout, the top left button is RESET on the second layer,
+this board has a reset button on the back. So I feel like it serves a better
+purpose as the grave key (because grave-escape doesn't really
+work with mac and norwegian layout). It could of course also be on the base layer.
+But as a regular vim user I use escape more than the grave key.
+
+I have also added mod-tap to the right shift, with the "default" position for
+`KC_SLSH` beeing on the far right, that works fine.
+
+There is also a "sleep-mode" function added,
+this can be enabled defining `SLEEPMODE_ENABLE` in `config.h`.
+This makes the keyboard backlight turn off after 10 minutes without any
+keypresses, and turn on again on keypress. (This is something different than `USB_SUSPEND`)