![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
06.03.2018
Fork of Alarmsystem_med_matrix_log_funker_ikke by
main.cpp
- Committer:
- andreped
- Date:
- 2018-02-02
- Revision:
- 9:e9c4715e06ca
- Parent:
- 8:bdb8bd12d4f4
File content as of revision 9:e9c4715e06ca:
#include "mbed.h" #include <vector> #define Feil 0<1 #define Tilstand1 2.5<2.7 #define Tilstand2 2.1<2.3 #define Tilstand3 3.3 #define Normaldrift 1.8<2.0 //vector<DigitalOut> navn; navn.push_back( *(new DigitalOut( p17 )) ); DigitalOut myled2(LED2); Serial pc(USBTX, USBRX); DigitalOut Driftslys(LED1); BusOut AlarmUtganger1(p21, p22, p23, p24); BusOut AlarmUtganger2(p25, p26, p27, p28); DigitalIn Servicebryter(p20); AnalogIn _Sone1(p15); float Sone1 = _Sone1; AnalogIn _Sone2(p16); float Sone2 = _Sone2; AnalogIn _Sone3(p17); float Sone3 = _Sone3; AnalogIn _Sone4(p19); float Sone4 = _Sone4; Ticker AlarmBlink; //10Hz blinking for alarmfunksjon på lys og telling int Tid = 0; volatile int sysclock = 0; int Door1_1, Door1_2, Door2_1, Door2_2, Door3_1, Door3_2, Door4_1, Door4_2; //void fill_arrSone (float Sone1,float Sone2,float Sone3,float Sone4); //void fill_arrDoorOne(int Door1_1,int Door2_1,int Door3_1,int Door4_1); //void fill_arrDoorTwo(int Door1_2,int Door2_2,int Door3_2,int Door4_2); float Sone[]; int DoorOne[]; int DoorTwo[]; int Tilstandssjekk(); void AlarmBlink_Start(void); // ubrukelig nå // int Bryter = Servicebryter; // ubrukelig nå // volatile int Klokke = 0; // ubrukelig nå // enum {_Feil, _Tilstand1, _Tilstand2, _Tilstand3, _NormalDrift} Tilstand; // Tilstand1 = Bryter1 i Sonen valgt, Tilstand2 = Bryter2 i sonen valgt, Tilstand3 = bryter 1 og 2 i sonen valgt, Normaldrift = alt er optimalt. int main() { AlarmBlink.attach(&AlarmBlink_Start, 0.05); while(1) { if(Servicebryter == 1) { AlarmUtganger1 = 0; AlarmUtganger2 = 0; } Sone[4] = {float Sone1,float Sone2,float Sone3,float Sone4}; DoorOne[4] = {int Door1_1, int Door2_1, int Door3_1, int Door4_1}; DoorTwo[4] = {int Door1_2, int Door2_2, int Door3_2, int Door4_2}; Tilstandssjekk(); float volt = Sone1; pc.printf("%f\n", volt); wait(1.0); //while(sysclock == 1); //while(sysclock == 0); Tid++; } } int Tilstandssjekk() { for(int i = 0; i < 4; i++) { if(Sone[i] * 3.3 == Tilstand1) { pc.printf("I tilstand 1\n"); AlarmUtganger1 = DoorOne[i]; AlarmBlink_Start(); } if(Sone[i] * 3.3 == Tilstand2) { pc.printf("I tilstand 2\n"); AlarmUtganger2 = DoorTwo[i]; AlarmBlink_Start(); } if(Sone[i] * 3.3 == Tilstand3) { pc.printf("I tilstand 3\n"); DoorOne[i] = i; DoorTwo[i] = i; AlarmUtganger1 == DoorOne[i]; AlarmUtganger2 == DoorTwo[i]; AlarmBlink_Start(); } if(Sone[i] * 3.3 == Feil) { pc.printf("I tilstand feil\n"); AlarmBlink_Start(); } if(Sone[i] * 3.3 == Normaldrift) { pc.printf("I tilstand normaldrift\n"); Driftslys = 1; DoorOne[i] = NULL; DoorTwo[i] = NULL; } if(i < 0 ) { Sone[i] * 3.3 == Feil; } } return 0; } void AlarmBlink_Start(void) { sysclock = !sysclock; Driftslys = 1; } //*void fill_arrSone (float Sone1, float Sone2, float Sone3, float Sone4){ // filled_arrSone[4] = {Sone1, Sone2, Sone3, Sone4}; // //} //void fill_arrDoorOne(int Door1_1,int Door2_1,int Door3_1,int Door4_1) { // filled_arrDoorOne[0] = Door1_1; // filled_arrDoorOne[1] = Door2_1; // filled_arrDoorOne[2] = Door3_1; // filled_arrDoorOne[3] = Door4_1; //} //void fill_arrDoorTwo(int Door1_2,int Door2_2,int Door3_2,int Door4_2) { // filled_arrDoorOne[0] = Door1_2; // filled_arrDoorOne[1] = Door2_2; // filled_arrDoorOne[2] = Door3_2; // filled_arrDoorOne[3] = Door4_2; //}