aboutsummaryrefslogtreecommitdiff
path: root/keyboards/honeycomb
diff options
context:
space:
mode:
Diffstat (limited to 'keyboards/honeycomb')
-rwxr-xr-xkeyboards/honeycomb/config.h65
-rwxr-xr-xkeyboards/honeycomb/honeycomb.c92
-rwxr-xr-xkeyboards/honeycomb/honeycomb.h37
-rwxr-xr-xkeyboards/honeycomb/keymaps/default/keymap.c91
-rwxr-xr-xkeyboards/honeycomb/matrix.c202
-rwxr-xr-xkeyboards/honeycomb/readme.md20
-rwxr-xr-xkeyboards/honeycomb/rules.mk68
7 files changed, 575 insertions, 0 deletions
diff --git a/keyboards/honeycomb/config.h b/keyboards/honeycomb/config.h
new file mode 100755
index 000000000..abc273c97
--- /dev/null
+++ b/keyboards/honeycomb/config.h
@@ -0,0 +1,65 @@
1/*
2Copyright 2019 @filoxo
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
24#define VENDOR_ID 0xFEED
25#define PRODUCT_ID 0xACC8
26#define DEVICE_VER 0x0001
27#define MANUFACTURER Keyhive
28#define PRODUCT Honeycomb Macropad
29#define DESCRIPTION QMK firmware for Honeycomb Macropad
30
31/* key matrix size */
32#define MATRIX_ROWS 1
33#define MATRIX_COLS 16
34
35#define ONESHOT_TIMEOUT 500
36
37/* disable debug print */
38//#define NO_DEBUG
39
40/* disable print */
41//#define NO_PRINT
42
43/* disable action features */
44//#define NO_ACTION_LAYER
45//#define NO_ACTION_TAPPING
46//#define NO_ACTION_ONESHOT
47//#define NO_ACTION_MACRO
48//#define NO_ACTION_FUNCTION
49
50//UART settings for communication with the RF microcontroller
51#define SERIAL_UART_BAUD 1000000
52#define SERIAL_UART_DATA UDR1
53#define SERIAL_UART_UBRR (F_CPU / (16UL * SERIAL_UART_BAUD) - 1)
54#define SERIAL_UART_TXD_READY (UCSR1A & _BV(UDRE1))
55#define SERIAL_UART_RXD_PRESENT (UCSR1A & _BV(RXC1))
56#define SERIAL_UART_INIT() do { \
57 /* baud rate */ \
58 UBRR1L = SERIAL_UART_UBRR; \
59 /* baud rate */ \
60 UBRR1H = SERIAL_UART_UBRR >> 8; \
61 /* enable TX and RX */ \
62 UCSR1B = _BV(TXEN1) | _BV(RXEN1); \
63 /* 8-bit data */ \
64 UCSR1C = _BV(UCSZ11) | _BV(UCSZ10); \
65} while(0)
diff --git a/keyboards/honeycomb/honeycomb.c b/keyboards/honeycomb/honeycomb.c
new file mode 100755
index 000000000..add4af153
--- /dev/null
+++ b/keyboards/honeycomb/honeycomb.c
@@ -0,0 +1,92 @@
1#include "honeycomb.h"
2#include "pointing_device.h"
3#include "report.h"
4
5void uart_init(void) {
6 SERIAL_UART_INIT();
7}
8
9void pointing_device_task(void){
10 /*report_mouse_t currentReport = {};
11 SERIAL_UART_INIT();
12 uint32_t timeout = 0;
13
14 //the m character requests the RF slave to send the mouse report
15 SERIAL_UART_DATA = 'm';
16
17 //trust the external inputs completely, erase old data
18 uint8_t uart_data[5] = {0};
19
20 //there are 10 bytes corresponding to 10 columns, and an end byte
21 for (uint8_t i = 0; i < 5; i++) {
22 //wait for the serial data, timeout if it's been too long
23 //this only happened in testing with a loose wire, but does no
24 //harm to leave it in here
25 while(!SERIAL_UART_RXD_PRESENT){
26 timeout++;
27 if (timeout > 10000){
28 xprintf("\r\nTIMED OUT");
29 break;
30 }
31 }
32 xprintf("\r\nGOT DATA for %d",i);
33 uart_data[i] = SERIAL_UART_DATA;
34 }
35
36 //check for the end packet, bytes 1-4 are movement and scroll
37 //but byte 5 has bits 0-3 for the scroll button state
38 //(1000 if pressed, 0000 if not) and bits 4-7 are always 1
39 //We can use this to verify the report sent properly.
40 if (uart_data[4] == 0x0F || uart_data[4] == 0x8F)
41 {
42 xprintf("\r\nREQUESTED MOUSE, RECEIVED %i, %i, %i, %i, %i",uart_data[0],uart_data[1],uart_data[2],uart_data[3],uart_data[4]);
43 currentReport = pointing_device_get_report();
44 //shifting and transferring the info to the mouse report varaible
45 //mouseReport.x = 127 max -127 min
46 currentReport.x = (int8_t) uart_data[0];
47 //mouseReport.y = 127 max -127 min
48 currentReport.y = (int8_t) uart_data[1];
49 //mouseReport.v = 127 max -127 min (scroll vertical)
50 currentReport.v = (int8_t) uart_data[2];
51 //mouseReport.h = 127 max -127 min (scroll horizontal)
52 currentReport.h = (int8_t) uart_data[3];
53 //mouseReport.buttons = 0x31 max (bitmask for mouse buttons 1-5) 0x00 min
54 //mouse buttons 1 and 2 are handled by the keymap, but not 3
55 if (uart_data[4] == 0x0F) { //then 3 is not pressed
56 currentReport.buttons &= ~MOUSE_BTN3; //MOUSE_BTN3 is def in report.h
57 } else { //3 must be pressed
58 currentReport.buttons |= MOUSE_BTN3;
59 }
60 pointing_device_set_report(currentReport);
61 } else {
62 xprintf("\r\nRequested packet, data 4 was %d",uart_data[4]);
63 }*/
64 pointing_device_send();
65}
66
67void led_init(void) {
68 setPinOutput(D1);
69 writePinHigh(D1);
70 setPinOutput(F4);
71 writePinHigh(F4);
72 setPinOutput(F5);
73 writePinHigh(F5);
74}
75
76void matrix_init_kb(void) {
77 // put your keyboard start-up code here
78 // runs once when the firmware starts up
79 matrix_init_user();
80 uart_init();
81 led_init();
82}
83
84void matrix_scan_kb(void) {
85 // put your looping keyboard code here
86 // runs every cycle (a lot)
87 matrix_scan_user();
88}
89
90void led_set_kb(uint8_t usb_led) {
91
92}
diff --git a/keyboards/honeycomb/honeycomb.h b/keyboards/honeycomb/honeycomb.h
new file mode 100755
index 000000000..9374a02c5
--- /dev/null
+++ b/keyboards/honeycomb/honeycomb.h
@@ -0,0 +1,37 @@
1#pragma once
2
3#define HONEYCOMB_H
4
5#include "quantum.h"
6#include "matrix.h"
7#include "backlight.h"
8#include <stddef.h>
9
10#define RED_LED_OFF() writePinHigh(F6)
11#define RED_LED_ON() writePinLow(F6)
12#define BLU_LED_OFF() writePinHigh(F5)
13#define BLU_LED_ON() writePinLow(F5)
14#define GRN_LED_OFF() writePinHigh(D1)
15#define GRN_LED_ON() writePinLow(D1)
16
17#define SET_LED_OFF (RED_LED_OFF(); GRN_LED_OFF(); BLU_LED_OFF(); )
18#define SET_LED_RED (RED_LED_ON(); GRN_LED_OFF(); BLU_LED_OFF(); )
19#define SET_LED_BLUE (RED_LED_OFF(); GRN_LED_OFF(); BLU_LED_ON(); )
20#define SET_LED_GREEN (RED_LED_OFF(); GRN_LED_ON(); BLU_LED_OFF(); )
21#define SET_LED_YELLOW (RED_LED_ON(); GRN_LED_ON(); BLU_LED_OFF(); )
22#define SET_LED_MAGENTA (RED_LED_ON(); GRN_LED_OFF(); BLU_LED_ON(); )
23#define SET_LED_CYAN (RED_LED_OFF(); GRN_LED_ON(); BLU_LED_ON(); )
24#define SET_LED_WHITE (RED_LED_ON(); GRN_LED_ON(); BLU_LED_ON(); )
25
26// This a shortcut to help you visually see your layout.
27// The first section contains all of the arguements
28// The second converts the arguments into a two-dimensional array
29#define LAYOUT( \
30 k13, k14, k15, k16, \
31 k09, k10, k11, k12, \
32 k05, k06, k07, k08, \
33 k01, k02, k03, k04 \
34) \
35{ \
36 { k01, k02, k03, k04, k05, k06, k07, k08, k09, k10, k11, k12, k13, k14, k15, k16 } \
37}
diff --git a/keyboards/honeycomb/keymaps/default/keymap.c b/keyboards/honeycomb/keymaps/default/keymap.c
new file mode 100755
index 000000000..d0a596187
--- /dev/null
+++ b/keyboards/honeycomb/keymaps/default/keymap.c
@@ -0,0 +1,91 @@
1#include QMK_KEYBOARD_H
2
3// Each layer gets a name for readability, which is then used in the keymap matrix below.
4// The underscores don't mean anything - you can have a layer called STUFF or any other name.
5// Layer names don't all need to be of the same length, obviously, and you can also skip them
6// entirely and just use numbers.
7enum honeycomb_layers {
8 _BS,
9 _EN
10};
11
12// Macro definitions for readability
13enum honeycomb_keycodes {
14 HW = SAFE_RANGE,
15 COPY,
16 PASTA
17};
18
19extern int8_t encoderValue;
20
21const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
22 [_BS] = LAYOUT( /* Base layout, put whatever defaults. */
23 HW, COPY, PASTA, KC_MUTE,
24 KC_4, KC_5, KC_6, KC_7,
25 KC_8, KC_9, KC_A, KC_B,
26 KC_C, KC_D, KC_E, KC_F
27 ),
28
29 [_EN] = LAYOUT( /* Alternate layer */
30 _______, _______, _______, _______,
31 _______, _______, _______, _______,
32 _______, _______, _______, _______,
33 _______, _______, _______, _______
34 )
35};
36
37report_mouse_t currentReport = {};
38
39bool process_record_user(uint16_t keycode, keyrecord_t *record) {
40 //uint8_t layer = biton32(layer_state); // get the current layer
41
42 // Basic example functions
43 switch (keycode) {
44 case HW:
45 if (record->event.pressed) {
46 SEND_STRING("Hello, world!");
47 } else {
48 SEND_STRING("Goodbye, cruel world!");
49 }
50 break;
51 case COPY:
52 if (record->event.pressed) {
53 tap_code16(LCTL(KC_C)); // Replace with tap_code16(LCMD(KC_C)) to enable for Mac
54 }
55 break;
56 case PASTA:
57 if (record->event.pressed) {
58 tap_code16(LCTL(KC_V)); // Replace with tap_code16(LCMD(KC_V)) to enable for Mac
59 }
60 break;
61 return false;
62 }
63 return true;
64};
65
66void matrix_scan_user(void) {
67 /* Leaving some LED stuff in here in comment form so you can see how to use it.
68 if (shiftLED || capsLED){
69 red_led_on;
70 } else {
71 red_led_off;
72 }
73 if (numLED){
74 grn_led_on;
75 } else {
76 grn_led_off;
77 }
78 if (mouseLED){
79 blu_led_on;
80 } else {
81 blu_led_off;
82 }*/
83 while (encoderValue < 0){
84 tap_code(KC_VOLD);
85 encoderValue++;
86 }
87 while (encoderValue > 0){
88 tap_code(KC_VOLU);
89 encoderValue--;
90 }
91};
diff --git a/keyboards/honeycomb/matrix.c b/keyboards/honeycomb/matrix.c
new file mode 100755
index 000000000..a06afb6d9
--- /dev/null
+++ b/keyboards/honeycomb/matrix.c
@@ -0,0 +1,202 @@
1/*
2Copyright 2012 Jun Wako
3Copyright 2014 Jack Humbert
4Copyright 2019 @filoxo
5
6This program is free software: you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by
8the Free Software Foundation, either version 2 of the License, or
9(at your option) any later version.
10
11This program is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with this program. If not, see <http://www.gnu.org/licenses/>.
18*/
19#include <stdint.h>
20#include <stdbool.h>
21#if defined(__AVR__)
22#include <avr/io.h>
23#endif
24#include "wait.h"
25#include "print.h"
26#include "debug.h"
27#include "util.h"
28#include "matrix.h"
29#include "timer.h"
30#include "honeycomb.h"
31#include "pointing_device.h"
32#include "report.h"
33
34#if (MATRIX_COLS <= 8)
35# define print_matrix_header() print("\nr/c 01234567\n")
36# define print_matrix_row(row) print_bin_reverse8(matrix_get_row(row))
37# define matrix_bitpop(i) bitpop(matrix[i])
38# define ROW_SHIFTER ((uint8_t)1)
39#elif (MATRIX_COLS <= 16)
40# define print_matrix_header() print("\nr/c 0123456789ABCDEF\n")
41# define print_matrix_row(row) print_bin_reverse16(matrix_get_row(row))
42# define matrix_bitpop(i) bitpop16(matrix[i])
43# define ROW_SHIFTER ((uint16_t)1)
44#elif (MATRIX_COLS <= 32)
45# define print_matrix_header() print("\nr/c 0123456789ABCDEF0123456789ABCDEF\n")
46# define print_matrix_row(row) print_bin_reverse32(matrix_get_row(row))
47# define matrix_bitpop(i) bitpop32(matrix[i])
48# define ROW_SHIFTER ((uint32_t)1)
49#endif
50
51/* matrix state(1:on, 0:off) */
52static matrix_row_t matrix[MATRIX_ROWS];
53//extern int8_t encoderValue;
54int8_t encoderValue = 0;
55
56__attribute__ ((weak))
57void matrix_init_quantum(void) {
58 matrix_init_kb();
59}
60
61__attribute__ ((weak))
62void matrix_scan_quantum(void) {
63 matrix_scan_kb();
64}
65
66__attribute__ ((weak))
67void matrix_init_kb(void) {
68 matrix_init_user();
69}
70
71__attribute__ ((weak))
72void matrix_scan_kb(void) {
73 matrix_scan_user();
74}
75
76__attribute__ ((weak))
77void matrix_init_user(void) {
78}
79
80__attribute__ ((weak))
81void matrix_scan_user(void) {
82}
83
84inline
85uint8_t matrix_rows(void) {
86 return MATRIX_ROWS;
87}
88
89inline
90uint8_t matrix_cols(void) {
91 return MATRIX_COLS;
92}
93
94void matrix_init(void) {
95
96 matrix_init_quantum();
97}
98
99uint8_t matrix_scan(void)
100{
101 SERIAL_UART_INIT();
102
103 uint32_t timeout = 0;
104
105 // The 's' character requests the RF slave to send the matrix
106 SERIAL_UART_DATA = 's';
107
108 // Trust the external keystates entirely, erase the last data
109 uint8_t uart_data[4] = {0};
110
111 // There are 3 bytes corresponding to the data, and a checksum
112 for (uint8_t i = 0; i < 4; i++) {
113 // Wait for the serial data, timeout if it's been too long
114 // This only happened in testing with a loose wire, but does no
115 // harm to leave it in here
116 while(!SERIAL_UART_RXD_PRESENT){
117 timeout++;
118 if (timeout > 10000){
119 xprintf("\r\nTime out in keyboard.");
120 break;
121 }
122 }
123 uart_data[i] = SERIAL_UART_DATA;
124 }
125
126 // Check for the end packet, it's our checksum.
127 // Will only be a match if the correct bytes were recieved
128 if (uart_data[3] == (uart_data[0] ^ uart_data[1] ^ uart_data[2])) { // This is an arbitrary checksum calculated by XORing all the data.
129 // Transferring the keystates to the QMK matrix variable
130 /* ASSUMING MSB FIRST */
131 matrix[0] = ((uint16_t) uart_data[0] << 8) | ((uint16_t) uart_data[1]);
132 encoderValue += (int8_t) uart_data[2];
133 if ((uart_data[0] | uart_data[1] | uart_data[2])!=0){
134 xprintf("\r\n0x%0X%02X%02X",uart_data[0],uart_data[1], uart_data[2]);
135 }
136 /* OK, TURNS OUT THAT WAS A BAD ASSUMPTION */
137 for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
138 // I've unpacked these into the mirror image of what QMK expects them to be, so...
139 matrix[i] = bitrev16(matrix[i]);
140 // So I'll reverse it, and this should be fine now.
141 }
142
143 // A mouse report for scrolling would go here, but I don't plan on doing scrolling with the encoder. So.
144
145 report_mouse_t currentReport = {};
146/*
147 currentReport = pointing_device_get_report();
148 //mouseReport.x = 127 max -127 min
149 currentReport.x = (int8_t) uart_data[6];
150 //mouseReport.y = 127 max -127 min
151 currentReport.y = (int8_t) uart_data[7];
152 //mouseReport.v = 127 max -127 min (scroll vertical)
153 currentReport.v = (int8_t) uart_data[8];
154 //mouseReport.h = 127 max -127 min (scroll horizontal)
155 currentReport.h = (int8_t) uart_data[9];
156 */
157 /*
158 currentReport.x = 0;
159 currentReport.y = 0;
160 currentReport.v = 0;
161 currentReport.h = 0;*/
162
163 pointing_device_set_report(currentReport);
164 } else {
165 xprintf("\r\nRequested packet, data 3 was %d",uart_data[3]);
166 }
167
168 matrix_scan_quantum();
169 return 1;
170}
171
172inline
173bool matrix_is_on(uint8_t row, uint8_t col)
174{
175 return (matrix[row] & ((matrix_row_t)1<col));
176}
177
178inline
179matrix_row_t matrix_get_row(uint8_t row)
180{
181 return matrix[row];
182}
183
184void matrix_print(void)
185{
186 print_matrix_header();
187
188 for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
189 phex(row); print(": ");
190 print_matrix_row(row);
191 print("\n");
192 }
193}
194
195uint8_t matrix_key_count(void)
196{
197 uint8_t count = 0;
198 for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
199 count += matrix_bitpop(i);
200 }
201 return count;
202}
diff --git a/keyboards/honeycomb/readme.md b/keyboards/honeycomb/readme.md
new file mode 100755
index 000000000..955f0ac7a
--- /dev/null
+++ b/keyboards/honeycomb/readme.md
@@ -0,0 +1,20 @@
1Honeycomb Keyboard Firmware
2======================
3
4These configuration files use a completely different 'matrix scan' system than other keyboards, it relies on an external nRF51822 microcontroller maintaining a matrix of keystates received from the macropad - it also receives rotary encoder information from the macropad. The matrix.c file contains the code to poll the external microcontroller for the key matrix, and the keymap.c file contains example code for encoder use. As long as the relevant functions in these files are not changed, all other QMK features are supported.
5
6## Building
7
8Run the following command in your terminal:
9
10```
11make honeycomb:default
12# or use this to automatically flash the controller
13make honeycomb:default:avrdude
14```
15
16Follow the QMK guide for this or ask in Discord.
17
18### Other Keymaps
19
20Because this is a totally custom macropad, it is recommended that you copy the `default/` folder, rename it as desired, and modify the `keymap.c` to your liking. \ No newline at end of file
diff --git a/keyboards/honeycomb/rules.mk b/keyboards/honeycomb/rules.mk
new file mode 100755
index 000000000..90992bad7
--- /dev/null
+++ b/keyboards/honeycomb/rules.mk
@@ -0,0 +1,68 @@
1# # project specific files
2SRC += matrix.c
3
4
5# MCU name
6#MCU = at90usb1287
7MCU = atmega32u4
8
9# Processor frequency.
10# This will define a symbol, F_CPU, in all source code files equal to the
11# processor frequency in Hz. You can then use this symbol in your source code to
12# calculate timings. Do NOT tack on a 'UL' at the end, this will be done
13# automatically to create a 32-bit value in your source code.
14#
15# This will be an integer division of F_USB below, as it is sourced by
16# F_USB after it has run through any CPU prescalers. Note that this value
17# does not *change* the processor frequency - it should merely be updated to
18# reflect the processor speed set externally so that the code can use accurate
19# software delays.
20F_CPU = 16000000
21
22
23#
24# LUFA specific
25#
26# Target architecture (see library "Board Types" documentation).
27ARCH = AVR8
28
29# Input clock frequency.
30# This will define a symbol, F_USB, in all source code files equal to the
31# input clock frequency (before any prescaling is performed) in Hz. This value may
32# differ from F_CPU if prescaling is used on the latter, and is required as the
33# raw input clock is fed directly to the PLL sections of the AVR for high speed
34# clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL'
35# at the end, this will be done automatically to create a 32-bit value in your
36# source code.
37#
38# If no clock division is performed on the input clock inside the AVR (via the
39# CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU.
40F_USB = $(F_CPU)
41
42# Interrupt driven control endpoint task(+60)
43OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT
44
45BOOTLOADER = caterina
46
47# Build Options
48# comment out to disable the options.
49#
50#BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration(+1000)
51#MOUSEKEY_ENABLE = yes # Mouse keys(+4700)
52POINTING_DEVICE_ENABLE = yes # Generic Pointer, not as big as mouse keys hopefully.
53EXTRAKEY_ENABLE = yes # Audio control and System control(+450)
54CONSOLE_ENABLE = yes # Console for debug(+400)
55COMMAND_ENABLE = yes # Commands for debug and configuration
56CUSTOM_MATRIX = yes # Remote matrix from the wireless bridge
57# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE
58# SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend
59NKRO_ENABLE = yes # USB Nkey Rollover - not yet supported in LUFA
60# BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality
61# MIDI_ENABLE = YES # MIDI controls
62UNICODE_ENABLE = YES # Unicode
63# BLUETOOTH_ENABLE = yes # Enable Bluetooth with the Adafruit EZ-Key HID
64
65USB = /dev/ttyACM0
66
67#upload: build
68# $(honeycomb_UPLOAD_COMMAND)