Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of prosjektoppgave_alarm by
Diff: main.cpp
- Revision:
 - 9:7fff168507fa
 - Parent:
 - 7:1fbdaef9052a
 - Child:
 - 10:557f325a6119
 
--- a/main.cpp	Wed Jan 25 11:11:50 2017 +0000
+++ b/main.cpp	Wed Jan 25 11:41:09 2017 +0000
@@ -10,7 +10,11 @@
 Ticker tick;
 Timer systemTid;
 
-int brytere[8]; //en for hver bryter, 1 = alarm
+struct alarmKretser { //1 = aktivert
+    int A;
+    int B;
+}
+struct brytere[4]
 
 int status = 0; //1 = alarm
 
@@ -30,7 +34,7 @@
     
 }
 
-void log(int status = 0, int tall = 0) {
+void log(int status = 0, int tall1 = 0, char bokstav = "") {
     FILE *fp = fopen("/local/log.txt", "a");
     fprintf(fp, "\r\n TIME: %f |", systemTid.read());
     switch(status){
@@ -68,17 +72,29 @@
             if(volt < bryterBhigh){
                 if(volt < bryterABhigh){
                     bryter = 3;
+                    if (brytere[kretsn-1].A != 1 || brytere[kretsn-1].B != 1){
+                        log(1,kretsn,"A");
+                        log(1,kretsn,"B");
+                    }
+                    brytere[kretsn-1].A = brytere[kretsn-1].B = 1;
                     
                 } else {
                     bryter = 2;
+                    if ( brytere[kretsn-1].B != 1){
+                        log(1,kretsn,"B");
+                    }
+                    brytere[kretsn-1].B = 1;
                 }
             } else {
                 bryter = 1;
+                if ( brytere[kretsn-1].B != 1){
+                        log(1,kretsn,"B");
+                    }
+                brytere[kretsn-1].A = 1;
             }
         } else {
             bryter = -2;
         }
-        log(1,bryter);
     } else(bryter = 0);
     return bryter;
 }
@@ -89,25 +105,16 @@
     int b = alarmSjekk(ain2, 1);
     int c = alarmSjekk(ain3, 2);
     int d = alarmSjekk(ain4, 3);
-    pc.printf("krets 1: %d krets 2: %d krets 3: %d krets 4: %d ",a,b,c,d);
 }
 
 void statusLED(){
     //oppdatere statusLED til aktiverte alarmer
-    for(int i=0; brytere[i]!=NULL;i++){
-        if(brytere[i] == 1){
-            ledStatus = ledStatus+i;
-        }
-    }
 }
 
 
 
 void resetSystem(){
     //reseter alarmsystemet
-    for(int i=0; brytere[i]!=NULL;i++){
-        brytere[i] = 0;
-    }
     status = 0;
     
 }
    