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

Graphic LCD
Goto page Previous  1, 2
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
hemnath



Joined: 03 Oct 2012
Posts: 228
Location: chennai

View user's profile Send private message

PostPosted: Sun Aug 06, 2017 9:36 pm     Reply with quote

Thank you very much Smile It works with
Quote:
#device PASS_STRINGS option
hemnath



Joined: 03 Oct 2012
Posts: 228
Location: chennai

View user's profile Send private message

PostPosted: Sun Aug 06, 2017 9:43 pm     Reply with quote

To display the bargraph on GLCD, I used the below program.
Code:
void bargraph_disp()
{
   int16 percent;
   int c = 0;
   
//   percent = Y02 * 100/10.0;

   percent  = 100;

   if(percent <= 0)
   {
      percent = 0;
   }

   if(percent >= 100)
   {
      percent = 100;
   }

   if(percent >= 100)
   {
      bargraph_display(0xB0, 0x10, 0x00, 0xD8);
      bargraph_display(0xB1, 0x10, 0x00, 0xB6);   
      bargraph_display(0xB2, 0x10, 0x00, 0x6D);   
      bargraph_display(0xB3, 0x10, 0x00, 0xDB);
      bargraph_display(0xB4, 0x10, 0x00, 0xB6);
      bargraph_display(0xB5, 0x10, 0x00, 0x6D);
      bargraph_display(0xB6, 0x10, 0x00, 0xDB);
      bargraph_display(0xB7, 0x10, 0x00, 0x36);
   }


   else if(percent >= 95)
   {
      bargraph_display(0xB0, 0x10, 0x00, 0xC0);
      bargraph_display(0xB1, 0x10, 0x00, 0xB6);   
      bargraph_display(0xB2, 0x10, 0x00, 0x6D);   
      bargraph_display(0xB3, 0x10, 0x00, 0xDB);
      bargraph_display(0xB4, 0x10, 0x00, 0xB6);
      bargraph_display(0xB5, 0x10, 0x00, 0x6D);
      bargraph_display(0xB6, 0x10, 0x00, 0xDB);     
      bargraph_display(0xB7, 0x10, 0x00, 0x36);
   }

   else if(percent >= 90)
   {
      bargraph_display(0xB0, 0x10, 0x00, 0x00);
      bargraph_display(0xB1, 0x10, 0x00, 0xB6);   
      bargraph_display(0xB2, 0x10, 0x00, 0x6D);   
      bargraph_display(0xB3, 0x10, 0x00, 0xDB);
      bargraph_display(0xB4, 0x10, 0x00, 0xB6);
      bargraph_display(0xB5, 0x10, 0x00, 0x6D);
      bargraph_display(0xB6, 0x10, 0x00, 0xDB);     
      bargraph_display(0xB7, 0x10, 0x00, 0x36);
   }

   else if(percent >= 85)
   {
      bargraph_display(0xB0, 0x10, 0x00, 0x00);
      bargraph_display(0xB1, 0x10, 0x00, 0xB0);   
      bargraph_display(0xB2, 0x10, 0x00, 0x6D);   
      bargraph_display(0xB3, 0x10, 0x00, 0xDB);
      bargraph_display(0xB4, 0x10, 0x00, 0xB6);
      bargraph_display(0xB5, 0x10, 0x00, 0x6D);
      bargraph_display(0xB6, 0x10, 0x00, 0xDB);     
      bargraph_display(0xB7, 0x10, 0x00, 0x36);
   }

   else if(percent >= 80)
   {
      bargraph_display(0xB0, 0x10, 0x00, 0x00);
      bargraph_display(0xB1, 0x10, 0x00, 0x80);
      bargraph_display(0xB2, 0x10, 0x00, 0x6D);   
      bargraph_display(0xB3, 0x10, 0x00, 0xDB);
      bargraph_display(0xB4, 0x10, 0x00, 0xB6);
      bargraph_display(0xB5, 0x10, 0x00, 0x6D);
      bargraph_display(0xB6, 0x10, 0x00, 0xDB);     
      bargraph_display(0xB7, 0x10, 0x00, 0x36);
   }

   else if(percent >= 75)
   {
      for(c = 0; c <= 1; c++)   
      {
         bargraph_display(0xB0+c, 0x10, 0x00, 0x00);
      }

      bargraph_display(0xB2, 0x10, 0x00, 0x6C);   
      bargraph_display(0xB3, 0x10, 0x00, 0xDB);
      bargraph_display(0xB4, 0x10, 0x00, 0xB6);
      bargraph_display(0xB5, 0x10, 0x00, 0x6D);
      bargraph_display(0xB6, 0x10, 0x00, 0xDB);   
      bargraph_display(0xB7, 0x10, 0x00, 0x36);
   }

   else if(percent >= 70)
   {
      for(c = 0; c <= 1; c++)   
      {
         bargraph_display(0xB0+c, 0x10, 0x00, 0x00);
      }

      bargraph_display(0xB2, 0x10, 0x00, 0x60);   
      bargraph_display(0xB3, 0x10, 0x00, 0xDB);
      bargraph_display(0xB4, 0x10, 0x00, 0xB6);
      bargraph_display(0xB5, 0x10, 0x00, 0x6D);
      bargraph_display(0xB6, 0x10, 0x00, 0xDB);     
      bargraph_display(0xB7, 0x10, 0x00, 0x36);
   }

   else if(percent >= 65)
   {
      for(c = 0; c <= 2; c++)   
      {
         bargraph_display(0xB0+c, 0x10, 0x00, 0x00);
      }

      bargraph_display(0xB3, 0x10, 0x00, 0xDB);
      bargraph_display(0xB4, 0x10, 0x00, 0xB6);
      bargraph_display(0xB5, 0x10, 0x00, 0x6D);
      bargraph_display(0xB6, 0x10, 0x00, 0xDB);     
      bargraph_display(0xB7, 0x10, 0x00, 0x36);
   }

   else if(percent >= 60)
   {
      for(c = 0; c <= 2; c++)   
      {
         bargraph_display(0xB0+c, 0x10, 0x00, 0x00);
      }

      bargraph_display(0xB3, 0x10, 0x00, 0xD8);
      bargraph_display(0xB4, 0x10, 0x00, 0xB6);
      bargraph_display(0xB5, 0x10, 0x00, 0x6D);
      bargraph_display(0xB6, 0x10, 0x00, 0xDB);     
      bargraph_display(0xB7, 0x10, 0x00, 0x36);
   }

   else if(percent >= 55)
   {
      for(c = 0; c <= 2; c++)   
      {
         bargraph_display(0xB0+c, 0x10, 0x00, 0x00);
      }

      bargraph_display(0xB3, 0x10, 0x00, 0xC0);
      bargraph_display(0xB4, 0x10, 0x00, 0xB6);
      bargraph_display(0xB5, 0x10, 0x00, 0x6D);
      bargraph_display(0xB6, 0x10, 0x00, 0xDB);   
      bargraph_display(0xB7, 0x10, 0x00, 0x36);
   }

   else if(percent >= 50)
   {
      for(c = 0; c <= 3; c++)   
      {
         bargraph_display(0xB0+c, 0x10, 0x00, 0x00);
      }

      bargraph_display(0xB4, 0x10, 0x00, 0xB6);
      bargraph_display(0xB5, 0x10, 0x00, 0x6D);
      bargraph_display(0xB6, 0x10, 0x00, 0xDB);     
      bargraph_display(0xB7, 0x10, 0x00, 0x36);
   }


   else if(percent >= 45)
   {
      for(c = 0; c <= 3; c++)   
      {
         bargraph_display(0xB0+c, 0x10, 0x00, 0x00);
      }

      bargraph_display(0xB4, 0x10, 0x00, 0xB0);
      bargraph_display(0xB5, 0x10, 0x00, 0x6D);
      bargraph_display(0xB6, 0x10, 0x00, 0xDB);     
      bargraph_display(0xB7, 0x10, 0x00, 0x36);
   }

   else if(percent >= 40)
   {
      for(c = 0; c <= 3; c++)   
      {
         bargraph_display(0xB0+c, 0x10, 0x00, 0x00);
      }

      bargraph_display(0xB4, 0x10, 0x00, 0x80);
      bargraph_display(0xB5, 0x10, 0x00, 0x6D);
      bargraph_display(0xB6, 0x10, 0x00, 0xDB);     
      bargraph_display(0xB7, 0x10, 0x00, 0x36);
   }


   else if(percent >= 35)
   {
      for(c = 0; c <= 4; c++)   
      {
         bargraph_display(0xB0+c, 0x10, 0x00, 0x00);
      }

      bargraph_display(0xB5, 0x10, 0x00, 0x6C);
      bargraph_display(0xB6, 0x10, 0x00, 0xDB);     
      bargraph_display(0xB7, 0x10, 0x00, 0x36);
   }

   else if(percent >= 30)
   {
      for(c = 0; c <= 4; c++)   
      {
         bargraph_display(0xB0+c, 0x10, 0x00, 0x00);
      }

      bargraph_display(0xB5, 0x10, 0x00, 0x60);
      bargraph_display(0xB6, 0x10, 0x00, 0xDB);     
      bargraph_display(0xB7, 0x10, 0x00, 0x36);
   }

   else if(percent >= 25)
   {
      for(c = 0; c <= 5; c++)   
      {
         bargraph_display(0xB0+c, 0x10, 0x00, 0x00);
      }

      bargraph_display(0xB6, 0x10, 0x00, 0xDB);     
      bargraph_display(0xB7, 0x10, 0x00, 0x36);
   }

   else if(percent >= 20)
   {
      for(c = 0; c <= 5; c++)   
      {
         bargraph_display(0xB0+c, 0x10, 0x00, 0x00);
      }

      bargraph_display(0xB6, 0x10, 0x00, 0xD8);     
      bargraph_display(0xB7, 0x10, 0x00, 0x36);
   }

   else if(percent >= 15)
   {
      for(c = 0; c <= 5; c++)   
      {
         bargraph_display(0xB0+c, 0x10, 0x00, 0x00);
      }

      bargraph_display(0xB6, 0x10, 0x00, 0xC0);     
      bargraph_display(0xB7, 0x10, 0x00, 0x36);
   }


   else if(percent >= 10)
   {
      for(c = 0; c <= 6; c++)   
      {
         bargraph_display(0xB0+c, 0x10, 0x00, 0x00);
      }
     
      bargraph_display(0xB7, 0x10, 0x00, 0x36);
   }

   else if(percent >= 5)
   {
      for(c = 0; c <= 6; c++)   
      {
         bargraph_display(0xB0+c, 0x10, 0x00, 0x00);
      }
   
      bargraph_display(0xB7, 0x10, 0x00, 0x30);
   }

   else if(percent <= 0)
   {
      for(c = 0; c <= 7; c++)   
      {
         bargraph_display(0xB0+c, 0x10, 0x00, 0x00);
      } 
   }
}

void bargraph_display(char address, char upper_address, char lower_address, char data)
{   
   glcd_command(address);
   glcd_command(upper_address);
   glcd_command(lower_address);

   for(i = 0; i < 5; i++)
   {   
      glcd_data(data);
   }
}


When I compile the code, it occupies 7% of ROM. Is it possible to reduce the memory with much simpler program? Please help.
Ttelmah



Joined: 11 Mar 2010
Posts: 19221

View user's profile Send private message

PostPosted: Mon Aug 07, 2017 12:14 am     Reply with quote

Probably not by much.

Just the 'numbers' table you showed at the start of your earlier code, occupies 3%. Add the code used for each routine, and 7% sounds very reasonable. However remember that things like this are only loaded once, so as your code gets larger, it will grow more slowly.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page Previous  1, 2
Page 2 of 2

 
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