Keyboard: Putting all my ducks in a row: Lightsaver (#3758)
This commit is contained in:
		
							parent
							
								
									1ee545014a
								
							
						
					
					
						commit
						a63d4774f5
					
				
					 15 changed files with 0 additions and 0 deletions
				
			
		
							
								
								
									
										54
									
								
								keyboards/duck/lightsaver/config.h
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										54
									
								
								keyboards/duck/lightsaver/config.h
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,54 @@
 | 
			
		|||
/*
 | 
			
		||||
Copyright 2017 Rasmus Schults <rasmusx@gmail.com>
 | 
			
		||||
 | 
			
		||||
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/>.
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
#ifndef CONFIG_H
 | 
			
		||||
#define CONFIG_H
 | 
			
		||||
 | 
			
		||||
#include "config_common.h"
 | 
			
		||||
 | 
			
		||||
/* USB Device descriptor parameter */
 | 
			
		||||
#define VENDOR_ID       0xFEED
 | 
			
		||||
#define PRODUCT_ID      0x1337
 | 
			
		||||
#define DEVICE_VER      0x0003
 | 
			
		||||
#define MANUFACTURER    Duck
 | 
			
		||||
#define PRODUCT         Lightsaver V3
 | 
			
		||||
#define DESCRIPTION     Duck Lightsaver V3
 | 
			
		||||
 | 
			
		||||
/* key matrix size */
 | 
			
		||||
#define MATRIX_ROWS 6
 | 
			
		||||
#define MATRIX_COLS 19
 | 
			
		||||
 | 
			
		||||
#define DIODE_DIRECTION COL2ROW
 | 
			
		||||
 | 
			
		||||
/* Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not needed */
 | 
			
		||||
#define DEBOUNCING_DELAY 5
 | 
			
		||||
 | 
			
		||||
/* number of backlight levels */
 | 
			
		||||
#define BACKLIGHT_LEVELS 1
 | 
			
		||||
 | 
			
		||||
/* key combination for magic key command */
 | 
			
		||||
#define IS_COMMAND() ( \
 | 
			
		||||
    keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
#define RGBLIGHT_ANIMATIONS
 | 
			
		||||
#define RGB_DI_PIN D6
 | 
			
		||||
#define RGBLED_NUM 17
 | 
			
		||||
 | 
			
		||||
#define TAPPING_TERM 200
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
							
								
								
									
										91
									
								
								keyboards/duck/lightsaver/indicator_leds.c
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										91
									
								
								keyboards/duck/lightsaver/indicator_leds.c
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,91 @@
 | 
			
		|||
/*
 | 
			
		||||
Copyright 2016-2017 Ralf Schmitt <ralf@bunkertor.net> Rasmus Schults <rasmusx@gmail.com>
 | 
			
		||||
 | 
			
		||||
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 <avr/interrupt.h>
 | 
			
		||||
#include <avr/io.h>
 | 
			
		||||
#include <stdbool.h>
 | 
			
		||||
#include <util/delay.h>
 | 
			
		||||
 | 
			
		||||
#define T1H  900
 | 
			
		||||
#define T1L  600
 | 
			
		||||
#define T0H  400
 | 
			
		||||
#define T0L  900
 | 
			
		||||
#define RES 6000
 | 
			
		||||
 | 
			
		||||
#define NS_PER_SEC (1000000000L)
 | 
			
		||||
#define CYCLES_PER_SEC (F_CPU)
 | 
			
		||||
#define NS_PER_CYCLE (NS_PER_SEC / CYCLES_PER_SEC)
 | 
			
		||||
#define NS_TO_CYCLES(n) ((n) / NS_PER_CYCLE)
 | 
			
		||||
 | 
			
		||||
void send_bit_d4(bool bitVal) {
 | 
			
		||||
  if(bitVal) {
 | 
			
		||||
    asm volatile (
 | 
			
		||||
        "sbi %[port], %[bit] \n\t"
 | 
			
		||||
        ".rept %[onCycles] \n\t"
 | 
			
		||||
        "nop \n\t"
 | 
			
		||||
        ".endr \n\t"
 | 
			
		||||
        "cbi %[port], %[bit] \n\t"
 | 
			
		||||
        ".rept %[offCycles] \n\t"
 | 
			
		||||
        "nop \n\t"
 | 
			
		||||
        ".endr \n\t"
 | 
			
		||||
        ::
 | 
			
		||||
        [port]      "I" (_SFR_IO_ADDR(PORTD)),
 | 
			
		||||
        [bit]       "I" (4),
 | 
			
		||||
        [onCycles]  "I" (NS_TO_CYCLES(T1H) - 2),
 | 
			
		||||
        [offCycles] "I" (NS_TO_CYCLES(T1L) - 2));
 | 
			
		||||
  } else {
 | 
			
		||||
    asm volatile (
 | 
			
		||||
        "sbi %[port], %[bit] \n\t"
 | 
			
		||||
        ".rept %[onCycles] \n\t"
 | 
			
		||||
        "nop \n\t"
 | 
			
		||||
        ".endr \n\t"
 | 
			
		||||
        "cbi %[port], %[bit] \n\t"
 | 
			
		||||
        ".rept %[offCycles] \n\t"
 | 
			
		||||
        "nop \n\t"
 | 
			
		||||
        ".endr \n\t"
 | 
			
		||||
        ::
 | 
			
		||||
        [port]      "I" (_SFR_IO_ADDR(PORTD)),
 | 
			
		||||
        [bit]       "I" (4),
 | 
			
		||||
        [onCycles]  "I" (NS_TO_CYCLES(T0H) - 2),
 | 
			
		||||
        [offCycles] "I" (NS_TO_CYCLES(T0L) - 2));
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void show(void) {
 | 
			
		||||
  _delay_us((RES / 1000UL) + 1);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void send_value(uint8_t byte) {
 | 
			
		||||
  for(uint8_t b = 0; b < 8; b++) {
 | 
			
		||||
    send_bit_d4(byte & 0b10000000);
 | 
			
		||||
    byte <<= 1;
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void send_color(uint8_t r, uint8_t g, uint8_t b) {
 | 
			
		||||
  send_value(g);
 | 
			
		||||
  send_value(r);
 | 
			
		||||
  send_value(b);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void indicator_leds_set(bool leds[8]) {
 | 
			
		||||
  cli();
 | 
			
		||||
  send_color(leds[1] ? 255 : 0, leds[2] ? 255 : 0, leds[0] ? 255 : 0);
 | 
			
		||||
  send_color(leds[4] ? 255 : 0, leds[5] ? 255 : 0, leds[3] ? 255 : 0);
 | 
			
		||||
  send_color(leds[6] ? 255 : 0, leds[7] ? 255 : 0, 0);
 | 
			
		||||
  sei();
 | 
			
		||||
  show();
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										1
									
								
								keyboards/duck/lightsaver/indicator_leds.h
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								keyboards/duck/lightsaver/indicator_leds.h
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1 @@
 | 
			
		|||
void indicator_leds_set(bool leds[8]);
 | 
			
		||||
							
								
								
									
										13
									
								
								keyboards/duck/lightsaver/info.json
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								keyboards/duck/lightsaver/info.json
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,13 @@
 | 
			
		|||
{
 | 
			
		||||
  "keyboard_name": "Duck Lightsaver V3",
 | 
			
		||||
  "url": "",
 | 
			
		||||
  "maintainer": "qmk",
 | 
			
		||||
  "width": 19,
 | 
			
		||||
  "height": 6,
 | 
			
		||||
  "layouts": {
 | 
			
		||||
    "LAYOUT": {
 | 
			
		||||
      "key_count": 100,
 | 
			
		||||
      "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}]
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										48
									
								
								keyboards/duck/lightsaver/keymaps/default/keymap.c
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										48
									
								
								keyboards/duck/lightsaver/keymaps/default/keymap.c
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,48 @@
 | 
			
		|||
/* Copyright 2017 Rasmus Schults <rasmus.schults@gmail.com>
 | 
			
		||||
 *
 | 
			
		||||
 *
 | 
			
		||||
 * 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
 | 
			
		||||
 | 
			
		||||
#define KC_F1GL TD(TD_F1_GAME)
 | 
			
		||||
#define KC_CLFN TD(TD_CAPS_FN)
 | 
			
		||||
 | 
			
		||||
enum custom_layers {
 | 
			
		||||
    BASE,   // Base QWERTY layer
 | 
			
		||||
    FN = 5, // Function layer
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
 | 
			
		||||
[BASE] = LAYOUT(\
 | 
			
		||||
      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, \
 | 
			
		||||
      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, \
 | 
			
		||||
      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, \
 | 
			
		||||
      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, \
 | 
			
		||||
      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, \
 | 
			
		||||
      KC_LCTL,  KC_LGUI, KC_LALT,                                              KC_SPC,                    KC_RALT, KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT, KC_P0,   KC_PDOT), \
 | 
			
		||||
 | 
			
		||||
[FN] = LAYOUT(\
 | 
			
		||||
      _______,  _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_PAUS, KC_SLCK, RGB_TOG, RGB_MOD, _______, _______,  \
 | 
			
		||||
      _______,  _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,          KC_CAPS, BL_TOGG, _______, _______, _______,  \
 | 
			
		||||
      _______,  _______, _______, _______, _______, _______, KC_HOME, KC_PGDN, KC_PGUP, KC_END,  _______, _______, _______,          _______, _______, _______, _______, _______,  \
 | 
			
		||||
      _______,  _______, _______, _______, _______, _______, KC_LEFT, KC_DOWN, KC_UP,   KC_RGHT, _______, _______,                   _______, _______, _______, _______, _______,  \
 | 
			
		||||
      _______,           _______, _______, _______, _______, _______, _______, _______, _______, _______,          _______, _______, _______, _______, _______, _______, RESET,  \
 | 
			
		||||
      _______,  _______, _______,                                              _______,                   _______, _______, _______, _______, _______, _______, _______ ), \
 | 
			
		||||
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) {
 | 
			
		||||
  return MACRO_NONE;
 | 
			
		||||
};
 | 
			
		||||
							
								
								
									
										11
									
								
								keyboards/duck/lightsaver/keymaps/default/readme.md
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								keyboards/duck/lightsaver/keymaps/default/readme.md
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,11 @@
 | 
			
		|||

 | 
			
		||||
 | 
			
		||||
# Default Lightsaver Layout
 | 
			
		||||
 | 
			
		||||
This is the default implement layout for Duck Lightsaver V3.
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
## Features
 | 
			
		||||
 | 
			
		||||
* Default QWERTY layer
 | 
			
		||||
* FN layer - Control RGB underglow and backlight. HJKL Vim style movement.
 | 
			
		||||
							
								
								
									
										8
									
								
								keyboards/duck/lightsaver/keymaps/rasmus/config.h
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								keyboards/duck/lightsaver/keymaps/rasmus/config.h
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,8 @@
 | 
			
		|||
#ifndef CONFIG_USER_H
 | 
			
		||||
#define CONFIG_USER_H
 | 
			
		||||
 | 
			
		||||
#include "../../config.h"
 | 
			
		||||
 | 
			
		||||
#define FORCE_NKRO
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
							
								
								
									
										105
									
								
								keyboards/duck/lightsaver/keymaps/rasmus/keymap.c
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										105
									
								
								keyboards/duck/lightsaver/keymaps/rasmus/keymap.c
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,105 @@
 | 
			
		|||
/* Copyright 2017 Rasmus Schults <rasmus.schults@gmail.com>
 | 
			
		||||
 *
 | 
			
		||||
 *
 | 
			
		||||
 * 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
 | 
			
		||||
 | 
			
		||||
#define KC_F1GL TD(TD_F1_GAME)
 | 
			
		||||
#define KC_CLFN TD(TD_CAPS_FN)
 | 
			
		||||
 | 
			
		||||
enum custom_layers {
 | 
			
		||||
    BASE,   // Base QWERTY layer
 | 
			
		||||
    GAME,   // Gaming layer
 | 
			
		||||
    FN = 5, // Function layer
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
//Tap Dance Declarations
 | 
			
		||||
enum {
 | 
			
		||||
  TD_F1_BASE,
 | 
			
		||||
  TD_F1_GAME,
 | 
			
		||||
  TD_CAPS_FN
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
//Tap Dance Definitions
 | 
			
		||||
qk_tap_dance_action_t tap_dance_actions[] = {
 | 
			
		||||
  [TD_F1_GAME] = ACTION_TAP_DANCE_DUAL_ROLE(KC_F1, GAME),
 | 
			
		||||
  [TD_CAPS_FN] = ACTION_TAP_DANCE_DUAL_ROLE(KC_CAPS, 5)
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
enum macro_id {
 | 
			
		||||
  SHRG,
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
#define TYPE_SHRUG MACRO( \
 | 
			
		||||
  D(LCTRL), D(LSHIFT), T(U), U(LCTRL), U(LSHIFT), \
 | 
			
		||||
  T(0), T(0), T(A), T(F), \
 | 
			
		||||
  D(LCTRL), D(LSHIFT), T(U), U(LCTRL), U(LSHIFT), \
 | 
			
		||||
  T(0), T(0), T(5), T(C), \
 | 
			
		||||
  D(LCTRL), D(LSHIFT), T(U), U(LCTRL), U(LSHIFT), \
 | 
			
		||||
  T(0), T(0), T(5), T(F), \
 | 
			
		||||
  D(LCTRL), D(LSHIFT), T(U), U(LCTRL), U(LSHIFT), \
 | 
			
		||||
  T(0), T(0), T(2), T(8), \
 | 
			
		||||
  D(LCTRL), D(LSHIFT), T(U), U(LCTRL), U(LSHIFT), \
 | 
			
		||||
  T(3), T(0), T(C), T(4), \
 | 
			
		||||
  D(LCTRL), D(LSHIFT), T(U), U(LCTRL), U(LSHIFT), \
 | 
			
		||||
  T(0), T(0), T(2), T(9), \
 | 
			
		||||
  D(LCTRL), D(LSHIFT), T(U), U(LCTRL), U(LSHIFT), \
 | 
			
		||||
  T(0), T(0), T(5), T(F), \
 | 
			
		||||
  D(LCTRL), D(LSHIFT), T(U), U(LCTRL), U(LSHIFT), \
 | 
			
		||||
  T(0), T(0), T(2), T(F), \
 | 
			
		||||
  D(LCTRL), D(LSHIFT), T(U), U(LCTRL), U(LSHIFT), \
 | 
			
		||||
  T(0), T(0), T(A), T(F), \
 | 
			
		||||
  T(SPACE), END \
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
 | 
			
		||||
[BASE] = LAYOUT(\
 | 
			
		||||
      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, \
 | 
			
		||||
      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, \
 | 
			
		||||
      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, \
 | 
			
		||||
      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, \
 | 
			
		||||
      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, \
 | 
			
		||||
      KC_LCTL,  KC_LALT, KC_LGUI,                                              KC_SPC,                    KC_RGUI, KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT, KC_P0,   KC_PDOT), \
 | 
			
		||||
 | 
			
		||||
[GAME] = LAYOUT(\
 | 
			
		||||
      _______,  _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_LOCK, _______, _______, _______, _______, _______,  \
 | 
			
		||||
      _______,  _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,          _______, _______, _______, _______, _______,  \
 | 
			
		||||
      _______,  _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,          _______, _______, _______, _______, _______,  \
 | 
			
		||||
      KC_CLFN,  _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,                   _______, _______, _______, _______, _______,  \
 | 
			
		||||
      _______,           _______, _______, _______, _______, _______, _______, _______, _______, _______,          _______, _______, _______, _______, _______, _______, _______,  \
 | 
			
		||||
      _______,  KC_LGUI, KC_LALT,                                              _______,                   KC_RALT, _______, _______, _______, _______, _______, _______ ), \
 | 
			
		||||
 | 
			
		||||
[FN] = LAYOUT(\
 | 
			
		||||
      _______,  M(SHRG), _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_PAUS, KC_SLCK, RGB_TOG, RGB_MOD, _______, _______,  \
 | 
			
		||||
      _______,  _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,          _______, BL_TOGG, _______, _______, _______,  \
 | 
			
		||||
      _______,  _______, _______, _______, _______, _______, KC_HOME, KC_PGDN, KC_PGUP, KC_END,  _______, _______, _______,          _______, _______, _______, _______, _______,  \
 | 
			
		||||
      _______,  _______, _______, _______, _______, _______, KC_LEFT, KC_DOWN, KC_UP,   KC_RGHT, _______, _______,                   _______, _______, _______, _______, _______,  \
 | 
			
		||||
      _______,           _______, _______, _______, _______, _______, _______, _______, _______, _______,          _______, _______, _______, _______, _______, _______, RESET,  \
 | 
			
		||||
      _______,  _______, _______,                                              _______,                   _______, _______, _______, _______, _______, _______, _______ ), \
 | 
			
		||||
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
const uint16_t PROGMEM fn_actions[] = {
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) {
 | 
			
		||||
  switch(id) {
 | 
			
		||||
    case SHRG:
 | 
			
		||||
      return (record->event.pressed ? TYPE_SHRUG : MACRO_NONE );
 | 
			
		||||
      break;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  return MACRO_NONE;
 | 
			
		||||
};
 | 
			
		||||
							
								
								
									
										12
									
								
								keyboards/duck/lightsaver/keymaps/rasmus/readme.md
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								keyboards/duck/lightsaver/keymaps/rasmus/readme.md
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,12 @@
 | 
			
		|||

 | 
			
		||||
 | 
			
		||||
# rasmusx's Lightsaver Layout
 | 
			
		||||
 | 
			
		||||
Custom keymap for Lightsaver.
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
## Features
 | 
			
		||||
 | 
			
		||||
* Default layer has ALT/SUPER switched and FN key in Caps Lock place.
 | 
			
		||||
* FN layer - Control RGB underglow and backlight. HJKL Vim style movement.
 | 
			
		||||
* Game layer - ALT/SUPER in normal positions. FN behaviour: 1 tap Caps Lock, 2 taps FN
 | 
			
		||||
							
								
								
									
										2
									
								
								keyboards/duck/lightsaver/keymaps/rasmus/rules.mk
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								keyboards/duck/lightsaver/keymaps/rasmus/rules.mk
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,2 @@
 | 
			
		|||
KEY_LOCK_ENABLE = yes
 | 
			
		||||
TAP_DANCE_ENABLE = yes
 | 
			
		||||
							
								
								
									
										60
									
								
								keyboards/duck/lightsaver/lightsaver.c
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										60
									
								
								keyboards/duck/lightsaver/lightsaver.c
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,60 @@
 | 
			
		|||
/* Copyright 2017 Rasmus Schults <rasmusx@gmail.com>
 | 
			
		||||
 *
 | 
			
		||||
 * 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 "lightsaver.h"
 | 
			
		||||
#include "indicator_leds.h"
 | 
			
		||||
 | 
			
		||||
enum BACKLIGHT_AREAS {
 | 
			
		||||
  BACKLIGHT_ALPHAS = 0b00000010, // Alpha keys
 | 
			
		||||
  BACKLIGHT_FKEYS =  0b00000100, // Function row keys
 | 
			
		||||
  BACKLIGHT_MODNUM = 0b00001000, // Modifiers and number row
 | 
			
		||||
  BACKLIGHT_NUMPAD = 0b01000000  // Numpad area
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
void backlight_set(uint8_t level) {
 | 
			
		||||
  if (level > 0) {
 | 
			
		||||
    // Turn on leds
 | 
			
		||||
    PORTB &= ~BACKLIGHT_ALPHAS;
 | 
			
		||||
    PORTB &= ~BACKLIGHT_FKEYS;
 | 
			
		||||
    PORTB &= ~BACKLIGHT_MODNUM;
 | 
			
		||||
    PORTE &= ~BACKLIGHT_NUMPAD;
 | 
			
		||||
  } else {
 | 
			
		||||
    // Turn off leds
 | 
			
		||||
    PORTB |= BACKLIGHT_ALPHAS;
 | 
			
		||||
    PORTB |= BACKLIGHT_FKEYS;
 | 
			
		||||
    PORTB |= BACKLIGHT_MODNUM;
 | 
			
		||||
    PORTE |= BACKLIGHT_NUMPAD;
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void led_set_kb(uint8_t usb_led) {
 | 
			
		||||
  bool leds[8] = {
 | 
			
		||||
    usb_led & (1<<USB_LED_CAPS_LOCK),
 | 
			
		||||
    usb_led & (1<<USB_LED_SCROLL_LOCK),
 | 
			
		||||
    usb_led & (1<<USB_LED_NUM_LOCK),
 | 
			
		||||
    layer_state & (1<<1),
 | 
			
		||||
    layer_state & (1<<2),
 | 
			
		||||
    layer_state & (1<<3),
 | 
			
		||||
    layer_state & (1<<4),
 | 
			
		||||
    layer_state & (1<<5)
 | 
			
		||||
  };
 | 
			
		||||
  indicator_leds_set(leds);
 | 
			
		||||
 | 
			
		||||
  led_set_user(usb_led);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
 | 
			
		||||
  return process_record_user(keycode, record);
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										40
									
								
								keyboards/duck/lightsaver/lightsaver.h
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										40
									
								
								keyboards/duck/lightsaver/lightsaver.h
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,40 @@
 | 
			
		|||
/* Copyright 2017 Rasmus Schults <rasmusx@gmail.com>
 | 
			
		||||
 *
 | 
			
		||||
 * 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/>.
 | 
			
		||||
 */
 | 
			
		||||
#ifndef LIGHTSAVER_H
 | 
			
		||||
#define LIGHTSAVER_H
 | 
			
		||||
 | 
			
		||||
#include "quantum.h"
 | 
			
		||||
 | 
			
		||||
#define NO KC_NO
 | 
			
		||||
 | 
			
		||||
#define LAYOUT( \
 | 
			
		||||
    K5A, K5B, K5C, K5D, K5E, K5F, K5G, K5H, K5I, K5J, K5K, K5L, K5M, K5N, K5O,   K5P, K5Q, K5R, K5S, \
 | 
			
		||||
    K4A, K4B, K4C, K4D, K4E, K4F, K4G, K4H, K4I, K4J, K4K, K4L, K4M,      K4O,   K4P, K4Q, K4R, K4S, \
 | 
			
		||||
    K3A, K3B, K3C, K3D, K3E, K3F, K3G, K3H, K3I, K3J, K3K, K3L, K3M,      K3O,   K3P, K3Q, K3R, K3S, \
 | 
			
		||||
    K2A, K2B, K2C, K2D, K2E, K2F, K2G, K2H, K2I, K2J, K2K, K2L,           K2O,   K2P, K2Q, K2R, K2S, \
 | 
			
		||||
    K1A,      K1C, K1D, K1E, K1F, K1G, K1H, K1I, K1J, K1K,      K1M, K1N, K1O,   K1P, K1Q, K1R, K1S, \
 | 
			
		||||
    K0A, K0B, K0C,                          K0I,      K0K,      K0M, K0N, K0O,   K0P, K0Q, K0R \
 | 
			
		||||
) { \
 | 
			
		||||
/*           0    1    2    3    4    5    6    7    8    9    10   11   12   13   14     15   16   17   18  */ \
 | 
			
		||||
/* 0 */   { K5A, K5B, K5C, K5D, K5E, K5F, K5G, K5H, K5I, K5J, K5K, K5L, K5M, K5N, K5O,   K5P, K5Q, K5R, K5S, }, \
 | 
			
		||||
/* 1 */   { K4A, K4B, K4C, K4D, K4E, K4F, K4G, K4H, K4I, K4J, K4K, K4L, K4M, NO,  K4O,   K4P, K4Q, K4R, K4S, }, \
 | 
			
		||||
/* 2 */   { K3A, K3B, K3C, K3D, K3E, K3F, K3G, K3H, K3I, K3J, K3K, K3L, K3M, NO,  K3O,   K3P, K3Q, K3R, K3S, }, \
 | 
			
		||||
/* 3 */   { K2A, K2B, K2C, K2D, K2E, K2F, K2G, K2H, K2I, K2J, K2K, K2L, NO,  NO,  K2O,   K2P, K2Q, K2R, K2S, }, \
 | 
			
		||||
/* 4 */   { K1A, NO,  K1C, K1D, K1E, K1F, K1G, K1H, K1I, K1J, K1K, NO,  K1M, K1N, K1O,   K1P, K1Q, K1R, K1S, }, \
 | 
			
		||||
/* 5 */   { K0A, K0B, K0C, NO,  NO,  NO,  NO,  NO,  K0I, NO,  K0K, NO,  K0M, K0N, K0O,   K0P, K0Q, K0R } \
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
							
								
								
									
										275
									
								
								keyboards/duck/lightsaver/matrix.c
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										275
									
								
								keyboards/duck/lightsaver/matrix.c
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,275 @@
 | 
			
		|||
/*
 | 
			
		||||
Copyright 2016-2017 Ralf Schmitt <ralf@bunkertor.net> Rasmus Schults <rasmusx@gmail.com>
 | 
			
		||||
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 <util/delay.h>
 | 
			
		||||
#include <avr/io.h>
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include "matrix.h"
 | 
			
		||||
#include "util.h"
 | 
			
		||||
#include "print.h"
 | 
			
		||||
#include "debug.h"
 | 
			
		||||
 | 
			
		||||
static uint8_t debouncing = DEBOUNCING_DELAY;
 | 
			
		||||
 | 
			
		||||
/* matrix state(1:on, 0:off) */
 | 
			
		||||
static matrix_row_t matrix[MATRIX_ROWS];
 | 
			
		||||
static matrix_row_t matrix_debouncing[MATRIX_ROWS];
 | 
			
		||||
 | 
			
		||||
static uint8_t read_rows(void);
 | 
			
		||||
static uint8_t read_fwkey(void);
 | 
			
		||||
static void init_rows(void);
 | 
			
		||||
static void unselect_cols(void);
 | 
			
		||||
static void select_col(uint8_t col);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
__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) {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void matrix_init(void) {
 | 
			
		||||
  DDRD  |=  0b11010000;
 | 
			
		||||
  PORTD &= ~0b01010000;
 | 
			
		||||
  DDRB  |=  0b00011111;
 | 
			
		||||
  PORTB &= ~0b00001110;
 | 
			
		||||
  PORTB |=  0b00010001;
 | 
			
		||||
  DDRE  |=  0b01000000;
 | 
			
		||||
  PORTE &= ~0b01000000;
 | 
			
		||||
 | 
			
		||||
  unselect_cols();
 | 
			
		||||
  init_rows();
 | 
			
		||||
 | 
			
		||||
  for (uint8_t i=0; i < MATRIX_ROWS; i++)  {
 | 
			
		||||
    matrix[i] = 0;
 | 
			
		||||
    matrix_debouncing[i] = 0;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  matrix_init_quantum();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
uint8_t matrix_scan(void) {
 | 
			
		||||
  for (uint8_t col = 0; col < MATRIX_COLS; col++) {
 | 
			
		||||
    select_col(col);
 | 
			
		||||
    _delay_us(3);
 | 
			
		||||
 | 
			
		||||
    uint8_t rows = read_rows();
 | 
			
		||||
    if(col == 0) {
 | 
			
		||||
      rows |= read_fwkey();
 | 
			
		||||
    }
 | 
			
		||||
    for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
 | 
			
		||||
      bool prev_bit = matrix_debouncing[row] & ((matrix_row_t)1<<col);
 | 
			
		||||
      bool curr_bit = rows & (1<<row);
 | 
			
		||||
      if (prev_bit != curr_bit) {
 | 
			
		||||
        matrix_debouncing[row] ^= ((matrix_row_t)1<<col);
 | 
			
		||||
        debouncing = DEBOUNCING_DELAY;
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    unselect_cols();
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if (debouncing) {
 | 
			
		||||
    if (--debouncing) {
 | 
			
		||||
      _delay_ms(1);
 | 
			
		||||
    } else {
 | 
			
		||||
      for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
 | 
			
		||||
        matrix[i] = matrix_debouncing[i];
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  matrix_scan_quantum();
 | 
			
		||||
  return 1;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
inline matrix_row_t matrix_get_row(uint8_t row) {
 | 
			
		||||
  return matrix[row];
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void matrix_print(void) {
 | 
			
		||||
  print("\nr/c 0123456789ABCDEF\n");
 | 
			
		||||
  for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
 | 
			
		||||
    xprintf("%02X: %032lb\n", row, bitrev32(matrix_get_row(row)));
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* Row pin configuration
 | 
			
		||||
 * row: 0    1    2    3    4    5
 | 
			
		||||
 * pin: PB7  PD0  PD1  PD2  PD3  PD5
 | 
			
		||||
 *
 | 
			
		||||
 * Esc uses its own pin PE2
 | 
			
		||||
 */
 | 
			
		||||
static void init_rows(void) {
 | 
			
		||||
  DDRB  &= ~0b10000000;
 | 
			
		||||
  PORTB &= ~0b10000000;
 | 
			
		||||
 | 
			
		||||
  DDRD  &= ~0b00101111;
 | 
			
		||||
  PORTD &= ~0b00101111;
 | 
			
		||||
 | 
			
		||||
  DDRE  &= ~0b00000100;
 | 
			
		||||
  PORTE |=  0b00000100;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static uint8_t read_rows() {
 | 
			
		||||
  return (PINB&(1<<7) ? (1<<0) : 0) |
 | 
			
		||||
    (PIND&(1<<0) ? (1<<1) : 0) |
 | 
			
		||||
    (PIND&(1<<1) ? (1<<2) : 0) |
 | 
			
		||||
    (PIND&(1<<2) ? (1<<3) : 0) |
 | 
			
		||||
    (PIND&(1<<3) ? (1<<4) : 0) |
 | 
			
		||||
    (PIND&(1<<5) ? (1<<5) : 0);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static uint8_t read_fwkey(void)
 | 
			
		||||
{
 | 
			
		||||
  return PINE&(1<<2) ? 0 : (1<<0);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* Columns 0 - 15
 | 
			
		||||
 * These columns uses two 74HC237D 3 to 8 bit demultiplexers.
 | 
			
		||||
 * col / pin:    PC6  PB6  PF0  PF1  PC7
 | 
			
		||||
 * 0:             1    0    0    0    0
 | 
			
		||||
 * 1:             1    0    1    0    0
 | 
			
		||||
 * 2:             1    0    0    1    0
 | 
			
		||||
 * 3:             1    0    1    1    0
 | 
			
		||||
 * 4:             1    0    0    0    1
 | 
			
		||||
 * 5:             1    0    1    0    1
 | 
			
		||||
 * 6:             1    0    0    1    1
 | 
			
		||||
 * 7:             1    0    1    1    1
 | 
			
		||||
 * 8:             0    1    0    0    0
 | 
			
		||||
 * 9:             0    1    1    0    0
 | 
			
		||||
 * 10:            0    1    0    1    0
 | 
			
		||||
 * 11:            0    1    1    1    0
 | 
			
		||||
 * 12:            0    1    0    0    1
 | 
			
		||||
 * 13:            0    1    1    0    1
 | 
			
		||||
 * 14:            0    1    0    1    1
 | 
			
		||||
 * 15:            0    1    1    1    1
 | 
			
		||||
 *
 | 
			
		||||
 * col: 16
 | 
			
		||||
 * pin: PB5
 | 
			
		||||
 *
 | 
			
		||||
 * col: 17
 | 
			
		||||
 * pin: PB4
 | 
			
		||||
 *
 | 
			
		||||
 * col: 18
 | 
			
		||||
 * pin: PD7
 | 
			
		||||
 */
 | 
			
		||||
static void unselect_cols(void) {
 | 
			
		||||
  DDRB  |=  0b01110000;
 | 
			
		||||
  PORTB &= ~0b01110000;
 | 
			
		||||
 | 
			
		||||
  DDRC |= (1<<6) | (1<<7);
 | 
			
		||||
  PORTC &= ~((1<<6) | (1<<7));
 | 
			
		||||
 | 
			
		||||
  DDRF |= (1<<0) | (1<<1);
 | 
			
		||||
  PORTF &= ~((1<<0) | (1<<1));
 | 
			
		||||
 | 
			
		||||
  DDRD |= (1<<7);
 | 
			
		||||
  PORTD &= ~(1<<7);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void select_col(uint8_t col) {
 | 
			
		||||
  switch (col) {
 | 
			
		||||
    case 0:
 | 
			
		||||
      PORTC |= (1<<6);
 | 
			
		||||
      break;
 | 
			
		||||
    case 1:
 | 
			
		||||
      PORTC |= (1<<6);
 | 
			
		||||
      PORTF |= (1<<0);
 | 
			
		||||
      break;
 | 
			
		||||
    case 2:
 | 
			
		||||
      PORTC |= (1<<6);
 | 
			
		||||
      PORTF |= (1<<1);
 | 
			
		||||
      break;
 | 
			
		||||
    case 3:
 | 
			
		||||
      PORTC |= (1<<6);
 | 
			
		||||
      PORTF |= (1<<0) | (1<<1);
 | 
			
		||||
      break;
 | 
			
		||||
    case 4:
 | 
			
		||||
      PORTC |= (1<<6);
 | 
			
		||||
      PORTC |= (1<<7);
 | 
			
		||||
      break;
 | 
			
		||||
    case 5:
 | 
			
		||||
      PORTC |= (1<<6);
 | 
			
		||||
      PORTF |= (1<<0);
 | 
			
		||||
      PORTC |= (1<<7);
 | 
			
		||||
      break;
 | 
			
		||||
    case 6:
 | 
			
		||||
      PORTC |= (1<<6);
 | 
			
		||||
      PORTF |= (1<<1);
 | 
			
		||||
      PORTC |= (1<<7);
 | 
			
		||||
      break;
 | 
			
		||||
    case 7:
 | 
			
		||||
      PORTC |= (1<<6);
 | 
			
		||||
      PORTF |= (1<<0) | (1<<1);
 | 
			
		||||
      PORTC |= (1<<7);
 | 
			
		||||
      break;
 | 
			
		||||
    case 8:
 | 
			
		||||
      PORTB |= (1<<6);
 | 
			
		||||
      break;
 | 
			
		||||
    case 9:
 | 
			
		||||
      PORTB |= (1<<6);
 | 
			
		||||
      PORTF |= (1<<0);
 | 
			
		||||
      break;
 | 
			
		||||
    case 10:
 | 
			
		||||
      PORTB |= (1<<6);
 | 
			
		||||
      PORTF |= (1<<1);
 | 
			
		||||
      break;
 | 
			
		||||
    case 11:
 | 
			
		||||
      PORTB |= (1<<6);
 | 
			
		||||
      PORTF |= (1<<0) | (1<<1);
 | 
			
		||||
      break;
 | 
			
		||||
    case 12:
 | 
			
		||||
      PORTB |= (1<<6);
 | 
			
		||||
      PORTC |= (1<<7);
 | 
			
		||||
      break;
 | 
			
		||||
    case 13:
 | 
			
		||||
      PORTB |= (1<<6);
 | 
			
		||||
      PORTF |= (1<<0);
 | 
			
		||||
      PORTC |= (1<<7);
 | 
			
		||||
      break;
 | 
			
		||||
    case 14:
 | 
			
		||||
      PORTB |= (1<<6);
 | 
			
		||||
      PORTF |= (1<<1);
 | 
			
		||||
      PORTC |= (1<<7);
 | 
			
		||||
      break;
 | 
			
		||||
    case 15:
 | 
			
		||||
      PORTB |= (1<<6);
 | 
			
		||||
      PORTF |= (1<<0) | (1<<1);
 | 
			
		||||
      PORTC |= (1<<7);
 | 
			
		||||
      break;
 | 
			
		||||
    case 16:
 | 
			
		||||
      PORTB |= (1<<5);
 | 
			
		||||
      break;
 | 
			
		||||
    case 17:
 | 
			
		||||
      PORTB |= (1<<4);
 | 
			
		||||
      break;
 | 
			
		||||
    case 18:
 | 
			
		||||
      PORTD |= (1<<7);
 | 
			
		||||
      break;
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										19
									
								
								keyboards/duck/lightsaver/readme.md
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								keyboards/duck/lightsaver/readme.md
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,19 @@
 | 
			
		|||
# Duck Lightsaver V3
 | 
			
		||||
 | 
			
		||||

 | 
			
		||||
 | 
			
		||||
Non official firmware for custom Korean keyboard with 96 key layout made by Duck.  
 | 
			
		||||
Group buy was run 2017 May via [geekhack](https://geekhack.org/index.php?topic=89546.0) and limited to 100 units.
 | 
			
		||||
 | 
			
		||||
Keyboard Maintainer: [Rasmus Schults](https://github.com/rasmusx)  
 | 
			
		||||
Hardware Supported: Lightsaver PCB Ver 3.0, Atmega32u4  
 | 
			
		||||
Hardware Availability: [geekhack](https://geekhack.org/index.php?topic=89546.0)
 | 
			
		||||
 | 
			
		||||
Make example for this keyboard (after setting up your build environment):
 | 
			
		||||
 | 
			
		||||
    make lightsaver:default
 | 
			
		||||
 | 
			
		||||
See [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.
 | 
			
		||||
 | 
			
		||||
## Notes
 | 
			
		||||
Thanks to Ralf Schmitt for previous implementations in his [TMK fork](https://github.com/xauser/tmk_keyboard/tree/xauser/) and few helping words.
 | 
			
		||||
							
								
								
									
										72
									
								
								keyboards/duck/lightsaver/rules.mk
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										72
									
								
								keyboards/duck/lightsaver/rules.mk
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,72 @@
 | 
			
		|||
# 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*
 | 
			
		||||
#   Teensy halfKay   512
 | 
			
		||||
#   Teensy++ halfKay 1024
 | 
			
		||||
#   Atmel DFU loader 4096
 | 
			
		||||
#   LUFA bootloader  4096
 | 
			
		||||
#   USBaspLoader     2048
 | 
			
		||||
OPT_DEFS += -DBOOTLOADER_SIZE=4096
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
# Build Options
 | 
			
		||||
#   change yes to no to disable
 | 
			
		||||
#
 | 
			
		||||
BOOTMAGIC_ENABLE ?= no       # Virtual DIP switch configuration(+1000)
 | 
			
		||||
MOUSEKEY_ENABLE ?= no        # Mouse keys(+4700)
 | 
			
		||||
EXTRAKEY_ENABLE ?= no        # Audio control and System control(+450)
 | 
			
		||||
CONSOLE_ENABLE ?= no         # Console for debug(+400)
 | 
			
		||||
COMMAND_ENABLE ?= yes        # Commands for debug and configuration
 | 
			
		||||
# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE
 | 
			
		||||
SLEEP_LED_ENABLE ?= no       # Breathing sleep LED during USB suspend
 | 
			
		||||
# if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work
 | 
			
		||||
NKRO_ENABLE ?= yes           # USB Nkey Rollover
 | 
			
		||||
BACKLIGHT_ENABLE ?= yes      # Enable keyboard backlight functionality on B7 by default
 | 
			
		||||
MIDI_ENABLE ?= no            # MIDI support (+2400 to 4200, depending on config)
 | 
			
		||||
UNICODE_ENABLE ?= no         # Unicode
 | 
			
		||||
BLUETOOTH_ENABLE ?= no       # Enable Bluetooth with the Adafruit EZ-Key HID
 | 
			
		||||
AUDIO_ENABLE ?= no           # Audio output on port C6
 | 
			
		||||
FAUXCLICKY_ENABLE ?= no      # Use buzzer to emulate clicky switches
 | 
			
		||||
RGBLIGHT_ENABLE = yes
 | 
			
		||||
 | 
			
		||||
CUSTOM_MATRIX = yes
 | 
			
		||||
SRC += indicator_leds.c \
 | 
			
		||||
			 matrix.c
 | 
			
		||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue