term.h 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. #ifndef _DEV_TERM_H_
  2. #define _DEV_TERM_H_
  3. /*
  4. * Copyright (C) 2003-2005 by egnite Software GmbH. All rights reserved.
  5. *
  6. * Redistribution and use in source and binary forms, with or without
  7. * modification, are permitted provided that the following conditions
  8. * are met:
  9. *
  10. * 1. Redistributions of source code must retain the above copyright
  11. * notice, this list of conditions and the following disclaimer.
  12. * 2. Redistributions in binary form must reproduce the above copyright
  13. * notice, this list of conditions and the following disclaimer in the
  14. * documentation and/or other materials provided with the distribution.
  15. * 3. Neither the name of the copyright holders nor the names of
  16. * contributors may be used to endorse or promote products derived
  17. * from this software without specific prior written permission.
  18. *
  19. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  20. * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  21. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  22. * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  23. * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  24. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  25. * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
  26. * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
  27. * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  28. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  29. * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  30. * SUCH DAMAGE.
  31. *
  32. * For additional information see http://www.ethernut.de/
  33. */
  34. #include <sys/device.h>
  35. /*!
  36. * \file dev/term.h
  37. * \brief Terminal device definitions.
  38. */
  39. /*!
  40. * \addtogroup xgTerminal
  41. */
  42. /*@{*/
  43. /*
  44. * I/O control commands.
  45. */
  46. #define LCD_CMDBYTE 0x0401
  47. #define LCD_CMDWORD16 0x0402
  48. #define LCD_CMDWORD32 0x0403
  49. #define LCD_DATABYTE 0x0405
  50. #define LCD_DATAWORD16 0x0406
  51. #define LCD_DATAWORD32 0x0407
  52. #define LCD_SETCOOKEDMODE 0x0413 /*!< \brief Set raw mode. */
  53. #define LCD_GETCOOKEDMODE 0x0414 /*!< \brief Query raw mode. */
  54. #define LCD_SET_AUTOLF 0x0415
  55. #define LCD_GET_AUTOLF 0x0416
  56. #ifndef TIOCGWINSZ
  57. #define TIOCGWINSZ 0x0501 /*!< Gets the window size */
  58. #endif
  59. #ifndef TIOCSWINSZ
  60. #define TIOCSWINSZ 0x0502 /*!< Sets the window size */
  61. #endif
  62. #define LCD_MF_CURSORON 0x00000001UL /*!< \brief Cursor on flag. */
  63. #define LCD_MF_COOKEDMODE 0x00020000UL /*!< \brief Control character interpretation on flag. */
  64. #define LCD_MF_AUTOLF 0x00040000UL /*!< \brief Control automatic break into next line on line end */
  65. #define LCD_MF_AUTOSCROLL 0x00080000UL /*!< \brief Control automatic scrolling at end of display */
  66. #define LCD_MF_INVERTED 0x10000000UL /*!< \breif display inverted characters on grafic displays */
  67. #ifndef ESC_CHAR
  68. #define ESC_CHAR "\x1B"
  69. #endif
  70. #define ESC_POS ESC_CHAR "Y"
  71. #define ESC_UP ESC_CHAR "A"
  72. #define ESC_DOWN ESC_CHAR "B"
  73. #define ESC_RIGHT ESC_CHAR "C"
  74. #define ESC_LEFT ESC_CHAR "D"
  75. #define ESC_CLRHOME ESC_CHAR "E"
  76. #define ESC_HOME ESC_CHAR "H"
  77. #define ESC_CLREND ESC_CHAR "J"
  78. #define ESC_CLREOL ESC_CHAR "K"
  79. #define ESC_CLRSTART ESC_CHAR "d"
  80. #define ESC_CLRSOL ESC_CHAR "o"
  81. #define ESC_INSCHAR ESC_CHAR "@"
  82. #define ESC_INSLINE ESC_CHAR "L"
  83. #define ESC_DELCHAR ESC_CHAR "P"
  84. #define ESC_DELLINE ESC_CHAR "M"
  85. #define ESC_RLF ESC_CHAR "I"
  86. #define ESC_CURSORON ESC_CHAR "e"
  87. #define ESC_CURSOROFF ESC_CHAR "f"
  88. #define ESC_INVERTON ESC_CHAR "i"
  89. #define ESC_INVERTOFF ESC_CHAR "n"
  90. #define ESC_SPECIALSET ESC_CHAR "F"
  91. #define ESC_DEFAULTSET ESC_CHAR "G"
  92. #define ESC_ACTIVE ESC_CHAR "R"
  93. #define ESC_SLEEP ESC_CHAR "S"
  94. /*! \brief Deprecated, use ESC_CLRHOME.
  95. *
  96. * Although wrong, we keep it for now in order not to break existing code.
  97. */
  98. #define ESC_CLR ESC_CLRHOME
  99. /*
  100. * winsize structure
  101. */
  102. typedef struct _WINSIZE WINSIZE;
  103. struct _WINSIZE {
  104. uint16_t ws_row;
  105. uint16_t ws_col;
  106. uint16_t ws_xpixel;
  107. uint16_t ws_ypixel;
  108. };
  109. /*!
  110. * Terminal device control block type.
  111. */
  112. typedef struct _TERMDCB TERMDCB;
  113. /*!
  114. * \struct _TERMDCB term.h dev/term.h
  115. * \brief Terminal device control block structure.
  116. */
  117. struct _TERMDCB {
  118. /*! \brief Initialize display subsystem.
  119. */
  120. int (*dss_init)(NUTDEVICE *);
  121. /*! \brief Write display character.
  122. */
  123. void (*dss_write)(uint8_t);
  124. /*! \brief Write display command.
  125. */
  126. void (*dss_command)(uint8_t, uint8_t);
  127. /*! \brief Clear display.
  128. */
  129. void (*dss_clear)(void);
  130. /*! \brief Set display cursor.
  131. */
  132. void (*dss_set_cursor)(uint8_t);
  133. /*! \brief Set display cursor home.
  134. */
  135. void (*dss_cursor_home)(void);
  136. /*! \brief Move display cursor left.
  137. */
  138. void (*dss_cursor_left)(void);
  139. /*! \brief Move display cursor right.
  140. */
  141. void (*dss_cursor_right)(void);
  142. /*! \brief Switch cursor on/off.
  143. */
  144. void (*dss_cursor_mode)(uint8_t);
  145. /*! \brief Mode flags.
  146. */
  147. uint32_t dcb_modeflags;
  148. /*! \brief Control sequence.
  149. */
  150. uint8_t dcb_ctlseq;
  151. /*! \brief Number of rows.
  152. * Specifies the display height.
  153. */
  154. uint8_t dcb_nrows;
  155. /*! \brief Total number of columns per row.
  156. * Used to calculate display memory addresses.
  157. */
  158. uint8_t dcb_ncols;
  159. /*! \brief Number of visible columns.
  160. * Specifies the display width being updated.
  161. */
  162. uint8_t dcb_vcols;
  163. /*! \brief Cursor row.
  164. */
  165. uint8_t dcb_row;
  166. /*! \brief Cursor column.
  167. */
  168. uint8_t dcb_col;
  169. /*! \brief Display shadow memory.
  170. */
  171. uint8_t *dcb_smem;
  172. /*! \brief Display shadow memory.
  173. */
  174. uint8_t *dcb_sptr;
  175. };
  176. /*@}*/
  177. extern int TermInit(NUTDEVICE * dev);
  178. extern int TermIOCtl(NUTDEVICE * dev, int req, void *conf);
  179. extern int TermWrite(NUTFILE * fp, const void *buffer, int len);
  180. #ifdef __HARVARD_ARCH__
  181. extern int TermWrite_P(NUTFILE * fp, PGM_P buffer, int len);
  182. #endif
  183. extern NUTFILE *TermOpen(NUTDEVICE * dev, const char *name, int mode, int acc);
  184. extern int TermClose(NUTFILE * fp);
  185. #endif