View previous topic :: View next topic |
Author |
Message |
MCUprogrammer
Joined: 08 Sep 2020 Posts: 221
|
speedometer with graphic lcd |
Posted: Tue Feb 09, 2021 11:16 am |
|
|
Hello to everyone
I want to make a speedometer with graphic lcd. As long as the button is pressed, the pointer will move within half an arc. Like the system in vehicles. I wrote the arc function to the graphics driver. It works. But how can I move the pointer at an angle? What is the formula for this job? Do I do it using glcd_line or glcd_pixel? How do you think. _________________ Best Regards...
MCUprogrammer
_______________________________
Work Hard |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9243 Location: Greensville,Ontario
|
|
Posted: Tue Feb 09, 2021 11:33 am |
|
|
hmm, the last intense graphics I did was 3+ decades ago, on a Model III computer but...
Since you cut the code for the 'arm' of the pointer, you know where the moving 'end' of the arm will be. The 'pointer' is probably 2-3 pixels next to the end of the arm, so you could just turn on those 'nearby' pixels. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19538
|
|
Posted: Tue Feb 09, 2021 11:34 am |
|
|
You would draw a line from the centre to the angle required on the curve
forming the outside of the shape. Honestly think in terms of using a look-
up table for this. So precalculate the X and Y coordinates of the end
points, perhaps in a spreadsheet on a PC, and store the coordinates in
an array. For something like 100 RPM values, this will be smaller and
enormously faster than trying to do the calculation in the PIC. |
|
|
|