MinitelNyanCat.ino 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  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. #include <SoftwareSerial.h>
  15. #include <Minitel.h>
  16. Minitel m;
  17. void setup() {
  18. }
  19. void loop() {
  20. m.graphicMode();
  21. m.clearScreen();
  22. m.graphicMode();
  23. bg();
  24. rainbow(2, 10);
  25. body(12, 9);
  26. drawStar1(28, 4);
  27. drawStar1(20, 21);
  28. drawStar2(5, 5, false);
  29. drawStar2(22, 9, true);
  30. drawStar2(35, 20, false);
  31. drawStar2(20, 5, true);
  32. drawStar2(5, 20, true);
  33. drawStar3(32, 11);
  34. drawFrame();
  35. delay(60000);
  36. }
  37. void drawFrame() {
  38. m.graphicMode();
  39. m.rect((byte) m.getGraphicChar("011001"), 1, 1, 39, 24);
  40. }
  41. void drawStar1(int x, int y) {
  42. m.graphicMode();
  43. m.textColor(WHITE);
  44. m.blink();
  45. m.graphic("111111", x, y);
  46. m.noBlink();
  47. m.graphic("111111", x, y-1);
  48. m.graphic("111111", x, y+1);
  49. m.graphic("111111", x-1, y);
  50. m.graphic("111111", x+1, y);
  51. }
  52. void drawStar2(int x, int y, boolean b) {
  53. m.textMode();
  54. //m.m.bgColor
  55. m.bgColor(RED);
  56. if (b) {
  57. m.blink();
  58. }
  59. m.text(" *", x, y);
  60. if (b) {
  61. m.noBlink();
  62. }
  63. }
  64. void drawStar3(int x, int y) {
  65. m.graphicMode();
  66. m.bgColor(RED);
  67. m.textColor(WHITE);
  68. m.graphic("001111", x, y-2);
  69. m.graphic("111100", x, y-1);
  70. m.graphic("111100", x, y);
  71. m.graphic("111111", x, y+1);
  72. m.graphic("110000", x, y+2);
  73. m.graphic("101000", x-1, y);
  74. m.graphic("111100", x-2, y);
  75. m.graphic("010100", x+1, y);
  76. m.graphic("111100", x+2, y);
  77. }
  78. void body(int x, int y) {
  79. m.graphicMode();
  80. m.moveCursorTo(x, y);
  81. m.bgColor(RED);
  82. m.textColor(BLACK);
  83. m.graphic("000001");
  84. m.graphic("000011");
  85. m.repeat(7);
  86. for (int i=1; i<7; i++) {
  87. m.moveCursorTo(x, y+i);
  88. m.graphic("101010");
  89. m.moveCursor(RIGHT, 8);
  90. m.graphic("101010");
  91. }
  92. m.moveCursorTo(x-1, y+7);
  93. m.graphic("011011");
  94. // Legs
  95. m.moveCursorTo(x, y+7);
  96. m.graphic("111000");
  97. m.graphic("111001");
  98. m.graphic("111010");
  99. m.graphic("110000");
  100. m.graphic("110000");
  101. m.graphic("111001");
  102. m.graphic("111010");
  103. m.graphic("110100");
  104. m.graphic("110111");
  105. // Fur
  106. m.moveCursorTo(x+2, y+2);
  107. m.graphic("010000");
  108. m.moveCursorTo(x+4, y+3);
  109. m.graphic("010010");
  110. m.moveCursorTo(x+2, y+4);
  111. m.graphic("010010");
  112. m.moveCursorTo(x+4, y+5);
  113. m.graphic("010010");
  114. m.moveCursorTo(x+6, y+2);
  115. m.graphic("100001");
  116. // tail
  117. m.moveCursorTo(x-3, y+4);
  118. m.graphic("111011");
  119. m.graphic("110011");
  120. m.graphic("110011");
  121. // Head
  122. m.moveCursorTo(x+6, y+3);
  123. m.graphic("011010");
  124. m.graphic("001001");
  125. m.graphic("000011");
  126. m.graphic("100110");
  127. m.graphic("100101");
  128. m.graphic("000000");
  129. m.moveCursorTo(x+5, y+4);
  130. m.graphic("000001");
  131. m.graphic("101000");
  132. m.graphic("000010");
  133. m.graphic("000000");
  134. m.graphic("000001");
  135. m.graphic("010100");
  136. m.graphic("000010");
  137. m.moveCursorTo(x+5, y+5);
  138. m.graphic("010101");
  139. m.graphic("010000");
  140. m.graphic("100010"); // eyeleft
  141. m.graphic("100010");
  142. m.graphic("110010");
  143. m.graphic("000000");
  144. m.graphic("101010");
  145. m.moveCursorTo(x+6, y+6);
  146. m.graphic("101001");
  147. m.graphic("110000");
  148. m.graphic("110000");
  149. m.graphic("100000");
  150. m.graphic("010110");
  151. m.moveCursorTo(x+9, y+7);
  152. m.graphic("110000");
  153. m.graphic("100000");
  154. }
  155. void bg() {
  156. m.graphicMode();
  157. m.textColor(RED);
  158. m.moveCursorTo(1, 1);
  159. for (int i=1; i<25; i++) {
  160. m.graphic("111111");
  161. m.repeat(39);
  162. }
  163. }
  164. void rainbow(int x, int y) {
  165. //WHITE, YELLOW, CYAN, GREEN, BLUE, RED, MAGENTA, BLACK
  166. m.graphicMode();
  167. int colors[] = {
  168. RED, MAGENTA, YELLOW, WHITE, GREEN, CYAN, BLUE, RED };
  169. for (int i=0; i<8; i++) {
  170. m.bgColor(colors[i]);
  171. m.textColor(colors[i+1]);
  172. m.graphic("001111", x, y+i);
  173. // m.repeat(1);
  174. m.graphic("111111");
  175. m.repeat(2);
  176. m.graphic("001111");
  177. m.repeat(2);
  178. m.graphic("111111");
  179. m.repeat(2);
  180. }
  181. }