Minitel.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. /**
  2. * Minitel library for Arduino (v0.1) / May 2013
  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_BOOK 35
  94. #define SPE_CHAR_PARAGRAPH 39
  95. #define SPE_CHAR_ARROW_LEFT 44
  96. #define SPE_CHAR_ARROW_UP 45
  97. #define SPE_CHAR_ARROW_RIGHT 46
  98. #define SPE_CHAR_ARROW_DOWN 47
  99. #define SPE_CHAR_CIRCLE 48
  100. #define SPE_CHAR_MINUS_PLUS 49
  101. #define SPE_CHAR_1_4 60
  102. #define SPE_CHAR_1_2 61
  103. #define SPE_CHAR_3_4 62
  104. #define SPE_CHAR_UPPER_OE 106
  105. #define SPE_CHAR_LOWER_OE 122
  106. #define SPE_CHAR_BETA 123
  107. class Minitel : public SoftwareSerial {
  108. private :
  109. byte _currentBgColor;
  110. byte _currentTextColor;
  111. byte _currentMode;
  112. byte _currentVideo;
  113. byte _currentSize;
  114. boolean _currentUnderline;
  115. boolean _currentBlink;
  116. boolean _currentShowCursor;
  117. boolean _menuKeyPressed;
  118. void init();
  119. void mode(byte mode);
  120. void cursor(boolean b);
  121. void blink(boolean b);
  122. void pixelate(boolean b);
  123. void video(byte v);
  124. void incrustation(boolean b);
  125. void lineMask(boolean b);
  126. boolean isValidChar(byte index);
  127. boolean isAccent(char c);
  128. boolean printAccentChar(char c);
  129. void printAccent(int index);
  130. char getAccentLetter(int letterIndex);
  131. public :
  132. Minitel();
  133. Minitel(int rx, int tx);
  134. void refreshSettings();
  135. byte getGraphicChar(String s);
  136. void serialprint7(byte b);
  137. void graphic(String s, int x, int y);
  138. void graphic(String s);
  139. void textByte(byte c);
  140. void textByte(byte b, int x, int y);
  141. boolean textChar(byte c);
  142. boolean textChar(byte c, int x, int y);
  143. void text(String s, int x, int y);
  144. void text(String s);
  145. void text(String s, int x, int y, int orientation);
  146. void text(String s, int orientation);
  147. byte getCharByte(char c);
  148. void specialChar(byte c, int x, int y);
  149. void specialChar(byte c);
  150. void repeat(byte n);
  151. void bgColor(byte c);
  152. void textColor(byte c);
  153. void useDefaultColors();
  154. void moveCursorTo(byte x, byte y);
  155. void moveCursor(byte dir);
  156. void moveCursorTo(byte location);
  157. void moveCursor(byte dir, int n);
  158. void cursor();
  159. void noCursor();
  160. void clearScreen();
  161. void graphicMode();
  162. void textMode();
  163. void blink();
  164. void noBlink();
  165. void charSize(byte type);
  166. void incrustation();
  167. void noIncrustation();
  168. void pixelate();
  169. void noPixelate();
  170. void lineMask();
  171. void noLineMask();
  172. void standardVideo();
  173. void invertVideo();
  174. void transparentVideo();
  175. void setMaxSpeed();
  176. void bip(long duration);
  177. char getKey();
  178. byte getKeyCode();
  179. boolean isMenuKey();
  180. void rect(char c, int x, int y, int w, int h);
  181. void rect(byte c, int x, int y, int w, int h);
  182. void spiral(int x, int y, int siz, int c);
  183. };
  184. #endif