-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.h
133 lines (118 loc) · 4.06 KB
/
config.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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
/*
* refrigerator-lights: https://github.com/munichmakerlab/refrigerator-lights
* Copyright (C) 2016 Juergen Skrotzky alias Jorgen ([email protected])
*
* This sketch lights up a 15x10 WS2812b RGB LEDs.
* The lights are fully controllable over WiFi by MQTT.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef config_h
#define config_h
// Debug mode
// set to 0 to disable debug prints
#define _debug 1
// LED settings
#define COLOR_ORDER GRB
#define CHIPSET WS2812B
#define DATA_PIN D5
int brightness = 100;
//***********************************************************
const char *ssid1 = "<SSID1>";
const char *pass1 = "<PASS1>";
const char *ssid2 = "<SSID2>";
const char *pass2 = "<PASS2>";
const char *ssid3 = "<SSID3>";
const char *pass3 = "<PASS3>";
char mqtt_host[40] = "<MQTT-HOST>";
char mqtt_port[6] = "1883";
char mqtt_user[20] = "<MQTT-USER>";
char mqtt_pass[33] = "<MQTT-PASS>";
char http_user[20] = "<HTTP-USER>";
char http_pass[33] = "<HTTP-PASS>";
char mqtt_client_id[20] = "FridgeLights";
//***********************************************************
// initial matrix layout (to get led strip index by x/y)
#define MATRIX_WIDTH 15
#define MATRIX_HEIGHT 10
#define MATRIX_TYPE HORIZONTAL_ZIGZAG_MATRIX
#define MATRIX_SIZE (MATRIX_WIDTH*MATRIX_HEIGHT)
#define NUMPIXELS MATRIX_SIZE
cLEDMatrix<-MATRIX_WIDTH, MATRIX_HEIGHT, MATRIX_TYPE> leds;
cLEDMatrix<-MATRIX_WIDTH, -MATRIX_HEIGHT, MATRIX_TYPE> tetrisLeds;
cLEDMatrix<-MATRIX_WIDTH, MATRIX_HEIGHT, MATRIX_TYPE> ledsFront;
cLEDMatrix<-MATRIX_WIDTH, MATRIX_HEIGHT, MATRIX_TYPE> ledsBack;
/*
* helper variables for connection (ip, mac, formatted UID)
*/
String strIPAddr;
String strClientID;
String strChipID;
String strTopicPrefix;
String strTopicPrefixChipID;
String strHostname;
String LedR = "0";
String LedG = "255";
String LedB = "0";
String colorEffect = "solid";
String background = "black";
String effectMode = "normal";
uint16_t PlasmaTime, PlasmaShift;
uint32_t LoopDelayMS, LastLoop;
/*
* https://github.com/BenTommyE/Arduino_getStringPartByNr
*/
String getStringPartByNr(String data, char separator, int index)
{
// spliting a string and return the part nr index
// split by separator
int stringData = 0; //variable to count data part nr
String dataPart = ""; //variable to hole the return text
for(int i = 0; i<data.length(); i++) { //Walk through the text one letter at a time
if(data[i]==separator) {
//Count the number of times separator character appears in the text
stringData++;
}else if(stringData==index) {
//get the text when separator is the rignt one
dataPart.concat(data[i]);
}else if(stringData>index) {
//return text and stop if the next separator appears - to save CPU-time
return dataPart;
break;
}
}
//return text if this is the last part
return dataPart;
}
int countCharacters(const String &str, char character) {
int count = 0;
for(int i = 0; i<str.length()-1; i++) { //Walk through the text one letter at a time
if(str[i] == character)
count++;
}
return count;
}
template <typename Generic>
void DEBUG_PRINT(Generic text) {
if(_debug) {
Serial.print(text);
}
}
template <typename Generic>
void DEBUG_PRINTLN(Generic text) {
if(_debug) {
Serial.println(text);
}
}
#endif //config_h