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

memcopy problem

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



Joined: 09 Aug 2007
Posts: 82
Location: TN, India

View user's profile Send private message Send e-mail

memcopy problem
PostPosted: Sat Jun 20, 2009 8:59 am     Reply with quote

Dear CCS friends,

i use memcopy command for 128 x64 display program.. if try to copy 5 variable from Font2[] array into pixaldata[5] array. so that i use following code..

Code:
void glcd_text57(int8 x, int8 y, char textptr, int8 size, int1 color)
{
   unsigned char j, k, l, m;                       // Loop counters
   unsigned char pixelData[5];                     // Stores character data

 k=0;
memcpy(pixelData,FONT2[textptr[k]-'S'], 5);

   for ( j =0; j<5;j++)
    {
       printf("Font2[%u]=%X\n\r",j,pixelData[j]);
    }

}


Font2 array is

Code:
const int8 FONT2[44][5]={0x26, 0x49, 0x49, 0x49, 0x32, // S
                         0x01, 0x01, 0x7F, 0x01, 0x01, // T
                         0x3F, 0x40, 0x40, 0x40, 0x3F, // U
                         0x1F, 0x20, 0x40, 0x20, 0x1F, // V
                         0x7F, 0x20, 0x10, 0x20, 0x7F, // W
                         0x41, 0x22, 0x1C, 0x22, 0x41, // X
                         0x07, 0x08, 0x70, 0x08, 0x07, // Y
                         0x61, 0x51, 0x49, 0x45, 0x43, // Z
                         0x00, 0x7F, 0x41, 0x00, 0x00, // [
                         0x02, 0x04, 0x08, 0x10, 0x20, // \
                         0x00, 0x00, 0x41, 0x7F, 0x00, // ]
                         0x04, 0x02, 0x01, 0x02, 0x04, // ^
                         0x40, 0x40, 0x40, 0x40, 0x40, // _
                         0x00, 0x01, 0x02, 0x04, 0x00, // `
                         0x20, 0x54, 0x54, 0x54, 0x78, // a
                         0x7F, 0x44, 0x44, 0x44, 0x38, // b
                         0x38, 0x44, 0x44, 0x44, 0x44, // c
                         0x38, 0x44, 0x44, 0x44, 0x7F, // d
                         0x38, 0x54, 0x54, 0x54, 0x18, // e
                         0x04, 0x04, 0x7E, 0x05, 0x05, // f
                         0x08, 0x54, 0x54, 0x54, 0x3C, // g
                         0x7F, 0x08, 0x04, 0x04, 0x78, // h
                         0x00, 0x44, 0x7D, 0x40, 0x00, // i
                         0x20, 0x40, 0x44, 0x3D, 0x00, // j
                         0x7F, 0x10, 0x28, 0x44, 0x00, // k
                         0x00, 0x41, 0x7F, 0x40, 0x00, // l
                         0x7C, 0x04, 0x78, 0x04, 0x78, // m
                         0x7C, 0x08, 0x04, 0x04, 0x78, // n
                         0x38, 0x44, 0x44, 0x44, 0x38, // o
                         0x7C, 0x14, 0x14, 0x14, 0x08, // p
                         0x08, 0x14, 0x14, 0x14, 0x7C, // q
                         0x00, 0x7C, 0x08, 0x04, 0x04, // r
                         0x48, 0x54, 0x54, 0x54, 0x20, // s
                         0x04, 0x04, 0x3F, 0x44, 0x44, // t
                         0x3C, 0x40, 0x40, 0x20, 0x7C, // u
                         0x1C, 0x20, 0x40, 0x20, 0x1C, // v
                         0x3C, 0x40, 0x30, 0x40, 0x3C, // w
                         0x44, 0x28, 0x10, 0x28, 0x44, // x
                         0x0C, 0x50, 0x50, 0x50, 0x3C, // y
                         0x44, 0x64, 0x54, 0x4C, 0x44, // z
                         0x00, 0x08, 0x36, 0x41, 0x41, // {
                         0x00, 0x00, 0x7F, 0x00, 0x00, // |
                         0x41, 0x41, 0x36, 0x08, 0x00, // }
                         0x02, 0x01, 0x02, 0x04, 0x02};// ~



when exectu the code, my result is like below

Font2[0]=00
Font2[1]=00
Font2[2]=00
Font2[3]=00
Font2[4]=00

instant of

Font2[0]=26
Font2[1]=49
Font2[2]=49
Font2[3]=49
Font2[4]=32

i dont know what is problem with memcopy command..

i check below command

Code:
memcpy(pixelData,FONT2[0], 5);


its give correct answer...
Guest








PostPosted: Sat Jun 20, 2009 9:16 am     Reply with quote

Just wonder what this is?
Code:
FONT2[textptr[k]-'S']


textptr is a int8/char but you access it as an array?
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Sun Jun 21, 2009 2:07 am     Reply with quote

Yes, it isn't a memcopy problem. The code works when defining textptr correctly
Quote:
void glcd_text57(int8 x, int8 y, char *textptr, int8 size, int1 color)
karthickiw



Joined: 09 Aug 2007
Posts: 82
Location: TN, India

View user's profile Send private message Send e-mail

thank you
PostPosted: Sun Jun 21, 2009 6:54 am     Reply with quote

FvM wrote:
Yes, it isn't a memcopy problem. The code works when defining textptr correctly
Quote:
void glcd_text57(int8 x, int8 y, char *textptr, int8 size, int1 color)


Thank you FvM. I finished my function using other method. Cool
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