浏览代码

Fix issue with refreshSettings avec mode change + new samples

01010101 12 年之前
父节点
当前提交
005d4a77c0

+ 7 - 5
Minitel.cpp

@@ -38,6 +38,7 @@ Minitel::Minitel(int rx, int tx) : SoftwareSerial(rx,tx) {
 void Minitel::init() {
 	Serial.begin(1200);
 	begin(1200);
+	useDefaultColors();
 	refreshSettings();
 }
 
@@ -277,7 +278,7 @@ void Minitel::useDefaultColors() {
 }
 
 
-void Minitel::moveCursorTo(int x, int y) {
+void Minitel::moveCursorTo(byte x, byte y) {
   serialprint7(31); // Code positionnement de curseur
   serialprint7(64+y); // coordonnées x (x+64) (x de 1 à 40)
   serialprint7(64+x); // coordonnées y (y+64) (y de 1 à 24)
@@ -325,7 +326,7 @@ void Minitel::moveCursor(byte dir, int n) {
 
 void Minitel::refreshSettings() {
   // Common parameters
-  mode(_currentMode);
+  serialprint7(_currentMode);
   textColor(_currentTextColor);
   bgColor(_currentBgColor); // Only in graphic mode ?
   blink(_currentBlink);
@@ -363,22 +364,23 @@ void Minitel::cursor(boolean b) {
 
 void Minitel::clearScreen() {
   serialprint7(CLEARSCREEN);
+  refreshSettings();
 }
 
 
 void Minitel::mode(byte mode) {
   if (mode == GRAPHIC_MODE || mode == TEXT_MODE) {
-    serialprint7(mode);
     _currentMode = mode;
+    refreshSettings();
   } 
 }
 
 void Minitel::graphicMode() {
-  mode(GRAPHIC_MODE); 
+  mode(GRAPHIC_MODE);
 }
 
 void Minitel::textMode() {
-  mode(TEXT_MODE); 
+  mode(TEXT_MODE);
 }
 
 

+ 7 - 69
Minitel.h

@@ -36,11 +36,11 @@
 #define HOME 13
 #define LINE_END 24
 
-#define TOP_LEFT 30
-#define TOP_RIGHT 1001
-#define BOTTOM_LEFT 1002
-#define BOTTOM_RIGHT 1003
-#define CENTER 1004
+#define TOP_LEFT 1
+#define TOP_RIGHT 2
+#define BOTTOM_LEFT 3
+#define BOTTOM_RIGHT 4
+#define CENTER 5
 
 // Cursor visibility
 // Preceeded by 27
@@ -128,72 +128,10 @@
 #define SPE_CHAR_LOWER_OE 122
 #define SPE_CHAR_BETA 123
 
-/*
-#define kPause  160
-#define k1  177
-#define k2  178
-#define k3  51
-#define k4  180
-#define k5  53
-#define k6  54
-#define k7  183
-#define k8  184
-#define k9  57
-#define k0  48
-#define kStar  170
-#define kHash  163
-
-#define kComa  172
-#define kDot  46
-#define kExcl  39
-#define kSemi  187
-#define kDash  45
-#define kColon  58
-#define kInterro  63
-
-#define kMenu  147
-#define kSomm  198
-#define kGuide  68
-#define kAnnul  197
-#define kCorrect  71
-#define kRetour  66
-#define kSuite  72
-#define kRepet  195
-#define kEnvoi  65
-
-#define kA  65
-#define kB  66
-#define kC  195
-#define kD  68
-#define kE  197
-#define kF  198
-#define kG  71
-#define kH  72
-#define kI  201
-#define kJ  202
-#define kK  75
-#define kL  204
-#define kM  77
-#define kN  78
-#define kO  207
-#define kP  80
-#define kQ  209
-#define kR  210
-#define kS  83
-#define kT  212
-#define kU  85
-#define kV  86
-#define kW  215
-#define kX  216
-#define kY  89
-#define kZ  90
-*/
 
 class Minitel : public SoftwareSerial {
 
 private :	
-	//String _characters;
-	//String _accents;
 	byte _currentBgColor;
 	byte _currentTextColor;
 	byte _currentMode;
@@ -204,7 +142,6 @@ private :
 	boolean _currentShowCursor;
 	boolean _menuKeyPressed;
 	void init();
-	void refreshSettings();
 	void mode(byte mode);
 	void cursor(boolean b);
 	void blink(boolean b);
@@ -223,6 +160,7 @@ public :
 
 	Minitel();
 	Minitel(int rx, int tx);
+	void refreshSettings();
 	byte getGraphicChar(String s);
 	void serialprint7(byte b);
 	void graphic(String s, int x, int y);
@@ -242,7 +180,7 @@ public :
 	void bgColor(byte c);
 	void textColor(byte c);
 	void useDefaultColors();
-	void moveCursorTo(int x, int y);
+	void moveCursorTo(byte x, byte y);
 	void moveCursor(byte dir);
 	void moveCursorTo(byte location);
 	void moveCursor(byte dir, int n);

文件差异内容过多而无法显示
+ 19 - 0
examples/MinitelBoobs/MinitelBoobs.ino


+ 49 - 0
examples/MinitelElectroCardio/Minitel_ElectroCardio.ino

@@ -0,0 +1,49 @@
+/**
+ * Minitel library for Arduino (v0.1) / May 2013
+ * http://github.com/01010101/Minitel
+ *
+ * By Jerome Saint-Clair aka 01010101
+ * http://saint-clair.net
+ * 
+ * For the Graffiti Research Lab France
+ * http://graffitiresearchlab.fr
+ * 
+ * Based on works by the Tetalab (Fabrice, Renaud, PG & Phil)
+ * http://tetalab.org
+ */
+ 
+#include <SoftwareSerial.h>
+#include <Minitel.h>
+
+Minitel m;
+int counter = 0;
+byte ccc = 36;
+
+char c[] = {ccc,11,ccc,11,ccc,11,ccc,11,ccc,10,ccc,10,ccc,10,ccc,ccc,10,ccc,ccc,11,8,ccc,11,8,ccc,11,8,ccc,11,8,ccc,11,8,ccc,11,8,ccc,11,8,ccc,11,8,ccc,11,8,ccc,11,8,ccc,11,8,ccc,11,8,ccc,11,8,ccc,11,8,7,10,10,9,ccc,10,ccc,10,8,ccc,10,8,ccc,10,8,ccc,10,8,ccc,10,8,ccc,10,8,ccc,10,8,ccc,10,8,ccc,10,8,ccc,10,8,ccc,10,8,ccc,10,8,ccc,10,8,9,ccc,10,ccc,ccc,11,ccc,11,ccc,11,ccc,11,ccc,ccc,ccc,11,ccc,11,ccc,ccc,ccc,10,ccc,10,ccc,ccc,ccc,ccc,ccc,ccc,ccc,ccc,ccc,ccc,ccc,ccc,ccc};
+
+void setup() {
+}
+
+void loop() {
+  m.clearScreen();
+  m.graphicMode();
+
+  m.moveCursorTo(1,18);
+  for (int i=0; i<sizeof(c); i++) {
+   m.textByte(c[i]); 
+  }
+  delay(900);
+  counter ++;
+
+  if (counter == 20) {
+    m.clearScreen();
+    counter = 0;
+    m.moveCursorTo(1,14);
+    for (int i=0; i<40; i++) {
+      m.textByte(ccc);
+    }
+    m.bip(1000);
+    delay(5000);
+  }
+} 
+

+ 180 - 0
examples/MinitelGoogleSearch/MinitelGoogleSearch.ino

@@ -0,0 +1,180 @@
+/**
+ * Minitel library for Arduino (v0.1) / May 2013
+ * http://github.com/01010101/Minitel
+ *
+ * By Jerome Saint-Clair aka 01010101
+ * http://saint-clair.net
+ * 
+ * For the Graffiti Research Lab France
+ * http://graffitiresearchlab.fr
+ * 
+ * Based on works by the Tetalab (Fabrice, Renaud, PG & Phil)
+ * http://tetalab.org
+ */
+ 
+#include <SoftwareSerial.h>
+#include <Minitel.h>
+
+Minitel m;
+
+void setup() {
+}
+
+void loop() {
+
+  m.clearScreen();
+  m.graphicMode();
+  m.pixelate();
+  m.graphic("000001", 1, 1);
+  m.graphic("011000");
+  m.graphic("110000");
+  m.graphic("110000");
+  m.graphic("101101");
+  m.graphic("000010");
+  m.graphic("100010", 1, 2);
+  m.graphic("000000");
+  m.graphic("000110");
+  m.graphic("000110");
+  m.graphic("000110");
+  m.graphic("000110");
+  m.graphic("000001", 1, 3);
+  m.graphic("011001");
+  m.graphic("011001");
+  m.graphic("011001");
+  m.graphic("011000");
+  m.graphic("000001");
+
+  m.graphic("100001", 1, 4);
+  m.graphic("100010");
+  m.graphic("100000");
+  m.graphic("100000");
+  m.graphic("000000");
+  m.graphic("000110");
+
+  m.graphic("000000", 1, 5);
+  m.graphic("110100");
+  m.graphic("001100");
+  m.graphic("001100");
+  m.graphic("011000");
+  
+  m.noPixelate();
+
+  m.textMode();
+  m.invertVideo();
+  m.textColor(CYAN);
+  m.bgColor(WHITE);
+  m.text(" RECHERCHE           ", 13, 1);
+  
+  m.graphicMode();
+  m.graphic("111110");
+  m.graphic("110000");
+  m.graphic("111110");
+  m.graphic("110000");
+  m.graphic("111111");
+  
+  m.textMode();
+  m.text(" PAR NOM             ", 13, 2);
+  
+  m.graphicMode(); 
+  m.graphic("101111");
+  m.graphic("000000");
+  m.graphic("101111");
+  m.graphic("000000");
+  m.graphic("111111");
+
+  m.textMode();
+  m.text(" OU PAR RUBRIQUE     ", 13, 3);
+  
+  m.graphicMode(); 
+  m.graphic("111111");
+  m.graphic("000011");
+  m.graphic("111111");
+  m.graphic("000011");
+  m.graphic("111111");
+
+  m.standardVideo();  
+  m.graphicMode(); 
+  m.bgColor(BLACK);
+  m.graphic("110000", 13, 4);
+  m.repeat(25);
+  
+  m.textMode();
+  m.textColor(WHITE);
+
+  m.text("NOM:", 9, 5);
+  dots(13, 5, 25);
+  m.text("ou  ", 9, 6);
+  dots(13, 6, 25);
+
+
+  m.text("RUBRIQUE:",4, 7);
+  dots(13, 7, 25);
+  dots(13, 8, 25);
+  dots(13, 9, 25);
+
+  m.text("LOCALITE:", 4, 10);
+  dots(13, 10, 25);
+  dots(13, 11, 25);
+
+  m.text("vous pouvez préciser", 13, 12);
+
+  m.text("DEPARTEMENT:", 1, 13);
+  dots(13, 13, 25);
+
+  m.text("ADRESSE:", 5, 14);
+  dots(13, 14, 25);
+
+  m.text("PRENOM:", 6, 15);
+  dots(13, 15, 25);
+
+  m.textByte(126, 1, 19);
+  m.repeat(39);
+    
+  m.text("ligne suivante ", 9, 20);
+  m.invertVideo();
+  m.text(" Suite  ", 32, 20);
+  m.standardVideo();
+
+  m.text("ligne précédente ", 9, 21);
+  m.invertVideo();
+  m.text(" Retour ", 32, 21);
+  m.standardVideo();
+  
+  m.text("effacer ", 9, 22);
+  m.invertVideo();
+  m.text(" Correc.", 32, 22);
+  m.standardVideo();
+  
+  m.text("choisir dans une liste ", 9, 23);
+  m.invertVideo();
+  m.text(" Guide  ", 32, 23);
+  m.standardVideo();
+  
+  m.text("obtenir la réponse ", 9, 24);
+  m.invertVideo();
+  m.text(" Envoi  ", 32, 24);
+  m.standardVideo();
+  
+
+  delay(1000);
+  m.text("G", 13, 5);
+  delay(1000);
+  m.text("O");
+  delay(1000);
+  m.text("O");
+  delay(1000);
+  m.text("G");
+  delay(1000);
+  m.text("L");
+  delay(1000);  
+  m.text("E");
+
+  delay(60000);
+
+}
+
+void dots(int x, int y, int w) {
+  m.text(".", x, y);
+  m.repeat(w);
+}
+

文件差异内容过多而无法显示
+ 19 - 0
examples/MinitelInternetmaTuer/MinitelInternetmaTuer.ino


+ 231 - 0
examples/MinitelNyanCat/MinitelNyanCat.ino

@@ -0,0 +1,231 @@
+/**
+ * Minitel library for Arduino (v0.1) / May 2013
+ * http://github.com/01010101/Minitel
+ *
+ * By Jerome Saint-Clair aka 01010101
+ * http://saint-clair.net
+ * 
+ * For the Graffiti Research Lab France
+ * http://graffitiresearchlab.fr
+ * 
+ * Based on works by the Tetalab (Fabrice, Renaud, PG & Phil)
+ * http://tetalab.org
+ */
+ 
+#include <SoftwareSerial.h>
+#include <Minitel.h>
+
+Minitel m;
+
+void setup() {
+}
+
+void loop() {
+  m.graphicMode();
+  m.clearScreen();
+  m.graphicMode();
+  bg();
+  rainbow(2, 10);  
+  body(12, 9);
+
+  drawStar1(28, 4);
+  drawStar1(20, 21);
+
+  drawStar2(5, 5, false);
+  drawStar2(22, 9, true);
+  drawStar2(35, 20, false);
+  drawStar2(20, 5, true);
+
+  drawStar2(5, 20, true);
+  drawStar3(32, 11);  
+  drawFrame();
+
+  delay(60000);
+
+}
+
+void drawFrame() {
+  m.graphicMode();
+  m.rect((byte) m.getGraphicChar("011001"), 1, 1, 39, 24);
+ 
+}
+
+
+void drawStar1(int x, int y) {
+  m.graphicMode();
+  m.textColor(WHITE);
+  m.blink();
+  m.graphic("111111", x, y);
+  m.noBlink();
+  m.graphic("111111", x, y-1);
+  m.graphic("111111", x, y+1);
+  m.graphic("111111", x-1, y);
+  m.graphic("111111", x+1, y);  
+}
+
+void drawStar2(int x, int y, boolean b) {
+  m.textMode();
+  //m.m.bgColor
+  m.bgColor(RED);
+  if (b) {
+    m.blink();
+  }
+  m.text(" *", x, y);
+  if (b) {
+    m.noBlink();
+  }
+}
+
+void drawStar3(int x, int y) {
+  m.graphicMode();
+  m.bgColor(RED);
+  m.textColor(WHITE);
+
+  m.graphic("001111", x, y-2);  
+  m.graphic("111100", x, y-1);  
+  m.graphic("111100", x, y);
+  m.graphic("111111", x, y+1);  
+  m.graphic("110000", x, y+2);  
+
+
+  m.graphic("101000", x-1, y);  
+  m.graphic("111100", x-2, y);  
+
+  m.graphic("010100", x+1, y);  
+  m.graphic("111100", x+2, y);  
+
+
+}
+
+
+
+void body(int x, int y) {
+  m.graphicMode();
+
+  m.moveCursorTo(x, y);
+  m.bgColor(RED);
+  m.textColor(BLACK);
+
+  m.graphic("000001");
+  m.graphic("000011");
+  m.repeat(7);
+
+  for (int i=1; i<7; i++) {
+    m.moveCursorTo(x, y+i);
+    m.graphic("101010");
+    m.moveCursor(RIGHT, 8);
+    m.graphic("101010");
+  }
+
+
+  m.moveCursorTo(x-1, y+7);
+  m.graphic("011011");  
+
+
+  // Legs
+  m.moveCursorTo(x, y+7);
+  m.graphic("111000");
+  m.graphic("111001");  
+  m.graphic("111010");
+
+  m.graphic("110000");
+  m.graphic("110000");
+  m.graphic("111001");
+  m.graphic("111010");
+
+  m.graphic("110100");
+  m.graphic("110111");
+
+  // Fur
+  m.moveCursorTo(x+2, y+2);
+  m.graphic("010000");
+  m.moveCursorTo(x+4, y+3);
+  m.graphic("010010");
+
+  m.moveCursorTo(x+2, y+4);
+  m.graphic("010010");
+  m.moveCursorTo(x+4, y+5);
+  m.graphic("010010");
+
+  m.moveCursorTo(x+6, y+2);
+  m.graphic("100001");
+
+  // tail
+  m.moveCursorTo(x-3, y+4);
+  m.graphic("111011");
+  m.graphic("110011");
+  m.graphic("110011");
+
+  // Head
+  m.moveCursorTo(x+6, y+3);
+  m.graphic("011010");
+  m.graphic("001001");
+  m.graphic("000011");
+  m.graphic("100110");
+  m.graphic("100101");
+  m.graphic("000000");
+
+  m.moveCursorTo(x+5, y+4);
+  m.graphic("000001");
+  m.graphic("101000");
+  m.graphic("000010");
+  m.graphic("000000");
+  m.graphic("000001");
+  m.graphic("010100");
+  m.graphic("000010");
+
+  m.moveCursorTo(x+5, y+5);
+  m.graphic("010101");
+  m.graphic("010000");
+  m.graphic("100010"); // eyeleft
+  m.graphic("100010");
+  m.graphic("110010");
+  m.graphic("000000");
+  m.graphic("101010");
+
+  m.moveCursorTo(x+6, y+6);
+  m.graphic("101001");
+  m.graphic("110000");
+  m.graphic("110000");
+  m.graphic("100000");
+  m.graphic("010110");
+
+  m.moveCursorTo(x+9, y+7);
+  m.graphic("110000");
+  m.graphic("100000");
+}
+
+void bg() {
+  m.graphicMode();
+  m.textColor(RED);
+  m.moveCursorTo(1, 1);
+  for (int i=1; i<25; i++) {
+    m.graphic("111111");
+    m.repeat(39);
+  }
+
+}
+
+void rainbow(int x, int y) {
+
+  //WHITE, YELLOW, CYAN, GREEN, BLUE, RED, MAGENTA, BLACK
+  m.graphicMode();
+
+  int colors[] = {
+    RED, MAGENTA, YELLOW, WHITE, GREEN, CYAN, BLUE, RED  };
+
+  for (int i=0; i<8; i++) {
+    m.bgColor(colors[i]);
+    m.textColor(colors[i+1]);
+    m.graphic("001111", x, y+i);
+    //    m.repeat(1);
+    m.graphic("111111");
+    m.repeat(2);
+    m.graphic("001111");
+    m.repeat(2);
+    m.graphic("111111");
+    m.repeat(2);
+  }
+}
+
+

部分文件因为文件数量过多而无法显示