Alle Uebungen ab Uebung 4

Dependencies:   C12832 Terminal mbed

Files at this revision

API Documentation at this revision

Comitter:
Leitner
Date:
Tue Nov 28 13:54:52 2017 +0000
Commit message:
DIC 3BHEL

Changed in this revision

C12832.lib Show annotated file Show diff for this revision Revisions of this file
Terminal.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r 86fbfadf398b C12832.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/C12832.lib	Tue Nov 28 13:54:52 2017 +0000
@@ -0,0 +1,1 @@
+https://mbed.org/users/chris/code/C12832/#7de323fa46fe
diff -r 000000000000 -r 86fbfadf398b Terminal.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Terminal.lib	Tue Nov 28 13:54:52 2017 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/users/simon/code/Terminal/#85184c13476c
diff -r 000000000000 -r 86fbfadf398b main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Tue Nov 28 13:54:52 2017 +0000
@@ -0,0 +1,646 @@
+#include "mbed.h"
+#include "C12832.h"
+#include "Terminal.h"
+
+
+C12832 lcd(p5, p7, p6, p8, p11);
+
+Serial fs(USBTX, USBRX);
+DigitalOut myled1(LED1);
+DigitalOut myled2(LED2);
+DigitalOut myled3(LED3);
+DigitalOut myled4(LED4);
+
+BusOut Leds(LED1, LED2, LED3, LED4);
+//BusOut RGBLed(p23, p24, p25);
+BusIn joy(p15,p12,p13,p16); // 1 = up, 2 = down, 4 = left, 8 = right
+DigitalIn center(p14);
+// Übung 4: A
+/*
+// CENTER UP DOWN LEFT RIGHT
+BusIn joy(p15,p12,p13,p16);
+DigitalIn center(p14);
+
+int cnt=7;
+
+int main()
+{
+    Leds = cnt;
+    while(1) 
+    {
+        lcd.cls();
+        while (joy == 8)
+        {
+            lcd.locate(25,10);
+                lcd.printf("right cnt: %i", cnt);
+            cnt = cnt - 2;
+            if (cnt < 0)
+             cnt = 0;
+            Leds = cnt;
+            wait(0.5);
+        }
+        while (joy == 4)
+        {
+            lcd.locate(25,10);
+                lcd.printf("left cnt: %i", cnt);
+            cnt= cnt + 2;
+            if (cnt > 15)
+             cnt = 0;
+            Leds = cnt;
+            wait(0.5);
+        }
+        while (joy == 2)
+        {
+            lcd.locate(25,10);
+                lcd.printf("down cnt: %i", cnt);
+            cnt--;
+            if (cnt < 0)
+             cnt = 0;
+            Leds = cnt;
+            wait(0.5);
+        }
+        while (joy == 1)
+        {
+            lcd.locate(25,10);
+                lcd.printf("up cnt: %i", cnt);
+            cnt++;
+            if (cnt > 15)
+             cnt = 0;
+            Leds = cnt;
+            wait(0.5);
+        }
+        while (center)
+        {
+            lcd.locate(25,10);
+                lcd.printf("center cnt: %i", cnt);
+            cnt = 0;
+            Leds = cnt;
+            wait(0.5);
+        }
+    }
+}
+*/
+// Application Board: Joystick
+
+/*
+Schreiben sie ein Programm, dass die Inputs des Joysticks
+Auf den blauen LED's widerspiegelt.
+Wird dir mittlere Taste des Joysticks betätigt sollen alle Leds leuchten.
+Dieser Zustand lautet: "Fire".
+
+
+BusIn biJoyStick(p15,p12,p13,p16);
+DigitalIn diFireButton(p14);
+
+BusOut boBlueLeds(LED1,LED2,LED3,LED4);
+
+int main()
+{
+    while(1) {
+        if (diFireButton) {
+            boBlueLeds=0xf;
+        } else {
+            boBlueLeds=biJoyStick;
+        }
+        wait(0.1);
+    }
+}
+*/
+
+/*
+void switchLeds(char led1, char led2, char led3, char led4, float time)
+{
+ if(led1 == 'E') myled1 = 1;
+ else            myled1 = 0;
+ if(led2 == 'E') myled2 = 1;
+ else            myled2 = 0;
+ if(led3 == 'E') myled3 = 1;
+ else            myled3 = 0;
+ if(led4 == 'E') myled4 = 1;
+ else            myled4 = 0;  
+ wait(time);
+}
+int leds = 0;
+int a = 0;
+int main()
+{
+    
+    while(1) 
+    {
+    switchLeds('a','a','a','a', 0.5);
+        a = 0;
+           
+        while (joy == 2)
+        {
+           
+           switch(a)
+            {
+                case 0:
+                switchLeds('E','a','a','a', 0.5);
+                break;
+                
+                case 1:
+                switchLeds('a','E','a','a', 0.5);
+                break;
+                
+                case 2: 
+                switchLeds('a','a','E','a', 0.5);
+                break;
+                
+                case 3:
+                switchLeds('a','a','a','E', 0.5);
+                break;
+                
+                case 4: 
+                switchLeds('a','a','E','a', 0.5);
+                break;
+                
+                case 5:
+                switchLeds('a','E','a','a', 0.5);
+                break;
+                
+                case 6:
+                switchLeds('E','a','a','a', 0.5);
+                break;
+                
+                default:
+                break;
+            }
+           a++;
+            if (a > 6)
+            a =0;
+        }
+        
+       while (joy ==1)
+        {
+           
+           switch(a)
+            {
+                case 0:
+                switchLeds('E','a','a','a', 0.5);
+                break;
+                
+                case 1:
+                switchLeds('a','E','a','a', 0.5);
+                break;
+                
+                case 2: 
+                switchLeds('a','a','E','a', 0.5);
+                break;
+                
+                case 3:
+                switchLeds('a','a','a','E', 0.5);
+                break;
+                
+                
+                default:
+                break;
+            }
+           a++;
+            if (a > 3)
+            a =0;
+        }
+    }
+}
+*/
+// Übung 4: C
+/*
+int main()
+{
+    char wort[20];
+    fs.printf("Bitte gib mir Wort");
+    
+    fs.scanf("%s", wort);
+    
+    fs.printf("Wort: %s", wort);
+    while(1) 
+    {
+        
+        
+        char wortchanged[20];
+    
+    
+        
+        if (joy == 4)
+        {
+            int a= 0;
+            for (int i = 1; wort[i] != '\0'; i++)
+            {
+                
+                
+                a++;
+            }
+            for (int i = 1; i < sizeof(wort); i++)
+            {
+                
+                wortchanged[i-1] = wort[i];
+                
+            }
+            
+            
+            wortchanged[a] = wort[0];
+            
+            lcd.locate(25,10);
+                lcd.printf("%s,%s",wort, wortchanged);
+                wait(5);
+                lcd.cls();
+        }
+        if (joy == 8)
+        {
+            int a= 0;
+            for (int i = 1; wort[i] != '\0'; i++)
+            {
+                a++;
+            }
+            for (int i = 1; i <= a; i++)
+            {
+                
+                wortchanged[i] = wort[i - 1];
+                
+            }
+            
+            
+            wortchanged[0] = wort[a];
+            
+            lcd.locate(25,10);
+                lcd.printf("%s,%s",wort, wortchanged);
+                wait(5);
+                lcd.cls();
+        }
+        if (center)
+        {
+            
+        }
+     }
+}
+*/
+// Übung 4: D
+/*
+#include "mbed.h"
+#include "C12832.h"
+
+DigitalIn JDown(p12);
+DigitalIn JLeft(p13);
+DigitalIn JUp(p15);
+DigitalIn JRight(p16);
+DigitalOut myled(LED1);
+BusOut leds(LED4, LED3, LED2, LED1);
+C12832 lcd(p5, p7, p6, p8, p11);
+DigitalOut red(p23);
+DigitalOut green(p24);
+DigitalOut blue(p25);
+
+int main()
+{
+    red=green=blue=1;
+    leds=0x00;
+
+    while(1) 
+    {
+        if(JUp ==1) 
+        {
+            leds=0x08;
+            wait(0.5);
+            while(JUp==1)
+             {
+                leds=leds>>1;
+                wait(0.5);
+                if(leds==0x01) 
+                {
+                    leds=0x08;
+                    wait(0.5);
+                }
+            }
+        } 
+        else if(JDown ==1) 
+        {
+            leds=0x08;
+            wait(0.25);
+            while(JDown==1) 
+            {
+                leds=leds>>1;
+                wait(0.25);
+                if(leds==0x01) 
+                {
+                    for(int i=0; i<3; i++) 
+                    {
+                        leds=leds<<1;
+                        wait(0.25);
+                    }
+                }
+            }
+        } 
+        else 
+        {
+            leds = 0x0;
+        }
+    }
+}
+*/
+// Übung 5: A
+/*
+int main ()
+{
+  
+// 8 right, 4 left, 2 down, 1 up
+
+int right = 8;
+int left = 4;
+int down = 2;
+int up = 1;
+int z = 0;
+int zHashtag = 0;
+int zReset = 0;
+void cls();
+
+char wort[20];
+bool selection = true;
+
+   
+    fs.printf("Bitte geben Sie ein Wort ein. (20 Zeichen max)"); 
+    fs.scanf("%s",wort);
+    for (int i = 0; wort[i] != 0; i++)
+    {
+        z++;
+    }
+    char position[80];
+    int posi = 0;
+     position[0] = '^';
+     position[1] = 0;
+        
+    while (1)
+    {
+       
+        if (selection)
+        {        
+            fs.printf("\n\n\n%s\n",wort);
+            fs.printf("%s", position); 
+            selection = false;
+        }        
+              
+        if(joy == right && posi < z-1)
+        {
+            position[posi] = ' ';
+            posi++;
+            position[posi] = '^';
+            
+            position[posi+1] = 0;
+            selection = true;
+            while(joy == right);
+        }
+        
+        else if(joy == left && posi > 0)
+        {
+            position[posi] = ' ';
+            posi--;
+            position[posi] = '^';
+            
+            position[posi+1] = 0;
+            selection = true;
+            while(joy == left);
+        }
+        
+        else if (center) 
+        {
+            zReset++;
+            zHashtag = 0;
+            for (int i = 0; position[i] != 0; i++)
+            {
+                zHashtag++;
+            }
+            wort[zHashtag-1] = '#';
+            selection = true;
+            wait(1);
+        }
+        
+    }
+}
+*/
+// Übung 5: B 
+
+ /*
+int main ()
+{
+  
+// 8 right, 4 left, 2 down, 1 up
+
+int right = 8;
+int left = 4;
+int down = 2;
+int up = 1;
+int z = 0;
+int zHashtag = 0;
+int zReset = 0;
+void cls();
+
+char wort[20];
+bool selection = true;
+
+   
+    fs.printf("Bitte geben Sie ein Wort ein. (20 Zeichen max)"); 
+    fs.scanf("%s",wort);
+    for (int i = 0; wort[i] != 0; i++)
+    {
+        z++;
+    }
+ 
+   
+   
+        
+    while (1)
+    {
+       
+        if (selection)
+        {        
+            fs.printf("\n\n\n%s\n",wort);
+            
+            selection = false;
+        }        
+              
+        if(joy == right)
+        {
+            int first = 0;
+            wort[z-1] = wort[z];
+            for(int i = 0; i < z; i++)
+            {
+               if (i != z-1)
+               {
+                wort[i] = wort[i+1];
+                }
+            }
+            
+            selection = true;
+            while(joy == right);
+        }
+        /*
+        else if(joy == left && posi > 0)
+        {
+            position[posi] = ' ';
+            posi--;
+            position[posi] = '^';
+            
+            position[posi+1] = 0;
+            selection = true;
+            while(joy == left);
+        }
+        
+        else if (center) 
+        {
+            zReset++;
+            zHashtag = 0;
+            for (int i = 0; position[i] != 0; i++)
+            {
+                zHashtag++;
+            }
+            wort[zHashtag-1] = '#';
+            selection = true;
+            wait(1);
+        }
+        */
+        
+    }
+}
+
+// Übung 5: C 
+/*
+int main ()
+{
+    
+int right = 8;
+int left = 4;
+int down = 2;
+int up = 1;
+int z = 0;
+int zHashtag = 0;
+int zReset = 0;
+char ersatz;
+void cls();
+
+char wort[20];
+bool selection = true;
+
+   
+    fs.printf("Bitte geben Sie ein Wort ein. (20 Zeichen max)"); 
+    fs.scanf("%s",wort);
+    for (int i = 0; wort[i] != 0; i++)
+    {
+        z++;
+    }
+    char position[80];
+    int posi = 0;
+     position[0] = '^';
+     position[1] = 0;
+        
+    while (1)
+    {
+       
+        if (selection)
+        {        
+            fs.printf("\n\n\n%s\n",wort);
+            fs.printf("%s", position); 
+            selection = false;
+        }        
+              
+        if(joy == right && posi < z-1)
+        {
+            position[posi] = ' ';
+            posi++;
+            position[posi] = '^';
+            
+            position[posi+1] = 0;
+            selection = true;
+            while(joy == right);
+        }
+        
+        else if(joy == left && posi > 0)
+        {
+            position[posi] = ' ';
+            posi--;
+            position[posi] = '^';
+            
+            position[posi+1] = 0;
+            selection = true;
+            while(joy == left);
+        }
+        else if (joy == up) 
+        {
+            zHashtag = 0;
+            for (int i = 0; position[i] != 0; i++)
+            {
+                zHashtag++;
+            }
+            if(wort[zHashtag-1] <= 'z' && wort[zHashtag-1] >= 'a')
+            {
+                fs.printf("Klein machen");
+                wort[zHashtag-1] -= 32;
+            }
+            
+            else if(wort[zHashtag-1] <= 'Z' && wort[zHashtag-1] >= 'A')
+            {
+                 fs.printf("Klein machen");
+                 wort[zHashtag-1] += 'a' - 'A';
+            }
+            selection = true;
+            while(joy == up);
+        }
+        else if (joy == down)
+        {
+            zHashtag = 0;
+            for (int i = 0; position[i] != 0; i++)
+            {
+                zHashtag++;
+            }
+            printf("\nNeues Zeichen: \n");
+            scanf("%c", &ersatz);
+            wort[zHashtag-1] = ersatz;
+            selection = true;
+            while (joy == down);
+            
+        }
+        else if (center) 
+        {
+            
+            zReset++;
+            zHashtag = 0;
+            for (int i = 0; position[i] != 0; i++)
+            {
+                zHashtag++;
+            }
+            if(wort[zHashtag-1] == 'z')
+            {
+                wort[zHashtag-1] = 'A';
+            }
+            else if(wort[zHashtag-1] == 'Z')
+            {
+                wort[zHashtag-1] = 'a';
+            }
+            else if(wort[zHashtag-1] == '9')
+            {
+                wort[zHashtag-1] = '0';
+            }
+            else if(wort[zHashtag-1] < 'z' && wort[zHashtag-1] >= 'a')
+            {
+                wort[zHashtag-1]++;
+            }
+            else if(wort[zHashtag-1] < 'Z' && wort[zHashtag-1] >= 'A')
+            {
+                 wort[zHashtag-1]++;
+            }
+            else if(wort[zHashtag-1] < '9' && wort[zHashtag-1] >= '0')
+            {
+                 wort[zHashtag-1]++;
+            }
+            else
+            {
+                wort[zHashtag-1] = '-';
+            }
+            
+            selection = true;
+            while (center);
+        } 
+        
+        
+        
+    }
+}
+*/
\ No newline at end of file
diff -r 000000000000 -r 86fbfadf398b mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Tue Nov 28 13:54:52 2017 +0000
@@ -0,0 +1,1 @@
+https://mbed.org/users/mbed_official/code/mbed/builds/86740a56073b
\ No newline at end of file