Created
May 10, 2019 02:42
-
-
Save KenMacD/611172a2f7e57da07335f46b5d430eaa to your computer and use it in GitHub Desktop.
Particle.io Callback Variable Testing
This file contains 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 <Particle.h> | |
static char* var_str = (char *)"ORIG STR"; | |
static int var_int = 1; | |
static double var_double = 1.23; | |
static double override_double; | |
static const void* static_str_test(const char* name, Spark_Data_TypeDef type, | |
const void* var, void *reserverd) { | |
return "STATIC UPDATE"; | |
} | |
static const void* dynamic_int_test(const char* name, Spark_Data_TypeDef type, | |
const void* var, void *reserverd) { | |
*((int *)var) += 1; | |
return var; | |
} | |
static const void* static_double_test(const char* name, Spark_Data_TypeDef type, | |
const void* var, void *reservered) { | |
override_double = 2.34; | |
return &override_double; | |
} | |
void setup() { | |
spark_variable_t extra_str; | |
extra_str.size = sizeof(extra_str); | |
extra_str.update = static_str_test; | |
spark_variable("str", (void *)var_str, CloudVariableTypeString::value(), &extra_str); | |
spark_variable_t extra_int; | |
extra_int.size = sizeof(extra_int); | |
extra_int.update = dynamic_int_test; | |
spark_variable("int", (void *)&var_int, CloudVariableTypeInt::value(), &extra_int); | |
spark_variable_t extra_double; | |
extra_double.size = sizeof(extra_double); | |
extra_double.update = static_double_test; | |
spark_variable("double", (void *)&var_double, CloudVariableTypeDouble::value(), &extra_double); | |
} | |
void loop() { | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment