diff options
-rw-r--r-- | keyboards/cospad/config.h | 94 | ||||
-rw-r--r-- | keyboards/cospad/cospad.c | 37 | ||||
-rw-r--r-- | keyboards/cospad/cospad.h | 77 | ||||
-rw-r--r-- | keyboards/cospad/keymaps/default/keymap.c | 91 | ||||
-rw-r--r-- | keyboards/cospad/readme.md | 21 | ||||
-rw-r--r-- | keyboards/cospad/rules.mk | 66 | ||||
-rw-r--r-- | quantum/rgblight.c | 12 | ||||
-rw-r--r-- | quantum/rgblight.h | 3 |
8 files changed, 401 insertions, 0 deletions
diff --git a/keyboards/cospad/config.h b/keyboards/cospad/config.h new file mode 100644 index 000000000..4bdf434a4 --- /dev/null +++ b/keyboards/cospad/config.h | |||
@@ -0,0 +1,94 @@ | |||
1 | /* | ||
2 | Copyright 2012 Jun Wako <wakojun@gmail.com> | ||
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 | |||
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 0x6060 | ||
26 | #define DEVICE_VER 0x0001 | ||
27 | #define MANUFACTURER KPREPUBLIC | ||
28 | #define PRODUCT COSPAD | ||
29 | #define DESCRIPTION QMK keyboard firmware for COSPAD | ||
30 | |||
31 | /* key matrix size */ | ||
32 | #define MATRIX_ROWS 6 | ||
33 | #define MATRIX_COLS 4 | ||
34 | |||
35 | // ROWS: Top to bottom, COLS: Left to right | ||
36 | |||
37 | #define MATRIX_ROW_PINS { D0, D1, D2, D3, D4, D5 } | ||
38 | #define MATRIX_COL_PINS { F0, F1, E6, C7 } | ||
39 | #define UNUSED_PINS | ||
40 | |||
41 | #define BACKLIGHT_PIN F7 | ||
42 | |||
43 | /* COL2ROW or ROW2COL */ | ||
44 | #define DIODE_DIRECTION COL2ROW | ||
45 | |||
46 | /* define if matrix has ghost */ | ||
47 | //#define MATRIX_HAS_GHOST | ||
48 | |||
49 | /* Set 0 if debouncing isn't needed */ | ||
50 | #define DEBOUNCING_DELAY 5 | ||
51 | |||
52 | /* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */ | ||
53 | //#define LOCKING_SUPPORT_ENABLE | ||
54 | /* Locking resynchronize hack */ | ||
55 | #define LOCKING_RESYNC_ENABLE | ||
56 | |||
57 | /* key combination for command */ | ||
58 | #define IS_COMMAND() ( \ | ||
59 | keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \ | ||
60 | ) | ||
61 | |||
62 | /* Backlight configuration | ||
63 | */ | ||
64 | #define BACKLIGHT_LEVELS 4 | ||
65 | |||
66 | /* Underlight configuration | ||
67 | */ | ||
68 | |||
69 | #define RGB_DI_PIN F6 | ||
70 | #define RGBLIGHT_ANIMATIONS | ||
71 | #define RGBLED_NUM 4 // Number of LEDs | ||
72 | #define RGBLIGHT_HUE_STEP 10 | ||
73 | #define RGBLIGHT_SAT_STEP 17 | ||
74 | #define RGBLIGHT_VAL_STEP 17 | ||
75 | |||
76 | /* | ||
77 | * Feature disable options | ||
78 | * These options are also useful to firmware size reduction. | ||
79 | */ | ||
80 | |||
81 | /* disable debug print */ | ||
82 | //#define NO_DEBUG | ||
83 | |||
84 | /* disable print */ | ||
85 | //#define NO_PRINT | ||
86 | |||
87 | /* disable action features */ | ||
88 | //#define NO_ACTION_LAYER | ||
89 | //#define NO_ACTION_TAPPING | ||
90 | //#define NO_ACTION_ONESHOT | ||
91 | //#define NO_ACTION_MACRO | ||
92 | //#define NO_ACTION_FUNCTION | ||
93 | |||
94 | #endif | ||
diff --git a/keyboards/cospad/cospad.c b/keyboards/cospad/cospad.c new file mode 100644 index 000000000..48d752a84 --- /dev/null +++ b/keyboards/cospad/cospad.c | |||
@@ -0,0 +1,37 @@ | |||
1 | #include "cospad.h" | ||
2 | #include "led.h" | ||
3 | |||
4 | extern inline void cospad_bl_led_on(void); | ||
5 | extern inline void cospad_bl_led_off(void); | ||
6 | extern inline void cospad_bl_led_togg(void); | ||
7 | |||
8 | void matrix_init_kb(void) { | ||
9 | // put your keyboard start-up code here | ||
10 | // runs once when the firmware starts up | ||
11 | matrix_init_user(); | ||
12 | led_init_ports(); | ||
13 | }; | ||
14 | |||
15 | void matrix_scan_kb(void) { | ||
16 | // put your looping keyboard code here | ||
17 | // runs every cycle (a lot) | ||
18 | matrix_scan_user(); | ||
19 | }; | ||
20 | |||
21 | void led_init_ports(void) { | ||
22 | // * Set our LED pins as output | ||
23 | DDRB |= (1<<2); | ||
24 | DDRF |= (1<<7); | ||
25 | // * Setting BL LEDs to init as off | ||
26 | PORTF |= (1<<7); | ||
27 | } | ||
28 | |||
29 | void led_set_kb(uint8_t usb_led) { | ||
30 | if (usb_led & (1<<USB_LED_NUM_LOCK)) { | ||
31 | // Turn numlock on | ||
32 | PORTB &= ~(1<<2); | ||
33 | } else { | ||
34 | // Turn numlock off | ||
35 | PORTB |= (1<<2); | ||
36 | } | ||
37 | } | ||
diff --git a/keyboards/cospad/cospad.h b/keyboards/cospad/cospad.h new file mode 100644 index 000000000..cbcbdaf96 --- /dev/null +++ b/keyboards/cospad/cospad.h | |||
@@ -0,0 +1,77 @@ | |||
1 | #ifndef COSPAD_H | ||
2 | #define COSPAD_H | ||
3 | |||
4 | #include "quantum.h" | ||
5 | |||
6 | // readability | ||
7 | #define XXX KC_NO | ||
8 | |||
9 | /* COSPAD ortho matrix layout | ||
10 | * ,-------------------. | ||
11 | * | 00 | 01 | 02 | 03 | | ||
12 | * |----|----|----|----| | ||
13 | * | 10 | 11 | 12 | 13 | | ||
14 | * |----|----|----|----| | ||
15 | * | 20 | 21 | 22 | 23 | | ||
16 | * |----|----|----|----| | ||
17 | * | 30 | 31 | 32 | 33 | | ||
18 | * |----|----|----|----| | ||
19 | * | 40 | 41 | 42 | 43 | | ||
20 | * |----|----|----|----| | ||
21 | * | 50 | 51 | 52 | 53 | | ||
22 | * `-------------------' | ||
23 | */ | ||
24 | |||
25 | |||
26 | /* COSPAD numpad matrix layout | ||
27 | * ,-------------------. | ||
28 | * | 00 | 01 | 02 | 03 | | ||
29 | * |----|----|----|----| | ||
30 | * | 10 | 11 | 12 | 13 | | ||
31 | * |----|----|----|----| | ||
32 | * | 20 | 21 | 22 | | | ||
33 | * |----|----|----| 23 | | ||
34 | * | 30 | 31 | 32 | | | ||
35 | * |----|----|----|----| | ||
36 | * | 40 | 41 | 42 | | | ||
37 | * |----|----|----| 43 | | ||
38 | * | 50 | 52 | | | ||
39 | * `-------------------' | ||
40 | */ | ||
41 | // The first section contains all of the arguments | ||
42 | // The second converts the arguments into a two-dimensional array | ||
43 | #define KEYMAP( \ | ||
44 | k00, k01, k02, k03, \ | ||
45 | k10, k11, k12, k13, \ | ||
46 | k20, k21, k22, k23, \ | ||
47 | k30, k31, k32, k33, \ | ||
48 | k40, k41, k42, k43, \ | ||
49 | k50, k51, k52, k53 \ | ||
50 | ) \ | ||
51 | { \ | ||
52 | {k00, k01, k02, k03}, \ | ||
53 | {k10, k11, k12, k13}, \ | ||
54 | {k20, k21, k22, k23}, \ | ||
55 | {k30, k31, k32, k33}, \ | ||
56 | {k40, k41, k42, k43}, \ | ||
57 | {k50, k51, k52, k53} \ | ||
58 | } | ||
59 | void matrix_init_user(void); | ||
60 | void matrix_scan_user(void); | ||
61 | /* | ||
62 | inline void cospad_bl_led_on(void) { DDRF |= (1<<7); PORTF &= ~(1<<7); } | ||
63 | inline void cospad_bl_led_off(void) { DDRF &= ~(1<<7); PORTF &= ~(1<<7); } | ||
64 | */ | ||
65 | |||
66 | inline void cospad_bl_led_on(void) { PORTF &= ~(1<<7); } | ||
67 | inline void cospad_bl_led_off(void) { PORTF |= (1<<7); } | ||
68 | |||
69 | inline void cospad_bl_led_togg(void) { | ||
70 | uint8_t bl_mask = PORTF&(1<<7); | ||
71 | if (bl_mask) { | ||
72 | PORTF &= ~(1<<7); | ||
73 | } else { | ||
74 | PORTF |= (1<<7); | ||
75 | } | ||
76 | } | ||
77 | #endif | ||
diff --git a/keyboards/cospad/keymaps/default/keymap.c b/keyboards/cospad/keymaps/default/keymap.c new file mode 100644 index 000000000..0e762c2e4 --- /dev/null +++ b/keyboards/cospad/keymaps/default/keymap.c | |||
@@ -0,0 +1,91 @@ | |||
1 | #include "cospad.h" | ||
2 | #include "led.h" | ||
3 | |||
4 | #ifdef RGBLIGHT_ENABLE | ||
5 | #include "rgblight.h" | ||
6 | #endif | ||
7 | |||
8 | // Each layer gets a name for readability, which is then used in the keymap matrix below. | ||
9 | // The underscores don't mean anything - you can have a layer called STUFF or any other name. | ||
10 | // Layer names don't all need to be of the same length, obviously, and you can also skip them | ||
11 | // entirely and just use numbers. | ||
12 | #define _BL 0 | ||
13 | #define _FL 1 | ||
14 | |||
15 | #define _______ KC_TRNS | ||
16 | |||
17 | const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | ||
18 | /* Keymap _BL: (Base Layer) Default Layer | ||
19 | * ,-------------------. | ||
20 | * |Esc |TAB | FN | BS | | ||
21 | * |----|----|----|----| | ||
22 | * | NL | / | * | - | | ||
23 | * |----|----|----|----| | ||
24 | * | 7 | 8 | 9 | | | ||
25 | * |----|----|----| + | | ||
26 | * | 4 | 5 | 6 | | | ||
27 | * |----|----|----|----| | ||
28 | * | 1 | 2 | 3 | | | ||
29 | * |----|----|----| En | | ||
30 | * | 0 | . | | | ||
31 | * `-------------------' | ||
32 | */ | ||
33 | |||
34 | [_BL] = KEYMAP( | ||
35 | KC_ESC, KC_TAB, MO(_FL), KC_BSPC, \ | ||
36 | KC_NLCK, KC_PSLS, KC_PAST, KC_PMNS, \ | ||
37 | KC_P7, KC_P8, KC_P9, KC_PPLS, \ | ||
38 | KC_P4, KC_P5, KC_P6, KC_NO, \ | ||
39 | KC_P1, KC_P2, KC_P3, KC_PENT, \ | ||
40 | KC_P0, KC_NO, KC_PDOT, KC_NO), | ||
41 | |||
42 | /* Keymap _FL: Function Layer | ||
43 | * ,-------------------. | ||
44 | * |RGBT|TAB | FN | BS | | ||
45 | * |----|----|----|----| | ||
46 | * |RGBM|RGBP|BTOG| - | | ||
47 | * |----|----|----|----| | ||
48 | * |HUD |HUI |BON | | | ||
49 | * |----|----|----| + | | ||
50 | * |SAD |SAI |BOFF| | | ||
51 | * |----|----|----|----| | ||
52 | * |VAD |VAS | 3 | | | ||
53 | * |----|----|----| En | | ||
54 | * | 0 |RST | | | ||
55 | * `-------------------' | ||
56 | */ | ||
57 | [_FL] = KEYMAP( | ||
58 | RGB_TOG, KC_TAB, KC_TRNS, KC_BSPC, \ | ||
59 | RGB_MOD, RGB_M_P, BL_TOGG, KC_PMNS, \ | ||
60 | RGB_HUD, RGB_HUI, BL_ON, KC_PPLS, \ | ||
61 | RGB_SAD, RGB_SAI, BL_OFF, KC_NO, \ | ||
62 | RGB_VAD, RGB_VAI, KC_P3, KC_PENT, \ | ||
63 | KC_P0, KC_NO, RESET, KC_NO), | ||
64 | }; | ||
65 | |||
66 | |||
67 | const uint16_t PROGMEM fn_actions[] = { | ||
68 | [0] = MO(_FL), | ||
69 | }; | ||
70 | |||
71 | bool process_record_user(uint16_t keycode, keyrecord_t *record) { | ||
72 | switch (keycode) { | ||
73 | case BL_TOGG: | ||
74 | if (record->event.pressed) { | ||
75 | cospad_bl_led_togg(); | ||
76 | } | ||
77 | return false; | ||
78 | case BL_ON: | ||
79 | if (record->event.pressed) { | ||
80 | cospad_bl_led_on(); | ||
81 | } | ||
82 | return false; | ||
83 | case BL_OFF: | ||
84 | if(record->event.pressed) { | ||
85 | cospad_bl_led_off(); | ||
86 | } | ||
87 | return false; | ||
88 | default: | ||
89 | return true; | ||
90 | } | ||
91 | } | ||
diff --git a/keyboards/cospad/readme.md b/keyboards/cospad/readme.md new file mode 100644 index 000000000..436b87dce --- /dev/null +++ b/keyboards/cospad/readme.md | |||
@@ -0,0 +1,21 @@ | |||
1 | COSPAD | ||
2 | === | ||
3 | |||
4 | A DIY Keypad Kit sold by KPRepublic, runs TKG natively. | ||
5 | |||
6 | Keyboard Maintainer: QMK Community | ||
7 | Hardware Supported: COSPAD | ||
8 | Hardware Availability: https://aliexpress.com/item/cospad-Custom-Mechanical-Keyboard-Kit-up-tp-24-keys-Supports-TKG-TOOLS-Underglow-RGB-PCB-20/32818383873.html | ||
9 | |||
10 | Only supports on and off for the backlight leds, as they are not connected to a PWM pin. | ||
11 | |||
12 | Supported Layouts: | ||
13 | |||
14 |  | ||
15 |  | ||
16 | |||
17 | Make example for this keyboard (after setting up your build environment): | ||
18 | |||
19 | make cospad:default | ||
20 | |||
21 | 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. | ||
diff --git a/keyboards/cospad/rules.mk b/keyboards/cospad/rules.mk new file mode 100644 index 000000000..3c5913d0d --- /dev/null +++ b/keyboards/cospad/rules.mk | |||
@@ -0,0 +1,66 @@ | |||
1 | |||
2 | # MCU name | ||
3 | #MCU = at90usb1287 | ||
4 | MCU = atmega32u4 | ||
5 | |||
6 | # Processor frequency. | ||
7 | # This will define a symbol, F_CPU, in all source code files equal to the | ||
8 | # processor frequency in Hz. You can then use this symbol in your source code to | ||
9 | # calculate timings. Do NOT tack on a 'UL' at the end, this will be done | ||
10 | # automatically to create a 32-bit value in your source code. | ||
11 | # | ||
12 | # This will be an integer division of F_USB below, as it is sourced by | ||
13 | # F_USB after it has run through any CPU prescalers. Note that this value | ||
14 | # does not *change* the processor frequency - it should merely be updated to | ||
15 | # reflect the processor speed set externally so that the code can use accurate | ||
16 | # software delays. | ||
17 | F_CPU = 16000000 | ||
18 | |||
19 | |||
20 | # | ||
21 | # LUFA specific | ||
22 | # | ||
23 | # Target architecture (see library "Board Types" documentation). | ||
24 | ARCH = AVR8 | ||
25 | |||
26 | # Input clock frequency. | ||
27 | # This will define a symbol, F_USB, in all source code files equal to the | ||
28 | # input clock frequency (before any prescaling is performed) in Hz. This value may | ||
29 | # differ from F_CPU if prescaling is used on the latter, and is required as the | ||
30 | # raw input clock is fed directly to the PLL sections of the AVR for high speed | ||
31 | # clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL' | ||
32 | # at the end, this will be done automatically to create a 32-bit value in your | ||
33 | # source code. | ||
34 | # | ||
35 | # If no clock division is performed on the input clock inside the AVR (via the | ||
36 | # CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU. | ||
37 | F_USB = $(F_CPU) | ||
38 | |||
39 | # Interrupt driven control endpoint task(+60) | ||
40 | OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT | ||
41 | |||
42 | |||
43 | # Boot Section Size in *bytes* | ||
44 | # Teensy halfKay 512 | ||
45 | # Teensy++ halfKay 1024 | ||
46 | # Atmel DFU loader 4096 | ||
47 | # LUFA bootloader 4096 | ||
48 | # USBaspLoader 2048 | ||
49 | OPT_DEFS += -DBOOTLOADER_SIZE=4096 | ||
50 | |||
51 | |||
52 | # Build Options | ||
53 | # comment out to disable the options. | ||
54 | # | ||
55 | BOOTMAGIC_ENABLE = no # Virtual DIP switch configuration(+1000) | ||
56 | MOUSEKEY_ENABLE = no # Mouse keys(+4700) | ||
57 | EXTRAKEY_ENABLE = yes # Audio control and System control(+450) | ||
58 | CONSOLE_ENABLE = no # Console for debug(+400) | ||
59 | COMMAND_ENABLE = no # Commands for debug and configuration | ||
60 | NKRO_ENABLE = yes # USB Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work | ||
61 | RGBLIGHT_ENABLE = yes # Enable keyboard underlight functionality (+4870) | ||
62 | BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality (+1150) | ||
63 | MIDI_ENABLE = no # MIDI controls | ||
64 | AUDIO_ENABLE = no | ||
65 | UNICODE_ENABLE = no # Unicode | ||
66 | BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID | ||
diff --git a/quantum/rgblight.c b/quantum/rgblight.c index 63eda47cd..ab218b8c5 100644 --- a/quantum/rgblight.c +++ b/quantum/rgblight.c | |||
@@ -370,6 +370,18 @@ void rgblight_sethsv(uint16_t hue, uint8_t sat, uint8_t val) { | |||
370 | } | 370 | } |
371 | } | 371 | } |
372 | 372 | ||
373 | uint16_t rgblight_get_hue(void) { | ||
374 | return rgblight_config.hue; | ||
375 | } | ||
376 | |||
377 | uint8_t rgblight_get_sat(void) { | ||
378 | return rgblight_config.sat; | ||
379 | } | ||
380 | |||
381 | uint8_t rgblight_get_val(void) { | ||
382 | return rgblight_config.val; | ||
383 | } | ||
384 | |||
373 | void rgblight_setrgb(uint8_t r, uint8_t g, uint8_t b) { | 385 | void rgblight_setrgb(uint8_t r, uint8_t g, uint8_t b) { |
374 | if (!rgblight_config.enable) { return; } | 386 | if (!rgblight_config.enable) { return; } |
375 | 387 | ||
diff --git a/quantum/rgblight.h b/quantum/rgblight.h index 6d362e1d5..73dd89946 100644 --- a/quantum/rgblight.h +++ b/quantum/rgblight.h | |||
@@ -113,6 +113,9 @@ void rgblight_decrease_sat(void); | |||
113 | void rgblight_increase_val(void); | 113 | void rgblight_increase_val(void); |
114 | void rgblight_decrease_val(void); | 114 | void rgblight_decrease_val(void); |
115 | void rgblight_sethsv(uint16_t hue, uint8_t sat, uint8_t val); | 115 | void rgblight_sethsv(uint16_t hue, uint8_t sat, uint8_t val); |
116 | uint16_t rgblight_get_hue(void); | ||
117 | uint8_t rgblight_get_sat(void); | ||
118 | uint8_t rgblight_get_val(void); | ||
116 | void rgblight_setrgb(uint8_t r, uint8_t g, uint8_t b); | 119 | void rgblight_setrgb(uint8_t r, uint8_t g, uint8_t b); |
117 | void rgblight_setrgb_at(uint8_t r, uint8_t g, uint8_t b, uint8_t index); | 120 | void rgblight_setrgb_at(uint8_t r, uint8_t g, uint8_t b, uint8_t index); |
118 | void rgblight_sethsv_at(uint16_t hue, uint8_t sat, uint8_t val, uint8_t index); | 121 | void rgblight_sethsv_at(uint16_t hue, uint8_t sat, uint8_t val, uint8_t index); |