удалил лишний Pcf8574

This commit is contained in:
Mit4el
2025-01-13 19:29:33 +03:00
parent f214140cea
commit 68d653902c
2 changed files with 0 additions and 122 deletions

View File

@@ -1,71 +0,0 @@
#include "Global.h"
#include "classes/IoTItem.h"
#include "Wire.h"
#include <Adafruit_PCF8591.h>
// Make sure that this is set to the value in volts of VCC
#define ADC_REFERENCE_VOLTAGE 3.3
class Pcf8591 : public IoTItem {
int _pin;
bool _isRaw;
bool _isInited = false;
Adafruit_PCF8591 pcf = Adafruit_PCF8591();
public:
Pcf8591(String parameters) : IoTItem(parameters) {
String tmp;
jsonRead(parameters, "pin", tmp);
_pin = tmp.toInt();
jsonRead(parameters, "mode", tmp);
_isRaw = tmp == "raw";
if (!pcf.begin()) {
Serial.println("# Adafruit PCF8591 not found!");
_isInited = false;
} else
_isInited = true;
Serial.println("# Adafruit PCF8591 found");
pcf.enableDAC(true);
Serial.println("AIN0, AIN1, AIN2, AIN3");
}
uint8_t dac_counter = 0;
void doByInterval() {
// Make a triangle wave on the DAC output
pcf.analogWrite(dac_counter++);
if (_isInited) {
if (_isRaw)
value.valD = pcf.analogRead(_pin); // Чтение АЦП нулевого канала (Вольты)
else
value.valD = (int_to_volts(pcf.analogRead(_pin), 8, ADC_REFERENCE_VOLTAGE));
regEvent(value.valD, "PCF8591");
}
}
float int_to_volts(uint16_t dac_value, uint8_t bits, float logic_level) {
return (((float)dac_value / ((1 << bits) - 1)) * logic_level);
}
~Pcf8591(){};
};
void *getAPI_Pcf8591(String subtype, String param) {
if (subtype == F("Pcf8591")) {
return new Pcf8591(param);
} else {
return nullptr;
}
}

View File

@@ -1,51 +0,0 @@
{
"menuSection": "sensors",
"configItem": [
{
"global": 0,
"name": "Расширитель портов PCF8591",
"type": "Reading",
"subtype": "Pcf8591",
"id": "Pcf85",
"widget": "anydataVlt",
"page": "PCF8591",
"descr": "PCF_0",
"pin": "0",
"mode": "volt",
"map": "1,255,1,100",
"plus": 0,
"multiply": 1,
"round": 2,
"int": 7
}
],
"about": {
"authorName": "Serghei Crasnicov",
"authorContact": "https://t.me/Serghei63",
"authorGit": "https://github.com/Serghei63",
"specialThanks": "",
"moduleName": "Pcf8591",
"moduleVersion": "1.0",
"usedRam": {
"esp32_4mb": 15,
"esp8266_4mb": 15
},
"title": "Расширитель 4-х аналоговых портов PCF8591",
"moduleDesc": "Позволяет получить относительную величину напряжения на понижающем трансформаторе.",
"propInfo": {
"pin": "Номер AN, к которому подключен датчик. Допускается 0, 1, 2, 3",
"mode": "Режим работы. volt - вывод в вольтах , raw - значения от 0 до 255",
"int": "Количество секунд между опросами датчика."
}
},
"defActive": false,
"usedLibs": {
"esp32*": [
"https://github.com/adafruit/Adafruit_PCF8591"
],
"esp82*": [
"https://github.com/adafruit/Adafruit_PCF8591"
]
}
}