klokka 15:07

Fork of AlarmsystemDel1 by Programmeringsgruppe 1

Revision:
7:25e0260ee887
Parent:
5:045ef3068f21
Child:
8:bdb8bd12d4f4
--- a/main.cpp	Tue Jan 30 10:41:49 2018 +0000
+++ b/main.cpp	Thu Feb 01 09:07:51 2018 +0000
@@ -11,12 +11,10 @@
 BusOut AlarmUtganger1(p21, p22, p23, p24);
 BusOut AlarmUtganger2(p25, p26, p27, p28);
 DigitalIn Servicebryter(p20);
-AnalogIn _Sone1(p15); float Sone1 =  _Sone1 * 3.3;
-AnalogIn _Sone2(p16); float Sone2 =  _Sone2 * 3.3;
-AnalogIn _Sone3(p17); float Sone3 =  _Sone3 * 3.3;
-AnalogIn _Sone4(p19); float Sone4 =  _Sone4 * 3.3;
-
-
+AnalogIn _Sone1(p15); float Sone1;
+AnalogIn _Sone2(p16); float Sone2;
+AnalogIn _Sone3(p17); float Sone3;
+AnalogIn _Sone4(p19); float Sone4;
 Ticker AlarmBlink; //10Hz blinking for alarmfunksjon på lys og telling
 int Tid = 0;
 volatile int sysclock = 0;
@@ -25,7 +23,8 @@
 int Utganger2 = AlarmUtganger2;
 int Bryter = Servicebryter;
 int Door1_1 = 0, Door1_2 = 0, Door2_1 = 0, Door2_2 = 0, Door3_1 = 0, Door3_2 = 0, Door4_1 = 0, Door4_2 = 0;
-float ArrSone[4] = {Sone1, Sone2, Sone3, Sone4};
+void fill_arrSone (float Sone1,float Sone2,float Sone3,float Sone4);
+float filled_arr[10];
 int DoorOne[4] = { Door1_1, Door2_1, Door3_1, Door4_1 };
 int DoorTwo[4] = { Door1_2, Door2_2, Door3_2, Door4_2 };
 
@@ -44,14 +43,12 @@
             Utganger2 = 0;
         }
         Tilstandssjekk();
-        float volt = Sone1;
+        float volt = Sone1*3.3;
         pc.printf("%f\n", volt);
         wait(1.0);
         //while(sysclock == 1);
         //while(sysclock == 0);
         Tid++;
-
-
     }
 }
 
@@ -59,26 +56,30 @@
 {
     int i = 0;
     for(i = 0; i < 3; i++) {
-        if(ArrSone[i] == Tilstand1) {
+        if(filled_arr[i] == Tilstand1) {
+            pc.printf("I tilstand 1\n");
             AlarmBlink_Start();
             DoorOne[i] = AlarmUtganger1;
         }
-        if(Tilstand2 == ArrSone[i]) {
+        if(Tilstand2 == filled_arr[i]) {
+            pc.printf("I tilstand 2\n");
             AlarmBlink_Start();
             DoorTwo[i] = AlarmUtganger2;
         }
-        if(Tilstand3 == ArrSone[i]) {
+        if(Tilstand3 == filled_arr[i]) {
+            pc.printf("I tilstand 3\n");
             AlarmBlink_Start();
             DoorOne[i] = AlarmUtganger1;
             DoorTwo[i] = AlarmUtganger2;
         }
-        if(Feil == ArrSone[i]) {
+        if(Feil == filled_arr[i]) {
             AlarmBlink_Start();
+            pc.printf("I tilstand feil\n");
         }
-        if(Normaldrift == ArrSone[i]) {
+        if(Normaldrift == filled_arr[i]) {
             Driftslys = 1;
             DoorOne[i] = AlarmUtganger1 - DoorOne[i];
-            myled2 = 1;
+            pc.printf("I tilstand normaldrift\n");
         }
         if(i < 0 ) {
             DoorOne[i] = AlarmUtganger1 + DoorOne[i];
@@ -96,6 +97,14 @@
     sysclock = !sysclock;
     Driftslys = 1;
     if(Normaldrift == 1) {
-        sysclock = 1;
+        Driftslys = 1;
+        Utganger1 = 0;
+        Utganger2 = 0;
     }
+}
+void fill_arrSone =(float Sone1, float Sone2, float Sone3, float Sone4){
+        filled_arr[1] = Sone1;
+        filled_arr[2] = Sone2;
+        filled_arr[3] = Sone3;
+        filled_arr[4] = Sone4;
 }
\ No newline at end of file