bed24da57c
new file: .idea/.idea.GSM-Chata.dir/.idea/encodings.xml
new file: .idea/.idea.GSM-Chata.dir/.idea/indexLayout.xml
new file: .idea/.idea.GSM-Chata.dir/.idea/vcs.xml
new file: .vscode/settings.json
modified: platformio.ini
new file: src/Data/DeviceBase.cpp
new file: src/Data/DeviceBase.h
new file: src/Data/GSMData.cpp
new file: src/Data/GSMData.h
new file: src/Data/PinTypeIn.cpp
new file: src/Data/PinTypeIn.h
new file: src/Data/PinTypeOut.cpp
new file: src/Data/PinTypeOut.h
new file: src/Device/EEPROMUtils.cpp
modified: src/Device/EEPROMUtils.h
new file: src/Device/GSMDevice.cpp
new file: src/Device/GSMDevice.h
new file: src/Device/WebServer.cpp
new file: src/Helper/HTMLGenerator.cpp
new file: src/Helper/HTMLGenerator.h
new file: src/PinDefinitions.cpp
new file: src/PinDefinitions.h
new file: src/Utills.cpp
new file: src/Utills.h
deleted: src/Zabezpecovacka-GSM.cpp
new file: src/main.cpp
58 lines
1.2 KiB
C++
58 lines
1.2 KiB
C++
#include <Arduino.h>
|
|
#include "DeviceBase.h"
|
|
|
|
class PinTypeIn : DeviceBase
|
|
{
|
|
private:
|
|
int pin;
|
|
unsigned long debounceDelay;
|
|
unsigned long lastDebounceTime;
|
|
int lastButtonState;
|
|
int buttonState;
|
|
const char *description;
|
|
|
|
bool ReadValue()
|
|
{
|
|
int reading = digitalRead(pin);
|
|
|
|
if (reading != lastButtonState)
|
|
{
|
|
lastDebounceTime = millis();
|
|
}
|
|
|
|
if ((millis() - lastDebounceTime) > debounceDelay)
|
|
{
|
|
if (reading != buttonState)
|
|
{
|
|
buttonState = reading;
|
|
|
|
if (buttonState == HIGH)
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
|
|
lastButtonState = reading;
|
|
return false;
|
|
}
|
|
|
|
public:
|
|
PinTypeIn(String id, int pin, unsigned long debounceDelay, const char *description) : DeviceBase(id)
|
|
{
|
|
this->pin = pin;
|
|
this->debounceDelay = debounceDelay;
|
|
this->description = description;
|
|
|
|
lastDebounceTime = 0;
|
|
lastButtonState = LOW;
|
|
buttonState = LOW;
|
|
pinMode(pin, INPUT);
|
|
}
|
|
|
|
bool IsSetPinValueToHigh()
|
|
{
|
|
return ReadValue();
|
|
}
|
|
};
|