Notifications
Clear all

10/18/2023 Map Stopped Working?
Visit this post for the fix

Wind Direction Display

13 Posts
3 Users
0 Reactions
916 Views
(@mezmer3365)
Active Member
Joined: 5 years ago
Posts: 16
Topic starter  

Is there a way to display the wind direction in number rather than arrow? Or was there a reason that was donw.


   
Quote
Mark Harris
(@markyharris)
Member Admin Registered
Joined: 5 years ago
Posts: 557
 

Mez, I can look at doing that. The reason for the arrow was to limit the space needed so that the font could remain as big as possible. If we are able to figure a way to do the numbers so that its readable, we'll post the information here.

Thanks for the suggestion. - Mark


   
ReplyQuote
(@mezmer3365)
Active Member
Joined: 5 years ago
Posts: 16
Topic starter  

Mark - Thanks for the quick reply. I look forward to hearing what you can come up with. Your work is greatly appreciated. 


   
ReplyQuote
Mark Harris
(@markyharris)
Member Admin Registered
Joined: 5 years ago
Posts: 557
 

Mez, I was able to play with this a bit and it looks doable. It should be in the next release. It will be setup in such a way as the builder can choose between displaying the wind direction using an Arrow or with numbers in degrees from the web interface under 'Display Options'.

Thank you for the suggestion. - Mark

oled wndir

 


   
ReplyQuote
(@mezmer3365)
Active Member
Joined: 5 years ago
Posts: 16
Topic starter  

Looking forward to having that in the next version. I am impressed with your code. Is there any chance I can see the changes you made. I would love to try it out. I am looking to see if the LCD ro OLED is better for me. Let me know and thanks again!


   
ReplyQuote
Mark Harris
(@markyharris)
Member Admin Registered
Joined: 5 years ago
Posts: 557
 

Around Line 302, replace this function with the one there (or make the changes);

def oledcenter(txt, ch, font, wndir=0, dim=dimswitch, onoff = 0, pause = 0): #Center text vertically and horizontally
tca_select(ch) #Select the display to write to
oleddim(dim) #Set brightness, 0 = Full bright, 1 = medium bright, 2 = low brightdef oledcenter(txt): #Center text vertically and horizontally
draw.rectangle((0, 0, width-1, height-1), outline=border, fill=backcolor) #blank the display
x1, y1, x2, y2 = 0, 0, width, height #create boundaries of display

if wndir == "" or txt == '\n' or 'Updated' in txt or 'Calm' in txt: #Setup and print wind direction arrow
pass #don't print any arrow in certain conditions

elif wind_numorarrow == 0: #draw wind direction using arrows
draw.text((96, 37), wndir, font=arrows, fill=fontcolor) #lower right of oled

else: #draw wind direction using numbers
txt = txt + ' @' + str(dir) + chr(176) #chr(176) = degree symbol

w, h = draw.textsize(txt, font=font) #get textsize of what is to be displayed
x = (x2 - x1 - w)/2 + x1 #calculate center for text
y = (y2 - y1 - h)/2 + y1 - offset

draw.text((x, y), txt, align='center', font=font, fill=fontcolor) #Draw the text to buffer

invertoled(onoff) #invert display if set
disp.image(image) #Display image
disp.display() #display text in buffer
time.sleep(pause) #pause long enough to be read

 

Around Line 121 - add this variable set to '1';

wind_numorarrow = 1        #0 = Display Wind direction using arrows, 1 = Display wind direction using numbers.

 

Around Line 1493 - remove the space in front of ' kts';

#add kts to the end of the wind speed if present
if isinstance(wnd, int):
    val = val + "kts"

 

Make these changes and it should work. Make a backup of metar-display-v31.py in case things go bad. You can set the variable above to '0' if you want to go back to arrows for the wind direction. Let us know how it works. Good luck. - Mark

 


   
ReplyQuote
(@mezmer3365)
Active Member
Joined: 5 years ago
Posts: 16
Topic starter  

So I was trying to flip the direction and speed so it display 110@10kts, but every change I make is erroring it out. I was wondering if you could take a quick look.


   
ReplyQuote
Mark Harris
(@markyharris)
Member Admin Registered
Joined: 5 years ago
Posts: 557
 

This isn't very elegant but it will work.

ap, wndsp = txt.split('\n')
txt = ap + '\n' + str(dir) + chr(176) + '@' + wndsp

 

It deconstructs the 'txt' message and then re-arranges the elements into the format order you would like. Let us know if this works for you. - Mark

 


   
ReplyQuote
(@mezmer3365)
Active Member
Joined: 5 years ago
Posts: 16
Topic starter  

Did you place this in the same place in the function above? When I do I am only getting the wind speed.


   
ReplyQuote
Mark Harris
(@markyharris)
Member Admin Registered
Joined: 5 years ago
Posts: 557
 

Yes, just substitute the first code snippet for the 2nd code snippet below. I tried it and it works well.

else: #draw wind direction using numbers
txt = txt + ' @' + str(dir) + chr(176) #chr(176) = degree symbol

else: #draw wind direction using numbers
ap, wndsp = txt.split('\n')
txt = ap + '\n' + str(dir) + chr(176) + '@' + wndsp

   
ReplyQuote
(@mezmer3365)
Active Member
Joined: 5 years ago
Posts: 16
Topic starter  

I saw what I did and that worked. I appreciate the quick responses. I think it is great to have the option. I will get some vid once this is done. 


   
ReplyQuote
(@captain_ron)
Estimable Member
Joined: 5 years ago
Posts: 162
 

Since we can set a user defined wind speed so the lights blink, would it be possible for the OLED's to display the wind data for that airport? Maybe from highest speed to lowest in order?

Or is it just a set list of airports?


   
ReplyQuote
Mark Harris
(@markyharris)
Member Admin Registered
Joined: 5 years ago
Posts: 557
 

Hi Ron,

If I understand your question correctly, yes you can do that. The first 4 settings under the 'LCD And OLED Display Settings' should accommodate that. Set the first setting to the Max number of airports to display and be sure that the 4th setting is set to 'Yes'. Keep in mind that the order in which the airports are displayed is sorted by their wind speeds. So the highest wind speed airport will be displayed first followed by the second highest and so forth.

If you want all wind speeds, regardless if they are blinking or not then set the 4th setting to 'No' and then it will cycle through the number of airports you specify in the first setting regardless if they are higher than the high wind setting in 'Basic Settings'.

You can also limit which airports are displayed by filling out the list in the 3rd setting. No other airport will be displayed, only those in the list.

If I didn't quite understand the question, let me know. - Mark

 

image

   
ReplyQuote
Share: