add globaly available notaus-state

master
Eggert Jung 4 years ago
parent a33902424e
commit 678d40709d

@ -1,10 +1,16 @@
#include "kraftsensor.h" #include "kraftsensor.h"
#include "avrIOhelper/io-helper.h" #include "avrIOhelper/io-helper.h"
#include <stdint.h>
#include <stdio.h> #include <stdio.h>
#include "notaus.h"
uint8_t notaus_state = POWER_OFF;
void do_notaus(){ void do_notaus(){
if(!read_Input(IN_NOTAUS_ANLAGE, LEVEL) || read_Input(IN_NOTAUS_SCHRANK, LEVEL) || read_Input(IN_NOTAUS_DISPLAY, LEVEL)){ 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_ROT, 1);
ioHelperSetBit(outStates, AMPEL_GELB, 0); ioHelperSetBit(outStates, AMPEL_GELB, 0);
ioHelperSetBit(outStates, AMPEL_GRUEN, 0); ioHelperSetBit(outStates, AMPEL_GRUEN, 0);
@ -34,6 +40,8 @@ void do_notaus(){
} }
else if(!read_Input(IN_ANLAGE_EIN, LEVEL)){ else if(!read_Input(IN_ANLAGE_EIN, LEVEL)){
/* nothing pressed, but power not on */ /* nothing pressed, but power not on */
notaus_state = ARMED;
ioHelperSetBit(outStates, AMPEL_ROT, 0); ioHelperSetBit(outStates, AMPEL_ROT, 0);
ioHelperSetBit(outStates, AMPEL_GELB, 1); ioHelperSetBit(outStates, AMPEL_GELB, 1);
ioHelperSetBit(outStates, AMPEL_GRUEN, 0); ioHelperSetBit(outStates, AMPEL_GRUEN, 0);
@ -48,6 +56,8 @@ void do_notaus(){
} }
else{ else{
/* powered on */ /* powered on */
notaus_state = POWER_ON;
ioHelperSetBit(outStates, AMPEL_ROT, 0); ioHelperSetBit(outStates, AMPEL_ROT, 0);
ioHelperSetBit(outStates, AMPEL_GELB, 0); ioHelperSetBit(outStates, AMPEL_GELB, 0);
ioHelperSetBit(outStates, AMPEL_GRUEN, 1); ioHelperSetBit(outStates, AMPEL_GRUEN, 1);

@ -1,6 +1,14 @@
#ifndef _NOTAUS_H_ #ifndef _NOTAUS_H_
#define _NOTAUS_H_ #define _NOTAUS_H_
#include <stdint.h>
#define POWER_ON 2
#define ARMED 1
#define POWER_OFF 0
extern uint8_t notaus_state;
void do_notaus(void); void do_notaus(void);
#endif #endif