diff options
-rw-r--r-- | build_keyboard.mk | 6 | ||||
-rw-r--r-- | keyboards/ergodox/config.h | 2 | ||||
-rw-r--r-- | keyboards/ergodox/keymaps/jack/Makefile | 5 | ||||
-rw-r--r-- | keyboards/ergodox/keymaps/jack/config.h | 14 | ||||
-rw-r--r-- | keyboards/ergodox/keymaps/jack/keymap.c | 15 | ||||
-rw-r--r-- | keyboards/planck/keymaps/thermal_printer/Makefile | 26 | ||||
-rw-r--r-- | keyboards/planck/keymaps/thermal_printer/config.h | 23 | ||||
-rw-r--r-- | keyboards/planck/keymaps/thermal_printer/keymap.c | 314 | ||||
-rw-r--r-- | keyboards/planck/keymaps/thermal_printer/readme.md | 2 | ||||
-rw-r--r-- | quantum/keymap.h | 4 | ||||
-rwxr-xr-x | quantum/light_ws2812.c | 143 | ||||
-rwxr-xr-x | quantum/light_ws2812.h | 7 | ||||
-rw-r--r-- | quantum/process_keycode/process_printer.c | 254 | ||||
-rw-r--r-- | quantum/process_keycode/process_printer.h | 8 | ||||
-rw-r--r-- | quantum/process_keycode/process_printer_bb.c | 260 | ||||
-rw-r--r-- | quantum/quantum.c | 2 | ||||
-rw-r--r-- | quantum/quantum.h | 4 | ||||
-rw-r--r-- | quantum/rgblight.c | 18 | ||||
-rw-r--r-- | quantum/rgblight.h | 1 |
19 files changed, 1098 insertions, 10 deletions
diff --git a/build_keyboard.mk b/build_keyboard.mk index 61aebf393..42f8f8ac7 100644 --- a/build_keyboard.mk +++ b/build_keyboard.mk | |||
@@ -174,6 +174,12 @@ ifeq ($(strip $(TAP_DANCE_ENABLE)), yes) | |||
174 | SRC += $(QUANTUM_DIR)/process_keycode/process_tap_dance.c | 174 | SRC += $(QUANTUM_DIR)/process_keycode/process_tap_dance.c |
175 | endif | 175 | endif |
176 | 176 | ||
177 | ifeq ($(strip $(PRINTING_ENABLE)), yes) | ||
178 | OPT_DEFS += -DPRINTING_ENABLE | ||
179 | SRC += $(QUANTUM_DIR)/process_keycode/process_printer.c | ||
180 | SRC += $(TMK_DIR)/protocol/serial_uart.c | ||
181 | endif | ||
182 | |||
177 | ifeq ($(strip $(SERIAL_LINK_ENABLE)), yes) | 183 | ifeq ($(strip $(SERIAL_LINK_ENABLE)), yes) |
178 | SRC += $(patsubst $(QUANTUM_PATH)/%,%,$(SERIAL_SRC)) | 184 | SRC += $(patsubst $(QUANTUM_PATH)/%,%,$(SERIAL_SRC)) |
179 | OPT_DEFS += $(SERIAL_DEFS) | 185 | OPT_DEFS += $(SERIAL_DEFS) |
diff --git a/keyboards/ergodox/config.h b/keyboards/ergodox/config.h index edc60caae..049c707a5 100644 --- a/keyboards/ergodox/config.h +++ b/keyboards/ergodox/config.h | |||
@@ -1,6 +1,8 @@ | |||
1 | #ifndef KEYBOARDS_ERGODOX_CONFIG_H_ | 1 | #ifndef KEYBOARDS_ERGODOX_CONFIG_H_ |
2 | #define KEYBOARDS_ERGODOX_CONFIG_H_ | 2 | #define KEYBOARDS_ERGODOX_CONFIG_H_ |
3 | 3 | ||
4 | #include "config_common.h" | ||
5 | |||
4 | #define MOUSEKEY_DELAY 100 | 6 | #define MOUSEKEY_DELAY 100 |
5 | #define MOUSEKEY_INTERVAL 20 | 7 | #define MOUSEKEY_INTERVAL 20 |
6 | #define MOUSEKEY_MAX_SPEED 3 | 8 | #define MOUSEKEY_MAX_SPEED 3 |
diff --git a/keyboards/ergodox/keymaps/jack/Makefile b/keyboards/ergodox/keymaps/jack/Makefile new file mode 100644 index 000000000..1e5761278 --- /dev/null +++ b/keyboards/ergodox/keymaps/jack/Makefile | |||
@@ -0,0 +1,5 @@ | |||
1 | RGBLIGHT_ENABLE = yes | ||
2 | |||
3 | ifndef QUANTUM_DIR | ||
4 | include ../../../../Makefile | ||
5 | endif | ||
diff --git a/keyboards/ergodox/keymaps/jack/config.h b/keyboards/ergodox/keymaps/jack/config.h new file mode 100644 index 000000000..1781563b8 --- /dev/null +++ b/keyboards/ergodox/keymaps/jack/config.h | |||
@@ -0,0 +1,14 @@ | |||
1 | #ifndef CONFIG_USER_H | ||
2 | #define CONFIG_USER_H | ||
3 | |||
4 | #include "../../config.h" | ||
5 | |||
6 | /* ws2812 RGB LED */ | ||
7 | #define RGB_DI_PIN D7 | ||
8 | // #define RGBLIGHT_TIMER | ||
9 | #define RGBLED_NUM 15 // Number of LEDs | ||
10 | #define RGBLIGHT_HUE_STEP 12 | ||
11 | #define RGBLIGHT_SAT_STEP 255 | ||
12 | #define RGBLIGHT_VAL_STEP 12 | ||
13 | |||
14 | #endif \ No newline at end of file | ||
diff --git a/keyboards/ergodox/keymaps/jack/keymap.c b/keyboards/ergodox/keymaps/jack/keymap.c index dda253fa4..8721b9644 100644 --- a/keyboards/ergodox/keymaps/jack/keymap.c +++ b/keyboards/ergodox/keymaps/jack/keymap.c | |||
@@ -19,13 +19,13 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | |||
19 | KC_HOME, | 19 | KC_HOME, |
20 | KC_SPC,KC_SPC,KC_END, | 20 | KC_SPC,KC_SPC,KC_END, |
21 | // right hand | 21 | // right hand |
22 | KC_NO, KC_6, KC_7, KC_8, KC_9, KC_0, KC_NO, | 22 | KC_NO, M(1), KC_7, KC_8, KC_9, KC_0, KC_NO, |
23 | KC_NO, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSPC, | 23 | KC_NO, RGB_TOG, RGB_MOD, RGB_HUI, RGB_HUD, KC_P, KC_BSPC, |
24 | KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, | 24 | RGB_SAI, RGB_SAD, RGB_VAI, RGB_VAD, KC_SCLN, KC_QUOT, |
25 | KC_NO, KC_N, KC_M, KC_COMM,KC_DOT, KC_SLSH, KC_ENT, | 25 | KC_NO, KC_N, KC_M, KC_COMM,KC_DOT, KC_SLSH, KC_ENT, |
26 | MO(1), KC_LEFT,KC_DOWN,KC_UP, KC_RGHT, | 26 | MO(1), KC_LEFT,KC_DOWN,KC_UP, KC_RGHT, |
27 | KC_NO, KC_NO, | 27 | RGB_TOG, RGB_HUI, |
28 | KC_PGUP, | 28 | RGB_MOD, |
29 | KC_PGDN, KC_SPC,KC_SPC | 29 | KC_PGDN, KC_SPC,KC_SPC |
30 | ), | 30 | ), |
31 | [SYMB] = KEYMAP( | 31 | [SYMB] = KEYMAP( |
@@ -84,6 +84,11 @@ const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) | |||
84 | unregister_code(KC_RSFT); | 84 | unregister_code(KC_RSFT); |
85 | } | 85 | } |
86 | break; | 86 | break; |
87 | case 1: | ||
88 | if (record->event.pressed) { // For resetting EEPROM | ||
89 | eeconfig_init(); | ||
90 | } | ||
91 | break; | ||
87 | } | 92 | } |
88 | return MACRO_NONE; | 93 | return MACRO_NONE; |
89 | }; | 94 | }; |
diff --git a/keyboards/planck/keymaps/thermal_printer/Makefile b/keyboards/planck/keymaps/thermal_printer/Makefile new file mode 100644 index 000000000..3d1d11877 --- /dev/null +++ b/keyboards/planck/keymaps/thermal_printer/Makefile | |||
@@ -0,0 +1,26 @@ | |||
1 | |||
2 | |||
3 | # Build Options | ||
4 | # change to "no" to disable the options, or define them in the Makefile in | ||
5 | # the appropriate keymap folder that will get included automatically | ||
6 | # | ||
7 | BOOTMAGIC_ENABLE = no # Virtual DIP switch configuration(+1000) | ||
8 | MOUSEKEY_ENABLE = yes # Mouse keys(+4700) | ||
9 | EXTRAKEY_ENABLE = yes # Audio control and System control(+450) | ||
10 | CONSOLE_ENABLE = no # Console for debug(+400) | ||
11 | COMMAND_ENABLE = yes # Commands for debug and configuration | ||
12 | NKRO_ENABLE = yes # Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work | ||
13 | BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality | ||
14 | MIDI_ENABLE = no # MIDI controls | ||
15 | AUDIO_ENABLE = yes # Audio output on port C6 | ||
16 | UNICODE_ENABLE = no # Unicode | ||
17 | BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID | ||
18 | RGBLIGHT_ENABLE = no # Enable WS2812 RGB underlight. Do not enable this with audio at the same time. | ||
19 | PRINTING_ENABLE = yes | ||
20 | |||
21 | # Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE | ||
22 | SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend | ||
23 | |||
24 | ifndef QUANTUM_DIR | ||
25 | include ../../../../Makefile | ||
26 | endif | ||
diff --git a/keyboards/planck/keymaps/thermal_printer/config.h b/keyboards/planck/keymaps/thermal_printer/config.h new file mode 100644 index 000000000..430b6493c --- /dev/null +++ b/keyboards/planck/keymaps/thermal_printer/config.h | |||
@@ -0,0 +1,23 @@ | |||
1 | #ifndef CONFIG_USER_H | ||
2 | #define CONFIG_USER_H | ||
3 | |||
4 | #include "../../config.h" | ||
5 | |||
6 | # define SERIAL_UART_BAUD 19200 | ||
7 | # define SERIAL_UART_DATA UDR1 | ||
8 | # define SERIAL_UART_UBRR (F_CPU / (16UL * SERIAL_UART_BAUD) - 1) | ||
9 | # define SERIAL_UART_RXD_VECT USART1_RX_vect | ||
10 | # define SERIAL_UART_TXD_READY (UCSR1A & _BV(UDRE1)) | ||
11 | # define SERIAL_UART_INIT() do { \ | ||
12 | /* baud rate */ \ | ||
13 | UBRR1L = SERIAL_UART_UBRR; \ | ||
14 | /* baud rate */ \ | ||
15 | UBRR1H = SERIAL_UART_UBRR >> 8; \ | ||
16 | /* enable TX */ \ | ||
17 | UCSR1B = _BV(TXEN1); \ | ||
18 | /* 8-bit data */ \ | ||
19 | UCSR1C = _BV(UCSZ11) | _BV(UCSZ10); \ | ||
20 | sei(); \ | ||
21 | } while(0) | ||
22 | |||
23 | #endif \ No newline at end of file | ||
diff --git a/keyboards/planck/keymaps/thermal_printer/keymap.c b/keyboards/planck/keymaps/thermal_printer/keymap.c new file mode 100644 index 000000000..e88059731 --- /dev/null +++ b/keyboards/planck/keymaps/thermal_printer/keymap.c | |||
@@ -0,0 +1,314 @@ | |||
1 | // This is the canonical layout file for the Quantum project. If you want to add another keyboard, | ||
2 | // this is the style you want to emulate. | ||
3 | |||
4 | #include "planck.h" | ||
5 | #include "action_layer.h" | ||
6 | #ifdef AUDIO_ENABLE | ||
7 | #include "audio.h" | ||
8 | #endif | ||
9 | #include "eeconfig.h" | ||
10 | |||
11 | extern keymap_config_t keymap_config; | ||
12 | |||
13 | // Each layer gets a name for readability, which is then used in the keymap matrix below. | ||
14 | // The underscores don't mean anything - you can have a layer called STUFF or any other name. | ||
15 | // Layer names don't all need to be of the same length, obviously, and you can also skip them | ||
16 | // entirely and just use numbers. | ||
17 | #define _QWERTY 0 | ||
18 | #define _COLEMAK 1 | ||
19 | #define _DVORAK 2 | ||
20 | #define _LOWER 3 | ||
21 | #define _RAISE 4 | ||
22 | #define _PLOVER 5 | ||
23 | #define _ADJUST 16 | ||
24 | |||
25 | enum planck_keycodes { | ||
26 | QWERTY = SAFE_RANGE, | ||
27 | COLEMAK, | ||
28 | DVORAK, | ||
29 | PLOVER, | ||
30 | LOWER, | ||
31 | RAISE, | ||
32 | BACKLIT, | ||
33 | EXT_PLV | ||
34 | }; | ||
35 | |||
36 | // Fillers to make layering more clear | ||
37 | #define _______ KC_TRNS | ||
38 | #define XXXXXXX KC_NO | ||
39 | |||
40 | const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | ||
41 | |||
42 | /* Qwerty | ||
43 | * ,-----------------------------------------------------------------------------------. | ||
44 | * | Tab | Q | W | E | R | T | Y | U | I | O | P | Bksp | | ||
45 | * |------+------+------+------+------+-------------+------+------+------+------+------| | ||
46 | * | Esc | A | S | D | F | G | H | J | K | L | ; | " | | ||
47 | * |------+------+------+------+------+------|------+------+------+------+------+------| | ||
48 | * | Shift| Z | X | C | V | B | N | M | , | . | / |Enter | | ||
49 | * |------+------+------+------+------+------+------+------+------+------+------+------| | ||
50 | * | Brite| Ctrl | Alt | GUI |Lower | Space |Raise | Left | Down | Up |Right | | ||
51 | * `-----------------------------------------------------------------------------------' | ||
52 | */ | ||
53 | [_QWERTY] = { | ||
54 | {KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSPC}, | ||
55 | {KC_ESC, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT}, | ||
56 | {KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_ENT }, | ||
57 | {BACKLIT, KC_LCTL, KC_LALT, KC_LGUI, LOWER, KC_SPC, KC_SPC, RAISE, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT} | ||
58 | }, | ||
59 | |||
60 | /* Colemak | ||
61 | * ,-----------------------------------------------------------------------------------. | ||
62 | * | Tab | Q | W | F | P | G | J | L | U | Y | ; | Bksp | | ||
63 | * |------+------+------+------+------+-------------+------+------+------+------+------| | ||
64 | * | Esc | A | R | S | T | D | H | N | E | I | O | " | | ||
65 | * |------+------+------+------+------+------|------+------+------+------+------+------| | ||
66 | * | Shift| Z | X | C | V | B | K | M | , | . | / |Enter | | ||
67 | * |------+------+------+------+------+------+------+------+------+------+------+------| | ||
68 | * | Brite| Ctrl | Alt | GUI |Lower | Space |Raise | Left | Down | Up |Right | | ||
69 | * `-----------------------------------------------------------------------------------' | ||
70 | */ | ||
71 | [_COLEMAK] = { | ||
72 | {KC_TAB, KC_Q, KC_W, KC_F, KC_P, KC_G, KC_J, KC_L, KC_U, KC_Y, KC_SCLN, KC_BSPC}, | ||
73 | {KC_ESC, KC_A, KC_R, KC_S, KC_T, KC_D, KC_H, KC_N, KC_E, KC_I, KC_O, KC_QUOT}, | ||
74 | {KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_K, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_ENT }, | ||
75 | {BACKLIT, KC_LCTL, KC_LALT, KC_LGUI, LOWER, KC_SPC, KC_SPC, RAISE, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT} | ||
76 | }, | ||
77 | |||
78 | /* Dvorak | ||
79 | * ,-----------------------------------------------------------------------------------. | ||
80 | * | Tab | " | , | . | P | Y | F | G | C | R | L | Bksp | | ||
81 | * |------+------+------+------+------+-------------+------+------+------+------+------| | ||
82 | * | Esc | A | O | E | U | I | D | H | T | N | S | / | | ||
83 | * |------+------+------+------+------+------|------+------+------+------+------+------| | ||
84 | * | Shift| ; | Q | J | K | X | B | M | W | V | Z |Enter | | ||
85 | * |------+------+------+------+------+------+------+------+------+------+------+------| | ||
86 | * | Brite| Ctrl | Alt | GUI |Lower | Space |Raise | Left | Down | Up |Right | | ||
87 | * `-----------------------------------------------------------------------------------' | ||
88 | */ | ||
89 | [_DVORAK] = { | ||
90 | {KC_TAB, KC_QUOT, KC_COMM, KC_DOT, KC_P, KC_Y, KC_F, KC_G, KC_C, KC_R, KC_L, KC_BSPC}, | ||
91 | {KC_ESC, KC_A, KC_O, KC_E, KC_U, KC_I, KC_D, KC_H, KC_T, KC_N, KC_S, KC_SLSH}, | ||
92 | {KC_LSFT, KC_SCLN, KC_Q, KC_J, KC_K, KC_X, KC_B, KC_M, KC_W, KC_V, KC_Z, KC_ENT }, | ||
93 | {BACKLIT, KC_LCTL, KC_LALT, KC_LGUI, LOWER, KC_SPC, KC_SPC, RAISE, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT} | ||
94 | }, | ||
95 | |||
96 | /* Lower | ||
97 | * ,-----------------------------------------------------------------------------------. | ||
98 | * | ~ | ! | @ | # | $ | % | ^ | & | * | ( | ) | Bksp | | ||
99 | * |------+------+------+------+------+-------------+------+------+------+------+------| | ||
100 | * | Del | F1 | F2 | F3 | F4 | F5 | F6 | _ | + | { | } | | | | ||
101 | * |------+------+------+------+------+------|------+------+------+------+------+------| | ||
102 | * | | F7 | F8 | F9 | F10 | F11 | F12 |ISO ~ |ISO | | | |Enter | | ||
103 | * |------+------+------+------+------+------+------+------+------+------+------+------| | ||
104 | * | | | | | | | | Next | Vol- | Vol+ | Play | | ||
105 | * `-----------------------------------------------------------------------------------' | ||
106 | */ | ||
107 | [_LOWER] = { | ||
108 | {KC_TILD, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, KC_BSPC}, | ||
109 | {KC_DEL, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_UNDS, KC_PLUS, KC_LCBR, KC_RCBR, KC_PIPE}, | ||
110 | {_______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12,S(KC_NUHS),S(KC_NUBS),_______, _______, _______}, | ||
111 | {_______, _______, _______, _______, _______, _______, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY} | ||
112 | }, | ||
113 | |||
114 | /* Raise | ||
115 | * ,-----------------------------------------------------------------------------------. | ||
116 | * | ` | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | Bksp | | ||
117 | * |------+------+------+------+------+-------------+------+------+------+------+------| | ||
118 | * | Del | F1 | F2 | F3 | F4 | F5 | F6 | - | = | [ | ] | \ | | ||
119 | * |------+------+------+------+------+------|------+------+------+------+------+------| | ||
120 | * | | F7 | F8 | F9 | F10 | F11 | F12 |ISO # |ISO / | | |Enter | | ||
121 | * |------+------+------+------+------+------+------+------+------+------+------+------| | ||
122 | * | | | | | | | | Next | Vol- | Vol+ | Play | | ||
123 | * `-----------------------------------------------------------------------------------' | ||
124 | */ | ||
125 | [_RAISE] = { | ||
126 | {KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_BSPC}, | ||
127 | {KC_DEL, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_MINS, KC_EQL, KC_LBRC, KC_RBRC, KC_BSLS}, | ||
128 | {_______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_NUHS, KC_NUBS, _______, _______, _______}, | ||
129 | {_______, _______, _______, _______, _______, _______, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY} | ||
130 | }, | ||
131 | |||
132 | /* Plover layer (http://opensteno.org) | ||
133 | * ,-----------------------------------------------------------------------------------. | ||
134 | * | # | # | # | # | # | # | # | # | # | # | # | # | | ||
135 | * |------+------+------+------+------+-------------+------+------+------+------+------| | ||
136 | * | | S | T | P | H | * | * | F | P | L | T | D | | ||
137 | * |------+------+------+------+------+------|------+------+------+------+------+------| | ||
138 | * |TogOut| S | K | W | R | * | * | R | B | G | S | Z | | ||
139 | * |------+------+------+------+------+------+------+------+------+------+------+------| | ||
140 | * | Exit | | | A | O | | E | U | | | | | ||
141 | * `-----------------------------------------------------------------------------------' | ||
142 | */ | ||
143 | |||
144 | [_PLOVER] = { | ||
145 | {KC_1, KC_1, KC_1, KC_1, KC_1, KC_1, KC_1, KC_1, KC_1, KC_1, KC_1, KC_1 }, | ||
146 | {XXXXXXX, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC}, | ||
147 | {XXXXXXX, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT}, | ||
148 | {EXT_PLV, XXXXXXX, XXXXXXX, KC_C, KC_V, XXXXXXX, XXXXXXX, KC_N, KC_M, XXXXXXX, XXXXXXX, XXXXXXX} | ||
149 | }, | ||
150 | |||
151 | /* Adjust (Lower + Raise) | ||
152 | * ,-----------------------------------------------------------------------------------. | ||
153 | * | | Reset| | Print|no prnt | | | | | | | Del | | ||
154 | * |------+------+------+------+------+-------------+------+------+------+------+------| | ||
155 | * | | | |Aud on|Audoff|AGnorm|AGswap|Qwerty|Colemk|Dvorak|Plover| | | ||
156 | * |------+------+------+------+------+------|------+------+------+------+------+------| | ||
157 | * | |Voice-|Voice+|Mus on|Musoff|MIDIon|MIDIof| | | | | | | ||
158 | * |------+------+------+------+------+------+------+------+------+------+------+------| | ||
159 | * | | | | | | | | | | | | | ||
160 | * `-----------------------------------------------------------------------------------' | ||
161 | */ | ||
162 | [_ADJUST] = { | ||
163 | {_______, RESET, _______, PRINT_ON, PRINT_OFF, _______, _______, _______, _______, _______, _______, KC_DEL}, | ||
164 | {_______, _______, _______, AU_ON, AU_OFF, AG_NORM, AG_SWAP, QWERTY, COLEMAK, DVORAK, PLOVER, _______}, | ||
165 | {_______, MUV_DE, MUV_IN, MU_ON, MU_OFF, MI_ON, MI_OFF, _______, _______, _______, _______, _______}, | ||
166 | {_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______} | ||
167 | } | ||
168 | |||
169 | |||
170 | }; | ||
171 | |||
172 | #ifdef AUDIO_ENABLE | ||
173 | |||
174 | float tone_startup[][2] = SONG(STARTUP_SOUND); | ||
175 | float tone_qwerty[][2] = SONG(QWERTY_SOUND); | ||
176 | float tone_dvorak[][2] = SONG(DVORAK_SOUND); | ||
177 | float tone_colemak[][2] = SONG(COLEMAK_SOUND); | ||
178 | float tone_plover[][2] = SONG(PLOVER_SOUND); | ||
179 | float tone_plover_gb[][2] = SONG(PLOVER_GOODBYE_SOUND); | ||
180 | float music_scale[][2] = SONG(MUSIC_SCALE_SOUND); | ||
181 | |||
182 | float tone_goodbye[][2] = SONG(GOODBYE_SOUND); | ||
183 | #endif | ||
184 | |||
185 | |||
186 | void persistant_default_layer_set(uint16_t default_layer) { | ||
187 | eeconfig_update_default_layer(default_layer); | ||
188 | default_layer_set(default_layer); | ||
189 | } | ||
190 | |||
191 | bool process_record_user(uint16_t keycode, keyrecord_t *record) { | ||
192 | switch (keycode) { | ||
193 | case QWERTY: | ||
194 | if (record->event.pressed) { | ||
195 | #ifdef AUDIO_ENABLE | ||
196 | PLAY_NOTE_ARRAY(tone_qwerty, false, 0); | ||
197 | #endif | ||
198 | persistant_default_layer_set(1UL<<_QWERTY); | ||
199 | } | ||
200 | return false; | ||
201 | break; | ||
202 | case COLEMAK: | ||
203 | if (record->event.pressed) { | ||
204 | #ifdef AUDIO_ENABLE | ||
205 | PLAY_NOTE_ARRAY(tone_colemak, false, 0); | ||
206 | #endif | ||
207 | persistant_default_layer_set(1UL<<_COLEMAK); | ||
208 | } | ||
209 | return false; | ||
210 | break; | ||
211 | case DVORAK: | ||
212 | if (record->event.pressed) { | ||
213 | #ifdef AUDIO_ENABLE | ||
214 | PLAY_NOTE_ARRAY(tone_dvorak, false, 0); | ||
215 | #endif | ||
216 | persistant_default_layer_set(1UL<<_DVORAK); | ||
217 | } | ||
218 | return false; | ||
219 | break; | ||
220 | case LOWER: | ||
221 | if (record->event.pressed) { | ||
222 | layer_on(_LOWER); | ||
223 | update_tri_layer(_LOWER, _RAISE, _ADJUST); | ||
224 | } else { | ||
225 | layer_off(_LOWER); | ||
226 | update_tri_layer(_LOWER, _RAISE, _ADJUST); | ||
227 | } | ||
228 | return false; | ||
229 | break; | ||
230 | case RAISE: | ||
231 | if (record->event.pressed) { | ||
232 | layer_on(_RAISE); | ||
233 | update_tri_layer(_LOWER, _RAISE, _ADJUST); | ||
234 | } else { | ||
235 | layer_off(_RAISE); | ||
236 | update_tri_layer(_LOWER, _RAISE, _ADJUST); | ||
237 | } | ||
238 | return false; | ||
239 | break; | ||
240 | case BACKLIT: | ||
241 | if (record->event.pressed) { | ||
242 | register_code(KC_RSFT); | ||
243 | #ifdef BACKLIGHT_ENABLE | ||
244 | backlight_step(); | ||
245 | #endif | ||
246 | } else { | ||
247 | unregister_code(KC_RSFT); | ||
248 | } | ||
249 | return false; | ||
250 | break; | ||
251 | case PLOVER: | ||
252 | if (record->event.pressed) { | ||
253 | #ifdef AUDIO_ENABLE | ||
254 | stop_all_notes(); | ||
255 | PLAY_NOTE_ARRAY(tone_plover, false, 0); | ||
256 | #endif | ||
257 | layer_off(_RAISE); | ||
258 | layer_off(_LOWER); | ||
259 | layer_off(_ADJUST); | ||
260 | layer_on(_PLOVER); | ||
261 | if (!eeconfig_is_enabled()) { | ||
262 | eeconfig_init(); | ||
263 | } | ||
264 | keymap_config.raw = eeconfig_read_keymap(); | ||
265 | keymap_config.nkro = 1; | ||
266 | eeconfig_update_keymap(keymap_config.raw); | ||
267 | } | ||
268 | return false; | ||
269 | break; | ||
270 | case EXT_PLV: | ||
271 | if (record->event.pressed) { | ||
272 | #ifdef AUDIO_ENABLE | ||
273 | PLAY_NOTE_ARRAY(tone_plover_gb, false, 0); | ||
274 | #endif | ||
275 | layer_off(_PLOVER); | ||
276 | } | ||
277 | return false; | ||
278 | break; | ||
279 | } | ||
280 | return true; | ||
281 | } | ||
282 | |||
283 | void matrix_init_user(void) { | ||
284 | #ifdef AUDIO_ENABLE | ||
285 | startup_user(); | ||
286 | #endif | ||
287 | } | ||
288 | |||
289 | #ifdef AUDIO_ENABLE | ||
290 | |||
291 | void startup_user() | ||
292 | { | ||
293 | _delay_ms(20); // gets rid of tick | ||
294 | PLAY_NOTE_ARRAY(tone_startup, false, 0); | ||
295 | } | ||
296 | |||
297 | void shutdown_user() | ||
298 | { | ||
299 | PLAY_NOTE_ARRAY(tone_goodbye, false, 0); | ||
300 | _delay_ms(150); | ||
301 | stop_all_notes(); | ||
302 | } | ||
303 | |||
304 | void music_on_user(void) | ||
305 | { | ||
306 | music_scale_user(); | ||
307 | } | ||
308 | |||
309 | void music_scale_user(void) | ||
310 | { | ||
311 | PLAY_NOTE_ARRAY(music_scale, false, 0); | ||
312 | } | ||
313 | |||
314 | #endif | ||
diff --git a/keyboards/planck/keymaps/thermal_printer/readme.md b/keyboards/planck/keymaps/thermal_printer/readme.md new file mode 100644 index 000000000..de9680b49 --- /dev/null +++ b/keyboards/planck/keymaps/thermal_printer/readme.md | |||
@@ -0,0 +1,2 @@ | |||
1 | # The Default Planck Layout | ||
2 | |||
diff --git a/quantum/keymap.h b/quantum/keymap.h index a01bbfbd1..ae56d16c7 100644 --- a/quantum/keymap.h +++ b/quantum/keymap.h | |||
@@ -178,6 +178,10 @@ enum quantum_keycodes { | |||
178 | // Right shift, close paren | 178 | // Right shift, close paren |
179 | KC_RSPC, | 179 | KC_RSPC, |
180 | 180 | ||
181 | // Printing | ||
182 | PRINT_ON, | ||
183 | PRINT_OFF, | ||
184 | |||
181 | // always leave at the end | 185 | // always leave at the end |
182 | SAFE_RANGE | 186 | SAFE_RANGE |
183 | }; | 187 | }; |
diff --git a/quantum/light_ws2812.c b/quantum/light_ws2812.c index 401845e85..497543339 100755 --- a/quantum/light_ws2812.c +++ b/quantum/light_ws2812.c | |||
@@ -16,6 +16,122 @@ | |||
16 | #include <util/delay.h> | 16 | #include <util/delay.h> |
17 | #include "debug.h" | 17 | #include "debug.h" |
18 | 18 | ||
19 | #define RGBW_BB_TWI 1 | ||
20 | |||
21 | #ifdef RGBW_BB_TWI | ||
22 | |||
23 | // Port for the I2C | ||
24 | #define I2C_DDR DDRD | ||
25 | #define I2C_PIN PIND | ||
26 | #define I2C_PORT PORTD | ||
27 | |||
28 | // Pins to be used in the bit banging | ||
29 | #define I2C_CLK 0 | ||
30 | #define I2C_DAT 1 | ||
31 | |||
32 | #define I2C_DATA_HI()\ | ||
33 | I2C_DDR &= ~ (1 << I2C_DAT);\ | ||
34 | I2C_PORT |= (1 << I2C_DAT); | ||
35 | #define I2C_DATA_LO()\ | ||
36 | I2C_DDR |= (1 << I2C_DAT);\ | ||
37 | I2C_PORT &= ~ (1 << I2C_DAT); | ||
38 | |||
39 | #define I2C_CLOCK_HI()\ | ||
40 | I2C_DDR &= ~ (1 << I2C_CLK);\ | ||
41 | I2C_PORT |= (1 << I2C_CLK); | ||
42 | #define I2C_CLOCK_LO()\ | ||
43 | I2C_DDR |= (1 << I2C_CLK);\ | ||
44 | I2C_PORT &= ~ (1 << I2C_CLK); | ||
45 | |||
46 | #define I2C_DELAY 1 | ||
47 | |||
48 | void I2C_WriteBit(unsigned char c) | ||
49 | { | ||
50 | if (c > 0) | ||
51 | { | ||
52 | I2C_DATA_HI(); | ||
53 | } | ||
54 | else | ||
55 | { | ||
56 | I2C_DATA_LO(); | ||
57 | } | ||
58 | |||
59 | I2C_CLOCK_HI(); | ||
60 | _delay_us(I2C_DELAY); | ||
61 | |||
62 | I2C_CLOCK_LO(); | ||
63 | _delay_us(I2C_DELAY); | ||
64 | |||
65 | if (c > 0) | ||
66 | { | ||
67 | I2C_DATA_LO(); | ||
68 | } | ||
69 | |||
70 | _delay_us(I2C_DELAY); | ||
71 | } | ||
72 | |||
73 | // Inits bitbanging port, must be called before using the functions below | ||
74 | // | ||
75 | void I2C_Init() | ||
76 | { | ||
77 | I2C_PORT &= ~ ((1 << I2C_DAT) | (1 << I2C_CLK)); | ||
78 | |||
79 | I2C_CLOCK_HI(); | ||
80 | I2C_DATA_HI(); | ||
81 | |||
82 | _delay_us(I2C_DELAY); | ||
83 | } | ||
84 | |||
85 | // Send a START Condition | ||
86 | // | ||
87 | void I2C_Start() | ||
88 | { | ||
89 | // set both to high at the same time | ||
90 | I2C_DDR &= ~ ((1 << I2C_DAT) | (1 << I2C_CLK)); | ||
91 | _delay_us(I2C_DELAY); | ||
92 | |||
93 | I2C_DATA_LO(); | ||
94 | _delay_us(I2C_DELAY); | ||
95 | |||
96 | I2C_CLOCK_LO(); | ||
97 | _delay_us(I2C_DELAY); | ||
98 | } | ||
99 | |||
100 | // Send a STOP Condition | ||
101 | // | ||
102 | void I2C_Stop() | ||
103 | { | ||
104 | I2C_CLOCK_HI(); | ||
105 | _delay_us(I2C_DELAY); | ||
106 | |||
107 | I2C_DATA_HI(); | ||
108 | _delay_us(I2C_DELAY); | ||
109 | } | ||
110 | |||
111 | // write a byte to the I2C slave device | ||
112 | // | ||
113 | unsigned char I2C_Write(unsigned char c) | ||
114 | { | ||
115 | for (char i = 0; i < 8; i++) | ||
116 | { | ||
117 | I2C_WriteBit(c & 128); | ||
118 | |||
119 | c <<= 1; | ||
120 | } | ||
121 | |||
122 | |||
123 | I2C_WriteBit(0); | ||
124 | _delay_us(I2C_DELAY); | ||
125 | _delay_us(I2C_DELAY); | ||
126 | |||
127 | // _delay_us(I2C_DELAY); | ||
128 | //return I2C_ReadBit(); | ||
129 | return 0; | ||
130 | } | ||
131 | |||
132 | |||
133 | #endif | ||
134 | |||
19 | // Setleds for standard RGB | 135 | // Setleds for standard RGB |
20 | void inline ws2812_setleds(struct cRGB *ledarray, uint16_t leds) | 136 | void inline ws2812_setleds(struct cRGB *ledarray, uint16_t leds) |
21 | { | 137 | { |
@@ -36,12 +152,35 @@ void inline ws2812_setleds_pin(struct cRGB *ledarray, uint16_t leds, uint8_t pin | |||
36 | // Setleds for SK6812RGBW | 152 | // Setleds for SK6812RGBW |
37 | void inline ws2812_setleds_rgbw(struct cRGBW *ledarray, uint16_t leds) | 153 | void inline ws2812_setleds_rgbw(struct cRGBW *ledarray, uint16_t leds) |
38 | { | 154 | { |
155 | |||
156 | #ifdef RGBW_BB_TWI | ||
157 | cli(); | ||
158 | TWCR = 0; | ||
159 | I2C_Init(); | ||
160 | I2C_Start(); | ||
161 | I2C_Write(0x84); | ||
162 | uint16_t datlen = leds<<2; | ||
163 | uint8_t curbyte; | ||
164 | uint8_t * data = (uint8_t*)ledarray; | ||
165 | while (datlen--) { | ||
166 | curbyte=*data++; | ||
167 | I2C_Write(curbyte); | ||
168 | } | ||
169 | I2C_Stop(); | ||
170 | sei(); | ||
171 | #else | ||
172 | _delay_us(80); | ||
173 | #endif | ||
174 | |||
175 | |||
39 | // ws2812_DDRREG |= _BV(ws2812_pin); // Enable DDR | 176 | // ws2812_DDRREG |= _BV(ws2812_pin); // Enable DDR |
40 | // new universal format (DDR) | 177 | // new universal format (DDR) |
41 | _SFR_IO8((RGB_DI_PIN >> 4) + 1) |= _BV(RGB_DI_PIN & 0xF); | 178 | _SFR_IO8((RGB_DI_PIN >> 4) + 1) |= _BV(RGB_DI_PIN & 0xF); |
42 | 179 | ||
43 | ws2812_sendarray_mask((uint8_t*)ledarray,leds<<2,_BV(RGB_DI_PIN & 0xF)); | 180 | ws2812_sendarray_mask((uint8_t*)ledarray,leds<<2,_BV(RGB_DI_PIN & 0xF)); |
44 | _delay_us(80); | 181 | |
182 | |||
183 | |||
45 | } | 184 | } |
46 | 185 | ||
47 | void ws2812_sendarray(uint8_t *data,uint16_t datlen) | 186 | void ws2812_sendarray(uint8_t *data,uint16_t datlen) |
@@ -123,7 +262,7 @@ void inline ws2812_sendarray_mask(uint8_t *data,uint16_t datlen,uint8_t maskhi) | |||
123 | cli(); | 262 | cli(); |
124 | 263 | ||
125 | while (datlen--) { | 264 | while (datlen--) { |
126 | curbyte=*data++; | 265 | curbyte=(*data++); |
127 | 266 | ||
128 | asm volatile( | 267 | asm volatile( |
129 | " ldi %0,8 \n\t" | 268 | " ldi %0,8 \n\t" |
diff --git a/quantum/light_ws2812.h b/quantum/light_ws2812.h index 54eef22d9..576c3bc48 100755 --- a/quantum/light_ws2812.h +++ b/quantum/light_ws2812.h | |||
@@ -16,6 +16,13 @@ | |||
16 | #include <avr/io.h> | 16 | #include <avr/io.h> |
17 | #include <avr/interrupt.h> | 17 | #include <avr/interrupt.h> |
18 | //#include "ws2812_config.h" | 18 | //#include "ws2812_config.h" |
19 | #include "i2cmaster.h" | ||
20 | |||
21 | #define LIGHT_I2C 1 | ||
22 | #define LIGHT_I2C_ADDR 0x84 | ||
23 | #define LIGHT_I2C_ADDR_WRITE ( (LIGHT_I2C_ADDR<<1) | I2C_WRITE ) | ||
24 | #define LIGHT_I2C_ADDR_READ ( (LIGHT_I2C_ADDR<<1) | I2C_READ ) | ||
25 | |||
19 | 26 | ||
20 | /* | 27 | /* |
21 | * Structure of the LED array | 28 | * Structure of the LED array |
diff --git a/quantum/process_keycode/process_printer.c b/quantum/process_keycode/process_printer.c new file mode 100644 index 000000000..2e11dd366 --- /dev/null +++ b/quantum/process_keycode/process_printer.c | |||
@@ -0,0 +1,254 @@ | |||
1 | #include "process_printer.h" | ||
2 | #include "action_util.h" | ||
3 | |||
4 | bool printing_enabled = false; | ||
5 | uint8_t character_shift = 0; | ||
6 | |||
7 | void enabled_printing() { | ||
8 | printing_enabled = true; | ||
9 | serial_init(); | ||
10 | } | ||
11 | |||
12 | void disable_printing() { | ||
13 | printing_enabled = false; | ||
14 | } | ||
15 | |||
16 | uint8_t shifted_numbers[10] = {0x21, 0x40, 0x23, 0x24, 0x25, 0x5E, 0x26, 0x2A, 0x28, 0x29}; | ||
17 | |||
18 | // uint8_t keycode_to_ascii[0xFF][2]; | ||
19 | |||
20 | // keycode_to_ascii[KC_MINS] = {0x2D, 0x5F}; | ||
21 | |||
22 | void print_char(char c) { | ||
23 | USB_Disable(); | ||
24 | serial_send(c); | ||
25 | USB_Init(); | ||
26 | } | ||
27 | |||
28 | void print_box_string(uint8_t text[]) { | ||
29 | uint8_t len = strlen(text); | ||
30 | uint8_t out[len * 3 + 8]; | ||
31 | out[0] = 0xDA; | ||
32 | for (uint8_t i = 0; i < len; i++) { | ||
33 | out[i+1] = 0xC4; | ||
34 | } | ||
35 | out[len + 1] = 0xBF; | ||
36 | out[len + 2] = '\n'; | ||
37 | |||
38 | out[len + 3] = 0xB3; | ||
39 | for (uint8_t i = 0; i < len; i++) { | ||
40 | out[len + 4 + i] = text[i]; | ||
41 | } | ||
42 | out[len * 2 + 4] = 0xB3; | ||
43 | out[len * 2 + 5] = '\n'; | ||
44 | |||
45 | |||
46 | out[len * 2 + 6] = 0xC0; | ||
47 | for (uint8_t i = 0; i < len; i++) { | ||
48 | out[len * 2 + 7 + i] = 0xC4; | ||
49 | } | ||
50 | out[len * 3 + 7] = 0xD9; | ||
51 | out[len * 3 + 8] = '\n'; | ||
52 | |||
53 | print_string(out); | ||
54 | } | ||
55 | |||
56 | void print_string(char c[]) { | ||
57 | for(uint8_t i = 0; i < strlen(c); i++) | ||
58 | print_char(c[i]); | ||
59 | } | ||
60 | |||
61 | bool process_printer(uint16_t keycode, keyrecord_t *record) { | ||
62 | if (keycode == PRINT_ON) { | ||
63 | enabled_printing(); | ||
64 | return false; | ||
65 | } | ||
66 | if (keycode == PRINT_OFF) { | ||
67 | disable_printing(); | ||
68 | return false; | ||
69 | } | ||
70 | |||
71 | if (printing_enabled) { | ||
72 | switch(keycode) { | ||
73 | case KC_EXLM ... KC_RPRN: | ||
74 | case KC_UNDS: | ||
75 | case KC_PLUS: | ||
76 | case KC_LCBR: | ||
77 | case KC_RCBR: | ||
78 | case KC_PIPE: | ||
79 | case KC_TILD: | ||
80 | keycode &= 0xFF; | ||
81 | case KC_LSFT: | ||
82 | case KC_RSFT: | ||
83 | if (record->event.pressed) { | ||
84 | character_shift++; | ||
85 | } else { | ||
86 | character_shift--; | ||
87 | } | ||
88 | return false; | ||
89 | break; | ||
90 | } | ||
91 | |||
92 | switch(keycode) { | ||
93 | case KC_F1: | ||
94 | if (record->event.pressed) { | ||
95 | print_box_string("This is a line of text!"); | ||
96 | } | ||
97 | return false; | ||
98 | case KC_ESC: | ||
99 | if (record->event.pressed) { | ||
100 | print_char(0x1B); | ||
101 | } | ||
102 | return false; | ||
103 | break; | ||
104 | case KC_SPC: | ||
105 | if (record->event.pressed) { | ||
106 | print_char(0x20); | ||
107 | } | ||
108 | return false; | ||
109 | break; | ||
110 | case KC_A ... KC_Z: | ||
111 | if (record->event.pressed) { | ||
112 | if (character_shift) { | ||
113 | print_char(0x41 + (keycode - KC_A)); | ||
114 | } else { | ||
115 | print_char(0x61 + (keycode - KC_A)); | ||
116 | } | ||
117 | } | ||
118 | return false; | ||
119 | break; | ||
120 | case KC_1 ... KC_0: | ||
121 | if (record->event.pressed) { | ||
122 | if (character_shift) { | ||
123 | print_char(shifted_numbers[keycode - KC_1]); | ||
124 | } else { | ||
125 | print_char(0x30 + ((keycode - KC_1 + 1) % 10)); | ||
126 | } | ||
127 | } | ||
128 | return false; | ||
129 | break; | ||
130 | case KC_ENT: | ||
131 | if (record->event.pressed) { | ||
132 | if (character_shift) { | ||
133 | print_char(0x0C); | ||
134 | } else { | ||
135 | print_char(0x0A); | ||
136 | } | ||
137 | } | ||
138 | return false; | ||
139 | break; | ||
140 | case KC_BSPC: | ||
141 | if (record->event.pressed) { | ||
142 | if (character_shift) { | ||
143 | print_char(0x18); | ||
144 | } else { | ||
145 | print_char(0x1A); | ||
146 | } | ||
147 | } | ||
148 | return false; | ||
149 | break; | ||
150 | case KC_DOT: | ||
151 | if (record->event.pressed) { | ||
152 | if (character_shift) { | ||
153 | print_char(0x3E); | ||
154 | } else { | ||
155 | print_char(0x2E); | ||
156 | } | ||
157 | } | ||
158 | return false; | ||
159 | break; | ||
160 | case KC_COMM: | ||
161 | if (record->event.pressed) { | ||
162 | if (character_shift) { | ||
163 | print_char(0x3C); | ||
164 | } else { | ||
165 | print_char(0x2C); | ||
166 | } | ||
167 | } | ||
168 | return false; | ||
169 | break; | ||
170 | case KC_SLSH: | ||
171 | if (record->event.pressed) { | ||
172 | if (character_shift) { | ||
173 | print_char(0x3F); | ||
174 | } else { | ||
175 | print_char(0x2F); | ||
176 | } | ||
177 | } | ||
178 | return false; | ||
179 | break; | ||
180 | case KC_QUOT: | ||
181 | if (record->event.pressed) { | ||
182 | if (character_shift) { | ||
183 | print_char(0x22); | ||
184 | } else { | ||
185 | print_char(0x27); | ||
186 | } | ||
187 | } | ||
188 | return false; | ||
189 | break; | ||
190 | case KC_GRV: | ||
191 | if (record->event.pressed) { | ||
192 | if (character_shift) { | ||
193 | print_char(0x7E); | ||
194 | } else { | ||
195 | print_char(0x60); | ||
196 | } | ||
197 | } | ||
198 | return false; | ||
199 | break; | ||
200 | case KC_MINS: | ||
201 | if (record->event.pressed) { | ||
202 | if (character_shift) { | ||
203 | print_char(0x5F); | ||
204 | } else { | ||
205 | print_char(0x2D); | ||
206 | } | ||
207 | } | ||
208 | return false; | ||
209 | break; | ||
210 | case KC_EQL: | ||
211 | if (record->event.pressed) { | ||
212 | if (character_shift) { | ||
213 | print_char(0x2B); | ||
214 | } else { | ||
215 | print_char(0x3D); | ||
216 | } | ||
217 | } | ||
218 | return false; | ||
219 | break; | ||
220 | case KC_LBRC: | ||
221 | if (record->event.pressed) { | ||
222 | if (character_shift) { | ||
223 | print_char(0x7B); | ||
224 | } else { | ||
225 | print_char(0x5B); | ||
226 | } | ||
227 | } | ||
228 | return false; | ||
229 | break; | ||
230 | case KC_RBRC: | ||
231 | if (record->event.pressed) { | ||
232 | if (character_shift) { | ||
233 | print_char(0x7D); | ||
234 | } else { | ||
235 | print_char(0x5D); | ||
236 | } | ||
237 | } | ||
238 | return false; | ||
239 | break; | ||
240 | case KC_BSLS: | ||
241 | if (record->event.pressed) { | ||
242 | if (character_shift) { | ||
243 | print_char(0x7C); | ||
244 | } else { | ||
245 | print_char(0x5C); | ||
246 | } | ||
247 | } | ||
248 | return false; | ||
249 | break; | ||
250 | } | ||
251 | } | ||
252 | return true; | ||
253 | |||
254 | } \ No newline at end of file | ||
diff --git a/quantum/process_keycode/process_printer.h b/quantum/process_keycode/process_printer.h new file mode 100644 index 000000000..fdd36d75a --- /dev/null +++ b/quantum/process_keycode/process_printer.h | |||
@@ -0,0 +1,8 @@ | |||
1 | #ifndef PROCESS_PRINTER_H | ||
2 | #define PROCESS_PRINTER_H | ||
3 | |||
4 | #include "quantum.h" | ||
5 | |||
6 | #include "protocol/serial.h" | ||
7 | |||
8 | #endif \ No newline at end of file | ||
diff --git a/quantum/process_keycode/process_printer_bb.c b/quantum/process_keycode/process_printer_bb.c new file mode 100644 index 000000000..1924d0377 --- /dev/null +++ b/quantum/process_keycode/process_printer_bb.c | |||
@@ -0,0 +1,260 @@ | |||
1 | #include "process_printer.h" | ||
2 | #include "action_util.h" | ||
3 | |||
4 | bool printing_enabled = false; | ||
5 | uint8_t character_shift = 0; | ||
6 | |||
7 | #define SERIAL_PIN_DDR DDRD | ||
8 | #define SERIAL_PIN_PORT PORTD | ||
9 | #define SERIAL_PIN_MASK _BV(PD3) | ||
10 | #define SERIAL_DELAY 52 | ||
11 | |||
12 | inline static | ||
13 | void serial_delay(void) { | ||
14 | _delay_us(SERIAL_DELAY); | ||
15 | } | ||
16 | |||
17 | inline static | ||
18 | void serial_high(void) { | ||
19 | SERIAL_PIN_PORT |= SERIAL_PIN_MASK; | ||
20 | } | ||
21 | |||
22 | inline static | ||
23 | void serial_low(void) { | ||
24 | SERIAL_PIN_PORT &= ~SERIAL_PIN_MASK; | ||
25 | } | ||
26 | |||
27 | inline static | ||
28 | void serial_output(void) { | ||
29 | SERIAL_PIN_DDR |= SERIAL_PIN_MASK; | ||
30 | } | ||
31 | |||
32 | |||
33 | void enabled_printing() { | ||
34 | printing_enabled = true; | ||
35 | serial_output(); | ||
36 | serial_high(); | ||
37 | } | ||
38 | |||
39 | void disable_printing() { | ||
40 | printing_enabled = false; | ||
41 | } | ||
42 | |||
43 | uint8_t shifted_numbers[10] = {0x21, 0x40, 0x23, 0x24, 0x25, 0x5E, 0x26, 0x2A, 0x28, 0x29}; | ||
44 | |||
45 | // uint8_t keycode_to_ascii[0xFF][2]; | ||
46 | |||
47 | // keycode_to_ascii[KC_MINS] = {0x2D, 0x5F}; | ||
48 | |||
49 | void print_char(char c) { | ||
50 | uint8_t b = 8; | ||
51 | serial_output(); | ||
52 | while( b-- ) { | ||
53 | if(c & (1 << b)) { | ||
54 | serial_high(); | ||
55 | } else { | ||
56 | serial_low(); | ||
57 | } | ||
58 | serial_delay(); | ||
59 | } | ||
60 | } | ||
61 | |||
62 | void print_string(char c[]) { | ||
63 | for(uint8_t i = 0; i < strlen(c); i++) | ||
64 | print_char(c[i]); | ||
65 | } | ||
66 | |||
67 | bool process_printer(uint16_t keycode, keyrecord_t *record) { | ||
68 | if (keycode == PRINT_ON) { | ||
69 | enabled_printing(); | ||
70 | return false; | ||
71 | } | ||
72 | if (keycode == PRINT_OFF) { | ||
73 | disable_printing(); | ||
74 | return false; | ||
75 | } | ||
76 | |||
77 | if (printing_enabled) { | ||
78 | switch(keycode) { | ||
79 | case KC_EXLM ... KC_RPRN: | ||
80 | case KC_UNDS: | ||
81 | case KC_PLUS: | ||
82 | case KC_LCBR: | ||
83 | case KC_RCBR: | ||
84 | case KC_PIPE: | ||
85 | case KC_TILD: | ||
86 | keycode &= 0xFF; | ||
87 | case KC_LSFT: | ||
88 | case KC_RSFT: | ||
89 | if (record->event.pressed) { | ||
90 | character_shift++; | ||
91 | } else { | ||
92 | character_shift--; | ||
93 | } | ||
94 | return false; | ||
95 | break; | ||
96 | } | ||
97 | |||
98 | switch(keycode) { | ||
99 | case KC_F1: | ||
100 | if (record->event.pressed) { | ||
101 | print_string("This is a line of text!\n\n\n"); | ||
102 | } | ||
103 | return false; | ||
104 | case KC_ESC: | ||
105 | if (record->event.pressed) { | ||
106 | print_char(0x1B); | ||
107 | } | ||
108 | return false; | ||
109 | break; | ||
110 | case KC_SPC: | ||
111 | if (record->event.pressed) { | ||
112 | print_char(0x20); | ||
113 | } | ||
114 | return false; | ||
115 | break; | ||
116 | case KC_A ... KC_Z: | ||
117 | if (record->event.pressed) { | ||
118 | if (character_shift) { | ||
119 | print_char(0x41 + (keycode - KC_A)); | ||
120 | } else { | ||
121 | print_char(0x61 + (keycode - KC_A)); | ||
122 | } | ||
123 | } | ||
124 | return false; | ||
125 | break; | ||
126 | case KC_1 ... KC_0: | ||
127 | if (record->event.pressed) { | ||
128 | if (character_shift) { | ||
129 | print_char(shifted_numbers[keycode - KC_1]); | ||
130 | } else { | ||
131 | print_char(0x30 + ((keycode - KC_1 + 1) % 10)); | ||
132 | } | ||
133 | } | ||
134 | return false; | ||
135 | break; | ||
136 | case KC_ENT: | ||
137 | if (record->event.pressed) { | ||
138 | if (character_shift) { | ||
139 | print_char(0x0C); | ||
140 | } else { | ||
141 | print_char(0x0A); | ||
142 | } | ||
143 | } | ||
144 | return false; | ||
145 | break; | ||
146 | case KC_BSPC: | ||
147 | if (record->event.pressed) { | ||
148 | if (character_shift) { | ||
149 | print_char(0x18); | ||
150 | } else { | ||
151 | print_char(0x1A); | ||
152 | } | ||
153 | } | ||
154 | return false; | ||
155 | break; | ||
156 | case KC_DOT: | ||
157 | if (record->event.pressed) { | ||
158 | if (character_shift) { | ||
159 | print_char(0x3E); | ||
160 | } else { | ||
161 | print_char(0x2E); | ||
162 | } | ||
163 | } | ||
164 | return false; | ||
165 | break; | ||
166 | case KC_COMM: | ||
167 | if (record->event.pressed) { | ||
168 | if (character_shift) { | ||
169 | print_char(0x3C); | ||
170 | } else { | ||
171 | print_char(0x2C); | ||
172 | } | ||
173 | } | ||
174 | return false; | ||
175 | break; | ||
176 | case KC_SLSH: | ||
177 | if (record->event.pressed) { | ||
178 | if (character_shift) { | ||
179 | print_char(0x3F); | ||
180 | } else { | ||
181 | print_char(0x2F); | ||
182 | } | ||
183 | } | ||
184 | return false; | ||
185 | break; | ||
186 | case KC_QUOT: | ||
187 | if (record->event.pressed) { | ||
188 | if (character_shift) { | ||
189 | print_char(0x22); | ||
190 | } else { | ||
191 | print_char(0x27); | ||
192 | } | ||
193 | } | ||
194 | return false; | ||
195 | break; | ||
196 | case KC_GRV: | ||
197 | if (record->event.pressed) { | ||
198 | if (character_shift) { | ||
199 | print_char(0x7E); | ||
200 | } else { | ||
201 | print_char(0x60); | ||
202 | } | ||
203 | } | ||
204 | return false; | ||
205 | break; | ||
206 | case KC_MINS: | ||
207 | if (record->event.pressed) { | ||
208 | if (character_shift) { | ||
209 | print_char(0x5F); | ||
210 | } else { | ||
211 | print_char(0x2D); | ||
212 | } | ||
213 | } | ||
214 | return false; | ||
215 | break; | ||
216 | case KC_EQL: | ||
217 | if (record->event.pressed) { | ||
218 | if (character_shift) { | ||
219 | print_char(0x2B); | ||
220 | } else { | ||
221 | print_char(0x3D); | ||
222 | } | ||
223 | } | ||
224 | return false; | ||
225 | break; | ||
226 | case KC_LBRC: | ||
227 | if (record->event.pressed) { | ||
228 | if (character_shift) { | ||
229 | print_char(0x7B); | ||
230 | } else { | ||
231 | print_char(0x5B); | ||
232 | } | ||
233 | } | ||
234 | return false; | ||
235 | break; | ||
236 | case KC_RBRC: | ||
237 | if (record->event.pressed) { | ||
238 | if (character_shift) { | ||
239 | print_char(0x7D); | ||
240 | } else { | ||
241 | print_char(0x5D); | ||
242 | } | ||
243 | } | ||
244 | return false; | ||
245 | break; | ||
246 | case KC_BSLS: | ||
247 | if (record->event.pressed) { | ||
248 | if (character_shift) { | ||
249 | print_char(0x7C); | ||
250 | } else { | ||
251 | print_char(0x5C); | ||
252 | } | ||
253 | } | ||
254 | return false; | ||
255 | break; | ||
256 | } | ||
257 | } | ||
258 | return true; | ||
259 | |||
260 | } \ No newline at end of file | ||
diff --git a/quantum/quantum.c b/quantum/quantum.c index 098312e6e..b8a81a76b 100644 --- a/quantum/quantum.c +++ b/quantum/quantum.c | |||
@@ -129,6 +129,8 @@ bool process_record_quantum(keyrecord_t *record) { | |||
129 | #ifdef UCIS_ENABLE | 129 | #ifdef UCIS_ENABLE |
130 | process_ucis(keycode, record) && | 130 | process_ucis(keycode, record) && |
131 | #endif | 131 | #endif |
132 | #ifdef PRINTING_ENABLE | ||
133 | process_printer(keycode, record) && | ||
132 | #ifdef UNICODEMAP_ENABLE | 134 | #ifdef UNICODEMAP_ENABLE |
133 | process_unicode_map(keycode, record) && | 135 | process_unicode_map(keycode, record) && |
134 | #endif | 136 | #endif |
diff --git a/quantum/quantum.h b/quantum/quantum.h index 0c6046649..06a2e049d 100644 --- a/quantum/quantum.h +++ b/quantum/quantum.h | |||
@@ -59,6 +59,10 @@ extern uint32_t default_layer_state; | |||
59 | 59 | ||
60 | #include "process_tap_dance.h" | 60 | #include "process_tap_dance.h" |
61 | 61 | ||
62 | #ifdef PRINTING_ENABLE | ||
63 | #include "process_printer.h" | ||
64 | #endif | ||
65 | |||
62 | #define SEND_STRING(str) send_string(PSTR(str)) | 66 | #define SEND_STRING(str) send_string(PSTR(str)) |
63 | void send_string(const char *str); | 67 | void send_string(const char *str); |
64 | 68 | ||
diff --git a/quantum/rgblight.c b/quantum/rgblight.c index d550c5866..221a16402 100644 --- a/quantum/rgblight.c +++ b/quantum/rgblight.c | |||
@@ -69,7 +69,11 @@ const uint8_t RGBLED_KNIGHT_INTERVALS[] PROGMEM = {100, 50, 20}; | |||
69 | 69 | ||
70 | rgblight_config_t rgblight_config; | 70 | rgblight_config_t rgblight_config; |
71 | rgblight_config_t inmem_config; | 71 | rgblight_config_t inmem_config; |
72 | struct cRGB led[RGBLED_NUM]; | 72 | #ifdef RGBW |
73 | struct cRGBW led[RGBLED_NUM]; | ||
74 | #else | ||
75 | struct cRGB led[RGBLED_NUM]; | ||
76 | #endif | ||
73 | uint8_t rgblight_inited = 0; | 77 | uint8_t rgblight_inited = 0; |
74 | 78 | ||
75 | 79 | ||
@@ -351,14 +355,22 @@ void rgblight_setrgb(uint8_t r, uint8_t g, uint8_t b) { | |||
351 | 355 | ||
352 | void rgblight_set(void) { | 356 | void rgblight_set(void) { |
353 | if (rgblight_config.enable) { | 357 | if (rgblight_config.enable) { |
354 | ws2812_setleds(led, RGBLED_NUM); | 358 | #ifdef RGBW |
359 | ws2812_setleds_rgbw(led, RGBLED_NUM); | ||
360 | #else | ||
361 | ws2812_setleds(led, RGBLED_NUM); | ||
362 | #endif | ||
355 | } else { | 363 | } else { |
356 | for (uint8_t i = 0; i < RGBLED_NUM; i++) { | 364 | for (uint8_t i = 0; i < RGBLED_NUM; i++) { |
357 | led[i].r = 0; | 365 | led[i].r = 0; |
358 | led[i].g = 0; | 366 | led[i].g = 0; |
359 | led[i].b = 0; | 367 | led[i].b = 0; |
360 | } | 368 | } |
361 | ws2812_setleds(led, RGBLED_NUM); | 369 | #ifdef RGBW |
370 | ws2812_setleds_rgbw(led, RGBLED_NUM); | ||
371 | #else | ||
372 | ws2812_setleds(led, RGBLED_NUM); | ||
373 | #endif | ||
362 | } | 374 | } |
363 | } | 375 | } |
364 | 376 | ||
diff --git a/quantum/rgblight.h b/quantum/rgblight.h index 17f04ffcf..efc685f31 100644 --- a/quantum/rgblight.h +++ b/quantum/rgblight.h | |||
@@ -1,6 +1,7 @@ | |||
1 | #ifndef RGBLIGHT_H | 1 | #ifndef RGBLIGHT_H |
2 | #define RGBLIGHT_H | 2 | #define RGBLIGHT_H |
3 | 3 | ||
4 | #define RGBW 1 | ||
4 | 5 | ||
5 | #if !defined(AUDIO_ENABLE) && defined(RGBLIGHT_TIMER) | 6 | #if !defined(AUDIO_ENABLE) && defined(RGBLIGHT_TIMER) |
6 | #define RGBLIGHT_MODES 23 | 7 | #define RGBLIGHT_MODES 23 |