mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-26 22:22:16 +03:00
Merge pull request #190 from biveraxe/ver4dev
Исправление кнопки и даты
This commit is contained in:
@@ -31,7 +31,10 @@ class ButtonIn : public IoTItem {
|
||||
|
||||
|
||||
// TODO: загрузить значение из памяти иначе пока просто считываем значение текущего состояния PIN
|
||||
_lastButtonState = _buttonState = IoTgpio.digitalRead(_pin);
|
||||
value.valD = _buttonState = IoTgpio.digitalRead(_pin);
|
||||
// сообщаем всем о стартовом статусе без генерации события
|
||||
publishStatusMqtt(_id, (String)_buttonState);
|
||||
publishStatusWs(_id, (String)_buttonState);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
||||
@@ -157,12 +157,17 @@ boolean isDigitStr(const String& str) {
|
||||
}
|
||||
|
||||
boolean isDigitDotCommaStr(const String& str) {
|
||||
bool dotCountWas = false;
|
||||
for (size_t i = 0; i < str.length(); i++) {
|
||||
char latter = str.charAt(i);
|
||||
//если символ не цифра и не точка и не тире
|
||||
if (!isDigit(latter) && latter != '.') {
|
||||
if (!isDigit(latter) && latter != '.' && latter != '-') {
|
||||
return false;
|
||||
}
|
||||
if (latter == '.') { // проверяем на две точки, чтоб исключить дату
|
||||
if (dotCountWas) return false;
|
||||
dotCountWas = true;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user