mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-04-01 04:49:13 +03:00
Impuls generator in progress
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
#include "Web.h"
|
||||
#include "items/LoggingClass.h"
|
||||
|
||||
#include "Class/NotAsync.h"
|
||||
#include "Global.h"
|
||||
#include "Init.h"
|
||||
#include "ItemsList.h"
|
||||
#include "items/LoggingClass.h"
|
||||
|
||||
bool parseRequestForPreset(AsyncWebServerRequest* request, uint8_t& preset) {
|
||||
if (request->hasArg("preset")) {
|
||||
@@ -239,6 +240,8 @@ void web_init() {
|
||||
msg = F("Cервер не найден. Попробуйте повторить позже...");
|
||||
} else if (lastVersion == -2) {
|
||||
msg = F("Устройство не подключено к роутеру!");
|
||||
} else if (lastVersion < FIRMWARE_VERSION) {
|
||||
msg = F("Ошибка версии. Попробуйте повторить позже...");
|
||||
}
|
||||
|
||||
// else if (lastVersion == "") {
|
||||
|
||||
55
src/items/ImpulsOutClass.cpp
Normal file
55
src/items/ImpulsOutClass.cpp
Normal file
@@ -0,0 +1,55 @@
|
||||
#include "items/ImpulsOutClass.h"
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
#include "Class/LineParsing.h"
|
||||
#include "Global.h"
|
||||
#include "ItemsCmd.h"
|
||||
|
||||
ImpulsOutClass::ImpulsOutClass(unsigned long impulsPeriod, unsigned int impulsCount, unsigned int impulsPin) {
|
||||
_impulsPeriod = impulsPeriod;
|
||||
_impulsCount = impulsCount * 2;
|
||||
_impulsPin = impulsPin;
|
||||
pinMode(impulsPin, OUTPUT);
|
||||
}
|
||||
|
||||
ImpulsOutClass::~ImpulsOutClass() {}
|
||||
|
||||
void ImpulsOutClass::activate() {
|
||||
_impulsCountBuf = _impulsCount;
|
||||
}
|
||||
|
||||
void ImpulsOutClass::loop() {
|
||||
currentMillis = millis();
|
||||
unsigned long difference = currentMillis - prevMillis;
|
||||
if (_impulsCountBuf > 0) {
|
||||
if (difference > _impulsPeriod) {
|
||||
_impulsCountBuf--;
|
||||
prevMillis = millis();
|
||||
yield();
|
||||
digitalWrite(_impulsPin, !digitalRead(_impulsPin));
|
||||
yield();
|
||||
}
|
||||
}
|
||||
if (_impulsCountBuf <= 0) {
|
||||
digitalWrite(_impulsPin, LOW);
|
||||
}
|
||||
}
|
||||
|
||||
MyImpulsOutVector* myImpulsOut = nullptr;
|
||||
|
||||
//void impuls() {
|
||||
// myLineParsing.update();
|
||||
// String loggingValueKey = myLineParsing.gvalue();
|
||||
// String key = myLineParsing.gkey();
|
||||
// String interv = myLineParsing.gint();
|
||||
// String maxcnt = myLineParsing.gmaxcnt();
|
||||
// myLineParsing.clear();
|
||||
//
|
||||
// logging_value_names_list += key + ",";
|
||||
//
|
||||
// static bool firstTime = true;
|
||||
// if (firstTime) myImpulsOut = new MyImpulsOutVector();
|
||||
// firstTime = false;
|
||||
// myImpulsOut->push_back(ImpulsOutClass(interv.toInt(), maxcnt.toInt(), loggingValueKey, key));
|
||||
//}
|
||||
16
src/main.cpp
16
src/main.cpp
@@ -17,6 +17,8 @@
|
||||
#include "items/ButtonInClass.h"
|
||||
#include "items/LoggingClass.h"
|
||||
|
||||
#include "items/ImpulsOutClass.h"
|
||||
|
||||
void not_async_actions();
|
||||
|
||||
Timings metric;
|
||||
@@ -99,11 +101,13 @@ void setup() {
|
||||
just_load = false;
|
||||
initialized = true; //this second POST makes the data to be processed (you don't need to connect as "keep-alive" for that to work)
|
||||
|
||||
|
||||
static bool firstTime = true;
|
||||
if (firstTime) myImpulsOut = new MyImpulsOutVector();
|
||||
firstTime = false;
|
||||
myImpulsOut->push_back(ImpulsOutClass(500, 10, 13));
|
||||
myImpulsOut->at(0).activate();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void loop() {
|
||||
if (!initialized) {
|
||||
return;
|
||||
@@ -129,4 +133,10 @@ void loop() {
|
||||
myLogging->at(i).loop();
|
||||
}
|
||||
}
|
||||
|
||||
if (myImpulsOut != nullptr) {
|
||||
for (unsigned int i = 0; i < myImpulsOut->size(); i++) {
|
||||
myImpulsOut->at(i).loop();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user