1 #include "process_printer.h"
2 #include "action_util.h"
4 bool printing_enabled = false;
5 uint8_t character_shift = 0;
7 #define SERIAL_PIN_DDR DDRD
8 #define SERIAL_PIN_PORT PORTD
9 #define SERIAL_PIN_MASK _BV(PD3)
10 #define SERIAL_DELAY 52
13 void serial_delay(void) {
14 _delay_us(SERIAL_DELAY);
18 void serial_high(void) {
19 SERIAL_PIN_PORT |= SERIAL_PIN_MASK;
23 void serial_low(void) {
24 SERIAL_PIN_PORT &= ~SERIAL_PIN_MASK;
28 void serial_output(void) {
29 SERIAL_PIN_DDR |= SERIAL_PIN_MASK;
33 void enabled_printing() {
34 printing_enabled = true;
39 void disable_printing() {
40 printing_enabled = false;
43 uint8_t shifted_numbers[10] = {0x21, 0x40, 0x23, 0x24, 0x25, 0x5E, 0x26, 0x2A, 0x28, 0x29};
45 // uint8_t keycode_to_ascii[0xFF][2];
47 // keycode_to_ascii[KC_MINS] = {0x2D, 0x5F};
49 void print_char(char c) {
62 void print_string(char c[]) {
63 for(uint8_t i = 0; i < strlen(c); i++)
67 bool process_printer(uint16_t keycode, keyrecord_t *record) {
68 if (keycode == PRINT_ON) {
72 if (keycode == PRINT_OFF) {
77 if (printing_enabled) {
79 case KC_EXLM ... KC_RPRN:
89 if (record->event.pressed) {
100 if (record->event.pressed) {
101 print_string("This is a line of text!\n\n\n");
105 if (record->event.pressed) {
111 if (record->event.pressed) {
117 if (record->event.pressed) {
118 if (character_shift) {
119 print_char(0x41 + (keycode - KC_A));
121 print_char(0x61 + (keycode - KC_A));
127 if (record->event.pressed) {
128 if (character_shift) {
129 print_char(shifted_numbers[keycode - KC_1]);
131 print_char(0x30 + ((keycode - KC_1 + 1) % 10));
137 if (record->event.pressed) {
138 if (character_shift) {
147 if (record->event.pressed) {
148 if (character_shift) {
157 if (record->event.pressed) {
158 if (character_shift) {
167 if (record->event.pressed) {
168 if (character_shift) {
177 if (record->event.pressed) {
178 if (character_shift) {
187 if (record->event.pressed) {
188 if (character_shift) {
197 if (record->event.pressed) {
198 if (character_shift) {
207 if (record->event.pressed) {
208 if (character_shift) {
217 if (record->event.pressed) {
218 if (character_shift) {
227 if (record->event.pressed) {
228 if (character_shift) {
237 if (record->event.pressed) {
238 if (character_shift) {
247 if (record->event.pressed) {
248 if (character_shift) {