Created
July 22, 2014 15:15
-
-
Save lawrencejones/58e1c41bb119f8158699 to your computer and use it in GitHub Desktop.
Variadic function to enable easy writing to serial char device on an arduino
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <cstdarg.h> | |
| void writeValues(int count, ...) | |
| { | |
| /* Declare variadic args */ | |
| va_list ap; | |
| va_start(ap, count); | |
| Serial.print("#S|SAVEDATA|["); | |
| /* For each value, print to Serial */ | |
| for (int i = 0; i < count; i++) | |
| { | |
| Serial.print(va_arg(ap, float)); | |
| Serial.print(';'); | |
| } | |
| Serial.print("]#"); | |
| va_end(ap); | |
| } | |
| writeValues | |
| ( 3 | |
| , humidity | |
| , sensors.getTempC(fanThermometer) | |
| , sensors.getTempC(airThermometer) ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment