mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-26 22:22:16 +03:00
4 mb version
This commit is contained in:
@@ -18,6 +18,7 @@ void itemsListInit() {
|
||||
delChoosingItems();
|
||||
},
|
||||
nullptr);
|
||||
|
||||
#ifdef FLASH_SIZE_1MB
|
||||
myNotAsyncActions->add(
|
||||
do_addItem, [&](void*) {
|
||||
|
||||
@@ -59,8 +59,8 @@ void upgrade_firmware(int type) {
|
||||
String devconfig_ForUpdate;
|
||||
String configSetup_ForUpdate;
|
||||
|
||||
scenario_ForUpdate = readFile(String(DEVICE_SCENARIO_FILE), 4000);
|
||||
devconfig_ForUpdate = readFile(String(DEVICE_CONFIG_FILE), 4000);
|
||||
scenario_ForUpdate = readFile(String(DEVICE_SCENARIO_FILE), 4096);
|
||||
devconfig_ForUpdate = readFile(String(DEVICE_CONFIG_FILE), 4096);
|
||||
configSetup_ForUpdate = configSetupJson;
|
||||
|
||||
if (type == 1) { //only build
|
||||
|
||||
71
src/items/vSensorAnalog.cpp
Normal file
71
src/items/vSensorAnalog.cpp
Normal file
@@ -0,0 +1,71 @@
|
||||
#include "items/vSensorAnalog.h"
|
||||
#include "Class/LineParsing.h"
|
||||
#include "Global.h"
|
||||
#include "BufferExecute.h"
|
||||
#include <Arduino.h>
|
||||
|
||||
SensorAnalog::SensorAnalog(String key, unsigned long interval, unsigned int adcPin, int map1, int map2, int map3, int map4, float c) {
|
||||
_interval = interval * 1000;
|
||||
_key = key;
|
||||
_adcPin = _adcPin;
|
||||
|
||||
_map1 = map1;
|
||||
_map2 = map2;
|
||||
_map3 = map3;
|
||||
_map4 = map4;
|
||||
|
||||
_c = c;
|
||||
}
|
||||
|
||||
SensorAnalog::~SensorAnalog() {}
|
||||
|
||||
void SensorAnalog::loop() {
|
||||
currentMillis = millis();
|
||||
difference = currentMillis - prevMillis;
|
||||
if (difference >= _interval) {
|
||||
prevMillis = millis();
|
||||
readAnalog();
|
||||
}
|
||||
}
|
||||
|
||||
void SensorAnalog::readAnalog() {
|
||||
int value;
|
||||
#ifdef ESP32
|
||||
int pinInt = pin.toInt();
|
||||
value = analogRead(pinInt);
|
||||
#endif
|
||||
#ifdef ESP8266
|
||||
value = analogRead(A0);
|
||||
#endif
|
||||
|
||||
value = map(value, _map1, _map2, _map3, _map4);
|
||||
float valueFloat = value * _c;
|
||||
|
||||
eventGen2(_key, String(valueFloat));
|
||||
jsonWriteStr(configLiveJson, _key, String(valueFloat));
|
||||
publishStatus(_key, String(valueFloat));
|
||||
SerialPrint("I", "Sensor", "'" + _key + "' data: " + String(valueFloat));
|
||||
}
|
||||
|
||||
MySensorAnalogVector* mySensorAnalog = nullptr;
|
||||
|
||||
void analogAdc() {
|
||||
myLineParsing.update();
|
||||
String interval = myLineParsing.gint();
|
||||
String pin = myLineParsing.gpin();
|
||||
String key = myLineParsing.gkey();
|
||||
String map = myLineParsing.gmap();
|
||||
String c = myLineParsing.gc();
|
||||
myLineParsing.clear();
|
||||
|
||||
int map1 = selectFromMarkerToMarker(map, ",", 0).toInt();
|
||||
int map2 = selectFromMarkerToMarker(map, ",", 1).toInt();
|
||||
int map3 = selectFromMarkerToMarker(map, ",", 2).toInt();
|
||||
int map4 = selectFromMarkerToMarker(map, ",", 3).toInt();
|
||||
|
||||
static bool firstTime = true;
|
||||
if (firstTime) mySensorAnalog = new MySensorAnalogVector();
|
||||
firstTime = false;
|
||||
mySensorAnalog->push_back(SensorAnalog(key, interval.toInt(), pin.toInt(), map1, map2, map3, map4, c.toFloat()));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user