Add reciever power
This commit is contained in:
@@ -77,6 +77,8 @@ void setup() {
|
||||
pinMode(LED_G, OUTPUT);
|
||||
pinMode(LED_B, OUTPUT);
|
||||
pinMode(POWER, OUTPUT);
|
||||
pinMode(RECIVER, OUTPUT);
|
||||
|
||||
ledcSetup(PWM_WHITE, 5000, 8);
|
||||
ledcSetup(PWM_BLUE, 5000, 8);
|
||||
ledcAttachPin(LED_WHITE, PWM_WHITE);
|
||||
@@ -209,8 +211,8 @@ void loop() {
|
||||
ledcWrite(PWM_BLUE, levBlue);
|
||||
statLamp |= 0x01;
|
||||
bLamp = true;
|
||||
Serial.println(F("BLamp On"));
|
||||
WebSerial.println(F("Blue Lamp On"));
|
||||
//Serial.println(F("BLamp On"));
|
||||
//WebSerial.println(F("Blue Lamp On"));
|
||||
}
|
||||
else if((LightLev > (spLight + dbLight)) || (move == 0)){
|
||||
if((levRunB + 50 <= millis() && levBlue > 0)){
|
||||
@@ -240,7 +242,7 @@ void loop() {
|
||||
wLamp = false;
|
||||
}
|
||||
if(statLamp > 0) digitalWrite(POWER, HIGH);
|
||||
else if((levBlue > 0) && (levWhite > 0)) digitalWrite(POWER, LOW);
|
||||
else if((levBlue == 0) && (levWhite == 0)) digitalWrite(POWER, LOW);
|
||||
if((cRun + 1000) <= millis()){ //Once per second
|
||||
cRun = millis();
|
||||
if(abs(LightLev - prevLLevel) > 100){
|
||||
@@ -370,6 +372,7 @@ void onMqttConnect(bool sessionPresent) {
|
||||
mqttClient.publish(TOPIC"spLevel", 1, false, s);
|
||||
itoa(dbLight, s, 10);
|
||||
mqttClient.publish(TOPIC"dbLevel", 1, false, s);
|
||||
mqttClient.publish(TOPIC"reciever", 1, false, "0");
|
||||
mqttClient.publish(TOPIC"lampw", 1, false, lightWhite ? "1" : "0");
|
||||
mqttClient.publish(TOPIC"lampw_set", 1, false, lightWhite ? "1" : "0");
|
||||
|
||||
@@ -380,6 +383,7 @@ void onMqttConnect(bool sessionPresent) {
|
||||
mqttClient.subscribe(TOPIC"moveperiod", 1);
|
||||
mqttClient.subscribe(TOPIC"spLevel", 1);
|
||||
mqttClient.subscribe(TOPIC"dbLevel", 1);
|
||||
mqttClient.subscribe(TOPIC"reciever", 1);
|
||||
|
||||
Serial.print(F("PeriodMove:"));Serial.println(periodMotion);
|
||||
Serial.print(F("SPLight:"));Serial.println(spLight);
|
||||
@@ -449,6 +453,15 @@ void onMqttMessage(char* topic, char* payload, AsyncMqttClientMessageProperties
|
||||
//EEPROM.put(0, levelBlue);
|
||||
//w = true;
|
||||
}
|
||||
if(strcmp(topic, TOPIC"reciever") == 0){
|
||||
reciever = atoi(pl);
|
||||
digitalWrite(RECIVER, reciever);
|
||||
Serial.printf("New Reciever: %d\n", lightWhite);
|
||||
WebSerial.print("New Reciever: ");WebSerial.println(lightWhite);
|
||||
//mqttClient.publish(TOPIC"reciever", 1, false, reciever ? "1" : "0");
|
||||
//EEPROM.put(0, levelBlue);
|
||||
//w = true;
|
||||
}
|
||||
if(strcmp(topic, TOPIC"moveperiod") == 0){
|
||||
periodMotion = atoi(pl);
|
||||
Serial.printf("New MovePeriod: %d\n", periodMotion);
|
||||
|
||||
Reference in New Issue
Block a user