Minitel.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  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 30
  32. #define TOP_RIGHT 1001
  33. #define BOTTOM_LEFT 1002
  34. #define BOTTOM_RIGHT 1003
  35. #define CENTER 1004
  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. //String _characters;
  110. //String _accents;
  111. byte _currentBgColor;
  112. byte _currentTextColor;
  113. byte _currentMode;
  114. byte _currentVideo;
  115. byte _currentSize;
  116. boolean _currentUnderline;
  117. boolean _currentBlink;
  118. boolean _currentShowCursor;
  119. void init();
  120. boolean isValidChar(byte index);
  121. boolean isAccent(char c);
  122. boolean printAccentChar(char c);
  123. void printAccent(int index);
  124. char getAccentLetter(int letterIndex);
  125. public :
  126. Minitel();
  127. Minitel(int rx, int tx);
  128. void refreshSettings();
  129. byte getGraphicChar(String s);
  130. void serialprint7(byte b);
  131. void graphic(String s, int x, int y);
  132. void graphic(String s);
  133. void textByte(byte c);
  134. void textByte(byte b, int x, int y);
  135. boolean textChar(byte c);
  136. boolean textChar(byte c, int x, int y);
  137. void text(String s, int x, int y);
  138. void text(String s);
  139. void text(String s, int x, int y, int orientation);
  140. void text(String s, int orientation);
  141. byte getCharByte(char c);
  142. void specialChar(byte c, int x, int y);
  143. void specialChar(byte c);
  144. void repeat(byte n);
  145. void bgColor(byte c);
  146. void textColor(byte c);
  147. void useDefaultColors();
  148. void moveCursorTo(int x, int y);
  149. void moveCursor(byte dir);
  150. void moveCursorTo(byte location);
  151. void moveCursor(byte dir, int n);
  152. void cursor();
  153. void noCursor();
  154. void cursor(boolean b);
  155. void clearScreen();
  156. void mode(byte mode);
  157. void graphicMode();
  158. void textMode();
  159. void blink();
  160. void noBlink();
  161. void blink(boolean b);
  162. void charSize(byte type);
  163. void incrustation(boolean b);
  164. void pixelate();
  165. void noPixelate();
  166. void pixelate(boolean b);
  167. void setLineMask(boolean b);
  168. void video(byte v);
  169. void standardVideo();
  170. void invertVideo();
  171. void transparentVideo();
  172. void setMaxSpeed();
  173. void bip(long duration);
  174. void rect(char c, int x, int y, int w, int h);
  175. void rect(byte c, int x, int y, int w, int h);
  176. void spiral(int x, int y, int siz, int c);
  177. };
  178. #endif