aboutsummaryrefslogtreecommitdiff
path: root/keyboards/duck
diff options
context:
space:
mode:
authorMechMerlin <30334081+mechmerlin@users.noreply.github.com>2018-08-26 09:30:49 -0700
committerDrashna Jaelre <drashna@live.com>2018-08-26 09:30:49 -0700
commita63d4774f5115b91703936183a39a4724b44b94d (patch)
tree3e5e1e394b0c23aed6d187b73755b2eb009c556f /keyboards/duck
parent1ee545014a0415eee8cbe4a3773002fb13371d14 (diff)
downloadqmk_firmware-a63d4774f5115b91703936183a39a4724b44b94d.tar.gz
qmk_firmware-a63d4774f5115b91703936183a39a4724b44b94d.zip
Keyboard: Putting all my ducks in a row: Lightsaver (#3758)
Diffstat (limited to 'keyboards/duck')
-rw-r--r--keyboards/duck/lightsaver/config.h54
-rw-r--r--keyboards/duck/lightsaver/indicator_leds.c91
-rw-r--r--keyboards/duck/lightsaver/indicator_leds.h1
-rw-r--r--keyboards/duck/lightsaver/info.json13
-rw-r--r--keyboards/duck/lightsaver/keymaps/default/keymap.c48
-rw-r--r--keyboards/duck/lightsaver/keymaps/default/readme.md11
-rw-r--r--keyboards/duck/lightsaver/keymaps/rasmus/config.h8
-rw-r--r--keyboards/duck/lightsaver/keymaps/rasmus/keymap.c105
-rw-r--r--keyboards/duck/lightsaver/keymaps/rasmus/readme.md12
-rw-r--r--keyboards/duck/lightsaver/keymaps/rasmus/rules.mk2
-rw-r--r--keyboards/duck/lightsaver/lightsaver.c60
-rw-r--r--keyboards/duck/lightsaver/lightsaver.h40
-rw-r--r--keyboards/duck/lightsaver/matrix.c275
-rw-r--r--keyboards/duck/lightsaver/readme.md19
-rw-r--r--keyboards/duck/lightsaver/rules.mk72
15 files changed, 811 insertions, 0 deletions
diff --git a/keyboards/duck/lightsaver/config.h b/keyboards/duck/lightsaver/config.h
new file mode 100644
index 000000000..bc984c7e5
--- /dev/null
+++ b/keyboards/duck/lightsaver/config.h
@@ -0,0 +1,54 @@
1/*
2Copyright 2017 Rasmus Schults <rasmusx@gmail.com>
3
4This program is free software: you can redistribute it and/or modify
5it under the terms of the GNU General Public License as published by
6the Free Software Foundation, either version 2 of the License, or
7(at your option) any later version.
8
9This program is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12GNU General Public License for more details.
13
14You should have received a copy of the GNU General Public License
15along with this program. If not, see <http://www.gnu.org/licenses/>.
16*/
17
18#ifndef CONFIG_H
19#define CONFIG_H
20
21#include "config_common.h"
22
23/* USB Device descriptor parameter */
24#define VENDOR_ID 0xFEED
25#define PRODUCT_ID 0x1337
26#define DEVICE_VER 0x0003
27#define MANUFACTURER Duck
28#define PRODUCT Lightsaver V3
29#define DESCRIPTION Duck Lightsaver V3
30
31/* key matrix size */
32#define MATRIX_ROWS 6
33#define MATRIX_COLS 19
34
35#define DIODE_DIRECTION COL2ROW
36
37/* Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not needed */
38#define DEBOUNCING_DELAY 5
39
40/* number of backlight levels */
41#define BACKLIGHT_LEVELS 1
42
43/* key combination for magic key command */
44#define IS_COMMAND() ( \
45 keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \
46)
47
48#define RGBLIGHT_ANIMATIONS
49#define RGB_DI_PIN D6
50#define RGBLED_NUM 17
51
52#define TAPPING_TERM 200
53
54#endif
diff --git a/keyboards/duck/lightsaver/indicator_leds.c b/keyboards/duck/lightsaver/indicator_leds.c
new file mode 100644
index 000000000..0a54e151e
--- /dev/null
+++ b/keyboards/duck/lightsaver/indicator_leds.c
@@ -0,0 +1,91 @@
1/*
2Copyright 2016-2017 Ralf Schmitt <ralf@bunkertor.net> Rasmus Schults <rasmusx@gmail.com>
3
4This program is free software: you can redistribute it and/or modify
5it under the terms of the GNU General Public License as published by
6the Free Software Foundation, either version 2 of the License, or
7(at your option) any later version.
8
9This program is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12GNU General Public License for more details.
13
14You should have received a copy of the GNU General Public License
15along with this program. If not, see <http://www.gnu.org/licenses/>.
16*/
17#include <avr/interrupt.h>
18#include <avr/io.h>
19#include <stdbool.h>
20#include <util/delay.h>
21
22#define T1H 900
23#define T1L 600
24#define T0H 400
25#define T0L 900
26#define RES 6000
27
28#define NS_PER_SEC (1000000000L)
29#define CYCLES_PER_SEC (F_CPU)
30#define NS_PER_CYCLE (NS_PER_SEC / CYCLES_PER_SEC)
31#define NS_TO_CYCLES(n) ((n) / NS_PER_CYCLE)
32
33void send_bit_d4(bool bitVal) {
34 if(bitVal) {
35 asm volatile (
36 "sbi %[port], %[bit] \n\t"
37 ".rept %[onCycles] \n\t"
38 "nop \n\t"
39 ".endr \n\t"
40 "cbi %[port], %[bit] \n\t"
41 ".rept %[offCycles] \n\t"
42 "nop \n\t"
43 ".endr \n\t"
44 ::
45 [port] "I" (_SFR_IO_ADDR(PORTD)),
46 [bit] "I" (4),
47 [onCycles] "I" (NS_TO_CYCLES(T1H) - 2),
48 [offCycles] "I" (NS_TO_CYCLES(T1L) - 2));
49 } else {
50 asm volatile (
51 "sbi %[port], %[bit] \n\t"
52 ".rept %[onCycles] \n\t"
53 "nop \n\t"
54 ".endr \n\t"
55 "cbi %[port], %[bit] \n\t"
56 ".rept %[offCycles] \n\t"
57 "nop \n\t"
58 ".endr \n\t"
59 ::
60 [port] "I" (_SFR_IO_ADDR(PORTD)),
61 [bit] "I" (4),
62 [onCycles] "I" (NS_TO_CYCLES(T0H) - 2),
63 [offCycles] "I" (NS_TO_CYCLES(T0L) - 2));
64 }
65}
66
67void show(void) {
68 _delay_us((RES / 1000UL) + 1);
69}
70
71void send_value(uint8_t byte) {
72 for(uint8_t b = 0; b < 8; b++) {
73 send_bit_d4(byte & 0b10000000);
74 byte <<= 1;
75 }
76}
77
78void send_color(uint8_t r, uint8_t g, uint8_t b) {
79 send_value(g);
80 send_value(r);
81 send_value(b);
82}
83
84void indicator_leds_set(bool leds[8]) {
85 cli();
86 send_color(leds[1] ? 255 : 0, leds[2] ? 255 : 0, leds[0] ? 255 : 0);
87 send_color(leds[4] ? 255 : 0, leds[5] ? 255 : 0, leds[3] ? 255 : 0);
88 send_color(leds[6] ? 255 : 0, leds[7] ? 255 : 0, 0);
89 sei();
90 show();
91}
diff --git a/keyboards/duck/lightsaver/indicator_leds.h b/keyboards/duck/lightsaver/indicator_leds.h
new file mode 100644
index 000000000..fe66eef6b
--- /dev/null
+++ b/keyboards/duck/lightsaver/indicator_leds.h
@@ -0,0 +1 @@
void indicator_leds_set(bool leds[8]);
diff --git a/keyboards/duck/lightsaver/info.json b/keyboards/duck/lightsaver/info.json
new file mode 100644
index 000000000..0637ef9a1
--- /dev/null
+++ b/keyboards/duck/lightsaver/info.json
@@ -0,0 +1,13 @@
1{
2 "keyboard_name": "Duck Lightsaver V3",
3 "url": "",
4 "maintainer": "qmk",
5 "width": 19,
6 "height": 6,
7 "layouts": {
8 "LAYOUT": {
9 "key_count": 100,
10 "layout": [{"label":"Esc", "x":0, "y":0}, {"label":"F1", "x":1, "y":0}, {"label":"F2", "x":2, "y":0}, {"label":"F3", "x":3, "y":0}, {"label":"F4", "x":4, "y":0}, {"label":"F5", "x":5, "y":0}, {"label":"F6", "x":6, "y":0}, {"label":"F7", "x":7, "y":0}, {"label":"F8", "x":8, "y":0}, {"label":"F9", "x":9, "y":0}, {"label":"F10", "x":10, "y":0}, {"label":"F11", "x":11, "y":0}, {"label":"F12", "x":12, "y":0}, {"label":"PrtSc", "x":13, "y":0}, {"label":"Num<br>Lock", "x":14, "y":0}, {"label":"Insert", "x":15, "y":0}, {"label":"Home", "x":16, "y":0}, {"label":"PgUp", "x":17, "y":0}, {"label":"/", "x":18, "y":0}, {"label":"~", "x":0, "y":1}, {"label":"!", "x":1, "y":1}, {"label":"@", "x":2, "y":1}, {"label":"#", "x":3, "y":1}, {"label":"$", "x":4, "y":1}, {"label":"%", "x":5, "y":1}, {"label":"^", "x":6, "y":1}, {"label":"&", "x":7, "y":1}, {"label":"*", "x":8, "y":1}, {"label":"(", "x":9, "y":1}, {"label":")", "x":10, "y":1}, {"label":"_", "x":11, "y":1}, {"label":"+", "x":12, "y":1}, {"label":"Bkspc", "x":13, "y":1, "w":2}, {"label":"Delete", "x":15, "y":1}, {"label":"End", "x":16, "y":1}, {"label":"PgDn", "x":17, "y":1}, {"label":"*", "x":18, "y":1}, {"label":"Tab", "x":0, "y":2, "w":1.5}, {"label":"Q", "x":1.5, "y":2}, {"label":"W", "x":2.5, "y":2}, {"label":"E", "x":3.5, "y":2}, {"label":"R", "x":4.5, "y":2}, {"label":"T", "x":5.5, "y":2}, {"label":"Y", "x":6.5, "y":2}, {"label":"U", "x":7.5, "y":2}, {"label":"I", "x":8.5, "y":2}, {"label":"O", "x":9.5, "y":2}, {"label":"P", "x":10.5, "y":2}, {"label":"{", "x":11.5, "y":2}, {"label":"}", "x":12.5, "y":2}, {"label":"|", "x":13.5, "y":2, "w":1.5}, {"label":"7", "x":15, "y":2}, {"label":"8", "x":16, "y":2}, {"label":"9", "x":17, "y":2}, {"label":"-", "x":18, "y":2}, {"label":"CapsLock", "x":0, "y":3, "w":1.75}, {"label":"A", "x":1.75, "y":3}, {"label":"S", "x":2.75, "y":3}, {"label":"D", "x":3.75, "y":3}, {"label":"F", "x":4.75, "y":3}, {"label":"G", "x":5.75, "y":3}, {"label":"H", "x":6.75, "y":3}, {"label":"J", "x":7.75, "y":3}, {"label":"K", "x":8.75, "y":3}, {"label":"L", "x":9.75, "y":3}, {"label":":", "x":10.75, "y":3}, {"label":"\"", "x":11.75, "y":3}, {"label":"Enter", "x":12.75, "y":3, "w":2.25}, {"label":"4", "x":15, "y":3}, {"label":"5", "x":16, "y":3}, {"label":"6", "x":17, "y":3}, {"label":"+", "x":18, "y":3}, {"label":"Shift", "x":0, "y":4, "w":2.25}, {"label":"Z", "x":2.25, "y":4}, {"label":"X", "x":3.25, "y":4}, {"label":"C", "x":4.25, "y":4}, {"label":"V", "x":5.25, "y":4}, {"label":"B", "x":6.25, "y":4}, {"label":"N", "x":7.25, "y":4}, {"label":"M", "x":8.25, "y":4}, {"label":"<", "x":9.25, "y":4}, {"label":">", "x":10.25, "y":4}, {"label":"?", "x":11.25, "y":4}, {"label":"Shift", "x":12.25, "y":4, "w":1.75}, {"label":"\u2191", "x":14, "y":4}, {"label":"1", "x":15, "y":4}, {"label":"2", "x":16, "y":4}, {"label":"3", "x":17, "y":4}, {"label":"Enter", "x":18, "y":4, "h":2}, {"label":"Ctrl", "x":0, "y":5, "w":1.25}, {"label":"Win", "x":1.25, "y":5, "w":1.25}, {"label":"Alt", "x":2.5, "y":5, "w":1.25}, {"x":3.75, "y":5, "w":6.25}, {"label":"Alt", "x":10, "y":5, "w":1.5}, {"label":"Ctrl", "x":11.5, "y":5, "w":1.5}, {"label":"\u2190", "x":13, "y":5}, {"label":"\u2193", "x":14, "y":5}, {"label":"\u2192", "x":15, "y":5}, {"label":"0", "x":16, "y":5}, {"label":".", "x":17, "y":5}]
11 }
12 }
13}
diff --git a/keyboards/duck/lightsaver/keymaps/default/keymap.c b/keyboards/duck/lightsaver/keymaps/default/keymap.c
new file mode 100644
index 000000000..d945ada24
--- /dev/null
+++ b/keyboards/duck/lightsaver/keymaps/default/keymap.c
@@ -0,0 +1,48 @@
1/* Copyright 2017 Rasmus Schults <rasmus.schults@gmail.com>
2 *
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17#include QMK_KEYBOARD_H
18
19#define KC_F1GL TD(TD_F1_GAME)
20#define KC_CLFN TD(TD_CAPS_FN)
21
22enum custom_layers {
23 BASE, // Base QWERTY layer
24 FN = 5, // Function layer
25};
26
27const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
28[BASE] = LAYOUT(\
29 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_PSCR, KC_NLCK, KC_INS, KC_HOME, KC_PGUP, KC_PSLS, \
30 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_DEL, KC_END, KC_PGDN, KC_PAST, \
31 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_P7, KC_P8, KC_P9, KC_PMNS, \
32 MO(FN), 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_P4, KC_P5, KC_P6, KC_PPLS, \
33 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_P1, KC_P2, KC_P3, KC_PENT, \
34 KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, KC_RALT, KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT, KC_P0, KC_PDOT), \
35
36[FN] = LAYOUT(\
37 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_PAUS, KC_SLCK, RGB_TOG, RGB_MOD, _______, _______, \
38 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_CAPS, BL_TOGG, _______, _______, _______, \
39 _______, _______, _______, _______, _______, _______, KC_HOME, KC_PGDN, KC_PGUP, KC_END, _______, _______, _______, _______, _______, _______, _______, _______, \
40 _______, _______, _______, _______, _______, _______, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT, _______, _______, _______, _______, _______, _______, _______, \
41 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, RESET, \
42 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______ ), \
43
44};
45
46const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) {
47 return MACRO_NONE;
48};
diff --git a/keyboards/duck/lightsaver/keymaps/default/readme.md b/keyboards/duck/lightsaver/keymaps/default/readme.md
new file mode 100644
index 000000000..06f9aac5a
--- /dev/null
+++ b/keyboards/duck/lightsaver/keymaps/default/readme.md
@@ -0,0 +1,11 @@
1![Lightsaver Layout Image](https://i.imgur.com/vRAy2XP.png)
2
3# Default Lightsaver Layout
4
5This is the default implement layout for Duck Lightsaver V3.
6
7
8## Features
9
10* Default QWERTY layer
11* FN layer - Control RGB underglow and backlight. HJKL Vim style movement.
diff --git a/keyboards/duck/lightsaver/keymaps/rasmus/config.h b/keyboards/duck/lightsaver/keymaps/rasmus/config.h
new file mode 100644
index 000000000..f2b5d264e
--- /dev/null
+++ b/keyboards/duck/lightsaver/keymaps/rasmus/config.h
@@ -0,0 +1,8 @@
1#ifndef CONFIG_USER_H
2#define CONFIG_USER_H
3
4#include "../../config.h"
5
6#define FORCE_NKRO
7
8#endif
diff --git a/keyboards/duck/lightsaver/keymaps/rasmus/keymap.c b/keyboards/duck/lightsaver/keymaps/rasmus/keymap.c
new file mode 100644
index 000000000..518ba2d21
--- /dev/null
+++ b/keyboards/duck/lightsaver/keymaps/rasmus/keymap.c
@@ -0,0 +1,105 @@
1/* Copyright 2017 Rasmus Schults <rasmus.schults@gmail.com>
2 *
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17#include QMK_KEYBOARD_H
18
19#define KC_F1GL TD(TD_F1_GAME)
20#define KC_CLFN TD(TD_CAPS_FN)
21
22enum custom_layers {
23 BASE, // Base QWERTY layer
24 GAME, // Gaming layer
25 FN = 5, // Function layer
26};
27
28//Tap Dance Declarations
29enum {
30 TD_F1_BASE,
31 TD_F1_GAME,
32 TD_CAPS_FN
33};
34
35//Tap Dance Definitions
36qk_tap_dance_action_t tap_dance_actions[] = {
37 [TD_F1_GAME] = ACTION_TAP_DANCE_DUAL_ROLE(KC_F1, GAME),
38 [TD_CAPS_FN] = ACTION_TAP_DANCE_DUAL_ROLE(KC_CAPS, 5)
39};
40
41enum macro_id {
42 SHRG,
43};
44
45#define TYPE_SHRUG MACRO( \
46 D(LCTRL), D(LSHIFT), T(U), U(LCTRL), U(LSHIFT), \
47 T(0), T(0), T(A), T(F), \
48 D(LCTRL), D(LSHIFT), T(U), U(LCTRL), U(LSHIFT), \
49 T(0), T(0), T(5), T(C), \
50 D(LCTRL), D(LSHIFT), T(U), U(LCTRL), U(LSHIFT), \
51 T(0), T(0), T(5), T(F), \
52 D(LCTRL), D(LSHIFT), T(U), U(LCTRL), U(LSHIFT), \
53 T(0), T(0), T(2), T(8), \
54 D(LCTRL), D(LSHIFT), T(U), U(LCTRL), U(LSHIFT), \
55 T(3), T(0), T(C), T(4), \
56 D(LCTRL), D(LSHIFT), T(U), U(LCTRL), U(LSHIFT), \
57 T(0), T(0), T(2), T(9), \
58 D(LCTRL), D(LSHIFT), T(U), U(LCTRL), U(LSHIFT), \
59 T(0), T(0), T(5), T(F), \
60 D(LCTRL), D(LSHIFT), T(U), U(LCTRL), U(LSHIFT), \
61 T(0), T(0), T(2), T(F), \
62 D(LCTRL), D(LSHIFT), T(U), U(LCTRL), U(LSHIFT), \
63 T(0), T(0), T(A), T(F), \
64 T(SPACE), END \
65)
66
67const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
68[BASE] = LAYOUT(\
69 KC_ESC, KC_F1GL, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_PSCR, KC_NLCK, KC_INS, KC_HOME, KC_PGUP, KC_PSLS, \
70 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_DEL, KC_END, KC_PGDN, KC_PAST, \
71 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_P7, KC_P8, KC_P9, KC_PMNS, \
72 MO(FN), 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_P4, KC_P5, KC_P6, KC_PPLS, \
73 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_P1, KC_P2, KC_P3, KC_PENT, \
74 KC_LCTL, KC_LALT, KC_LGUI, KC_SPC, KC_RGUI, KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT, KC_P0, KC_PDOT), \
75
76[GAME] = LAYOUT(\
77 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_LOCK, _______, _______, _______, _______, _______, \
78 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, \
79 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, \
80 KC_CLFN, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, \
81 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, \
82 _______, KC_LGUI, KC_LALT, _______, KC_RALT, _______, _______, _______, _______, _______, _______ ), \
83
84[FN] = LAYOUT(\
85 _______, M(SHRG), _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_PAUS, KC_SLCK, RGB_TOG, RGB_MOD, _______, _______, \
86 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, BL_TOGG, _______, _______, _______, \
87 _______, _______, _______, _______, _______, _______, KC_HOME, KC_PGDN, KC_PGUP, KC_END, _______, _______, _______, _______, _______, _______, _______, _______, \
88 _______, _______, _______, _______, _______, _______, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT, _______, _______, _______, _______, _______, _______, _______, \
89 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, RESET, \
90 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______ ), \
91
92};
93
94const uint16_t PROGMEM fn_actions[] = {
95};
96
97const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) {
98 switch(id) {
99 case SHRG:
100 return (record->event.pressed ? TYPE_SHRUG : MACRO_NONE );
101 break;
102 }
103
104 return MACRO_NONE;
105};
diff --git a/keyboards/duck/lightsaver/keymaps/rasmus/readme.md b/keyboards/duck/lightsaver/keymaps/rasmus/readme.md
new file mode 100644
index 000000000..7670145f7
--- /dev/null
+++ b/keyboards/duck/lightsaver/keymaps/rasmus/readme.md
@@ -0,0 +1,12 @@
1![Lightsaver Layout Image](https://i.imgur.com/KqdZQZZ.png)
2
3# rasmusx's Lightsaver Layout
4
5Custom keymap for Lightsaver.
6
7
8## Features
9
10* Default layer has ALT/SUPER switched and FN key in Caps Lock place.
11* FN layer - Control RGB underglow and backlight. HJKL Vim style movement.
12* Game layer - ALT/SUPER in normal positions. FN behaviour: 1 tap Caps Lock, 2 taps FN
diff --git a/keyboards/duck/lightsaver/keymaps/rasmus/rules.mk b/keyboards/duck/lightsaver/keymaps/rasmus/rules.mk
new file mode 100644
index 000000000..3b11f9a9c
--- /dev/null
+++ b/keyboards/duck/lightsaver/keymaps/rasmus/rules.mk
@@ -0,0 +1,2 @@
1KEY_LOCK_ENABLE = yes
2TAP_DANCE_ENABLE = yes
diff --git a/keyboards/duck/lightsaver/lightsaver.c b/keyboards/duck/lightsaver/lightsaver.c
new file mode 100644
index 000000000..75e35b28b
--- /dev/null
+++ b/keyboards/duck/lightsaver/lightsaver.c
@@ -0,0 +1,60 @@
1/* Copyright 2017 Rasmus Schults <rasmusx@gmail.com>
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 "lightsaver.h"
17#include "indicator_leds.h"
18
19enum BACKLIGHT_AREAS {
20 BACKLIGHT_ALPHAS = 0b00000010, // Alpha keys
21 BACKLIGHT_FKEYS = 0b00000100, // Function row keys
22 BACKLIGHT_MODNUM = 0b00001000, // Modifiers and number row
23 BACKLIGHT_NUMPAD = 0b01000000 // Numpad area
24};
25
26void backlight_set(uint8_t level) {
27 if (level > 0) {
28 // Turn on leds
29 PORTB &= ~BACKLIGHT_ALPHAS;
30 PORTB &= ~BACKLIGHT_FKEYS;
31 PORTB &= ~BACKLIGHT_MODNUM;
32 PORTE &= ~BACKLIGHT_NUMPAD;
33 } else {
34 // Turn off leds
35 PORTB |= BACKLIGHT_ALPHAS;
36 PORTB |= BACKLIGHT_FKEYS;
37 PORTB |= BACKLIGHT_MODNUM;
38 PORTE |= BACKLIGHT_NUMPAD;
39 }
40}
41
42void led_set_kb(uint8_t usb_led) {
43 bool leds[8] = {
44 usb_led & (1<<USB_LED_CAPS_LOCK),
45 usb_led & (1<<USB_LED_SCROLL_LOCK),
46 usb_led & (1<<USB_LED_NUM_LOCK),
47 layer_state & (1<<1),
48 layer_state & (1<<2),
49 layer_state & (1<<3),
50 layer_state & (1<<4),
51 layer_state & (1<<5)
52 };
53 indicator_leds_set(leds);
54
55 led_set_user(usb_led);
56}
57
58bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
59 return process_record_user(keycode, record);
60}
diff --git a/keyboards/duck/lightsaver/lightsaver.h b/keyboards/duck/lightsaver/lightsaver.h
new file mode 100644
index 000000000..19fcf36ba
--- /dev/null
+++ b/keyboards/duck/lightsaver/lightsaver.h
@@ -0,0 +1,40 @@
1/* Copyright 2017 Rasmus Schults <rasmusx@gmail.com>
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#ifndef LIGHTSAVER_H
17#define LIGHTSAVER_H
18
19#include "quantum.h"
20
21#define NO KC_NO
22
23#define LAYOUT( \
24 K5A, K5B, K5C, K5D, K5E, K5F, K5G, K5H, K5I, K5J, K5K, K5L, K5M, K5N, K5O, K5P, K5Q, K5R, K5S, \
25 K4A, K4B, K4C, K4D, K4E, K4F, K4G, K4H, K4I, K4J, K4K, K4L, K4M, K4O, K4P, K4Q, K4R, K4S, \
26 K3A, K3B, K3C, K3D, K3E, K3F, K3G, K3H, K3I, K3J, K3K, K3L, K3M, K3O, K3P, K3Q, K3R, K3S, \
27 K2A, K2B, K2C, K2D, K2E, K2F, K2G, K2H, K2I, K2J, K2K, K2L, K2O, K2P, K2Q, K2R, K2S, \
28 K1A, K1C, K1D, K1E, K1F, K1G, K1H, K1I, K1J, K1K, K1M, K1N, K1O, K1P, K1Q, K1R, K1S, \
29 K0A, K0B, K0C, K0I, K0K, K0M, K0N, K0O, K0P, K0Q, K0R \
30) { \
31/* 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 */ \
32/* 0 */ { K5A, K5B, K5C, K5D, K5E, K5F, K5G, K5H, K5I, K5J, K5K, K5L, K5M, K5N, K5O, K5P, K5Q, K5R, K5S, }, \
33/* 1 */ { K4A, K4B, K4C, K4D, K4E, K4F, K4G, K4H, K4I, K4J, K4K, K4L, K4M, NO, K4O, K4P, K4Q, K4R, K4S, }, \
34/* 2 */ { K3A, K3B, K3C, K3D, K3E, K3F, K3G, K3H, K3I, K3J, K3K, K3L, K3M, NO, K3O, K3P, K3Q, K3R, K3S, }, \
35/* 3 */ { K2A, K2B, K2C, K2D, K2E, K2F, K2G, K2H, K2I, K2J, K2K, K2L, NO, NO, K2O, K2P, K2Q, K2R, K2S, }, \
36/* 4 */ { K1A, NO, K1C, K1D, K1E, K1F, K1G, K1H, K1I, K1J, K1K, NO, K1M, K1N, K1O, K1P, K1Q, K1R, K1S, }, \
37/* 5 */ { K0A, K0B, K0C, NO, NO, NO, NO, NO, K0I, NO, K0K, NO, K0M, K0N, K0O, K0P, K0Q, K0R } \
38}
39
40#endif
diff --git a/keyboards/duck/lightsaver/matrix.c b/keyboards/duck/lightsaver/matrix.c
new file mode 100644
index 000000000..a07cdd0d1
--- /dev/null
+++ b/keyboards/duck/lightsaver/matrix.c
@@ -0,0 +1,275 @@
1/*
2Copyright 2016-2017 Ralf Schmitt <ralf@bunkertor.net> Rasmus Schults <rasmusx@gmail.com>
3This program is free software: you can redistribute it and/or modify
4it under the terms of the GNU General Public License as published by
5the Free Software Foundation, either version 2 of the License, or
6(at your option) any later version.
7
8This program is distributed in the hope that it will be useful,
9but WITHOUT ANY WARRANTY; without even the implied warranty of
10MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11GNU General Public License for more details.
12
13You should have received a copy of the GNU General Public License
14along with this program. If not, see <http://www.gnu.org/licenses/>.
15*/
16
17#include <util/delay.h>
18#include <avr/io.h>
19#include <stdio.h>
20#include "matrix.h"
21#include "util.h"
22#include "print.h"
23#include "debug.h"
24
25static uint8_t debouncing = DEBOUNCING_DELAY;
26
27/* matrix state(1:on, 0:off) */
28static matrix_row_t matrix[MATRIX_ROWS];
29static matrix_row_t matrix_debouncing[MATRIX_ROWS];
30
31static uint8_t read_rows(void);
32static uint8_t read_fwkey(void);
33static void init_rows(void);
34static void unselect_cols(void);
35static void select_col(uint8_t col);
36
37
38__attribute__ ((weak))
39void matrix_init_kb(void) {
40 matrix_init_user();
41}
42
43__attribute__ ((weak))
44void matrix_scan_kb(void) {
45 matrix_scan_user();
46}
47
48__attribute__ ((weak))
49void matrix_init_user(void) {
50}
51
52__attribute__ ((weak))
53void matrix_scan_user(void) {
54}
55
56void matrix_init(void) {
57 DDRD |= 0b11010000;
58 PORTD &= ~0b01010000;
59 DDRB |= 0b00011111;
60 PORTB &= ~0b00001110;
61 PORTB |= 0b00010001;
62 DDRE |= 0b01000000;
63 PORTE &= ~0b01000000;
64
65 unselect_cols();
66 init_rows();
67
68 for (uint8_t i=0; i < MATRIX_ROWS; i++) {
69 matrix[i] = 0;
70 matrix_debouncing[i] = 0;
71 }
72
73 matrix_init_quantum();
74}
75
76uint8_t matrix_scan(void) {
77 for (uint8_t col = 0; col < MATRIX_COLS; col++) {
78 select_col(col);
79 _delay_us(3);
80
81 uint8_t rows = read_rows();
82 if(col == 0) {
83 rows |= read_fwkey();
84 }
85 for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
86 bool prev_bit = matrix_debouncing[row] & ((matrix_row_t)1<<col);
87 bool curr_bit = rows & (1<<row);
88 if (prev_bit != curr_bit) {
89 matrix_debouncing[row] ^= ((matrix_row_t)1<<col);
90 debouncing = DEBOUNCING_DELAY;
91 }
92 }
93 unselect_cols();
94 }
95
96 if (debouncing) {
97 if (--debouncing) {
98 _delay_ms(1);
99 } else {
100 for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
101 matrix[i] = matrix_debouncing[i];
102 }
103 }
104 }
105
106 matrix_scan_quantum();
107 return 1;
108}
109
110inline matrix_row_t matrix_get_row(uint8_t row) {
111 return matrix[row];
112}
113
114void matrix_print(void) {
115 print("\nr/c 0123456789ABCDEF\n");
116 for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
117 xprintf("%02X: %032lb\n", row, bitrev32(matrix_get_row(row)));
118 }
119}
120
121/* Row pin configuration
122 * row: 0 1 2 3 4 5
123 * pin: PB7 PD0 PD1 PD2 PD3 PD5
124 *
125 * Esc uses its own pin PE2
126 */
127static void init_rows(void) {
128 DDRB &= ~0b10000000;
129 PORTB &= ~0b10000000;
130
131 DDRD &= ~0b00101111;
132 PORTD &= ~0b00101111;
133
134 DDRE &= ~0b00000100;
135 PORTE |= 0b00000100;
136}
137
138static uint8_t read_rows() {
139 return (PINB&(1<<7) ? (1<<0) : 0) |
140 (PIND&(1<<0) ? (1<<1) : 0) |
141 (PIND&(1<<1) ? (1<<2) : 0) |
142 (PIND&(1<<2) ? (1<<3) : 0) |
143 (PIND&(1<<3) ? (1<<4) : 0) |
144 (PIND&(1<<5) ? (1<<5) : 0);
145}
146
147static uint8_t read_fwkey(void)
148{
149 return PINE&(1<<2) ? 0 : (1<<0);
150}
151
152/* Columns 0 - 15
153 * These columns uses two 74HC237D 3 to 8 bit demultiplexers.
154 * col / pin: PC6 PB6 PF0 PF1 PC7
155 * 0: 1 0 0 0 0
156 * 1: 1 0 1 0 0
157 * 2: 1 0 0 1 0
158 * 3: 1 0 1 1 0
159 * 4: 1 0 0 0 1
160 * 5: 1 0 1 0 1
161 * 6: 1 0 0 1 1
162 * 7: 1 0 1 1 1
163 * 8: 0 1 0 0 0
164 * 9: 0 1 1 0 0
165 * 10: 0 1 0 1 0
166 * 11: 0 1 1 1 0
167 * 12: 0 1 0 0 1
168 * 13: 0 1 1 0 1
169 * 14: 0 1 0 1 1
170 * 15: 0 1 1 1 1
171 *
172 * col: 16
173 * pin: PB5
174 *
175 * col: 17
176 * pin: PB4
177 *
178 * col: 18
179 * pin: PD7
180 */
181static void unselect_cols(void) {
182 DDRB |= 0b01110000;
183 PORTB &= ~0b01110000;
184
185 DDRC |= (1<<6) | (1<<7);
186 PORTC &= ~((1<<6) | (1<<7));
187
188 DDRF |= (1<<0) | (1<<1);
189 PORTF &= ~((1<<0) | (1<<1));
190
191 DDRD |= (1<<7);
192 PORTD &= ~(1<<7);
193}
194
195static void select_col(uint8_t col) {
196 switch (col) {
197 case 0:
198 PORTC |= (1<<6);
199 break;
200 case 1:
201 PORTC |= (1<<6);
202 PORTF |= (1<<0);
203 break;
204 case 2:
205 PORTC |= (1<<6);
206 PORTF |= (1<<1);
207 break;
208 case 3:
209 PORTC |= (1<<6);
210 PORTF |= (1<<0) | (1<<1);
211 break;
212 case 4:
213 PORTC |= (1<<6);
214 PORTC |= (1<<7);
215 break;
216 case 5:
217 PORTC |= (1<<6);
218 PORTF |= (1<<0);
219 PORTC |= (1<<7);
220 break;
221 case 6:
222 PORTC |= (1<<6);
223 PORTF |= (1<<1);
224 PORTC |= (1<<7);
225 break;
226 case 7:
227 PORTC |= (1<<6);
228 PORTF |= (1<<0) | (1<<1);
229 PORTC |= (1<<7);
230 break;
231 case 8:
232 PORTB |= (1<<6);
233 break;
234 case 9:
235 PORTB |= (1<<6);
236 PORTF |= (1<<0);
237 break;
238 case 10:
239 PORTB |= (1<<6);
240 PORTF |= (1<<1);
241 break;
242 case 11:
243 PORTB |= (1<<6);
244 PORTF |= (1<<0) | (1<<1);
245 break;
246 case 12:
247 PORTB |= (1<<6);
248 PORTC |= (1<<7);
249 break;
250 case 13:
251 PORTB |= (1<<6);
252 PORTF |= (1<<0);
253 PORTC |= (1<<7);
254 break;
255 case 14:
256 PORTB |= (1<<6);
257 PORTF |= (1<<1);
258 PORTC |= (1<<7);
259 break;
260 case 15:
261 PORTB |= (1<<6);
262 PORTF |= (1<<0) | (1<<1);
263 PORTC |= (1<<7);
264 break;
265 case 16:
266 PORTB |= (1<<5);
267 break;
268 case 17:
269 PORTB |= (1<<4);
270 break;
271 case 18:
272 PORTD |= (1<<7);
273 break;
274 }
275}
diff --git a/keyboards/duck/lightsaver/readme.md b/keyboards/duck/lightsaver/readme.md
new file mode 100644
index 000000000..9d4b453c0
--- /dev/null
+++ b/keyboards/duck/lightsaver/readme.md
@@ -0,0 +1,19 @@
1# Duck Lightsaver V3
2
3![Lightsaver V3](https://i.imgur.com/Vz23Dkel.jpg)
4
5Non official firmware for custom Korean keyboard with 96 key layout made by Duck.
6Group buy was run 2017 May via [geekhack](https://geekhack.org/index.php?topic=89546.0) and limited to 100 units.
7
8Keyboard Maintainer: [Rasmus Schults](https://github.com/rasmusx)
9Hardware Supported: Lightsaver PCB Ver 3.0, Atmega32u4
10Hardware Availability: [geekhack](https://geekhack.org/index.php?topic=89546.0)
11
12Make example for this keyboard (after setting up your build environment):
13
14 make lightsaver:default
15
16See [build environment setup](https://docs.qmk.fm/build_environment_setup.html) then the [make instructions](https://docs.qmk.fm/make_instructions.html) for more information.
17
18## Notes
19Thanks to Ralf Schmitt for previous implementations in his [TMK fork](https://github.com/xauser/tmk_keyboard/tree/xauser/) and few helping words.
diff --git a/keyboards/duck/lightsaver/rules.mk b/keyboards/duck/lightsaver/rules.mk
new file mode 100644
index 000000000..d95dbd960
--- /dev/null
+++ b/keyboards/duck/lightsaver/rules.mk
@@ -0,0 +1,72 @@
1# MCU name
2MCU = atmega32u4
3
4# Processor frequency.
5# This will define a symbol, F_CPU, in all source code files equal to the
6# processor frequency in Hz. You can then use this symbol in your source code to
7# calculate timings. Do NOT tack on a 'UL' at the end, this will be done
8# automatically to create a 32-bit value in your source code.
9#
10# This will be an integer division of F_USB below, as it is sourced by
11# F_USB after it has run through any CPU prescalers. Note that this value
12# does not *change* the processor frequency - it should merely be updated to
13# reflect the processor speed set externally so that the code can use accurate
14# software delays.
15F_CPU = 16000000
16
17
18#
19# LUFA specific
20#
21# Target architecture (see library "Board Types" documentation).
22ARCH = AVR8
23
24# Input clock frequency.
25# This will define a symbol, F_USB, in all source code files equal to the
26# input clock frequency (before any prescaling is performed) in Hz. This value may
27# differ from F_CPU if prescaling is used on the latter, and is required as the
28# raw input clock is fed directly to the PLL sections of the AVR for high speed
29# clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL'
30# at the end, this will be done automatically to create a 32-bit value in your
31# source code.
32#
33# If no clock division is performed on the input clock inside the AVR (via the
34# CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU.
35F_USB = $(F_CPU)
36
37# Interrupt driven control endpoint task(+60)
38#OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT
39
40
41# Boot Section Size in *bytes*
42# Teensy halfKay 512
43# Teensy++ halfKay 1024
44# Atmel DFU loader 4096
45# LUFA bootloader 4096
46# USBaspLoader 2048
47OPT_DEFS += -DBOOTLOADER_SIZE=4096
48
49
50# Build Options
51# change yes to no to disable
52#
53BOOTMAGIC_ENABLE ?= no # Virtual DIP switch configuration(+1000)
54MOUSEKEY_ENABLE ?= no # Mouse keys(+4700)
55EXTRAKEY_ENABLE ?= no # Audio control and System control(+450)
56CONSOLE_ENABLE ?= no # Console for debug(+400)
57COMMAND_ENABLE ?= yes # Commands for debug and configuration
58# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE
59SLEEP_LED_ENABLE ?= no # Breathing sleep LED during USB suspend
60# if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work
61NKRO_ENABLE ?= yes # USB Nkey Rollover
62BACKLIGHT_ENABLE ?= yes # Enable keyboard backlight functionality on B7 by default
63MIDI_ENABLE ?= no # MIDI support (+2400 to 4200, depending on config)
64UNICODE_ENABLE ?= no # Unicode
65BLUETOOTH_ENABLE ?= no # Enable Bluetooth with the Adafruit EZ-Key HID
66AUDIO_ENABLE ?= no # Audio output on port C6
67FAUXCLICKY_ENABLE ?= no # Use buzzer to emulate clicky switches
68RGBLIGHT_ENABLE = yes
69
70CUSTOM_MATRIX = yes
71SRC += indicator_leds.c \
72 matrix.c