Back to Parent

Code for a Time Index to Multiply Estimated Time when Snowing
//code to handle walk time difference caused by snowfall 
//a time index inspired by Dina
//to response to the 
//Particle.publish("snowData", snowfall, PUBLIC);
//in the code for fan with api

int snowTimeIndex = 1; // Default multiplier = 1

void setup() {
  // Subscribe to the integration response event
  Particle.subscribe("snowData", snowfallHandler); // Subscribe to snowfall data
}

void snowfallHandler(const char *event, const char *data) {
  // Handle snowfall data received
  String snowfallData = String(data);
  snowTimeIndex= snowfallData.toInt() == 1 ? 2 : 1;
}

void predictionHandler(const char *event, const char *data) {
  // Handle the integration response
  String dataStr = String(data);
  busTime = dataStr.toInt() * snowTimeIndex; // Multiply bus time with the snowTimeIndex
}
Click to Expand

Content Rating

Is this a good/useful/informative piece of content to include in the project? Have your say!

0