@@ -35,8 +35,8 @@ namespace weatherbit {
35
35
let msWindTurnLast = 0
36
36
let windMPH = 0
37
37
let directionArrow = [ ArrowNames . North , ArrowNames . NorthEast , ArrowNames . East , ArrowNames . SouthEast , ArrowNames . South , ArrowNames . SouthWest , ArrowNames . West , ArrowNames . NorthWest ]
38
- let directionString = [ "N" , "NE" , "E" , "SE" , "S" , "SW" , "W" , "NW " ]
39
- let simDirection = 0 // North - but simulation will override
38
+ let directionStringArray = [ "N" , "NNE" , " NE", "ENE" , " E", "ESE" , " SE", "SSE" , " S", "SSW" , " SW", "WSW" , " W", "WNW" , "NW" , "NNW "]
39
+ let simDirection = 180 // South - but simulation will override
40
40
41
41
// BME280 Addresses
42
42
const bmeAddr = 0x76
@@ -195,8 +195,8 @@ namespace weatherbit {
195
195
* returns the correct direction string for the index supplied
196
196
*/
197
197
//% weight=18
198
- export function directionStringName ( direction : number ) : string {
199
- return directionString [ Math . round ( direction / 45 ) ]
198
+ export function directionString ( direction : number ) : string {
199
+ return directionStringArray [ Math . round ( direction / 22.5 ) ]
200
200
}
201
201
202
202
/**
@@ -263,22 +263,39 @@ namespace weatherbit {
263
263
264
264
let windDir = 0
265
265
windDir = pins . analogReadPin ( AnalogPin . P1 )
266
- if ( windDir < 906 && windDir > 886 )
266
+
267
+ if ( windDir < 911 && windDir > 894 )
267
268
return 0
268
- else if ( windDir < 712 && windDir > 692 )
269
+ else if ( windDir < 670 && windDir > 653 )
270
+ return 22.5
271
+ else if ( windDir < 709 && windDir > 692 )
269
272
return 45
270
- else if ( windDir < 415 && windDir > 395 )
273
+ else if ( windDir < 395 && windDir > 382 )
274
+ return 67.5
275
+ else if ( windDir < 408 && windDir > 394 )
271
276
return 90
272
- else if ( windDir < 498 && windDir > 478 )
277
+ else if ( windDir < 381 && windDir > 364 )
278
+ return 112.5
279
+ else if ( windDir < 492 && windDir > 475 )
273
280
return 135
281
+ else if ( windDir < 439 && windDir > 422 )
282
+ return 157.5
274
283
else if ( windDir < 584 && windDir > 564 )
275
284
return 180
276
- else if ( windDir < 819 && windDir > 799 )
285
+ else if ( windDir < 543 && windDir > 526 )
286
+ return 202.5
287
+ else if ( windDir < 820 && windDir > 803 )
277
288
return 225
278
- else if ( windDir < 988 && windDir > 968 )
289
+ else if ( windDir < 801 && windDir > 784 )
290
+ return 247.5
291
+ else if ( windDir < 994 && windDir > 977 )
279
292
return 270
280
- else if ( windDir < 959 && windDir > 939 )
293
+ else if ( windDir < 933 && windDir > 916 )
294
+ return 292.5
295
+ else if ( windDir < 964 && windDir > 947 )
281
296
return 315
297
+ else if ( windDir < 864 && windDir > 847 )
298
+ return 337.5
282
299
else
283
300
return simDirection
284
301
}
0 commit comments