Skip to content

Commit a306d3e

Browse files
authored
Merge pull request #31 from shramik49/master
Added CAYENNE_OUT()
2 parents f498e07 + ea04837 commit a306d3e

File tree

10 files changed

+99
-8
lines changed

10 files changed

+99
-8
lines changed

examples/Actuators/GenericDigitalOutput/GenericDigitalOutput.ino

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ char password[] = "MQTT_PASSWORD";
2525
char clientID[] = "CLIENT_ID";
2626

2727
#define VIRTUAL_CHANNEL 1
28+
2829
#define ACTUATOR_PIN 4 // Do not use digital pins 0 or 1 since those conflict with the use of Serial.
2930

3031
void setup()
@@ -47,3 +48,12 @@ CAYENNE_IN(VIRTUAL_CHANNEL)
4748
// Write the value received to the digital pin.
4849
digitalWrite(ACTUATOR_PIN, value);
4950
}
51+
52+
// This function is called at intervals to send data to Cayenne and keep the device online.
53+
// Will create a temporary green widget on Channel 0, make it permanent by clicking on '+'.
54+
CAYENNE_OUT(0)
55+
{
56+
CAYENNE_LOG("Send data for Virtual Channel 0");
57+
// This command writes the device's uptime in seconds to the Virtual Channel.
58+
Cayenne.virtualWrite(0, millis() / 1000);
59+
}

examples/Actuators/GenericPWMOutput/GenericPWMOutput.ino

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,13 @@ CAYENNE_IN(VIRTUAL_CHANNEL)
4747
CAYENNE_LOG("Channel %d, pin %d, value %d", VIRTUAL_CHANNEL, ACTUATOR_PIN, value);
4848
// Write the value received to the PWM pin. analogWrite accepts a value from 0 to 255.
4949
analogWrite(ACTUATOR_PIN, value);
50-
}
50+
}
51+
52+
// This function is called at intervals to send data to Cayenne and keep the device online.
53+
// Will create a temporary green widget on Channel 0, make it permanent by clicking on '+'.
54+
CAYENNE_OUT(0)
55+
{
56+
CAYENNE_LOG("Send data for Virtual Channel 0");
57+
// This command writes the device's uptime in seconds to the Virtual Channel.
58+
Cayenne.virtualWrite(0, millis() / 1000);
59+
}

examples/Actuators/LightSwitch/LightSwitch.ino

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,13 @@ CAYENNE_IN(VIRTUAL_CHANNEL)
4848
CAYENNE_LOG("Channel %d, pin %d, value %d", VIRTUAL_CHANNEL, ACTUATOR_PIN, value);
4949
// Write the value received to the digital pin.
5050
digitalWrite(ACTUATOR_PIN, value);
51-
}
51+
}
52+
53+
// This function is called at intervals to send data to Cayenne and keep the device online.
54+
// Will create a temporary green widget on Channel 0, make it permanent by clicking on '+'.
55+
CAYENNE_OUT(0)
56+
{
57+
CAYENNE_LOG("Send data for Virtual Channel 0");
58+
// This command writes the device's uptime in seconds to the Virtual Channel.
59+
Cayenne.virtualWrite(0, millis() / 1000);
60+
}

examples/Actuators/Luminosity/Luminosity.ino

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,13 @@ CAYENNE_IN(VIRTUAL_CHANNEL)
5050
CAYENNE_LOG("Channel %d, pin %d, value %d", VIRTUAL_CHANNEL, ACTUATOR_PIN, value);
5151
// Write the value received to the PWM pin. analogWrite accepts a value from 0 to 255.
5252
analogWrite(ACTUATOR_PIN, value);
53-
}
53+
}
54+
55+
// This function is called at intervals to send data to Cayenne and keep the device online.
56+
// Will create a temporary green widget on Channel 0, make it permanent by clicking on '+'.
57+
CAYENNE_OUT(0)
58+
{
59+
CAYENNE_LOG("Send data for Virtual Channel 0");
60+
// This command writes the device's uptime in seconds to the Virtual Channel.
61+
Cayenne.virtualWrite(0, millis() / 1000);
62+
}

examples/Actuators/MotorSwitch/MotorSwitch.ino

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,13 @@ CAYENNE_IN(VIRTUAL_CHANNEL)
5656
// Turn off the motor.
5757
analogWrite(ACTUATOR_PIN, 0);
5858
}
59-
}
59+
}
60+
61+
// This function is called at intervals to send data to Cayenne and keep the device online.
62+
// Will create a temporary green widget on Channel 0, make it permanent by clicking on '+'.
63+
CAYENNE_OUT(0)
64+
{
65+
CAYENNE_LOG("Send data for Virtual Channel 0");
66+
// This command writes the device's uptime in seconds to the Virtual Channel.
67+
Cayenne.virtualWrite(0, millis() / 1000);
68+
}

examples/Actuators/RelaySwitch/RelaySwitch.ino

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,13 @@ CAYENNE_IN(VIRTUAL_CHANNEL)
4949
else {
5050
digitalWrite(ACTUATOR_PIN, LOW);
5151
}
52-
}
52+
}
53+
54+
// This function is called at intervals to send data to Cayenne and keep the device online.
55+
// Will create a temporary green widget on Channel 0, make it permanent by clicking on '+'.
56+
CAYENNE_OUT(0)
57+
{
58+
CAYENNE_LOG("Send data for Virtual Channel 0");
59+
// This command writes the device's uptime in seconds to the Virtual Channel.
60+
Cayenne.virtualWrite(0, millis() / 1000);
61+
}

examples/Actuators/ServoMotor/ServoMotor.ino

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,13 @@ CAYENNE_IN(VIRTUAL_CHANNEL)
5151
int position = getValue.asDouble() * 180;
5252
// Move the servo to the specified position.
5353
s1.write(position);
54-
}
54+
}
55+
56+
// This function is called at intervals to send data to Cayenne and keep the device online.
57+
// Will create a temporary green widget on Channel 0, make it permanent by clicking on '+'.
58+
CAYENNE_OUT(0)
59+
{
60+
CAYENNE_LOG("Send data for Virtual Channel 0");
61+
// This command writes the device's uptime in seconds to the Virtual Channel.
62+
Cayenne.virtualWrite(0, millis() / 1000);
63+
}

examples/Actuators/ValveSwitch/ValveSwitch.ino

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,13 @@ CAYENNE_IN(VIRTUAL_CHANNEL)
5151
CAYENNE_LOG("Channel %d, pin %d, value %d", VIRTUAL_CHANNEL, ACTUATOR_PIN, value);
5252
// Write the value received to the digital pin.
5353
digitalWrite(ACTUATOR_PIN, value);
54-
}
54+
}
55+
56+
// This function is called at intervals to send data to Cayenne and keep the device online.
57+
// Will create a temporary green widget on Channel 0, make it permanent by clicking on '+'.
58+
CAYENNE_OUT(0)
59+
{
60+
CAYENNE_LOG("Send data for Virtual Channel 0");
61+
// This command writes the device's uptime in seconds to the Virtual Channel.
62+
Cayenne.virtualWrite(0, millis() / 1000);
63+
}

examples/CustomWidgets/ButtonWidget/ButtonWidget.ino

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,12 @@ CAYENNE_IN(VIRTUAL_CHANNEL)
4747
// Write the value received to the digital pin.
4848
digitalWrite(ACTUATOR_PIN, value);
4949
}
50+
51+
// This function is called at intervals to send data to Cayenne and keep the device online.
52+
// Will create a temporary green widget on Channel 0, make it permanent by clicking on '+'.
53+
CAYENNE_OUT(0)
54+
{
55+
CAYENNE_LOG("Send data for Virtual Channel 0");
56+
// This command writes the device's uptime in seconds to the Virtual Channel.
57+
Cayenne.virtualWrite(0, millis() / 1000);
58+
}

examples/CustomWidgets/SliderWidget/SliderWidget.ino

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,13 @@ CAYENNE_IN(VIRTUAL_CHANNEL)
4646
CAYENNE_LOG("Channel %d, pin %d, value %d", VIRTUAL_CHANNEL, ACTUATOR_PIN, value);
4747
// Write the value received to the PWM pin. analogWrite accepts a value from 0 to 255.
4848
analogWrite(ACTUATOR_PIN, value);
49-
}
49+
}
50+
51+
// This function is called at intervals to send data to Cayenne and keep the device online.
52+
// Will create a temporary green widget on Channel 0, make it permanent by clicking on '+'.
53+
CAYENNE_OUT(0)
54+
{
55+
CAYENNE_LOG("Send data for Virtual Channel 0");
56+
// This command writes the device's uptime in seconds to the Virtual Channel.
57+
Cayenne.virtualWrite(0, millis() / 1000);
58+
}

0 commit comments

Comments
 (0)