nowe + funkcje na lux

Dependencies:   Servo_fullrange mbed

Fork of Kola_Servo_nowe by Dominik Święch

Files at this revision

API Documentation at this revision

Comitter:
yruiewyrui3
Date:
Wed Jun 15 12:33:51 2016 +0000
Parent:
1:da4c204737bf
Commit message:
lux

Changed in this revision

Servo.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
diff -r da4c204737bf -r 325a730cd438 Servo.lib
--- a/Servo.lib	Tue Jun 14 13:32:33 2016 +0000
+++ b/Servo.lib	Wed Jun 15 12:33:51 2016 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/simon/code/Servo/#36b69a7ced07
+https://developer.mbed.org/users/yruiewyrui3/code/Servo_fullrange/#0b7244868ca2
diff -r da4c204737bf -r 325a730cd438 main.cpp
--- a/main.cpp	Tue Jun 14 13:32:33 2016 +0000
+++ b/main.cpp	Wed Jun 15 12:33:51 2016 +0000
@@ -35,7 +35,7 @@
 //*******************KONIEC OPISU******************************************************************//
 
 bool isCorrectPacket(char *buffor){
-    if ((bufor[0]!='@') && (bufor[0]!='&'))
+    if (bufor[0]!='@')
     {
        // stm.printf("ZLY ZNAK POCZATKU\n");
        stm.printf("blad\n");
@@ -53,7 +53,7 @@
        stm.printf("blad\n");
         return false;
     }
-    if(bufor[9]!='$')
+    if((bufor[9]!='$')&&(bufor[9]!='&'))
     {
        // stm.printf("ZLY ZNAK KONCA\n");
        stm.printf("blad\n");
@@ -107,8 +107,6 @@
         //**********ODPALANIE SILNIKOW******// 
             eng_left.move(l);
             eng_right.move(p);
-            
-            stm.printf(bufor);
 }
 void move_camera()
 {
@@ -140,29 +138,7 @@
             cam_poziom.position(po);
             cam_pion.position(pi);      
 }
-void fill_buffer(int i)
-{
-    bufor[i] = stm.getc();            
-    if(i==0){
-        if((bufor[i]=='@') || (bufor[i]=='&')) //zaczynamy zapelniac bufor jak dostaniemy @
-        ++i;  
-        }
-    else if(bufor[i]=='@'){ // i != 0 //interpretujemy jakby potencjalny poczatek ramki
-        cleanBuffer(bufor);
-        //stm.printf("blad\n");
-        bufor[0]='@';
-        i=1; //bo zerowy znak '@' juz zczytal
-        }
-    else if (bufor[i]=='&'){ // i != 0 //interpretujemy jakby potencjalny poczatek ramki
-        cleanBuffer(bufor);
-        //stm.printf("blad\n");
-        bufor[0]='&';
-        i=1; //bo zerowy znak '@' juz zczytal
-        }
-    else
-        i++;
-}
- 
+
 int main(){
     int i = 0;
     cleanBuffer(bufor);
@@ -172,19 +148,29 @@
             eng_left.move(0);
             eng_right.move(0);
             }
-        //if((bufor[9] == NULL)&&(stm.readable()))
-        while (bufor[9] == NULL){
-            fill_buffer(i);
-        }           
+        if(bufor[9] == NULL){
+            bufor[i] = stm.getc();            
+            if(i==0){
+                if(bufor[i]=='@') //zaczynamy zapelniac bufor jak dostaniemy @
+                   ++i;    
+            }
+            else if(bufor[i]=='@'){ // i != 0 //interpretujemy jakby potencjalny poczatek ramki
+                cleanBuffer(bufor);
+                bufor[0]='@';
+                i=1; //bo zerowy znak '@' juz zczytal
+                }
+            else i++;
+        continue;
+        }         
         if(isCorrectPacket(bufor)){   
             t.stop();
             t.reset();
             t.start();                    
         }
-        if(bufor[0]=='@'){
+        if(bufor[9]=='$'){
         move_wheels();
         }
-        else if(bufor[0]=='&'){
+        else if(bufor[9]=='&'){
         move_camera();
         }
         i=0;