From cb2f2fd258011e6637ed182f484a4317ac510db8 Mon Sep 17 00:00:00 2001 From: MechMerlin <30334081+mechmerlin@users.noreply.github.com> Date: Wed, 3 Apr 2019 10:17:25 -0700 Subject: [PATCH] [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 --- keyboards/duck/duck_led/duck_led.c | 7 +++ keyboards/duck/duck_led/duck_led.h | 16 ++++++ keyboards/duck/eagle_viper/readme.md | 1 - keyboards/duck/eagle_viper/v2/config.h | 8 +-- .../duck/eagle_viper/v2/indicator_leds.c | 23 +++------ .../duck/eagle_viper/v2/indicator_leds.h | 1 - keyboards/duck/eagle_viper/v2/matrix.c | 3 ++ keyboards/duck/eagle_viper/v2/readme.md | 2 + keyboards/duck/eagle_viper/v2/rules.mk | 28 +++++------ keyboards/duck/eagle_viper/v2/v2.h | 4 +- keyboards/duck/jetfire/config.h | 4 ++ .../{backlight_led.c => indicator_leds.c} | 43 ++++++---------- .../{backlight_led.h => indicator_leds.h} | 11 +---- keyboards/duck/jetfire/jetfire.c | 10 ++-- keyboards/duck/jetfire/jetfire.h | 4 +- keyboards/duck/jetfire/readme.md | 2 +- keyboards/duck/jetfire/rules.mk | 6 +-- keyboards/duck/lightsaver/config.h | 8 +-- keyboards/duck/lightsaver/indicator_leds.c | 49 ++++++++----------- keyboards/duck/lightsaver/lightsaver.h | 4 +- keyboards/duck/lightsaver/matrix.c | 3 ++ keyboards/duck/lightsaver/rules.mk | 28 +++++------ keyboards/duck/octagon/v1/config.h | 9 ++-- keyboards/duck/octagon/v1/matrix.c | 3 ++ keyboards/duck/octagon/v1/rules.mk | 26 +++++----- keyboards/duck/octagon/v1/v1.h | 4 +- keyboards/duck/octagon/v2/config.h | 8 +-- keyboards/duck/octagon/v2/indicator_leds.c | 36 +++++--------- keyboards/duck/octagon/v2/indicator_leds.h | 6 +-- keyboards/duck/octagon/v2/matrix.c | 3 ++ keyboards/duck/octagon/v2/readme.md | 2 + keyboards/duck/octagon/v2/rules.mk | 28 +++++------ keyboards/duck/octagon/v2/v2.h | 4 +- 33 files changed, 192 insertions(+), 202 deletions(-) create mode 100644 keyboards/duck/duck_led/duck_led.c create mode 100644 keyboards/duck/duck_led/duck_led.h rename keyboards/duck/jetfire/{backlight_led.c => indicator_leds.c} (76%) rename keyboards/duck/jetfire/{backlight_led.h => indicator_leds.h} (70%) 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 @@ +#include +#include "duck_led.h" +#include "quantum.h" + +void show(void) { + wait_us((RES / 1000UL) + 1); +} 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 @@ +#pragma once + +#define RES 6000 + +#define NS_PER_SEC (1000000000L) +#define CYCLES_PER_SEC (F_CPU) +#define NS_PER_CYCLE (NS_PER_SEC / CYCLES_PER_SEC) +#define NS_TO_CYCLES(n) ((n) / NS_PER_CYCLE) + +enum Device { + Device_PCBRGB, + Device_STATUSLED +}; + +void show(void); + 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) Make example for this keyboard (after setting up your build environment): make duck/eagle_viper/v2:default - 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 along with this program. If not, see . */ -#ifndef CONFIG_H -#define CONFIG_H +#pragma once #include "config_common.h" @@ -44,6 +43,9 @@ along with this program. If not, see . #define RGB_DI_PIN D6 #define RGBLED_NUM 17 +/* Set to top left most key */ +#define BOOTMAGIC_LITE_ROW 4 +#define BOOTMAGIC_LITE_COLUMN 10 + #define TAPPING_TERM 200 -#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 . #include #include #include "indicator_leds.h" - -#define RES 6000 +#include "duck_led/duck_led.h" #define LED_T1H 600 #define LED_T1L 650 #define LED_T0H 250 #define LED_T0L 1000 -#define NS_PER_SEC (1000000000L) -#define CYCLES_PER_SEC (F_CPU) -#define NS_PER_CYCLE (NS_PER_SEC / CYCLES_PER_SEC) -#define NS_TO_CYCLES(n) ((n) / NS_PER_CYCLE) - void send_bit_d4(bool bitVal) { if(bitVal) { asm volatile ( @@ -66,14 +60,12 @@ void send_bit_d4(bool bitVal) { } } -void show(void) { - _delay_us((RES / 1000UL) + 1); -} - -void send_value(uint8_t byte) { +void send_value(uint8_t byte, enum Device device) { for(uint8_t b = 0; b < 8; b++) { - send_bit_d4(byte & 0b10000000); - byte <<= 1; + if(device == Device_STATUSLED) { + send_bit_d4(byte & 0b10000000); + byte <<= 1; + } } } @@ -83,7 +75,8 @@ void indicator_leds_set(bool leds[8]) { cli(); for(led_cnt = 0; led_cnt < 8; led_cnt++) - send_value(leds[led_cnt] ? 255 : 0); + send_value(leds[led_cnt] ? 255 : 0, Device_STATUSLED); sei(); show(); } + 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 @@ void indicator_leds_set(bool leds[8]); -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) { bool curr_bit = rows & (1<. */ -#ifndef V2_H -#define V2_H +#pragma once #include "quantum.h" @@ -78,4 +77,3 @@ #define LAYOUT_eagle LAYOUT_60_ansi -#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 . /* Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not needed */ #define DEBOUNCING_DELAY 5 +/* Set to top left most key */ +#define BOOTMAGIC_LITE_ROW 5 +#define BOOTMAGIC_LITE_COLUMN 10 + /* If defined, GRAVE_ESC will always act as ESC when CTRL is held. * This is userful for the Windows task manager shortcut (ctrl+shift+esc). */ diff --git a/keyboards/duck/jetfire/backlight_led.c b/keyboards/duck/jetfire/indicator_leds.c similarity index 76% rename from keyboards/duck/jetfire/backlight_led.c rename to 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 . #include #include #include -#include "backlight_led.h" +#include "indicator_leds.h" #include "quantum.h" -// #include "led.h" - -#define T1H 900 -#define T1L 600 -#define T0H 400 -#define T0L 900 -#define RES 6000 - -#define NS_PER_SEC (1000000000L) -#define CYCLES_PER_SEC (F_CPU) -#define NS_PER_CYCLE (NS_PER_SEC / CYCLES_PER_SEC) -#define NS_TO_CYCLES(n) ((n) / NS_PER_CYCLE) +#define LED_T1H 900 +#define LED_T1L 600 +#define LED_T0H 400 +#define LED_T0L 900 void send_bit_d4(bool bitVal) { @@ -48,8 +40,8 @@ void send_bit_d4(bool bitVal) :: [port] "I" (_SFR_IO_ADDR(PORTD)), [bit] "I" (4), - [onCycles] "I" (NS_TO_CYCLES(T1H) - 2), - [offCycles] "I" (NS_TO_CYCLES(T1L) - 2)); + [onCycles] "I" (NS_TO_CYCLES(LED_T1H) - 2), + [offCycles] "I" (NS_TO_CYCLES(LED_T1L) - 2)); } else { asm volatile ( "sbi %[port], %[bit] \n\t" @@ -63,8 +55,8 @@ void send_bit_d4(bool bitVal) :: [port] "I" (_SFR_IO_ADDR(PORTD)), [bit] "I" (4), - [onCycles] "I" (NS_TO_CYCLES(T0H) - 2), - [offCycles] "I" (NS_TO_CYCLES(T0L) - 2)); + [onCycles] "I" (NS_TO_CYCLES(LED_T0H) - 2), + [offCycles] "I" (NS_TO_CYCLES(LED_T0L) - 2)); } } @@ -83,8 +75,8 @@ void send_bit_d6(bool bitVal) :: [port] "I" (_SFR_IO_ADDR(PORTD)), [bit] "I" (6), - [onCycles] "I" (NS_TO_CYCLES(T1H) - 2), - [offCycles] "I" (NS_TO_CYCLES(T1L) - 2)); + [onCycles] "I" (NS_TO_CYCLES(LED_T1H) - 2), + [offCycles] "I" (NS_TO_CYCLES(LED_T1L) - 2)); } else { asm volatile ( "sbi %[port], %[bit] \n\t" @@ -98,20 +90,15 @@ void send_bit_d6(bool bitVal) :: [port] "I" (_SFR_IO_ADDR(PORTD)), [bit] "I" (6), - [onCycles] "I" (NS_TO_CYCLES(T0H) - 2), - [offCycles] "I" (NS_TO_CYCLES(T0L) - 2)); + [onCycles] "I" (NS_TO_CYCLES(LED_T0H) - 2), + [offCycles] "I" (NS_TO_CYCLES(LED_T0L) - 2)); } } -void show(void) -{ - _delay_us((RES / 1000UL) + 1); -} - void send_value(uint8_t byte, enum Device device) { for(uint8_t b = 0; b < 8; b++) { - if(device == Device_STATELED) { + if(device == Device_STATUSLED) { send_bit_d4(byte & 0b10000000); } if(device == Device_PCBRGB) { @@ -123,7 +110,7 @@ void send_value(uint8_t byte, enum Device device) void send_color(uint8_t r, uint8_t g, uint8_t b, enum Device device) { - send_value(g, device); send_value(r, device); + send_value(g, device); send_value(b, device); } diff --git a/keyboards/duck/jetfire/backlight_led.h b/keyboards/duck/jetfire/indicator_leds.h similarity index 70% rename from keyboards/duck/jetfire/backlight_led.h rename to 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 @@ -#ifndef BACKLIGHT_LED_H -#define BACKLIGHT_LED_H +#pragma once -enum Device { - Device_PCBRGB, - Device_STATELED -}; +#include "duck_led/duck_led.h" void backlight_init_ports(void); void backlight_set_state(bool cfg[7]); @@ -13,6 +9,3 @@ void backlight_toggle_rgb(bool enabled); void backlight_set_rgb(uint8_t cfg[17][3]); void backlight_set(uint8_t level); void send_color(uint8_t r, uint8_t g, uint8_t b, enum Device device); -void show(void); - -#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 @@ * along with this program. If not, see . */ #include "jetfire.h" -#include "backlight_led.h" +#include "indicator_leds.h" -enum backlight_level { +enum BACKLIGHT_AREAS { BACKLIGHT_ALPHA = 0b0000001, BACKLIGHT_MOD = 0b0000010, BACKLIGHT_FROW = 0b0000100, @@ -137,15 +137,15 @@ void backlight_update_state() send_color(backlight_state_led & (1<. */ -#ifndef JETFIRE_H -#define JETFIRE_H +#pragma once #include "quantum.h" @@ -57,4 +56,3 @@ { 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 } \ } -#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) Hardware Supported: Duck Jetfire PCB Hardware Availability: [Geekhack GB](https://geekhack.org/index.php?topic=92708.0) -To get into bootloader mode, hold the top top most key above the 2 navigation keys while connecting the USB cable. +**Reset Key:** To put the Jetfire into reset, hold top most key above the 2 navigation keys (`K5P`) while plugging in. Make example for this keyboard (after setting up your build environment): 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 # Build Options # change yes to no to disable # -BOOTMAGIC_ENABLE = no # Virtual DIP switch configuration(+1000) +BOOTMAGIC_ENABLE = lite # Virtual DIP switch configuration(+1000) MOUSEKEY_ENABLE = no # Mouse keys(+4700) EXTRAKEY_ENABLE = no # Audio control and System control(+450) CONSOLE_ENABLE = yes # Console for debug(+400) @@ -70,5 +70,5 @@ FAUXCLICKY_ENABLE = no # Use buzzer to emulate clicky switches HD44780_ENABLE = no # Enable support for HD44780 based LCDs (+400) CUSTOM_MATRIX = yes -SRC += backlight_led.c \ - matrix.c +SRC += indicator_leds.c \ + 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 along with this program. If not, see . */ -#ifndef CONFIG_H -#define CONFIG_H +#pragma once #include "config_common.h" @@ -44,6 +43,9 @@ along with this program. If not, see . #define RGB_DI_PIN D6 #define RGBLED_NUM 17 +/* Set to top left most key */ +#define BOOTMAGIC_LITE_ROW 5 +#define BOOTMAGIC_LITE_COLUMN 10 + #define TAPPING_TERM 200 -#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 . #include #include #include +#include "duck_led/duck_led.h" -#define T1H 900 -#define T1L 600 -#define T0H 400 -#define T0L 900 -#define RES 6000 - -#define NS_PER_SEC (1000000000L) -#define CYCLES_PER_SEC (F_CPU) -#define NS_PER_CYCLE (NS_PER_SEC / CYCLES_PER_SEC) -#define NS_TO_CYCLES(n) ((n) / NS_PER_CYCLE) +#define LED_T1H 900 +#define LED_T1L 600 +#define LED_T0H 400 +#define LED_T0L 900 void send_bit_d4(bool bitVal) { if(bitVal) { @@ -44,8 +39,8 @@ void send_bit_d4(bool bitVal) { :: [port] "I" (_SFR_IO_ADDR(PORTD)), [bit] "I" (4), - [onCycles] "I" (NS_TO_CYCLES(T1H) - 2), - [offCycles] "I" (NS_TO_CYCLES(T1L) - 2)); + [onCycles] "I" (NS_TO_CYCLES(LED_T1H) - 2), + [offCycles] "I" (NS_TO_CYCLES(LED_T1L) - 2)); } else { asm volatile ( "sbi %[port], %[bit] \n\t" @@ -59,33 +54,31 @@ void send_bit_d4(bool bitVal) { :: [port] "I" (_SFR_IO_ADDR(PORTD)), [bit] "I" (4), - [onCycles] "I" (NS_TO_CYCLES(T0H) - 2), - [offCycles] "I" (NS_TO_CYCLES(T0L) - 2)); + [onCycles] "I" (NS_TO_CYCLES(LED_T0H) - 2), + [offCycles] "I" (NS_TO_CYCLES(LED_T0L) - 2)); } } -void show(void) { - _delay_us((RES / 1000UL) + 1); -} - -void send_value(uint8_t byte) { +void send_value(uint8_t byte, enum Device device) { for(uint8_t b = 0; b < 8; b++) { - send_bit_d4(byte & 0b10000000); - byte <<= 1; + if(device == Device_STATUSLED) { + send_bit_d4(byte & 0b10000000); + byte <<= 1; + } } } -void send_color(uint8_t r, uint8_t g, uint8_t b) { - send_value(g); - send_value(r); - send_value(b); +void send_color(uint8_t r, uint8_t g, uint8_t b, enum Device device) { + send_value(r, device); + send_value(g, device); + send_value(b, device); } void indicator_leds_set(bool leds[8]) { cli(); - send_color(leds[1] ? 255 : 0, leds[2] ? 255 : 0, leds[0] ? 255 : 0); - send_color(leds[4] ? 255 : 0, leds[5] ? 255 : 0, leds[3] ? 255 : 0); - send_color(leds[6] ? 255 : 0, leds[7] ? 255 : 0, 0); + send_color(leds[1] ? 255 : 0, leds[2] ? 255 : 0, leds[0] ? 255 : 0, Device_STATUSLED); + send_color(leds[4] ? 255 : 0, leds[5] ? 255 : 0, leds[3] ? 255 : 0, Device_STATUSLED); + send_color(leds[6] ? 255 : 0, leds[7] ? 255 : 0, 0, Device_STATUSLED); sei(); show(); } 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 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -#ifndef LIGHTSAVER_H -#define LIGHTSAVER_H +#pragma once #include "quantum.h" @@ -37,4 +36,3 @@ /* 5 */ { K0A, K0B, K0C, NO, NO, NO, NO, NO, K0I, NO, K0K, NO, K0M, K0N, K0O, K0P, K0Q, K0R } \ } -#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) { bool curr_bit = rows & (1<. */ -#ifndef CONFIG_H -#define CONFIG_H +#pragma once #include "config_common.h" @@ -44,6 +43,8 @@ along with this program. If not, see . #define RGB_DI_PIN D6 #define RGBLED_NUM 17 -#define TAPPING_TERM 200 +/* Set to top left most key */ +#define BOOTMAGIC_LITE_ROW 5 +#define BOOTMAGIC_LITE_COLUMN 10 -#endif +#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) { bool curr_bit = rows & (1<. */ -#ifndef V1_H -#define V1_H +#pragma once #include "quantum.h" @@ -49,4 +48,3 @@ { K1A, K1C, K1D, K1E, K1F, K1G, K1H, K1I, K1J, K1K, K1L, KC_NO, K1M, K1N, KC_NO, K1P }, \ { K0A, K0B, K0C, KC_NO, KC_NO, K0G, KC_NO, KC_NO, K0J, K0K, K0L, KC_NO, K0M, K0N, KC_NO, K0P } \ } -#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 along with this program. If not, see . */ -#ifndef CONFIG_H -#define CONFIG_H +#pragma once #include "config_common.h" @@ -44,6 +43,9 @@ along with this program. If not, see . #define RGB_DI_PIN D6 #define RGBLED_NUM 17 +/* Set to top left most key */ +#define BOOTMAGIC_LITE_ROW 5 +#define BOOTMAGIC_LITE_COLUMN 10 + #define TAPPING_TERM 200 -#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 . #include #include "indicator_leds.h" -#define T1H 900 -#define T1L 600 -#define T0H 400 -#define T0L 900 -#define RES 6000 - -#define NS_PER_SEC (1000000000L) -#define CYCLES_PER_SEC (F_CPU) -#define NS_PER_CYCLE (NS_PER_SEC / CYCLES_PER_SEC) -#define NS_TO_CYCLES(n) ((n) / NS_PER_CYCLE) +#define LED_T1H 900 +#define LED_T1L 600 +#define LED_T0H 400 +#define LED_T0L 900 void send_bit_d4(bool bitVal) { if(bitVal) { @@ -45,8 +39,8 @@ void send_bit_d4(bool bitVal) { :: [port] "I" (_SFR_IO_ADDR(PORTD)), [bit] "I" (4), - [onCycles] "I" (NS_TO_CYCLES(T1H) - 2), - [offCycles] "I" (NS_TO_CYCLES(T1L) - 2)); + [onCycles] "I" (NS_TO_CYCLES(LED_T1H) - 2), + [offCycles] "I" (NS_TO_CYCLES(LED_T1L) - 2)); } else { asm volatile ( "sbi %[port], %[bit] \n\t" @@ -60,8 +54,8 @@ void send_bit_d4(bool bitVal) { :: [port] "I" (_SFR_IO_ADDR(PORTD)), [bit] "I" (4), - [onCycles] "I" (NS_TO_CYCLES(T0H) - 2), - [offCycles] "I" (NS_TO_CYCLES(T0L) - 2)); + [onCycles] "I" (NS_TO_CYCLES(LED_T0H) - 2), + [offCycles] "I" (NS_TO_CYCLES(LED_T0L) - 2)); } } @@ -80,8 +74,8 @@ void send_bit_d6(bool bitVal) :: [port] "I" (_SFR_IO_ADDR(PORTD)), [bit] "I" (6), - [onCycles] "I" (NS_TO_CYCLES(T1H) - 2), - [offCycles] "I" (NS_TO_CYCLES(T1L) - 2)); + [onCycles] "I" (NS_TO_CYCLES(LED_T1H) - 2), + [offCycles] "I" (NS_TO_CYCLES(LED_T1L) - 2)); } else { asm volatile ( "sbi %[port], %[bit] \n\t" @@ -95,15 +89,11 @@ void send_bit_d6(bool bitVal) :: [port] "I" (_SFR_IO_ADDR(PORTD)), [bit] "I" (6), - [onCycles] "I" (NS_TO_CYCLES(T0H) - 2), - [offCycles] "I" (NS_TO_CYCLES(T0L) - 2)); + [onCycles] "I" (NS_TO_CYCLES(LED_T0H) - 2), + [offCycles] "I" (NS_TO_CYCLES(LED_T0L) - 2)); } } -void show(void) { - _delay_us((RES / 1000UL) + 1); -} - void send_value(uint8_t byte, enum Device device) { for(uint8_t b = 0; b < 8; b++) { if(device == Device_STATUSLED) { @@ -117,8 +107,8 @@ void send_value(uint8_t byte, enum Device device) { } void send_color(uint8_t r, uint8_t g, uint8_t b, enum Device device) { - send_value(g, device); send_value(r, device); + send_value(g, device); send_value(b, device); } 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 @@ -enum Device { - Device_PCBRGB, - Device_STATUSLED -}; +#include "duck_led/duck_led.h" void indicator_leds_set(bool leds[8]); void backlight_toggle_rgb(bool enabled); void backlight_set_rgb(uint8_t cfg[17][3]); void backlight_init_ports(void); void send_color(uint8_t r, uint8_t g, uint8_t b, enum Device device); -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) { bool curr_bit = rows & (1<. */ -#ifndef V2_H -#define V2_H +#pragma once #include "quantum.h" @@ -49,4 +48,3 @@ { K1A, KC_NO, K1C, K1D, K1E, K1F, K1G, K1H, K1I, K1J, K1K, KC_NO, K1M, K1N, K1O, K1P, KC_NO }, \ { K0A, K0B, K0C, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, K0J, KC_NO, K0K, K0L, K0M, K0N, K0O, K0P, KC_NO } \ } -#endif