summaryrefslogtreecommitdiffstats
path: root/keyboards/duck
diff options
context:
space:
mode:
authorMechMerlin <30334081+mechmerlin@users.noreply.github.com>2018-08-29 01:52:00 +0200
committerDrashna Jaelre <drashna@live.com>2018-08-29 01:52:00 +0200
commit3916b06168f39233f77a252fbf5f9cfdae3df4fe (patch)
tree672677c365c8d0455328b1ff3b0c32e434a7ab97 /keyboards/duck
parent444def8411d6ac67203c14ec92f8e33d77330895 (diff)
downloadqmk_firmware-3916b06168f39233f77a252fbf5f9cfdae3df4fe.tar.gz
qmk_firmware-3916b06168f39233f77a252fbf5f9cfdae3df4fe.tar.xz
Putting my ducks in a row: Octagon V1/V2 (#3765)
* Move octagon directory into duck diretory and fix as many compile issues as I can * fix formatting * fix layout75 matrix * edit readme for build instructions
Diffstat (limited to 'keyboards/duck')
-rw-r--r--keyboards/duck/jetfire/readme.md2
-rw-r--r--keyboards/duck/octagon/keymaps/default/keymap.c37
-rw-r--r--keyboards/duck/octagon/keymaps/default/readme.md0
-rw-r--r--keyboards/duck/octagon/readme.md11
-rw-r--r--keyboards/duck/octagon/rules.mk1
-rw-r--r--keyboards/duck/octagon/v1/config.h54
-rw-r--r--keyboards/duck/octagon/v1/info.json12
-rw-r--r--keyboards/duck/octagon/v1/matrix.c227
-rw-r--r--keyboards/duck/octagon/v1/readme.md28
-rw-r--r--keyboards/duck/octagon/v1/rules.mk72
-rw-r--r--keyboards/duck/octagon/v1/v1.c50
-rw-r--r--keyboards/duck/octagon/v1/v1.h52
-rw-r--r--keyboards/duck/octagon/v2/config.h54
-rw-r--r--keyboards/duck/octagon/v2/indicator_leds.c133
-rw-r--r--keyboards/duck/octagon/v2/indicator_leds.h11
-rw-r--r--keyboards/duck/octagon/v2/info.json12
-rw-r--r--keyboards/duck/octagon/v2/matrix.c258
-rw-r--r--keyboards/duck/octagon/v2/readme.md28
-rw-r--r--keyboards/duck/octagon/v2/rules.mk74
-rw-r--r--keyboards/duck/octagon/v2/v2.c117
-rw-r--r--keyboards/duck/octagon/v2/v2.h52
21 files changed, 1284 insertions, 1 deletions
diff --git a/keyboards/duck/jetfire/readme.md b/keyboards/duck/jetfire/readme.md
index fb5baf975..fe641e622 100644
--- a/keyboards/duck/jetfire/readme.md
+++ b/keyboards/duck/jetfire/readme.md
@@ -13,6 +13,6 @@ To get into bootloader mode, hold the top top most key above the 2 navigation ke
Make example for this keyboard (after setting up your build environment):
- make jetfire:default
+ make duck/jetfire:default
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/duck/octagon/keymaps/default/keymap.c b/keyboards/duck/octagon/keymaps/default/keymap.c
new file mode 100644
index 000000000..a2029ba05
--- /dev/null
+++ b/keyboards/duck/octagon/keymaps/default/keymap.c
@@ -0,0 +1,37 @@
+/* Copyright 2018 MechMerlin <mechmerlin@gmail.com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+#include QMK_KEYBOARD_H
+
+#define _BL 0 // Base Layer
+#define _FL 1 // Fn Layer
+
+const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
+ [_BL] = LAYOUT_75_ansi(\
+ KC_ESC, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_PSCR, KC_PAUS, KC_DEL,
+ KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC, KC_HOME,
+ KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSLS, KC_PGUP,
+ KC_CAPS, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT, KC_PGDN,
+ KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, KC_UP, KC_END,
+ KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, MO(_FL), KC_RGUI, KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT),
+
+ [_FL] = LAYOUT_75_ansi(\
+ KC_TRNS, RGB_TOG, RGB_MOD, RGB_VAI, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
+ KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
+ KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, RESET, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
+ KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
+ KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
+ KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS),
+}; \ No newline at end of file
diff --git a/keyboards/duck/octagon/keymaps/default/readme.md b/keyboards/duck/octagon/keymaps/default/readme.md
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/keyboards/duck/octagon/keymaps/default/readme.md
diff --git a/keyboards/duck/octagon/readme.md b/keyboards/duck/octagon/readme.md
new file mode 100644
index 000000000..7f5b2f7e6
--- /dev/null
+++ b/keyboards/duck/octagon/readme.md
@@ -0,0 +1,11 @@
+# Duck Octagon
+
+Non official firmware for custom Korean keyboard with 75% key layout made by Duck.
+
+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.
+
+Newest version is the [Octagon V2](http://duck0113.tistory.com/127)
+
+Make example for this keyboard (after setting up your build environment):
+
+ make duck/octagon/v2:default
diff --git a/keyboards/duck/octagon/rules.mk b/keyboards/duck/octagon/rules.mk
new file mode 100644
index 000000000..46bd457bb
--- /dev/null
+++ b/keyboards/duck/octagon/rules.mk
@@ -0,0 +1 @@
+DEFAULT_FOLDER = duck/octagon/v2 \ No newline at end of file
diff --git a/keyboards/duck/octagon/v1/config.h b/keyboards/duck/octagon/v1/config.h
new file mode 100644
index 000000000..fbbc8999b
--- /dev/null
+++ b/keyboards/duck/octagon/v1/config.h
@@ -0,0 +1,54 @@
+/*
+Copyright 2017 MechMerlin <mechmerlin@gmail.com>
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+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 CONFIG_H
+#define CONFIG_H
+
+#include "config_common.h"
+
+/* USB Device descriptor parameter */
+#define VENDOR_ID 0xFEED
+#define PRODUCT_ID 0x6050
+#define DEVICE_VER 0x0104
+#define MANUFACTURER Duck
+#define PRODUCT Octagon V1
+#define DESCRIPTION Duck Octagon V1
+
+/* key matrix size */
+#define MATRIX_ROWS 6
+#define MATRIX_COLS 16
+
+#define DIODE_DIRECTION COL2ROW
+
+/* Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not needed */
+#define DEBOUNCING_DELAY 5
+
+/* number of backlight levels */
+#define BACKLIGHT_LEVELS 1
+
+/* key combination for magic key command */
+#define IS_COMMAND() ( \
+ keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \
+)
+
+#define RGBLIGHT_ANIMATIONS
+#define RGB_DI_PIN D6
+#define RGBLED_NUM 17
+
+#define TAPPING_TERM 200
+
+#endif
diff --git a/keyboards/duck/octagon/v1/info.json b/keyboards/duck/octagon/v1/info.json
new file mode 100644
index 000000000..1feff9519
--- /dev/null
+++ b/keyboards/duck/octagon/v1/info.json
@@ -0,0 +1,12 @@
+{
+ "keyboard_name": "Octagon V1",
+ "url": "",
+ "maintainer": "qmk",
+ "width": 16,
+ "height": 6,
+ "layouts": {
+ "LAYOUT": {
+ "layout": [{"label":"Esc", "x":0, "y":0}, {"label":"F1", "x":1, "y":0}, {"label":"F2", "x":2, "y":0}, {"label":"F3", "x":3, "y":0}, {"label":"F4", "x":4, "y":0}, {"label":"F5", "x":5, "y":0}, {"label":"F6", "x":6, "y":0}, {"label":"F7", "x":7, "y":0}, {"label":"F8", "x":8, "y":0}, {"label":"F9", "x":9, "y":0}, {"label":"F10", "x":10, "y":0}, {"label":"F11", "x":11, "y":0}, {"label":"F12", "x":12, "y":0}, {"label":"PrtSc", "x":13, "y":0}, {"label":"Pause", "x":14, "y":0}, {"label":"~", "x":0, "y":1}, {"label":"!", "x":1, "y":1}, {"label":"@", "x":2, "y":1}, {"label":"#", "x":3, "y":1}, {"label":"$", "x":4, "y":1}, {"label":"%", "x":5, "y":1}, {"label":"^", "x":6, "y":1}, {"label":"&", "x":7, "y":1}, {"label":"*", "x":8, "y":1}, {"label":"(", "x":9, "y":1}, {"label":")", "x":10, "y":1}, {"label":"_", "x":11, "y":1}, {"label":"+", "x":12, "y":1}, {"label":"Backspace", "x":13, "y":1, "w":2}, {"label":"Home", "x":15, "y":1}, {"label":"Tab", "x":0, "y":2, "w":1.5}, {"label":"Q", "x":1.5, "y":2}, {"label":"W", "x":2.5, "y":2}, {"label":"E", "x":3.5, "y":2}, {"label":"R", "x":4.5, "y":2}, {"label":"T", "x":5.5, "y":2}, {"label":"Y", "x":6.5, "y":2}, {"label":"U", "x":7.5, "y":2}, {"label":"I", "x":8.5, "y":2}, {"label":"O", "x":9.5, "y":2}, {"label":"P", "x":10.5, "y":2}, {"label":"{", "x":11.5, "y":2}, {"label":"}", "x":12.5, "y":2}, {"label":"|", "x":13.5, "y":2, "w":1.5}, {"label":"Page Up", "x":15, "y":2}, {"label":"Caps Lock", "x":0, "y":3, "w":1.75}, {"label":"A", "x":1.75, "y":3}, {"label":"S", "x":2.75, "y":3}, {"label":"D", "x":3.75, "y":3}, {"label":"F", "x":4.75, "y":3}, {"label":"G", "x":5.75, "y":3}, {"label":"H", "x":6.75, "y":3}, {"label":"J", "x":7.75, "y":3}, {"label":"K", "x":8.75, "y":3}, {"label":"L", "x":9.75, "y":3}, {"label":":", "x":10.75, "y":3}, {"label":"\"", "x":11.75, "y":3}, {"x":12.75, "y":3}, {"label":"Enter", "x":13.75, "y":3, "w":1.25}, {"label":"Page Down", "x":15, "y":3}, {"label":"Shift", "x":0, "y":4, "w":2.25}, {"label":"Z", "x":2.25, "y":4}, {"label":"X", "x":3.25, "y":4}, {"label":"C", "x":4.25, "y":4}, {"label":"V", "x":5.25, "y":4}, {"label":"B", "x":6.25, "y":4}, {"label":"N", "x":7.25, "y":4}, {"label":"M", "x":8.25, "y":4}, {"label":"<", "x":9.25, "y":4}, {"label":">", "x":10.25, "y":4}, {"label":"?", "x":11.25, "y":4}, {"label":"Shift", "x":12.25, "y":4, "w":1.75}, {"label":"\u2191", "x":14, "y":4}, {"label":"End", "x":15, "y":4}, {"label":"Ctrl", "x":0, "y":5, "w":1.25}, {"label":"Win", "x":1.25, "y":5, "w":1.25}, {"label":"Alt", "x":2.5, "y":5, "w":1.25}, {"x":3.75, "y":5, "w":6.25}, {"label":"Alt", "x":10, "y":5}, {"label":"Fn", "x":11, "y":5}, {"label":"Ctrl", "x":12, "y":5}, {"label":"\u2190", "x":13, "y":5}, {"label":"\u2193", "x":14, "y":5}, {"label":"\u2192", "x":15, "y":5}]
+ }
+ }
+}
diff --git a/keyboards/duck/octagon/v1/matrix.c b/keyboards/duck/octagon/v1/matrix.c
new file mode 100644
index 000000000..855534994
--- /dev/null
+++ b/keyboards/duck/octagon/v1/matrix.c
@@ -0,0 +1,227 @@
+/*
+Copyright 2017 MechMerlin <mechmerlin@gmail.com>
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include <util/delay.h>
+#include <avr/io.h>
+#include <stdio.h>
+#include "matrix.h"
+#include "util.h"
+#include "print.h"
+#include "debug.h"
+
+static uint8_t debouncing = DEBOUNCING_DELAY;
+
+/* matrix state(1:on, 0:off) */
+static matrix_row_t matrix[MATRIX_ROWS];
+static matrix_row_t matrix_debouncing[MATRIX_ROWS];
+
+static uint8_t read_rows(uint8_t col);
+static void init_rows(void);
+static void unselect_cols(void);
+static void select_col(uint8_t col);
+
+
+__attribute__ ((weak))
+void matrix_init_kb(void) {
+ matrix_init_user();
+}
+
+__attribute__ ((weak))
+void matrix_scan_kb(void) {
+ matrix_scan_user();
+}
+
+__attribute__ ((weak))
+void matrix_init_user(void) {
+}
+
+__attribute__ ((weak))
+void matrix_scan_user(void) {
+}
+
+void backlight_init_ports(void)
+{
+ DDRB |= 0b00011111; // PB0 (caps), PB1 (alpha), PB2 (extra), PB3 (modnum), PB4 (caps)
+ DDRD |= 0b11010000; // PD4, (rgb blue), PD6 (rgb red), PD7 (rgb green)
+ DDRE |= 0b01000000; // PE6 (frow)
+}
+
+void matrix_init(void) {
+ backlight_init_ports();
+ unselect_cols();
+ init_rows();
+
+ for (uint8_t i=0; i < MATRIX_ROWS; i++) {
+ matrix[i] = 0;
+ matrix_debouncing[i] = 0;
+ }
+
+ matrix_init_quantum();
+}
+
+uint8_t matrix_scan(void) {
+ for (uint8_t col = 0; col < MATRIX_COLS; col++) {
+ select_col(col);
+ _delay_us(3);
+
+ uint8_t rows = read_rows(col);
+
+ for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
+ bool prev_bit = matrix_debouncing[row] & ((matrix_row_t)1<<col);
+ bool curr_bit = rows & (1<<row);
+ if (prev_bit != curr_bit) {
+ matrix_debouncing[row] ^= ((matrix_row_t)1<<col);
+ debouncing = DEBOUNCING_DELAY;
+ }
+ }
+ unselect_cols();
+ }
+
+ if (debouncing) {
+ if (--debouncing) {
+ _delay_ms(1);
+ } else {
+ for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
+ matrix[i] = matrix_debouncing[i];
+ }
+ }
+ }
+
+ matrix_scan_quantum();
+ return 1;
+}
+
+inline matrix_row_t matrix_get_row(uint8_t row) {
+ return matrix[row];
+}
+
+void matrix_print(void) {
+ print("\nr/c 0123456789ABCDEF\n");
+ for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
+ xprintf("%02X: %032lb\n", row, bitrev32(matrix_get_row(row)));
+ }
+}
+
+/* Row pin configuration
+ * row: 0 1 2 3 4 5
+ * pin: PB7 PD0 PD1 PD2 PD3 PD5
+ *
+ * Esc uses its own pin PE2
+ */
+static void init_rows(void) {
+ DDRD &= ~0b00101111; // PD0, PD1, PD2, PD3, PD5 input
+ PORTD &= ~0b00101111; // PD0, PD1, PD2, PD3, PD5 low
+
+ DDRB &= ~0b10000000; // PB7 input
+ PORTB &= ~0b10000000; // PB7 low
+
+ DDRE &= ~0b00000100; // PE2 input
+ PORTE |= 0b00000100; // PE2 high
+}
+
+static uint8_t read_rows(uint8_t col) {
+ if (col == 14) {
+ return PINE&(1<<2) ? 0 : (1<<0); // PE2 (Row 0)
+ } else {
+ return (PIND&(1<<0) ? (1<<0) : 0) | // PD0 (Row 0)
+ (PIND&(1<<1) ? (1<<1) : 0) | // PD1 (Row 1)
+ (PIND&(1<<2) ? (1<<2) : 0) | // PD2 (Row 2)
+ (PIND&(1<<3) ? (1<<3) : 0) | // PD3 (Row 3)
+ (PIND&(1<<5) ? (1<<4) : 0) | // PD5 (Row 4)
+ (PINB&(1<<7) ? (1<<5) : 0); // PB7 (Row 5)
+ }
+}
+
+uint8_t read_fwkey(void)
+{
+ return PINE&(1<<2) ? 0 : (1<<0);
+}
+
+static void unselect_cols(void) {
+ DDRB |= 0b01000000; // PB6 (U2) output
+ PORTB &= ~0b01000000; // PB6 (U2) low
+
+ DDRC |= 0b11000000; // PC6 (U1), PC7 (A2) output
+ PORTC &= ~0b11000000; // PC6 (U1), PC7 (A2) low
+
+ DDRF |= 0b00000011; // PF0 (A0), PF1 (A1) output
+ PORTF &= ~0b00000011; // PF0 (A0), PF1 (A1) low
+}
+
+static void select_col(uint8_t col) {
+
+ switch (col) {
+ case 0:
+ PORTC |= 0b01000000; // PC6 high
+ break;
+ case 1:
+ PORTC |= 0b01000000; // PC6 high
+ PORTF |= 0b00000001; // PF0 high
+ break;
+ case 2:
+ PORTC |= 0b01000000; // PC6 high
+ PORTF |= 0b00000010; // PF1 high
+ break;
+ case 3:
+ PORTC |= 0b01000000; // PC6 high
+ PORTF |= 0b00000011; // PF0, PF1 high
+ break;
+ case 4:
+ PORTC |= 0b11000000; // PC6, PC7 high
+ break;
+ case 5:
+ PORTC |= 0b11000000; // PC6, PC7 high
+ PORTF |= 0b00000001; // PF0 high
+ break;
+ case 6:
+ PORTC |= 0b11000000; // PC6, PC7 high
+ PORTF |= 0b00000010; // PF1 high
+ break;
+ case 7:
+ PORTC |= 0b11000000; // PC6, PC7 high
+ PORTF |= 0b00000011; // PF0, PF1 high
+ break;
+ case 8:
+ PORTB |= 0b01000000; // PB6 high
+ break;
+ case 9:
+ PORTB |= 0b01000000; // PB6 high
+ PORTF |= 0b00000001; // PF0 high
+ break;
+ case 10:
+ PORTB |= 0b01000000; // PB6 high
+ PORTF |= 0b00000010; // PF1 high
+ break;
+ case 11:
+ PORTB |= 0b01000000; // PB6 high
+ PORTF |= 0b00000011; // PF0, PF1 high
+ break;
+ case 12:
+ PORTB |= 0b01000000; // PB6 high
+ PORTC |= 0b10000000; // PC7 high
+ break;
+ case 13:
+ PORTB |= 0b01000000; // PB6 high
+ PORTF |= 0b00000001; // PF0 high
+ PORTC |= 0b10000000; // PC7 high
+ break;
+ case 15:
+ PORTB |= 0b01000000; // PB6 high
+ PORTF |= 0b00000010; // PF1 high
+ PORTC |= 0b10000000; // PC7 high
+ break;
+ }
+}
diff --git a/keyboards/duck/octagon/v1/readme.md b/keyboards/duck/octagon/v1/readme.md
new file mode 100644
index 000000000..f5cb2d789
--- /dev/null
+++ b/keyboards/duck/octagon/v1/readme.md
@@ -0,0 +1,28 @@
+# Duck Octagon V1
+
+Non official firmware for custom Korean keyboard with 75% key layout made by Duck.
+Group buy was run October 2014 via [geekhack](https://geekhack.org/index.php?topic=65036.0) 35 keyboards total.
+
+Keyboard Maintainer: [MechMerlin](https://github.com/mechmerlin)
+Hardware Supported: Duck Octagon PCB Ver 1.0, Atmega32u4
+Hardware Availability: Wait until GB of the next revision
+
+Make example for this keyboard (after setting up your build environment):
+
+ make duck/octagon/v1:default
+
+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.
+
+## Hardware Notes
+
+The Duck Octagon V1 PCB consists of:
+
+### Microchips
+2 74HC237D 3-to-8 line decoders
+1 Atmega32u4 microcontroller
+2 WS2811 LED controller
+
+## Notes
+Thanks to Ralf Schmitt for previous implementations in his [TMK fork](https://github.com/xauser/tmk_keyboard/tree/xauser/) and few helping words.
+
+Based heavily on Rasmus Schults [Duck Lightsaver QMK Port](https://github.com/qmk/qmk_firmware/tree/master/keyboards/lightsaver)
diff --git a/keyboards/duck/octagon/v1/rules.mk b/keyboards/duck/octagon/v1/rules.mk
new file mode 100644
index 000000000..a08695b50
--- /dev/null
+++ b/keyboards/duck/octagon/v1/rules.mk
@@ -0,0 +1,72 @@
+# MCU name
+MCU = atmega32u4
+
+# Processor frequency.
+# This will define a symbol, F_CPU, in all source code files equal to the
+# processor frequency in Hz. You can then use this symbol in your source code to
+# calculate timings. Do NOT tack on a 'UL' at the end, this will be done
+# automatically to create a 32-bit value in your source code.
+#
+# This will be an integer division of F_USB below, as it is sourced by
+# F_USB after it has run through any CPU prescalers. Note that this value
+# does not *change* the processor frequency - it should merely be updated to
+# reflect the processor speed set externally so that the code can use accurate
+# software delays.
+F_CPU = 16000000
+
+
+#
+# LUFA specific
+#
+# Target architecture (see library "Board Types" documentation).
+ARCH = AVR8
+
+# Input clock frequency.
+# This will define a symbol, F_USB, in all source code files equal to the
+# input clock frequency (before any prescaling is performed) in Hz. This value may
+# differ from F_CPU if prescaling is used on the latter, and is required as the
+# raw input clock is fed directly to the PLL sections of the AVR for high speed
+# clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL'
+# at the end, this will be done automatically to create a 32-bit value in your
+# source code.
+#
+# If no clock division is performed on the input clock inside the AVR (via the
+# CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU.
+F_USB = $(F_CPU)
+
+# Interrupt driven control endpoint task(+60)
+#OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT
+
+
+# Boot Section Size in *bytes*
+# Teensy halfKay 512
+# Teensy++ halfKay 1024
+# Atmel DFU loader 4096
+# LUFA bootloader 4096
+# USBaspLoader 2048
+OPT_DEFS += -DBOOTLOADER_SIZE=4096
+
+
+# Build Options
+# change yes to no to disable
+#
+BOOTMAGIC_ENABLE ?= no # Virtual DIP switch configuration(+1000)
+MOUSEKEY_ENABLE ?= no # Mouse keys(+4700)
+EXTRAKEY_ENABLE ?= no # Audio control and System control(+450)
+CONSOLE_ENABLE ?= no # Console for debug(+400)
+COMMAND_ENABLE ?= yes # Commands for debug and configuration
+# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE
+SLEEP_LED_ENABLE ?= no # Breathing sleep LED during USB suspend
+# if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work
+NKRO_ENABLE ?= yes # USB Nkey Rollover
+BACKLIGHT_ENABLE ?= yes # Enable keyboard backlight functionality on B7 by default
+MIDI_ENABLE ?= no # MIDI support (+2400 to 4200, depending on config)
+UNICODE_ENABLE ?= no # Unicode
+BLUETOOTH_ENABLE ?= no # Enable Bluetooth with the Adafruit EZ-Key HID
+AUDIO_ENABLE ?= no # Audio output on port C6
+FAUXCLICKY_ENABLE ?= no # Use buzzer to emulate clicky switches
+RGBLIGHT_ENABLE = yes
+
+CUSTOM_MATRIX = yes
+SRC += matrix.c \
+
diff --git a/keyboards/duck/octagon/v1/v1.c b/keyboards/duck/octagon/v1/v1.c
new file mode 100644
index 000000000..258688229
--- /dev/null
+++ b/keyboards/duck/octagon/v1/v1.c
@@ -0,0 +1,50 @@
+/* Copyright 2017 MechMerlin <mechmerlin@gmail.com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+#include "v1.h"
+
+enum BACKLIGHT_AREAS {
+ BACKLIGHT_ALPHA = 0b0000001,
+ BACKLIGHT_EXTRA = 0b0000010,
+ BACKLIGHT_MODNUM = 0b0000100,
+ BACKLIGHT_FROW = 0b0001000,
+ BACKLIGHT_RGB = 0b0010000,
+ BACKLIGHT_RGBRED = 0b0010000,
+ BACKLIGHT_RGBGREEN = 0b0100000,
+ BACKLIGHT_RGBBLUE = 0b1000000,
+ BACKLIGHT_SWITCH = 0b0001111
+};
+
+uint8_t backlight_os_state = 0;
+uint32_t backlight_layer_state = 0;
+
+void backlight_set(uint8_t level) {
+ level & BACKLIGHT_ALPHA ? (PORTB |= 0b00000010) : (PORTB &= ~0b00000010);
+ level & BACKLIGHT_EXTRA ? (PORTB |= 0b00000100) : (PORTB &= ~0b00000100);
+ level & BACKLIGHT_MODNUM ? (PORTB |= 0b00001000) : (PORTB &= ~0b00001000);
+ level & BACKLIGHT_FROW ? (PORTE |= 0b01000000) : (PORTE &= ~0b01000000);
+ level & BACKLIGHT_RGBRED ? (PORTD |= 0b01000000) : (PORTD &= ~0b01000000);
+ level & BACKLIGHT_RGBGREEN ? (PORTD |= 0b10000000) : (PORTD &= ~0b10000000);
+ level & BACKLIGHT_RGBBLUE ? (PORTD |= 0b00010000) : (PORTD &= ~0b00010000);
+}
+
+void led_set_kb(uint8_t usb_led) {
+ backlight_os_state & (1<<USB_LED_CAPS_LOCK) ? (PORTB &= ~0b00000001) : (PORTB |= 0b00000001);
+ backlight_os_state & (1<<USB_LED_SCROLL_LOCK) ? (PORTB &= ~0b00010000) : (PORTB |= 0b00010000);
+}
+
+bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
+ return process_record_user(keycode, record);
+}
diff --git a/keyboards/duck/octagon/v1/v1.h b/keyboards/duck/octagon/v1/v1.h
new file mode 100644
index 000000000..d89188f22
--- /dev/null
+++ b/keyboards/duck/octagon/v1/v1.h
@@ -0,0 +1,52 @@
+/* Copyright 2017 MechMerlin <mechmerlin@gmail.com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * 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 V1_H
+#define V1_H
+
+#include "quantum.h"
+
+#define LAYOUT( \
+ K5A, K5B, K5C, K5D, K5E, K5F, K5G, K5H, K5I, K5J, K5K, K5L, K5M, K5N, K5P, \
+ K4A, K4B, K4C, K4D, K4E, K4F, K4G, K4H, K4I, K4J, K4K, K4L, K4M, K4N, K4P, \
+ K3A, K3B, K3C, K3D, K3E, K3F, K3G, K3H, K3I, K3J, K3K, K3L, K3M, K3N, K3P, \
+ K2A, K2B, K2C, K2D, K2E, K2F, K2G, K2H, K2I, K2J, K2K, K2L, K5O, K2N, K2P, \
+ K1A, K1C, K1D, K1E, K1F, K1G, K1H, K1I, K1J, K1K, K1L, K1M, K1N, K1P, \
+ K0A, K0B, K0C, K0G, K0J, K0K, K0L, K0M, K0N, K0P \
+) { \
+ { K5A, K5B, K5C, K5D, K5E, K5F, K5G, K5H, K5I, K5J, K5K, K5L, K5M, K5N, K5O, K5P }, \
+ { K4A, K4B, K4C, K4D, K4E, K4F, K4G, K4H, K4I, K4J, K4K, K4L, K4M, K4N, KC_NO, K4P }, \
+ { K3A, K3B, K3C, K3D, K3E, K3F, K3G, K3H, K3I, K3J, K3K, K3L, K3M, K3N, KC_NO, K3P }, \
+ { K2A, K2B, K2C, K2D, K2E, K2F, K2G, K2H, K2I, K2J, K2K, K2L, KC_NO, K2N, KC_NO, K2P }, \
+ { 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 } \
+}
+
+#define LAYOUT_75_ansi( \
+ K5A, K5B, K5C, K5D, K5E, K5F, K5G, K5H, K5I, K5J, K5K, K5L, K5M, K5N, K5O, K5P, \
+ K4A, K4B, K4C, K4D, K4E, K4F, K4G, K4H, K4I, K4J, K4K, K4L, K4M, K4N, K4P, \
+ K3A, K3B, K3C, K3D, K3E, K3F, K3G, K3H, K3I, K3J, K3K, K3L, K3M, K3N, K3P, \
+ K2A, K2B, K2C, K2D, K2E, K2F, K2G, K2H, K2I, K2J, K2K, K2L, K2N, K2P, \
+ K1A, K1C, K1D, K1E, K1F, K1G, K1H, K1I, K1J, K1K, K1L, K1M, K1N, K1P, \
+ K0A, K0B, K0C, K0G, K0J, K0K, K0L, K0M, K0N, K0P \
+) { \
+ { K5A, K5B, K5C, K5D, K5E, K5F, K5G, K5H, K5I, K5J, K5K, K5L, K5M, K5N, K5O, K5P }, \
+ { K4A, K4B, K4C, K4D, K4E, K4F, K4G, K4H, K4I, K4J, K4K, K4L, K4M, K4N, KC_NO, K4P }, \
+ { K3A, K3B, K3C, K3D, K3E, K3F, K3G, K3H, K3I, K3J, K3K, K3L, K3M, K3N, KC_NO, K3P }, \
+ { K2A, K2B, K2C, K2D, K2E, K2F, K2G, K2H, K2I, K2J, K2K, K2L, KC_NO, K2N, KC_NO, K2P }, \
+ { 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
new file mode 100644
index 000000000..c916a30a1
--- /dev/null
+++ b/keyboards/duck/octagon/v2/config.h
@@ -0,0 +1,54 @@
+/*
+Copyright 2017 MechMerlin <mechmerlin@gmail.com>
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+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 CONFIG_H
+#define CONFIG_H
+
+#include "config_common.h"
+
+/* USB Device descriptor parameter */
+#define VENDOR_ID 0xFEED
+#define PRODUCT_ID 0x6050
+#define DEVICE_VER 0x0104
+#define MANUFACTURER Duck
+#define PRODUCT Octagon V2
+#define DESCRIPTION Duck Octagon V2
+
+/* key matrix size */
+#define MATRIX_ROWS 6
+#define MATRIX_COLS 17
+
+#define DIODE_DIRECTION COL2ROW
+
+/* Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not needed */
+#define DEBOUNCING_DELAY 5
+
+/* number of backlight levels */
+#define BACKLIGHT_LEVELS 1
+
+/* key combination for magic key command */
+#define IS_COMMAND() ( \
+ keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \
+)
+
+#define RGBLIGHT_ANIMATIONS
+#define RGB_DI_PIN D6
+#define RGBLED_NUM 17
+
+#define TAPPING_TERM 200
+
+#endif
diff --git a/keyboards/duck/octagon/v2/indicator_leds.c b/keyboards/duck/octagon/v2/indicator_leds.c
new file mode 100644
index 000000000..c24509f51
--- /dev/null
+++ b/keyboards/duck/octagon/v2/indicator_leds.c
@@ -0,0 +1,133 @@
+/*
+Copyright 2017 MechMerlin <mechmerlin@gmail.com>
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+#include <avr/interrupt.h>
+#include <avr/io.h>
+#include <stdbool.h>
+#include <util/delay.h>
+#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)
+
+void send_bit_d4(bool bitVal) {
+ if(bitVal) {
+ asm volatile (
+ "sbi %[port], %[bit] \n\t"
+ ".rept %[onCycles] \n\t"
+ "nop \n\t"
+ ".endr \n\t"
+ "cbi %[port], %[bit] \n\t"
+ ".rept %[offCycles] \n\t"
+ "nop \n\t"
+ ".endr \n\t"
+ ::
+ [port] "I" (_SFR_IO_ADDR(PORTD)),
+ [bit] "I" (4),
+ [onCycles] "I" (NS_TO_CYCLES(T1H) - 2),
+ [offCycles] "I" (NS_TO_CYCLES(T1L) - 2));
+ } else {
+ asm volatile (
+ "sbi %[port], %[bit] \n\t"
+ ".rept %[onCycles] \n\t"
+ "nop \n\t"
+ ".endr \n\t"
+ "cbi %[port], %[bit] \n\t"
+ ".rept %[offCycles] \n\t"
+ "nop \n\t"
+ ".endr \n\t"
+ ::
+ [port] "I" (_SFR_IO_ADDR(PORTD)),
+ [bit] "I" (4),
+ [onCycles] "I" (NS_TO_CYCLES(T0H) - 2),
+ [offCycles] "I" (NS_TO_CYCLES(T0L) - 2));
+ }
+}
+
+void send_bit_d6(bool bitVal)
+{
+ if(bitVal) {
+ asm volatile (
+ "sbi %[port], %[bit] \n\t"
+ ".rept %[onCycles] \n\t"
+ "nop \n\t"
+ ".endr \n\t"
+ "cbi %[port], %[bit] \n\t"
+ ".rept %[offCycles] \n\t"
+ "nop \n\t"
+ ".endr \n\t"
+ ::
+ [port] "I" (_SFR_IO_ADDR(PORTD)),
+ [bit] "I" (6),
+ [onCycles] "I" (NS_TO_CYCLES(T1H) - 2),
+ [offCycles] "I" (NS_TO_CYCLES(T1L) - 2));
+ } else {
+ asm volatile (
+ "sbi %[port], %[bit] \n\t"
+ ".rept %[onCycles] \n\t"
+ "nop \n\t"
+ ".endr \n\t"
+ "cbi %[port], %[bit] \n\t"
+ ".rept %[offCycles] \n\t"
+ "nop \n\t"
+ ".endr \n\t"
+ ::
+ [port] "I" (_SFR_IO_ADDR(PORTD)),
+ [bit] "I" (6),
+ [onCycles] "I" (NS_TO_CYCLES(T0H) - 2),
+ [offCycles] "I" (NS_TO_CYCLES(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) {
+ send_bit_d4(byte & 0b10000000);
+ }
+ if(device == Device_PCBRGB) {
+ send_bit_d6(byte & 0b10000000);
+ }
+ byte <<= 1;
+ }
+}
+
+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(b, device);
+}
+
+// Port from backlight_set_state
+void indicator_leds_set(bool leds[8]) {
+ cli();
+ send_color(leds[1] ? 255 : 0, leds[2] ? 255 : 0, leds[0] ? 255 : 0, Device_STATUSLED);
+ send_color(leds[4] ? 255 : 0, leds[3] ? 255 : 0, leds[5] ? 255 : 0, Device_STATUSLED);
+ leds[6] ? (PORTD &= ~0b10000000) : (PORTD |= 0b10000000);
+ sei();
+ show();
+}
diff --git a/keyboards/duck/octagon/v2/indicator_leds.h b/keyboards/duck/octagon/v2/indicator_leds.h
new file mode 100644
index 000000000..9bb2c8ced
--- /dev/null
+++ b/keyboards/duck/octagon/v2/indicator_leds.h
@@ -0,0 +1,11 @@
+enum Device {
+ Device_PCBRGB,
+ Device_STATUSLED
+};
+
+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/info.json b/keyboards/duck/octagon/v2/info.json
new file mode 100644
index 000000000..7bc0c6ef9
--- /dev/null
+++ b/keyboards/duck/octagon/v2/info.json
@@ -0,0 +1,12 @@
+{
+ "keyboard_name": "Octagon V2",
+ "url": "",
+ "maintainer": "qmk",
+ "width": 16,
+ "height": 6,
+ "layouts": {
+ "LAYOUT": {
+ "layout": [{"label":"Esc", "x":0, "y":0}, {"label":"F1", "x":1, "y":0}, {"label":"F2", "x":2, "y":0}, {"label":"F3", "x":3, "y":0}, {"label":"F4", "x":4, "y":0}, {"label":"F5", "x":5, "y":0}, {"label":"F6", "x":6, "y":0}, {"label":"F7", "x":7, "y":0}, {"label":"F8", "x":8, "y":0}, {"label":"F9", "x":9, "y":0}, {"label":"F10", "x":10, "y":0}, {"label":"F11", "x":11, "y":0}, {"label":"F12", "x":12, "y":0}, {"label":"PrtSc", "x":13, "y":0}, {"label":"Pause", "x":14, "y":0}, {"label":"Delete", "x":15, "y":0}, {"label":"~", "x":0, "y":1}, {"label":"!", "x":1, "y":1}, {"label":"@", "x":2, "y":1}, {"label":"#", "x":3, "y":1}, {"label":"$", "x":4, "y":1}, {"label":"%", "x":5, "y":1}, {"label":"^", "x":6, "y":1}, {"label":"&", "x":7, "y":1}, {"label":"*", "x":8, "y":1}, {"label":"(", "x":9, "y":1}, {"label":")", "x":10, "y":1}, {"label":"_", "x":11, "y":1}, {"label":"+", "x":12, "y":1}, {"label":"Backspace", "x":13, "y":1, "w":2}, {"label":"Home", "x":15, "y":1}, {"label":"Tab", "x":0, "y":2, "w":1.5}, {"label":"Q", "x":1.5, "y":2}, {"label":"W", "x":2.5, "y":2}, {"label":"E", "x":3.5, "y":2}, {"label":"R", "x":4.5, "y":2}, {"label":"T", "x":5.5, "y":2}, {"label":"Y", "x":6.5, "y":2}, {"label":"U", "x":7.5, "y":2}, {"label":"I", "x":8.5, "y":2}, {"label":"O", "x":9.5, "y":2}, {"label":"P", "x":10.5, "y":2}, {"label":"{", "x":11.5, "y":2}, {"label":"}", "x":12.5, "y":2}, {"label":"|", "x":13.5, "y":2, "w":1.5}, {"label":"Page Up", "x":15, "y":2}, {"label":"Caps Lock", "x":0, "y":3, "w":1.75}, {"label":"A", "x":1.75, "y":3}, {"label":"S", "x":2.75, "y":3}, {"label":"D", "x":3.75, "y":3}, {"label":"F", "x":4.75, "y":3}, {"label":"G", "x":5.75, "y":3}, {"label":"H", "x":6.75, "y":3}, {"label":"J", "x":7.75, "y":3}, {"label":"K", "x":8.75, "y":3}, {"label":"L", "x":9.75, "y":3}, {"label":":", "x":10.75, "y":3}, {"label":"\"", "x":11.75, "y":3}, {"x":12.75, "y":3}, {"label":"Enter", "x":13.75, "y":3, "w":1.25}, {"label":"Page Down", "x":15, "y":3}, {"label":"Shift", "x":0, "y":4, "w":1.25}, {"x":1.25, "y":4}, {"label":"Z", "x":2.25, "y":4}, {"label":"X", "x":3.25, "y":4}, {"label":"C", "x":4.25, "y":4}, {"label":"V", "x":5.25, "y":4}, {"label":"B", "x":6.25, "y":4}, {"label":"N", "x":7.25, "y":4}, {"label":"M", "x":8.25, "y":4}, {"label":"<", "x":9.25, "y":4}, {"label":">", "x":10.25, "y":4}, {"label":"?", "x":11.25, "y":4}, {"label":"Shift", "x":12.25, "y":4, "w":1.75}, {"label":"\u2191", "x":14, "y":4}, {"label":"End", "x":15, "y":4}, {"label":"Ctrl", "x":0, "y":5, "w":1.25}, {"label":"Win", "x":1.25, "y":5, "w":1.25}, {"label":"Alt", "x":2.5, "y":5, "w":1.25}, {"x":3.75, "y":5, "w":6.25}, {"label":"Alt", "x":10, "y":5}, {"label":"Fn", "x":11, "y":5}, {"label":"Ctrl", "x":12, "y":5}, {"label":"\u2190", "x":13, "y":5}, {"label":"\u2193", "x":14, "y":5}, {"label":"\u2192", "x":15, "y":5}]
+ }
+ }
+}
diff --git a/keyboards/duck/octagon/v2/matrix.c b/keyboards/duck/octagon/v2/matrix.c
new file mode 100644
index 000000000..a63a37640
--- /dev/null
+++ b/keyboards/duck/octagon/v2/matrix.c
@@ -0,0 +1,258 @@
+/*
+Copyright 2017 MechMerlin <mechmerlin@gmail.com>
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include <util/delay.h>
+#include <avr/io.h>
+#include <stdio.h>
+#include "matrix.h"
+#include "util.h"
+#include "print.h"
+#include "debug.h"
+
+static uint8_t debouncing = DEBOUNCING_DELAY;
+
+/* matrix state(1:on, 0:off) */
+static matrix_row_t matrix[MATRIX_ROWS];
+static matrix_row_t matrix_debouncing[MATRIX_ROWS];
+
+static uint8_t read_rows(uint8_t col);
+static void init_rows(void);
+static void unselect_cols(void);
+static void select_col(uint8_t col);
+
+
+__attribute__ ((weak))
+void matrix_init_kb(void) {
+ matrix_init_user();
+}
+
+__attribute__ ((weak))
+void matrix_scan_kb(void) {
+ matrix_scan_user();
+}
+
+__attribute__ ((weak))
+void matrix_init_user(void) {
+}
+
+__attribute__ ((weak))
+void matrix_scan_user(void) {
+}
+
+void backlight_init_ports(void)
+{
+ DDRD |= 0b11010000;
+ PORTD &= ~0b01010000;
+ PORTD |= 0b10000000;
+ DDRB |= 0b00011111;
+ PORTB &= ~0b00001110;
+ PORTB |= 0b00010001;
+ DDRE |= 0b01000000;
+ PORTE &= ~0b01000000;
+}
+
+void matrix_init(void) {
+ backlight_init_ports();
+ unselect_cols();
+ init_rows();
+
+ for (uint8_t i=0; i < MATRIX_ROWS; i++) {
+ matrix[i] = 0;
+ matrix_debouncing[i] = 0;
+ }
+
+ matrix_init_quantum();
+}
+
+uint8_t matrix_scan(void) {
+ for (uint8_t col = 0; col < MATRIX_COLS; col++) {
+ select_col(col);
+ _delay_us(3);
+
+ uint8_t rows = read_rows(col);
+
+ for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
+ bool prev_bit = matrix_debouncing[row] & ((matrix_row_t)1<<col);
+ bool curr_bit = rows & (1<<row);
+ if (prev_bit != curr_bit) {
+ matrix_debouncing[row] ^= ((matrix_row_t)1<<col);
+ debouncing = DEBOUNCING_DELAY;
+ }
+ }
+ unselect_cols();
+ }
+
+ if (debouncing) {
+ if (--debouncing) {
+ _delay_ms(1);
+ } else {
+ for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
+ matrix[i] = matrix_debouncing[i];
+ }
+ }
+ }
+
+ matrix_scan_quantum();
+ return 1;
+}
+
+inline matrix_row_t matrix_get_row(uint8_t row) {
+ return matrix[row];
+}
+
+void matrix_print(void) {
+ print("\nr/c 0123456789ABCDEF\n");
+ for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
+ xprintf("%02X: %032lb\n", row, bitrev32(matrix_get_row(row)));
+ }
+}
+
+/* Row pin configuration
+ * row: 0 1 2 3 4 5
+ * pin: PB7 PD0 PD1 PD2 PD3 PD5
+ *
+ * Esc uses its own pin PE2
+ */
+static void init_rows(void) {
+ DDRD &= ~0b00101111;
+ PORTD &= ~0b00101111;
+
+ DDRB &= ~0b10000000;
+ PORTB &= ~0b10000000;
+
+ DDRE &= ~0b00000100;
+ PORTE |= 0b00000100;
+}
+
+static uint8_t read_rows(uint8_t col) {
+ if (col == 16) {
+ return PINE&(1<<2) ? 0 : (1<<0);
+ } else {
+ return (PIND&(1<<0) ? (1<<0) : 0) |
+ (PIND&(1<<1) ? (1<<1) : 0) |
+ (PIND&(1<<2) ? (1<<2) : 0) |
+ (PIND&(1<<3) ? (1<<3) : 0) |
+ (PIND&(1<<5) ? (1<<4) : 0) |
+ (PINB&(1<<7) ? (1<<5) : 0);
+ }
+}
+
+uint8_t read_fwkey(void)
+{
+ return PINE&(1<<2) ? 0 : (1<<0);
+}
+
+/* Columns 0 - 15
+ * These columns uses two 74HC237D 3 to 8 bit demultiplexers.
+ * col / pin: PC6 PB6 PF0 PF1 PC7
+ * 0: 1 0 0 0 0
+ * 1: 1 0 1 0 0
+ * 2: 1 0 0 1 0
+ * 3: 1 0 1 1 0
+ * 4: 1 0 0 0 1
+ * 5: 1 0 1 0 1
+ * 6: 1 0 0 1 1
+ * 7: 1 0 1 1 1
+ * 8: 0 1 0 0 0
+ * 9: 0 1 1 0 0
+ * 10: 0 1 0 1 0
+ * 11: 0 1 1 1 0
+ * 12: 0 1 0 0 1
+ * 13: 0 1 1 0 1
+ * 14: 0 1 0 1 1
+ * 15: 0 1 1 1 1
+ *
+ */
+static void unselect_cols(void) {
+ DDRB |= 0b01000000;
+ PORTB &= ~0b01000000;
+
+ DDRC |= 0b11000000;
+ PORTC &= ~0b11000000;
+
+ DDRF |= 0b00000011;
+ PORTF &= ~0b00000011;
+}
+
+static void select_col(uint8_t col) {
+
+ switch (col) {
+ case 0:
+ PORTC |= 0b01000000;
+ break;
+ case 1:
+ PORTC |= 0b01000000;
+ PORTF |= 0b00000001;
+ break;
+ case 2:
+ PORTC |= 0b01000000;
+ PORTF |= 0b00000010;
+ break;
+ case 3:
+ PORTC |= 0b01000000;
+ PORTF |= 0b00000011;
+ break;
+ case 4:
+ PORTC |= 0b11000000;
+ break;
+ case 5:
+ PORTC |= 0b11000000;
+ PORTF |= 0b00000001;
+ break;
+ case 6:
+ PORTC |= 0b11000000;
+ PORTF |= 0b00000010;
+ break;
+ case 7:
+ PORTC |= 0b11000000;
+ PORTF |= 0b00000011;
+ break;
+ case 8:
+ PORTB |= 0b01000000;
+ break;
+ case 9:
+ PORTB |= 0b01000000;
+ PORTF |= 0b00000001;
+ break;
+ case 10:
+ PORTB |= 0b01000000;
+ PORTF |= 0b00000010;
+ break;
+ case 11:
+ PORTB |= 0b01000000;
+ PORTF |= 0b00000011;
+ break;
+ case 12:
+ PORTB |= 0b01000000;
+ PORTC |= 0b10000000;
+ break;
+ case 13:
+ PORTB |= 0b01000000;
+ PORTF |= 0b00000001;
+ PORTC |= 0b10000000;
+ break;
+ case 14:
+ PORTB |= 0b01000000;
+ PORTF |= 0b00000010;
+ PORTC |= 0b10000000;
+ break;
+ case 15:
+ PORTB |= 0b01000000;
+ PORTF |= 0b00000011;
+ PORTC |= 0b10000000;
+ break;
+ }
+}
diff --git a/keyboards/duck/octagon/v2/readme.md b/keyboards/duck/octagon/v2/readme.md
new file mode 100644
index 000000000..125f09f9c
--- /dev/null
+++ b/keyboards/duck/octagon/v2/readme.md
@@ -0,0 +1,28 @@
+# Duck Octagon V2
+
+Non official firmware for custom Korean keyboard with 75% key layout made by Duck.
+Group buy was run January 2016 via [geekhack](https://geekhack.org/index.php?topic=78549.0) with 2 rounds, 100 keyboards total.
+
+Keyboard Maintainer: [MechMerlin](https://github.com/mechmerlin)
+Hardware Supported: Duck Octagon PCB Ver 2.0, Atmega32u4
+Hardware Availability: Wait until GB of the next revision
+
+Make example for this keyboard (after setting up your build environment):
+
+ make octagon/v2:default
+
+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.
+
+## Hardware Notes
+
+The Duck Octagon V2 PCB consists of:
+
+### Microchips
+2 74HC237D 3-to-8 line decoders
+1 Atmega32u4 microcontroller
+2 WS2811 LED controller
+
+## Notes
+Thanks to Ralf Schmitt for previous implementations in his [TMK fork](https://github.com/xauser/tmk_keyboard/tree/xauser/) and few helping words.
+
+Based heavily on Rasmus Schults [Duck Lightsaver QMK Port](https://github.com/qmk/qmk_firmware/tree/master/keyboards/lightsaver)
diff --git a/keyboards/duck/octagon/v2/rules.mk b/keyboards/duck/octagon/v2/rules.mk
new file mode 100644
index 000000000..37f3938d9
--- /dev/null
+++ b/keyboards/duck/octagon/v2/rules.mk
@@ -0,0 +1,74 @@
+# MCU name
+MCU = atmega32u4
+
+# Processor frequency.
+# This will define a symbol, F_CPU, in all source code files equal to the
+# processor frequency in Hz. You can then use this symbol in your source code to
+# calculate timings. Do NOT tack on a 'UL' at the end, this will be done
+# automatically to create a 32-bit value in your source code.
+#
+# This will be an integer division of F_USB below, as it is sourced by
+# F_USB after it has run through any CPU prescalers. Note that this value
+# does not *change* the processor frequency - it should merely be updated to
+# reflect the processor speed set externally so that the code can use accurate
+# software delays.
+F_CPU = 16000000
+
+
+#
+# LUFA specific
+#
+# Target architecture (see library "Board Types" documentation).
+ARCH = AVR8
+
+# Input clock frequency.
+# This will define a symbol, F_USB, in all source code files equal to the
+# input clock frequency (before any prescaling is performed) in Hz. This value may
+# differ from F_CPU if prescaling is used on the latter, and is required as the
+# raw input clock is fed directly to the PLL sections of the AVR for high speed
+# clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL'
+# at the end, this will be done automatically to create a 32-bit value in your
+# source code.
+#
+# If no clock division is performed on the input clock inside the AVR (via the
+# CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU.
+F_USB = $(F_CPU)
+
+# Interrupt driven control endpoint task(+60)
+#OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT
+
+
+# Boot Section Size in *bytes*
+# Teensy halfKay 512
+# Teensy++ halfKay 1024
+# Atmel DFU loader 4096
+# LUFA bootloader 4096
+# USBaspLoader 2048
+OPT_DEFS += -DBOOTLOADER_SIZE=4096
+
+
+# Build Options
+# change yes to no to disable
+#
+BOOTMAGIC_ENABLE ?= no # Virtual DIP switch configuration(+1000)
+MOUSEKEY_ENABLE ?= no # Mouse keys(+4700)
+EXTRAKEY_ENABLE ?= no # Audio control and System control(+450)
+CONSOLE_ENABLE ?= no # Console for debug(+400)
+COMMAND_ENABLE ?= yes # Commands for debug and configuration
+# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE
+SLEEP_LED_ENABLE ?= no # Breathing sleep LED during USB suspend
+# if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work
+NKRO_ENABLE ?= yes # USB Nkey Rollover
+BACKLIGHT_ENABLE ?= yes # Enable keyboard backlight functionality on B7 by default
+MIDI_ENABLE ?= no # MIDI support (+2400 to 4200, depending on config)
+UNICODE_ENABLE ?= no # Unicode
+BLUETOOTH_ENABLE ?= no # Enable Bluetooth with the Adafruit EZ-Key HID
+AUDIO_ENABLE ?= no # Audio output on port C6
+FAUXCLICKY_ENABLE ?= no # Use buzzer to emulate clicky switches
+RGBLIGHT_ENABLE = yes
+
+CUSTOM_MATRIX = yes
+SRC += indicator_leds.c \
+ matrix.c
+
+LAYOUTS = 75_ansi
diff --git a/keyboards/duck/octagon/v2/v2.c b/keyboards/duck/octagon/v2/v2.c
new file mode 100644
index 000000000..52653b37e
--- /dev/null
+++ b/keyboards/duck/octagon/v2/v2.c
@@ -0,0 +1,117 @@
+/* Copyright 2017 MechMerlin <mechmerlin@gmail.com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+#include "v2.h"
+#include "indicator_leds.h"
+
+enum BACKLIGHT_AREAS {
+ BACKLIGHT_ALPHA = 0b0000001,
+ BACKLIGHT_EXTRA = 0b0000010,
+ BACKLIGHT_MODNUM = 0b0000100,
+ BACKLIGHT_FROW = 0b0001000,
+ BACKLIGHT_RGB = 0b0010000,
+ BACKLIGHT_SWITCH = 0b0001111
+};
+
+uint8_t backlight_rgb_r = 255;
+uint8_t backlight_rgb_g = 0;
+uint8_t backlight_rgb_b = 0;
+uint8_t backlight_os_state = 0;
+uint32_t backlight_layer_state = 0;
+
+void backlight_toggle_rgb(bool enabled)
+{
+ if(enabled) {
+ uint8_t rgb[17][3] = {
+ {backlight_rgb_r, backlight_rgb_g, backlight_rgb_b},
+ {backlight_rgb_r, backlight_rgb_g, backlight_rgb_b},
+ {backlight_rgb_r, backlight_rgb_g, backlight_rgb_b},
+ {backlight_rgb_r, backlight_rgb_g, backlight_rgb_b},
+ {backlight_rgb_r, backlight_rgb_g, backlight_rgb_b},
+ {backlight_rgb_r, backlight_rgb_g, backlight_rgb_b},
+ {backlight_rgb_r, backlight_rgb_g, backlight_rgb_b},
+ {backlight_rgb_r, backlight_rgb_g, backlight_rgb_b},
+ {backlight_rgb_r, backlight_rgb_g, backlight_rgb_b},
+ {backlight_rgb_r, backlight_rgb_g, backlight_rgb_b},
+ {backlight_rgb_r, backlight_rgb_g, backlight_rgb_b},
+ {backlight_rgb_r, backlight_rgb_g, backlight_rgb_b},
+ {backlight_rgb_r, backlight_rgb_g, backlight_rgb_b},
+ {backlight_rgb_r, backlight_rgb_g, backlight_rgb_b},
+ {backlight_rgb_r, backlight_rgb_g, backlight_rgb_b},
+ {backlight_rgb_r, backlight_rgb_g, backlight_rgb_b},
+ {backlight_rgb_r, backlight_rgb_g, backlight_rgb_b}
+ };
+ backlight_set_rgb(rgb);
+ } else {
+ uint8_t rgb[17][3] = {
+ {0, 0, 0},
+ {0, 0, 0},
+ {0, 0, 0},
+ {0, 0, 0},
+ {0, 0, 0},
+ {0, 0, 0},
+ {0, 0, 0},
+ {0, 0, 0},
+ {0, 0, 0},
+ {0, 0, 0},
+ {0, 0, 0},
+ {0, 0, 0},
+ {0, 0, 0},
+ {0, 0, 0},
+ {0, 0, 0},
+ {0, 0, 0},
+ {0, 0, 0}
+ };
+ backlight_set_rgb(rgb);
+ }
+}
+
+void backlight_set_rgb(uint8_t cfg[17][3])
+{
+ cli();
+ for(uint8_t i = 0; i < 17; ++i) {
+ send_color(cfg[i][0], cfg[i][1], cfg[i][2], Device_PCBRGB);
+ }
+ sei();
+ show();
+}
+
+void backlight_set(uint8_t level) {
+ level & BACKLIGHT_ALPHA ? (PORTB |= 0b00000010) : (PORTB &= ~0b00000010);
+ level & BACKLIGHT_EXTRA ? (PORTB |= 0b00000100) : (PORTB &= ~0b00000100);
+ level & BACKLIGHT_MODNUM ? (PORTB |= 0b00001000) : (PORTB &= ~0b00001000);
+ level & BACKLIGHT_FROW ? (PORTE |= 0b01000000) : (PORTE &= ~0b01000000);
+ level & BACKLIGHT_RGB ? backlight_toggle_rgb(true) : backlight_toggle_rgb(false);
+}
+
+// Port from backlight_update_state
+void led_set_kb(uint8_t usb_led) {
+ bool status[7] = {
+ backlight_os_state & (1<<USB_LED_CAPS_LOCK),
+ backlight_os_state & (1<<USB_LED_SCROLL_LOCK),
+ backlight_os_state & (1<<USB_LED_NUM_LOCK),
+ backlight_layer_state & (1<<1),
+ backlight_layer_state & (1<<2),
+ backlight_layer_state & (1<<3),
+ backlight_layer_state & (1<<4)
+ };
+ indicator_leds_set(status);
+ backlight_os_state & (1<<USB_LED_CAPS_LOCK) ? (PORTB &= ~0b00000001) : (PORTB |= 0b00000001);
+ backlight_os_state & (1<<USB_LED_SCROLL_LOCK) ? (PORTB &= ~0b00010000) : (PORTB |= 0b00010000);
+}
+
+bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
+ return process_record_user(keycode, record);
+}
diff --git a/keyboards/duck/octagon/v2/v2.h b/keyboards/duck/octagon/v2/v2.h
new file mode 100644
index 000000000..1487b3640
--- /dev/null
+++ b/keyboards/duck/octagon/v2/v2.h
@@ -0,0 +1,52 @@
+/* Copyright 2017 MechMerlin <mechmerlin@gmail.com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * 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 V2_H
+#define V2_H
+
+#include "quantum.h"
+
+#define LAYOUT( \
+ K5A, K5B, K5C, K5D, K5E, K5F, K5G, K5H, K5I, K5J, K5K, K5L, K5M, K5N, K5O, K5Q, \
+ K4A, K4B, K4C, K4D, K4E, K4F, K4G, K4H, K4I, K4J, K4K, K4L, K4M, K4O, K4P, \
+ K3A, K3B, K3C, K3D, K3E, K3F, K3G, K3H, K3I, K3J, K3K, K3L, K3M, K3O, K3P, \
+ K2A, K2B, K2C, K2D, K2E, K2F, K2G, K2H, K2I, K2J, K2K, K2L, K2M, K2O, K2P, \
+ K1A, K1B, K1C, K1D, K1E, K1F, K1G, K1H, K1I, K1J, K1K, K1M, K1N, K1O, K1P, \
+ K0A, K0B, K0C, K0J, K0K, K0L, K0M, K0N, K0O, K0P \
+) { \
+ { K5A, K5B, K5C, K5D, K5E, K5F, K5G, K5H, K5I, K5J, K5K, K5L, K5M, K5N, K5O, KC_NO, K5Q }, \
+ { K4A, K4B, K4C, K4D, K4E, K4F, K4G, K4H, K4I, K4J, K4K, K4L, K4M, KC_NO, K4O, K4P, KC_NO }, \
+ { K3A, K3B, K3C, K3D, K3E, K3F, K3G, K3H, K3I, K3J, K3K, K3L, K3M, KC_NO, K3O, K3P, KC_NO }, \
+ { K2A, K2B, K2C, K2D, K2E, K2F, K2G, K2H, K2I, K2J, K2K, K2L, K2M, KC_NO, K2O, K2P, KC_NO }, \
+ { K1A, K1B, 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 } \
+}
+
+#define LAYOUT_75_ansi( \
+ K5A, K5B, K5C, K5D, K5E, K5F, K5G, K5H, K5I, K5J, K5K, K5L, K5M, K5N, K5O, K5Q, \
+ K4A, K4B, K4C, K4D, K4E, K4F, K4G, K4H, K4I, K4J, K4K, K4L, K4M, K4O, K4P, \
+ K3A, K3B, K3C, K3D, K3E, K3F, K3G, K3H, K3I, K3J, K3K, K3L, K3M, K3O, K3P, \
+ K2A, K2B, K2C, K2D, K2E, K2F, K2G, K2H, K2I, K2J, K2K, K2L, K2O, K2P, \
+ K1A, K1C, K1D, K1E, K1F, K1G, K1H, K1I, K1J, K1K, K1M, K1N, K1O, K1P, \
+ K0A, K0B, K0C, K0J, K0K, K0L, K0M, K0N, K0O, K0P \
+) { \
+ { K5A, K5B, K5C, K5D, K5E, K5F, K5G, K5H, K5I, K5J, K5K, K5L, K5M, K5N, K5O, KC_NO, K5Q }, \
+ { K4A, K4B, K4C, K4D, K4E, K4F, K4G, K4H, K4I, K4J, K4K, K4L, K4M, KC_NO, K4O, K4P, KC_NO }, \
+ { K3A, K3B, K3C, K3D, K3E, K3F, K3G, K3H, K3I, K3J, K3K, K3L, K3M, KC_NO, K3O, K3P, KC_NO }, \
+ { K2A, K2B, K2C, K2D, K2E, K2F, K2G, K2H, K2I, K2J, K2K, K2L, KC_NO, KC_NO, K2O, K2P, KC_NO }, \
+ { 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