|
|
View previous topic :: View next topic |
Author |
Message |
Micro_Guy
Joined: 06 Aug 2015 Posts: 10
|
Image Location on 128x64 GLD Display |
Posted: Wed Aug 19, 2015 11:17 pm |
|
|
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
|
|
Posted: Wed Aug 19, 2015 11:42 pm |
|
|
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
|
|
Posted: Wed Aug 19, 2015 11:59 pm |
|
|
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
|
|
Posted: Thu Aug 20, 2015 12:13 am |
|
|
I don't know. I hoped you were going to explain it to me. |
|
|
|
|
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
|