a,b Gruppe B
Dependencies: mbed
Revision 0:8a6f8b1df4ea, committed 2015-06-10
- Comitter:
- Planinsec
- Date:
- Wed Jun 10 16:21:26 2015 +0000
- Commit message:
- A+B_Gruppe B
Changed in this revision
Gruppe_B_MatthiasPlaninsec.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 8a6f8b1df4ea Gruppe_B_MatthiasPlaninsec.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Gruppe_B_MatthiasPlaninsec.cpp Wed Jun 10 16:21:26 2015 +0000 @@ -0,0 +1,94 @@ +#include "mbed.h" + + +InterruptIn iiUp(p15); +//Timer timer1; +int los=0; + +// global vars and objects +DigitalOut led2(LED2); +//DigitalOut ledAlle(LED1,LED2, LED3,LED4); +Serial pc(USBTX, USBRX); // tx, rx ; is default !!! (9600, 8N1) +char recChar=0; +bool recFlag=false; +char recArr[20]; +int index=0; + +// functions +void flushSerialBuffer() +{ + while (pc.readable()) + { + pc.getc(); + } +} + +void readData() +{ + + //recArr[index] = recChar; + if ( pc.readable()) //recChar == '\r') || (index>=19) + { + recChar = pc.getc(); + //recFlag = true; + //recArr[index] = 0; + // float t = timer1.read_ms(); + pc.printf(" - That's the input: \n",recArr); + //if(index<5) + //{ + // pc.printf("Eingabe zu kurz "); + //} + //if(index>10) + //{ + // pc.printf("Eingabe zu lang "); + //} + //index = 0; + flushSerialBuffer(); + //los=0; + } + + else + { + return; + } + +} + + void SendText() + { + + pc.printf("Folgende Befehle werden ausgefuehrt:"); + pc.printf("r oder R = alle LEDs aus\n"); + pc.printf("s oder S = alle LEDs ein\n"); + pc.printf("s,Lx = LED x ein (X=1...4\n"); + pc.printf("r,Lx = LED x aus (X=1...4\n"); + pc.printf("I=alle LEDs invertieren (leuchtende LEDs aus, dunkle LEDs ein)\n"); + //timer1.start(); + los=1; + + } + +int main() { +// pc.baud(115200); + pc.baud(38400); + pc.format(8, SerialBase::Odd, 2); + led2 = 1; + + flushSerialBuffer(); + pc.printf("Matthias Planinsec Gruppe B\r\n"); + + + pc.attach(&readData); + SendText(); + + //iiUp.rise(&SendText); + + while(1) { + if (recFlag) { + flushSerialBuffer(); +// pc.printf(" - That's the input: %s\r\n", recArr); // non reantrant function + recFlag = false; + led2 = !led2; + } + } +} \ No newline at end of file
diff -r 000000000000 -r 8a6f8b1df4ea mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Wed Jun 10 16:21:26 2015 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/7cff1c4259d7 \ No newline at end of file