Create a needle graphic that follows wind direction
AGCB
Posts: 327
in Propeller 1
I'm building a weather station and would like to add a simple direction needle for the wind. I have a 16 point pole mounted sensor but sometimes, rather than reading the cardinal points, a simple needle would be nice. I've looked at the graphics object and a demo but to me it seems very complicated. Might there be another way? Else I need a little help!
Comments
Then, just draw a line using graphics.
You could even double buffer to avoid flicker.
After failure upon failure with finally a LITTLE bit of success in a small area, I'm beginning to learn. Using the graphics object and ideas from Cluso99, it just might get to how I want it.
Aaron
Hope that helps you. It's got window methods that can show how to set up and draw to a smaller screen region
My LCD Drivers have routines to draw boxes and fill them in colors, draw lines at any angle which also has how I add arrows (as in drawing the hour/minute/second hands in a clock), etc.
Thanks
Aaron
Hint: Post the part of the code.
I can draw a single line by ( gr.line (50,50) '' Draw a line to point " )
but can't figure out how to use the info from weather vane (16 points) to automatically change the angle of line. I've tried some of your code (and modified parts of it) but may not have the correct formula.
This is Chip's "graphics demo" with most things removed
So you would need a table of the 16 points.
You could use the minutes or seconds. Basically you would need the points for 0, 15, 30, 45 for N E S W, then 7.5, 22.5, 37.5, 52.5 for NE SE SW NE. To divide again you get 3.75, 11.25, etc.
Now, to get approximately there, use 0, 4, 8, 12, 15, 18, 22, 26, 30, etc.
Once you get this working, to get the actual 3.75 minute intervals (22.5 degrees) use SINE mathematics. IIRC I used an excel spreadsheet to pre-calculate the coordinates.
In that program each line of info is incremented as the seconds or minutes tick by.
Is there a way to specify a certain line in a table like this without making a separate address for each line?
Thanks
Aaron
You will only need a single table of 16 combinations.
I don't currently have access to my code.
Sure, you can calculate the the end point (sin & cos) of the lines based on the time using trig functions, however it is simpler to have a table of the x and y values for one quadrant of the circle and change the sign of the x/y values to produce the other quadrants.
In the case of the weather vane’s 16 points that would require 4 x and y values. For a clock 15 x and y values.
In either case it probably takes less time and space to use a table than to use code to calculate the values.
There is a SIN table in the Prop though. Says how to use it on P.385 of Prop Manual.
It isn't really complex though...
1) Pick a Degree point you want to represent (0 to 360) and the radius (how far you want that point from center) ... plug that into the Coordic routine to determine the X and Y for that location. This defines the tip of the arrow
2) Pick two other points that are +5 Deg and -5 Deg from the degree point and a radius that is slightly smaller ... use the coordic routine as in step 1 to obtain the other two X and Y points. This forms the sides of your arrow.
3) Connect your points with the graphics line function and that's all.
4) To extend the needle in the opposite direction, follow step 1 but choose a Deg value that is 180 Deg away from your DEG point.
i have some Time and no TV
I wrote a little Demo for VGA 320x240 (signaled as 640x480).
Have Fun
propeller.ws-nbg.de
Greetings from Nuremberg, Germany
Werner
Here's an interesting link about Cordic on the Propeller:
https://forums.parallax.com/discussion/88799/some-cordic-documentation
Might be some handy code in this object too:
http://obex.parallax.com/object/791
sorry, i forgot the Preview.
Greetings from Nuremberg, Germany
Werner
@zx81vga
Its amazing how, not watching TV .. COMPLETELY CHANGES EVERYTHING!
Nice LCARS theme on your site!
Nice code preview!
Excellent content and nice job on providing example code!
Aaron
Werner
Would you please explain a little about this Aaron
P.S. I was in Stuttgart when I was in the army 45 years ago.
i create 16 Tables for the 16 Wind Directions.
Every Table is an Array 7x7.
In the Table are ASCII-Character's eg. $20 = Space, $85 = Rotating-Point...
The Character's are in the File CP437_8.BMP
The Char's for N and NNE are marked green.
I fill the Screen-Needle-Area with the current Wind Direction. eg. wind_NNE
See the attached Pictures.
Greetings from Nuremberg, Germany
Werner
P.S.
The Tables occupy 196 Long's
Aaron
VGACOLOR_320x240_CURSOR.spin is included in windneedle.zip (attached)
I changed Chip Gracey's VGA High-Res Text Driver v1.0
Greetings from Nuremberg, Germany
Werner
If a separate IC, how do I identify it?
Thanks
Aaron
Just make sure you have
If it works with RCFast but not PLL, that's a pretty good sign the PLL is dead...
Otherwise, try a simple led flasher and time the flash to see if it works with RC, the xtal.