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 Image

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



Joined: 07 Feb 2012
Posts: 34

View user's profile Send private message

GLCD Image
PostPosted: Fri Mar 16, 2012 5:11 am     Reply with quote

Hello evrybody!!
i want to display a Bmp image using pic18f452 and GLCD(128x64) (ks0108 controller),i didn't find a software that convert Bmp to hex
So i tried a one that convert to decimal, i used a method already found it in this forum topics
But i got nothing just random display.
how to make this works
Code:

const int 8 image [64][16]={
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
 255,255,255,255,255,255,255,127,127,127, 63, 63, 63, 31, 31, 31,
  15, 47, 47, 47, 39, 23,135,135,135,131,  3,  3,  3,  3,  3,  1,
   1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0,  0,
   0,  1,  1,  0,  0,  0,  1, 33, 33, 33, 33, 33, 97, 97, 97, 97,
  97,195,195,195,131,131,131,135,  7,  7,  7,  7, 15, 15, 15, 15,
  31, 31, 31, 63, 63, 63,127,127,127,255,255,255,255,255,255,255,
 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
 255,255,255,255,255,255,255,255,255,127,127, 63, 31, 31, 15,  7,
   7,  3,  3,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  4,  6,
   4,  4,  6, 14, 30,159,255,255,255,255,255,254,252,252,252,244,
 164,180,148, 20, 24, 88, 80,242,242,242,240,240,240,248,240, 48,
  24,  8,  8,  0,  0,  0,  0,  0,  0,  0,  0,  0,192,192,144,128,
   0,  0,  0,  0,  1,  3,  3,  3,  7,  6,  8,  0,  0,  0,  0,  0,
   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  1,  1,  3,  3,  7,
   7, 15, 31, 31, 63, 63,127,255,255,255,255,255,255,255,255,255,
 255,255,127, 31, 15,  7,  3,  1,  0,  0,  0,  0,  0,  0,  0,  0,
   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
   0,  0,  0,  0,128,134,255,255,254,252,254,255,255,255,255,255,
 255,255,127,127,255,255,255,127,125,236,230,199,199,207,191,190,
 252,252,124,124, 60, 24, 56, 56,120,120,224,224,192,192,255,255,
 127,127,238,255,255,253, 61,153,200,206, 12,  4,  4,  0,  0,  8,
  16,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
   0,  0,  0,  0,  0,  0,  0,  0,  1,  3,  7, 15, 31,127,255,255,
  15,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
   0, 44,126,255,255,255,255,255,127,255,255,183,183,255,255,255,
 255,255,255,255,255,255,255,255,255,252,251,255,255,255,255,255,
 255,255,254,254,254,254,240,224,240,252,248,240,224,240,241,243,
 249,249,249,159, 15, 23,  7,  7,  1,  0,  0,  0,  0,  0,  0,  0,
   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  1,  7,
 224,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
   0,  0,  0,  0,  0,  7,  3,  3,  3, 15, 31, 63, 63,127,255,255,
 255,255,255,255,255,255,255,255,255,255,191, 63, 31, 31, 31, 31,
  31, 31, 31, 31, 31, 31, 15, 15, 13, 15, 15, 15, 15, 15, 31, 55,
   3,  3,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,192,
 255,255,252,248,224,192,128,  0,  0,  0,  0,  0,  0,  0,  0,  0,
   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  1,
   1, 15, 15, 31, 31, 31, 31, 63, 63, 63, 57, 48, 32, 32,  0,  0,
   0, 64, 64, 96,224,240,112,176,136,128,128,128,128,128,  0,  0,
   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
   0,  0,  0,  0,  0,  0,128,128,128,128,128,128,  0,  0,  0,128,
 128,128,  0,  0,  0,  0,  0,  0,  0,128,192,224,240,252,255,255,
 255,255,255,255,255,255,255,255,254,252,252,248,240,240,224,192,
 192,128,128,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  3,  0,  0,
   0,  0,  0,  0,128,192,192,236,252,252,254,254,255,254,254,255,
 255,255,255,255,255,255,255,255,255,255,127,127, 63,191,159,223,
 205,236,246,242,249,253,252,254,255,255,255,255,255,255,255,255,
 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
 255,255,255,255,255,254,254,254,252,252,248,248,248,240,240,240,
 240,224,224,224,192,192,192,192,192,128,128,128,128,128,128,128,
   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
   0,128,128,131,131,135,135,199,199,199,199,199,239,239,239,247,
 247,247,243,251,251,249,253,253,254,254,254,255,255,255,255,255,
 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255
};

//display function is :
void glcd_image()
{
char i,j;
signed char k;

for( i = 0 ; i < 64 ; i ++ )
{

for( j = 0 ; j < 16 ; j ++)
{
for(k=7;k>-1;--k)
{
if( bit_test(image[i][j] ,7-k ))
glcd_pixel( j*8+k,i, ON );
}
}
}
}


void main()
{
................
.
.
glcd_image();
}


is it obligatory to convert to hex ???
_________________
NOway!!


Last edited by exodia505 on Fri Mar 16, 2012 8:10 am; edited 3 times in total
temtronic



Joined: 01 Jul 2010
Posts: 9170
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Fri Mar 16, 2012 6:06 am     Reply with quote

Do yourself a BIG favour !!

in your program...

if( bit_test(image[i][j] ,7-k ))
glcd_pixel( j*8+k,i, ON );

...

Insert code to printout the variables i,j,7-k, etc.... ALL of them
saving to a file on a PC terminal program.

Then compare what IS being send to the GLCD as data to what you WANT to be sent there!

Also I woudln't be using signed variables for simple counters ( k ) , not needed. CCS C is smart, you just need to recode the for(....) loop.
exodia505



Joined: 07 Feb 2012
Posts: 34

View user's profile Send private message

PostPosted: Fri Mar 16, 2012 1:36 pm     Reply with quote

I tried the function with another picture (hex) not mine and it worked
pretty good so, i think problem is in image matrix.
How to convert it to [64][16] hex ?
_________________
NOway!!
exodia505



Joined: 07 Feb 2012
Posts: 34

View user's profile Send private message

PostPosted: Sat Mar 17, 2012 1:54 pm     Reply with quote

I always fix my problems alone.
!!! hehe it works.
_________________
NOway!!
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