This commit is contained in:
Dmitry Borisenko
2021-10-05 19:21:52 +08:00
parent 74c31e30ea
commit 421f3fcb9a
348 changed files with 22008 additions and 0 deletions

View File

@@ -0,0 +1,49 @@
#include "Class/CallBackTest.h"
CallBackTest::CallBackTest(){};
void CallBackTest::loop() {
count++;
if (count > 5000) {
// Проверяем что переменная содержит указатель - не пустая не null
// и непосредственно вызываем то, на что это указывает
// просто пишем имя - без () - это указатель на фунецию.
// () - вызываем функцию - с пустым набором параметров
if (_cb != NULL) {
_cb();
}
//или ровно тоже самое
//if (_cb) _cb();
if (_pcb) {
if (_pcb("SomeTextValue")) {
Serial.println("Got true!");
} else {
Serial.println("Got false!");
}
}
count = 0;
}
}
//передаем внутрь класса функцию любую void функцию без агрументов
void CallBackTest::setCallback(AsyncActionCb cb) {
_cb = cb;
}
//передаем внутрь класса функцию любую void функцию с аргументами
void CallBackTest::setCallback(AsyncParamActionCb pcb) {
_pcb = pcb;
}
//CallBackTest* CB;
//CB->setCallback([]() {
// Serial.println("123");
//});
//
//CB->setCallback([](const String str) {
// Serial.println(str);
// return true;
//});

View File

@@ -0,0 +1,2 @@
#include "Class/LineParsing.h"
LineParsing myLineParsing;

30
src/Class/NotAsync.cpp Normal file
View File

@@ -0,0 +1,30 @@
#include "Class/NotAsync.h"
NotAsync::NotAsync(uint8_t size) {
this->items = new NotAsyncItem[size];
this->size = size;
}
NotAsync::~NotAsync() {}
void NotAsync::add(uint8_t i, NotAsyncCb f, void* arg) {
this->items[i].cb = f;
this->items[i].cb_arg = arg;
this->items[i].is_used = true;
}
void NotAsync::loop() {
if (this->items[task].is_used) {
handle(this->items[task].cb, this->items[task].cb_arg);
task = 0;
}
}
void NotAsync::make(uint8_t task) {
this->task = task;
}
void NotAsync::handle(NotAsyncCb f, void* arg) {
f(arg);
}
NotAsync* myNotAsyncActions;

View File

@@ -0,0 +1,35 @@
#include "Class/ScenarioClass3.h"
#include "MqttClient.h"
#include "RemoteOrdersUdp.h"
Scenario* myScenario;
void eventGen2(String eventName, String eventValue) {
if (!jsonReadBool(configSetupJson, "scen")) {
return;
}
String event = eventName + " " + eventValue + ",";
eventBuf += event;
SerialPrint("I", "Event add", eventName + " " + eventValue);
if (jsonReadBool(configSetupJson, "MqttOut")) {
if (eventName != "timenow") {
publishEvent(eventName, eventValue);
}
}
}
void streamEventUDP(String event) {
#ifdef UDP_ENABLED
if (!jsonReadBool(configSetupJson, "snaUdp")) {
return;
}
if (event.indexOf("timenow") == -1) {
event = "iotm;event:" + event;
asyncUdp.broadcastTo(event.c_str(), 4210);
}
#endif
}