-
Notifications
You must be signed in to change notification settings - Fork 0
/
DrawScreen.pde
273 lines (243 loc) · 12.1 KB
/
DrawScreen.pde
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
/* This program is free software. It comes without any warranty, to
* the extent permitted by applicable law. You can redistribute it
* and/or modify it under the terms of the Do What The Fuck You Want
* To Public License, Version 2, as published by Sam Hocevar. See
* http://sam.zoy.org/wtfpl/COPYING for more details. */
import gifAnimation.*;
PImage[] animation;
Gif loopingGif;
void updateRadar() {
float houseWidth = .6*width-2*padding - 2*thickpad;
float houseHeight = height-.142875*height-3*padding - 2*thickpad;
loopingGif = wundergroundWeather.updateRadar("74074", apiKey, int(houseHeight), int(houseWidth));
}
void drawRadar() {
float houseXstart = .4*width+padding + thickpad;
float houseYstart = .142875*height+2*padding + thickpad;
image(loopingGif, houseXstart, houseYstart);
}
void drawTopInformation() {
textAlign(LEFT);
textSize(60);
fill(fontColor);
// text(cityName+" ", 39, 90);
textSize(20);
// text("Lon: "+nf(googleWeather.getLongitude(), 2, 2)+" Lat: "+nf(googleWeather.getLatitude(), 2, 2));
textSize(20);
textAlign(RIGHT);
// text(topInfo.format(googleWeather.getLastUpdated()), 1070, 90);
}
void drawWeatherNow() {
int paddingTop = 203;
int paddingLeft = 25;
textAlign(LEFT);
fill(fontColor);
textSize(20);
text("Updated: "+measureTime(weatherService, SpeedUnits), 46, 155);
textSize(80);
text(currentTemp(weatherService, TempUnits), paddingLeft+15, paddingTop+80);
textSize(20);
// text("Min:" + int(googleWeather.getMinTemperatureInFahrenheitInXDays(0))+" Max:"+int(googleWeather.getMaxTemperatureInFahrenheitInXDays(0))+"F°", paddingLeft+15, paddingTop+85+thickpad);
textSize(50);
text(currentCondition(weatherService, TempUnits), paddingLeft+17, paddingTop+180);
textSize(30);
text("Wind: "+currentWindDirection(weatherService, SpeedUnits)+" at "+ currentWindSpeed(weatherService, SpeedUnits), paddingLeft+20, paddingTop+235 );
text("Humidity: "+currentHumidity(weatherService, SpeedUnits) +"%", paddingLeft+20, paddingTop+275);
drawIcon(280, 125, 240, 240, currentCondition(weatherService, TempUnits));
}
void setupHistoryGraph() {
pushStyle();
textSize(10);
if (!initalSerial) {
minRange = min(min(outsideTempHistoryInt), min(insideTempHistoryInt))-5;
maxRange = max(max(outsideTempHistoryInt), max(insideTempHistoryInt));
}
else {
minRange = min(outsideTempHistoryInt)-5;
maxRange = max(outsideTempHistoryInt);
}
quarterRange = lerp(minRange, maxRange, .25);
halfRange = lerp(minRange, maxRange, .5);
threeQuarterRange = lerp(minRange, maxRange, .75);
text( maxRange, 3*padding, .68*height+4*padding); //prints the max measured value
text(int(quarterRange), 3*padding, lerp(.68*height+ (1-.142875-.537125)*height-2*padding, .68*height+4*padding, .25));
text(int(halfRange), 3*padding, lerp(.68*height+ (1-.142875-.537125)*height-2*padding, .68*height+4*padding, .5));
text(int(threeQuarterRange), 3*padding, lerp(.68*height+ (1-.142875-.537125)*height-2*padding, .68*height+4*padding, .75));
//text( max(max(outsideTempHistoryInt), max(insideTempHistoryInt)), 2*padding, .68*height+3*padding);
text( minRange, 3*padding, .68*height+ (1-.142875-.537125)*height-2*padding); //min recored value
stroke(255);
line(3*padding + textWidth("1111"), .68*height+4*padding, 3*padding + textWidth("1111"), .68*height+ (1-.142875-.537125)*height-2*padding); //y axis line
line(3*padding + textWidth("1111"), .68*height+ (1-.142875-.537125)*height-2*padding, .4*width-3*padding+6, .68*height+ (1-.142875-.537125)*height-2*padding); //x axis line
popStyle();
}
void drawHistoryLine() {
setupHistoryGraph();
pushStyle();
strokeWeight(5);
stroke(color(0, 0, 255));
fill(color(0, 0, 255, 200));
textSize(10);
for (int i=0; i <outsideTempHistoryInt.length; i++) {
int yPos = int(map(outsideTempHistoryInt[i], minRange, maxRange, .68*height+ (1-.142875-.537125)*height-2*padding -1, .68*height+4*padding));
int xPos = int( (.4*width-3*padding - 3*padding + textWidth("1111") )/ outsideTempHistoryInt.length);
int yPos2 = 0;
// rectMode(CORNERS);
if (i == outsideTempHistoryInt.length) {
yPos2 = int(map(outsideTempHistoryInt[outsideTempHistoryInt.length], minRange, maxRange, .68*height+ (1-.142875-.537125)*height-2*padding -1, .68*height+4*padding));
line(3*padding + 1+ textWidth("1111")+ i*9, yPos, (3*padding + 1+ textWidth("1111")+ i*9)+18, yPos2) ;
}
else if (i < outsideTempHistoryInt.length - 1) {
yPos2 = int(map(outsideTempHistoryInt[i+1], minRange, maxRange, .68*height+ (1-.142875-.537125)*height-2*padding -1, .68*height+4*padding));
line(3*padding + 1+ textWidth("1111")+ i*9, yPos, (3*padding + 1+ textWidth("1111")+ i*9)+9, yPos2) ;
}
}
popStyle();
if (!initalSerial) {
pushStyle();
strokeWeight(5);
stroke(color(255, 128, 0));
fill(color(255, 128, 0, 200));
textSize(10);
for (int i=0; i <insideTempHistoryInt.length; i++) {
int yPos = int(map(insideTempHistoryInt[i], minRange, maxRange, .68*height+ (1-.142875-.537125)*height-2*padding -1, .68*height+4*padding));
int xPos = int( (.4*width-3*padding - 3*padding + textWidth("1111") )/ insideTempHistoryInt.length);
int yPos2 = 0;
// rectMode(CORNERS);
if (i == insideTempHistoryInt.length) {
yPos2 = int(map(insideTempHistoryInt[insideTempHistoryInt.length], minRange, maxRange, .68*height+ (1-.142875-.537125)*height-2*padding -1, .68*height+4*padding));
line(3*padding + 1+ textWidth("1111")+ i*9, yPos, (3*padding + 1+ textWidth("1111")+ i*9)+18, yPos2) ;
}
else if (i < insideTempHistoryInt.length - 1) {
yPos2 = int(map(insideTempHistoryInt[i+1], minRange, maxRange, .68*height+ (1-.142875-.537125)*height-2*padding -1, .68*height+4*padding));
line(3*padding + 1+ textWidth("1111")+ i*9, yPos, (3*padding + 1+ textWidth("1111")+ i*9)+9, yPos2) ;
}
}
popStyle();
}
pushStyle();
textSize(10);
if ( mouseX > 3*padding + textWidth("1111") && mouseX < .4*width-3*padding+6 && mouseY > .68*height+4*padding && mouseY < .68*height+ (1-.142875-.537125)*height-2*padding) {
cursor(CROSS);
textSize(15);
text(nfc(lerp(maxRange, minRange, norm(mouseY, .68*height+4*padding, .68*height+ (1-.142875-.537125)*height-2*padding)), 1)+"°", mouseX+15, mouseY-15);
}
else {
cursor(ARROW);
}
popStyle();
}
void drawHistoryBar() {
setupHistoryGraph();
pushStyle();
stroke(color(0, 0, 255));
fill(color(0, 0, 255, 200));
textSize(10);
for (int i=0; i <outsideTempHistoryInt.length; i++) {
int yPos = int(map(outsideTempHistoryInt[i], minRange, maxRange, .68*height+ (1-.142875-.537125)*height-2*padding -1, .68*height+4*padding));
int xPos = int( (.4*width-3*padding - 3*padding + textWidth("1111") )/ outsideTempHistoryInt.length);
rectMode(CORNERS);
rect(3*padding + 1+ textWidth("1111")+ i*9, yPos, (3*padding + 1+ textWidth("1111")+ i*9)+9, .68*height + (1-.142875-.537125)*height-2*padding -1);
}
popStyle();
if (!initalSerial) {
pushStyle();
// stroke(color(255, 128, 0));
// fill(color(255, 128, 0, 100));
textSize(10);
for (int i=0; i <insideTempHistoryInt.length; i++) {
if (insideTempHistoryInt[i] > outsideTempHistoryInt[i] ) {
stroke(color(255, 128, 0)); //orange
fill(color(255, 128, 0, 1)); //orange with partial transparent
}
else {
stroke(color(255, 128, 0));
fill(color(255, 128, 0, 192));
}
int yPos = int(map(insideTempHistoryInt[i], minRange, maxRange, .68*height + (1-.142875-.537125)*height-2*padding -1, .68*height+4*padding));
int xPos = int( (.4*width-3*padding - 3*padding + textWidth("1111") )/ insideTempHistoryInt.length);
rectMode(CORNERS);
rect(3*padding + 1+ textWidth("1111")+ i*9, yPos, 3*padding + 1+ textWidth("1111")+ i*9+9, .68*height+ (1-.142875-.537125)*height-2*padding -1);
}
popStyle();
}
pushStyle();
textSize(10);
if ( mouseX > 3*padding + textWidth("1111") && mouseX < .4*width-3*padding+6 && mouseY > .68*height+4*padding && mouseY < .68*height+ (1-.142875-.537125)*height-2*padding) {
cursor(CROSS);
textSize(15);
text(nfc(lerp(maxRange, minRange, norm(mouseY, .68*height+4*padding, .68*height+ (1-.142875-.537125)*height-2*padding)), 1)+"°", mouseX+15, mouseY-15);
}
else {
cursor(ARROW);
}
popStyle();
}
void drawHouseInformation() {
float houseXstart = .4*width+padding;
float houseYstart = .142875*height+2*padding;
float houseWidth = .6*width-2*padding;
float houseHeight = height-.142875*height-3*padding;
pushStyle(); //Draw the LAundry room
noSmooth();
stroke(255);
strokeWeight(4);
color fillcolor = TempReading(1, 0, true, true);
fill(fillcolor);
rect(houseXstart + thickpad, houseYstart + thickpad, houseWidth - houseWidth*.125- 2*thickpad, (houseWidth - 2*thickpad)/5.5 );
textSize(60);
fill(0);
if (!initalSerial) {
text(LaundryTemp, houseXstart + (houseWidth - houseWidth*.125- 2*thickpad)/2, houseYstart + 2*thickpad +((houseWidth - 2*thickpad)/5.5)/2 );
}
popStyle();
pushStyle(); //draw the living room
noSmooth();
stroke(255);
strokeWeight(4);
fillcolor = TempReading(2, 0, true, true);
fill(TempReading(2, 0, true, true));
rect(houseXstart + houseWidth/2 + thickpad, houseYstart + thickpad +(houseWidth - 2*thickpad)/5.5, houseWidth/2 - 2*thickpad, houseHeight - 2*thickpad -(houseWidth - 2*thickpad)/5.5 );
textSize(60);
fill(0);
if (!initalSerial) {
text(LivingTemp, houseXstart + houseWidth/2 + ((houseWidth/2 - 2*thickpad)/2), houseYstart + thickpad +(houseWidth - 3*thickpad)/5.5+((houseHeight - 2*thickpad -(houseWidth - 2*thickpad)/5.5)/2) );
}
popStyle();
pushStyle(); //draw the kitchen
noSmooth();
stroke(255);
strokeWeight(4);
fillcolor = TempReading(3, 0, true, true);
fill(fillcolor);
rect(houseXstart + thickpad, houseYstart + thickpad +(houseWidth - 2*thickpad)/5.5, houseWidth/2, (houseWidth - 2*thickpad)/5 );
popStyle();
pushStyle(); //draw the Bathroom and closet
noSmooth();
stroke(255);
strokeWeight(4);
fill(96);
rect(houseXstart + thickpad, houseYstart + (houseWidth - 2*thickpad)/5 +(houseWidth - 2*thickpad)/5, houseWidth/2, (houseWidth - 2*thickpad)/7 );
line(houseXstart + thickpad + houseWidth/2.75, houseYstart + (houseWidth - 2*thickpad)/5 +(houseWidth - 2*thickpad)/5, houseXstart + thickpad + houseWidth/2.75, houseYstart + (houseWidth - 2*thickpad)/5 +(houseWidth - 2*thickpad)/5 +(houseWidth - 2*thickpad)/7);
popStyle();
pushStyle(); //draw the Study
noSmooth();
stroke(255);
strokeWeight(4);
fillcolor = TempReading(4, 0, true, true);
fill(fillcolor);
rect(houseXstart + thickpad, houseYstart + (houseWidth - 2*thickpad)/5 +(houseWidth - 2*thickpad)/5 +(houseWidth - 2*thickpad)/7, houseWidth/2, (houseWidth - 2*thickpad)/3.8 );
popStyle();
/*
pushStyle(); //Draw the doors
noSmooth();
stroke(0);
strokeWeight(4);
line( houseXstart + 75+ thickpad, houseYstart + thickpad +(houseWidth - 2*thickpad)/5.5, houseXstart + thickpad+150, houseYstart + thickpad +(houseWidth - 2*thickpad)/5.5); //laundry to kitchen
line( houseXstart + 75+ thickpad + houseWidth/2, houseYstart + thickpad +(houseWidth - 2*thickpad)/5.5, houseXstart + thickpad+150 +houseWidth/2, houseYstart + thickpad +(houseWidth - 2*thickpad)/5.5); //laundry to living
line( houseXstart + 75+ thickpad, houseYstart + (houseWidth - 2*thickpad)/5 +(houseWidth - 2*thickpad)/5 +(houseWidth - 2*thickpad)/7, houseXstart + 150+ thickpad, houseYstart + (houseWidth - 2*thickpad)/5 +(houseWidth - 2*thickpad)/5 +(houseWidth - 2*thickpad)/7); //bathrrom to study
line( houseXstart + houseWidth/2 + thickpad, houseYstart + thickpad +(houseWidth - 2*thickpad)/5.5 +25, houseXstart + houseWidth/2 + thickpad, houseYstart + thickpad +(houseWidth - 2*thickpad)/5.5 +95); //kitchen to living
line( houseXstart + houseWidth/2 + thickpad, (1.33*houseYstart + (houseWidth - 2*thickpad)/5 +(houseWidth - 2*thickpad)/5 +(houseWidth - 2*thickpad)/7), houseXstart + houseWidth/2 + thickpad, 100+ (1.33*houseYstart + (houseWidth - 2*thickpad)/5 +(houseWidth - 2*thickpad)/5 +(houseWidth - 2*thickpad)/7)); //living to study
popStyle();
*/
smooth();
}