View previous topic :: View next topic |
Author |
Message |
ERICOO
Joined: 13 Jun 2011 Posts: 14 Location: NIGERIA
|
CODE FOR DISPLAY OF TRUE CIRCLE |
Posted: Mon Jun 13, 2011 5:47 am |
|
|
I am very new to mcu programming. I will appreciate if anyone could tell me why the ccs GRAPHICS.C driver in PCM compiler displays an elliptical shape instead of a true circle. I have compiled the ccs EX_GLCD.c and it displayed elliptical shape i have recently written a code to display analog clock on glcd using the ccs divers, PIC16F887 and LCM128643 GLCD and it still display the elliptical shape. I will be pleased if someone could provide me with the correct code for circle.
Thanks
ERICOO. |
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Mon Jun 13, 2011 6:22 am |
|
|
The CCS driver is universal and assumes a display with pixels that are square (have same width and height).
The pixels in your LCD are not square. The size of each pixel is 0.4 x 0.56mm and gap of 0.04mm between the pixels. If you want to draw something that looks like a circle you actually have to draw an ellipse.
Using Google you should be able to find an ellipse drawing function. |
|
|
Douglas Kennedy
Joined: 07 Sep 2003 Posts: 755 Location: Florida
|
|
Posted: Mon Jun 13, 2011 11:18 am |
|
|
The circle drawing algorithms assume a 1.1 aspect ratio ( square pixels)
For non square lcds I just altered the algorithm to add an aspect ratio. The algorithm used is Breshenham's where delta x and delta y are assumed to have the same unit value when translated to the physical system. |
|
|
Douglas Kennedy
Joined: 07 Sep 2003 Posts: 755 Location: Florida
|
|
Posted: Thu Jun 16, 2011 11:49 am |
|
|
Ericoo
I PM'd you circle code with the aspect ratio adjustment to the algorithm the comments in the code explain the eight fold symmetry and the finite difference math on which Breshenham based the algorithm. |
|
|
ERICOO
Joined: 13 Jun 2011 Posts: 14 Location: NIGERIA
|
CODE FOR DISPLAY OF TRUE CIRCLE |
Posted: Tue Jun 28, 2011 4:24 am |
|
|
Hello Douglas.
The code you forwarded to me worked, but i could comprehend the code.
I observed that the origin (0,0) is at the far right side instead of left side of the glcd. Again the circle could not drawn together on the two sides. once the radius extend over x=63 the circle will split in two, one mirror of the other. I interchanged the logic states of cs1 and cs2, but the circle remain split. Apparently my limited knowledge of MCU code writing made unable for me to fix these observations. I would appreciate if you are chanced though to suggest solutions and and explain the following:
Code: | ( long) as in y1=(long)y*(long)5/(long)6; /// aspect ratio
| is this a kind of variable type?
what are the functions of( pen size and set_clr) in void lcd_circle(int8 x_ctr,int8 y_ctr,int8 radius,int8 pen_size,int8 solid,int8 set_clr) and why are they int8 type instead short or boolean?
Thanks for the assistance thus far.
ERICOO |
|
|
|