From 678d40709dc9d90ba882211abf899731c5c7ccc3 Mon Sep 17 00:00:00 2001 From: Eggert Jung Date: Sat, 2 Apr 2022 16:47:58 +0200 Subject: [PATCH] add globaly available notaus-state --- notaus.c | 12 +++++++++++- notaus.h | 8 ++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/notaus.c b/notaus.c index eb9225b..9f9c8d4 100644 --- a/notaus.c +++ b/notaus.c @@ -1,10 +1,16 @@ #include "kraftsensor.h" #include "avrIOhelper/io-helper.h" +#include #include +#include "notaus.h" + +uint8_t notaus_state = POWER_OFF; void do_notaus(){ if(!read_Input(IN_NOTAUS_ANLAGE, LEVEL) || read_Input(IN_NOTAUS_SCHRANK, LEVEL) || read_Input(IN_NOTAUS_DISPLAY, LEVEL)){ - /* at least on pressed */ + /* at least one pressed */ + notaus_state = POWER_OFF; + ioHelperSetBit(outStates, AMPEL_ROT, 1); ioHelperSetBit(outStates, AMPEL_GELB, 0); ioHelperSetBit(outStates, AMPEL_GRUEN, 0); @@ -34,6 +40,8 @@ void do_notaus(){ } else if(!read_Input(IN_ANLAGE_EIN, LEVEL)){ /* nothing pressed, but power not on */ + notaus_state = ARMED; + ioHelperSetBit(outStates, AMPEL_ROT, 0); ioHelperSetBit(outStates, AMPEL_GELB, 1); ioHelperSetBit(outStates, AMPEL_GRUEN, 0); @@ -48,6 +56,8 @@ void do_notaus(){ } else{ /* powered on */ + notaus_state = POWER_ON; + ioHelperSetBit(outStates, AMPEL_ROT, 0); ioHelperSetBit(outStates, AMPEL_GELB, 0); ioHelperSetBit(outStates, AMPEL_GRUEN, 1); diff --git a/notaus.h b/notaus.h index f17c7e4..e0e34ec 100644 --- a/notaus.h +++ b/notaus.h @@ -1,6 +1,14 @@ #ifndef _NOTAUS_H_ #define _NOTAUS_H_ +#include + +#define POWER_ON 2 +#define ARMED 1 +#define POWER_OFF 0 + +extern uint8_t notaus_state; + void do_notaus(void); #endif