[Keyboard] New Keyboard: Duck TC-V3 (#8265)

Co-Authored-By: Ryan <fauxpark@gmail.com>
Co-Authored-By: James Young <18669334+noroadsleft@users.noreply.github.com>
Co-Authored-By: Drashna Jaelre <drashna@live.com>
Co-authored-by: Drashna Jaelre <drashna@live.com>
Co-authored-by: Joel Challis <git@zvecr.com>
Co-authored-by: Ryan <fauxpark@gmail.com>
Co-authored-by: James Young <18669334+noroadsleft@users.noreply.github.com>
master
MechMerlin 2020-06-02 21:59:13 -07:00 committed by GitHub
parent 81a2113cbd
commit be73820f7b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 797 additions and 1 deletions

View File

@ -14,4 +14,5 @@ Lightsaver V3
Octagon V1
Octagon V2
Orion V3
TC-V3
Viper V2

View File

@ -0,0 +1,45 @@
/*
Copyright 2019 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/>.
*/
#pragma once
#include "config_common.h"
/* USB Device descriptor parameter */
#define VENDOR_ID 0x444B // Duck ("DK")
#define PRODUCT_ID 0x5443 // TC-V3 ("TC")
#define DEVICE_VER 0x0001
#define MANUFACTURER Duck
#define PRODUCT TC-V3
#define DESCRIPTION Duck TC-V3
/* key matrix size */
#define MATRIX_ROWS 6
#define MATRIX_COLS 20
#define DIODE_DIRECTION COL2ROW
/* Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not needed */
#define DEBOUNCE 5
#define RGBLIGHT_ANIMATIONS
#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

View File

@ -0,0 +1,123 @@
/*
Copyright 2019 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 LED_T1H 900
#define LED_T1L 600
#define LED_T0H 400
#define LED_T0L 900
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(LED_T1H) - 2),
[offCycles] "I" (NS_TO_CYCLES(LED_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(LED_T0H) - 2),
[offCycles] "I" (NS_TO_CYCLES(LED_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(LED_T1H) - 2),
[offCycles] "I" (NS_TO_CYCLES(LED_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(LED_T0H) - 2),
[offCycles] "I" (NS_TO_CYCLES(LED_T0L) - 2));
}
}
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(r, device);
send_value(g, 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();
}

View File

@ -0,0 +1,7 @@
#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);

View File

@ -0,0 +1,16 @@
{
"keyboard_name": "TCV3",
"url": "",
"maintainer": "qmk",
"width": 19.5,
"height": 6.5,
"layouts": {
"LAYOUT_all": {
"layout": [{"x":0, "y":0}, {"x":1, "y":0}, {"x":2.25, "y":0}, {"x":4.25, "y":0}, {"x":5.25, "y":0}, {"x":6.25, "y":0}, {"x":7.25, "y":0}, {"x":8.75, "y":0}, {"x":9.75, "y":0}, {"x":10.75, "y":0}, {"x":11.75, "y":0}, {"x":13.25, "y":0}, {"x":14.25, "y":0}, {"x":15.25, "y":0}, {"x":16.25, "y":0}, {"x":17.5, "y":0}, {"x":18.5, "y":0}, {"x":0, "y":1.25}, {"x":1, "y":1.25}, {"x":2.25, "y":1.25}, {"x":3.25, "y":1.25}, {"x":4.25, "y":1.25}, {"x":5.25, "y":1.25}, {"x":6.25, "y":1.25}, {"x":7.25, "y":1.25}, {"x":8.25, "y":1.25}, {"x":9.25, "y":1.25}, {"x":10.25, "y":1.25}, {"x":11.25, "y":1.25}, {"x":12.25, "y":1.25}, {"x":13.25, "y":1.25}, {"x":14.25, "y":1.25}, {"x":15.25, "y":1.25}, {"x":16.25, "y":1.25}, {"x":17.5, "y":1.25}, {"x":18.5, "y":1.25}, {"x":0, "y":2.25}, {"x":1, "y":2.25}, {"x":2.25, "y":2.25, "w":1.5}, {"x":3.75, "y":2.25}, {"x":4.75, "y":2.25}, {"x":5.75, "y":2.25}, {"x":6.75, "y":2.25}, {"x":7.75, "y":2.25}, {"x":8.75, "y":2.25}, {"x":9.75, "y":2.25}, {"x":10.75, "y":2.25}, {"x":11.75, "y":2.25}, {"x":12.75, "y":2.25}, {"x":13.75, "y":2.25}, {"x":14.75, "y":2.25}, {"x":15.75, "y":2.25, "w":1.5}, {"x":17.5, "y":2.25}, {"x":18.5, "y":2.25}, {"x":0, "y":3.25}, {"x":1, "y":3.25}, {"x":2.25, "y":3.25, "w":1.75}, {"x":4, "y":3.25}, {"x":5, "y":3.25}, {"x":6, "y":3.25}, {"x":7, "y":3.25}, {"x":8, "y":3.25}, {"x":9, "y":3.25}, {"x":10, "y":3.25}, {"x":11, "y":3.25}, {"x":12, "y":3.25}, {"x":13, "y":3.25}, {"x":14, "y":3.25}, {"x":15, "y":3.25}, {"x":16, "y":3.25, "w":1.25}, {"x":17.5, "y":3.25}, {"x":18.5, "y":3.25}, {"x":0, "y":4.25}, {"x":1, "y":4.25}, {"x":2.25, "y":4.25, "w":1.25}, {"x":3.5, "y":4.25}, {"x":4.5, "y":4.25}, {"x":5.5, "y":4.25}, {"x":6.5, "y":4.25}, {"x":7.5, "y":4.25}, {"x":8.5, "y":4.25}, {"x":9.5, "y":4.25}, {"x":10.5, "y":4.25}, {"x":11.5, "y":4.25}, {"x":12.5, "y":4.25}, {"x":13.5, "y":4.25}, {"x":14.5, "y":4.25, "w":1.75}, {"x":16.25, "y":4.25}, {"x":17.5, "y":4.5}, {"x":0, "y":5.25}, {"x":1, "y":5.25}, {"x":2.25, "y":5.25, "w":1.5}, {"x":3.75, "y":5.25}, {"x":4.75, "y":5.25, "w":1.5}, {"x":6.25, "y":5.25, "w":6}, {"x":12.25, "y":5.25, "w":1.5}, {"x":13.75, "y":5.25}, {"x":14.75, "y":5.25, "w":1.5}, {"x":16.5, "y":5.5}, {"x":17.5, "y":5.5}, {"x":18.5, "y":5.5}]
},
"LAYOUT": {
"layout": [{"x":0, "y":0}, {"x":1, "y":0}, {"x":2.25, "y":0}, {"x":4.25, "y":0}, {"x":5.25, "y":0}, {"x":6.25, "y":0}, {"x":7.25, "y":0}, {"x":8.75, "y":0}, {"x":9.75, "y":0}, {"x":10.75, "y":0}, {"x":11.75, "y":0}, {"x":13.25, "y":0}, {"x":14.25, "y":0}, {"x":15.25, "y":0}, {"x":16.25, "y":0}, {"x":17.5, "y":0}, {"x":18.5, "y":0}, {"x":0, "y":1.25}, {"x":1, "y":1.25}, {"x":2.25, "y":1.25}, {"x":3.25, "y":1.25}, {"x":4.25, "y":1.25}, {"x":5.25, "y":1.25}, {"x":6.25, "y":1.25}, {"x":7.25, "y":1.25}, {"x":8.25, "y":1.25}, {"x":9.25, "y":1.25}, {"x":10.25, "y":1.25}, {"x":11.25, "y":1.25}, {"x":12.25, "y":1.25}, {"x":13.25, "y":1.25}, {"x":14.25, "y":1.25}, {"x":15.25, "y":1.25, "w":2}, {"x":17.5, "y":1.25}, {"x":18.5, "y":1.25}, {"x":0, "y":2.25}, {"x":1, "y":2.25}, {"x":2.25, "y":2.25, "w":1.5}, {"x":3.75, "y":2.25}, {"x":4.75, "y":2.25}, {"x":5.75, "y":2.25}, {"x":6.75, "y":2.25}, {"x":7.75, "y":2.25}, {"x":8.75, "y":2.25}, {"x":9.75, "y":2.25}, {"x":10.75, "y":2.25}, {"x":11.75, "y":2.25}, {"x":12.75, "y":2.25}, {"x":13.75, "y":2.25}, {"x":14.75, "y":2.25}, {"x":15.75, "y":2.25, "w":1.5}, {"x":17.5, "y":2.25}, {"x":18.5, "y":2.25}, {"x":0, "y":3.25}, {"x":1, "y":3.25}, {"x":2.25, "y":3.25, "w":1.75}, {"x":4, "y":3.25}, {"x":5, "y":3.25}, {"x":6, "y":3.25}, {"x":7, "y":3.25}, {"x":8, "y":3.25}, {"x":9, "y":3.25}, {"x":10, "y":3.25}, {"x":11, "y":3.25}, {"x":12, "y":3.25}, {"x":13, "y":3.25}, {"x":14, "y":3.25}, {"x":15, "y":3.25, "w":2.25}, {"x":17.5, "y":3.25}, {"x":18.5, "y":3.25}, {"x":0, "y":4.25}, {"x":1, "y":4.25}, {"x":2.25, "y":4.25, "w":2.25}, {"x":4.5, "y":4.25}, {"x":5.5, "y":4.25}, {"x":6.5, "y":4.25}, {"x":7.5, "y":4.25}, {"x":8.5, "y":4.25}, {"x":9.5, "y":4.25}, {"x":10.5, "y":4.25}, {"x":11.5, "y":4.25}, {"x":12.5, "y":4.25}, {"x":13.5, "y":4.25}, {"x":14.5, "y":4.25, "w":2.75}, {"x":17.5, "y":4.5}, {"x":0, "y":5.25}, {"x":1, "y":5.25}, {"x":2.25, "y":5.25, "w":1.5}, {"x":3.75, "y":5.25}, {"x":4.75, "y":5.25, "w":1.5}, {"x":6.25, "y":5.25, "w":6}, {"x":12.25, "y":5.25, "w":1.5}, {"x":13.75, "y":5.25}, {"x":14.75, "y":5.25, "w":1.5}, {"x":16.5, "y":5.5}, {"x":17.5, "y":5.5}, {"x":18.5, "y":5.5}]
}
}
}

View File

@ -0,0 +1,37 @@
/* Copyright 2019 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(\
KC_F1, KC_F2, 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_F3, KC_F4, 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_INS, KC_DEL,
KC_F5, KC_F6, 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_HOME, KC_END,
KC_F7, KC_F8, 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_PGUP, KC_PGDN,
KC_F9, KC_F10, 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_F11, KC_F12, KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, MO(_FL), KC_RGUI, KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT),
[_FL] = LAYOUT(\
KC_TRNS, KC_TRNS, 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, 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, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS),
};

View File

@ -0,0 +1 @@
#define DYNAMIC_KEYMAP_LAYER_COUNT 3

View File

@ -0,0 +1,42 @@
/* Copyright 2019 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
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
[0] = LAYOUT(\
KC_F1, KC_F2, 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_F3, KC_F4, 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_INS, KC_DEL,
KC_F5, KC_F6, 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_HOME, KC_END,
KC_F7, KC_F8, 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_PGUP, KC_PGDN,
KC_F9, KC_F10, 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_F11, KC_F12, KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, MO(1), KC_RGUI, KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT),
[1] = LAYOUT(\
KC_TRNS, KC_TRNS, 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, 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, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS),
[2] = LAYOUT(\
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, 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, KC_TRNS),
};

View File

@ -0,0 +1,2 @@
VIA_ENABLE = yes
LTO_ENABLE = yes

View File

@ -0,0 +1,272 @@
/*
Copyright 2019 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"
#include "debounce.h"
#include "wait.h"
/* 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;
}
debounce_init(MATRIX_ROWS);
matrix_init_quantum();
}
uint8_t matrix_scan(void) {
bool changed = false;
for (uint8_t col = 0; col < MATRIX_COLS; col++) {
select_col(col);
wait_us(30);
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);
changed = true;
}
}
unselect_cols();
}
debounce(matrix, matrix_debouncing, MATRIX_ROWS, changed);
matrix_scan_quantum();
return (uint8_t)changed;
}
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
*
* Reset Key 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 == 20) {
return PINE&(1<<2) ? 0 : (1<<0);
} else {
return (PIND&(1<<0) ? (1<<1) : 0) |
(PIND&(1<<1) ? (1<<2) : 0) |
(PIND&(1<<2) ? (1<<3) : 0) |
(PIND&(1<<3) ? (1<<4) : 0) |
(PIND&(1<<5) ? (1<<5) : 0) |
(PINB&(1<<7) ? (1<<0) : 0);
}
}
/* Columns 0 - G
* These columns uses two 74HC237D 3 to 8 bit demultiplexers.
*
* atmega32u4 decoder pin
* C6 U1 E2
* B6 U2 E2
* F0 U1, U2 A0
* F1 U1, U2 A1
* C7 U1, U2 A2
*
* col 0: B4
* col 1: D7
* col I: B5
*
* col / pin: PC6 PB6 PF0 PF1 PC7 Decoder Pin
* 2: 1 0 0 0 0 U1 Y0
* 3: 1 0 1 0 0 U1 Y1
* 4: 1 0 0 1 0 U1 Y2
* 5: 1 0 1 1 0 U1 Y3
* 6: 1 0 0 0 1 U1 Y4
* 7: 1 0 1 0 1 U1 Y5
* 8: 1 0 0 1 1 U1 Y6
* 9: 1 0 1 1 1 U1 Y7
* A: 0 1 0 0 0 U2 Y0
* B: 0 1 1 0 0 U2 Y1
* C: 0 1 0 1 0 U2 Y2
* D: 0 1 1 1 0 U2 Y3
* E: 0 1 0 0 1 U2 Y4
* F: 0 1 1 0 1 U2 Y5
* G: 0 1 0 1 1 U2 Y6
* H: 0 1 1 1 1 U2 Y7
*
*/
static void unselect_cols(void) {
DDRB |= 0b01110000;
PORTB &= ~0b01110000;
DDRC |= 0b11000000;
PORTC &= ~0b11000000;
DDRD |= 0b10000000;
PORTD &= ~0b10000000;
DDRF |= 0b00000011;
PORTF &= ~0b00000011;
}
static void select_col(uint8_t col) {
switch (col) {
case 0:
PORTB |= 0b00010000;
break;
case 1:
PORTD |= 0b10000000;
break;
case 2: // U1 Y0
PORTC |= 0b01000000;
break;
case 3: // U1 Y1
PORTC |= 0b01000000;
PORTF |= 0b00000001;
break;
case 4: // U1 Y2
PORTC |= 0b01000000;
PORTF |= 0b00000010;
break;
case 5: // U1 Y3
PORTC |= 0b01000000;
PORTF |= 0b00000011;
break;
case 6: // U1 Y4
PORTC |= 0b11000000;
break;
case 7: // U1 Y5
PORTC |= 0b11000000;
PORTF |= 0b00000001;
break;
case 8: // U1 Y6
PORTC |= 0b11000000;
PORTF |= 0b00000010;
break;
case 9: // U1 Y7
PORTC |= 0b11000000;
PORTF |= 0b00000011;
break;
case 10: // U2 Y0
PORTB |= 0b01000000;
break;
case 11: // U2 Y1
PORTB |= 0b01000000;
PORTF |= 0b00000001;
break;
case 12: // U2 Y2
PORTB |= 0b01000000;
PORTF |= 0b00000010;
break;
case 13: // U2 Y3
PORTB |= 0b01000000;
PORTF |= 0b00000011;
break;
case 14: // U2 Y4
PORTB |= 0b01000000;
PORTC |= 0b10000000;
break;
case 15: // U2 Y5
PORTB |= 0b01000000;
PORTC |= 0b10000000;
PORTF |= 0b00000001;
break;
case 16: // U2 Y6
PORTB |= 0b01000000;
PORTC |= 0b10000000;
PORTF |= 0b00000010;
break;
case 17: // U2 Y7
PORTB |= 0b01000000;
PORTC |= 0b10000000;
PORTF |= 0b00000011;
break;
case 18:
PORTB |= 0b00100000;
break;
}
}

View File

@ -0,0 +1,27 @@
# Duck TC-V3
Non official firmware for custom Korean keyboard made by Duck.
Group buy was run April 2018 via [geekhack](https://geekhack.org/index.php?topic=95335.0).
* Keyboard Maintainer: [MechMerlin](https://github.com/mechmerlin)
* Hardware Supported: Duck TC-V3 ver 1.0 PCB, Atmega32u4, 74HC237D
* Hardware Availability: Wait until GB of the next revision
Make example for this keyboard (after setting up your build environment):
make duck/tcv3:default
**Reset Key:** To put the TC-V3 into reset, hold the top second most right key (`K0J`) while plugging in.
**CAUTION:** At this time 02/28/20 backlighting has not been tested fully and may not properly work.
See [build environment setup](https://docs.qmk.fm/#/getting_started_build_tools) then the [make instructions](https://docs.qmk.fm/#/getting_started_make_guide) for more information.
## Hardware Notes
The Duck TC-V3 PCB consists of:
### Microchips
* 2 74HC237D 3-to-8 line decoders
* 1 Atmega32u4 microcontroller
* 3 WS2811 LED controller

View File

@ -0,0 +1,36 @@
# MCU name
MCU = atmega32u4
# Bootloader selection
# Teensy halfkay
# Pro Micro caterina
# Atmel DFU atmel-dfu
# LUFA DFU lufa-dfu
# QMK DFU qmk-dfu
# ATmega32A bootloadHID
# ATmega328P USBasp
BOOTLOADER = atmel-dfu
# Build Options
# change yes to no to disable
#
BOOTMAGIC_ENABLE = lite # Virtual DIP switch configuration
MOUSEKEY_ENABLE = no # Mouse keys
EXTRAKEY_ENABLE = no # Audio control and System control
CONSOLE_ENABLE = no # Console for debug
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 = no # Enable keyboard backlight functionality
MIDI_ENABLE = no # MIDI support
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 duck_led/duck_led.c

134
keyboards/duck/tcv3/tcv3.c Normal file
View File

@ -0,0 +1,134 @@
/* Copyright 2019 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 "tcv3.h"
#include "indicator_leds.h"
enum BACKLIGHT_AREAS {
BACKLIGHT_ALPHA = 0b0000001,
BACKLIGHT_FROW = 0b0000010,
BACKLIGHT_MOD = 0b0000100,
BACKLIGHT_MACRO = 0b0001000,
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();
// }
// Q5, Q6, Q7 is connected to B1 - alphas
// Q8, Q9 is connected to B2 - frow
// Q1, Q2, Q3 is connected to B3 - mods
// Q4 is connected to E6 - macro keys
void backlight_set(uint8_t level) {
level & BACKLIGHT_ALPHA ? (PORTB |= 0b00000010) : (PORTB &= ~0b00000010);
level & BACKLIGHT_FROW ? (PORTB |= 0b00000100) : (PORTB &= ~0b00000100);
level & BACKLIGHT_MOD ? (PORTB |= 0b00001000) : (PORTB &= ~0b00001000);
level & BACKLIGHT_MACRO ? (PORTE |= 0b01000000) : (PORTE &= ~0b01000000);
}
// // 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);
// }
// U5 Pin 1, 2, 3 connected to top left LEDs
// U6 Pin 1, 2, 3 connected to bottom right leds col of 3
// U7 Pin 1 connected to row connected to bottom right leds solo LED
// U7 Pin 2, 3 connected to bottom right leds row of 2
// U6 Pin 5 connected to U7 Pin 6
// U5 pin 5 connected to U6 Pin 6
// U5, U6, U7 Pin 8 VCC
// U5, U6, U7 Pin 4 GRND
// U5 Pin 6 connected to atmega32u4 D4

View File

@ -0,0 +1,53 @@
/* Copyright 2019 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/>.
*/
#pragma once
#include "quantum.h"
#define XXX KC_NO
#define LAYOUT_all( \
K00, K01, K02, K04, K05, K06, K07, K09, K0A, K0B, K0C, K0D, K0E, K0F, K0G, K0J, K0I, \
K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, K1C, K1D, K1E, K1F, K1G, K1H, K1I, \
K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, K2C, K2D, K2E, K2G, K2H, K2I, \
K30, K31, K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B, K3C, K3D, K3E, K3G, K3H, K3I, \
K40, K41, K42, k43, K44, K45, K46, K47, K48, K49, K4A, K4B, K4C, K4E, K4F, K4G, K4H, \
K50, K51, K52, K53, K54, K5A, K5C, K5E, K5F, K5G, K5H, K5I \
) { \
{ K00, K01, K02, XXX, K04, K05, K06, K07, XXX, K09, K0A, K0B, K0C, K0D, K0E, K0F, K0G, XXX, K0I, K0J }, \
{ K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, K1C, K1D, K1E, K1F, K1G, K1H, K1I, XXX }, \
{ K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, K2C, K2D, K2E, XXX, K2G, K2H, K2I, XXX }, \
{ K30, K31, K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B, K3C, K3D, K3E, XXX, K3G, K3H, K3I, XXX }, \
{ K40, K41, K42, K43, K44, K45, K46, K47, K48, K49, K4A, K4B, K4C, XXX, K4E, K4F, K4G, K4H, XXX, XXX }, \
{ K50, K51, K52, K53, K54, XXX, XXX, XXX, XXX, XXX, K5A, XXX, K5C, XXX, K5E, K5F, K5G, K5H, K5I, XXX }, \
}
#define LAYOUT( \
K00, K01, K02, K04, K05, K06, K07, K09, K0A, K0B, K0C, K0D, K0E, K0F, K0G, K0J, K0I, \
K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, K1C, K1D, K1E, K1G, K1H, K1I, \
K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, K2C, K2D, K2E, K2G, K2H, K2I, \
K30, K31, K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B, K3C, K3D, K3G, K3H, K3I, \
K40, K41, K42, K44, K45, K46, K47, K48, K49, K4A, K4B, K4C, K4E, K4F, K4H, \
K50, K51, K52, K53, K54, K5A, K5C, K5E, K5F, K5G, K5H, K5I \
) { \
{ K00, K01, K02, XXX, K04, K05, K06, K07, XXX, K09, K0A, K0B, K0C, K0D, K0E, K0F, K0G, XXX, K0I, K0J }, \
{ K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, K1C, K1D, K1E, XXX, K1G, K1H, K1I, XXX }, \
{ K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, K2C, K2D, K2E, XXX, K2G, K2H, K2I, XXX }, \
{ K30, K31, K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B, K3C, K3D, XXX, XXX, K3G, K3H, K3I, XXX }, \
{ K40, K41, K42, XXX, K44, K45, K46, K47, K48, K49, K4A, K4B, K4C, XXX, K4E, K4F, XXX, K4H, XXX, XXX }, \
{ K50, K51, K52, K53, K54, XXX, XXX, XXX, XXX, XXX, K5A, XXX, K5C, XXX, K5E, K5F, K5G, K5H, K5I, XXX }, \
}