Have you tried to develop a key input feature on your small embedded platform with a serial input? It is not so easy to implement correctly because the input methodology is using a complicated protocol known as VT100. In my recent project "Natural Tiny Shell (NT-Shell)" provides VT100 compatible terminal control features for small embedded systems. However, the middleware is still large for small embedded processors such as 8-bit MCUs, 16-bit MCUs and also for small 32-bit MCUs like Cortex-M0. This "MicroShell" middleware provides a minimal terminal control for the platforms.
core/mscore.h@0:e91b984e285d, 2017-02-05 (annotated)
- Committer:
- shintamainjp
- Date:
- Sun Feb 05 03:55:01 2017 +0000
- Revision:
- 0:e91b984e285d
first commitment.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
shintamainjp | 0:e91b984e285d | 1 | /** |
shintamainjp | 0:e91b984e285d | 2 | * @file mscore.h |
shintamainjp | 0:e91b984e285d | 3 | * @author Shinichiro Nakamura (CuBeatSystems) |
shintamainjp | 0:e91b984e285d | 4 | * =============================================================== |
shintamainjp | 0:e91b984e285d | 5 | * MicroShell (Version 0.0.1) |
shintamainjp | 0:e91b984e285d | 6 | * Copyright (c) 2016, 2017 Shinichiro Nakamura (CuBeatSystems) |
shintamainjp | 0:e91b984e285d | 7 | * =============================================================== |
shintamainjp | 0:e91b984e285d | 8 | * The MIT License : https://opensource.org/licenses/MIT |
shintamainjp | 0:e91b984e285d | 9 | * |
shintamainjp | 0:e91b984e285d | 10 | * Copyright (c) 2016, 2017 Shinichiro Nakamura (CuBeatSystems) |
shintamainjp | 0:e91b984e285d | 11 | * |
shintamainjp | 0:e91b984e285d | 12 | * Permission is hereby granted, free of charge, to any person |
shintamainjp | 0:e91b984e285d | 13 | * obtaining a copy of this software and associated documentation |
shintamainjp | 0:e91b984e285d | 14 | * files (the "Software"), to deal in the Software without |
shintamainjp | 0:e91b984e285d | 15 | * restriction, including without limitation the rights to use, |
shintamainjp | 0:e91b984e285d | 16 | * copy, modify, merge, publish, distribute, sublicense, and/or |
shintamainjp | 0:e91b984e285d | 17 | * sell copies of the Software, and to permit persons to whom the |
shintamainjp | 0:e91b984e285d | 18 | * Software is furnished to do so, subject to the following |
shintamainjp | 0:e91b984e285d | 19 | * conditions: |
shintamainjp | 0:e91b984e285d | 20 | * |
shintamainjp | 0:e91b984e285d | 21 | * The above copyright notice and this permission notice shall be |
shintamainjp | 0:e91b984e285d | 22 | * included in all copies or substantial portions of the Software. |
shintamainjp | 0:e91b984e285d | 23 | * |
shintamainjp | 0:e91b984e285d | 24 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
shintamainjp | 0:e91b984e285d | 25 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES |
shintamainjp | 0:e91b984e285d | 26 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
shintamainjp | 0:e91b984e285d | 27 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT |
shintamainjp | 0:e91b984e285d | 28 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, |
shintamainjp | 0:e91b984e285d | 29 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
shintamainjp | 0:e91b984e285d | 30 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
shintamainjp | 0:e91b984e285d | 31 | * OTHER DEALINGS IN THE SOFTWARE. |
shintamainjp | 0:e91b984e285d | 32 | */ |
shintamainjp | 0:e91b984e285d | 33 | |
shintamainjp | 0:e91b984e285d | 34 | #ifndef MSCORE_H |
shintamainjp | 0:e91b984e285d | 35 | #define MSCORE_H |
shintamainjp | 0:e91b984e285d | 36 | |
shintamainjp | 0:e91b984e285d | 37 | #define MSCORE_BUFFER_SIZE (8) |
shintamainjp | 0:e91b984e285d | 38 | #define MSCORE_INITIALIZER() { .keycnt = 0, .keybuf = {0} } |
shintamainjp | 0:e91b984e285d | 39 | |
shintamainjp | 0:e91b984e285d | 40 | typedef enum { |
shintamainjp | 0:e91b984e285d | 41 | MSCORE_ACTION_IGNORE, |
shintamainjp | 0:e91b984e285d | 42 | MSCORE_ACTION_DISPLAYABLE, |
shintamainjp | 0:e91b984e285d | 43 | MSCORE_ACTION_BS, |
shintamainjp | 0:e91b984e285d | 44 | MSCORE_ACTION_DEL, |
shintamainjp | 0:e91b984e285d | 45 | MSCORE_ACTION_TAB, |
shintamainjp | 0:e91b984e285d | 46 | MSCORE_ACTION_INSERT, |
shintamainjp | 0:e91b984e285d | 47 | MSCORE_ACTION_ENTER, |
shintamainjp | 0:e91b984e285d | 48 | MSCORE_ACTION_CTRL_A, |
shintamainjp | 0:e91b984e285d | 49 | MSCORE_ACTION_CTRL_B, |
shintamainjp | 0:e91b984e285d | 50 | MSCORE_ACTION_CTRL_C, |
shintamainjp | 0:e91b984e285d | 51 | MSCORE_ACTION_CTRL_D, |
shintamainjp | 0:e91b984e285d | 52 | MSCORE_ACTION_CTRL_E, |
shintamainjp | 0:e91b984e285d | 53 | MSCORE_ACTION_CTRL_F, |
shintamainjp | 0:e91b984e285d | 54 | MSCORE_ACTION_CTRL_G, |
shintamainjp | 0:e91b984e285d | 55 | MSCORE_ACTION_CTRL_H, |
shintamainjp | 0:e91b984e285d | 56 | MSCORE_ACTION_CTRL_I, |
shintamainjp | 0:e91b984e285d | 57 | MSCORE_ACTION_CTRL_J, |
shintamainjp | 0:e91b984e285d | 58 | MSCORE_ACTION_CTRL_K, |
shintamainjp | 0:e91b984e285d | 59 | MSCORE_ACTION_CTRL_L, |
shintamainjp | 0:e91b984e285d | 60 | MSCORE_ACTION_CTRL_M, |
shintamainjp | 0:e91b984e285d | 61 | MSCORE_ACTION_CTRL_N, |
shintamainjp | 0:e91b984e285d | 62 | MSCORE_ACTION_CTRL_O, |
shintamainjp | 0:e91b984e285d | 63 | MSCORE_ACTION_CTRL_P, |
shintamainjp | 0:e91b984e285d | 64 | MSCORE_ACTION_CTRL_Q, |
shintamainjp | 0:e91b984e285d | 65 | MSCORE_ACTION_CTRL_R, |
shintamainjp | 0:e91b984e285d | 66 | MSCORE_ACTION_CTRL_S, |
shintamainjp | 0:e91b984e285d | 67 | MSCORE_ACTION_CTRL_T, |
shintamainjp | 0:e91b984e285d | 68 | MSCORE_ACTION_CTRL_U, |
shintamainjp | 0:e91b984e285d | 69 | MSCORE_ACTION_CTRL_V, |
shintamainjp | 0:e91b984e285d | 70 | MSCORE_ACTION_CTRL_W, |
shintamainjp | 0:e91b984e285d | 71 | MSCORE_ACTION_CTRL_X, |
shintamainjp | 0:e91b984e285d | 72 | MSCORE_ACTION_CTRL_Y, |
shintamainjp | 0:e91b984e285d | 73 | MSCORE_ACTION_CTRL_Z, |
shintamainjp | 0:e91b984e285d | 74 | MSCORE_ACTION_F1, |
shintamainjp | 0:e91b984e285d | 75 | MSCORE_ACTION_F2, |
shintamainjp | 0:e91b984e285d | 76 | MSCORE_ACTION_F3, |
shintamainjp | 0:e91b984e285d | 77 | MSCORE_ACTION_F4, |
shintamainjp | 0:e91b984e285d | 78 | MSCORE_ACTION_F5, |
shintamainjp | 0:e91b984e285d | 79 | MSCORE_ACTION_F6, |
shintamainjp | 0:e91b984e285d | 80 | MSCORE_ACTION_F7, |
shintamainjp | 0:e91b984e285d | 81 | MSCORE_ACTION_F8, |
shintamainjp | 0:e91b984e285d | 82 | MSCORE_ACTION_F9, |
shintamainjp | 0:e91b984e285d | 83 | MSCORE_ACTION_F10, |
shintamainjp | 0:e91b984e285d | 84 | MSCORE_ACTION_F11, |
shintamainjp | 0:e91b984e285d | 85 | MSCORE_ACTION_F12, |
shintamainjp | 0:e91b984e285d | 86 | MSCORE_ACTION_ARROW_UP, |
shintamainjp | 0:e91b984e285d | 87 | MSCORE_ACTION_ARROW_DOWN, |
shintamainjp | 0:e91b984e285d | 88 | MSCORE_ACTION_ARROW_LEFT, |
shintamainjp | 0:e91b984e285d | 89 | MSCORE_ACTION_ARROW_RIGHT, |
shintamainjp | 0:e91b984e285d | 90 | MSCORE_ACTION_HOME, |
shintamainjp | 0:e91b984e285d | 91 | MSCORE_ACTION_END, |
shintamainjp | 0:e91b984e285d | 92 | MSCORE_ACTION_PAGE_UP, |
shintamainjp | 0:e91b984e285d | 93 | MSCORE_ACTION_PAGE_DOWN, |
shintamainjp | 0:e91b984e285d | 94 | } MSCORE_ACTION; |
shintamainjp | 0:e91b984e285d | 95 | |
shintamainjp | 0:e91b984e285d | 96 | typedef struct { |
shintamainjp | 0:e91b984e285d | 97 | int keycnt; |
shintamainjp | 0:e91b984e285d | 98 | char keybuf[MSCORE_BUFFER_SIZE]; |
shintamainjp | 0:e91b984e285d | 99 | } MSCORE; |
shintamainjp | 0:e91b984e285d | 100 | |
shintamainjp | 0:e91b984e285d | 101 | #ifdef __cplusplus |
shintamainjp | 0:e91b984e285d | 102 | extern "C" { |
shintamainjp | 0:e91b984e285d | 103 | #endif |
shintamainjp | 0:e91b984e285d | 104 | |
shintamainjp | 0:e91b984e285d | 105 | void mscore_init(MSCORE *handle); |
shintamainjp | 0:e91b984e285d | 106 | MSCORE_ACTION mscore_push(MSCORE *handle, char c); |
shintamainjp | 0:e91b984e285d | 107 | |
shintamainjp | 0:e91b984e285d | 108 | #ifdef __cplusplus |
shintamainjp | 0:e91b984e285d | 109 | } |
shintamainjp | 0:e91b984e285d | 110 | #endif |
shintamainjp | 0:e91b984e285d | 111 | |
shintamainjp | 0:e91b984e285d | 112 | #endif |
shintamainjp | 0:e91b984e285d | 113 | |
shintamainjp | 0:e91b984e285d | 114 |