summaryrefslogtreecommitdiff
path: root/keyboards/duck/jetfire
diff options
context:
space:
mode:
authorMechMerlin <30334081+mechmerlin@users.noreply.github.com>2019-04-03 10:17:25 -0700
committerDrashna Jaelre <drashna@live.com>2019-04-03 10:17:25 -0700
commitcb2f2fd258011e6637ed182f484a4317ac510db8 (patch)
treee0ffc4ff80b4467110787575ea581daa3fa140af /keyboards/duck/jetfire
parentcaefb1c61eca10dcb70ca6481a8a592057de7318 (diff)
downloadqmk_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/jetfire')
-rw-r--r--keyboards/duck/jetfire/config.h4
-rw-r--r--keyboards/duck/jetfire/indicator_leds.c (renamed from keyboards/duck/jetfire/backlight_led.c)43
-rw-r--r--keyboards/duck/jetfire/indicator_leds.h (renamed from keyboards/duck/jetfire/backlight_led.h)11
-rw-r--r--keyboards/duck/jetfire/jetfire.c10
-rw-r--r--keyboards/duck/jetfire/jetfire.h4
-rw-r--r--keyboards/duck/jetfire/readme.md2
-rw-r--r--keyboards/duck/jetfire/rules.mk6
7 files changed, 31 insertions, 49 deletions
diff --git a/keyboards/duck/jetfire/config.h b/keyboards/duck/jetfire/config.h
index 4bc535b192..774e284918 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/>.
/* 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
index 7e9dca6e9f..7dbdb1ff79 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/>.
#include <stdbool.h>
#include <util/delay.h>
#include <stdint.h>
-#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
index 36d8d9aa9b..695e1db6d4 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 81bdb95ba1..0662489c6f 100644
--- a/keyboards/duck/jetfire/jetfire.c
+++ b/keyboards/duck/jetfire/jetfire.c
@@ -14,9 +14,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#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<<STATE_LED_SCROLL_LOCK) ? 255 : 0,
backlight_state_led & (1<<STATE_LED_CAPS_LOCK) ? 255 : 0,
backlight_state_led & (1<<STATE_LED_NUM_LOCK) ? 255 : 0,
- Device_STATELED);
+ Device_STATUSLED);
send_color(backlight_state_led & (1<<STATE_LED_LAYER_1) ? 255 : 0,
backlight_state_led & (1<<STATE_LED_LAYER_2) ? 255 : 0,
backlight_state_led & (1<<STATE_LED_LAYER_0) ? 255 : 0,
- Device_STATELED);
+ Device_STATUSLED);
send_color(backlight_state_led & (1<<STATE_LED_LAYER_4) ? 255 : 0,
backlight_state_led & (1<<STATE_LED_LAYER_3) ? 255 : 0,
0,
- Device_STATELED);
+ Device_STATUSLED);
sei();
show();
}
diff --git a/keyboards/duck/jetfire/jetfire.h b/keyboards/duck/jetfire/jetfire.h
index 9ce1406f0a..3c4834bce4 100644
--- a/keyboards/duck/jetfire/jetfire.h
+++ b/keyboards/duck/jetfire/jetfire.h
@@ -13,8 +13,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef 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 34b351a726..8de2f5ced6 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 8e05516df3..c708593293 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