v1

Dependencies:   PinDetect TextLCD mbed

Fork of SunflowerMach1 by Milan Draganic

Files at this revision

API Documentation at this revision

Comitter:
mdraganic
Date:
Mon Nov 11 13:14:10 2013 +0000
Parent:
6:902bec57d9ae
Child:
8:4044ae40bbc1
Commit message:
dodan LCD display samo za az.

Changed in this revision

TextLCD.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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TextLCD.lib	Mon Nov 11 13:14:10 2013 +0000
@@ -0,0 +1,1 @@
+https://mbed.org/users/simon/code/TextLCD/#44f34c09bd37
--- a/main.cpp	Mon Nov 11 11:45:55 2013 +0000
+++ b/main.cpp	Mon Nov 11 13:14:10 2013 +0000
@@ -1,5 +1,6 @@
 #include "mbed.h"
 #include "Motor.h"
+#include "TextLCD.h"
 
 #define sensorStartTreshold     0.05
 #define sensorStopTreshold      0.01
@@ -9,10 +10,16 @@
 #define calibrateFactorSenzC    1.06
 #define calibrateFactorSenzD    0.9
 
-#define serialOutputEnable      true
+#define lcdOutputEnable         true
+#define serialOutputEnable      false
 #define serialOutputBaudrate    115200
 
 Serial pc(USBTX, USBRX);
+TextLCD lcd(p15, p16, p5, p6, p7, p8); // rs, e, d4-d7
+
+DigitalOut ledBoot(LED1);
+DigitalOut ledAz(LED3);
+DigitalOut ledEl(LED4);
 
 AnalogIn ainSensA(p17);
 AnalogIn ainSensB(p18);
@@ -56,27 +63,25 @@
 
         pc.printf("az:%6.3f el:%6.3f \n", valAzimut, valElevacija);
     }
+    
+    if(lcdOutputEnable) {
+        lcd.cls();
+        lcd.printf("a:%6.3f \n", valAzimut);    
+    }
+    
 }
 
 int main() {
 
+    ledBoot = 1;
     pc.baud(serialOutputBaudrate);
-
     Motor *motorAz = new Motor(p25, p26, p24);
     Motor *motorEl = new Motor(p22, p21, p23);
+    wait_ms(500);
+    ledBoot = 0;
 
     while(1) {
-    
-        (*motorEl).movePositive();
-        (*motorAz).movePositive();
-        wait(5);
-        (*motorAz).moveNegative();
-        (*motorEl).moveNegative();
-        wait(3);
-        continue;
-
-    
-    
+        
         readValuesForAveraging();
         
 // ----- azimut -----
@@ -86,10 +91,12 @@
                 (*motorAz).movePositive();
             else
                 (*motorAz).moveNegative();
+            ledAz = 1;
         }
         
         if(abs(valAzimut) < sensorStopTreshold) {
             (*motorAz).stop();
+            ledAz = 0;
         }
         
 // ----- elevacija -----
@@ -99,15 +106,17 @@
                 (*motorEl).movePositive();
             else
                 (*motorEl).moveNegative();
+            ledEl = 1;
         }
         
         if(abs(valElevacija) < sensorStopTreshold) {
             (*motorEl).stop();
+            ledEl = 0;
         }
         
 // ----- pauza ------
 
-        wait_ms(100);        
+        wait_ms(200);        
     }
 }