|
@@ -38,6 +38,10 @@ void setup()
|
|
|
|
|
|
LOG("Initializing stepper");
|
|
|
initializeStepper();
|
|
|
+
|
|
|
+ LOG("'Initializeing PWM");
|
|
|
+ pinMode(PWM, OUTPUT);
|
|
|
+
|
|
|
}
|
|
|
|
|
|
void loop()
|
|
@@ -149,9 +153,8 @@ void processCommand(const char *cmd, const char *data)
|
|
|
*/
|
|
|
case 'L':
|
|
|
LOG("Light on received");
|
|
|
- lightStatus = ON;
|
|
|
lastCommand = LIGHT_ON;
|
|
|
- // setBrightness(brightness);
|
|
|
+ setBrightness(brightness);
|
|
|
break;
|
|
|
|
|
|
/*
|
|
@@ -162,9 +165,8 @@ void processCommand(const char *cmd, const char *data)
|
|
|
*/
|
|
|
case 'D':
|
|
|
LOG("Turn off received");
|
|
|
- lightStatus = OFF;
|
|
|
lastCommand = LIGHT_OFF;
|
|
|
- // setBrightness(0);
|
|
|
+ setBrightness(0);
|
|
|
break;
|
|
|
|
|
|
/*
|
|
@@ -179,7 +181,7 @@ void processCommand(const char *cmd, const char *data)
|
|
|
LOG("Set brightness received");
|
|
|
brightness = atoi(data);
|
|
|
lastCommand = SET_BRIGHTNESS;
|
|
|
- // setBrightness(brightness);
|
|
|
+ setBrightness(brightness);
|
|
|
break;
|
|
|
|
|
|
/*
|
|
@@ -309,29 +311,25 @@ void sendCommandResponse()
|
|
|
break;
|
|
|
|
|
|
case OPEN:
|
|
|
- //if (stepper.distanceToGo() == 0)
|
|
|
- //{
|
|
|
coverStatus = OPENED;
|
|
|
FF_SERIAL << F("*O") << deviceId << F("OOO\n");
|
|
|
lastCommand = NONE;
|
|
|
- //}
|
|
|
break;
|
|
|
|
|
|
case CLOSE:
|
|
|
- //if (stepper.distanceToGo() == 0)
|
|
|
- //{
|
|
|
coverStatus = CLOSED;
|
|
|
FF_SERIAL << F("*C") << deviceId << F("OOO\n");
|
|
|
lastCommand = NONE;
|
|
|
- //}
|
|
|
break;
|
|
|
|
|
|
case LIGHT_ON:
|
|
|
+ lightStatus =ON;
|
|
|
FF_SERIAL << F("*L") << deviceId << F("OOO\n");
|
|
|
lastCommand = NONE;
|
|
|
break;
|
|
|
|
|
|
case LIGHT_OFF:
|
|
|
+ lightStatus = OFF;
|
|
|
FF_SERIAL << F("*D") << deviceId << F("OOO\n");
|
|
|
lastCommand = NONE;
|
|
|
break;
|
|
@@ -362,3 +360,8 @@ void sendCommandResponse()
|
|
|
}
|
|
|
|
|
|
}
|
|
|
+
|
|
|
+void setBrightness(int newBrightness)
|
|
|
+{
|
|
|
+ analogWrite(PWM, newBrightness);
|
|
|
+}
|