Minitel.h 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  1. /**
  2. * Minitel library for Arduino (v0.2) / April 2015
  3. * http://github.com/01010101/Minitel
  4. *
  5. * By Jerome Saint-Clair aka 01010101
  6. * http://saint-clair.net
  7. *
  8. * For the Graffiti Research Lab France
  9. * http://graffitiresearchlab.fr
  10. *
  11. * Based on works by the Tetalab (Fabrice, Renaud, PG & Phil)
  12. * http://tetalab.org
  13. */
  14. #ifndef Minitel_h
  15. #define Minitel_h
  16. #include "Arduino.h"
  17. #include "SoftwareSerial.h"
  18. // Modes
  19. #define GRAPHIC_MODE 14
  20. #define TEXT_MODE 15
  21. #define HORIZONTAL 0
  22. #define VERTICAL 1
  23. // Cursor moves
  24. #define LEFT 8
  25. #define RIGHT 9
  26. #define DOWN 10
  27. #define UP 11
  28. // Cursor positionning
  29. #define HOME 13
  30. #define LINE_END 24
  31. #define TOP_LEFT 1
  32. #define TOP_RIGHT 2
  33. #define BOTTOM_LEFT 3
  34. #define BOTTOM_RIGHT 4
  35. #define CENTER 5
  36. // Cursor visibility
  37. // Preceeded by 27
  38. #define CURSOR_SHOW 17
  39. #define CURSOR_HIDE 20
  40. // Clear screen
  41. #define CLEARSCREEN 12
  42. // Font type
  43. // Preceeded by 27
  44. // DOUBLE-HEIGHT and DOUBLE may not work on certain Minitels
  45. #define SIZE_NORMAL 76
  46. #define SIZE_DOUBLE_HEIGHT 77
  47. #define SIZE_DOUBLE_WIDTH 78
  48. #define SIZE_DOUBLE 79
  49. // Colors (+80 for background, +64 for text)
  50. // Preceeded by 27
  51. // 64->71 txt color black, red, green, yellow, blue, magenta, cyan, white
  52. // 80->87 bg color black, red, green, yellow, blue, magenta, cyan, white
  53. #define BLACK 0
  54. #define RED 1
  55. #define GREEN 2
  56. #define YELLOW 3
  57. #define MAGENTA 4
  58. #define BLUE 5
  59. #define CYAN 6
  60. #define WHITE 7
  61. // Blink
  62. // Preceeded by 27
  63. #define BLINK_ON 72
  64. #define BLINK_OFF 73
  65. // Incrustation
  66. // Preceeded by 27
  67. #define INCRUSTATION_ON 75
  68. #define INCRUSTATION_OFF 74
  69. // Underline
  70. #define UNDERLINE_ON 90
  71. #define UNDERLINE_OFF 89
  72. // Underline
  73. #define LINE_MASK_ON 88
  74. #define LINE_MASK_OFF 95
  75. // Video mode
  76. #define VIDEO_INVERT 93
  77. #define VIDEO_STANDARD 92
  78. #define VIDEO_TRANSPARENT 94
  79. // Speeds
  80. #define SPEED_75 0
  81. #define SPEED_300 1
  82. #define SPEED_4800 100
  83. #define SPEED_9600 111 // ??? Minitel 2 ???
  84. // Bip
  85. #define BIP 7
  86. // Accents
  87. // #define ACCUTE 65
  88. // #define GRAVE 66
  89. // #define CIRCUMFLEX 67
  90. // #define UMLAUT 72
  91. #define SUB_ARTICLE_SEPARATOR 31;
  92. // Preceeded by 25
  93. #define SPE_CHAR_POUND 35
  94. #define SPE_CHAR_DOLLAR 36
  95. #define SPE_CHAR_HASHTAG 38
  96. #define SPE_CHAR_PARAGRAPH 39
  97. #define SPE_CHAR_ARROW_LEFT 44
  98. #define SPE_CHAR_ARROW_UP 45
  99. #define SPE_CHAR_ARROW_RIGHT 46
  100. #define SPE_CHAR_ARROW_DOWN 47
  101. #define SPE_CHAR_DEGREE 48
  102. #define SPE_CHAR_MINUS_PLUS 49
  103. #define SPE_CHAR_DIVIDE 56
  104. #define SPE_CHAR_1_4 60 // output only ?
  105. #define SPE_CHAR_1_2 61 // output only ?
  106. #define SPE_CHAR_3_4 62 // output only ?
  107. #define SPE_CHAR_GRAVE 65
  108. #define SPE_CHAR_ACUTE 66
  109. #define SPE_CHAR_CIRCUMFLEX 67
  110. #define SPE_CHAR_UMLAUT 72
  111. #define SPE_CHAR_CEDIL 75
  112. #define SPE_CHAR_UPPER_OE 106
  113. #define SPE_CHAR_LOWER_OE 122
  114. #define SPE_CHAR_BETA 123
  115. // Non Arduino characters
  116. #define SPE_CHAR_ARROW_UP2 94
  117. #define SPE_CHAR_PIPE_BOTTOM 95
  118. #define SPE_CHAR_PIPE_MIDDLE 96
  119. #define SPE_CHAR_PIPE_LEFT 123
  120. #define SPE_CHAR_PIPE_CENTER 124
  121. #define SPE_CHAR_PIPE_RIGHT 125
  122. #define SPE_CHAR_PIPE_TOP 126
  123. // TODO Escape character handling ???
  124. #define SOMMAIRE 198
  125. #define ANNULATION 197
  126. #define RETOUR 66
  127. #define REPETITION 195
  128. #define GUIDE 68
  129. #define CORRECTION 71
  130. #define SUITE 72
  131. #define ENVOI 65
  132. class Minitel : public SoftwareSerial {
  133. private :
  134. String accents = "àáâäèéêëìíîïòóôöùúûü";
  135. byte _currentBgColor;
  136. byte _currentTextColor;
  137. byte _currentMode;
  138. byte _currentVideo;
  139. byte _currentSize;
  140. boolean _currentUnderline;
  141. boolean _currentBlink;
  142. boolean _currentShowCursor;
  143. boolean _menuKeyPressed;
  144. int _menuKey;
  145. int _specialCharacterKey;
  146. int _characterKey;
  147. int _accentKey;
  148. char _nullChar = '~';
  149. void init(short speed);
  150. void mode(byte mode);
  151. void cursor(boolean b);
  152. void blink(boolean b);
  153. void pixelate(boolean b);
  154. void video(byte v);
  155. void incrustation(boolean b);
  156. void lineMask(boolean b);
  157. boolean isValidChar(byte index);
  158. boolean isSpecialChar(byte c);
  159. boolean isAccent(char c);
  160. boolean printAccentChar(char c);
  161. void printAccent(int index);
  162. char getAccentLetter(int letterIndex);
  163. void refreshSettings();
  164. public :
  165. Minitel();
  166. Minitel(int rx, int tx);
  167. Minitel(short speed);
  168. Minitel(int rx, int tx, short speed);
  169. void serialprint7(byte b);
  170. byte getGraphicChar(String s);
  171. void graphic(String s, int x, int y);
  172. void graphic(String s);
  173. void textByte(byte c);
  174. void textByte(byte b, int x, int y);
  175. boolean textChar(byte c);
  176. boolean textChar(byte c, int x, int y);
  177. void text(String s, int x, int y);
  178. void text(String s);
  179. void text(String s, int x, int y, int orientation);
  180. void text(String s, int orientation);
  181. byte getCharByte(char c);
  182. void specialChar(byte c, int x, int y);
  183. void specialChar(byte c);
  184. void semiGraphic(byte b, int x, int y);
  185. void semiGraphic(byte b);
  186. void repeat(byte n);
  187. void bgColor(byte c);
  188. void textColor(byte c);
  189. void useDefaultColors();
  190. void moveCursorTo(byte x, byte y);
  191. void moveCursor(byte dir);
  192. void moveCursorTo(byte location);
  193. void moveCursor(byte dir, int n);
  194. void cursor();
  195. void noCursor();
  196. void clearScreen();
  197. void graphicMode();
  198. void textMode();
  199. void blink();
  200. void noBlink();
  201. void charSize(byte type);
  202. void incrustation();
  203. void noIncrustation();
  204. void pixelate();
  205. void noPixelate();
  206. void lineMask();
  207. void noLineMask();
  208. void standardVideo();
  209. void invertVideo();
  210. void transparentVideo();
  211. void setSpeed(short speed);
  212. void bip(unsigned long duration);
  213. void rect(char c, int x, int y, int w, int h);
  214. void rect(byte c, int x, int y, int w, int h);
  215. void spiral(int x, int y, int siz, int c);
  216. void readKey();
  217. boolean keyTyped();
  218. boolean isMenuKey();
  219. int getMenuKey();
  220. boolean isSpecialCharacterKey();
  221. int getSpecialCharacterKey();
  222. boolean accentKeyStored();
  223. int getAccentKey();
  224. boolean isCharacterKey();
  225. boolean isSerializableKey();
  226. char getCharacterKey();
  227. };
  228. #endif