mirror of
https://github.com/UtilitechAS/amsreader-firmware.git
synced 2026-01-27 20:48:36 +00:00
Yellow flash for AP mode if RGB LED is configured
This commit is contained in:
@@ -341,7 +341,11 @@ void loop() {
|
||||
} else {
|
||||
dnsServer.processNextRequest();
|
||||
// Continously flash the LED when AP mode
|
||||
if (now / 50 % 64 == 0) hw.ledBlink(LED_INTERNAL, 1);
|
||||
if (now / 50 % 64 == 0) {
|
||||
if(!hw.ledBlink(LED_YELLOW, 1)) {
|
||||
hw.ledBlink(LED_INTERNAL, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(hanSerialPin != config.getHanPin()) {
|
||||
@@ -495,9 +499,7 @@ void readHanPort() {
|
||||
lastSuccessfulRead = millis();
|
||||
|
||||
if(config.getMeterType() > 0) {
|
||||
if(config.getLedPinGreen() != 0xFF)
|
||||
hw.ledBlink(LED_GREEN, 1);
|
||||
else
|
||||
if(!hw.ledBlink(LED_GREEN, 1))
|
||||
hw.ledBlink(LED_INTERNAL, 1);
|
||||
|
||||
AmsData data(config.getMeterType(), config.isSubstituteMissing(), hanReader);
|
||||
|
||||
@@ -110,25 +110,25 @@ void HwTools::setLedRgb(uint8_t ledPinRed, uint8_t ledPinGreen, uint8_t ledPinBl
|
||||
}
|
||||
}
|
||||
|
||||
void HwTools::ledOn(uint8_t color) {
|
||||
bool HwTools::ledOn(uint8_t color) {
|
||||
if(color == LED_INTERNAL) {
|
||||
writeLedPin(color, ledInverted ? LOW : HIGH);
|
||||
return writeLedPin(color, ledInverted ? LOW : HIGH);
|
||||
} else {
|
||||
writeLedPin(color, ledRgbInverted ? LOW : HIGH);
|
||||
return writeLedPin(color, ledRgbInverted ? LOW : HIGH);
|
||||
}
|
||||
}
|
||||
|
||||
void HwTools::ledOff(uint8_t color) {
|
||||
bool HwTools::ledOff(uint8_t color) {
|
||||
if(color == LED_INTERNAL) {
|
||||
writeLedPin(color, ledInverted ? HIGH : LOW);
|
||||
return writeLedPin(color, ledInverted ? HIGH : LOW);
|
||||
} else {
|
||||
writeLedPin(color, ledRgbInverted ? HIGH : LOW);
|
||||
return writeLedPin(color, ledRgbInverted ? HIGH : LOW);
|
||||
}
|
||||
}
|
||||
|
||||
void HwTools::ledBlink(uint8_t color, uint8_t blink) {
|
||||
bool HwTools::ledBlink(uint8_t color, uint8_t blink) {
|
||||
for(int i = 0; i < blink; i++) {
|
||||
ledOn(color);
|
||||
if(!ledOn(color)) return false;
|
||||
delay(50);
|
||||
ledOff(color);
|
||||
if(i != blink)
|
||||
@@ -136,29 +136,49 @@ void HwTools::ledBlink(uint8_t color, uint8_t blink) {
|
||||
}
|
||||
}
|
||||
|
||||
void HwTools::writeLedPin(uint8_t color, uint8_t state) {
|
||||
bool HwTools::writeLedPin(uint8_t color, uint8_t state) {
|
||||
switch(color) {
|
||||
case LED_INTERNAL:
|
||||
if(ledPin != 0xFF)
|
||||
if(ledPin != 0xFF) {
|
||||
digitalWrite(ledPin, state);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case LED_RED:
|
||||
if(ledPinRed != 0xFF)
|
||||
if(ledPinRed != 0xFF) {
|
||||
digitalWrite(ledPinRed, state);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case LED_GREEN:
|
||||
if(ledPinGreen != 0xFF)
|
||||
if(ledPinGreen != 0xFF) {
|
||||
digitalWrite(ledPinGreen, state);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case LED_BLUE:
|
||||
if(ledPinBlue != 0xFF)
|
||||
if(ledPinBlue != 0xFF) {
|
||||
digitalWrite(ledPinBlue, state);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case LED_YELLOW:
|
||||
if(ledPinRed != 0xFF && ledPinGreen != 0xFF) {
|
||||
digitalWrite(ledPinRed, state);
|
||||
digitalWrite(ledPinGreen, state);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -28,9 +28,9 @@ public:
|
||||
int getWifiRssi();
|
||||
void setLed(uint8_t ledPin, bool ledInverted);
|
||||
void setLedRgb(uint8_t ledPinRed, uint8_t ledPinGreen, uint8_t ledPinBlue, bool ledRgbInverted);
|
||||
void ledOn(uint8_t color);
|
||||
void ledOff(uint8_t color);
|
||||
void ledBlink(uint8_t color, uint8_t blink);
|
||||
bool ledOn(uint8_t color);
|
||||
bool ledOff(uint8_t color);
|
||||
bool ledBlink(uint8_t color, uint8_t blink);
|
||||
|
||||
HwTools() {};
|
||||
private:
|
||||
@@ -43,7 +43,7 @@ private:
|
||||
OneWire *oneWire;
|
||||
DallasTemperature *tempSensor;
|
||||
|
||||
void writeLedPin(uint8_t color, uint8_t state);
|
||||
bool writeLedPin(uint8_t color, uint8_t state);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user