This commit is contained in:
Dmitry Borisenko
2020-09-02 22:33:03 +03:00
parent 26383c0a19
commit 70096c71c8
288 changed files with 0 additions and 29977 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;
};