config.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /**
  2. Microrl library config files
  3. Autor: Eugene Samoylov aka Helius (ghelius@gmail.com)
  4. */
  5. #ifndef _MICRORL_CONFIG_H_
  6. #define _MICRORL_CONFIG_H_
  7. #define MICRORL_LIB_VER "1.5.1"
  8. /*********** CONFIG SECTION **************/
  9. /*
  10. Command line length, define cmdline buffer size. Set max number of chars + 1,
  11. because last byte of buffer need to contain '\0' - NULL terminator, and
  12. not use for storing inputed char.
  13. If user input chars more then it parametrs-1, chars not added to command line.*/
  14. #define _COMMAND_LINE_LEN (1+100) // for 32 chars
  15. /*
  16. Command token number, define max token it command line, if number of token
  17. typed in command line exceed this value, then prints message about it and
  18. command line not to be parced and 'execute' callback will not calls.
  19. Token is word separate by white space, for example 3 token line:
  20. "IRin> set mode test" */
  21. #define _COMMAND_TOKEN_NMB 8
  22. /*
  23. Define you prompt string here. You can use colors escape code, for highlight you prompt,
  24. for example this prompt will green color (if you terminal supports color)*/
  25. #define _PROMPT_DEFAULT "\033[32mIBPn >\033[0m " // green color
  26. //#define _PROMPT_DEFAULT "\033[32mIRin >\033[0m " // green color
  27. //#define _PROMPT_DEFAULT "IRin > "
  28. /*
  29. Define prompt text (without ESC sequence, only text) prompt length, it needs because if you use
  30. ESC sequence, it's not possible detect only text length*/
  31. #define _PROMPT_LEN 7
  32. /*Define it, if you wanna use completion functional, also set completion callback in you code,
  33. now if user press TAB calls 'copmlitetion' callback. If you no need it, you can just set
  34. NULL to callback ptr and do not use it, but for memory saving tune,
  35. if you are not going to use it - disable this define.*/
  36. #define _USE_COMPLETE
  37. /*Define it, if you wanna use history. It s work's like bash history, and
  38. set stored value to cmdline, if UP and DOWN key pressed. Using history add
  39. memory consuming, depends from _RING_HISTORY_LEN parametr */
  40. #define _USE_HISTORY
  41. /*
  42. History ring buffer length, define static buffer size.
  43. For saving memory, each entered cmdline store to history in ring buffer,
  44. so we can not say, how many line we can store, it depends from cmdline len,
  45. but memory using more effective. We not prefer dinamic memory allocation for
  46. small and embedded devices. Overhead is 2 char on each saved line*/
  47. #define _RING_HISTORY_LEN 64
  48. /*
  49. Enable Handling terminal ESC sequence. If disabling, then cursor arrow, HOME, END will not work,
  50. use Ctrl+A(B,F,P,N,A,E,H,K,U,C) see README, but decrease code memory.*/
  51. #define _USE_ESC_SEQ
  52. /*
  53. Use snprintf from you standard complier library, but it gives some overhead.
  54. If not defined, use my own u16int_to_str variant, it's save about 800 byte of code size
  55. on AVR (avr-gcc build).
  56. Try to build with and without, and compare total code size for tune library.
  57. */
  58. #define _USE_LIBC_STDIO
  59. /*
  60. Enable 'interrupt signal' callback, if user press Ctrl+C */
  61. #define _USE_CTLR_C
  62. /*
  63. Print prompt at 'microrl_init', if enable, prompt will print at startup,
  64. otherwise first prompt will print after first press Enter in terminal
  65. NOTE!: Enable it, if you call 'microrl_init' after your communication subsystem
  66. already initialize and ready to print message */
  67. #undef _ENABLE_INIT_PROMPT
  68. /*
  69. New line symbol */
  70. #define _ENDL_CR
  71. #if defined(_ENDL_CR)
  72. #define ENDL "\r"
  73. #elif defined(_ENDL_CRLF)
  74. #define ENDL "\r\n"
  75. #elif defined(_ENDL_LF)
  76. #define ENDL "\n"
  77. #elif defined(_ENDL_LFCR)
  78. #define ENDL "\n\r"
  79. #else
  80. #error "You must define new line symbol."
  81. #endif
  82. /********** END CONFIG SECTION ************/
  83. #if _RING_HISTORY_LEN > 256
  84. #error "This history implementation (ring buffer with 1 byte iterator) allow 256 byte buffer size maximum"
  85. #endif
  86. #endif