1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-07-30 16:24:09 +03:00

Run new astyle formatter against all the examples

This commit is contained in:
Federico Fissore
2013-10-21 09:58:40 +02:00
parent 3c6ee46828
commit b4c68b3dff
259 changed files with 5160 additions and 5217 deletions

View File

@ -1,16 +1,16 @@
/*
Time Check
Time Check
Gets the time from the linino processor via Bridge
then parses out hours, minutes and seconds for the Arduino
using an Arduino Yún.
using an Arduino Yún.
created 27 May 2013
modified 21 June 2013
By Tom Igoe
By Tom Igoe
This example code is in the public domain.
http://arduino.cc/en/Tutorial/TimeCheck
*/
@ -24,14 +24,14 @@ int lastSecond = -1; // need an impossible value for comparison
void setup() {
Bridge.begin(); // initialize Bridge
Serial.begin(9600); // initialize serial
while(!Serial); // wait for Serial Monitor to open
Serial.begin(9600); // initialize serial
while (!Serial); // wait for Serial Monitor to open
Serial.println("Time Check"); // Title of sketch
// run an initial date process. Should return:
// hh:mm:ss :
if (!date.running()) {
if (!date.running()) {
date.begin("date");
date.addParameter("+%T");
date.run();
@ -40,10 +40,10 @@ void setup() {
void loop() {
if(lastSecond != seconds) { // if a second has passed
if (lastSecond != seconds) { // if a second has passed
// print the time:
if (hours <= 9) Serial.print("0"); // adjust for 0-9
Serial.print(hours);
Serial.print(hours);
Serial.print(":");
if (minutes <= 9) Serial.print("0"); // adjust for 0-9
Serial.print(minutes);
@ -52,7 +52,7 @@ void loop() {
Serial.println(seconds);
// restart the date process:
if (!date.running()) {
if (!date.running()) {
date.begin("date");
date.addParameter("+%T");
date.run();
@ -60,24 +60,24 @@ void loop() {
}
//if there's a result from the date process, parse it:
while (date.available()>0) {
while (date.available() > 0) {
// get the result of the date process (should be hh:mm:ss):
String timeString = date.readString();
String timeString = date.readString();
// find the colons:
int firstColon = timeString.indexOf(":");
int secondColon= timeString.lastIndexOf(":");
int secondColon = timeString.lastIndexOf(":");
// get the substrings for hour, minute second:
String hourString = timeString.substring(0, firstColon);
String minString = timeString.substring(firstColon+1, secondColon);
String secString = timeString.substring(secondColon+1);
String hourString = timeString.substring(0, firstColon);
String minString = timeString.substring(firstColon + 1, secondColon);
String secString = timeString.substring(secondColon + 1);
// convert to ints,saving the previous second:
hours = hourString.toInt();
minutes = minString.toInt();
lastSecond = seconds; // save to do a time comparison
seconds = secString.toInt();
}
}
}