diff options
author | Jack Humbert <jack.humb@gmail.com> | 2016-10-16 16:03:56 -0400 |
---|---|---|
committer | Jack Humbert <jack.humb@gmail.com> | 2016-10-16 16:03:56 -0400 |
commit | a889b899e2cf52b3b7807d8a7ad39f12e0761a10 (patch) | |
tree | 8c2bf722fe4f740a1c661b8d215f5b64e4a5f27b | |
parent | 5f91fb413624781ac79db641549b9e08753c04b5 (diff) | |
download | qmk_firmware-a889b899e2cf52b3b7807d8a7ad39f12e0761a10.tar.gz qmk_firmware-a889b899e2cf52b3b7807d8a7ad39f12e0761a10.zip |
working with power limit
-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/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 |
7 files changed, 887 insertions, 0 deletions
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/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 | ||