# Drawing a continuous line

Hello everyone.
I am desparately looking for help here. I have a function which generates a set of integers startng from 0-1023.I want to display this values on a LCD in the form of continuous line across the LCD screen.

For example,if I have a value of 1000,it should represent a dot with some radius(not essential)on the LCD screen.Again if i have a value of 1023,it should represent a different point.The line can be irregular but continuous.The standard or can be used here.

The function to be used is shown below(also check the attachment)

{
//code to display circle on LCD
}

char s[3];
s[3]=a2%10 + '0';
a2=a2/10;
s[2]=a2%10 + '0';
a2=a2/10;
s[1]=a2%10 + '0';
a2=a2/10;
s[0]=a2%10 + '0';
int x=strlen(&s);

#ifdef Ascii8x16

Lcd_DspAscII8X16(100,50,BLACK, &s); //s ponting to random number

#endif

void Lcd_DspAscII8X16(U16 x0, U16 y0, INT8U ForeColor, INT8U * s)
{
INT16 i,j,k,x,y,xx;
INT8U qm;
S32 ulOffset;
INT8 ywbuf[16],temp[2];

for(i = 0; i < strlen((const char*)s); i++)
{
if((INT8U)*(s+i) >= 161)
{
temp[0] = *(s + i);
temp[1] = '';
return;
}
else
{
qm = *(s+i);
ulOffset = (S32)(qm) * 16; //Here to be changed tomorrow
for (j = 0; j < 16; j ++)
{
ywbuf[j] = g_auc_Ascii8x16[ulOffset + j];
}

for(y = 0; y < 16; y++)
{
for(x = 0; x < 8; x++)
{
k = x % 8;
if (ywbuf[y] & (0x80 >> k))
{
xx = x0 + x + i*8;
PutPixel( xx, y + y0, (INT8U)ForeColor);
}
}
}
}
}
}
#endif

• : char s[3];
: s[3]=a2%10 + '0';
: a2=a2/10;
: s[2]=a2%10 + '0';
: a2=a2/10;
: s[1]=a2%10 + '0';
: a2=a2/10;
: s[0]=a2%10 + '0';
: int x=strlen(&s);

You seem unfamiliar with string handling in C/C++. First of all, you are trying to put 4 tokens into an array of 3 bytes which will make the program crash.

Second, you are calling strlen() on a non-null terminated string, which will make the program crash.

The correct code would be:

[code]
char s[4+1];

s[3]=a2%10 + '0';
a2=a2/10;
s[2]=a2%10 + '0';
a2=a2/10;
s[1]=a2%10 + '0';
a2=a2/10;
s[0]=a2%10 + '0';

s[4] = ''; // null termination

int x=strlen(s);[/code]

• Hello Lundin,
Thank you for the reply.Yeah i have made the changes as you pointed out.It works...Thanks again

• Hello Lundin,
Thank you for the reply.Yeah i have made the changes as you pointed out.It works...Thanks again

• Hello Lundin,
Thank you for the reply.Yeah i have made the changes as you pointed out.It works...Thanks again