I’m using the Yahoo Weather Library
GitHub - delvedor/YahooWeatherProcessing: Yahoo Weather library for Processing
however I get an error whenever i try to create a weather object.
My code:
import processing.serial.*;
Serial dataPort;
String val;
//Settings
boolean use12Time = true; //24-Hour time or 12-Hour time
int slide = 1; //Starting slide
int totalSlides = 3; //# of slides total
int slideTime = 3; //Time on each slide (s)
//Timer
int savedTime;
int totalTime = slideTime * 1000;
//Yahoo weather
Weather weather = new Weather(23509325, "Celsius");
void setup() {
size(200, 200);
dataPort = new Serial(this, "COM5", 9600);
savedTime = millis();
while(weather.checkConnection() == false) {
println("Refresh");
}
}
void draw() {
int passedTime = millis() - savedTime;
if(passedTime > totalTime) {
slide = (slide + 1) % totalSlides;
savedTime = millis();
}
switch(slide) {
case 1:
if(use12Time) {
if(hour() == 0) {
dataPort.write("12:" + nf(minute(), 2) + " A" + '\n');
} else if(1 <= hour() && hour() < 12) {
dataPort.write(str(hour()) + ':' + nf(minute(), 2) + " A" + '\n');
} else if(hour() == 12) {
dataPort.write("12:" + str(minute()) + " P" + '\n');
} else if(13 <= hour() && hour() < 24) {
dataPort.write(str(hour() - 12) + ':' + nf(minute(), 2) + " P" + '\n');
} else if(hour() == 24) {
dataPort.write(str(hour()) + "12:" +nf(minute(), 2) + " A" + '\n');
}
} else {
dataPort.write(str(hour()) + ':' + str(minute()) + '\n');
}
break;
case 2:
dataPort.write(str(month()) + '/' + str(day()) + '\n');
break;
case 3:
break;
}
}
The error:
The sketch path is not set.
java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
at processing.core.PApplet.runSketch(PApplet.java:10741)
at processing.core.PApplet.main(PApplet.java:10511)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at processing.core.PApplet.runSketch(PApplet.java:10735)
... 1 more
Caused by: java.lang.RuntimeException: Files must be loaded inside setup() or after it has been called.
at processing.core.PApplet.createInputRaw(PApplet.java:7039)
at processing.core.PApplet.createInput(PApplet.java:7011)
at processing.core.PApplet.createReader(PApplet.java:6817)
at processing.core.PApplet.loadXML(PApplet.java:5930)
at processing.core.PApplet.loadXML(PApplet.java:5920)
at ProcessingTextClock$Weather.<init>(ProcessingTextClock.java:114)
at ProcessingTextClock.<init>(ProcessingTextClock.java:39)
... 6 more