diff options
| author | Nick Brassel <nick@tzarc.org> | 2022-11-06 00:15:55 +1100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-11-06 00:15:55 +1100 |
| commit | 5233c69bc60aa612709e5d74a005431594612b6e (patch) | |
| tree | fd4646bac5ab7d74a791c19d69ec9a5c54ecaf46 /quantum/process_keycode/process_printer_bb.c | |
| parent | 4d33f356a62c195f5498ed2fe8dd3ea434d5a689 (diff) | |
Remove thermal printer. (#18959)
Diffstat (limited to 'quantum/process_keycode/process_printer_bb.c')
| -rw-r--r-- | quantum/process_keycode/process_printer_bb.c | 270 |
1 files changed, 0 insertions, 270 deletions
diff --git a/quantum/process_keycode/process_printer_bb.c b/quantum/process_keycode/process_printer_bb.c deleted file mode 100644 index 88a9f33994..0000000000 --- a/quantum/process_keycode/process_printer_bb.c +++ /dev/null | |||
| @@ -1,270 +0,0 @@ | |||
| 1 | /* Copyright 2016 Jack Humbert | ||
| 2 | * | ||
| 3 | * This program is free software: you can redistribute it and/or modify | ||
| 4 | * it under the terms of the GNU General Public License as published by | ||
| 5 | * the Free Software Foundation, either version 2 of the License, or | ||
| 6 | * (at your option) any later version. | ||
| 7 | * | ||
| 8 | * This program is distributed in the hope that it will be useful, | ||
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 11 | * GNU General Public License for more details. | ||
| 12 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 16 | |||
| 17 | #include "process_printer.h" | ||
| 18 | #include "action_util.h" | ||
| 19 | |||
| 20 | bool printing_enabled = false; | ||
| 21 | uint8_t character_shift = 0; | ||
| 22 | |||
| 23 | #define SERIAL_PIN_DDR DDRD | ||
| 24 | #define SERIAL_PIN_PORT PORTD | ||
| 25 | #define SERIAL_PIN_MASK _BV(PD3) | ||
| 26 | #define SERIAL_DELAY 52 | ||
| 27 | |||
| 28 | inline static void serial_delay(void) { | ||
| 29 | _delay_us(SERIAL_DELAY); | ||
| 30 | } | ||
| 31 | |||
| 32 | inline static void serial_high(void) { | ||
| 33 | SERIAL_PIN_PORT |= SERIAL_PIN_MASK; | ||
| 34 | } | ||
| 35 | |||
| 36 | inline static void serial_low(void) { | ||
| 37 | SERIAL_PIN_PORT &= ~SERIAL_PIN_MASK; | ||
| 38 | } | ||
| 39 | |||
| 40 | inline static void serial_output(void) { | ||
| 41 | SERIAL_PIN_DDR |= SERIAL_PIN_MASK; | ||
| 42 | } | ||
| 43 | |||
| 44 | void enable_printing() { | ||
| 45 | printing_enabled = true; | ||
| 46 | serial_output(); | ||
| 47 | serial_high(); | ||
| 48 | } | ||
| 49 | |||
| 50 | void disable_printing() { | ||
| 51 | printing_enabled = false; | ||
| 52 | } | ||
| 53 | |||
| 54 | uint8_t shifted_numbers[10] = {0x21, 0x40, 0x23, 0x24, 0x25, 0x5E, 0x26, 0x2A, 0x28, 0x29}; | ||
| 55 | |||
| 56 | // uint8_t keycode_to_ascii[0xFF][2]; | ||
| 57 | |||
| 58 | // keycode_to_ascii[KC_MINUS] = {0x2D, 0x5F}; | ||
| 59 | |||
| 60 | void print_char(char c) { | ||
| 61 | uint8_t b = 8; | ||
| 62 | serial_output(); | ||
| 63 | while (b--) { | ||
| 64 | if (c & (1 << b)) { | ||
| 65 | serial_high(); | ||
| 66 | } else { | ||
| 67 | serial_low(); | ||
| 68 | } | ||
| 69 | serial_delay(); | ||
| 70 | } | ||
| 71 | } | ||
| 72 | |||
| 73 | void print_string(char c[]) { | ||
| 74 | for (uint8_t i = 0; i < strlen(c); i++) | ||
| 75 | print_char(c[i]); | ||
| 76 | } | ||
| 77 | |||
| 78 | bool process_printer(uint16_t keycode, keyrecord_t *record) { | ||
| 79 | if (keycode == PRINT_ON) { | ||
| 80 | enable_printing(); | ||
| 81 | return false; | ||
| 82 | } | ||
| 83 | if (keycode == PRINT_OFF) { | ||
| 84 | disable_printing(); | ||
| 85 | return false; | ||
| 86 | } | ||
| 87 | |||
| 88 | if (printing_enabled) { | ||
| 89 | switch (keycode) { | ||
| 90 | case KC_EXLM ... KC_RPRN: | ||
| 91 | case KC_UNDS: | ||
| 92 | case KC_PLUS: | ||
| 93 | case KC_LCBR: | ||
| 94 | case KC_RCBR: | ||
| 95 | case KC_PIPE: | ||
| 96 | case KC_TILD: | ||
| 97 | keycode &= 0xFF; | ||
| 98 | case KC_LEFT_SHIFT: | ||
| 99 | case KC_RIGHT_SHIFT: | ||
| 100 | if (record->event.pressed) { | ||
| 101 | character_shift++; | ||
| 102 | } else { | ||
| 103 | character_shift--; | ||
| 104 | } | ||
| 105 | return false; | ||
| 106 | break; | ||
| 107 | } | ||
| 108 | |||
| 109 | switch (keycode) { | ||
| 110 | case KC_F1: | ||
| 111 | if (record->event.pressed) { | ||
| 112 | print_string("This is a line of text!\n\n\n"); | ||
| 113 | } | ||
| 114 | return false; | ||
| 115 | case KC_ESCAPE: | ||
| 116 | if (record->event.pressed) { | ||
| 117 | print_char(0x1B); | ||
| 118 | } | ||
| 119 | return false; | ||
| 120 | break; | ||
| 121 | case KC_SPACE: | ||
| 122 | if (record->event.pressed) { | ||
| 123 | print_char(0x20); | ||
| 124 | } | ||
| 125 | return false; | ||
| 126 | break; | ||
| 127 | case KC_A ... KC_Z: | ||
| 128 | if (record->event.pressed) { | ||
| 129 | if (character_shift) { | ||
| 130 | print_char(0x41 + (keycode - KC_A)); | ||
| 131 | } else { | ||
| 132 | print_char(0x61 + (keycode - KC_A)); | ||
| 133 | } | ||
| 134 | } | ||
| 135 | return false; | ||
| 136 | break; | ||
| 137 | case KC_1 ... KC_0: | ||
| 138 | if (record->event.pressed) { | ||
| 139 | if (character_shift) { | ||
| 140 | print_char(shifted_numbers[keycode - KC_1]); | ||
| 141 | } else { | ||
| 142 | print_char(0x30 + ((keycode - KC_1 + 1) % 10)); | ||
| 143 | } | ||
| 144 | } | ||
| 145 | return false; | ||
| 146 | break; | ||
| 147 | case KC_ENTER: | ||
| 148 | if (record->event.pressed) { | ||
| 149 | if (character_shift) { | ||
| 150 | print_char(0x0C); | ||
| 151 | } else { | ||
| 152 | print_char(0x0A); | ||
| 153 | } | ||
| 154 | } | ||
| 155 | return false; | ||
| 156 | break; | ||
| 157 | case KC_BACKSPACE: | ||
| 158 | if (record->event.pressed) { | ||
| 159 | if (character_shift) { | ||
| 160 | print_char(0x18); | ||
| 161 | } else { | ||
| 162 | print_char(0x1A); | ||
| 163 | } | ||
| 164 | } | ||
| 165 | return false; | ||
| 166 | break; | ||
| 167 | case KC_DOT: | ||
| 168 | if (record->event.pressed) { | ||
| 169 | if (character_shift) { | ||
| 170 | print_char(0x3E); | ||
| 171 | } else { | ||
| 172 | print_char(0x2E); | ||
| 173 | } | ||
| 174 | } | ||
| 175 | return false; | ||
| 176 | break; | ||
| 177 | case KC_COMMA: | ||
| 178 | if (record->event.pressed) { | ||
| 179 | if (character_shift) { | ||
| 180 | print_char(0x3C); | ||
| 181 | } else { | ||
| 182 | print_char(0x2C); | ||
| 183 | } | ||
| 184 | } | ||
| 185 | return false; | ||
| 186 | break; | ||
| 187 | case KC_SLASH: | ||
| 188 | if (record->event.pressed) { | ||
| 189 | if (character_shift) { | ||
| 190 | print_char(0x3F); | ||
| 191 | } else { | ||
| 192 | print_char(0x2F); | ||
| 193 | } | ||
| 194 | } | ||
| 195 | return false; | ||
| 196 | break; | ||
| 197 | case KC_QUOTE: | ||
| 198 | if (record->event.pressed) { | ||
| 199 | if (character_shift) { | ||
| 200 | print_char(0x22); | ||
| 201 | } else { | ||
| 202 | print_char(0x27); | ||
| 203 | } | ||
| 204 | } | ||
| 205 | return false; | ||
| 206 | break; | ||
| 207 | case KC_GRAVE: | ||
| 208 | if (record->event.pressed) { | ||
| 209 | if (character_shift) { | ||
| 210 | print_char(0x7E); | ||
| 211 | } else { | ||
| 212 | print_char(0x60); | ||
| 213 | } | ||
| 214 | } | ||
| 215 | return false; | ||
| 216 | break; | ||
| 217 | case KC_MINUS: | ||
| 218 | if (record->event.pressed) { | ||
| 219 | if (character_shift) { | ||
| 220 | print_char(0x5F); | ||
| 221 | } else { | ||
| 222 | print_char(0x2D); | ||
| 223 | } | ||
| 224 | } | ||
| 225 | return false; | ||
| 226 | break; | ||
| 227 | case KC_EQUAL: | ||
| 228 | if (record->event.pressed) { | ||
| 229 | if (character_shift) { | ||
| 230 | print_char(0x2B); | ||
| 231 | } else { | ||
| 232 | print_char(0x3D); | ||
| 233 | } | ||
| 234 | } | ||
| 235 | return false; | ||
| 236 | break; | ||
| 237 | case KC_LEFT_BRACKET: | ||
| 238 | if (record->event.pressed) { | ||
| 239 | if (character_shift) { | ||
| 240 | print_char(0x7B); | ||
| 241 | } else { | ||
| 242 | print_char(0x5B); | ||
| 243 | } | ||
| 244 | } | ||
| 245 | return false; | ||
| 246 | break; | ||
| 247 | case KC_RIGHT_BRACKET: | ||
| 248 | if (record->event.pressed) { | ||
| 249 | if (character_shift) { | ||
| 250 | print_char(0x7D); | ||
| 251 | } else { | ||
| 252 | print_char(0x5D); | ||
| 253 | } | ||
| 254 | } | ||
| 255 | return false; | ||
| 256 | break; | ||
| 257 | case KC_BACKSLASH: | ||
| 258 | if (record->event.pressed) { | ||
| 259 | if (character_shift) { | ||
| 260 | print_char(0x7C); | ||
| 261 | } else { | ||
| 262 | print_char(0x5C); | ||
| 263 | } | ||
| 264 | } | ||
| 265 | return false; | ||
| 266 | break; | ||
| 267 | } | ||
| 268 | } | ||
| 269 | return true; | ||
| 270 | } | ||
