diff options
| author | MechMerlin <30334081+mechmerlin@users.noreply.github.com> | 2019-04-03 10:17:25 -0700 |
|---|---|---|
| committer | Drashna Jaelre <drashna@live.com> | 2019-04-03 10:17:25 -0700 |
| commit | cb2f2fd258011e6637ed182f484a4317ac510db8 (patch) | |
| tree | e0ffc4ff80b4467110787575ea581daa3fa140af /keyboards/duck | |
| parent | caefb1c61eca10dcb70ca6481a8a592057de7318 (diff) | |
| download | qmk_firmware-cb2f2fd258011e6637ed182f484a4317ac510db8.tar.gz qmk_firmware-cb2f2fd258011e6637ed182f484a4317ac510db8.zip | |
[Keyboard] Small Refactor of Duck boards (#5521)
* first [ass at pulling out common duck library functions
* use new library in jetfire
* use new library in duck lightsaver
* use new library in octagon v2
* put Device into the library
* refactor send_value
* refactor send_value and send_color
* use pragma once
* use pragma once
* use pragma once
* use pragma once
* rename backlight_led to indicator_leds to match with other duck boards
* rename enum
* make #define names consistent
* rename ducklib to duck_led
* update rules.mk ?= to =
* put rgb in the correct order
* add debounce debugging printouts
* turn on bootmagic lite and set it to the top left most key commonly programmed as Escape
* add reset key documentation
* fix that typo
* Update keyboards/duck/duck_led/duck_led.c
Co-Authored-By: mechmerlin <30334081+mechmerlin@users.noreply.github.com>
* include the correct library
Diffstat (limited to 'keyboards/duck')
33 files changed, 192 insertions, 202 deletions
diff --git a/keyboards/duck/duck_led/duck_led.c b/keyboards/duck/duck_led/duck_led.c new file mode 100644 index 000000000..2fa920e4b --- /dev/null +++ b/keyboards/duck/duck_led/duck_led.c | |||
| @@ -0,0 +1,7 @@ | |||
| 1 | #include <avr/io.h> | ||
| 2 | #include "duck_led.h" | ||
| 3 | #include "quantum.h" | ||
| 4 | |||
| 5 | void show(void) { | ||
| 6 | wait_us((RES / 1000UL) + 1); | ||
| 7 | } | ||
diff --git a/keyboards/duck/duck_led/duck_led.h b/keyboards/duck/duck_led/duck_led.h new file mode 100644 index 000000000..2546366d0 --- /dev/null +++ b/keyboards/duck/duck_led/duck_led.h | |||
| @@ -0,0 +1,16 @@ | |||
| 1 | #pragma once | ||
| 2 | |||
| 3 | #define RES 6000 | ||
| 4 | |||
| 5 | #define NS_PER_SEC (1000000000L) | ||
| 6 | #define CYCLES_PER_SEC (F_CPU) | ||
| 7 | #define NS_PER_CYCLE (NS_PER_SEC / CYCLES_PER_SEC) | ||
| 8 | #define NS_TO_CYCLES(n) ((n) / NS_PER_CYCLE) | ||
| 9 | |||
| 10 | enum Device { | ||
| 11 | Device_PCBRGB, | ||
| 12 | Device_STATUSLED | ||
| 13 | }; | ||
| 14 | |||
| 15 | void show(void); | ||
| 16 | |||
diff --git a/keyboards/duck/eagle_viper/readme.md b/keyboards/duck/eagle_viper/readme.md index 14fb16669..3fec11bc0 100644 --- a/keyboards/duck/eagle_viper/readme.md +++ b/keyboards/duck/eagle_viper/readme.md | |||
| @@ -9,4 +9,3 @@ Newest version is the [Eagle/Viper V2](http://duck0113.tistory.com/127) | |||
| 9 | Make example for this keyboard (after setting up your build environment): | 9 | Make example for this keyboard (after setting up your build environment): |
| 10 | 10 | ||
| 11 | make duck/eagle_viper/v2:default | 11 | make duck/eagle_viper/v2:default |
| 12 | |||
diff --git a/keyboards/duck/eagle_viper/v2/config.h b/keyboards/duck/eagle_viper/v2/config.h index f454b2e0e..a0ce866cc 100644 --- a/keyboards/duck/eagle_viper/v2/config.h +++ b/keyboards/duck/eagle_viper/v2/config.h | |||
| @@ -15,8 +15,7 @@ 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/>. | 15 | along 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 | ||
| @@ -44,6 +43,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 44 | #define RGB_DI_PIN D6 | 43 | #define RGB_DI_PIN D6 |
| 45 | #define RGBLED_NUM 17 | 44 | #define RGBLED_NUM 17 |
| 46 | 45 | ||
| 46 | /* Set to top left most key */ | ||
| 47 | #define BOOTMAGIC_LITE_ROW 4 | ||
| 48 | #define BOOTMAGIC_LITE_COLUMN 10 | ||
| 49 | |||
| 47 | #define TAPPING_TERM 200 | 50 | #define TAPPING_TERM 200 |
| 48 | 51 | ||
| 49 | #endif | ||
diff --git a/keyboards/duck/eagle_viper/v2/indicator_leds.c b/keyboards/duck/eagle_viper/v2/indicator_leds.c index 03a93197d..fc90ed3fb 100644 --- a/keyboards/duck/eagle_viper/v2/indicator_leds.c +++ b/keyboards/duck/eagle_viper/v2/indicator_leds.c | |||
| @@ -19,19 +19,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 19 | #include <stdbool.h> | 19 | #include <stdbool.h> |
| 20 | #include <util/delay.h> | 20 | #include <util/delay.h> |
| 21 | #include "indicator_leds.h" | 21 | #include "indicator_leds.h" |
| 22 | 22 | #include "duck_led/duck_led.h" | |
| 23 | #define RES 6000 | ||
| 24 | 23 | ||
| 25 | #define LED_T1H 600 | 24 | #define LED_T1H 600 |
| 26 | #define LED_T1L 650 | 25 | #define LED_T1L 650 |
| 27 | #define LED_T0H 250 | 26 | #define LED_T0H 250 |
| 28 | #define LED_T0L 1000 | 27 | #define LED_T0L 1000 |
| 29 | 28 | ||
| 30 | #define NS_PER_SEC (1000000000L) | ||
| 31 | #define CYCLES_PER_SEC (F_CPU) | ||
| 32 | #define NS_PER_CYCLE (NS_PER_SEC / CYCLES_PER_SEC) | ||
| 33 | #define NS_TO_CYCLES(n) ((n) / NS_PER_CYCLE) | ||
| 34 | |||
| 35 | void send_bit_d4(bool bitVal) { | 29 | void send_bit_d4(bool bitVal) { |
| 36 | if(bitVal) { | 30 | if(bitVal) { |
| 37 | asm volatile ( | 31 | asm volatile ( |
| @@ -66,14 +60,12 @@ void send_bit_d4(bool bitVal) { | |||
| 66 | } | 60 | } |
| 67 | } | 61 | } |
| 68 | 62 | ||
| 69 | void show(void) { | 63 | void send_value(uint8_t byte, enum Device device) { |
| 70 | _delay_us((RES / 1000UL) + 1); | ||
| 71 | } | ||
| 72 | |||
| 73 | void send_value(uint8_t byte) { | ||
| 74 | for(uint8_t b = 0; b < 8; b++) { | 64 | for(uint8_t b = 0; b < 8; b++) { |
| 75 | send_bit_d4(byte & 0b10000000); | 65 | if(device == Device_STATUSLED) { |
| 76 | byte <<= 1; | 66 | send_bit_d4(byte & 0b10000000); |
| 67 | byte <<= 1; | ||
| 68 | } | ||
| 77 | } | 69 | } |
| 78 | } | 70 | } |
| 79 | 71 | ||
| @@ -83,7 +75,8 @@ void indicator_leds_set(bool leds[8]) { | |||
| 83 | 75 | ||
| 84 | cli(); | 76 | cli(); |
| 85 | for(led_cnt = 0; led_cnt < 8; led_cnt++) | 77 | for(led_cnt = 0; led_cnt < 8; led_cnt++) |
| 86 | send_value(leds[led_cnt] ? 255 : 0); | 78 | send_value(leds[led_cnt] ? 255 : 0, Device_STATUSLED); |
| 87 | sei(); | 79 | sei(); |
| 88 | show(); | 80 | show(); |
| 89 | } | 81 | } |
| 82 | |||
diff --git a/keyboards/duck/eagle_viper/v2/indicator_leds.h b/keyboards/duck/eagle_viper/v2/indicator_leds.h index c174fa404..fe66eef6b 100644 --- a/keyboards/duck/eagle_viper/v2/indicator_leds.h +++ b/keyboards/duck/eagle_viper/v2/indicator_leds.h | |||
| @@ -1,2 +1 @@ | |||
| 1 | void indicator_leds_set(bool leds[8]); | void indicator_leds_set(bool leds[8]); | |
| 2 | void show(void); | ||
diff --git a/keyboards/duck/eagle_viper/v2/matrix.c b/keyboards/duck/eagle_viper/v2/matrix.c index 7003a7ae0..a6bc56342 100644 --- a/keyboards/duck/eagle_viper/v2/matrix.c +++ b/keyboards/duck/eagle_viper/v2/matrix.c | |||
| @@ -89,6 +89,9 @@ uint8_t matrix_scan(void) { | |||
| 89 | bool curr_bit = rows & (1<<row); | 89 | bool curr_bit = rows & (1<<row); |
| 90 | if (prev_bit != curr_bit) { | 90 | if (prev_bit != curr_bit) { |
| 91 | matrix_debouncing[row] ^= ((matrix_row_t)1<<col); | 91 | matrix_debouncing[row] ^= ((matrix_row_t)1<<col); |
| 92 | if (debouncing) { | ||
| 93 | dprint("bounce!: "); dprintf("%02X", debouncing); dprintln(); | ||
| 94 | } | ||
| 92 | debouncing = DEBOUNCING_DELAY; | 95 | debouncing = DEBOUNCING_DELAY; |
| 93 | } | 96 | } |
| 94 | } | 97 | } |
diff --git a/keyboards/duck/eagle_viper/v2/readme.md b/keyboards/duck/eagle_viper/v2/readme.md index 32ad8453c..31f70b93b 100644 --- a/keyboards/duck/eagle_viper/v2/readme.md +++ b/keyboards/duck/eagle_viper/v2/readme.md | |||
| @@ -11,6 +11,8 @@ Make example for this keyboard (after setting up your build environment): | |||
| 11 | 11 | ||
| 12 | make eagle_viper/v2:default | 12 | make eagle_viper/v2:default |
| 13 | 13 | ||
| 14 | **Reset Key:** To put the Eagle/Viper V2 into reset, hold caps lock key (`K2A`) while plugging in. | ||
| 15 | |||
| 14 | See [build environment setup](https://docs.qmk.fm/#/getting_started_build_tools) then the [make instructions](https://docs.qmk.fm/#/getting_started_make_guide) for more information. | 16 | See [build environment setup](https://docs.qmk.fm/#/getting_started_build_tools) then the [make instructions](https://docs.qmk.fm/#/getting_started_make_guide) for more information. |
| 15 | 17 | ||
| 16 | ## Hardware Notes | 18 | ## Hardware Notes |
diff --git a/keyboards/duck/eagle_viper/v2/rules.mk b/keyboards/duck/eagle_viper/v2/rules.mk index 64d839fcb..1abd7d941 100644 --- a/keyboards/duck/eagle_viper/v2/rules.mk +++ b/keyboards/duck/eagle_viper/v2/rules.mk | |||
| @@ -50,23 +50,23 @@ OPT_DEFS += -DBOOTLOADER_SIZE=4096 | |||
| 50 | # Build Options | 50 | # Build Options |
| 51 | # change yes to no to disable | 51 | # change yes to no to disable |
| 52 | # | 52 | # |
| 53 | BOOTMAGIC_ENABLE ?= no # Virtual DIP switch configuration(+1000) | 53 | BOOTMAGIC_ENABLE = lite # Virtual DIP switch configuration(+1000) |
| 54 | MOUSEKEY_ENABLE ?= no # Mouse keys(+4700) | 54 | MOUSEKEY_ENABLE = no # Mouse keys(+4700) |
| 55 | EXTRAKEY_ENABLE ?= yes # Audio control and System control(+450) | 55 | EXTRAKEY_ENABLE = yes # Audio control and System control(+450) |
| 56 | CONSOLE_ENABLE ?= no # Console for debug(+400) | 56 | CONSOLE_ENABLE = no # Console for debug(+400) |
| 57 | COMMAND_ENABLE ?= yes # Commands for debug and configuration | 57 | COMMAND_ENABLE = yes # Commands for debug and configuration |
| 58 | # Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE | 58 | # Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE |
| 59 | SLEEP_LED_ENABLE ?= no # Breathing sleep LED during USB suspend | 59 | SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend |
| 60 | # if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work | 60 | # if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work |
| 61 | NKRO_ENABLE ?= yes # USB Nkey Rollover | 61 | NKRO_ENABLE = yes # USB Nkey Rollover |
| 62 | BACKLIGHT_ENABLE ?= yes # Enable keyboard backlight functionality on B7 by default | 62 | BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality on B7 by default |
| 63 | MIDI_ENABLE ?= no # MIDI support (+2400 to 4200, depending on config) | 63 | MIDI_ENABLE = no # MIDI support (+2400 to 4200, depending on config) |
| 64 | UNICODE_ENABLE ?= no # Unicode | 64 | UNICODE_ENABLE = no # Unicode |
| 65 | BLUETOOTH_ENABLE ?= no # Enable Bluetooth with the Adafruit EZ-Key HID | 65 | BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID |
| 66 | AUDIO_ENABLE ?= no # Audio output on port C6 | 66 | AUDIO_ENABLE = no # Audio output on port C6 |
| 67 | FAUXCLICKY_ENABLE ?= no # Use buzzer to emulate clicky switches | 67 | FAUXCLICKY_ENABLE = no # Use buzzer to emulate clicky switches |
| 68 | RGBLIGHT_ENABLE = yes | 68 | RGBLIGHT_ENABLE = yes |
| 69 | 69 | ||
| 70 | CUSTOM_MATRIX = yes | 70 | CUSTOM_MATRIX = yes |
| 71 | SRC += indicator_leds.c \ | 71 | SRC += indicator_leds.c \ |
| 72 | matrix.c | 72 | matrix.c duck_led/duck_led.c |
diff --git a/keyboards/duck/eagle_viper/v2/v2.h b/keyboards/duck/eagle_viper/v2/v2.h index d149471ba..7fefcf770 100644 --- a/keyboards/duck/eagle_viper/v2/v2.h +++ b/keyboards/duck/eagle_viper/v2/v2.h | |||
| @@ -13,8 +13,7 @@ | |||
| 13 | * You should have received a copy of the GNU General Public License | 13 | * You should have received a copy of the GNU General Public License |
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 15 | */ | 15 | */ |
| 16 | #ifndef V2_H | 16 | #pragma once |
| 17 | #define V2_H | ||
| 18 | 17 | ||
| 19 | #include "quantum.h" | 18 | #include "quantum.h" |
| 20 | 19 | ||
| @@ -78,4 +77,3 @@ | |||
| 78 | 77 | ||
| 79 | #define LAYOUT_eagle LAYOUT_60_ansi | 78 | #define LAYOUT_eagle LAYOUT_60_ansi |
| 80 | 79 | ||
| 81 | #endif | ||
diff --git a/keyboards/duck/jetfire/config.h b/keyboards/duck/jetfire/config.h index 4bc535b19..774e28491 100644 --- a/keyboards/duck/jetfire/config.h +++ b/keyboards/duck/jetfire/config.h | |||
| @@ -48,6 +48,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 48 | /* Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not needed */ | 48 | /* Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not needed */ |
| 49 | #define DEBOUNCING_DELAY 5 | 49 | #define DEBOUNCING_DELAY 5 |
| 50 | 50 | ||
| 51 | /* Set to top left most key */ | ||
| 52 | #define BOOTMAGIC_LITE_ROW 5 | ||
| 53 | #define BOOTMAGIC_LITE_COLUMN 10 | ||
| 54 | |||
| 51 | /* If defined, GRAVE_ESC will always act as ESC when CTRL is held. | 55 | /* If defined, GRAVE_ESC will always act as ESC when CTRL is held. |
| 52 | * This is userful for the Windows task manager shortcut (ctrl+shift+esc). | 56 | * This is userful for the Windows task manager shortcut (ctrl+shift+esc). |
| 53 | */ | 57 | */ |
diff --git a/keyboards/duck/jetfire/backlight_led.c b/keyboards/duck/jetfire/indicator_leds.c index 7e9dca6e9..7dbdb1ff7 100644 --- a/keyboards/duck/jetfire/backlight_led.c +++ b/keyboards/duck/jetfire/indicator_leds.c | |||
| @@ -17,21 +17,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 17 | #include <stdbool.h> | 17 | #include <stdbool.h> |
| 18 | #include <util/delay.h> | 18 | #include <util/delay.h> |
| 19 | #include <stdint.h> | 19 | #include <stdint.h> |
| 20 | #include "backlight_led.h" | 20 | #include "indicator_leds.h" |
| 21 | #include "quantum.h" | 21 | #include "quantum.h" |
| 22 | // #include "led.h" | ||
| 23 | 22 | ||
| 24 | 23 | #define LED_T1H 900 | |
| 25 | #define T1H 900 | 24 | #define LED_T1L 600 |
| 26 | #define T1L 600 | 25 | #define LED_T0H 400 |
| 27 | #define T0H 400 | 26 | #define LED_T0L 900 |
| 28 | #define T0L 900 | ||
| 29 | #define RES 6000 | ||
| 30 | |||
| 31 | #define NS_PER_SEC (1000000000L) | ||
| 32 | #define CYCLES_PER_SEC (F_CPU) | ||
| 33 | #define NS_PER_CYCLE (NS_PER_SEC / CYCLES_PER_SEC) | ||
| 34 | #define NS_TO_CYCLES(n) ((n) / NS_PER_CYCLE) | ||
| 35 | 27 | ||
| 36 | void send_bit_d4(bool bitVal) | 28 | void send_bit_d4(bool bitVal) |
| 37 | { | 29 | { |
| @@ -48,8 +40,8 @@ void send_bit_d4(bool bitVal) | |||
| 48 | :: | 40 | :: |
| 49 | [port] "I" (_SFR_IO_ADDR(PORTD)), | 41 | [port] "I" (_SFR_IO_ADDR(PORTD)), |
| 50 | [bit] "I" (4), | 42 | [bit] "I" (4), |
| 51 | [onCycles] "I" (NS_TO_CYCLES(T1H) - 2), | 43 | [onCycles] "I" (NS_TO_CYCLES(LED_T1H) - 2), |
| 52 | [offCycles] "I" (NS_TO_CYCLES(T1L) - 2)); | 44 | [offCycles] "I" (NS_TO_CYCLES(LED_T1L) - 2)); |
| 53 | } else { | 45 | } else { |
| 54 | asm volatile ( | 46 | asm volatile ( |
| 55 | "sbi %[port], %[bit] \n\t" | 47 | "sbi %[port], %[bit] \n\t" |
| @@ -63,8 +55,8 @@ void send_bit_d4(bool bitVal) | |||
| 63 | :: | 55 | :: |
| 64 | [port] "I" (_SFR_IO_ADDR(PORTD)), | 56 | [port] "I" (_SFR_IO_ADDR(PORTD)), |
| 65 | [bit] "I" (4), | 57 | [bit] "I" (4), |
| 66 | [onCycles] "I" (NS_TO_CYCLES(T0H) - 2), | 58 | [onCycles] "I" (NS_TO_CYCLES(LED_T0H) - 2), |
| 67 | [offCycles] "I" (NS_TO_CYCLES(T0L) - 2)); | 59 | [offCycles] "I" (NS_TO_CYCLES(LED_T0L) - 2)); |
| 68 | } | 60 | } |
| 69 | } | 61 | } |
| 70 | 62 | ||
| @@ -83,8 +75,8 @@ void send_bit_d6(bool bitVal) | |||
| 83 | :: | 75 | :: |
| 84 | [port] "I" (_SFR_IO_ADDR(PORTD)), | 76 | [port] "I" (_SFR_IO_ADDR(PORTD)), |
| 85 | [bit] "I" (6), | 77 | [bit] "I" (6), |
| 86 | [onCycles] "I" (NS_TO_CYCLES(T1H) - 2), | 78 | [onCycles] "I" (NS_TO_CYCLES(LED_T1H) - 2), |
| 87 | [offCycles] "I" (NS_TO_CYCLES(T1L) - 2)); | 79 | [offCycles] "I" (NS_TO_CYCLES(LED_T1L) - 2)); |
| 88 | } else { | 80 | } else { |
| 89 | asm volatile ( | 81 | asm volatile ( |
| 90 | "sbi %[port], %[bit] \n\t" | 82 | "sbi %[port], %[bit] \n\t" |
| @@ -98,20 +90,15 @@ void send_bit_d6(bool bitVal) | |||
| 98 | :: | 90 | :: |
| 99 | [port] "I" (_SFR_IO_ADDR(PORTD)), | 91 | [port] "I" (_SFR_IO_ADDR(PORTD)), |
| 100 | [bit] "I" (6), | 92 | [bit] "I" (6), |
| 101 | [onCycles] "I" (NS_TO_CYCLES(T0H) - 2), | 93 | [onCycles] "I" (NS_TO_CYCLES(LED_T0H) - 2), |
| 102 | [offCycles] "I" (NS_TO_CYCLES(T0L) - 2)); | 94 | [offCycles] "I" (NS_TO_CYCLES(LED_T0L) - 2)); |
| 103 | } | 95 | } |
| 104 | } | 96 | } |
| 105 | 97 | ||
| 106 | void show(void) | ||
| 107 | { | ||
| 108 | _delay_us((RES / 1000UL) + 1); | ||
| 109 | } | ||
| 110 | |||
| 111 | void send_value(uint8_t byte, enum Device device) | 98 | void send_value(uint8_t byte, enum Device device) |
| 112 | { | 99 | { |
| 113 | for(uint8_t b = 0; b < 8; b++) { | 100 | for(uint8_t b = 0; b < 8; b++) { |
| 114 | if(device == Device_STATELED) { | 101 | if(device == Device_STATUSLED) { |
| 115 | send_bit_d4(byte & 0b10000000); | 102 | send_bit_d4(byte & 0b10000000); |
| 116 | } | 103 | } |
| 117 | if(device == Device_PCBRGB) { | 104 | if(device == Device_PCBRGB) { |
| @@ -123,7 +110,7 @@ void send_value(uint8_t byte, enum Device device) | |||
| 123 | 110 | ||
| 124 | void send_color(uint8_t r, uint8_t g, uint8_t b, enum Device device) | 111 | void send_color(uint8_t r, uint8_t g, uint8_t b, enum Device device) |
| 125 | { | 112 | { |
| 126 | send_value(g, device); | ||
| 127 | send_value(r, device); | 113 | send_value(r, device); |
| 114 | send_value(g, device); | ||
| 128 | send_value(b, device); | 115 | send_value(b, device); |
| 129 | } | 116 | } |
diff --git a/keyboards/duck/jetfire/backlight_led.h b/keyboards/duck/jetfire/indicator_leds.h index 36d8d9aa9..695e1db6d 100644 --- a/keyboards/duck/jetfire/backlight_led.h +++ b/keyboards/duck/jetfire/indicator_leds.h | |||
| @@ -1,10 +1,6 @@ | |||
| 1 | #ifndef BACKLIGHT_LED_H | 1 | #pragma once |
| 2 | #define BACKLIGHT_LED_H | ||
| 3 | 2 | ||
| 4 | enum Device { | 3 | #include "duck_led/duck_led.h" |
| 5 | Device_PCBRGB, | ||
| 6 | Device_STATELED | ||
| 7 | }; | ||
| 8 | 4 | ||
| 9 | void backlight_init_ports(void); | 5 | void backlight_init_ports(void); |
| 10 | void backlight_set_state(bool cfg[7]); | 6 | void backlight_set_state(bool cfg[7]); |
| @@ -13,6 +9,3 @@ void backlight_toggle_rgb(bool enabled); | |||
| 13 | void backlight_set_rgb(uint8_t cfg[17][3]); | 9 | void backlight_set_rgb(uint8_t cfg[17][3]); |
| 14 | void backlight_set(uint8_t level); | 10 | void backlight_set(uint8_t level); |
| 15 | void send_color(uint8_t r, uint8_t g, uint8_t b, enum Device device); | 11 | void send_color(uint8_t r, uint8_t g, uint8_t b, enum Device device); |
| 16 | void show(void); | ||
| 17 | |||
| 18 | #endif | ||
diff --git a/keyboards/duck/jetfire/jetfire.c b/keyboards/duck/jetfire/jetfire.c index 81bdb95ba..0662489c6 100644 --- a/keyboards/duck/jetfire/jetfire.c +++ b/keyboards/duck/jetfire/jetfire.c | |||
| @@ -14,9 +14,9 @@ | |||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 15 | */ | 15 | */ |
| 16 | #include "jetfire.h" | 16 | #include "jetfire.h" |
| 17 | #include "backlight_led.h" | 17 | #include "indicator_leds.h" |
| 18 | 18 | ||
| 19 | enum backlight_level { | 19 | enum BACKLIGHT_AREAS { |
| 20 | BACKLIGHT_ALPHA = 0b0000001, | 20 | BACKLIGHT_ALPHA = 0b0000001, |
| 21 | BACKLIGHT_MOD = 0b0000010, | 21 | BACKLIGHT_MOD = 0b0000010, |
| 22 | BACKLIGHT_FROW = 0b0000100, | 22 | BACKLIGHT_FROW = 0b0000100, |
| @@ -137,15 +137,15 @@ void backlight_update_state() | |||
| 137 | send_color(backlight_state_led & (1<<STATE_LED_SCROLL_LOCK) ? 255 : 0, | 137 | send_color(backlight_state_led & (1<<STATE_LED_SCROLL_LOCK) ? 255 : 0, |
| 138 | backlight_state_led & (1<<STATE_LED_CAPS_LOCK) ? 255 : 0, | 138 | backlight_state_led & (1<<STATE_LED_CAPS_LOCK) ? 255 : 0, |
| 139 | backlight_state_led & (1<<STATE_LED_NUM_LOCK) ? 255 : 0, | 139 | backlight_state_led & (1<<STATE_LED_NUM_LOCK) ? 255 : 0, |
| 140 | Device_STATELED); | 140 | Device_STATUSLED); |
| 141 | send_color(backlight_state_led & (1<<STATE_LED_LAYER_1) ? 255 : 0, | 141 | send_color(backlight_state_led & (1<<STATE_LED_LAYER_1) ? 255 : 0, |
| 142 | backlight_state_led & (1<<STATE_LED_LAYER_2) ? 255 : 0, | 142 | backlight_state_led & (1<<STATE_LED_LAYER_2) ? 255 : 0, |
| 143 | backlight_state_led & (1<<STATE_LED_LAYER_0) ? 255 : 0, | 143 | backlight_state_led & (1<<STATE_LED_LAYER_0) ? 255 : 0, |
| 144 | Device_STATELED); | 144 | Device_STATUSLED); |
| 145 | send_color(backlight_state_led & (1<<STATE_LED_LAYER_4) ? 255 : 0, | 145 | send_color(backlight_state_led & (1<<STATE_LED_LAYER_4) ? 255 : 0, |
| 146 | backlight_state_led & (1<<STATE_LED_LAYER_3) ? 255 : 0, | 146 | backlight_state_led & (1<<STATE_LED_LAYER_3) ? 255 : 0, |
| 147 | 0, | 147 | 0, |
| 148 | Device_STATELED); | 148 | Device_STATUSLED); |
| 149 | sei(); | 149 | sei(); |
| 150 | show(); | 150 | show(); |
| 151 | } | 151 | } |
diff --git a/keyboards/duck/jetfire/jetfire.h b/keyboards/duck/jetfire/jetfire.h index 9ce1406f0..3c4834bce 100644 --- a/keyboards/duck/jetfire/jetfire.h +++ b/keyboards/duck/jetfire/jetfire.h | |||
| @@ -13,8 +13,7 @@ | |||
| 13 | * You should have received a copy of the GNU General Public License | 13 | * You should have received a copy of the GNU General Public License |
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 15 | */ | 15 | */ |
| 16 | #ifndef JETFIRE_H | 16 | #pragma once |
| 17 | #define JETFIRE_H | ||
| 18 | 17 | ||
| 19 | #include "quantum.h" | 18 | #include "quantum.h" |
| 20 | 19 | ||
| @@ -57,4 +56,3 @@ | |||
| 57 | { K0A, K0B, K0C, KC_NO,KC_NO,KC_NO,KC_NO,KC_NO, K0I, KC_NO,KC_NO,KC_NO, K0M, K0N, K0O, K0P, K0Q, K0R, K0S, KC_NO } \ | 56 | { K0A, K0B, K0C, KC_NO,KC_NO,KC_NO,KC_NO,KC_NO, K0I, KC_NO,KC_NO,KC_NO, K0M, K0N, K0O, K0P, K0Q, K0R, K0S, KC_NO } \ |
| 58 | } | 57 | } |
| 59 | 58 | ||
| 60 | #endif | ||
diff --git a/keyboards/duck/jetfire/readme.md b/keyboards/duck/jetfire/readme.md index 34b351a72..8de2f5ced 100644 --- a/keyboards/duck/jetfire/readme.md +++ b/keyboards/duck/jetfire/readme.md | |||
| @@ -9,7 +9,7 @@ Keyboard Maintainer: [MechMerlin](https://github.com/mechmerlin) | |||
| 9 | Hardware Supported: Duck Jetfire PCB | 9 | Hardware Supported: Duck Jetfire PCB |
| 10 | Hardware Availability: [Geekhack GB](https://geekhack.org/index.php?topic=92708.0) | 10 | Hardware Availability: [Geekhack GB](https://geekhack.org/index.php?topic=92708.0) |
| 11 | 11 | ||
| 12 | To get into bootloader mode, hold the top top most key above the 2 navigation keys while connecting the USB cable. | 12 | **Reset Key:** To put the Jetfire into reset, hold top most key above the 2 navigation keys (`K5P`) while plugging in. |
| 13 | 13 | ||
| 14 | Make example for this keyboard (after setting up your build environment): | 14 | Make example for this keyboard (after setting up your build environment): |
| 15 | 15 | ||
diff --git a/keyboards/duck/jetfire/rules.mk b/keyboards/duck/jetfire/rules.mk index 8e05516df..c70859329 100644 --- a/keyboards/duck/jetfire/rules.mk +++ b/keyboards/duck/jetfire/rules.mk | |||
| @@ -51,7 +51,7 @@ OPT_DEFS += -DBOOTLOADER_SIZE=4096 | |||
| 51 | # Build Options | 51 | # Build Options |
| 52 | # change yes to no to disable | 52 | # change yes to no to disable |
| 53 | # | 53 | # |
| 54 | BOOTMAGIC_ENABLE = no # Virtual DIP switch configuration(+1000) | 54 | BOOTMAGIC_ENABLE = lite # Virtual DIP switch configuration(+1000) |
| 55 | MOUSEKEY_ENABLE = no # Mouse keys(+4700) | 55 | MOUSEKEY_ENABLE = no # Mouse keys(+4700) |
| 56 | EXTRAKEY_ENABLE = no # Audio control and System control(+450) | 56 | EXTRAKEY_ENABLE = no # Audio control and System control(+450) |
| 57 | CONSOLE_ENABLE = yes # Console for debug(+400) | 57 | CONSOLE_ENABLE = yes # Console for debug(+400) |
| @@ -70,5 +70,5 @@ FAUXCLICKY_ENABLE = no # Use buzzer to emulate clicky switches | |||
| 70 | HD44780_ENABLE = no # Enable support for HD44780 based LCDs (+400) | 70 | HD44780_ENABLE = no # Enable support for HD44780 based LCDs (+400) |
| 71 | 71 | ||
| 72 | CUSTOM_MATRIX = yes | 72 | CUSTOM_MATRIX = yes |
| 73 | SRC += backlight_led.c \ | 73 | SRC += indicator_leds.c \ |
| 74 | matrix.c | 74 | matrix.c duck_led/duck_led.c |
diff --git a/keyboards/duck/lightsaver/config.h b/keyboards/duck/lightsaver/config.h index 9e3a08fbd..d302fb395 100644 --- a/keyboards/duck/lightsaver/config.h +++ b/keyboards/duck/lightsaver/config.h | |||
| @@ -15,8 +15,7 @@ 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/>. | 15 | along 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 | ||
| @@ -44,6 +43,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 44 | #define RGB_DI_PIN D6 | 43 | #define RGB_DI_PIN D6 |
| 45 | #define RGBLED_NUM 17 | 44 | #define RGBLED_NUM 17 |
| 46 | 45 | ||
| 46 | /* Set to top left most key */ | ||
| 47 | #define BOOTMAGIC_LITE_ROW 5 | ||
| 48 | #define BOOTMAGIC_LITE_COLUMN 10 | ||
| 49 | |||
| 47 | #define TAPPING_TERM 200 | 50 | #define TAPPING_TERM 200 |
| 48 | 51 | ||
| 49 | #endif | ||
diff --git a/keyboards/duck/lightsaver/indicator_leds.c b/keyboards/duck/lightsaver/indicator_leds.c index 0a54e151e..5d2e1ad9f 100644 --- a/keyboards/duck/lightsaver/indicator_leds.c +++ b/keyboards/duck/lightsaver/indicator_leds.c | |||
| @@ -18,17 +18,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 18 | #include <avr/io.h> | 18 | #include <avr/io.h> |
| 19 | #include <stdbool.h> | 19 | #include <stdbool.h> |
| 20 | #include <util/delay.h> | 20 | #include <util/delay.h> |
| 21 | #include "duck_led/duck_led.h" | ||
| 21 | 22 | ||
| 22 | #define T1H 900 | 23 | #define LED_T1H 900 |
| 23 | #define T1L 600 | 24 | #define LED_T1L 600 |
| 24 | #define T0H 400 | 25 | #define LED_T0H 400 |
| 25 | #define T0L 900 | 26 | #define LED_T0L 900 |
| 26 | #define RES 6000 | ||
| 27 | |||
| 28 | #define NS_PER_SEC (1000000000L) | ||
| 29 | #define CYCLES_PER_SEC (F_CPU) | ||
| 30 | #define NS_PER_CYCLE (NS_PER_SEC / CYCLES_PER_SEC) | ||
| 31 | #define NS_TO_CYCLES(n) ((n) / NS_PER_CYCLE) | ||
| 32 | 27 | ||
| 33 | void send_bit_d4(bool bitVal) { | 28 | void send_bit_d4(bool bitVal) { |
| 34 | if(bitVal) { | 29 | if(bitVal) { |
| @@ -44,8 +39,8 @@ void send_bit_d4(bool bitVal) { | |||
| 44 | :: | 39 | :: |
| 45 | [port] "I" (_SFR_IO_ADDR(PORTD)), | 40 | [port] "I" (_SFR_IO_ADDR(PORTD)), |
| 46 | [bit] "I" (4), | 41 | [bit] "I" (4), |
| 47 | [onCycles] "I" (NS_TO_CYCLES(T1H) - 2), | 42 | [onCycles] "I" (NS_TO_CYCLES(LED_T1H) - 2), |
| 48 | [offCycles] "I" (NS_TO_CYCLES(T1L) - 2)); | 43 | [offCycles] "I" (NS_TO_CYCLES(LED_T1L) - 2)); |
| 49 | } else { | 44 | } else { |
| 50 | asm volatile ( | 45 | asm volatile ( |
| 51 | "sbi %[port], %[bit] \n\t" | 46 | "sbi %[port], %[bit] \n\t" |
| @@ -59,33 +54,31 @@ void send_bit_d4(bool bitVal) { | |||
| 59 | :: | 54 | :: |
| 60 | [port] "I" (_SFR_IO_ADDR(PORTD)), | 55 | [port] "I" (_SFR_IO_ADDR(PORTD)), |
| 61 | [bit] "I" (4), | 56 | [bit] "I" (4), |
| 62 | [onCycles] "I" (NS_TO_CYCLES(T0H) - 2), | 57 | [onCycles] "I" (NS_TO_CYCLES(LED_T0H) - 2), |
| 63 | [offCycles] "I" (NS_TO_CYCLES(T0L) - 2)); | 58 | [offCycles] "I" (NS_TO_CYCLES(LED_T0L) - 2)); |
| 64 | } | 59 | } |
| 65 | } | 60 | } |
| 66 | 61 | ||
| 67 | void show(void) { | 62 | void send_value(uint8_t byte, enum Device device) { |
| 68 | _delay_us((RES / 1000UL) + 1); | ||
| 69 | } | ||
| 70 | |||
| 71 | void send_value(uint8_t byte) { | ||
| 72 | for(uint8_t b = 0; b < 8; b++) { | 63 | for(uint8_t b = 0; b < 8; b++) { |
| 73 | send_bit_d4(byte & 0b10000000); | 64 | if(device == Device_STATUSLED) { |
| 74 | byte <<= 1; | 65 | send_bit_d4(byte & 0b10000000); |
| 66 | byte <<= 1; | ||
| 67 | } | ||
| 75 | } | 68 | } |
| 76 | } | 69 | } |
| 77 | 70 | ||
| 78 | void send_color(uint8_t r, uint8_t g, uint8_t b) { | 71 | void send_color(uint8_t r, uint8_t g, uint8_t b, enum Device device) { |
| 79 | send_value(g); | 72 | send_value(r, device); |
| 80 | send_value(r); | 73 | send_value(g, device); |
| 81 | send_value(b); | 74 | send_value(b, device); |
| 82 | } | 75 | } |
| 83 | 76 | ||
| 84 | void indicator_leds_set(bool leds[8]) { | 77 | void indicator_leds_set(bool leds[8]) { |
| 85 | cli(); | 78 | cli(); |
| 86 | send_color(leds[1] ? 255 : 0, leds[2] ? 255 : 0, leds[0] ? 255 : 0); | 79 | send_color(leds[1] ? 255 : 0, leds[2] ? 255 : 0, leds[0] ? 255 : 0, Device_STATUSLED); |
| 87 | send_color(leds[4] ? 255 : 0, leds[5] ? 255 : 0, leds[3] ? 255 : 0); | 80 | send_color(leds[4] ? 255 : 0, leds[5] ? 255 : 0, leds[3] ? 255 : 0, Device_STATUSLED); |
| 88 | send_color(leds[6] ? 255 : 0, leds[7] ? 255 : 0, 0); | 81 | send_color(leds[6] ? 255 : 0, leds[7] ? 255 : 0, 0, Device_STATUSLED); |
| 89 | sei(); | 82 | sei(); |
| 90 | show(); | 83 | show(); |
| 91 | } | 84 | } |
diff --git a/keyboards/duck/lightsaver/lightsaver.h b/keyboards/duck/lightsaver/lightsaver.h index 19fcf36ba..1e1185713 100644 --- a/keyboards/duck/lightsaver/lightsaver.h +++ b/keyboards/duck/lightsaver/lightsaver.h | |||
| @@ -13,8 +13,7 @@ | |||
| 13 | * You should have received a copy of the GNU General Public License | 13 | * You should have received a copy of the GNU General Public License |
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 15 | */ | 15 | */ |
| 16 | #ifndef LIGHTSAVER_H | 16 | #pragma once |
| 17 | #define LIGHTSAVER_H | ||
| 18 | 17 | ||
| 19 | #include "quantum.h" | 18 | #include "quantum.h" |
| 20 | 19 | ||
| @@ -37,4 +36,3 @@ | |||
| 37 | /* 5 */ { K0A, K0B, K0C, NO, NO, NO, NO, NO, K0I, NO, K0K, NO, K0M, K0N, K0O, K0P, K0Q, K0R } \ | 36 | /* 5 */ { K0A, K0B, K0C, NO, NO, NO, NO, NO, K0I, NO, K0K, NO, K0M, K0N, K0O, K0P, K0Q, K0R } \ |
| 38 | } | 37 | } |
| 39 | 38 | ||
| 40 | #endif | ||
diff --git a/keyboards/duck/lightsaver/matrix.c b/keyboards/duck/lightsaver/matrix.c index a07cdd0d1..543205c0b 100644 --- a/keyboards/duck/lightsaver/matrix.c +++ b/keyboards/duck/lightsaver/matrix.c | |||
| @@ -87,6 +87,9 @@ uint8_t matrix_scan(void) { | |||
| 87 | bool curr_bit = rows & (1<<row); | 87 | bool curr_bit = rows & (1<<row); |
| 88 | if (prev_bit != curr_bit) { | 88 | if (prev_bit != curr_bit) { |
| 89 | matrix_debouncing[row] ^= ((matrix_row_t)1<<col); | 89 | matrix_debouncing[row] ^= ((matrix_row_t)1<<col); |
| 90 | if (debouncing) { | ||
| 91 | dprint("bounce!: "); dprintf("%02X", debouncing); dprintln(); | ||
| 92 | } | ||
| 90 | debouncing = DEBOUNCING_DELAY; | 93 | debouncing = DEBOUNCING_DELAY; |
| 91 | } | 94 | } |
| 92 | } | 95 | } |
diff --git a/keyboards/duck/lightsaver/rules.mk b/keyboards/duck/lightsaver/rules.mk index d95dbd960..bc7b901b4 100644 --- a/keyboards/duck/lightsaver/rules.mk +++ b/keyboards/duck/lightsaver/rules.mk | |||
| @@ -50,23 +50,23 @@ OPT_DEFS += -DBOOTLOADER_SIZE=4096 | |||
| 50 | # Build Options | 50 | # Build Options |
| 51 | # change yes to no to disable | 51 | # change yes to no to disable |
| 52 | # | 52 | # |
| 53 | BOOTMAGIC_ENABLE ?= no # Virtual DIP switch configuration(+1000) | 53 | BOOTMAGIC_ENABLE = no # Virtual DIP switch configuration(+1000) |
| 54 | MOUSEKEY_ENABLE ?= no # Mouse keys(+4700) | 54 | MOUSEKEY_ENABLE = no # Mouse keys(+4700) |
| 55 | EXTRAKEY_ENABLE ?= no # Audio control and System control(+450) | 55 | EXTRAKEY_ENABLE = no # Audio control and System control(+450) |
| 56 | CONSOLE_ENABLE ?= no # Console for debug(+400) | 56 | CONSOLE_ENABLE = no # Console for debug(+400) |
| 57 | COMMAND_ENABLE ?= yes # Commands for debug and configuration | 57 | COMMAND_ENABLE = yes # Commands for debug and configuration |
| 58 | # Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE | 58 | # Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE |
| 59 | SLEEP_LED_ENABLE ?= no # Breathing sleep LED during USB suspend | 59 | SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend |
| 60 | # if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work | 60 | # if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work |
| 61 | NKRO_ENABLE ?= yes # USB Nkey Rollover | 61 | NKRO_ENABLE = yes # USB Nkey Rollover |
| 62 | BACKLIGHT_ENABLE ?= yes # Enable keyboard backlight functionality on B7 by default | 62 | BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality on B7 by default |
| 63 | MIDI_ENABLE ?= no # MIDI support (+2400 to 4200, depending on config) | 63 | MIDI_ENABLE = no # MIDI support (+2400 to 4200, depending on config) |
| 64 | UNICODE_ENABLE ?= no # Unicode | 64 | UNICODE_ENABLE = no # Unicode |
| 65 | BLUETOOTH_ENABLE ?= no # Enable Bluetooth with the Adafruit EZ-Key HID | 65 | BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID |
| 66 | AUDIO_ENABLE ?= no # Audio output on port C6 | 66 | AUDIO_ENABLE = no # Audio output on port C6 |
| 67 | FAUXCLICKY_ENABLE ?= no # Use buzzer to emulate clicky switches | 67 | FAUXCLICKY_ENABLE = no # Use buzzer to emulate clicky switches |
| 68 | RGBLIGHT_ENABLE = yes | 68 | RGBLIGHT_ENABLE = yes |
| 69 | 69 | ||
| 70 | CUSTOM_MATRIX = yes | 70 | CUSTOM_MATRIX = yes |
| 71 | SRC += indicator_leds.c \ | 71 | SRC += indicator_leds.c \ |
| 72 | matrix.c | 72 | matrix.c duck_led/duck_led.c |
diff --git a/keyboards/duck/octagon/v1/config.h b/keyboards/duck/octagon/v1/config.h index 5400c53ef..d818cb622 100644 --- a/keyboards/duck/octagon/v1/config.h +++ b/keyboards/duck/octagon/v1/config.h | |||
| @@ -15,8 +15,7 @@ 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/>. | 15 | along 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 | ||
| @@ -44,6 +43,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 44 | #define RGB_DI_PIN D6 | 43 | #define RGB_DI_PIN D6 |
| 45 | #define RGBLED_NUM 17 | 44 | #define RGBLED_NUM 17 |
| 46 | 45 | ||
| 47 | #define TAPPING_TERM 200 | 46 | /* Set to top left most key */ |
| 47 | #define BOOTMAGIC_LITE_ROW 5 | ||
| 48 | #define BOOTMAGIC_LITE_COLUMN 10 | ||
| 48 | 49 | ||
| 49 | #endif | 50 | #define TAPPING_TERM 200 |
diff --git a/keyboards/duck/octagon/v1/matrix.c b/keyboards/duck/octagon/v1/matrix.c index 855534994..233404ed3 100644 --- a/keyboards/duck/octagon/v1/matrix.c +++ b/keyboards/duck/octagon/v1/matrix.c | |||
| @@ -84,6 +84,9 @@ uint8_t matrix_scan(void) { | |||
| 84 | bool curr_bit = rows & (1<<row); | 84 | bool curr_bit = rows & (1<<row); |
| 85 | if (prev_bit != curr_bit) { | 85 | if (prev_bit != curr_bit) { |
| 86 | matrix_debouncing[row] ^= ((matrix_row_t)1<<col); | 86 | matrix_debouncing[row] ^= ((matrix_row_t)1<<col); |
| 87 | if (debouncing) { | ||
| 88 | dprint("bounce!: "); dprintf("%02X", debouncing); dprintln(); | ||
| 89 | } | ||
| 87 | debouncing = DEBOUNCING_DELAY; | 90 | debouncing = DEBOUNCING_DELAY; |
| 88 | } | 91 | } |
| 89 | } | 92 | } |
diff --git a/keyboards/duck/octagon/v1/rules.mk b/keyboards/duck/octagon/v1/rules.mk index a08695b50..66d2c8def 100644 --- a/keyboards/duck/octagon/v1/rules.mk +++ b/keyboards/duck/octagon/v1/rules.mk | |||
| @@ -50,21 +50,21 @@ OPT_DEFS += -DBOOTLOADER_SIZE=4096 | |||
| 50 | # Build Options | 50 | # Build Options |
| 51 | # change yes to no to disable | 51 | # change yes to no to disable |
| 52 | # | 52 | # |
| 53 | BOOTMAGIC_ENABLE ?= no # Virtual DIP switch configuration(+1000) | 53 | BOOTMAGIC_ENABLE = lite # Virtual DIP switch configuration(+1000) |
| 54 | MOUSEKEY_ENABLE ?= no # Mouse keys(+4700) | 54 | MOUSEKEY_ENABLE = no # Mouse keys(+4700) |
| 55 | EXTRAKEY_ENABLE ?= no # Audio control and System control(+450) | 55 | EXTRAKEY_ENABLE = no # Audio control and System control(+450) |
| 56 | CONSOLE_ENABLE ?= no # Console for debug(+400) | 56 | CONSOLE_ENABLE = no # Console for debug(+400) |
| 57 | COMMAND_ENABLE ?= yes # Commands for debug and configuration | 57 | COMMAND_ENABLE = yes # Commands for debug and configuration |
| 58 | # Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE | 58 | # Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE |
| 59 | SLEEP_LED_ENABLE ?= no # Breathing sleep LED during USB suspend | 59 | SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend |
| 60 | # if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work | 60 | # if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work |
| 61 | NKRO_ENABLE ?= yes # USB Nkey Rollover | 61 | NKRO_ENABLE = yes # USB Nkey Rollover |
| 62 | BACKLIGHT_ENABLE ?= yes # Enable keyboard backlight functionality on B7 by default | 62 | BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality on B7 by default |
| 63 | MIDI_ENABLE ?= no # MIDI support (+2400 to 4200, depending on config) | 63 | MIDI_ENABLE = no # MIDI support (+2400 to 4200, depending on config) |
| 64 | UNICODE_ENABLE ?= no # Unicode | 64 | UNICODE_ENABLE = no # Unicode |
| 65 | BLUETOOTH_ENABLE ?= no # Enable Bluetooth with the Adafruit EZ-Key HID | 65 | BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID |
| 66 | AUDIO_ENABLE ?= no # Audio output on port C6 | 66 | AUDIO_ENABLE = no # Audio output on port C6 |
| 67 | FAUXCLICKY_ENABLE ?= no # Use buzzer to emulate clicky switches | 67 | FAUXCLICKY_ENABLE = no # Use buzzer to emulate clicky switches |
| 68 | RGBLIGHT_ENABLE = yes | 68 | RGBLIGHT_ENABLE = yes |
| 69 | 69 | ||
| 70 | CUSTOM_MATRIX = yes | 70 | CUSTOM_MATRIX = yes |
diff --git a/keyboards/duck/octagon/v1/v1.h b/keyboards/duck/octagon/v1/v1.h index d89188f22..471a91a33 100644 --- a/keyboards/duck/octagon/v1/v1.h +++ b/keyboards/duck/octagon/v1/v1.h | |||
| @@ -13,8 +13,7 @@ | |||
| 13 | * You should have received a copy of the GNU General Public License | 13 | * You should have received a copy of the GNU General Public License |
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 15 | */ | 15 | */ |
| 16 | #ifndef V1_H | 16 | #pragma once |
| 17 | #define V1_H | ||
| 18 | 17 | ||
| 19 | #include "quantum.h" | 18 | #include "quantum.h" |
| 20 | 19 | ||
| @@ -49,4 +48,3 @@ | |||
| 49 | { K1A, K1C, K1D, K1E, K1F, K1G, K1H, K1I, K1J, K1K, K1L, KC_NO, K1M, K1N, KC_NO, K1P }, \ | 48 | { K1A, K1C, K1D, K1E, K1F, K1G, K1H, K1I, K1J, K1K, K1L, KC_NO, K1M, K1N, KC_NO, K1P }, \ |
| 50 | { K0A, K0B, K0C, KC_NO, KC_NO, K0G, KC_NO, KC_NO, K0J, K0K, K0L, KC_NO, K0M, K0N, KC_NO, K0P } \ | 49 | { K0A, K0B, K0C, KC_NO, KC_NO, K0G, KC_NO, KC_NO, K0J, K0K, K0L, KC_NO, K0M, K0N, KC_NO, K0P } \ |
| 51 | } | 50 | } |
| 52 | #endif | ||
diff --git a/keyboards/duck/octagon/v2/config.h b/keyboards/duck/octagon/v2/config.h index 78d18d3bb..4aab587f6 100644 --- a/keyboards/duck/octagon/v2/config.h +++ b/keyboards/duck/octagon/v2/config.h | |||
| @@ -15,8 +15,7 @@ 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/>. | 15 | along 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 | ||
| @@ -44,6 +43,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 44 | #define RGB_DI_PIN D6 | 43 | #define RGB_DI_PIN D6 |
| 45 | #define RGBLED_NUM 17 | 44 | #define RGBLED_NUM 17 |
| 46 | 45 | ||
| 46 | /* Set to top left most key */ | ||
| 47 | #define BOOTMAGIC_LITE_ROW 5 | ||
| 48 | #define BOOTMAGIC_LITE_COLUMN 10 | ||
| 49 | |||
| 47 | #define TAPPING_TERM 200 | 50 | #define TAPPING_TERM 200 |
| 48 | 51 | ||
| 49 | #endif | ||
diff --git a/keyboards/duck/octagon/v2/indicator_leds.c b/keyboards/duck/octagon/v2/indicator_leds.c index c24509f51..116306fb7 100644 --- a/keyboards/duck/octagon/v2/indicator_leds.c +++ b/keyboards/duck/octagon/v2/indicator_leds.c | |||
| @@ -20,16 +20,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 20 | #include <util/delay.h> | 20 | #include <util/delay.h> |
| 21 | #include "indicator_leds.h" | 21 | #include "indicator_leds.h" |
| 22 | 22 | ||
| 23 | #define T1H 900 | 23 | #define LED_T1H 900 |
| 24 | #define T1L 600 | 24 | #define LED_T1L 600 |
| 25 | #define T0H 400 | 25 | #define LED_T0H 400 |
| 26 | #define T0L 900 | 26 | #define LED_T0L 900 |
| 27 | #define RES 6000 | ||
| 28 | |||
| 29 | #define NS_PER_SEC (1000000000L) | ||
| 30 | #define CYCLES_PER_SEC (F_CPU) | ||
| 31 | #define NS_PER_CYCLE (NS_PER_SEC / CYCLES_PER_SEC) | ||
| 32 | #define NS_TO_CYCLES(n) ((n) / NS_PER_CYCLE) | ||
| 33 | 27 | ||
| 34 | void send_bit_d4(bool bitVal) { | 28 | void send_bit_d4(bool bitVal) { |
| 35 | if(bitVal) { | 29 | if(bitVal) { |
| @@ -45,8 +39,8 @@ void send_bit_d4(bool bitVal) { | |||
| 45 | :: | 39 | :: |
| 46 | [port] "I" (_SFR_IO_ADDR(PORTD)), | 40 | [port] "I" (_SFR_IO_ADDR(PORTD)), |
| 47 | [bit] "I" (4), | 41 | [bit] "I" (4), |
| 48 | [onCycles] "I" (NS_TO_CYCLES(T1H) - 2), | 42 | [onCycles] "I" (NS_TO_CYCLES(LED_T1H) - 2), |
| 49 | [offCycles] "I" (NS_TO_CYCLES(T1L) - 2)); | 43 | [offCycles] "I" (NS_TO_CYCLES(LED_T1L) - 2)); |
| 50 | } else { | 44 | } else { |
| 51 | asm volatile ( | 45 | asm volatile ( |
| 52 | "sbi %[port], %[bit] \n\t" | 46 | "sbi %[port], %[bit] \n\t" |
| @@ -60,8 +54,8 @@ void send_bit_d4(bool bitVal) { | |||
| 60 | :: | 54 | :: |
| 61 | [port] "I" (_SFR_IO_ADDR(PORTD)), | 55 | [port] "I" (_SFR_IO_ADDR(PORTD)), |
| 62 | [bit] "I" (4), | 56 | [bit] "I" (4), |
| 63 | [onCycles] "I" (NS_TO_CYCLES(T0H) - 2), | 57 | [onCycles] "I" (NS_TO_CYCLES(LED_T0H) - 2), |
| 64 | [offCycles] "I" (NS_TO_CYCLES(T0L) - 2)); | 58 | [offCycles] "I" (NS_TO_CYCLES(LED_T0L) - 2)); |
| 65 | } | 59 | } |
| 66 | } | 60 | } |
| 67 | 61 | ||
| @@ -80,8 +74,8 @@ void send_bit_d6(bool bitVal) | |||
| 80 | :: | 74 | :: |
| 81 | [port] "I" (_SFR_IO_ADDR(PORTD)), | 75 | [port] "I" (_SFR_IO_ADDR(PORTD)), |
| 82 | [bit] "I" (6), | 76 | [bit] "I" (6), |
| 83 | [onCycles] "I" (NS_TO_CYCLES(T1H) - 2), | 77 | [onCycles] "I" (NS_TO_CYCLES(LED_T1H) - 2), |
| 84 | [offCycles] "I" (NS_TO_CYCLES(T1L) - 2)); | 78 | [offCycles] "I" (NS_TO_CYCLES(LED_T1L) - 2)); |
| 85 | } else { | 79 | } else { |
| 86 | asm volatile ( | 80 | asm volatile ( |
| 87 | "sbi %[port], %[bit] \n\t" | 81 | "sbi %[port], %[bit] \n\t" |
| @@ -95,15 +89,11 @@ void send_bit_d6(bool bitVal) | |||
| 95 | :: | 89 | :: |
| 96 | [port] "I" (_SFR_IO_ADDR(PORTD)), | 90 | [port] "I" (_SFR_IO_ADDR(PORTD)), |
| 97 | [bit] "I" (6), | 91 | [bit] "I" (6), |
| 98 | [onCycles] "I" (NS_TO_CYCLES(T0H) - 2), | 92 | [onCycles] "I" (NS_TO_CYCLES(LED_T0H) - 2), |
| 99 | [offCycles] "I" (NS_TO_CYCLES(T0L) - 2)); | 93 | [offCycles] "I" (NS_TO_CYCLES(LED_T0L) - 2)); |
| 100 | } | 94 | } |
| 101 | } | 95 | } |
| 102 | 96 | ||
| 103 | void show(void) { | ||
| 104 | _delay_us((RES / 1000UL) + 1); | ||
| 105 | } | ||
| 106 | |||
| 107 | void send_value(uint8_t byte, enum Device device) { | 97 | void send_value(uint8_t byte, enum Device device) { |
| 108 | for(uint8_t b = 0; b < 8; b++) { | 98 | for(uint8_t b = 0; b < 8; b++) { |
| 109 | if(device == Device_STATUSLED) { | 99 | if(device == Device_STATUSLED) { |
| @@ -117,8 +107,8 @@ void send_value(uint8_t byte, enum Device device) { | |||
| 117 | } | 107 | } |
| 118 | 108 | ||
| 119 | void send_color(uint8_t r, uint8_t g, uint8_t b, enum Device device) { | 109 | void send_color(uint8_t r, uint8_t g, uint8_t b, enum Device device) { |
| 120 | send_value(g, device); | ||
| 121 | send_value(r, device); | 110 | send_value(r, device); |
| 111 | send_value(g, device); | ||
| 122 | send_value(b, device); | 112 | send_value(b, device); |
| 123 | } | 113 | } |
| 124 | 114 | ||
diff --git a/keyboards/duck/octagon/v2/indicator_leds.h b/keyboards/duck/octagon/v2/indicator_leds.h index 9bb2c8ced..ad3ec54f5 100644 --- a/keyboards/duck/octagon/v2/indicator_leds.h +++ b/keyboards/duck/octagon/v2/indicator_leds.h | |||
| @@ -1,11 +1,7 @@ | |||
| 1 | enum Device { | 1 | #include "duck_led/duck_led.h" |
| 2 | Device_PCBRGB, | ||
| 3 | Device_STATUSLED | ||
| 4 | }; | ||
| 5 | 2 | ||
| 6 | void indicator_leds_set(bool leds[8]); | 3 | void indicator_leds_set(bool leds[8]); |
| 7 | void backlight_toggle_rgb(bool enabled); | 4 | void backlight_toggle_rgb(bool enabled); |
| 8 | void backlight_set_rgb(uint8_t cfg[17][3]); | 5 | void backlight_set_rgb(uint8_t cfg[17][3]); |
| 9 | void backlight_init_ports(void); | 6 | void backlight_init_ports(void); |
| 10 | void send_color(uint8_t r, uint8_t g, uint8_t b, enum Device device); | 7 | void send_color(uint8_t r, uint8_t g, uint8_t b, enum Device device); |
| 11 | void show(void); \ No newline at end of file | ||
diff --git a/keyboards/duck/octagon/v2/matrix.c b/keyboards/duck/octagon/v2/matrix.c index a63a37640..e6e7046b4 100644 --- a/keyboards/duck/octagon/v2/matrix.c +++ b/keyboards/duck/octagon/v2/matrix.c | |||
| @@ -89,6 +89,9 @@ uint8_t matrix_scan(void) { | |||
| 89 | bool curr_bit = rows & (1<<row); | 89 | bool curr_bit = rows & (1<<row); |
| 90 | if (prev_bit != curr_bit) { | 90 | if (prev_bit != curr_bit) { |
| 91 | matrix_debouncing[row] ^= ((matrix_row_t)1<<col); | 91 | matrix_debouncing[row] ^= ((matrix_row_t)1<<col); |
| 92 | if (debouncing) { | ||
| 93 | dprint("bounce!: "); dprintf("%02X", debouncing); dprintln(); | ||
| 94 | } | ||
| 92 | debouncing = DEBOUNCING_DELAY; | 95 | debouncing = DEBOUNCING_DELAY; |
| 93 | } | 96 | } |
| 94 | } | 97 | } |
diff --git a/keyboards/duck/octagon/v2/readme.md b/keyboards/duck/octagon/v2/readme.md index b409454fc..cc9474fc9 100644 --- a/keyboards/duck/octagon/v2/readme.md +++ b/keyboards/duck/octagon/v2/readme.md | |||
| @@ -11,6 +11,8 @@ Make example for this keyboard (after setting up your build environment): | |||
| 11 | 11 | ||
| 12 | make octagon/v2:default | 12 | make octagon/v2:default |
| 13 | 13 | ||
| 14 | **Reset Key:** To put the Octagon V2 into reset, hold the top right most key (`K5Q`) while plugging in. | ||
| 15 | |||
| 14 | See [build environment setup](https://docs.qmk.fm/#/getting_started_build_tools) then the [make instructions](https://docs.qmk.fm/#/getting_started_make_guide) for more information. | 16 | See [build environment setup](https://docs.qmk.fm/#/getting_started_build_tools) then the [make instructions](https://docs.qmk.fm/#/getting_started_make_guide) for more information. |
| 15 | 17 | ||
| 16 | ## Hardware Notes | 18 | ## Hardware Notes |
diff --git a/keyboards/duck/octagon/v2/rules.mk b/keyboards/duck/octagon/v2/rules.mk index 37f3938d9..c40324707 100644 --- a/keyboards/duck/octagon/v2/rules.mk +++ b/keyboards/duck/octagon/v2/rules.mk | |||
| @@ -50,25 +50,25 @@ OPT_DEFS += -DBOOTLOADER_SIZE=4096 | |||
| 50 | # Build Options | 50 | # Build Options |
| 51 | # change yes to no to disable | 51 | # change yes to no to disable |
| 52 | # | 52 | # |
| 53 | BOOTMAGIC_ENABLE ?= no # Virtual DIP switch configuration(+1000) | 53 | BOOTMAGIC_ENABLE = lite # Virtual DIP switch configuration(+1000) |
| 54 | MOUSEKEY_ENABLE ?= no # Mouse keys(+4700) | 54 | MOUSEKEY_ENABLE = no # Mouse keys(+4700) |
| 55 | EXTRAKEY_ENABLE ?= no # Audio control and System control(+450) | 55 | EXTRAKEY_ENABLE = no # Audio control and System control(+450) |
| 56 | CONSOLE_ENABLE ?= no # Console for debug(+400) | 56 | CONSOLE_ENABLE = no # Console for debug(+400) |
| 57 | COMMAND_ENABLE ?= yes # Commands for debug and configuration | 57 | COMMAND_ENABLE = yes # Commands for debug and configuration |
| 58 | # Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE | 58 | # Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE |
| 59 | SLEEP_LED_ENABLE ?= no # Breathing sleep LED during USB suspend | 59 | SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend |
| 60 | # if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work | 60 | # if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work |
| 61 | NKRO_ENABLE ?= yes # USB Nkey Rollover | 61 | NKRO_ENABLE = yes # USB Nkey Rollover |
| 62 | BACKLIGHT_ENABLE ?= yes # Enable keyboard backlight functionality on B7 by default | 62 | BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality on B7 by default |
| 63 | MIDI_ENABLE ?= no # MIDI support (+2400 to 4200, depending on config) | 63 | MIDI_ENABLE = no # MIDI support (+2400 to 4200, depending on config) |
| 64 | UNICODE_ENABLE ?= no # Unicode | 64 | UNICODE_ENABLE = no # Unicode |
| 65 | BLUETOOTH_ENABLE ?= no # Enable Bluetooth with the Adafruit EZ-Key HID | 65 | BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID |
| 66 | AUDIO_ENABLE ?= no # Audio output on port C6 | 66 | AUDIO_ENABLE = no # Audio output on port C6 |
| 67 | FAUXCLICKY_ENABLE ?= no # Use buzzer to emulate clicky switches | 67 | FAUXCLICKY_ENABLE = no # Use buzzer to emulate clicky switches |
| 68 | RGBLIGHT_ENABLE = yes | 68 | RGBLIGHT_ENABLE = yes |
| 69 | 69 | ||
| 70 | CUSTOM_MATRIX = yes | 70 | CUSTOM_MATRIX = yes |
| 71 | SRC += indicator_leds.c \ | 71 | SRC += indicator_leds.c \ |
| 72 | matrix.c | 72 | matrix.c duck_led/duck_led.c |
| 73 | 73 | ||
| 74 | LAYOUTS = 75_ansi | 74 | LAYOUTS = 75_ansi |
diff --git a/keyboards/duck/octagon/v2/v2.h b/keyboards/duck/octagon/v2/v2.h index 1487b3640..d60631009 100644 --- a/keyboards/duck/octagon/v2/v2.h +++ b/keyboards/duck/octagon/v2/v2.h | |||
| @@ -13,8 +13,7 @@ | |||
| 13 | * You should have received a copy of the GNU General Public License | 13 | * You should have received a copy of the GNU General Public License |
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 15 | */ | 15 | */ |
| 16 | #ifndef V2_H | 16 | #pragma once |
| 17 | #define V2_H | ||
| 18 | 17 | ||
| 19 | #include "quantum.h" | 18 | #include "quantum.h" |
| 20 | 19 | ||
| @@ -49,4 +48,3 @@ | |||
| 49 | { K1A, KC_NO, K1C, K1D, K1E, K1F, K1G, K1H, K1I, K1J, K1K, KC_NO, K1M, K1N, K1O, K1P, KC_NO }, \ | 48 | { K1A, KC_NO, K1C, K1D, K1E, K1F, K1G, K1H, K1I, K1J, K1K, KC_NO, K1M, K1N, K1O, K1P, KC_NO }, \ |
| 50 | { K0A, K0B, K0C, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, K0J, KC_NO, K0K, K0L, K0M, K0N, K0O, K0P, KC_NO } \ | 49 | { K0A, K0B, K0C, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, K0J, KC_NO, K0K, K0L, K0M, K0N, K0O, K0P, KC_NO } \ |
| 51 | } | 50 | } |
| 52 | #endif | ||
