CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

CODE FOR DISPLAY OF TRUE CIRCLE

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
ERICOO



Joined: 13 Jun 2011
Posts: 14
Location: NIGERIA

View user's profile Send private message

CODE FOR DISPLAY OF TRUE CIRCLE
PostPosted: Mon Jun 13, 2011 5:47 am     Reply with quote

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

View user's profile Send private message

PostPosted: Mon Jun 13, 2011 6:22 am     Reply with quote

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. Smile

Using Google you should be able to find an ellipse drawing function.
Douglas Kennedy



Joined: 07 Sep 2003
Posts: 755
Location: Florida

View user's profile Send private message AIM Address

PostPosted: Mon Jun 13, 2011 11:18 am     Reply with quote

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

View user's profile Send private message AIM Address

PostPosted: Thu Jun 16, 2011 11:49 am     Reply with quote

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

View user's profile Send private message

CODE FOR DISPLAY OF TRUE CIRCLE
PostPosted: Tue Jun 28, 2011 4:24 am     Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group