Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates send_string functionality, adds terminal feature #1657

Merged
merged 11 commits into from
Sep 12, 2017
Prev Previous commit
Next Next commit
[terminal] adds nop.h, documentation
  • Loading branch information
jackhumbert committed Aug 30, 2017
commit fd4c5c669c16261f4cc610959aa9bef7f3a855df
1 change: 1 addition & 0 deletions docs/_summary.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
* [Thermal Printer](feature_thermal_printer.md)
* [Stenography](stenography.md)
* [Unicode](unicode.md)
* [Terminal](feature_terminal.md)

* Reference
* [Glossary](glossary.md)
Expand Down
80 changes: 80 additions & 0 deletions docs/feature_terminal.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# Terminal

> This feature is currently *huge* at 4400 bytes, and should probably only be put on boards with a lot of memory, or for fun.

The terminal feature is a command-line-like interface designed to communicate through a text editor with keystrokes. It's beneficial to turn off auto-indent features in your editor.

To enable, stick this in your `rules.mk` or `Makefile`:

TERMINAL_ENABLE = yes

And use the `TERM_ON` and `TERM_OFF` keycodes to turn it on or off.

When enabled, a `> ` prompt will appear, where you'll be able to type, backspace (a bell will ding if you reach the beginning and audio is enabled), and hit enter to send the command. Arrow keys are currently disabled so it doesn't get confused. Moving your cursor around with the mouse is discouraged.

`#define TERMINAL_HELP` enables some other output helpers that aren't really needed with this page.

## Future ideas

* Keyboard/user-extendable commands
* Smaller footprint
* Arrow key support
* Command history
* SD card support
* LCD support for buffer display
* Keycode -> name string LUT
* Layer status
* *Analog/digital port read/write*
* RGB mode stuff
* Macro definitions
* EEPROM read/write
* Audio control

## Current commands

### `about`

Prints out the current version of QMK with a build date:

```
> about
QMK Firmware
v0.5.115-7-g80ed73-dirty
Built: 2017-08-29-20:24:44
```

### `help`

Prints out the available commands:

```
> help
commands available:
about help keycode keymap exit
```

### `keycode <layer> <row> <col>`

Prints out the keycode value of a certain layer, row, and column:

```
> keycode 0 1 0
0x29 (41)
```

### `keymap <layer>`

Prints out the entire keymap for a certain layer

```
> keymap 0
0x002b, 0x0014, 0x001a, 0x0008, 0x0015, 0x0017, 0x001c, 0x0018, 0x000c, 0x0012, 0x0013, 0x002a,
0x0029, 0x0004, 0x0016, 0x0007, 0x0009, 0x000a, 0x000b, 0x000d, 0x000e, 0x000f, 0x0033, 0x0034,
0x00e1, 0x001d, 0x001b, 0x0006, 0x0019, 0x0005, 0x0011, 0x0010, 0x0036, 0x0037, 0x0038, 0x0028,
0x5cd6, 0x00e0, 0x00e2, 0x00e3, 0x5cd4, 0x002c, 0x002c, 0x5cd5, 0x0050, 0x0051, 0x0052, 0x004f,
>
```

### `exit`

Exits the terminal - same as `TERM_OFF`.
2 changes: 0 additions & 2 deletions keyboards/planck/keymaps/default/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
TERMINAL_ENABLE = yes

ifndef QUANTUM_DIR
include ../../../../Makefile
endif
14 changes: 8 additions & 6 deletions quantum/process_keycode/process_terminal.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
bool terminal_enabled = false;
char buffer[80] = "";
char newline[2] = "\n";
char arguments[6][80];
char arguments[6][20];

__attribute__ ((weak))
const char terminal_prompt[8] = "> ";
Expand Down Expand Up @@ -82,11 +82,13 @@ void terminal_about(void) {
SEND_STRING("\n"SS_TAP(X_HOME)" Built: ");
SEND_STRING(QMK_BUILDDATE);
send_string(newline);
if (strlen(arguments[1]) != 0) {
SEND_STRING("You entered: ");
send_string(arguments[1]);
send_string(newline);
}
#ifdef TERMINAL_HELP
if (strlen(arguments[1]) != 0) {
SEND_STRING("You entered: ");
send_string(arguments[1]);
send_string(newline);
}
#endif
}

void terminal_help(void);
Expand Down
25 changes: 25 additions & 0 deletions quantum/process_keycode/process_terminal_nop.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/* Copyright 2017 Jack Humbert
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef PROCESS_TERMINAL_H
#define PROCESS_TERMINAL_H

#include "quantum.h"

#define TERM_ON KC_NO
#define TERM_OFF KC_NO

#endif
2 changes: 2 additions & 0 deletions quantum/quantum.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ extern uint32_t default_layer_state;

#ifdef TERMINAL_ENABLE
#include "process_terminal.h"
#else
#include "process_terminal_nop.h"
#endif

#define STRINGIZE(z) #z
Expand Down