HI. I’m wondering if someone can help me with a simple problem.
I want to track the time that a button is pressed. it might get pressed upwards of 200 times in a 5 minute period.
I have a demo working that transfers the time stamp of each button press using Spark.publish
But, if there is any network downtime, etc. I’d in theory miss the timestamps from button push events.
So, I’m thinking I’d like to save all button press time stamps locally, then publish a big comma delimited string of timestamps that I can parse on the browser side.
I’ve tried two methods with little success. For the below examples, just assume that a button press event is triggering everything inside the loop.
Method 1:
String all;{}
void setup();{
void loop();
all += “,”;
all += Time.timeStr();
Spark.publish(“Uptime”, all);
}
Method 2:
String all;
char publishTime[2000];
void setup();{}
void loop();{
all += “,”;
all += Time.timeStr();
all.toCharArray(publishTime,2000);
Spark.publish(“Uptime2”, publishTime);
}
Both of these methods works for 2.5 time stamps, returning something like this on the browser side:
,Sat Jun 21 15:23:47 2014 ,Sat Jun 21 15:23:52 2014 ,Sat Jun 21
Finally, I used the above two methods because nothing I do with Time.now(); seems to work.
Ideally, I’d like to use Time.timeStr(); as my timestamp because it seems simpler and I can manipulate it on the browser side easily.
Any help will be appreciated! @bko