aboutsummaryrefslogtreecommitdiff
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
parent3c4fa6800066797fd99872d1fc0909822b20bb96 (diff)
downloadqmk_firmware-44f9017cb8ca8bd646b5561c0b587bab476e3054.tar.gz
qmk_firmware-44f9017cb8ca8bd646b5561c0b587bab476e3054.zip
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
-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 000000000..a1bb75eb4
--- /dev/null
+++ b/keyboards/bm60rgb_iso/keymaps/iso_nordic_sleepmode/config.h
@@ -0,0 +1,34 @@
1/* Copyright 2020 jakobst1n
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#pragma once
18
19/*****************************
20 * SLEEPMODE CONFIG
21 *****************************/
22#define SLEEPMODE_ENABLE // see keymap readme for info about this function.
23
24/* How long the backlight should stay on
25 without any interaction before turning off. */
26#define SLEEPMODE_TIMEOUT 10 // in minutes
27/* Which mode we should enter after the timeout,
28 RGB_MATRIX_NONE to turn off.
29 I thinks RGB_MATRIX_DIGITAL RAIN is pretty :) */
30#define SLEEPMODE_RGB_MODE RGB_MATRIX_NONE
31/* The desired animation speed when in "sleep mode" */
32#define SLEEPMODE_RGB_ANIMATION_SPEED 10
33/* The desired brightness when in "sleep mode" */
34#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 000000000..4e874b26d
--- /dev/null
+++ b/keyboards/bm60rgb_iso/keymaps/iso_nordic_sleepmode/keymap.c
@@ -0,0 +1,116 @@
1/* Copyright 2020 jakobst1n
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16#include QMK_KEYBOARD_H
17
18#ifdef RGB_MATRIX_ENABLE
19#ifdef SLEEPMODE_ENABLE
20 /* A bunch of vars to keep track of the rgb states
21 before sleepmode is turned on */
22 static bool sleepmode_on = false;
23 static uint8_t sleepmode_before_mode = -1;
24 static uint8_t sleepmode_before_brightness = -1;
25 static uint8_t sleepmode_before_anim_speed = -1;
26 static uint8_t halfmin_counter = 0;
27 static uint16_t idle_timer = 0;
28#endif
29#endif
30
31const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
32 /* ,-----------------------------------------------------------.
33 * |ESC| 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | + | ´ | BACK |
34 * |-----------------------------------------------------------|
35 * | TAB | Q | W | E | R | T | Y | U | I | O | P | Å | ¨ | RET |
36 * |------------------------------------------------------\ |
37 * | CAPS | A | S | D | F | G | H | J | K | L | Ø | Æ | @ | |
38 * |-----------------------------------------------------------|
39 * | ^ | < | Z | X | C | V | B | N | M | , | . | ^/- | U | - |
40 * |-----------------------------------------------------------|
41 * |ctrl| win| alt| |alt| fn| L | D | R |
42 * `-----------------------------------------------------------' */
43 [0] = LAYOUT(
44 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,
45 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,
46 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,
47 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,
48 KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, KC_RALT, OSL(1), KC_LEFT, KC_DOWN, KC_RGHT
49 ),
50 /* ,-----------------------------------------------------------.
51 * |GRA| f1| f2| f3| f4| f5| f6| f7| f8| f9|f10|f11|f12| DEL |
52 * |-----------------------------------------------------------|
53 * | | R | R | R | R | R | R | R | R | | | | | |
54 * |------------------------------------------------------\ |
55 * | | | | | | | H |PGD|PGU| E | | | | |
56 * |-----------------------------------------------------------|
57 * | | | | | | | | | | | | |V_D|V_U|
58 * |-----------------------------------------------------------|
59 * | | | | | |PRE|PLA|NEX|
60 * `-----------------------------------------------------------' */
61 [1] = LAYOUT(
62 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,
63 _______, RGB_TOG, RGB_MOD, RGB_HUI, RGB_HUD, RGB_SAI, RGB_SAD, RGB_VAI, RGB_VAD, _______, _______, _______, _______,
64 _______, _______, _______, _______, _______, _______, KC_HOME, KC_PGDN, KC_PGUP, KC_END, _______, _______, _______, _______,
65 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_VOLD, KC_VOLU,
66 _______, _______, _______, _______, _______, _______, KC_MPRV, KC_MPLY, KC_MNXT
67 ),
68};
69
70
71bool process_record_user(uint16_t keycode, keyrecord_t *record) {
72#if defined(RGB_MATRIX_ENABLE) && defined(SLEEPMODE_ENABLE)
73 if (record->event.pressed) {
74 if (sleepmode_before_mode == -1) { sleepmode_before_mode = rgb_matrix_get_mode(); }
75 if (sleepmode_before_brightness == -1) { sleepmode_before_brightness = rgb_matrix_get_val(); }
76 if (sleepmode_before_anim_speed == -1) { sleepmode_before_anim_speed = rgb_matrix_get_speed(); }
77
78 if (sleepmode_on == true) {
79 // rgb_matrix_enable_noeeprom();
80 rgb_matrix_mode_noeeprom(sleepmode_before_mode);
81 rgb_matrix_set_speed_noeeprom(sleepmode_before_anim_speed);
82 rgb_matrix_sethsv_noeeprom(rgb_matrix_get_hue(), rgb_matrix_get_sat(), sleepmode_before_brightness);
83 sleepmode_on = false;
84 }
85 idle_timer = timer_read();
86 halfmin_counter = 0;
87 }
88#endif
89 return true;
90 }
91
92 void matrix_scan_user(void) {
93#if defined(RGB_MATRIX_ENABLE) && defined(SLEEPMODE_ENABLE)
94 /* idle_timer needs to be set one time */
95 if (idle_timer == 0) idle_timer = timer_read();
96
97 if ( !sleepmode_on && timer_elapsed(idle_timer) > 30000) {
98 halfmin_counter++;
99 idle_timer = timer_read();
100 }
101
102 if ( !sleepmode_on && halfmin_counter >= SLEEPMODE_TIMEOUT * 2) {// * 2) {
103 layer_clear();
104 sleepmode_before_anim_speed = rgb_matrix_get_speed();
105 sleepmode_before_brightness = rgb_matrix_get_val();
106 sleepmode_before_mode = rgb_matrix_get_mode();
107 //rgb_matrix_disable_noeeprom();
108
109 rgb_matrix_mode_noeeprom(SLEEPMODE_RGB_MODE);
110 rgb_matrix_set_speed_noeeprom(SLEEPMODE_RGB_ANIMATION_SPEED);
111 rgb_matrix_sethsv_noeeprom(rgb_matrix_get_hue(), rgb_matrix_get_sat(), SLEEPMODE_RGB_VAL);
112 sleepmode_on = true;
113 halfmin_counter = 0;
114 }
115#endif
116}
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 000000000..af5b29da1
--- /dev/null
+++ b/keyboards/bm60rgb_iso/keymaps/iso_nordic_sleepmode/readme.md
@@ -0,0 +1,17 @@
1# Nordic keymap for BM60rgb_iso
2Very few changes from default keyboard, apart from the button right of leftshift,
3and adding some more buttons on the second layer (function keys, home/end, pg up/down and media keys).
4
5On the default layout, the top left button is RESET on the second layer,
6this board has a reset button on the back. So I feel like it serves a better
7purpose as the grave key (because grave-escape doesn't really
8work with mac and norwegian layout). It could of course also be on the base layer.
9But as a regular vim user I use escape more than the grave key.
10
11I have also added mod-tap to the right shift, with the "default" position for
12`KC_SLSH` beeing on the far right, that works fine.
13
14There is also a "sleep-mode" function added,
15this can be enabled defining `SLEEPMODE_ENABLE` in `config.h`.
16This makes the keyboard backlight turn off after 10 minutes without any
17keypresses, and turn on again on keypress. (This is something different than `USB_SUSPEND`)