config.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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[32mBT-6037v2 >\033[0m " // green color
  26. /*
  27. Define prompt text (without ESC sequence, only text) prompt length, it needs because if you use
  28. ESC sequence, it's not possible detect only text length*/
  29. #define _PROMPT_LEN 12
  30. /*Define it, if you wanna use completion functional, also set completion callback in you code,
  31. now if user press TAB calls 'copmlitetion' callback. If you no need it, you can just set
  32. NULL to callback ptr and do not use it, but for memory saving tune,
  33. if you are not going to use it - disable this define.*/
  34. #define _USE_COMPLETE
  35. /*Define it, if you wanna use history. It s work's like bash history, and
  36. set stored value to cmdline, if UP and DOWN key pressed. Using history add
  37. memory consuming, depends from _RING_HISTORY_LEN parametr */
  38. #define _USE_HISTORY
  39. /*
  40. History ring buffer length, define static buffer size.
  41. For saving memory, each entered cmdline store to history in ring buffer,
  42. so we can not say, how many line we can store, it depends from cmdline len,
  43. but memory using more effective. We not prefer dinamic memory allocation for
  44. small and embedded devices. Overhead is 2 char on each saved line*/
  45. #define _RING_HISTORY_LEN 64
  46. /*
  47. Enable Handling terminal ESC sequence. If disabling, then cursor arrow, HOME, END will not work,
  48. use Ctrl+A(B,F,P,N,A,E,H,K,U,C) see README, but decrease code memory.*/
  49. #define _USE_ESC_SEQ
  50. /*
  51. Use snprintf from you standard complier library, but it gives some overhead.
  52. If not defined, use my own u16int_to_str variant, it's save about 800 byte of code size
  53. on AVR (avr-gcc build).
  54. Try to build with and without, and compare total code size for tune library.
  55. */
  56. #define _USE_LIBC_STDIO
  57. /*
  58. Enable 'interrupt signal' callback, if user press Ctrl+C */
  59. #define _USE_CTLR_C
  60. /*
  61. Print prompt at 'microrl_init', if enable, prompt will print at startup,
  62. otherwise first prompt will print after first press Enter in terminal
  63. NOTE!: Enable it, if you call 'microrl_init' after your communication subsystem
  64. already initialize and ready to print message */
  65. //#undef _ENABLE_INIT_PROMPT
  66. #define _ENABLE_INIT_PROMPT
  67. /*
  68. New line symbol */
  69. #define _ENDL_CR
  70. #if defined(_ENDL_CR)
  71. #define ENDL "\r"
  72. #elif defined(_ENDL_CRLF)
  73. #define ENDL "\r\n"
  74. #elif defined(_ENDL_LF)
  75. #define ENDL "\n"
  76. #elif defined(_ENDL_LFCR)
  77. #define ENDL "\n\r"
  78. #else
  79. #error "You must define new line symbol."
  80. #endif
  81. /********** END CONFIG SECTION ************/
  82. #if _RING_HISTORY_LEN > 256
  83. #error "This history implementation (ring buffer with 1 byte iterator) allow 256 byte buffer size maximum"
  84. #endif
  85. #endif