Eigene Library für Truhe, Settings in extra datei
This commit is contained in:
parent
0301212bb5
commit
9d2cc72531
@ -13,70 +13,6 @@ static unsigned long last_lcd_time = 0;
|
|||||||
static unsigned long last_mess_time = 0;
|
static unsigned long last_mess_time = 0;
|
||||||
static unsigned long last_schalt_time = 0;
|
static unsigned long last_schalt_time = 0;
|
||||||
|
|
||||||
class Truhe {
|
|
||||||
private:
|
|
||||||
int _relay;
|
|
||||||
DHT _dht;
|
|
||||||
int _stat = -1;
|
|
||||||
int _cur_temp = 0;
|
|
||||||
int _updlcd = 0;
|
|
||||||
String _name = "";
|
|
||||||
uint8_t _dhtpin;
|
|
||||||
public:
|
|
||||||
Truhe(String name, int relay, uint8_t dhtpin): _dht(dhtpin, DHT22) {
|
|
||||||
_name = name;
|
|
||||||
_relay = relay;
|
|
||||||
_dhtpin = dhtpin;
|
|
||||||
};
|
|
||||||
|
|
||||||
void setup() {
|
|
||||||
Serial.println("Setup " + _name);
|
|
||||||
Serial.println(_dhtpin);
|
|
||||||
pinMode(_relay, OUTPUT);
|
|
||||||
digitalWrite(_relay, HIGH);
|
|
||||||
pinMode(_dhtpin, INPUT);
|
|
||||||
_dht.begin();
|
|
||||||
delay(2000);
|
|
||||||
}
|
|
||||||
|
|
||||||
void mess() {
|
|
||||||
Serial.println(String(_name) + " mess()");
|
|
||||||
//Serial.print("Minimum Sampling Period: ");
|
|
||||||
//delay(_dht.getMinimumSamplingPeriod());
|
|
||||||
_cur_temp = _dht.readTemperature();
|
|
||||||
Serial.println(String(_name) + "\t\t" + String((int)_cur_temp) + " grad gelesen");
|
|
||||||
};
|
|
||||||
void schalt(int oT, int uT) {
|
|
||||||
Serial.print(String(_name) + " schalt() stat: " + String(_stat));
|
|
||||||
if (_cur_temp >= oT && _stat != 1) {
|
|
||||||
digitalWrite(_relay, LOW);
|
|
||||||
_stat = 1;
|
|
||||||
Serial.println("schalt " + _name + " zu " + String(_stat));
|
|
||||||
}
|
|
||||||
else if (_cur_temp <= uT && _stat != 0) {
|
|
||||||
digitalWrite(_relay, HIGH);
|
|
||||||
_stat = 0;
|
|
||||||
Serial.println("schalt " + _name + " zu " + String(_stat));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
int getUpdLcd(){ return _updlcd;};
|
|
||||||
void setUpdLcd(int updlcd){ _updlcd = updlcd;};
|
|
||||||
int getRelay(){ return _relay;};
|
|
||||||
int getDhtPin(){return _dhtpin;};
|
|
||||||
int getStat(){return _stat;};
|
|
||||||
float getCurTemp(){return _cur_temp;};
|
|
||||||
String getName(){return _name;};
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Truhe truhen[] = {
|
|
||||||
Truhe("Truhe 1", 2, 8),
|
|
||||||
Truhe("Truhe 2", 3, 9),
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
void setup_sd() {
|
void setup_sd() {
|
||||||
//Initialsierugn SD
|
//Initialsierugn SD
|
||||||
lcd.clear();
|
lcd.clear();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user