116 lines
2.6 KiB
C++
116 lines
2.6 KiB
C++
/*************************************************************
|
|
Download latest Blynk library here:
|
|
https://github.com/blynkkk/blynk-library/releases/latest
|
|
|
|
Blynk is a platform with iOS and Android apps to control
|
|
Arduino, Raspberry Pi and the likes over the Internet.
|
|
You can easily build graphic interfaces for all your
|
|
projects by simply dragging and dropping widgets.
|
|
|
|
Downloads, docs, tutorials: http://www.blynk.cc
|
|
Sketch generator: http://examples.blynk.cc
|
|
Blynk community: http://community.blynk.cc
|
|
Follow us: http://www.fb.com/blynkapp
|
|
http://twitter.com/blynk_app
|
|
|
|
Blynk library is licensed under MIT license
|
|
This example code is in public domain.
|
|
|
|
*************************************************************
|
|
|
|
App project setup:
|
|
Time Input widget on V1.
|
|
*************************************************************/
|
|
|
|
/* Comment this out to disable prints and save space */
|
|
#define BLYNK_PRINT Serial
|
|
|
|
|
|
#include <SPI.h>
|
|
#include <Ethernet.h>
|
|
#include <BlynkSimpleEthernet.h>
|
|
|
|
// You should get Auth Token in the Blynk App.
|
|
// Go to the Project Settings (nut icon).
|
|
char auth[] = "YourAuthToken";
|
|
|
|
BLYNK_WRITE(V1) {
|
|
TimeInputParam t(param);
|
|
|
|
// Process start time
|
|
|
|
if (t.hasStartTime())
|
|
{
|
|
Serial.println(String("Start: ") +
|
|
t.getStartHour() + ":" +
|
|
t.getStartMinute() + ":" +
|
|
t.getStartSecond());
|
|
}
|
|
else if (t.isStartSunrise())
|
|
{
|
|
Serial.println("Start at sunrise");
|
|
}
|
|
else if (t.isStartSunset())
|
|
{
|
|
Serial.println("Start at sunset");
|
|
}
|
|
else
|
|
{
|
|
// Do nothing
|
|
}
|
|
|
|
// Process stop time
|
|
|
|
if (t.hasStopTime())
|
|
{
|
|
Serial.println(String("Stop: ") +
|
|
t.getStopHour() + ":" +
|
|
t.getStopMinute() + ":" +
|
|
t.getStopSecond());
|
|
}
|
|
else if (t.isStopSunrise())
|
|
{
|
|
Serial.println("Stop at sunrise");
|
|
}
|
|
else if (t.isStopSunset())
|
|
{
|
|
Serial.println("Stop at sunset");
|
|
}
|
|
else
|
|
{
|
|
// Do nothing: no stop time was set
|
|
}
|
|
|
|
// Process timezone
|
|
// Timezone is already added to start/stop time
|
|
|
|
Serial.println(String("Time zone: ") + t.getTZ());
|
|
|
|
// Get timezone offset (in seconds)
|
|
Serial.println(String("Time zone offset: ") + t.getTZ_Offset());
|
|
|
|
// Process weekdays (1. Mon, 2. Tue, 3. Wed, ...)
|
|
|
|
for (int i = 1; i <= 7; i++) {
|
|
if (t.isWeekdaySelected(i)) {
|
|
Serial.println(String("Day ") + i + " is selected");
|
|
}
|
|
}
|
|
|
|
Serial.println();
|
|
}
|
|
|
|
void setup()
|
|
{
|
|
// Debug console
|
|
Serial.begin(9600);
|
|
|
|
Blynk.begin(auth);
|
|
}
|
|
|
|
void loop()
|
|
{
|
|
Blynk.run();
|
|
}
|
|
|