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 support@ccsinfo.com

glcd_bar don't work ???

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







glcd_bar don't work ???
PostPosted: Mon Nov 08, 2004 3:35 am     Reply with quote

I'm using a 18F452 for a inboard computer in my raid's car (see http://action2003.free.fr ! ).
I try to draw a needle as for an analogical tachometer.
All the code work perfectly, but I want to use the function glcd_bar to draw a 6 (or 7) pixel wide needle between the center and its end. But when I use glcd_bar instead of glcd_line, the result is not correct.



This code work fine, valeur_rpm is the speed motor in rpm, x_c and y_c is the coodinate af the dial'centre.
the needle result is like :
Code:

 /|____
 \|


Code:
void aff_aigui(int16 valeur_rpm,int8 x_c,y_c)
{
   const int8 r3=40,r4=40,r5=49,r6=39; // distance between center and point
   float angle;
   int8 x3,x4,x5,x6,y3,y4,y5,y6;

   angle   = (float) valeur_rpm * ( PI / 6000); // exple 3000 rpm -> PI/2
   x3 = (int8) calc_x_coord(angle + 0.1,r3,x_c);
   x4 = (int8) calc_x_coord(angle - 0.1,r4,x_c);
                             // x3,y3,x4,y4,x5,y5 compute a triangle needle's end
   x5 = (int8) calc_x_coord(angle,r5,x_c); // x needle's end.
   x6 = (int8) calc_x_coord(angle,r6,x_c);
   y3 = (int8) calc_y_coord(angle + 0.1,r3,y_c);
   y4 = (int8) calc_y_coord(angle - 0.1,r4,y_c);
   y5 = (int8) calc_y_coord(angle,r5,y_c); y needle's end
   y6 = (int8) calc_y_coord(angle,r6,y_c);
   
   glcd_line(x3,y3,x5,y5,ON);
   glcd_line(x5,y5,x4,y4,ON);
   glcd_line(x3,y3,x4,y4,ON);
   glcd_line(x_c,y_c,x6,y6,ON);
}
////                                                                       ////
///////////////////////////////////////////////////////////////////////////////
////                                                                       ////
float calc_x_coord(float alpha,int8 rayon,x_offset)
{
   float resul;

   resul = ceil(x_offset - (rayon * cos(alpha)));
   return(resul);
}
////                                                                       ////
///////////////////////////////////////////////////////////////////////////////
////                                                                       ////
float calc_y_coord(float alpha,int8 rayon,y_offset)
{
   float resul;

   resul = ceil(y_offset - (rayon * sin(alpha)));
   return(resul);
}



if i wrote glcd_bar(x_c,y_c,x6,y6,6,ON) for a 6 pixel wide needle instead glcd_line(x_c,y_c,x6,y6,ON);.... it doesn't draw the bar ! Why ???


Is glcd_bar function have a bug ???

Sorry for my poor english !! I'm living in Avignon - France
please help
treitmey



Joined: 23 Jan 2004
Posts: 1094
Location: Appleton,WI USA

View user's profile Send private message Visit poster's website

PostPosted: Mon Nov 08, 2004 9:41 am     Reply with quote

Just from a quick look of the code, I think the bar can only be horizontal and vertical [--- or | ]

Its a bit more math to draw a line/bar at an angle.
action2003



Joined: 08 Nov 2004
Posts: 2
Location: Avignon - France

View user's profile Send private message Visit poster's website

PostPosted: Tue Nov 09, 2004 7:57 am     Reply with quote

treitmey wrote:
Just from a quick look of the code, I think the bar can only be horizontal and vertical [--- or | ]

Its a bit more math to draw a line/bar at an angle.


I don't think... Compare GLCD_LINE and GLCD_BAR code,.... it is same algorithm... (and GLCD_LINE work well for angle).
The difference is only for draw wide pixel... if you chose small x1-x2 and y1-y2, glcd_bar work a bit Laughing and draw a strange dotted line Mad

I don't find the bug, but i solve my problem, a new GLCD_LINE_WIDE function with large pixel (5 pixel square instead 1 pixel). Wink
_________________
Thierry - Avignon - France
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