We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 9e6a2a0 commit 3b5fce2Copy full SHA for 3b5fce2
weatherbit.ts
@@ -263,12 +263,19 @@ namespace weatherbit {
263
* Read the wind direction from the wind vane.
264
* Returns the compass bearing of the wind direction in degrees
265
*/
266
+ let windDirLast = 9999
267
//% weight=20 blockId="weatherbit_windDir" block="wind direction"
268
export function windDirection(): number {
269
startWindMonitoring();
270
271
+ /* read until reading stable */
272
let windDir = 0
273
windDir = pins.analogReadPin(AnalogPin.P1)
274
+ while (Math.abs(windDir-windDirLast)>10) { /* 10 is an arbitary number based on guess and observation */
275
+ windDirLast = windDir
276
+ windDir = pins.analogReadPin(AnalogPin.P1)
277
+ }
278
+
279
280
if (windDir < 911 && windDir > 894)
281
return 0
0 commit comments