This commit is contained in:
Dmitry Borisenko
2020-09-18 00:02:20 +03:00
parent 0598a20beb
commit b66b4ab947
10 changed files with 52 additions and 222 deletions

View File

@@ -1,56 +0,0 @@
#pragma once
#include <Arduino.h>
class BusScanner {
public:
BusScanner(const char* tag, String& out, size_t tries) : _found{0},
_tries{tries},
_out{&out} {
_tag = new char(strlen(tag) + 1);
strcpy(_tag, tag);
}
void scan() {
init();
bool res;
do {
res = syncScan();
} while (!res && --_tries);
if (!_found) {
addResult("не найдено");
}
}
const char* tag() {
return _tag;
}
protected:
virtual void init(){};
virtual boolean syncScan() = 0;
protected:
void addResult(const String& str) {
_out->concat(str);
}
void addResult(uint8_t addr, boolean last = true) {
_found++;
String str = "0x";
if (addr < 16) {
str += "0";
}
str += String(addr, HEX);
str += !last ? ", " : ", ";
addResult(str);
};
private:
char* _tag;
size_t _found;
size_t _tries;
String* _out;
};

View File

@@ -1,18 +0,0 @@
#pragma once
#include "Bus/BusScanner.h"
#include "Bus/I2CScanner.h"
#include "Consts.h"
#include "Utils/JsonUtils.h"
class BusScannerFactory {
public:
static BusScanner* get(String& config, BusScanner_t type, String& str) {
switch (type) {
case BS_I2C:
return new I2CScanner(str);
default:
return nullptr;
}
}
};

View File

@@ -1,12 +0,0 @@
#pragma once
#include "Bus/BusScanner.h"
class I2CScanner : public BusScanner {
public:
I2CScanner(String& out);
protected:
virtual void init() override;
virtual boolean syncScan() override;
};

View File

@@ -1,31 +1,25 @@
#pragma once
/*
* Main consts
*/
//=================Firmeare=================
#define FIRMWARE_NAME "esp8266-iotm"
#define FIRMWARE_VERSION 240
#define NUM_BUTTONS 6
#define LED_PIN 2
#define FLASH_4MB true
//=================System===================
#define NUM_BUTTONS 6
#define LED_PIN 2
//=================MQTT=====================
#define MQTT_RECONNECT_INTERVAL 20000
//===============Telemetry==================
#define TELEMETRY_UPDATE_INTERVAL_MIN 60
//=============Configuration================
#define DEVICE_CONFIG_FILE "s.conf.csv"
#define DEVICE_SCENARIO_FILE "s.scen.txt"
#define DEFAULT_PRESET 100
#define DEFAULT_SCENARIO 100
#define TAG_ONE_WIRE "oneWire"
#define TAG_I2C "i2c"
#define TAG_ONE_WIRE_PIN "oneWirePin"
/*
* Optional
*/
//=============System parts=================
//#define OTA_UPDATES_ENABLED
//#define MDNS_ENABLED
//#define WEBSOCKET_ENABLED
@@ -33,34 +27,25 @@
//#define UDP_ENABLED
#define SSDP_EN
/*
* Sensor
*/
//=========Sensors enable/disable===========
#define TANK_LEVEL_SAMPLES 10
#define LEVEL_ENABLED
#define ANALOG_ENABLED
#define DALLAS_ENABLED
#define DHT_ENABLED
#define BMP_ENABLED
#define BME_ENABLED
/*
* Gears
*/
//=========Gears enable/disable===========
#define STEPPER_ENABLED
#define SERVO_ENABLED
/*
* Other
*/
//=========Other enable/disable===========
#define LOGGING_ENABLED
#define SERIAL_ENABLED
#define PUSH_ENABLED
struct Time_t {
uint8_t second;
uint8_t minute;
@@ -129,9 +114,4 @@ enum LedStatus_t {
enum ConfigType_t {
CT_CONFIG,
CT_SCENARIO
};
enum BusScanner_t {
BS_I2C,
BS_ONE_WIRE
};
};

View File

@@ -82,15 +82,6 @@ extern int enter_to_logging_counter;
extern int scenario_line_status[40];
extern int lastVersion;
//Запрос на скарнирование шины
extern boolean busScanFlag;
//Запрос на сканирование шины, указание какую
extern BusScanner_t busToScan;
extern boolean fsCheckFlag;
//Global functions
// Logging
extern void logging();