-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProvider.h
80 lines (61 loc) · 1.5 KB
/
Provider.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
// Provider.h
#pragma once
#ifndef _PROVIDER_h
#define _PROVIDER_h
#if defined(ARDUINO) && ARDUINO >= 100
#include "arduino.h"
#else
#include "WProgram.h"
#endif
#endif
#include <vector>
#include <functional>
#include "ESP8266Bridge.h"
#include "CommandParser.h"
//GLOBAL SECTION
enum class EventCommands { MODE, LEVEL, RESET, SHOW };
typedef EventCommands TT;
using namespace std;
class Provider
{
private:
struct PIN
{
int addr;
int pMode;
int level;
bool pwm;
};
struct PIN_ADC
{
int addr;
int level;
};
//ïîêà ÷òî óäàëèë
//CommandParser parser;
vector<PIN> pinGPIOCfg;
vector<PIN_ADC> pinADCcfg;
int findPinGPIO(int addr);
PIN_ADC* findPinADC(int addr);
ESP8266Bridge<String, int, int> esp;
public:
Provider() = default;
Provider(int * pinAddrs, int cntPins);
Provider(int * pinGPIOAddrs, int cntGPIOPins, int * pinGPIOModes, int * pinGPIOLevels, int * pinADCAddrs, int cntADCPins);
// 1 - syntax error _mode, 2 - pin not found, 0 - OK
int setPinMode(int _addr, int _mode);
// 1 - syntax error _level, 2 - wrong mode, 3 - pin not found, 0 - OK
int setPinLevel(int _addr, int _level);
int setPinPWM(int _addr, int _level);
int GetPinMode(int addr);
int GetPinLevel(int addr);
int GetPinADC(int addr);
void OnMode(int _addr, int _mode);
void OnLevel(int _addr, int _level);
void OnShow(int _prop, int pin_addr);
void OnPWM(int _addr, int _level);
void OnReset();
void OnADC(int _addr);
void RiseThisSHIT(String cm, int a1, int a2);
void ProcessCommandLine(String cmdl);
};