Add function (pulse) to second LED (Amica only)
This commit is contained in:
parent
8f37203b79
commit
ecdce86bb1
23
src/main.cpp
23
src/main.cpp
|
@ -302,7 +302,7 @@ void timer() {
|
||||||
sprintf(t_stat[r], "off");
|
sprintf(t_stat[r], "off");
|
||||||
if (!override[r]) {
|
if (!override[r]) {
|
||||||
digitalWrite(pins[r], LOW);
|
digitalWrite(pins[r], LOW);
|
||||||
analogWrite(LED_BUILTIN, 0); // LED
|
analogWrite(LED_BUILTIN_AUX, 0); // LED
|
||||||
if (strcmp(stat[r], "AN") == 0) {
|
if (strcmp(stat[r], "AN") == 0) {
|
||||||
debug(r);
|
debug(r);
|
||||||
debugln(F(" is off"));
|
debugln(F(" is off"));
|
||||||
|
@ -314,6 +314,19 @@ void timer() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint ledBrightness = 0;
|
||||||
|
int ledBrightnessStep = 20;
|
||||||
|
uint lastLedCycle;
|
||||||
|
void pulseLed() {
|
||||||
|
if (millis() - lastLedCycle > 100) {
|
||||||
|
analogWrite(LED_BUILTIN_AUX, ledBrightness);
|
||||||
|
ledBrightness += ledBrightnessStep;
|
||||||
|
if (ledBrightness <= 0 || ledBrightness >= 255) {
|
||||||
|
ledBrightnessStep = -ledBrightnessStep;
|
||||||
|
}
|
||||||
|
lastLedCycle = millis();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void emergencyStop() {
|
void emergencyStop() {
|
||||||
for (uint pin = 0; pin < sizeof(pins) / sizeof(pins[0]); pin++) {
|
for (uint pin = 0; pin < sizeof(pins) / sizeof(pins[0]); pin++) {
|
||||||
|
@ -328,10 +341,13 @@ void emergencyStop() {
|
||||||
unsigned long lastTry = millis();
|
unsigned long lastTry = millis();
|
||||||
while (millis() - lastTry < (1000 * 60)) {
|
while (millis() - lastTry < (1000 * 60)) {
|
||||||
analogWrite(LED_BUILTIN, 255);
|
analogWrite(LED_BUILTIN, 255);
|
||||||
|
analogWrite(LED_BUILTIN_AUX, 0);
|
||||||
delay(125);
|
delay(125);
|
||||||
analogWrite(LED_BUILTIN, 0);
|
analogWrite(LED_BUILTIN, 0);
|
||||||
|
analogWrite(LED_BUILTIN_AUX, 255);
|
||||||
delay(125);
|
delay(125);
|
||||||
analogWrite(LED_BUILTIN, 255);
|
analogWrite(LED_BUILTIN, 255);
|
||||||
|
analogWrite(LED_BUILTIN_AUX, 255);
|
||||||
delay(250);
|
delay(250);
|
||||||
}
|
}
|
||||||
ESP.restart();
|
ESP.restart();
|
||||||
|
@ -350,7 +366,9 @@ void getCurrentTemperature() {
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
pinMode(LED_BUILTIN, OUTPUT);
|
pinMode(LED_BUILTIN, OUTPUT);
|
||||||
|
pinMode(LED_BUILTIN_AUX, OUTPUT);
|
||||||
analogWrite(LED_BUILTIN, 255);
|
analogWrite(LED_BUILTIN, 255);
|
||||||
|
analogWrite(LED_BUILTIN_AUX, 255);
|
||||||
uint p = 0;
|
uint p = 0;
|
||||||
while (p <= sizeof(pins) / sizeof(pins[0])) {
|
while (p <= sizeof(pins) / sizeof(pins[0])) {
|
||||||
pinMode(pins[p], OUTPUT);
|
pinMode(pins[p], OUTPUT);
|
||||||
|
@ -379,6 +397,7 @@ void setup() {
|
||||||
while (WiFi.status() != WL_CONNECTED) {
|
while (WiFi.status() != WL_CONNECTED) {
|
||||||
delay(250);
|
delay(250);
|
||||||
debug(F("."));
|
debug(F("."));
|
||||||
|
analogWrite(LED_BUILTIN_AUX, 255 * (notConnectedCounter % 2)); // LED
|
||||||
notConnectedCounter++;
|
notConnectedCounter++;
|
||||||
if (notConnectedCounter >
|
if (notConnectedCounter >
|
||||||
(1000 / 250) * 15) { // Reset board if not connected after 15s
|
(1000 / 250) * 15) { // Reset board if not connected after 15s
|
||||||
|
@ -386,6 +405,7 @@ void setup() {
|
||||||
ESP.restart();
|
ESP.restart();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
analogWrite(LED_BUILTIN_AUX, 0);
|
||||||
debug(F("\nConnected to "));
|
debug(F("\nConnected to "));
|
||||||
debugln(WiFi.SSID());
|
debugln(WiFi.SSID());
|
||||||
debug(F("IP address: "));
|
debug(F("IP address: "));
|
||||||
|
@ -431,4 +451,5 @@ void loop() {
|
||||||
delay(50);
|
delay(50);
|
||||||
events();
|
events();
|
||||||
ArduinoOTA.handle();
|
ArduinoOTA.handle();
|
||||||
|
pulseLed();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue