Code: Select all
class RelayAsInput : public Supla::Control::VirtualRelay {
public:
explicit RelayAsInput(int step = 1) : step(step) {
}
virtual ~RelayAsInput() {}
void turnOn(_supla_int_t duration = 0) override {
Serial.print("!!!!!!!!!!!!!!!!!!!!!!!!!/////////////////// 4 ");
Serial.println(tempON);
(void)(duration);
int newTemp = temp.getValue() + step;
if (newTemp > 90) {
newTemp = 90;
}
temp.setValue(newTemp);
tempON = newTemp;
sekund5.restart();
if(menu != PIEC){
lcd.clear();
}
menu = PIEC;
Serial.print("!!!!!!!!!!!!!!!!!!!!!!!!!/////////////////// 5 ");
Serial.println(tempON);
Supla::Storage::ScheduleSave(2000);
}
void turnOff(_supla_int_t duration = 0) override {
Serial.print("!!!!!!!!!!!!!!!!!!!!!!!!!/////////////////// 6 ");
Serial.println(tempON);
(void)(duration);
int newTemp = temp.getValue() - step;
if (newTemp < 5) {
newTemp = 5;
}
temp.setValue(newTemp);
tempON = newTemp;
sekund5.restart();
if(menu != PIEC){
lcd.clear();
}
menu = PIEC;
Serial.print("!!!!!!!!!!!!!!!!!!!!!!!!!/////////////////// 7 ");
Serial.println(tempON);
Supla::Storage::ScheduleSave(2000);
}
int getValue() {
return temp.getValue();
}
void setValue(int value) {
temp.setValue(value);
Supla::Storage::ScheduleSave(2000);
}
void onLoadState() override {
int temperature = 0;
Supla::Storage::ReadState(reinterpret_cast<unsigned char *>(&temperature),
sizeof(int));
temp.setValue(temperature);
tempON = temperature;
}
void onSaveState() override {
int temperature = temp.getValue();
Supla::Storage::WriteState(reinterpret_cast<unsigned char *>(&temperature),
sizeof(int));
}
protected:
Supla::Sensor::VirtualThermometer temp;
int step = 1;
};
16:54:14.103 -> Creating OneWire bus for pin: 13
16:54:14.103 -> Initializing OneWire bus at pin 13
16:54:14.150 -> OneWire(pin 13) Parasite power is OFF
16:54:14.244 -> OneWire(pin 13) Found 1 devices:
16:54:14.244 -> Index 0 - address {0x28, 0xF2, 0xDF, 0x57, 0x04, 0xE1, 0x3C, 0x5F}
16:54:14.713 -> Supla - starting initialization
16:54:14.713 -> Storage initialization
16:54:14.713 -> readStorage: 8; Read: [53 55 50 4C 41 1 0 1 ]
16:54:14.807 -> Storage: Number of sections 1
16:54:14.807 -> Reading section: 0
16:54:14.807 -> readStorage: 7; Read: [3 12 0 E2 4A E2 4A ]
16:54:14.900 -> Section type: 3; size: 18
16:54:14.947 -> CRC1 19170, CRC2 19170, CRC calc 19170
16:54:14.947 -> Config storage not configured
16:54:14.994 -> Validating storage state section with current device configuration
16:54:15.041 -> Storage state section validation completed. Loading elements state...
16:54:15.135 -> readStorage: 4; Read: [1D 0 0 0 ]
16:54:15.182 -> readStorage: 4; Read: [4 0 0 0 ]
16:54:15.182 -> readStorage: 4; Read: [0 0 0 0 ]
16:54:15.228 -> readStorage: 1; Read: [0 ]
16:54:15.275 -> readStorage: 4; Read: [0 0 0 0 ]
16:54:15.275 -> readStorage: 1; Read: [0 ]
16:54:15.322 -> Channel(0) value changed to 25.68
16:54:15.369 -> !!!!!!!!!!!!!!!!!!!!!!!!!/////////////////// 6 29
16:54:15.416 -> !!!!!!!!!!!!!!!!!!!!!!!!!/////////////////// 7 28
16:54:15.510 -> Channel(2) value changed to 28.0
16:54:15.510 -> Channel(4) value changed to 3.0
16:54:15.557 -> Relay[5] turn OFF (duration 0 ms)
16:54:15.603 -> **** Digital write[5], gpio: 14; value 1
16:54:15.650 -> Relay[5] turn OFF (duration 0 ms)
16:54:15.650 -> **** Digital write[5], gpio: 14; value 1
16:54:15.744 -> Relay[6] turn OFF (duration 0 ms)
16:54:15.744 -> **** Digital write[6], gpio: 12; value 1
16:54:15.791 -> Relay[6] turn OFF (duration 0 ms)
16:54:15.838 -> **** Digital write[6], gpio: 12; value 1
16:54:15.838 -> Initializing network layer
Ewidentnie przy odpalaniu widzi kliknięcie na OFF i dekrementuje zmienną, ale dlaczego?