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:
- 6:5607f07a3863
- Parent:
- 5:b4e1656b6627
- Child:
- 7:1fbdaef9052a
- Child:
- 8:0e77808699d0
--- a/main.cpp Wed Jan 25 10:07:40 2017 +0000
+++ b/main.cpp Wed Jan 25 10:46:36 2017 +0000
@@ -4,6 +4,7 @@
DigitalIn nullut(p16);
BusOut ledStatus(p21,p22,p23,p24,p25,p26,p27,p28);
DigitalOut ledMaster(LED1);
+Serial pc(USBTX, USBRX);
Ticker tick;
@@ -13,15 +14,19 @@
//todo: få dette i en konfigurasjons tekstfil
#define passord "qwerty"
-#define bryterAfrom 0
-#define bryterAto 0
-#define bryterBfrom 0
-#define bryterBto 0
-#define bryterABfrom 0
-#define bryterABto 0
-#define bryter0 0
+#define bryterAhigh 0.285f
+#define bryterAlow 0.200f
+#define bryterBhigh 0.200f
+#define bryterBlow 0.150f
+#define bryterABhigh 0.150f
+#define bryterABlow 0.050f
+#define bryter0 0.97f
+void getFromFile(){
+
+}
+
int alarmSjekk(AnalogIn& krets, int kretsn){
/* Sjekker kretsen etter spenningsendring og returnerer hvilke bryter som er åpen
-1 error
@@ -29,20 +34,25 @@
1 bryter A
2 bryter B
3 bryter AB
+ ---
*/
int bryter = -1;
float volt = krets.read();
- if(volt <=bryter0){
+ pc.printf("volt %f", volt);
+ if(volt <= bryter0){
status = 1;
- if(bryterAfrom < volt < bryterAto){
- bryter = 1;
- brytere[kretsn*2] = 1;
- } else if(bryterBfrom < volt < bryterBto){
- bryter = 2;
- brytere[kretsn*2+1] = 1;
- } else if(bryterABfrom < volt){
- bryter = 3;
- brytere[kretsn*2] = brytere[kretsn*2+1] = 1;
+ if(volt < bryterAhigh){
+ if(volt < bryterBhigh){
+ if(volt < bryterABhigh){
+ bryter = 3;
+ } else {
+ bryter = 2;
+ }
+ } else {
+ bryter = 1;
+ }
+ } else {
+ bryter = -2;
}
} else(bryter = 0);
@@ -90,6 +100,7 @@
int main() {
while(1){
-
+ int al = alarmSjekk(ain4, 4);
+ pc.printf(" Alarm Status: %d, Alarm %d gatt \r\n",status, al);
}
}
