/
OT_UI.h
93 lines (81 loc) · 2.89 KB
/
OT_UI.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
81
82
83
84
85
86
87
88
89
90
91
92
93
#ifndef OT_UI_h
#define OT_UI_h
#include <ScreenUi.h>
#include <LiquidCrystalFP.h>
#include <pin.h>
#include <encoder.h>
#include <Wire.h>
#include "HWProfile.h"
#include <NewDelete.h>
#include "OT_Outputs.h"
#include "OT_Inputs.h"
#define I2C_SEND_INT(x) { int value = x; Wire.send((uint8_t)(value >> 8)); Wire.send((uint8_t) value); }
#define I2C_RECV_INT(x) { }
class ScreenGPIO : public Screen {
private:
static LiquidCrystal* lcd;
static bool encoderInit;
public:
ScreenGPIO(byte cols, byte rows, byte rs, byte enable, byte d4, byte d5, byte d6, byte d7, byte encType, byte encA, byte encB, byte encEnter);
void getInputDeltas(int *x, int *y, bool *selected, bool *cancelled);
void clear();
void createCustomChar(uint8_t slot, uint8_t *data);
void draw(uint8_t x, uint8_t y, const char *text);
void draw(uint8_t x, uint8_t y, uint8_t customChar);
void setCursorVisible(bool visible);
void moveCursor(uint8_t x, uint8_t y);
void setBlink(bool blink);
};
class ScreenI2Cv2 : public Screen {
protected:
byte i2cLCDAddr;
public:
ScreenI2Cv2(byte cols, byte rows);
ScreenI2Cv2(byte cols, byte rows, byte addr);
virtual void getInputDeltas(int *x, int *y, bool *selected, bool *cancelled);
void clear();
void createCustomChar(uint8_t slot, uint8_t *data);
void draw(uint8_t x, uint8_t y, const char *text);
void draw(uint8_t x, uint8_t y, uint8_t customChar);
void setCursorVisible(bool visible);
void moveCursor(uint8_t x, uint8_t y);
void setBlink(bool blink);
};
class ScreenI2Cv1 : public ScreenI2Cv2 {
private:
public:
ScreenI2Cv1(byte cols, byte rows, byte addr, byte encType, byte encA, byte encB, byte encEnter);
void getInputDeltas(int *x, int *y, bool *selected, bool *cancelled);
};
typedef enum {
SCREENTYPE_NONE,
SCREENTYPE_GPIO,
SCREENTYPE_I2CV1,
SCREENTYPE_I2CV2,
SCREENTYPE_MODBUS
} screenType_t;
class screenUI {
private:
screenType_t screenType;
void (* waitFunc)(void);
public:
screenUI(void (* wF)(void));
Screen* create(byte cols, byte rows);
screenType_t detect();
boolean detectI2Cv2(byte i2cLCDAddr);
boolean detectI2Cv1(byte i2cLCDAddr);
boolean detectModbus(byte mbAddr);
void wait(void);
bool dlgYesNo(char *title, char *message);
byte dlgSelectOutput(char * title, outputs* Outputs, byte initValue);
unsigned long dlgCfgOutputProfile(char * title, outputs* Outputs, unsigned long initValue);
void dlgCfgTSensor(char * title, tSensorCfg_t* cfg);
tSensorType dlgCfgTSensor_None(char*, tSensorCfg_t*);
tSensorType dlgCfgTSensor_1Wire(char*, tSensorCfg_t*);
tSensorType dlgCfgTSensor_Modbus(char*, tSensorCfg_t*);
void dlgCfgAnalogIn(char * title, analogInCfg_t* cfg);
analogInType dlgCfgAnalogIn_None(char*, analogInCfg_t*);
analogInType dlgCfgAnalogIn_GPIO(char*, analogInCfg_t*);
analogInType dlgCfgAnalogIn_Modbus(char*, analogInCfg_t*);
};
#endif