Эх сурвалжийг харах

Simplification of the demoColor()

01010101 10 жил өмнө
parent
commit
e642896859

+ 77 - 77
examples/MinitelDemo/MinitelDemo.ino

@@ -1,29 +1,29 @@
 /**
- * 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
- */
+   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(6,7);
+Minitel m(6, 7);
 
 void setup() {
-  
+
 }
 
 void loop() {
- 
+
   long pause = 2000;
 
   demoColor();
@@ -46,14 +46,14 @@ void loop() {
 
   demoCharacters();
   delay(pause);
-  
+
 }
 
 /**
- *
- * DEMOS
- *
- */
+
+   DEMOS
+
+*/
 
 // Graphic characters
 
@@ -66,76 +66,76 @@ void demoGraphics(boolean underline) {
   m.text(" GRAPHICS DEMO ", 4, 1);
   m.bgColor(BLACK);
 
-  
+
   m.graphicMode();
-  
+
   if (underline) {
     m.pixelate();
   }
   m.noCursor();
 
-  // No color 
+  // No color
   m.useDefaultColors();
 
   int xPos = 5;
   int yPos = 5;
   m.moveCursorTo(xPos, yPos);
   int x = 32;
-  for (int i=x; i<x+16; i++) {
+  for (int i = x; i < x + 16; i++) {
     m.serialprint7(i);
     m.serialprint7(9);
   }
 
-  m.moveCursorTo(xPos, yPos+2);
-  for (int i=x+16; i<x+32; i++) {
+  m.moveCursorTo(xPos, yPos + 2);
+  for (int i = x + 16; i < x + 32; i++) {
     m.serialprint7(i);
     m.serialprint7(9);
   }
 
-  m.moveCursorTo(xPos, yPos+4);
-  for (int i=x+32; i<x+48; i++) {
+  m.moveCursorTo(xPos, yPos + 4);
+  for (int i = x + 32; i < x + 48; i++) {
     m.serialprint7(i);
     m.serialprint7(9);
   }
 
-  m.moveCursorTo(xPos, yPos+6);
-  for (int i=x+48; i<x+64; i++) {
+  m.moveCursorTo(xPos, yPos + 6);
+  for (int i = x + 48; i < x + 64; i++) {
     m.serialprint7(i);
     m.serialprint7(9);
-  } 
+  }
 
   // Colored
   m.bgColor(RED);
   m.textColor(WHITE);
 
-  m.moveCursorTo(xPos, yPos+10);
+  m.moveCursorTo(xPos, yPos + 10);
   x = 32;
-  for (int i=x; i<x+16; i++) {
+  for (int i = x; i < x + 16; i++) {
     m.serialprint7(i);
     m.serialprint7(9);
   }
 
-  m.moveCursorTo(xPos, yPos+12);
-  for (int i=x+16; i<x+32; i++) {
+  m.moveCursorTo(xPos, yPos + 12);
+  for (int i = x + 16; i < x + 32; i++) {
     m.serialprint7(i);
     m.serialprint7(9);
   }
 
-  m.moveCursorTo(xPos, yPos+14);
-  for (int i=x+32; i<x+48; i++) {
+  m.moveCursorTo(xPos, yPos + 14);
+  for (int i = x + 32; i < x + 48; i++) {
     m.serialprint7(i);
     m.serialprint7(9);
   }
 
-  m.moveCursorTo(xPos, yPos+16);
-  for (int i=x+48; i<x+64; i++) {
+  m.moveCursorTo(xPos, yPos + 16);
+  for (int i = x + 48; i < x + 64; i++) {
     m.serialprint7(i);
     m.serialprint7(9);
   }
-  
+
   m.useDefaultColors();
   m.noPixelate();
-  
+
 }
 
 
@@ -194,65 +194,66 @@ void demoCharacters() {
 
   // a->z
   m.moveCursorTo(xPos, yPos);
-  for (int i=97; i<97+26; i++) {
+  for (int i = 97; i < 97 + 26; i++) {
     m.serialprint7(i);
   }
 
   // A->Z
-  m.moveCursorTo(xPos, yPos+1);
-  for (int i=65; i<65+26; i++) {
+  m.moveCursorTo(xPos, yPos + 1);
+  for (int i = 65; i < 65 + 26; i++) {
     m.serialprint7(i);
   }
 
   // 0-9 + punctuation marks, ...
-  m.moveCursorTo(xPos, yPos+2);
-  for (int i=33; i<33+32; i++) {
+  m.moveCursorTo(xPos, yPos + 2);
+  for (int i = 33; i < 33 + 32; i++) {
     m.serialprint7(i);
   }
-  for (int i=91; i<97; i++) {
+  for (int i = 91; i < 97; i++) {
     m.serialprint7(i);
   }
 
   // Colored characters
-  m.moveCursorTo(xPos, yPos+3);
+  m.moveCursorTo(xPos, yPos + 3);
   m.textColor(RED);
-  for (int i=97; i<97+26; i++) {
+  for (int i = 97; i < 97 + 26; i++) {
     m.serialprint7(i);
   }
   m.textColor(WHITE);
 
   // Double width 1/2
-  m.moveCursorTo(xPos, yPos+4);
+  m.moveCursorTo(xPos, yPos + 4);
   m.charSize(SIZE_DOUBLE_WIDTH);
-  for (int i=97; i<97+13; i++) {
+  for (int i = 97; i < 97 + 13; i++) {
     m.serialprint7(i);
-  }  
-  m.moveCursorTo(xPos, yPos+5);
-  for (int i=97+13; i<97+26; i++) {
+  }
+  m.moveCursorTo(xPos, yPos + 5);
+  for (int i = 97 + 13; i < 97 + 26; i++) {
     m.serialprint7(i);
   }
   m.charSize(SIZE_NORMAL);
 
   // Special characters
-  m.moveCursorTo(xPos, yPos+6);
+  m.moveCursorTo(xPos, yPos + 6);
   byte chars[] = {
-    SPE_CHAR_BOOK, SPE_CHAR_PARAGRAPH, SPE_CHAR_ARROW_LEFT, SPE_CHAR_ARROW_UP, SPE_CHAR_ARROW_RIGHT, SPE_CHAR_ARROW_DOWN, SPE_CHAR_CIRCLE, SPE_CHAR_MINUS_PLUS, SPE_CHAR_1_4, SPE_CHAR_1_2, SPE_CHAR_3_4, SPE_CHAR_UPPER_OE, SPE_CHAR_LOWER_OE, SPE_CHAR_BETA                  };
-  for (int i=0; i<sizeof(chars); i++) {
+    SPE_CHAR_BOOK, SPE_CHAR_PARAGRAPH, SPE_CHAR_ARROW_LEFT, SPE_CHAR_ARROW_UP, SPE_CHAR_ARROW_RIGHT, SPE_CHAR_ARROW_DOWN, SPE_CHAR_CIRCLE, SPE_CHAR_MINUS_PLUS, SPE_CHAR_1_4, SPE_CHAR_1_2, SPE_CHAR_3_4, SPE_CHAR_UPPER_OE, SPE_CHAR_LOWER_OE, SPE_CHAR_BETA
+  };
+  for (int i = 0; i < sizeof(chars); i++) {
     m.specialChar(chars[i]);
   }
 
   // Blink
-  m.moveCursorTo(xPos, yPos+7);
+  m.moveCursorTo(xPos, yPos + 7);
   m.blink();
-  for (int i=97; i<97+26; i++) {
+  for (int i = 97; i < 97 + 26; i++) {
     m.serialprint7(i);
   }
   m.noBlink();
 
   // Invert video
-  m.moveCursorTo(xPos, yPos+8);
+  m.moveCursorTo(xPos, yPos + 8);
   m.invertVideo();
-  for (int i=97; i<97+26; i++) {
+  for (int i = 97; i < 97 + 26; i++) {
     m.serialprint7(i);
   }
   m.standardVideo();
@@ -260,9 +261,9 @@ void demoCharacters() {
 
   // Transparent
   // No effet on Minitel 1
-  m.moveCursorTo(xPos, yPos+9);
+  m.moveCursorTo(xPos, yPos + 9);
   m.transparentVideo();
-  for (int i=97; i<97+26; i++) {
+  for (int i = 97; i < 97 + 26; i++) {
     m.serialprint7(i);
   }
   m.standardVideo();
@@ -276,8 +277,8 @@ void demoBip() {
   m.bgColor(RED);
   m.text(" BIP DEMO ", 4, 1);
   m.bgColor(BLACK);
-  
-  for (int i=0; i<2; i++) {
+
+  for (int i = 0; i < 2; i++) {
     m.bip(50);
     delay(700);
     m.bip(5);
@@ -302,7 +303,7 @@ void demoText() {
   m.noBlink();
   m.text("This is a test", 13, 15);
   m.text("****************************************", 1, 20);
-  m.noCursor(); 
+  m.noCursor();
 }
 
 void demoColor() {
@@ -317,40 +318,39 @@ void demoColor() {
   m.bgColor(RED);
   m.rect((byte) m.getGraphicChar("011001"), 4, 4, 33, 20);
 
-  for(int i=0; i<18; i++) {
-    m.moveCursorTo(5, 5+i);
+  for (int i = 0; i < 18; i++) {
+    m.moveCursorTo(5, 5 + i);
 
     m.textColor(WHITE);
-    byte c = m.getGraphicChar("111111");
-    m.textByte(c);
+    m.graphic("111111");
     m.repeat(3);
 
     m.textColor(YELLOW);
-    m.textByte(m.getGraphicChar("111111"));
+    m.graphic("111111");
     m.repeat(3);
 
     m.textColor(CYAN);
-    m.textByte(m.getGraphicChar("111111"));
+    m.graphic("111111");
     m.repeat(3);
 
     m.textColor(GREEN);
-    m.textByte(m.getGraphicChar("111111"));
+    m.graphic("111111");
     m.repeat(3);
 
     m.textColor(BLUE);
-    m.textByte(m.getGraphicChar("111111"));
+    m.graphic("111111");
     m.repeat(3);
 
     m.textColor(RED);
-    m.textByte(m.getGraphicChar("111111"));
+    m.graphic("111111");
     m.repeat(3);
 
     m.textColor(MAGENTA);
-    m.textByte(m.getGraphicChar("111111"));
+    m.graphic("111111");
     m.repeat(3);
 
     m.textColor(BLACK);
-    m.textByte(m.getGraphicChar("111111"));
+    m.graphic("111111");
     m.repeat(3);
   }
 }