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

Image Location on 128x64 GLD Display

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



Joined: 06 Aug 2015
Posts: 10

View user's profile Send private message

Image Location on 128x64 GLD Display
PostPosted: Wed Aug 19, 2015 11:17 pm     Reply with quote

Hi Guys,

Typically when we want to display an image onto a 128x64 GLCD the byte array size is 64X16. To save space, I have a small image byte array 22x3. I would like to know how I can control where on the 128X64 the image is displayed (how to display it in the top left corner/ top right corner/ middle of screen etc.) I'm using the CCS HDM64GS12.c and graphics.c libraries...

Below is the code which writes the byte array onto the GLCD.
Code:
 

void glcd_imagem(int8 imagem);

const int8 imagem_1[22][3] = {
0x01, 0xFC, 0x00,
0x03, 0x03, 0x00,
0x04, 0x01, 0x00,
0x08, 0x00, 0x80,
0x08, 0x00, 0x80,
0x08, 0x00, 0x00,
0x08, 0x10, 0x00,
0x09, 0xA4, 0x80,
0x09, 0x5C, 0x80,
0x04, 0x09, 0x80,
0x06, 0x01, 0x00,
0x02, 0x02, 0x00,
0x01, 0x42, 0x00,
0x01, 0x04, 0x00,
0x01, 0xFC, 0x00,
0x01, 0x04, 0x00,
0x01, 0xFC, 0x00,
0x01, 0xFC, 0x00,
0x00, 0xD8, 0x00,
0x00, 0x20, 0x00,
0x00, 0x00, 0x00,
0x00, 0x00, 0x00,
0x00, 0x00, 0x00
};


void glcd_imagem(int8 imagem){
   
   char i,j;
   signed char k;
   
      if(imagem==1){
      for( i = 0 ; i < 22 ; i++ ){
         for( j = 0 ; j < 3 ; j++){   
         for(k=100;k>-1;k--){     
         if( bit_test(imagem_1[i][j] ,100-k ))
         glcd_pixel( j*8+k,i, ON );
         }
       }
      }
   }
}



After playing with the code above I've discovered that by changing the 100 value, the image is shifted left or right. However, I do not understand why (help here is also greatly appreciated).

Can someone help explain what the the code is actually doing and how i can adjust the image up and down...


Thanks in Advance
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Aug 19, 2015 11:42 pm     Reply with quote

Add int8 parameters of x, y to your glcd_imagem() function declaration.
Then inside that function, modify your call to glcd_pixel() to this:
Code:
glcd_pixel( (j*8+k) +x, i +y , ON );

This modification adds the x, y offset from the origin to all pixel draws.
Micro_Guy



Joined: 06 Aug 2015
Posts: 10

View user's profile Send private message

PostPosted: Wed Aug 19, 2015 11:59 pm     Reply with quote

Sucess!!!

Thanks PCM Programmer!!!

Do you think you could shine some insight as to what's going on with the following code.

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


I'm fairly new to programming and would like to better understand arrays and how they can be manipulated. I want to actually know what's going on instead of just manipulating code.


Thanks
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Aug 20, 2015 12:13 am     Reply with quote

I don't know. I hoped you were going to explain it to me. Shocked Smile
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