a

Dependencies:   Led-libary TextLCD mbed

Fork of Mbed-Mensch-8 by Projekte_werkstatt

Revision:
29:42646ca2f941
Parent:
28:94a949b0f03a
Child:
30:3482779d97af
--- a/main.cpp	Fri Apr 15 12:58:59 2016 +0000
+++ b/main.cpp	Fri Apr 15 14:18:11 2016 +0000
@@ -138,16 +138,20 @@
 void print_pos();
 void print_color();
 void print_default();
+void menuInit();
 void posUpdate();
 char ausfuehren(uint32_t postion);
 
 //string test ("");                                 0x0                     0x1                  0x2                   0x3                      0x4                   0x5                    0x6                    0x7                    0x8                     0x9                     0xA                    0xB                   0xC                     0xD                 0xE                     0xF                   0x10                    0x11                   0x12                  0x13                    0x14                    0x15                  0x16                    0x17
 //                                "1234567890123456789","1234567890123456789","1234567890123456789","1234567890123456789",  ,"1234567890123456789","1234567890123456789","1234567890123456789",
 const char* const text_ln0[] = { "MENU:              ", "Spiel-Menu:        ", "Anzeige-Menu:      ", "Speicher-Menu:     ", "ERROR              ", "7.Zustand-Menu:    ", "Farben-Menu:       ", "Spiel-Menu:        ", "Spielregeln-Menu:  ", "Spielregeln-Menu:  ", "Hell./Sp.Led-Menu: ", "Config-Menu:       ", "Autplay-zeit       ", "Autplay-Menu:      ", "Wurfel-Menu:       ", "Ofline/Com-Menu:   ", "Enable/Manuell     ", "Farben             ", "Helligkeit Wert    ", "Sp.Led-Verhalten   ", "Farbverhalten      ", "Farbverhalten def  ", "Helligkeit Wert    ","KI-Menu            "};
-const char* const text_ln1[] = { "Spiel              ", "7.Zustand          ", "Farben             ", "Spiel              ", "                   ", "Disable            ", "                   ", "Laden              ", "Taktik 1           ", "Smeiszwang <I/0>   ", "Wert: <wert>       ", "Laden              ", "normal             ", "Zeit               ", "Farbverhalten      ", "New                ", "                   ", "R:                 ", "100%               ", "Verhalten 1        ", "fixe Farbe         ", "Standart           ", "100%               ","                   "};
+const char* const text_ln1[] = { "Spiel              ", "7.Zustand          ", "Farben             ", "Spiel              ", "Postion:           ", "Disable            ", "                   ", "Laden              ", "Taktik 1           ", "Smeiszwang <I/0>   ", "Wert: <wert>       ", "Laden              ", "normal             ", "Zeit               ", "Farbverhalten      ", "New                ", "                   ", "R:                 ", "100%               ", "Verhalten 1        ", "fixe Farbe         ", "Standart           ", "100%               ","                   "};
 const char* const text_ln2[] = { "Anzeige            ", "Spielregeln        ", "Hellichkeit/Sp.Led ", "Config.            ", "                   ", "kleinstmoglich     ", "SP: 1   2   3   4  ", "Speichern          ", "Taktik 2           ", "Go Home first <I/0>", "Sp.Led-Verhalten   ", "Speichern          ", "x2                 ", "Agro/Taktik        ", "Farb def           ", "Reset              ", "                   ", "G:                 ", "75%                ", "Verhalten 2        ", "Spieler Farbe      ", "erlaubt            ", "75%                ","SP: 1   2   3   4  " };
 const char* const text_ln3[] = { "Speicher           ", "Autoplay           ", "Wurfel             ", "Ofline/Com         ", "                   ", "grostmoglich       ", "                   ", "Reset              ", "Taktik 3           ", "Ausfahrzwang <I/0> ", "Andert: <wert> fehl", "Reset              ", "x4                 ", "Enable/Manuell     ", "Hellichkeit        ", "Com                ", "                   ", "B:                 ", "50%                ", "Verhalten 3        ", "3 Farben           ", "verboten           ", "50%                ","                   "};
-char textPos[] = { 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x4, 0x9, 0xA, 0xB, 0x4, 0xD, 0xE, 0xF, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x11, 0x17, 0x18, 0x19, 0x12, 0x1B, 0x1C, 0xC, 0x14, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x11, 0x27, 0x28, 0x29, 0x13, 0x2B, 0x10, 0x2D, 0x15, 0x2F, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x11, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x17, 0x16, 0x3F, 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x11, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x11, 0x57, 0x58, 0x59, 0x5A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F };
+//jetzt in menuInit() am Ende definiert!
+//char textPos[] = { 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x4, 0x9, 0xA, 0xB, 0x4, 0xD, 0xE, 0xF, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x11, 0x17, 0x18, 0x19, 0x12, 0x1B, 0x1C, 0xC, 0x14, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x11, 0x27, 0x28, 0x29, 0x13, 0x2B, 0x10, 0x2D, 0x15, 0x2F, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x11, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x17, 0x16, 0x3F, 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x11, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x11, 0x57, 0x58, 0x59, 0x5A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F };
+char textPos[255];
+
 
 char VHS = 0;
 char mSelected[50];
@@ -315,9 +319,14 @@
     }
 }
 
-int main()
+int main() 
 {
     Random.start();
+
+    for (char k = 0; k < 255; k++)
+        textPos[i]=4;
+    
+    menuInit();
     //Random.stop();
     //Random.read_us();
 
@@ -599,6 +608,8 @@
             Dice.WriteLed(TestC);
             __enable_irq();
             break;
+            default:
+            break;
     }
 }
 
@@ -1450,7 +1461,7 @@
 {
     postion = 0;
     for (char i = 0; i < depth - 1; i++)
-        postion = postion | (mSelected[i] << (i * 2));
+        postion = postion | (mSelected[i] << (i * 3));
 }
 
 void up()
@@ -1519,7 +1530,7 @@
     {
         postion = 0;
         for (char i = 0; i < depth; i++)
-            postion = postion | (mSelected[i] << (i * 2));
+            postion = postion | (mSelected[i] << (i * 3));
         char temp = ausfuehren(postion);
         if (temp > 0)
         {
@@ -1644,7 +1655,13 @@
     lcd.locate(1, 3);
     lcd.printf(text_ln3[textPos[postion]]);
     port.printf("D%c%c%s\n", 28, 30, text_ln3[textPos[postion]]);
-    print_zus(); 
+    if(textPos[postion]]==5)
+    {
+        lcd.locate(9, 1);
+        lcd.printf("%d",postion);
+        port.printf("D%c%c%d\n",27+9, 28,postion);
+    }
+
 }
 
 void print_pos()
@@ -1856,4 +1873,104 @@
         break;
     }
     lcd.locate(19, 0);
-}
\ No newline at end of file
+}
+
+ void menuInit()
+ {
+ textPos[0x00] = 0x0;
+ textPos[0x01] = 0x1;
+ textPos[0x02] = 0x2;
+ textPos[0x03] = 0x3;
+ textPos[0x04] = 0x4;
+ textPos[0x05] = 0x5;
+ textPos[0x06] = 0x6;
+ textPos[0x07] = 0x7;
+ textPos[0x08] = 0x4;
+ textPos[0x09] = 0x9;
+ textPos[0x0a] = 0xA;
+ textPos[0x0b] = 0xB;
+ textPos[0x0c] = 0x4;
+ textPos[0x0d] = 0xD;
+ textPos[0x0e] = 0xE;
+ textPos[0x0f] = 0xF;
+ textPos[0x10] = 0x10;
+ textPos[0x11] = 0x11;
+ textPos[0x12] = 0x12;
+ textPos[0x13] = 0x13;
+ textPos[0x14] = 0x14;
+ textPos[0x15] = 0x15;
+ textPos[0x16] = 0x11;
+ textPos[0x17] = 0x17;
+ textPos[0x18] = 0x18;
+ textPos[0x19] = 0x19;
+ textPos[0x1a] = 0x12;
+ textPos[0x1b] = 0x1B;
+ textPos[0x1c] = 0x1C;
+ textPos[0x1d] = 0xC;
+ textPos[0x1e] = 0x14;
+ textPos[0x1f] = 0x1F;
+ textPos[0x20] = 0x20;
+ textPos[0x21] = 0x21;
+ textPos[0x22] = 0x22;
+ textPos[0x23] = 0x23;
+ textPos[0x24] = 0x24;
+ textPos[0x25] = 0x25;
+ textPos[0x26] = 0x11;
+ textPos[0x27] = 0x27;
+ textPos[0x28] = 0x28;
+ textPos[0x29] = 0x29;
+ textPos[0x2a] = 0x13;
+ textPos[0x2b] = 0x2B;
+ textPos[0x2c] = 0x10;
+ textPos[0x2d] = 0x2D;
+ textPos[0x2e] = 0x15;
+ textPos[0x2f] = 0x2F;
+ textPos[0x30] = 0x30;
+ textPos[0x31] = 0x31;
+ textPos[0x32] = 0x32;
+ textPos[0x33] = 0x33;
+ textPos[0x34] = 0x34;
+ textPos[0x35] = 0x35;
+ textPos[0x36] = 0x11;
+ textPos[0x37] = 0x37;
+ textPos[0x38] = 0x38;
+ textPos[0x39] = 0x39;
+ textPos[0x3a] = 0x3A;
+ textPos[0x3b] = 0x3B;
+ textPos[0x3c] = 0x3C;
+ textPos[0x3d] = 0x17;
+ textPos[0x3e] = 0x16;
+ textPos[0x3f] = 0x3F;
+ textPos[0x40] = 0x40;
+ textPos[0x41] = 0x41;
+ textPos[0x42] = 0x42;
+ textPos[0x43] = 0x43;
+ textPos[0x44] = 0x44;
+ textPos[0x45] = 0x45;
+ textPos[0x46] = 0x11;
+ textPos[0x47] = 0x47;
+ textPos[0x48] = 0x48;
+ textPos[0x49] = 0x49;
+ textPos[0x4a] = 0x4A;
+ textPos[0x4b] = 0x4B;
+ textPos[0x4c] = 0x4C;
+ textPos[0x4d] = 0x4D;
+ textPos[0x4e] = 0x4E;
+ textPos[0x4f] = 0x4F;
+ textPos[0x50] = 0x50;
+ textPos[0x51] = 0x51;
+ textPos[0x52] = 0x52;
+ textPos[0x53] = 0x53;
+ textPos[0x54] = 0x54;
+ textPos[0x55] = 0x55;
+ textPos[0x56] = 0x11;
+ textPos[0x57] = 0x57;
+ textPos[0x58] = 0x58;
+ textPos[0x59] = 0x59;
+ textPos[0x5a] = 0x5A;
+ textPos[0x5d] = 0x5B;
+ textPos[0x5c] = 0x5C;
+ textPos[0x5d] = 0x5D;
+ textPos[0x5e] = 0x5E;
+ textPos[0x5f] = 0x5F;
+ }
\ No newline at end of file