Skip to content

Commit

Permalink
Add publish event to get new weather
Browse files Browse the repository at this point in the history
  • Loading branch information
grahamplata committed Apr 14, 2019
1 parent a40d980 commit c3c72a8
Showing 1 changed file with 4 additions and 21 deletions.
25 changes: 4 additions & 21 deletions WeatherBuddy/src/WeatherBuddy.ino
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,7 @@ bool demoMode = false;
bool connectToCloud = false;

// Touch events
NexTouch *nex_Listen_List[] =
{
// &textLow,
// &textHigh,
// &textTemp,
// NULL
};
NexTouch *nex_Listen_List[] = {&textTemp, NULL};

// GPIO Variables
int led = D7;
Expand All @@ -54,8 +48,8 @@ void setup(void)
{
// Set the baudrate which is for debug and communicate with Nextion screen.
dbSerial.begin(9600);
nexInit(); // Begin connection
loadingPage.show();
nexInit(); // Begin Nextion connection
// textTemp.attachPop(temperaturePopCallback);

deviceID = System.deviceID();
Particle.publish("Version", APP_VERSION);
Expand All @@ -75,7 +69,6 @@ void setup(void)
registerCloudFunctions();
Particle.subscribe("hook-response/get_weather", gotWeatherData, MY_DEVICES);

indexPage.show();
defaultState(); // set initial button and text states
}

Expand All @@ -94,6 +87,7 @@ void loop(void)
Serial.println("");
Serial.println("-------------------");
Serial.println("Requesting Weather!");
Particle.publish("get_weather", data, PRIVATE);
delay(60000 * 5);
}

Expand Down Expand Up @@ -149,8 +143,6 @@ int demoModeFunc(String command)

void gotWeatherData(const char *name, const char *data)
{
Serial.println("Got Weather Data!");
Serial.println(data);
String str = String(data);
char strBuffer[500] = "";
str.toCharArray(strBuffer, 500);
Expand All @@ -159,15 +151,6 @@ void gotWeatherData(const char *name, const char *data)
int temperatureMax = atoi(strtok(NULL, "~"));
int temperatureMin = atoi(strtok(NULL, "~"));

Serial.print("CurrentTemperature: ");
Serial.println(currentTemperature);
Serial.print("currentTime: ");
Serial.println(currentTime);
Serial.print("temperatureMax: ");
Serial.println(temperatureMax);
Serial.print("temperatureMin: ");
Serial.println(temperatureMin);

textTemp.setText(String(currentTemperature));
textLow.setText(String(temperatureMin));
textHigh.setText(String(temperatureMax));
Expand Down

0 comments on commit c3c72a8

Please sign in to comment.