aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfauxpark <fauxpark@gmail.com>2020-02-05 13:41:19 +1100
committerGitHub <noreply@github.com>2020-02-04 18:41:19 -0800
commitefe8bd8e9218f67a0845ccfa3eef7b074aebf7dc (patch)
tree798b25c2b1bcb3c5a2982e748a95d947416da3e2
parent74e3cad72829f673b6398dc18257f9d05bdaa3fe (diff)
downloadqmk_firmware-efe8bd8e9218f67a0845ccfa3eef7b074aebf7dc.tar.gz
qmk_firmware-efe8bd8e9218f67a0845ccfa3eef7b074aebf7dc.zip
[Keyboard] LFKPad refactor (#8079)
-rw-r--r--keyboards/lfkeyboards/lfkpad/config.h131
-rw-r--r--keyboards/lfkeyboards/lfkpad/info.json40
-rw-r--r--keyboards/lfkeyboards/lfkpad/keymaps/default/config.h3
-rw-r--r--keyboards/lfkeyboards/lfkpad/keymaps/default/keymap.c50
-rw-r--r--keyboards/lfkeyboards/lfkpad/keymaps/default/readme.md2
-rw-r--r--keyboards/lfkeyboards/lfkpad/lfkpad.c92
-rw-r--r--keyboards/lfkeyboards/lfkpad/lfkpad.h22
-rw-r--r--keyboards/lfkeyboards/lfkpad/readme.md31
-rw-r--r--keyboards/lfkeyboards/lfkpad/rules.mk43
9 files changed, 242 insertions, 172 deletions
diff --git a/keyboards/lfkeyboards/lfkpad/config.h b/keyboards/lfkeyboards/lfkpad/config.h
index 1d8de837d..fb48297e5 100644
--- a/keyboards/lfkeyboards/lfkpad/config.h
+++ b/keyboards/lfkeyboards/lfkpad/config.h
@@ -15,31 +15,56 @@ You should have received a copy of the GNU General Public License
15along with this program. If not, see <http://www.gnu.org/licenses/>. 15along with this program. If not, see <http://www.gnu.org/licenses/>.
16*/ 16*/
17 17
18#ifndef CONFIG_H 18#pragma once
19#define CONFIG_H
20 19
21#include "config_common.h" 20#include "config_common.h"
22 21
22/* USB Device descriptor parameter */
23#define VENDOR_ID 0xFEED 23#define VENDOR_ID 0xFEED
24#define PRODUCT_ID 0x6060 24#define PRODUCT_ID 0x6060
25#define DEVICE_VER 0x0001 25#define DEVICE_VER 0x0001
26#define MANUFACTURER LFKeyboards 26#define MANUFACTURER LFKeyboards
27#define PRODUCT LFKPad 21 27#define PRODUCT LFKPad 21
28#define DESCRIPTION QMK keyboard firmware for LFKPad LFK_REV_STRING 28#define DESCRIPTION QMK keyboard firmware for LFKPad
29 29
30#define DIODE_DIRECTION COL2ROW 30/* key matrix size */
31#define MATRIX_ROWS 6 31#define MATRIX_ROWS 6
32#define MATRIX_COLS 4 32#define MATRIX_COLS 4
33#define MATRIX_ROW_PINS { D5, F4, F6, F7, C7, C6} 33
34#define MATRIX_COL_PINS { F1, F0, D4, D6} 34/*
35#define UNUSED_PINS { } 35 * Keyboard Matrix Assignments
36#define RGBLED_NUM 28 // Number of LEDs 36 *
37 * Change this to how you wired your keyboard
38 * COLS: AVR pins used for columns, left to right
39 * ROWS: AVR pins used for rows, top to bottom
40 * DIODE_DIRECTION: COL2ROW = COL = Anode (+), ROW = Cathode (-, marked on diode)
41 * ROW2COL = ROW = Anode (+), COL = Cathode (-, marked on diode)
42 *
43 */
44#define MATRIX_ROW_PINS { D5, F4, F6, F7, C7, C6 }
45#define MATRIX_COL_PINS { F1, F0, D4, D6 }
46#define UNUSED_PINS
47
48/* COL2ROW, ROW2COL*/
49#define DIODE_DIRECTION COL2ROW
50
51/*
52 * Split Keyboard specific options, make sure you have 'SPLIT_KEYBOARD = yes' in your rules.mk, and define SOFT_SERIAL_PIN.
53 */
54//#define SOFT_SERIAL_PIN D0 // or D1, D2, D3, E6
55
56// #define BACKLIGHT_PIN B7
57// #define BACKLIGHT_BREATHING
58// #define BACKLIGHT_LEVELS 3
37 59
38#define RGB_DI_PIN C7 // Have to set it to something to get the ws2812 code to compile 60#define RGB_DI_PIN C7 // Have to set it to something to get the ws2812 code to compile
39#define RGBLIGHT_ANIMATIONS 61#ifdef RGB_DI_PIN
40#define RGBLIGHT_HUE_STEP 10 62# define RGBLED_NUM 28
41#define RGBLIGHT_SAT_STEP 17 63# define RGBLIGHT_HUE_STEP 10
42#define RGBLIGHT_VAL_STEP 17 64# define RGBLIGHT_SAT_STEP 17
65# define RGBLIGHT_VAL_STEP 17
66# define RGBLIGHT_ANIMATIONS
67#endif
43 68
44#define TAPPING_TERM 200 69#define TAPPING_TERM 200
45 70
@@ -49,13 +74,16 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
49/* define if matrix has ghost (lacks anti-ghosting diodes) */ 74/* define if matrix has ghost (lacks anti-ghosting diodes) */
50//#define MATRIX_HAS_GHOST 75//#define MATRIX_HAS_GHOST
51 76
52/* number of backlight levels */
53
54/* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */ 77/* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */
55#define LOCKING_SUPPORT_ENABLE 78#define LOCKING_SUPPORT_ENABLE
56/* Locking resynchronize hack */ 79/* Locking resynchronize hack */
57#define LOCKING_RESYNC_ENABLE 80#define LOCKING_RESYNC_ENABLE
58 81
82/* If defined, GRAVE_ESC will always act as ESC when CTRL is held.
83 * This is userful for the Windows task manager shortcut (ctrl+shift+esc).
84 */
85// #define GRAVE_ESC_CTRL_OVERRIDE
86
59/* 87/*
60 * Force NKRO 88 * Force NKRO
61 * 89 *
@@ -89,6 +117,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
89 * 117 *
90 */ 118 */
91 119
120/* key combination for magic key command */
121/* defined by default; to change, uncomment and set to the combination you want */
122// #define IS_COMMAND() (get_mods() == MOD_MASK_SHIFT)
123
92/* control how magic key switches layers */ 124/* control how magic key switches layers */
93//#define MAGIC_KEY_SWITCH_LAYER_WITH_FKEYS true 125//#define MAGIC_KEY_SWITCH_LAYER_WITH_FKEYS true
94//#define MAGIC_KEY_SWITCH_LAYER_WITH_NKEYS true 126//#define MAGIC_KEY_SWITCH_LAYER_WITH_NKEYS true
@@ -98,8 +130,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
98//#define MAGIC_KEY_SWITCH_LAYER_WITH_FKEYS 130//#define MAGIC_KEY_SWITCH_LAYER_WITH_FKEYS
99//#define MAGIC_KEY_SWITCH_LAYER_WITH_NKEYS 131//#define MAGIC_KEY_SWITCH_LAYER_WITH_NKEYS
100//#define MAGIC_KEY_SWITCH_LAYER_WITH_CUSTOM 132//#define MAGIC_KEY_SWITCH_LAYER_WITH_CUSTOM
101//#define MAGIC_KEY_HELP1 H 133//#define MAGIC_KEY_HELP H
102//#define MAGIC_KEY_HELP2 SLASH 134//#define MAGIC_KEY_HELP_ALT SLASH
103//#define MAGIC_KEY_DEBUG D 135//#define MAGIC_KEY_DEBUG D
104//#define MAGIC_KEY_DEBUG_MATRIX X 136//#define MAGIC_KEY_DEBUG_MATRIX X
105//#define MAGIC_KEY_DEBUG_KBD K 137//#define MAGIC_KEY_DEBUG_KBD K
@@ -107,9 +139,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
107//#define MAGIC_KEY_VERSION V 139//#define MAGIC_KEY_VERSION V
108//#define MAGIC_KEY_STATUS S 140//#define MAGIC_KEY_STATUS S
109//#define MAGIC_KEY_CONSOLE C 141//#define MAGIC_KEY_CONSOLE C
110//#define MAGIC_KEY_LAYER0_ALT1 ESC
111//#define MAGIC_KEY_LAYER0_ALT2 GRAVE
112//#define MAGIC_KEY_LAYER0 0 142//#define MAGIC_KEY_LAYER0 0
143//#define MAGIC_KEY_LAYER0_ALT GRAVE
113//#define MAGIC_KEY_LAYER1 1 144//#define MAGIC_KEY_LAYER1 1
114//#define MAGIC_KEY_LAYER2 2 145//#define MAGIC_KEY_LAYER2 2
115//#define MAGIC_KEY_LAYER3 3 146//#define MAGIC_KEY_LAYER3 3
@@ -119,9 +150,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
119//#define MAGIC_KEY_LAYER7 7 150//#define MAGIC_KEY_LAYER7 7
120//#define MAGIC_KEY_LAYER8 8 151//#define MAGIC_KEY_LAYER8 8
121//#define MAGIC_KEY_LAYER9 9 152//#define MAGIC_KEY_LAYER9 9
122//#define MAGIC_KEY_BOOTLOADER PAUSE 153//#define MAGIC_KEY_BOOTLOADER B
154//#define MAGIC_KEY_BOOTLOADER_ALT ESC
123//#define MAGIC_KEY_LOCK CAPS 155//#define MAGIC_KEY_LOCK CAPS
124//#define MAGIC_KEY_EEPROM E 156//#define MAGIC_KEY_EEPROM E
157//#define MAGIC_KEY_EEPROM_CLEAR BSPACE
125//#define MAGIC_KEY_NKRO N 158//#define MAGIC_KEY_NKRO N
126//#define MAGIC_KEY_SLEEP_LED Z 159//#define MAGIC_KEY_SLEEP_LED Z
127 160
@@ -140,7 +173,63 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
140//#define NO_ACTION_LAYER 173//#define NO_ACTION_LAYER
141//#define NO_ACTION_TAPPING 174//#define NO_ACTION_TAPPING
142//#define NO_ACTION_ONESHOT 175//#define NO_ACTION_ONESHOT
143//#define NO_ACTION_MACRO
144//#define NO_ACTION_FUNCTION
145 176
177/* disable these deprecated features by default */
178#ifndef LINK_TIME_OPTIMIZATION_ENABLE
179 #define NO_ACTION_MACRO
180 #define NO_ACTION_FUNCTION
181#endif
182/*
183 * MIDI options
184 */
185
186/* Prevent use of disabled MIDI features in the keymap */
187//#define MIDI_ENABLE_STRICT 1
188
189/* enable basic MIDI features:
190 - MIDI notes can be sent when in Music mode is on
191*/
192//#define MIDI_BASIC
193
194/* enable advanced MIDI features:
195 - MIDI notes can be added to the keymap
196 - Octave shift and transpose
197 - Virtual sustain, portamento, and modulation wheel
198 - etc.
199*/
200//#define MIDI_ADVANCED
201
202/* override number of MIDI tone keycodes (each octave adds 12 keycodes and allocates 12 bytes) */
203//#define MIDI_TONE_KEYCODE_OCTAVES 1
204
205/*
206 * HD44780 LCD Display Configuration
207 */
208/*
209#define LCD_LINES 2 //< number of visible lines of the display
210#define LCD_DISP_LENGTH 16 //< visibles characters per line of the display
211
212#define LCD_IO_MODE 1 //< 0: memory mapped mode, 1: IO port mode
213
214#if LCD_IO_MODE
215#define LCD_PORT PORTB //< port for the LCD lines
216#define LCD_DATA0_PORT LCD_PORT //< port for 4bit data bit 0
217#define LCD_DATA1_PORT LCD_PORT //< port for 4bit data bit 1
218#define LCD_DATA2_PORT LCD_PORT //< port for 4bit data bit 2
219#define LCD_DATA3_PORT LCD_PORT //< port for 4bit data bit 3
220#define LCD_DATA0_PIN 4 //< pin for 4bit data bit 0
221#define LCD_DATA1_PIN 5 //< pin for 4bit data bit 1
222#define LCD_DATA2_PIN 6 //< pin for 4bit data bit 2
223#define LCD_DATA3_PIN 7 //< pin for 4bit data bit 3
224#define LCD_RS_PORT LCD_PORT //< port for RS line
225#define LCD_RS_PIN 3 //< pin for RS line
226#define LCD_RW_PORT LCD_PORT //< port for RW line
227#define LCD_RW_PIN 2 //< pin for RW line
228#define LCD_E_PORT LCD_PORT //< port for Enable line
229#define LCD_E_PIN 1 //< pin for Enable line
146#endif 230#endif
231*/
232
233/* Bootmagic Lite key configuration */
234// #define BOOTMAGIC_LITE_ROW 0
235// #define BOOTMAGIC_LITE_COLUMN 0
diff --git a/keyboards/lfkeyboards/lfkpad/info.json b/keyboards/lfkeyboards/lfkpad/info.json
index 71adb5d44..f5f41f5a7 100644
--- a/keyboards/lfkeyboards/lfkpad/info.json
+++ b/keyboards/lfkeyboards/lfkpad/info.json
@@ -1,12 +1,34 @@
1{ 1{
2 "keyboard_name": "LFKPad", 2 "keyboard_name": "LFKPad",
3 "url": "", 3 "url": "",
4 "maintainer": "qmk", 4 "maintainer": "qmk",
5 "width": 4, 5 "width": 4,
6 "height": 6, 6 "height": 6,
7 "layouts": { 7 "layouts": {
8 "LAYOUT_numpad_6x4": { 8 "LAYOUT_numpad_6x4": {
9 "layout": [{"label":"Esc", "x":0, "y":0}, {"label":"Tab", "x":1, "y":0}, {"label":"=", "x":2, "y":0}, {"label":"Fn", "x":3, "y":0}, {"label":"Num Lock", "x":0, "y":1}, {"label":"/", "x":1, "y":1}, {"label":"*", "x":2, "y":1}, {"label":"-", "x":3, "y":1}, {"label":"7", "x":0, "y":2}, {"label":"8", "x":1, "y":2}, {"label":"9", "x":2, "y":2}, {"label":"4", "x":0, "y":3}, {"label":"5", "x":1, "y":3}, {"label":"6", "x":2, "y":3}, {"label":"+", "x":3, "y":2, "h":2}, {"label":"1", "x":0, "y":4}, {"label":"2", "x":1, "y":4}, {"label":"3", "x":2, "y":4}, {"label":"0", "x":0, "y":5, "w":2}, {"label":".", "x":2, "y":5}, {"label":"Enter", "x":3, "y":4, "h":2}] 9 "layout": [
10 {"x":0, "y":0},
11 {"x":1, "y":0},
12 {"x":2, "y":0},
13 {"x":3, "y":0},
14 {"x":0, "y":1},
15 {"x":1, "y":1},
16 {"x":2, "y":1},
17 {"x":3, "y":1},
18 {"x":0, "y":2},
19 {"x":1, "y":2},
20 {"x":2, "y":2},
21 {"x":0, "y":3},
22 {"x":1, "y":3},
23 {"x":2, "y":3},
24 {"x":3, "y":2, "h":2},
25 {"x":0, "y":4},
26 {"x":1, "y":4},
27 {"x":2, "y":4},
28 {"x":0, "y":5, "w":2},
29 {"x":2, "y":5},
30 {"x":3, "y":4, "h":2}
31 ]
32 }
10 } 33 }
11 }
12} 34}
diff --git a/keyboards/lfkeyboards/lfkpad/keymaps/default/config.h b/keyboards/lfkeyboards/lfkpad/keymaps/default/config.h
deleted file mode 100644
index 271f48d00..000000000
--- a/keyboards/lfkeyboards/lfkpad/keymaps/default/config.h
+++ /dev/null
@@ -1,3 +0,0 @@
1#pragma once
2
3// place overrides here
diff --git a/keyboards/lfkeyboards/lfkpad/keymaps/default/keymap.c b/keyboards/lfkeyboards/lfkpad/keymaps/default/keymap.c
index 3e131b241..0aa720e40 100644
--- a/keyboards/lfkeyboards/lfkpad/keymaps/default/keymap.c
+++ b/keyboards/lfkeyboards/lfkpad/keymaps/default/keymap.c
@@ -1,41 +1,31 @@
1#include QMK_KEYBOARD_H 1#include QMK_KEYBOARD_H
2 2
3const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { 3const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
4 [0] = LAYOUT_numpad_6x4( /* Base */ 4 /* Base */
5 KC_ESC, KC_TAB, KC_PEQL, MO(1), \ 5 [0] = LAYOUT_numpad_6x4(
6 KC_LNUM, KC_PSLS, KC_PAST, KC_PMNS, \ 6 KC_ESC, KC_TAB, KC_PEQL, MO(1),
7 KC_P7, KC_P8, KC_P9, \ 7 KC_LNUM, KC_PSLS, KC_PAST, KC_PMNS,
8 KC_P4, KC_P5, KC_P6, KC_PPLS, \ 8 KC_P7, KC_P8, KC_P9,
9 KC_P1, KC_P2, KC_P3, \ 9 KC_P4, KC_P5, KC_P6, KC_PPLS,
10 KC_P0, KC_PDOT, KC_PENT \ 10 KC_P1, KC_P2, KC_P3,
11 ), 11 KC_P0, KC_PDOT, KC_PENT
12 12 ),
13 [1] = LAYOUT_numpad_6x4( /* RGB */ 13
14 RGB_SAI, RGB_VAI, RGB_HUI, _______, \ 14 /* RGB */
15 RGB_SAD, RGB_VAD, RGB_HUD, _______, \ 15 [1] = LAYOUT_numpad_6x4(
16 RGB_M_X, RGB_M_G, RGB_MOD, \ 16 RGB_SAI, RGB_VAI, RGB_HUI, _______,
17 RGB_M_SW, RGB_M_SN, RGB_M_K, RGB_RMOD, \ 17 RGB_SAD, RGB_VAD, RGB_HUD, _______,
18 RGB_M_P, RGB_M_B, RGB_M_R, \ 18 RGB_M_X, RGB_M_G, RGB_MOD,
19 XXXXXXX, XXXXXXX, RGB_TOG \ 19 RGB_M_SW,RGB_M_SN,RGB_M_K, RGB_RMOD,
20 ), 20 RGB_M_P, RGB_M_B, RGB_M_R,
21 XXXXXXX, XXXXXXX, RGB_TOG
22 )
21}; 23};
22 24
23void matrix_init_user(void) { 25void matrix_init_user(void) {
24 // This keymap only has a single base layer, so reset the default if needed 26 // This keymap only has a single base layer, so reset the default if needed
25 if(eeconfig_read_default_layer() > 1){ 27 if (eeconfig_read_default_layer() > 1) {
26 eeconfig_update_default_layer(1); 28 eeconfig_update_default_layer(1);
27 default_layer_set(1); 29 default_layer_set(1);
28 } 30 }
29} 31}
30
31void matrix_scan_user(void) {
32
33}
34
35bool process_record_user(uint16_t keycode, keyrecord_t *record) {
36 return true;
37}
38
39void led_set_user(uint8_t usb_led) {
40
41}
diff --git a/keyboards/lfkeyboards/lfkpad/keymaps/default/readme.md b/keyboards/lfkeyboards/lfkpad/keymaps/default/readme.md
index 6c48b8d0b..9c0dad030 100644
--- a/keyboards/lfkeyboards/lfkpad/keymaps/default/readme.md
+++ b/keyboards/lfkeyboards/lfkpad/keymaps/default/readme.md
@@ -1 +1 @@
# The default keymap LFKPad 21 # The default keymap for the LFKPad 21
diff --git a/keyboards/lfkeyboards/lfkpad/lfkpad.c b/keyboards/lfkeyboards/lfkpad/lfkpad.c
index 232285c32..b91b7da67 100644
--- a/keyboards/lfkeyboards/lfkpad/lfkpad.c
+++ b/keyboards/lfkeyboards/lfkpad/lfkpad.c
@@ -1,112 +1,117 @@
1#include <avr/sfr_defs.h> 1#include "lfkpad.h"
2
3#include "quantum.h"
4
2#include <avr/timer_avr.h> 5#include <avr/timer_avr.h>
3#include <avr/wdt.h> 6#include <avr/wdt.h>
4#include "lfkpad.h"
5#include "keymap.h"
6#include "issi.h" 7#include "issi.h"
7#include "TWIlib.h" 8#include "TWIlib.h"
8#include "lighting.h" 9#include "lighting.h"
9#include "debug.h"
10#include "quantum.h"
11 10
12uint16_t click_hz = CLICK_HZ; 11uint16_t click_hz = CLICK_HZ;
13uint16_t click_time = CLICK_MS; 12uint16_t click_time = CLICK_MS;
14uint8_t click_toggle = CLICK_ENABLED; 13uint8_t click_toggle = CLICK_ENABLED;
15 14
16 15void matrix_init_kb(void) {
17void matrix_init_kb(void)
18{
19 matrix_init_user(); 16 matrix_init_user();
17
20#ifndef AUDIO_ENABLE 18#ifndef AUDIO_ENABLE
21 // If we're not using the audio pin, drive it low 19 // If we're not using the audio pin, drive it low
22 sbi(DDRC, 6); 20 setPinOutput(C6);
23 cbi(PORTC, 6); 21 writePinLow(C6);
24#endif 22#endif
25 23
26#ifdef ISSI_ENABLE 24#ifdef ISSI_ENABLE
27 issi_init(); 25 issi_init();
28#endif 26#endif
27
29#ifdef WATCHDOG_ENABLE 28#ifdef WATCHDOG_ENABLE
30 // This is done after turning the layer LED red, if we're caught in a loop 29 // This is done after turning the layer LED red, if we're caught in a loop
31 // we should get a flashing red light 30 // we should get a flashing red light
32 wdt_enable(WDTO_500MS); 31 wdt_enable(WDTO_500MS);
33#endif 32#endif
34
35} 33}
36 34
37void matrix_scan_kb(void) 35void matrix_scan_kb(void) {
38{
39#ifdef WATCHDOG_ENABLE 36#ifdef WATCHDOG_ENABLE
40 wdt_reset(); 37 wdt_reset();
41#endif 38#endif
39
42#ifdef ISSI_ENABLE 40#ifdef ISSI_ENABLE
43 // switch/underglow lighting update 41 // switch/underglow lighting update
44 static uint32_t issi_device = 0; 42 static uint32_t issi_device = 0;
45 static uint32_t twi_last_ready = 0; 43 static uint32_t twi_last_ready = 0;
46 if(twi_last_ready > 1000){ 44
47 // Its been way too long since the last ISSI update, reset the I2C bus and start again 45 if (twi_last_ready > 1000) {
46 // It's been way too long since the last ISSI update, reset the I2C bus and start again
48 dprintf("TWI failed to recover, TWI re-init\n"); 47 dprintf("TWI failed to recover, TWI re-init\n");
49 twi_last_ready = 0; 48 twi_last_ready = 0;
50 TWIInit(); 49 TWIInit();
51 force_issi_refresh(); 50 force_issi_refresh();
52 } 51 }
53 if(isTWIReady()){ 52
53 if (isTWIReady()) {
54 twi_last_ready = 0; 54 twi_last_ready = 0;
55 // If the i2c bus is available, kick off the issi update, alternate between devices 55 // If the i2c bus is available, kick off the issi update, alternate between devices
56 update_issi(issi_device, issi_device); 56 update_issi(issi_device, issi_device);
57 if(issi_device){ 57
58 if (issi_device) {
58 issi_device = 0; 59 issi_device = 0;
59 }else{ 60 } else {
60 issi_device = 3; 61 issi_device = 3;
61 } 62 }
62 }else{ 63 } else {
63 twi_last_ready++; 64 twi_last_ready++;
64 } 65 }
65#endif 66#endif
67
66 matrix_scan_user(); 68 matrix_scan_user();
67} 69}
68 70
69void click(uint16_t freq, uint16_t duration){ 71void click(uint16_t freq, uint16_t duration) {
70#ifdef AUDIO_ENABLE 72#ifdef AUDIO_ENABLE
71 if(freq >= 100 && freq <= 20000 && duration < 100){ 73 if (freq >= 100 && freq <= 20000 && duration < 100) {
72 play_note(freq, 10); 74 play_note(freq, 10);
73 for (uint16_t i = 0; i < duration; i++){ 75
76 for (uint16_t i = 0; i < duration; i++) {
74 _delay_ms(1); 77 _delay_ms(1);
75 } 78 }
79
76 stop_all_notes(); 80 stop_all_notes();
77 } 81 }
78#endif 82#endif
79} 83}
80 84
81bool process_record_kb(uint16_t keycode, keyrecord_t* record) 85bool process_record_kb(uint16_t keycode, keyrecord_t* record) {
82{ 86 if (click_toggle && record->event.pressed) {
83 if (click_toggle && record->event.pressed){
84 click(click_hz, click_time); 87 click(click_hz, click_time);
85 } 88 }
89
86 if (keycode == RESET) { 90 if (keycode == RESET) {
87 reset_keyboard_kb(); 91 reset_keyboard_kb();
88 } else {
89 } 92 }
93
90 return process_record_user(keycode, record); 94 return process_record_user(keycode, record);
91} 95}
92 96
93void action_function(keyrecord_t *event, uint8_t id, uint8_t opt) 97void action_function(keyrecord_t *event, uint8_t id, uint8_t opt) {
94{
95#ifdef AUDIO_ENABLE 98#ifdef AUDIO_ENABLE
96 int8_t sign = 1; 99 int8_t sign = 1;
97#endif 100#endif
98 if(id == LFK_ESC_TILDE){ 101
102 if (id == LFK_ESC_TILDE) {
99 // Send ~ on shift-esc 103 // Send ~ on shift-esc
100 void (*method)(uint8_t) = (event->event.pressed) ? &add_key : &del_key; 104 void (*method)(uint8_t) = (event->event.pressed) ? &add_key : &del_key;
101 uint8_t shifted = get_mods() & (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)); 105 uint8_t shifted = get_mods() & MOD_MASK_SHIFT;
102 if(layer_state == 0){ 106
107 if (layer_state == 0) {
103 method(shifted ? KC_GRAVE : KC_ESCAPE); 108 method(shifted ? KC_GRAVE : KC_ESCAPE);
104 }else{ 109 } else {
105 method(shifted ? KC_ESCAPE : KC_GRAVE); 110 method(shifted ? KC_ESCAPE : KC_GRAVE);
106 } 111 }
107 send_keyboard_report(); 112 send_keyboard_report();
108 }else if(event->event.pressed){ 113 } else if (event->event.pressed) {
109 switch(id){ 114 switch (id) {
110 case LFK_SET_DEFAULT_LAYER: 115 case LFK_SET_DEFAULT_LAYER:
111 // set/save the current base layer to eeprom, falls through to LFK_CLEAR 116 // set/save the current base layer to eeprom, falls through to LFK_CLEAR
112 eeconfig_update_default_layer(1UL << opt); 117 eeconfig_update_default_layer(1UL << opt);
@@ -117,24 +122,24 @@ void action_function(keyrecord_t *event, uint8_t id, uint8_t opt)
117 break; 122 break;
118#ifdef AUDIO_ENABLE 123#ifdef AUDIO_ENABLE
119 case LFK_CLICK_FREQ_LOWER: 124 case LFK_CLICK_FREQ_LOWER:
120 sign = -1; // continue to next statement 125 sign = -1; // continue to next statement
121 case LFK_CLICK_FREQ_HIGHER: 126 case LFK_CLICK_FREQ_HIGHER:
122 click_hz += sign * 100; 127 click_hz += sign * 100;
123 click(click_hz, click_time); 128 click(click_hz, click_time);
124 break; 129 break;
125 case LFK_CLICK_TOGGLE: 130 case LFK_CLICK_TOGGLE:
126 if(click_toggle){ 131 if (click_toggle) {
127 click_toggle = 0; 132 click_toggle = 0;
128 click(4000, 100); 133 click(4000, 100);
129 click(1000, 100); 134 click(1000, 100);
130 }else{ 135 } else {
131 click_toggle = 1; 136 click_toggle = 1;
132 click(1000, 100); 137 click(1000, 100);
133 click(4000, 100); 138 click(4000, 100);
134 } 139 }
135 break; 140 break;
136 case LFK_CLICK_TIME_SHORTER: 141 case LFK_CLICK_TIME_SHORTER:
137 sign = -1; // continue to next statement 142 sign = -1; // continue to next statement
138 case LFK_CLICK_TIME_LONGER: 143 case LFK_CLICK_TIME_LONGER:
139 click_time += sign; 144 click_time += sign;
140 click(click_hz, click_time); 145 click(click_hz, click_time);
@@ -144,22 +149,18 @@ void action_function(keyrecord_t *event, uint8_t id, uint8_t opt)
144 } 149 }
145} 150}
146 151
147void reset_keyboard_kb(){ 152void reset_keyboard_kb() {
148#ifdef WATCHDOG_ENABLE 153#ifdef WATCHDOG_ENABLE
149 MCUSR = 0; 154 MCUSR = 0;
150 wdt_disable(); 155 wdt_disable();
151 wdt_reset(); 156 wdt_reset();
152#endif 157#endif
153 reset_keyboard();
154}
155 158
156void led_set_kb(uint8_t usb_led) 159 reset_keyboard();
157{
158 led_set_user(usb_led);
159} 160}
160 161
161// LFK lighting info 162// LFK lighting info
162const uint8_t rgb_matrices[] = {0, 1}; 163const uint8_t rgb_matrices[] = { 0, 1 };
163const uint8_t rgb_sequence[] = { 164const uint8_t rgb_sequence[] = {
164 32, 1, 2, 3, 165 32, 1, 2, 3,
165 31, 30, 5, 6, 166 31, 30, 5, 6,
@@ -172,5 +173,4 @@ const uint8_t rgb_sequence[] = {
172 4, 25, 173 4, 25,
173 13, 24, 174 13, 24,
174 20 175 20
175
176}; 176};
diff --git a/keyboards/lfkeyboards/lfkpad/lfkpad.h b/keyboards/lfkeyboards/lfkpad/lfkpad.h
index a4c248e2a..0f34150db 100644
--- a/keyboards/lfkeyboards/lfkpad/lfkpad.h
+++ b/keyboards/lfkeyboards/lfkpad/lfkpad.h
@@ -1,23 +1,6 @@
1#ifndef LFKPAD_H 1#pragma once
2#define LFKPAD_H
3
4/* if the kb.h file exists (because we're running from qmkbuilder) include it */
5#if __has_include("kb.h")
6#include "kb.h"
7#endif
8 2
9#include "quantum.h" 3#include "quantum.h"
10#include "matrix.h"
11#include <avr/sfr_defs.h>
12
13#ifndef cbi
14#define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit))
15#endif
16
17#ifndef sbi
18#define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))
19#endif
20
21 4
22typedef struct RGB_Color { 5typedef struct RGB_Color {
23 uint16_t red; 6 uint16_t red;
@@ -57,7 +40,6 @@ void click(uint16_t freq, uint16_t duration);
57// readability 40// readability
58#define ___ KC_NO 41#define ___ KC_NO
59 42
60
61#define LAYOUT_numpad_6x4( \ 43#define LAYOUT_numpad_6x4( \
62 k00, k01, k02, k03, \ 44 k00, k01, k02, k03, \
63 k10, k11, k12, k13, \ 45 k10, k11, k12, k13, \
@@ -73,5 +55,3 @@ void click(uint16_t freq, uint16_t duration);
73 { k40, k41, k42, k43 }, \ 55 { k40, k41, k42, k43 }, \
74 { k50, ___, k52, ___ } \ 56 { k50, ___, k52, ___ } \
75} 57}
76
77#endif //LFKPAD_H
diff --git a/keyboards/lfkeyboards/lfkpad/readme.md b/keyboards/lfkeyboards/lfkpad/readme.md
index 7dd8337e8..ce5e7f67b 100644
--- a/keyboards/lfkeyboards/lfkpad/readme.md
+++ b/keyboards/lfkeyboards/lfkpad/readme.md
@@ -1,28 +1,15 @@
1bluepad keyboard firmware 1# LFKPad
2======================
3 2
4## Quantum MK Firmware 3![LFKPad](https://cdn11.bigcommerce.com/s-dvx2zpcx7r/images/stencil/500x659/products/118/385/img_0256__06462.1546304848.jpg)
5 4
6For the full Quantum feature list, see [the parent readme.md](/docs/README.md). 5Hotswap 21-key numpad PCB with USB-C, per-key RGB and underglow.
7 6
8## Building 7* Keyboard Maintainer: QMK community
8* Hardware Supported: LFKPad HS21 PCB
9* Hardware Availability: [LFKeyboards](https://www.lfkeyboards.com/lfkpad/)
9 10
10Download or clone the whole firmware and navigate to the keyboards/bluepad folder. Once your dev env is setup, you'll be able to type `make` to generate your .hex - you can then use the Teensy Loader to program your .hex file. 11Make example for this keyboard (after setting up your build environment):
11 12
12Depending on which keymap you would like to use, you will have to compile slightly differently. 13 make lfkeyboards/lfkpad:default
13 14
14### Default 15See the [build environment setup](https://docs.qmk.fm/#/getting_started_build_tools) and the [make instructions](https://docs.qmk.fm/#/getting_started_make_guide) for more information. Brand new to QMK? Start with our [Complete Newbs Guide](https://docs.qmk.fm/#/newbs).
15
16To build with the default keymap, simply run `make`.
17
18### Other Keymaps
19
20Several version of keymap are available in advance but you are recommended to define your favorite layout yourself. To define your own keymap create a folder with the name of your keymap in the keymaps folder, and see keymap documentation (you can find in top readme.md) and existant keymap files.
21
22To build the firmware binary hex file with a keymap just do `make` with `keymap` option like:
23
24```
25$ make keymap=[default|jack|<name>]
26```
27
28Keymaps follow the format **__keymap.c__** and are stored in folders in the `keymaps` folder, eg `keymaps/my_keymap/`
diff --git a/keyboards/lfkeyboards/lfkpad/rules.mk b/keyboards/lfkeyboards/lfkpad/rules.mk
index 1529f8986..aca77f562 100644
--- a/keyboards/lfkeyboards/lfkpad/rules.mk
+++ b/keyboards/lfkeyboards/lfkpad/rules.mk
@@ -11,26 +11,29 @@ MCU = atmega32u4
11# ATmega328P USBasp 11# ATmega328P USBasp
12BOOTLOADER = atmel-dfu 12BOOTLOADER = atmel-dfu
13 13
14LAYOUTS = numpad_6x4 14# Build Options
15 15# change yes to no to disable
16BOOTMAGIC_ENABLE = no # Virtual DIP switch configuration 16#
17MOUSEKEY_ENABLE = no # Mouse keys 17BOOTMAGIC_ENABLE = no # Virtual DIP switch configuration
18EXTRAKEY_ENABLE = yes # Audio control and System control 18MOUSEKEY_ENABLE = no # Mouse keys
19CONSOLE_ENABLE = no # Console for debug 19EXTRAKEY_ENABLE = yes # Audio control and System control
20COMMAND_ENABLE = no # Commands for debug and configuration 20CONSOLE_ENABLE = no # Console for debug
21NKRO_ENABLE = no # Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work 21COMMAND_ENABLE = no # Commands for debug and configuration
22BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality 22# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE
23MIDI_ENABLE = no # MIDI controls 23SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend
24AUDIO_ENABLE = no # Audio output on port C6 24# if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work
25UNICODE_ENABLE = no # Unicode 25NKRO_ENABLE = no # USB Nkey Rollover
26BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID 26BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality
27RGBLIGHT_ENABLE = yes # Enable WS2812 RGB underlight. 27RGBLIGHT_ENABLE = yes # Enable keyboard RGB underglow
28RGBLIGHT_CUSTOM_DRIVER = yes # RGB code is implemented in lefkeyboards, not qmk base 28RGBLIGHT_CUSTOM_DRIVER = yes # RGB code is implemented in lefkeyboards, not qmk base
29SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend 29MIDI_ENABLE = no # MIDI support
30TAP_DANCE_ENABLE = no 30BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID
31AUDIO_ENABLE = no # Audio output on port C6
32FAUXCLICKY_ENABLE = no # Use buzzer to emulate clicky switches
33HD44780_ENABLE = no # Enable support for HD44780 based LCDs
31 34
32ISSI_ENABLE = yes # If the I2C pullup resistors aren't install this must be disabled 35ISSI_ENABLE = yes # If the I2C pullup resistors aren't installed this must be disabled
33WATCHDOG_ENABLE = no # Resets keyboard if matrix_scan isn't run every 250ms 36WATCHDOG_ENABLE = no # Resets keyboard if matrix_scan() isn't run every 250ms
34 37
35SRC = TWIlib.c issi.c lighting.c 38SRC = TWIlib.c issi.c lighting.c
36 39
@@ -41,3 +44,5 @@ endif
41ifeq ($(strip $(WATCHDOG_ENABLE)), yes) 44ifeq ($(strip $(WATCHDOG_ENABLE)), yes)
42 TMK_COMMON_DEFS += -DWATCHDOG_ENABLE 45 TMK_COMMON_DEFS += -DWATCHDOG_ENABLE
43endif 46endif
47
48LAYOUTS = numpad_6x4