mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-27 06:32:19 +03:00
Удаление сканера one wire
This commit is contained in:
@@ -1,25 +0,0 @@
|
||||
#include "Bus/OneWireBus.h"
|
||||
|
||||
OneWireBus oneWireBus;
|
||||
|
||||
OneWireBus::OneWireBus(){};
|
||||
|
||||
OneWire *OneWireBus::get(uint8_t pin) {
|
||||
// Ищем среди ранее созданных
|
||||
for (size_t i = 0; i < _items.size(); i++) {
|
||||
auto item = _items.at(i);
|
||||
if (item.pin == pin) {
|
||||
return item.bus;
|
||||
}
|
||||
}
|
||||
// Добавляем новый
|
||||
OneWireBus_t newItem;
|
||||
newItem.bus = new OneWire(pin);
|
||||
newItem.pin = pin;
|
||||
_items.push_back(newItem);
|
||||
return newItem.bus;
|
||||
}
|
||||
|
||||
size_t OneWireBus::count() {
|
||||
return _items.size();
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
#include "Bus/OneWireScanner.h"
|
||||
|
||||
#include "Utils/PrintMessage.h"
|
||||
|
||||
const char* MODULE = "OneWire";
|
||||
|
||||
OneWireScanner::OneWireScanner(String& out, uint8_t pin) : BusScanner(TAG_ONE_WIRE, out, 1) {
|
||||
_bus = oneWireBus.get(pin);
|
||||
}
|
||||
|
||||
bool OneWireScanner::syncScan() {
|
||||
uint8_t addr[8];
|
||||
pm.info("scanning...");
|
||||
while (_bus->search(addr)) {
|
||||
for (uint8_t i = 0; i < 8; i++) {
|
||||
pm.info("found: " + String(i, DEC));
|
||||
addResult(addr[i], i < 7);
|
||||
}
|
||||
}
|
||||
if (OneWire::crc8(addr, 7) != addr[7]) {
|
||||
pm.error(String("CRC!"));
|
||||
return false;
|
||||
}
|
||||
_bus->reset_search();
|
||||
return true;
|
||||
}
|
||||
@@ -108,6 +108,7 @@ void cmd_init() {
|
||||
|
||||
//==========================================================================================================
|
||||
//==========================================Модуль кнопок===================================================
|
||||
|
||||
void button() {
|
||||
pm.info("create 'button'");
|
||||
String number = sCmd.next();
|
||||
|
||||
@@ -17,6 +17,8 @@ StringCommand sCmd;
|
||||
|
||||
AsyncWebServer server(80);
|
||||
|
||||
OneWire *oneWire;
|
||||
|
||||
DallasTemperature sensors;
|
||||
|
||||
/*
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
#include "Bus/OneWireBus.h"
|
||||
#include "Global.h"
|
||||
|
||||
GMedian<10, int> medianFilter;
|
||||
@@ -232,18 +231,19 @@ void analog_reading2() {
|
||||
//=========================================================================================================================================
|
||||
//=========================================Модуль температурного сенсора ds18b20===========================================================
|
||||
#ifdef DALLAS_ENABLED
|
||||
//dallas temp1 2 0x14 Температура Датчики anydata 1
|
||||
//dallas temp2 2 0x14 Температура Датчики anydata 2
|
||||
//dallas temp1 2 1 Температура Датчики anydata 1
|
||||
//dallas temp2 2 2 Температура Датчики anydata 2
|
||||
void dallas() {
|
||||
String value_name = sCmd.next();
|
||||
uint8_t pin = (uint8_t)String(sCmd.next()).toInt();
|
||||
String pin = sCmd.next();
|
||||
String address = sCmd.next();
|
||||
jsonWriteStr(configOptionJson, value_name + "_ds", address);
|
||||
String widget_name = sCmd.next();
|
||||
String page_name = sCmd.next();
|
||||
String type = sCmd.next();
|
||||
String page_number = sCmd.next();
|
||||
sensors.setOneWire(oneWireBus.get(pin));
|
||||
oneWire = new OneWire((uint8_t) pin.toInt());
|
||||
sensors.setOneWire(oneWire);
|
||||
sensors.begin();
|
||||
sensors.setResolution(12);
|
||||
dallas_value_name += value_name + ";";
|
||||
|
||||
Reference in New Issue
Block a user