aboutsummaryrefslogtreecommitdiff
path: root/keyboards/duck/octagon/v2
diff options
context:
space:
mode:
Diffstat (limited to 'keyboards/duck/octagon/v2')
-rw-r--r--keyboards/duck/octagon/v2/config.h49
-rw-r--r--keyboards/duck/octagon/v2/indicator_leds.c123
-rw-r--r--keyboards/duck/octagon/v2/indicator_leds.h7
-rw-r--r--keyboards/duck/octagon/v2/info.json14
-rw-r--r--keyboards/duck/octagon/v2/matrix.c261
-rw-r--r--keyboards/duck/octagon/v2/readme.md30
-rw-r--r--keyboards/duck/octagon/v2/rules.mk25
-rw-r--r--keyboards/duck/octagon/v2/v2.c113
-rw-r--r--keyboards/duck/octagon/v2/v2.h50
9 files changed, 672 insertions, 0 deletions
diff --git a/keyboards/duck/octagon/v2/config.h b/keyboards/duck/octagon/v2/config.h
new file mode 100644
index 000000000..0de966c60
--- /dev/null
+++ b/keyboards/duck/octagon/v2/config.h
@@ -0,0 +1,49 @@
1/*
2Copyright 2017 MechMerlin <[email protected]>
3
4This program is free software: you can redistribute it and/or modify
5it under the terms of the GNU General Public License as published by
6the Free Software Foundation, either version 2 of the License, or
7(at your option) any later version.
8
9This program is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12GNU General Public License for more details.
13
14You should have received a copy of the GNU General Public License
15along with this program. If not, see <http://www.gnu.org/licenses/>.
16*/
17
18#pragma once
19
20#include "config_common.h"
21
22/* USB Device descriptor parameter */
23#define VENDOR_ID 0x444B // Duck ("DK")
24#define PRODUCT_ID 0x4F32 // Octagon V2 ("O2")
25#define DEVICE_VER 0x0002
26#define MANUFACTURER Duck
27#define PRODUCT Octagon V2
28
29/* key matrix size */
30#define MATRIX_ROWS 6
31#define MATRIX_COLS 17
32
33#define DIODE_DIRECTION COL2ROW
34
35/* Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not needed */
36#define DEBOUNCE 5
37
38/* number of backlight levels */
39#define BACKLIGHT_LEVELS 1
40
41#define RGBLIGHT_ANIMATIONS
42#define RGB_DI_PIN D6
43#define RGBLED_NUM 17
44
45/* Set to top left most key */
46#define BOOTMAGIC_LITE_ROW 5
47#define BOOTMAGIC_LITE_COLUMN 10
48
49#define TAPPING_TERM 200
diff --git a/keyboards/duck/octagon/v2/indicator_leds.c b/keyboards/duck/octagon/v2/indicator_leds.c
new file mode 100644
index 000000000..116306fb7
--- /dev/null
+++ b/keyboards/duck/octagon/v2/indicator_leds.c
@@ -0,0 +1,123 @@
1/*
2Copyright 2017 MechMerlin <[email protected]>
3
4This program is free software: you can redistribute it and/or modify
5it under the terms of the GNU General Public License as published by
6the Free Software Foundation, either version 2 of the License, or
7(at your option) any later version.
8
9This program is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12GNU General Public License for more details.
13
14You should have received a copy of the GNU General Public License
15along with this program. If not, see <http://www.gnu.org/licenses/>.
16*/
17#include <avr/interrupt.h>
18#include <avr/io.h>
19#include <stdbool.h>
20#include <util/delay.h>
21#include "indicator_leds.h"
22
23#define LED_T1H 900
24#define LED_T1L 600
25#define LED_T0H 400
26#define LED_T0L 900
27
28void send_bit_d4(bool bitVal) {
29 if(bitVal) {
30 asm volatile (
31 "sbi %[port], %[bit] \n\t"
32 ".rept %[onCycles] \n\t"
33 "nop \n\t"
34 ".endr \n\t"
35 "cbi %[port], %[bit] \n\t"
36 ".rept %[offCycles] \n\t"
37 "nop \n\t"
38 ".endr \n\t"
39 ::
40 [port] "I" (_SFR_IO_ADDR(PORTD)),
41 [bit] "I" (4),
42 [onCycles] "I" (NS_TO_CYCLES(LED_T1H) - 2),
43 [offCycles] "I" (NS_TO_CYCLES(LED_T1L) - 2));
44 } else {
45 asm volatile (
46 "sbi %[port], %[bit] \n\t"
47 ".rept %[onCycles] \n\t"
48 "nop \n\t"
49 ".endr \n\t"
50 "cbi %[port], %[bit] \n\t"
51 ".rept %[offCycles] \n\t"
52 "nop \n\t"
53 ".endr \n\t"
54 ::
55 [port] "I" (_SFR_IO_ADDR(PORTD)),
56 [bit] "I" (4),
57 [onCycles] "I" (NS_TO_CYCLES(LED_T0H) - 2),
58 [offCycles] "I" (NS_TO_CYCLES(LED_T0L) - 2));
59 }
60}
61
62void send_bit_d6(bool bitVal)
63{
64 if(bitVal) {
65 asm volatile (
66 "sbi %[port], %[bit] \n\t"
67 ".rept %[onCycles] \n\t"
68 "nop \n\t"
69 ".endr \n\t"
70 "cbi %[port], %[bit] \n\t"
71 ".rept %[offCycles] \n\t"
72 "nop \n\t"
73 ".endr \n\t"
74 ::
75 [port] "I" (_SFR_IO_ADDR(PORTD)),
76 [bit] "I" (6),
77 [onCycles] "I" (NS_TO_CYCLES(LED_T1H) - 2),
78 [offCycles] "I" (NS_TO_CYCLES(LED_T1L) - 2));
79 } else {
80 asm volatile (
81 "sbi %[port], %[bit] \n\t"
82 ".rept %[onCycles] \n\t"
83 "nop \n\t"
84 ".endr \n\t"
85 "cbi %[port], %[bit] \n\t"
86 ".rept %[offCycles] \n\t"
87 "nop \n\t"
88 ".endr \n\t"
89 ::
90 [port] "I" (_SFR_IO_ADDR(PORTD)),
91 [bit] "I" (6),
92 [onCycles] "I" (NS_TO_CYCLES(LED_T0H) - 2),
93 [offCycles] "I" (NS_TO_CYCLES(LED_T0L) - 2));
94 }
95}
96
97void send_value(uint8_t byte, enum Device device) {
98 for(uint8_t b = 0; b < 8; b++) {
99 if(device == Device_STATUSLED) {
100 send_bit_d4(byte & 0b10000000);
101 }
102 if(device == Device_PCBRGB) {
103 send_bit_d6(byte & 0b10000000);
104 }
105 byte <<= 1;
106 }
107}
108
109void send_color(uint8_t r, uint8_t g, uint8_t b, enum Device device) {
110 send_value(r, device);
111 send_value(g, device);
112 send_value(b, device);
113}
114
115// Port from backlight_set_state
116void indicator_leds_set(bool leds[8]) {
117 cli();
118 send_color(leds[1] ? 255 : 0, leds[2] ? 255 : 0, leds[0] ? 255 : 0, Device_STATUSLED);
119 send_color(leds[4] ? 255 : 0, leds[3] ? 255 : 0, leds[5] ? 255 : 0, Device_STATUSLED);
120 leds[6] ? (PORTD &= ~0b10000000) : (PORTD |= 0b10000000);
121 sei();
122 show();
123}
diff --git a/keyboards/duck/octagon/v2/indicator_leds.h b/keyboards/duck/octagon/v2/indicator_leds.h
new file mode 100644
index 000000000..ad3ec54f5
--- /dev/null
+++ b/keyboards/duck/octagon/v2/indicator_leds.h
@@ -0,0 +1,7 @@
1#include "duck_led/duck_led.h"
2
3void indicator_leds_set(bool leds[8]);
4void backlight_toggle_rgb(bool enabled);
5void backlight_set_rgb(uint8_t cfg[17][3]);
6void backlight_init_ports(void);
7void send_color(uint8_t r, uint8_t g, uint8_t b, enum Device device);
diff --git a/keyboards/duck/octagon/v2/info.json b/keyboards/duck/octagon/v2/info.json
new file mode 100644
index 000000000..23911f340
--- /dev/null
+++ b/keyboards/duck/octagon/v2/info.json
@@ -0,0 +1,14 @@
1{
2 "keyboard_name": "Octagon V2",
3 "url": "",
4 "maintainer": "qmk",
5 "layouts": {
6 "LAYOUT": {
7 "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}]
8 },
9
10 "LAYOUT_75_ansi": {
11 "layout": [{"x":0, "y":0}, {"x":1, "y":0}, {"x":2, "y":0}, {"x":3, "y":0}, {"x":4, "y":0}, {"x":5, "y":0}, {"x":6, "y":0}, {"x":7, "y":0}, {"x":8, "y":0}, {"x":9, "y":0}, {"x":10, "y":0}, {"x":11, "y":0}, {"x":12, "y":0}, {"x":13, "y":0}, {"x":14, "y":0}, {"x":15, "y":0}, {"x":0, "y":1}, {"x":1, "y":1}, {"x":2, "y":1}, {"x":3, "y":1}, {"x":4, "y":1}, {"x":5, "y":1}, {"x":6, "y":1}, {"x":7, "y":1}, {"x":8, "y":1}, {"x":9, "y":1}, {"x":10, "y":1}, {"x":11, "y":1}, {"x":12, "y":1}, {"x":13, "y":1, "w":2}, {"x":15, "y":1}, {"x":0, "y":2, "w":1.5}, {"x":1.5, "y":2}, {"x":2.5, "y":2}, {"x":3.5, "y":2}, {"x":4.5, "y":2}, {"x":5.5, "y":2}, {"x":6.5, "y":2}, {"x":7.5, "y":2}, {"x":8.5, "y":2}, {"x":9.5, "y":2}, {"x":10.5, "y":2}, {"x":11.5, "y":2}, {"x":12.5, "y":2}, {"x":13.5, "y":2, "w":1.5}, {"x":15, "y":2}, {"x":0, "y":3, "w":1.75}, {"x":1.75, "y":3}, {"x":2.75, "y":3}, {"x":3.75, "y":3}, {"x":4.75, "y":3}, {"x":5.75, "y":3}, {"x":6.75, "y":3}, {"x":7.75, "y":3}, {"x":8.75, "y":3}, {"x":9.75, "y":3}, {"x":10.75, "y":3}, {"x":11.75, "y":3}, {"x":12.75, "y":3, "w":2.25}, {"x":15, "y":3}, {"x":0, "y":4, "w":2.25}, {"x":2.25, "y":4}, {"x":3.25, "y":4}, {"x":4.25, "y":4}, {"x":5.25, "y":4}, {"x":6.25, "y":4}, {"x":7.25, "y":4}, {"x":8.25, "y":4}, {"x":9.25, "y":4}, {"x":10.25, "y":4}, {"x":11.25, "y":4}, {"x":12.25, "y":4, "w":1.75}, {"x":14, "y":4}, {"x":15, "y":4}, {"x":0, "y":5, "w":1.25}, {"x":1.25, "y":5, "w":1.25}, {"x":2.5, "y":5, "w":1.25}, {"x":3.75, "y":5, "w":6.25}, {"x":10, "y":5}, {"x":11, "y":5}, {"x":12, "y":5}, {"x":13, "y":5}, {"x":14, "y":5}, {"x":15, "y":5}]
12 }
13 }
14}
diff --git a/keyboards/duck/octagon/v2/matrix.c b/keyboards/duck/octagon/v2/matrix.c
new file mode 100644
index 000000000..25d1e45b0
--- /dev/null
+++ b/keyboards/duck/octagon/v2/matrix.c
@@ -0,0 +1,261 @@
1/*
2Copyright 2017 MechMerlin <[email protected]>
3This program is free software: you can redistribute it and/or modify
4it under the terms of the GNU General Public License as published by
5the Free Software Foundation, either version 2 of the License, or
6(at your option) any later version.
7
8This program is distributed in the hope that it will be useful,
9but WITHOUT ANY WARRANTY; without even the implied warranty of
10MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11GNU General Public License for more details.
12
13You should have received a copy of the GNU General Public License
14along with this program. If not, see <http://www.gnu.org/licenses/>.
15*/
16
17#include <util/delay.h>
18#include <avr/io.h>
19#include <stdio.h>
20#include "matrix.h"
21#include "util.h"
22#include "print.h"
23#include "debug.h"
24
25static uint8_t debouncing = DEBOUNCE;
26
27/* matrix state(1:on, 0:off) */
28static matrix_row_t matrix[MATRIX_ROWS];
29static matrix_row_t matrix_debouncing[MATRIX_ROWS];
30
31static uint8_t read_rows(uint8_t col);
32static void init_rows(void);
33static void unselect_cols(void);
34static void select_col(uint8_t col);
35
36
37__attribute__ ((weak))
38void matrix_init_kb(void) {
39 matrix_init_user();
40}
41
42__attribute__ ((weak))
43void matrix_scan_kb(void) {
44 matrix_scan_user();
45}
46
47__attribute__ ((weak))
48void matrix_init_user(void) {
49}
50
51__attribute__ ((weak))
52void matrix_scan_user(void) {
53}
54
55void backlight_init_ports(void)
56{
57 DDRD |= 0b11010000;
58 PORTD &= ~0b01010000;
59 PORTD |= 0b10000000;
60 DDRB |= 0b00011111;
61 PORTB &= ~0b00001110;
62 PORTB |= 0b00010001;
63 DDRE |= 0b01000000;
64 PORTE &= ~0b01000000;
65}
66
67void matrix_init(void) {
68 backlight_init_ports();
69 unselect_cols();
70 init_rows();
71
72 for (uint8_t i=0; i < MATRIX_ROWS; i++) {
73 matrix[i] = 0;
74 matrix_debouncing[i] = 0;
75 }
76
77 matrix_init_quantum();
78}
79
80uint8_t matrix_scan(void) {
81 for (uint8_t col = 0; col < MATRIX_COLS; col++) {
82 select_col(col);
83 _delay_us(3);
84
85 uint8_t rows = read_rows(col);
86
87 for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
88 bool prev_bit = matrix_debouncing[row] & ((matrix_row_t)1<<col);
89 bool curr_bit = rows & (1<<row);
90 if (prev_bit != curr_bit) {
91 matrix_debouncing[row] ^= ((matrix_row_t)1<<col);
92 if (debouncing) {
93 dprint("bounce!: "); dprintf("%02X", debouncing); dprintln();
94 }
95 debouncing = DEBOUNCE;
96 }
97 }
98 unselect_cols();
99 }
100
101 if (debouncing) {
102 if (--debouncing) {
103 _delay_ms(1);
104 } else {
105 for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
106 matrix[i] = matrix_debouncing[i];
107 }
108 }
109 }
110
111 matrix_scan_quantum();
112 return 1;
113}
114
115inline matrix_row_t matrix_get_row(uint8_t row) {
116 return matrix[row];
117}
118
119void matrix_print(void) {
120 print("\nr/c 0123456789ABCDEF\n");
121 for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
122 xprintf("%02X: %032lb\n", row, bitrev32(matrix_get_row(row)));
123 }
124}
125
126/* Row pin configuration
127 * row: 0 1 2 3 4 5
128 * pin: PB7 PD0 PD1 PD2 PD3 PD5
129 *
130 * Esc uses its own pin PE2
131 */
132static void init_rows(void) {
133 DDRD &= ~0b00101111;
134 PORTD &= ~0b00101111;
135
136 DDRB &= ~0b10000000;
137 PORTB &= ~0b10000000;
138
139 DDRE &= ~0b00000100;
140 PORTE |= 0b00000100;
141}
142
143static uint8_t read_rows(uint8_t col) {
144 if (col == 16) {
145 return PINE&(1<<2) ? 0 : (1<<0);
146 } else {
147 return (PIND&(1<<0) ? (1<<0) : 0) |
148 (PIND&(1<<1) ? (1<<1) : 0) |
149 (PIND&(1<<2) ? (1<<2) : 0) |
150 (PIND&(1<<3) ? (1<<3) : 0) |
151 (PIND&(1<<5) ? (1<<4) : 0) |
152 (PINB&(1<<7) ? (1<<5) : 0);
153 }
154}
155
156uint8_t read_fwkey(void)
157{
158 return PINE&(1<<2) ? 0 : (1<<0);
159}
160
161/* Columns 0 - 15
162 * These columns uses two 74HC237D 3 to 8 bit demultiplexers.
163 * col / pin: PC6 PB6 PF0 PF1 PC7
164 * 0: 1 0 0 0 0
165 * 1: 1 0 1 0 0
166 * 2: 1 0 0 1 0
167 * 3: 1 0 1 1 0
168 * 4: 1 0 0 0 1
169 * 5: 1 0 1 0 1
170 * 6: 1 0 0 1 1
171 * 7: 1 0 1 1 1
172 * 8: 0 1 0 0 0
173 * 9: 0 1 1 0 0
174 * 10: 0 1 0 1 0
175 * 11: 0 1 1 1 0
176 * 12: 0 1 0 0 1
177 * 13: 0 1 1 0 1
178 * 14: 0 1 0 1 1
179 * 15: 0 1 1 1 1
180 *
181 */
182static void unselect_cols(void) {
183 DDRB |= 0b01000000;
184 PORTB &= ~0b01000000;
185
186 DDRC |= 0b11000000;
187 PORTC &= ~0b11000000;
188
189 DDRF |= 0b00000011;
190 PORTF &= ~0b00000011;
191}
192
193static void select_col(uint8_t col) {
194
195 switch (col) {
196 case 0:
197 PORTC |= 0b01000000;
198 break;
199 case 1:
200 PORTC |= 0b01000000;
201 PORTF |= 0b00000001;
202 break;
203 case 2:
204 PORTC |= 0b01000000;
205 PORTF |= 0b00000010;
206 break;
207 case 3:
208 PORTC |= 0b01000000;
209 PORTF |= 0b00000011;
210 break;
211 case 4:
212 PORTC |= 0b11000000;
213 break;
214 case 5:
215 PORTC |= 0b11000000;
216 PORTF |= 0b00000001;
217 break;
218 case 6:
219 PORTC |= 0b11000000;
220 PORTF |= 0b00000010;
221 break;
222 case 7:
223 PORTC |= 0b11000000;
224 PORTF |= 0b00000011;
225 break;
226 case 8:
227 PORTB |= 0b01000000;
228 break;
229 case 9:
230 PORTB |= 0b01000000;
231 PORTF |= 0b00000001;
232 break;
233 case 10:
234 PORTB |= 0b01000000;
235 PORTF |= 0b00000010;
236 break;
237 case 11:
238 PORTB |= 0b01000000;
239 PORTF |= 0b00000011;
240 break;
241 case 12:
242 PORTB |= 0b01000000;
243 PORTC |= 0b10000000;
244 break;
245 case 13:
246 PORTB |= 0b01000000;
247 PORTF |= 0b00000001;
248 PORTC |= 0b10000000;
249 break;
250 case 14:
251 PORTB |= 0b01000000;
252 PORTF |= 0b00000010;
253 PORTC |= 0b10000000;
254 break;
255 case 15:
256 PORTB |= 0b01000000;
257 PORTF |= 0b00000011;
258 PORTC |= 0b10000000;
259 break;
260 }
261}
diff --git a/keyboards/duck/octagon/v2/readme.md b/keyboards/duck/octagon/v2/readme.md
new file mode 100644
index 000000000..cc9474fc9
--- /dev/null
+++ b/keyboards/duck/octagon/v2/readme.md
@@ -0,0 +1,30 @@
1# Duck Octagon V2
2
3Non official firmware for custom Korean keyboard with 75% key layout made by Duck.
4Group buy was run January 2016 via [geekhack](https://geekhack.org/index.php?topic=78549.0) with 2 rounds, 100 keyboards total.
5
6Keyboard Maintainer: [MechMerlin](https://github.com/mechmerlin)
7Hardware Supported: Duck Octagon PCB Ver 2.0, Atmega32u4
8Hardware Availability: Wait until GB of the next revision
9
10Make example for this keyboard (after setting up your build environment):
11
12 make octagon/v2:default
13
14**Reset Key:** To put the Octagon V2 into reset, hold the top right most key (`K5Q`) while plugging in.
15
16See [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.
17
18## Hardware Notes
19
20The Duck Octagon V2 PCB consists of:
21
22### Microchips
232 74HC237D 3-to-8 line decoders
241 Atmega32u4 microcontroller
252 WS2811 LED controller
26
27## Notes
28Thanks to Ralf Schmitt for previous implementations in his [TMK fork](https://github.com/xauser/tmk_keyboard/tree/xauser/) and few helping words.
29
30Based 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..14b5de127
--- /dev/null
+++ b/keyboards/duck/octagon/v2/rules.mk
@@ -0,0 +1,25 @@
1# MCU name
2MCU = atmega32u4
3
4# Bootloader selection
5BOOTLOADER = atmel-dfu
6
7# Build Options
8# change yes to no to disable
9#
10BOOTMAGIC_ENABLE = yes # Enable Bootmagic Lite
11MOUSEKEY_ENABLE = no # Mouse keys
12EXTRAKEY_ENABLE = no # Audio control and System control
13CONSOLE_ENABLE = no # Console for debug
14COMMAND_ENABLE = yes # Commands for debug and configuration
15NKRO_ENABLE = yes # Enable N-Key Rollover
16BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality
17BACKLIGHT_DRIVER = custom
18AUDIO_ENABLE = no # Audio output
19RGBLIGHT_ENABLE = yes
20
21CUSTOM_MATRIX = yes
22SRC += indicator_leds.c \
23 matrix.c duck_led/duck_led.c
24
25LAYOUTS = 75_ansi
diff --git a/keyboards/duck/octagon/v2/v2.c b/keyboards/duck/octagon/v2/v2.c
new file mode 100644
index 000000000..23e92b276
--- /dev/null
+++ b/keyboards/duck/octagon/v2/v2.c
@@ -0,0 +1,113 @@
1/* Copyright 2017 MechMerlin <[email protected]>
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
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/>.
15 */
16#include "v2.h"
17#include "indicator_leds.h"
18
19enum BACKLIGHT_AREAS {
20 BACKLIGHT_ALPHA = 0b0000001,
21 BACKLIGHT_EXTRA = 0b0000010,
22 BACKLIGHT_MODNUM = 0b0000100,
23 BACKLIGHT_FROW = 0b0001000,
24 BACKLIGHT_RGB = 0b0010000,
25 BACKLIGHT_SWITCH = 0b0001111
26};
27
28uint8_t backlight_rgb_r = 255;
29uint8_t backlight_rgb_g = 0;
30uint8_t backlight_rgb_b = 0;
31uint8_t backlight_os_state = 0;
32uint32_t backlight_layer_state = 0;
33
34void backlight_toggle_rgb(bool enabled)
35{
36 if(enabled) {
37 uint8_t rgb[17][3] = {
38 {backlight_rgb_r, backlight_rgb_g, backlight_rgb_b},
39 {backlight_rgb_r, backlight_rgb_g, backlight_rgb_b},
40 {backlight_rgb_r, backlight_rgb_g, backlight_rgb_b},
41 {backlight_rgb_r, backlight_rgb_g, backlight_rgb_b},
42 {backlight_rgb_r, backlight_rgb_g, backlight_rgb_b},
43 {backlight_rgb_r, backlight_rgb_g, backlight_rgb_b},
44 {backlight_rgb_r, backlight_rgb_g, backlight_rgb_b},
45 {backlight_rgb_r, backlight_rgb_g, backlight_rgb_b},
46 {backlight_rgb_r, backlight_rgb_g, backlight_rgb_b},
47 {backlight_rgb_r, backlight_rgb_g, backlight_rgb_b},
48 {backlight_rgb_r, backlight_rgb_g, backlight_rgb_b},
49 {backlight_rgb_r, backlight_rgb_g, backlight_rgb_b},
50 {backlight_rgb_r, backlight_rgb_g, backlight_rgb_b},
51 {backlight_rgb_r, backlight_rgb_g, backlight_rgb_b},
52 {backlight_rgb_r, backlight_rgb_g, backlight_rgb_b},
53 {backlight_rgb_r, backlight_rgb_g, backlight_rgb_b},
54 {backlight_rgb_r, backlight_rgb_g, backlight_rgb_b}
55 };
56 backlight_set_rgb(rgb);
57 } else {
58 uint8_t rgb[17][3] = {
59 {0, 0, 0},
60 {0, 0, 0},
61 {0, 0, 0},
62 {0, 0, 0},
63 {0, 0, 0},
64 {0, 0, 0},
65 {0, 0, 0},
66 {0, 0, 0},
67 {0, 0, 0},
68 {0, 0, 0},
69 {0, 0, 0},
70 {0, 0, 0},
71 {0, 0, 0},
72 {0, 0, 0},
73 {0, 0, 0},
74 {0, 0, 0},
75 {0, 0, 0}
76 };
77 backlight_set_rgb(rgb);
78 }
79}
80
81void backlight_set_rgb(uint8_t cfg[17][3])
82{
83 cli();
84 for(uint8_t i = 0; i < 17; ++i) {
85 send_color(cfg[i][0], cfg[i][1], cfg[i][2], Device_PCBRGB);
86 }
87 sei();
88 show();
89}
90
91void backlight_set(uint8_t level) {
92 level & BACKLIGHT_ALPHA ? (PORTB |= 0b00000010) : (PORTB &= ~0b00000010);
93 level & BACKLIGHT_EXTRA ? (PORTB |= 0b00000100) : (PORTB &= ~0b00000100);
94 level & BACKLIGHT_MODNUM ? (PORTB |= 0b00001000) : (PORTB &= ~0b00001000);
95 level & BACKLIGHT_FROW ? (PORTE |= 0b01000000) : (PORTE &= ~0b01000000);
96 level & BACKLIGHT_RGB ? backlight_toggle_rgb(true) : backlight_toggle_rgb(false);
97}
98
99// Port from backlight_update_state
100void led_set_kb(uint8_t usb_led) {
101 bool status[7] = {
102 backlight_os_state & (1<<USB_LED_CAPS_LOCK),
103 backlight_os_state & (1<<USB_LED_SCROLL_LOCK),
104 backlight_os_state & (1<<USB_LED_NUM_LOCK),
105 backlight_layer_state & (1<<1),
106 backlight_layer_state & (1<<2),
107 backlight_layer_state & (1<<3),
108 backlight_layer_state & (1<<4)
109 };
110 indicator_leds_set(status);
111 backlight_os_state & (1<<USB_LED_CAPS_LOCK) ? (PORTB &= ~0b00000001) : (PORTB |= 0b00000001);
112 backlight_os_state & (1<<USB_LED_SCROLL_LOCK) ? (PORTB &= ~0b00010000) : (PORTB |= 0b00010000);
113}
diff --git a/keyboards/duck/octagon/v2/v2.h b/keyboards/duck/octagon/v2/v2.h
new file mode 100644
index 000000000..d60631009
--- /dev/null
+++ b/keyboards/duck/octagon/v2/v2.h
@@ -0,0 +1,50 @@
1/* Copyright 2017 MechMerlin <[email protected]>
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
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/>.
15 */
16#pragma once
17
18#include "quantum.h"
19
20#define LAYOUT( \
21 K5A, K5B, K5C, K5D, K5E, K5F, K5G, K5H, K5I, K5J, K5K, K5L, K5M, K5N, K5O, K5Q, \
22 K4A, K4B, K4C, K4D, K4E, K4F, K4G, K4H, K4I, K4J, K4K, K4L, K4M, K4O, K4P, \
23 K3A, K3B, K3C, K3D, K3E, K3F, K3G, K3H, K3I, K3J, K3K, K3L, K3M, K3O, K3P, \
24 K2A, K2B, K2C, K2D, K2E, K2F, K2G, K2H, K2I, K2J, K2K, K2L, K2M, K2O, K2P, \
25 K1A, K1B, K1C, K1D, K1E, K1F, K1G, K1H, K1I, K1J, K1K, K1M, K1N, K1O, K1P, \
26 K0A, K0B, K0C, K0J, K0K, K0L, K0M, K0N, K0O, K0P \
27) { \
28 { K5A, K5B, K5C, K5D, K5E, K5F, K5G, K5H, K5I, K5J, K5K, K5L, K5M, K5N, K5O, KC_NO, K5Q }, \
29 { K4A, K4B, K4C, K4D, K4E, K4F, K4G, K4H, K4I, K4J, K4K, K4L, K4M, KC_NO, K4O, K4P, KC_NO }, \
30 { K3A, K3B, K3C, K3D, K3E, K3F, K3G, K3H, K3I, K3J, K3K, K3L, K3M, KC_NO, K3O, K3P, KC_NO }, \
31 { K2A, K2B, K2C, K2D, K2E, K2F, K2G, K2H, K2I, K2J, K2K, K2L, K2M, KC_NO, K2O, K2P, KC_NO }, \
32 { K1A, K1B, K1C, K1D, K1E, K1F, K1G, K1H, K1I, K1J, K1K, KC_NO, K1M, K1N, K1O, K1P, KC_NO }, \
33 { K0A, K0B, K0C, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, K0J, KC_NO, K0K, K0L, K0M, K0N, K0O, K0P, KC_NO } \
34}
35
36#define LAYOUT_75_ansi( \
37 K5A, K5B, K5C, K5D, K5E, K5F, K5G, K5H, K5I, K5J, K5K, K5L, K5M, K5N, K5O, K5Q, \
38 K4A, K4B, K4C, K4D, K4E, K4F, K4G, K4H, K4I, K4J, K4K, K4L, K4M, K4O, K4P, \
39 K3A, K3B, K3C, K3D, K3E, K3F, K3G, K3H, K3I, K3J, K3K, K3L, K3M, K3O, K3P, \
40 K2A, K2B, K2C, K2D, K2E, K2F, K2G, K2H, K2I, K2J, K2K, K2L, K2O, K2P, \
41 K1A, K1C, K1D, K1E, K1F, K1G, K1H, K1I, K1J, K1K, K1M, K1N, K1O, K1P, \
42 K0A, K0B, K0C, K0J, K0K, K0L, K0M, K0N, K0O, K0P \
43) { \
44 { K5A, K5B, K5C, K5D, K5E, K5F, K5G, K5H, K5I, K5J, K5K, K5L, K5M, K5N, K5O, KC_NO, K5Q }, \
45 { K4A, K4B, K4C, K4D, K4E, K4F, K4G, K4H, K4I, K4J, K4K, K4L, K4M, KC_NO, K4O, K4P, KC_NO }, \
46 { K3A, K3B, K3C, K3D, K3E, K3F, K3G, K3H, K3I, K3J, K3K, K3L, K3M, KC_NO, K3O, K3P, KC_NO }, \
47 { K2A, K2B, K2C, K2D, K2E, K2F, K2G, K2H, K2I, K2J, K2K, K2L, KC_NO, KC_NO, K2O, K2P, KC_NO }, \
48 { K1A, KC_NO, K1C, K1D, K1E, K1F, K1G, K1H, K1I, K1J, K1K, KC_NO, K1M, K1N, K1O, K1P, 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 } \
50}